diff --git a/api/src/utils/lib.rs b/api/src/utils/lib.rs index 7deff8fb..8858060a 100644 --- a/api/src/utils/lib.rs +++ b/api/src/utils/lib.rs @@ -8,13 +8,13 @@ pub const DEFAULT_CAIRO_DIR: &str = concat!( env!("CARGO_MANIFEST_DIR"), "/", "cairo_compilers/", - "v2.3.0" + "v2.3.1" ); pub const CAIRO_COMPILERS_DIR: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/", "cairo_compilers/"); #[allow(dead_code)] pub const TEMP_DIR: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/", "temp/"); -pub const DEFAULT_CAIRO_VERSION: &str = "v2.3.0"; +pub const DEFAULT_CAIRO_VERSION: &str = "v2.3.1"; pub const DURATION_TO_PURGE: u64 = 60 * 5; // 5 minutes diff --git a/plugin/pnpm-lock.yaml b/plugin/pnpm-lock.yaml index c01458d2..e496a1da 100644 --- a/plugin/pnpm-lock.yaml +++ b/plugin/pnpm-lock.yaml @@ -1,9 +1,5 @@ lockfileVersion: '6.0' -settings: - autoInstallPeers: true - excludeLinksFromLockfile: false - dependencies: '@radix-ui/react-accordion': specifier: ^1.1.2 @@ -4908,3 +4904,7 @@ packages: toposort: 2.0.2 type-fest: 2.19.0 dev: false + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false diff --git a/plugin/src/atoms/connection.ts b/plugin/src/atoms/connection.ts new file mode 100644 index 00000000..1a036b4f --- /dev/null +++ b/plugin/src/atoms/connection.ts @@ -0,0 +1,15 @@ +import { atom } from 'jotai' +import { + type Account, + type AccountInterface, + type Provider, + type ProviderInterface +} from 'starknet' + +import { type StarknetWindowObject } from 'get-starknet' + +const account = atom(null) +const provider = atom(null) +const starknetWindowObject = atom(null) + +export { account, provider, starknetWindowObject } diff --git a/plugin/src/atoms/remixClient.ts b/plugin/src/atoms/remixClient.ts new file mode 100644 index 00000000..23958826 --- /dev/null +++ b/plugin/src/atoms/remixClient.ts @@ -0,0 +1,6 @@ +import { atom } from 'jotai' + +// Is plugin loaded +const pluginLoaded = atom(true) + +export { pluginLoaded } diff --git a/plugin/src/components/DevnetAccountSelector/index.tsx b/plugin/src/components/DevnetAccountSelector/index.tsx index 2d4247b2..04720624 100644 --- a/plugin/src/components/DevnetAccountSelector/index.tsx +++ b/plugin/src/components/DevnetAccountSelector/index.tsx @@ -214,37 +214,6 @@ const DevnetAccountSelector: React.FC = () => { - {/* */}
)} - - {account != null && - selectedContract.deployedInfo.some( - (info) => - info.address === account.address && info.chainId === chainId - ) && ( -
- + ? 'not-allowed' + : 'pointer' + }` + }} + disabled={ + isDeploying || + account == null || + selectedContract.deployedInfo.some( + (info) => + info.address === account.address && + info.chainId === chainId + ) + } + aria-disabled={ + isDeploying || + account == null || + selectedContract.deployedInfo.some( + (info) => + info.address === account.address && + info.chainId === chainId + ) + } + type="submit" + > +
+
+ {isDeploying + ? ( + <> + + + {deployStatus} + + + ) + : ( +
+ {account != null && + selectedContract.deployedInfo.some( + (info) => + info.address === account.address && + info.chainId === chainId + ) + ? ( + + {' '} + Deployed {' '} + {selectedContract.name} + + ) + : ( + Deploy {selectedContract.name} + )} +
+ )}
- )} - {notEnoughInputs && ( - - )} -
+
+ + + {account != null && + selectedContract.deployedInfo.some( + (info) => + info.address === account.address && info.chainId === chainId + ) && ( +
+ +
+ )} + {notEnoughInputs && ( + + )} + ) : ( -

No contracts ready for deployment yet, compile a cairo contract

+

No contracts ready for deployment yet, compile a cairo contract

)} diff --git a/plugin/src/hooks/starknetWindow.ts b/plugin/src/hooks/starknetWindow.ts index 93991b2c..19271cd4 100644 --- a/plugin/src/hooks/starknetWindow.ts +++ b/plugin/src/hooks/starknetWindow.ts @@ -9,6 +9,8 @@ import { useEffect, useState } from 'react' import useAccount from './useAccount' import useProvider from './useProvider' import useRemixClient from './useRemixClient' +import { starknetWindowObject as stObj } from '../atoms/connection' +import { useAtom } from 'jotai' const useStarknetWindow = (): { starknetWindowObject: StarknetWindowObject | null @@ -18,11 +20,12 @@ const useStarknetWindow = (): { disconnectWalletHandler: (options?: DisconnectOptions) => Promise refreshWalletConnection: () => Promise } => { + const [starknetWindowObject, setStarknetWindowObject] = useAtom(stObj) + const { remixClient } = useRemixClient() const { setAccount } = useAccount() const { setProvider } = useProvider() - const [starknetWindowObject, setStarknetWindowObject] = useState(null) const [currentChainId, setCurrentChainId] = useState(undefined) const getChainId = async (): Promise => { if (starknetWindowObject != null) { diff --git a/plugin/src/hooks/useAccount.ts b/plugin/src/hooks/useAccount.ts index b5082078..06f1c7e8 100644 --- a/plugin/src/hooks/useAccount.ts +++ b/plugin/src/hooks/useAccount.ts @@ -1,15 +1,14 @@ import type React from 'react' -import { useState } from 'react' import { type Account, type AccountInterface } from 'starknet' +import { account as atomAccount } from '../atoms/connection' +import { useAtom } from 'jotai' + const useAccount = (): { account: Account | AccountInterface | null setAccount: React.Dispatch> } => { - const [account, setAccount] = useState( - null - ) - + const [account, setAccount] = useAtom(atomAccount) return { account, setAccount } } diff --git a/plugin/src/hooks/useProvider.ts b/plugin/src/hooks/useProvider.ts index d2909a26..ae799b78 100644 --- a/plugin/src/hooks/useProvider.ts +++ b/plugin/src/hooks/useProvider.ts @@ -1,14 +1,13 @@ import type React from 'react' -import { useState } from 'react' import { type Provider, type ProviderInterface } from 'starknet' +import { provider as atomProvider } from '../atoms/connection' +import { useAtom } from 'jotai' const useProvider = (): { provider: Provider | ProviderInterface | null setProvider: React.Dispatch> } => { - const [provider, setProvider] = useState( - null - ) + const [provider, setProvider] = useAtom(atomProvider) return { provider, setProvider } } diff --git a/plugin/src/hooks/useRemixClient.ts b/plugin/src/hooks/useRemixClient.ts index e70a013b..f9260c9d 100644 --- a/plugin/src/hooks/useRemixClient.ts +++ b/plugin/src/hooks/useRemixClient.ts @@ -1,7 +1,9 @@ import { PluginClient } from '@remixproject/plugin' import { createClient } from '@remixproject/plugin-webview' -import { useEffect, useState } from 'react' +import { useEffect } from 'react' import { fetchGitHubFilesRecursively } from '../utils/initial_scarb_codes' +import { pluginLoaded as atomPluginLoaded } from '../atoms/remixClient' +import { useAtom } from 'jotai' const remixClient = createClient(new PluginClient()) @@ -9,7 +11,7 @@ const useRemixClient = (): { remixClient: typeof remixClient isPluginLoaded: boolean } => { - const [pluginLoaded, setPluginLoaded] = useState(false) + const [pluginLoaded, setPluginLoaded] = useAtom(atomPluginLoaded) useEffect(() => { // eslint-disable-next-line @typescript-eslint/no-misused-promises