Skip to content

Commit

Permalink
Merge pull request #3 from strkfarm/akira/dnmm
Browse files Browse the repository at this point in the history
fix auto wallet connect and double your holdings bug
  • Loading branch information
akiraonstarknet authored Jun 23, 2024
2 parents 918e790 + 5266142 commit ac6d935
Show file tree
Hide file tree
Showing 5 changed files with 197 additions and 7 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"react-responsive-carousel": "3.2.23",
"react-select": "5.8.0",
"react-share": "5.1.0",
"sharp": "^0.33.4",
"starknet": "6.4.1",
"starknetkit": "1.1.9",
"swr": "2.2.5",
Expand Down
5 changes: 2 additions & 3 deletions src/app/strategy/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ export default function Strategy() {
{!balData.isLoading &&
!balData.isError &&
!balData.isPending &&
balData.data && (
balData.data &&
balData.data.tokenInfo && (
<Text>
<b>Your Holdings: </b>
{address
Expand Down Expand Up @@ -338,7 +339,6 @@ export default function Strategy() {
<Text
display={{ base: 'none', md: 'block' }}
width={{ base: '100%', md: '10%' }}
className="text-cell"
textAlign={'right'}
padding={'5px 10px'}
>
Expand All @@ -347,7 +347,6 @@ export default function Strategy() {
<Text
display={{ base: 'none', md: 'block' }}
width={{ base: '100%', md: '10%' }}
className="text-cell"
textAlign={'right'}
padding={'5px 10px'}
>
Expand Down
4 changes: 2 additions & 2 deletions src/app/template.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import * as React from 'react';
import { RpcProviderOptions, constants } from 'starknet';
import { ArgentMobileConnector } from 'starknetkit/argentMobile';
import { InjectedConnector } from 'starknetkit/injected';
import { WebWalletConnector } from 'starknetkit/webwallet';

import Navbar from '@/components/Navbar';
import { Toaster } from 'react-hot-toast';
Expand Down Expand Up @@ -70,11 +69,12 @@ BigInt.prototype.toJSON = function () {
return this.toString();
};

export const CONNECTOR_NAMES = ['Braavos', 'Argent X', 'Argent (mobile)']; // 'Argent Web Wallet'];
export const MYCONNECTORS = [
new InjectedConnector({ options: { id: 'braavos', name: 'Braavos' } }),
new InjectedConnector({ options: { id: 'argentX', name: 'Argent X' } }),
new WebWalletConnector({ url: 'https://web.argent.xyz' }),
new ArgentMobileConnector(),
// new WebWalletConnector({ url: 'https://web.argent.xyz' }),
];

export default function Template({ children }: { children: React.ReactNode }) {
Expand Down
10 changes: 9 additions & 1 deletion src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { MyMenuItemProps, MyMenuListProps, shortAddress } from '@/utils';
import { useEffect } from 'react';
import { lastWalletAtom } from '@/store/utils.atoms';
import { useAccount, useConnect, useDisconnect } from '@starknet-react/core';
import { CONNECTOR_NAMES, MYCONNECTORS } from '@/app/template';

export default function Navbar() {
const { address, connector } = useAccount();
Expand All @@ -37,13 +38,15 @@ export default function Navbar() {
useStarknetkitConnectModal({
modalMode: 'canAsk',
modalTheme: 'dark',
connectors: MYCONNECTORS,
});

// backup
const { starknetkitConnectModal: starknetkitConnectModal2 } =
useStarknetkitConnectModal({
modalMode: 'alwaysAsk',
modalTheme: 'dark',
connectors: MYCONNECTORS,
});

// Connect wallet using starknetkit
Expand All @@ -67,7 +70,12 @@ export default function Navbar() {
console.log('lastWallet', lastWallet, connectors);
try {
if (!address && lastWallet) {
connectWallet();
const connectorIndex = CONNECTOR_NAMES.findIndex(
(name) => name === lastWallet,
);
if (connectorIndex >= 0) {
connect({ connector: MYCONNECTORS[connectorIndex] });
}
}
} catch (error) {
console.error('lastWallet error', error);
Expand Down
184 changes: 183 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,13 @@
resolved "https://registry.npmjs.org/@chakra-ui/visually-hidden/-/visually-hidden-2.2.0.tgz"
integrity sha512-KmKDg01SrQ7VbTD3+cPWf/UfpF5MSwm3v7MWi0n5t8HnnadT13MF0MJCDSXbBWnzLv1ZKJ6zlyAOeARWX+DpjQ==

"@emnapi/runtime@^1.1.1":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@emnapi/runtime/-/runtime-1.2.0.tgz#71d018546c3a91f3b51106530edbc056b9f2f2e3"
integrity sha512-bV21/9LQmcQeCPEg3BDFtvwL6cwiTMksYNWQQ4KOxCZikEGalWtenoZ0wCiukJINlGCIi2KXx01g4FoH/LxpzQ==
dependencies:
tslib "^2.4.0"

"@emotion/babel-plugin@^11.11.0":
version "11.11.0"
resolved "https://registry.npmjs.org/@emotion/babel-plugin/-/babel-plugin-11.11.0.tgz"
Expand Down Expand Up @@ -1092,6 +1099,119 @@
resolved "https://registry.npmjs.org/@hutson/parse-repository-url/-/parse-repository-url-5.0.0.tgz"
integrity sha512-e5+YUKENATs1JgYHMzTr2MW/NDcXGfYFAuOQU8gJgF/kEh4EqKgfGrfLI67bMD4tbhZVlkigz/9YYwWcbOFthg==

"@img/[email protected]":
version "0.33.4"
resolved "https://registry.yarnpkg.com/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.33.4.tgz#a1cf4a7febece334f16e0328b9689f05797d7aec"
integrity sha512-p0suNqXufJs9t3RqLBO6vvrgr5OhgbWp76s5gTRvdmxmuv9E1rcaqGUsl3l4mKVmXPkTkTErXediAui4x+8PSA==
optionalDependencies:
"@img/sharp-libvips-darwin-arm64" "1.0.2"

"@img/[email protected]":
version "0.33.4"
resolved "https://registry.yarnpkg.com/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.33.4.tgz#f77be2d7c3609d3e77cd337b199a772e07b87bd2"
integrity sha512-0l7yRObwtTi82Z6ebVI2PnHT8EB2NxBgpK2MiKJZJ7cz32R4lxd001ecMhzzsZig3Yv9oclvqqdV93jo9hy+Dw==
optionalDependencies:
"@img/sharp-libvips-darwin-x64" "1.0.2"

"@img/[email protected]":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.0.2.tgz#b69f49fecbe9572378675769b189410721b0fa53"
integrity sha512-tcK/41Rq8IKlSaKRCCAuuY3lDJjQnYIW1UXU1kxcEKrfL8WR7N6+rzNoOxoQRJWTAECuKwgAHnPvqXGN8XfkHA==

"@img/[email protected]":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.0.2.tgz#5665da7360d8e5ed7bee314491c8fe736b6a3c39"
integrity sha512-Ofw+7oaWa0HiiMiKWqqaZbaYV3/UGL2wAPeLuJTx+9cXpCRdvQhCLG0IH8YGwM0yGWGLpsF4Su9vM1o6aer+Fw==

"@img/[email protected]":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.0.2.tgz#8a05e5e9e9b760ff46561e32f19bd5e035fa881c"
integrity sha512-x7kCt3N00ofFmmkkdshwj3vGPCnmiDh7Gwnd4nUwZln2YjqPxV1NlTyZOvoDWdKQVDL911487HOueBvrpflagw==

"@img/[email protected]":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.0.2.tgz#0fd33b9bf3221948ce0ca7a5a725942626577a03"
integrity sha512-iLWCvrKgeFoglQxdEwzu1eQV04o8YeYGFXtfWU26Zr2wWT3q3MTzC+QTCO3ZQfWd3doKHT4Pm2kRmLbupT+sZw==

"@img/[email protected]":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.0.2.tgz#4b89150ec91b256ee2cbb5bb125321bf029a4770"
integrity sha512-cmhQ1J4qVhfmS6szYW7RT+gLJq9dH2i4maq+qyXayUSn9/3iY2ZeWpbAgSpSVbV2E1JUL2Gg7pwnYQ1h8rQIog==

"@img/[email protected]":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.0.2.tgz#947ccc22ca5bc8c8cfe921b39a5fdaebc5e39f3f"
integrity sha512-E441q4Qdb+7yuyiADVi5J+44x8ctlrqn8XgkDTwr4qPJzWkaHwD489iZ4nGDgcuya4iMN3ULV6NwbhRZJ9Z7SQ==

"@img/[email protected]":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.0.2.tgz#821d58ce774f0f8bed065b69913a62f65d512f2f"
integrity sha512-3CAkndNpYUrlDqkCM5qhksfE+qSIREVpyoeHIU6jd48SJZViAmznoQQLAv4hVXF7xyUB9zf+G++e2v1ABjCbEQ==

"@img/[email protected]":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.0.2.tgz#4309474bd8b728a61af0b3b4fad0c476b5f3ccbe"
integrity sha512-VI94Q6khIHqHWNOh6LLdm9s2Ry4zdjWJwH56WoiJU7NTeDwyApdZZ8c+SADC8OH98KWNQXnE01UdJ9CSfZvwZw==

"@img/[email protected]":
version "0.33.4"
resolved "https://registry.yarnpkg.com/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.33.4.tgz#bd390113e256487041411b988ded13a26cfc5f95"
integrity sha512-2800clwVg1ZQtxwSoTlHvtm9ObgAax7V6MTAB/hDT945Tfyy3hVkmiHpeLPCKYqYR1Gcmv1uDZ3a4OFwkdBL7Q==
optionalDependencies:
"@img/sharp-libvips-linux-arm64" "1.0.2"

"@img/[email protected]":
version "0.33.4"
resolved "https://registry.yarnpkg.com/@img/sharp-linux-arm/-/sharp-linux-arm-0.33.4.tgz#14ecc81f38f75fb4cd7571bc83311746d6745fca"
integrity sha512-RUgBD1c0+gCYZGCCe6mMdTiOFS0Zc/XrN0fYd6hISIKcDUbAW5NtSQW9g/powkrXYm6Vzwd6y+fqmExDuCdHNQ==
optionalDependencies:
"@img/sharp-libvips-linux-arm" "1.0.2"

"@img/[email protected]":
version "0.33.4"
resolved "https://registry.yarnpkg.com/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.33.4.tgz#119e8081e2c6741b5ac908fe02244e4c559e525f"
integrity sha512-h3RAL3siQoyzSoH36tUeS0PDmb5wINKGYzcLB5C6DIiAn2F3udeFAum+gj8IbA/82+8RGCTn7XW8WTFnqag4tQ==
optionalDependencies:
"@img/sharp-libvips-linux-s390x" "1.0.2"

"@img/[email protected]":
version "0.33.4"
resolved "https://registry.yarnpkg.com/@img/sharp-linux-x64/-/sharp-linux-x64-0.33.4.tgz#21d4c137b8da9a313b069ff5c920ded709f853d7"
integrity sha512-GoR++s0XW9DGVi8SUGQ/U4AeIzLdNjHka6jidVwapQ/JebGVQIpi52OdyxCNVRE++n1FCLzjDovJNozif7w/Aw==
optionalDependencies:
"@img/sharp-libvips-linux-x64" "1.0.2"

"@img/[email protected]":
version "0.33.4"
resolved "https://registry.yarnpkg.com/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.33.4.tgz#f3fde68fd67b85a32da6f1155818c3b58b8e7ae0"
integrity sha512-nhr1yC3BlVrKDTl6cO12gTpXMl4ITBUZieehFvMntlCXFzH2bvKG76tBL2Y/OqhupZt81pR7R+Q5YhJxW0rGgQ==
optionalDependencies:
"@img/sharp-libvips-linuxmusl-arm64" "1.0.2"

"@img/[email protected]":
version "0.33.4"
resolved "https://registry.yarnpkg.com/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.33.4.tgz#44373724aecd7b69900e0578228144e181db7892"
integrity sha512-uCPTku0zwqDmZEOi4ILyGdmW76tH7dm8kKlOIV1XC5cLyJ71ENAAqarOHQh0RLfpIpbV5KOpXzdU6XkJtS0daw==
optionalDependencies:
"@img/sharp-libvips-linuxmusl-x64" "1.0.2"

"@img/[email protected]":
version "0.33.4"
resolved "https://registry.yarnpkg.com/@img/sharp-wasm32/-/sharp-wasm32-0.33.4.tgz#88e3f18d7e7cd8cfe1af98e9963db4d7b6491435"
integrity sha512-Bmmauh4sXUsUqkleQahpdNXKvo+wa1V9KhT2pDA4VJGKwnKMJXiSTGphn0gnJrlooda0QxCtXc6RX1XAU6hMnQ==
dependencies:
"@emnapi/runtime" "^1.1.1"

"@img/[email protected]":
version "0.33.4"
resolved "https://registry.yarnpkg.com/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.33.4.tgz#b1c772dd2952e983980b1eb85808fa8129484d46"
integrity sha512-99SJ91XzUhYHbx7uhK3+9Lf7+LjwMGQZMDlO/E/YVJ7Nc3lyDFZPGhjwiYdctoH2BOzW9+TnfqcaMKt0jHLdqw==

"@img/[email protected]":
version "0.33.4"
resolved "https://registry.yarnpkg.com/@img/sharp-win32-x64/-/sharp-win32-x64-0.33.4.tgz#106f911134035b4157ec92a0c154a6b6f88fa4c1"
integrity sha512-3QLocdTRVIrFNye5YocZl+KKpYKP+fksi1QhmOArgx7GyhIbQp/WrJRu176jm8IxromS7RIkzMiMINVdBtC8Aw==

"@isaacs/cliui@^8.0.2":
version "8.0.2"
resolved "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz"
Expand Down Expand Up @@ -2554,16 +2674,32 @@ [email protected]:
resolved "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz"
integrity sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==

color-name@^1.1.4, color-name@~1.1.4:
color-name@^1.0.0, color-name@^1.1.4, color-name@~1.1.4:
version "1.1.4"
resolved "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz"
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==

color-string@^1.9.0:
version "1.9.1"
resolved "https://registry.yarnpkg.com/color-string/-/color-string-1.9.1.tgz#4467f9146f036f855b764dfb5bf8582bf342c7a4"
integrity sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==
dependencies:
color-name "^1.0.0"
simple-swizzle "^0.2.2"

color2k@^2.0.2:
version "2.0.3"
resolved "https://registry.npmjs.org/color2k/-/color2k-2.0.3.tgz"
integrity sha512-zW190nQTIoXcGCaU08DvVNFTmQhUpnJfVuAKfWqUQkflXKpaDdpaYoM0iluLS9lgJNHyBF58KKA2FBEwkD7wog==

color@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/color/-/color-4.2.3.tgz#d781ecb5e57224ee43ea9627560107c0e0c6463a"
integrity sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==
dependencies:
color-convert "^2.0.1"
color-string "^1.9.0"

colorette@^1.2.1:
version "1.4.0"
resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.4.0.tgz#5190fbb87276259a86ad700bff2c6d6faa3fca40"
Expand Down Expand Up @@ -2873,6 +3009,11 @@ detect-libc@^1.0.3:
resolved "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz"
integrity sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg==

detect-libc@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-2.0.3.tgz#f0cd503b40f9939b894697d19ad50895e30cf700"
integrity sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==

detect-node-es@^1.1.0:
version "1.1.0"
resolved "https://registry.npmjs.org/detect-node-es/-/detect-node-es-1.1.0.tgz"
Expand Down Expand Up @@ -3916,6 +4057,11 @@ is-arrayish@^0.2.1:
resolved "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz"
integrity sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==

is-arrayish@^0.3.1:
version "0.3.2"
resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.3.2.tgz#4574a2ae56f7ab206896fb431eaeed066fdf8f03"
integrity sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==

is-async-function@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/is-async-function/-/is-async-function-2.0.0.tgz"
Expand Down Expand Up @@ -5465,6 +5611,35 @@ set-function-name@^2.0.0, set-function-name@^2.0.1:
functions-have-names "^1.2.3"
has-property-descriptors "^1.0.2"

sharp@^0.33.4:
version "0.33.4"
resolved "https://registry.yarnpkg.com/sharp/-/sharp-0.33.4.tgz#b88e6e843e095c6ab5e1a0c59c4885e580cd8405"
integrity sha512-7i/dt5kGl7qR4gwPRD2biwD2/SvBn3O04J77XKFgL2OnZtQw+AG9wnuS/csmu80nPRHLYE9E41fyEiG8nhH6/Q==
dependencies:
color "^4.2.3"
detect-libc "^2.0.3"
semver "^7.6.0"
optionalDependencies:
"@img/sharp-darwin-arm64" "0.33.4"
"@img/sharp-darwin-x64" "0.33.4"
"@img/sharp-libvips-darwin-arm64" "1.0.2"
"@img/sharp-libvips-darwin-x64" "1.0.2"
"@img/sharp-libvips-linux-arm" "1.0.2"
"@img/sharp-libvips-linux-arm64" "1.0.2"
"@img/sharp-libvips-linux-s390x" "1.0.2"
"@img/sharp-libvips-linux-x64" "1.0.2"
"@img/sharp-libvips-linuxmusl-arm64" "1.0.2"
"@img/sharp-libvips-linuxmusl-x64" "1.0.2"
"@img/sharp-linux-arm" "0.33.4"
"@img/sharp-linux-arm64" "0.33.4"
"@img/sharp-linux-s390x" "0.33.4"
"@img/sharp-linux-x64" "0.33.4"
"@img/sharp-linuxmusl-arm64" "0.33.4"
"@img/sharp-linuxmusl-x64" "0.33.4"
"@img/sharp-wasm32" "0.33.4"
"@img/sharp-win32-ia32" "0.33.4"
"@img/sharp-win32-x64" "0.33.4"

shebang-command@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz"
Expand Down Expand Up @@ -5492,6 +5667,13 @@ signal-exit@^4.0.1, signal-exit@^4.1.0:
resolved "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz"
integrity sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==

simple-swizzle@^0.2.2:
version "0.2.2"
resolved "https://registry.yarnpkg.com/simple-swizzle/-/simple-swizzle-0.2.2.tgz#a4da6b635ffcccca33f70d17cb92592de95e557a"
integrity sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==
dependencies:
is-arrayish "^0.3.1"

slash@^3.0.0:
version "3.0.0"
resolved "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz"
Expand Down

0 comments on commit ac6d935

Please sign in to comment.