Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Starknet abi forms #215

Merged
merged 19 commits into from
Dec 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -48,4 +48,6 @@ override.tf.json

# Ignore CLI configuration files
.terraformrc
terraform.rc
terraform.rc

.idea
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@
path = api/cairo_compilers/v2.3.0
url = https://github.com/starkware-libs/cairo.git
branch = v2.3.0

[submodule "api/cairo_compilers/v2.3.1"]
path = api/cairo_compilers/v2.3.1
url = https://github.com/starkware-libs/cairo
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scarb 2.3.1
1 change: 1 addition & 0 deletions plugin/package.json
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@
"react-dom": "^18.2.0",
"react-icons": "^4.10.1",
"starknet": "5.19.5",
"starknet-abi-forms": "^0.1.4",
"vite-plugin-svgr": "^4.0.0",
"web-vitals": "^2.1.4",
"yup": "^1.2.0"
22 changes: 18 additions & 4 deletions plugin/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions plugin/src/App.css
Original file line number Diff line number Diff line change
@@ -6,4 +6,6 @@

.cairo-version-legend {
margin: 0 24px;
display: flex;
flex-direction: row;
}
5 changes: 3 additions & 2 deletions plugin/src/components/BackgroundNotices/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { nanoid } from 'nanoid'
import React from 'react'
import './style.css'

const Notices = [
'The starknet Remix Plugin is in Alpha',
@@ -10,12 +11,12 @@ const Notices = [
const BackgroundNotices: React.FC = () => {
return (
<div className='bg-transparent'>
<p className="text-center text-md text-light">Notices</p>
<p className="text-center text-md bg-notices-text">Notices</p>
{
<ul className="list-group">
{Notices.map((notice, index) => {
return (
<li key={nanoid()} className="list-group-item d-flex justify-content-left align-items-center text-disabled bg-primary">
<li key={nanoid()} className="list-group-item d-flex justify-content-left align-items-center bg-primary bg-notices-text">
<span className="badge badge-information badge-pilled mr-2">
{index + 1}
</span>
3 changes: 3 additions & 0 deletions plugin/src/components/BackgroundNotices/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.bg-notices-text {
color: var(--text);
}
Original file line number Diff line number Diff line change
@@ -6,12 +6,12 @@

.devnet-account-selector-trigger {
width: 100%;
border: 1px solid var(--primary-color-500);
border: 1px solid var(--primary);
}

.text-copied {
top: 0px;
left: 0px;
top: 0;
left: 0;
background: slateblue;
padding: 0.2rem;
}
6 changes: 3 additions & 3 deletions plugin/src/components/EnvCard/envCard.css
Original file line number Diff line number Diff line change
@@ -10,10 +10,10 @@
}

.env-testnet-btn {
border: 1px solid orange;
border: 1px solid var(--orange);
color: var(--white);
}

.env-testnet-btn:hover {
border: 1px solid orange;
}
border: 1px solid var(--orange);
}
4 changes: 2 additions & 2 deletions plugin/src/components/EnvironmentSelector/styles.css
Original file line number Diff line number Diff line change
@@ -3,5 +3,5 @@
}

.devnet-trigger-wrapper {
border: 1px solid var(--primary-color-500);
}
border: 1px solid var(--primary);
}
6 changes: 3 additions & 3 deletions plugin/src/components/ExplorerSelector/index.css
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
overflow: hidden;
text-overflow: ellipsis;
font-weight: 500;
color: var(--secondaryColor);
color: var(--secondary);
}

.img-explorer-logo {
@@ -22,7 +22,7 @@
}

.styled-dropdown-item * {
margin: 0px;
margin: 0;
text-transform: capitalize;
}

@@ -58,4 +58,4 @@
justify-content: flex-start;
gap: 0.5rem;
flex-wrap: wrap;
}
}
107 changes: 59 additions & 48 deletions plugin/src/components/ManualAccount/index.tsx
Original file line number Diff line number Diff line change
@@ -19,11 +19,16 @@ import ExplorerSelector, { useCurrentExplorer } from '../ExplorerSelector'
import { useAtom } from 'jotai'

import transactionsAtom from '../../atoms/transactions'
import { accountAtom, networkAtom, selectedAccountAtom } from '../../atoms/manualAccount'
import {
accountAtom,
networkAtom,
selectedAccountAtom
} from '../../atoms/manualAccount'
import { type Env, envAtom } from '../../atoms/environment'
import useAccount from '../../hooks/useAccount'
import useProvider from '../../hooks/useProvider'
import useRemixClient from '../../hooks/useRemixClient'
import { getProvider } from '../../utils/misc'

// TODOS: move state parts to contexts
// Account address selection
@@ -58,16 +63,8 @@ const ManualAccount: React.FC<{
}, [setNetworkName])

useEffect(() => {
const netName = networkNameEquivalents.get(networkName)
const chainId = networkEquivalents.get(networkName)
if (chainId && netName) {
setProvider(
new RpcProvider({
nodeUrl: netName,
chainId
})
)
}
const prov = getProvider(networkName)
setProvider(prov)
}, [setProvider, networkName])

useEffect(() => {
@@ -115,11 +112,13 @@ const ManualAccount: React.FC<{

const updateBalance = async (): Promise<void> => {
if (account != null && provider != null && selectedAccount != null) {
const resp = await provider.callContract({
console.log(account, provider)
const resp = await account.callContract({
contractAddress: balanceContractAddress,
entrypoint: 'balanceOf',
calldata: [account.address]
})
console.log(resp)
const balance = resp.result[0]
const newAccount = { ...selectedAccount, balance }
const newAccounts = accounts.map((acc) => {
@@ -224,16 +223,18 @@ const ManualAccount: React.FC<{
publicKey: await account.signer.getPubKey()
})

const { transaction_hash: transactionHash, contract_address: contractAddress } =
await account.deployAccount({
classHash: OZaccountClassHash,
constructorCalldata: OZaccountConstructorCallData,
addressSalt: await account.signer.getPubKey()
})
const {
transaction_hash: transactionHash,
contract_address: contractAddress
} = await account.deployAccount({
classHash: OZaccountClassHash,
constructorCalldata: OZaccountConstructorCallData,
addressSalt: await account.signer.getPubKey()
})

console.log('transaction_hash=', transactionHash)

await provider.getTransactionReceipt(transactionHash)
await provider.waitForTransaction(transactionHash)

setTransactions([
{
@@ -313,16 +314,16 @@ const ManualAccount: React.FC<{
? (
accounts.map((account, index) => {
return (
<option value={index} key={index}>
{trimStr(account.address, 6)}
</option>
<option value={index} key={index}>
{trimStr(account.address, 6)}
</option>
)
})
)
: (
<option value={-1} key={-1}>
No account created yet
</option>
<option value={-1} key={-1}>
No account created yet
</option>
)}
</select>
<button
@@ -343,7 +344,10 @@ const ManualAccount: React.FC<{
<p className="m-0">
Address:{' '}
<a
href={`${getExplorerUrl(explorerHook.explorer, networkName as Network)}/contract/${selectedAccount?.address}`}
href={`${getExplorerUrl(
explorerHook.explorer,
networkName as Network
)}/contract/${selectedAccount?.address}`}
target="_blank"
rel="noreferer noopener noreferrer"
>
@@ -392,14 +396,20 @@ const ManualAccount: React.FC<{
</button>
</div>
)}
{networkName === 'goerli-alpha' && (
{networkName === 'goerli' && (
<button
className="btn btn-secondary w-100"
onClick={() => {
copy(selectedAccount?.address ?? '')
remixClient.call('notification' as any, 'toast', 'ℹ️ Address copied to Clipboard').catch((err) => {
console.log(err)
})
remixClient
.call(
'notification' as any,
'toast',
'ℹ️ Address copied to Clipboard'
)
.catch((err) => {
console.log(err)
})
setTimeout(() => {
window?.open(
'https://faucet.goerli.starknet.io/',
@@ -433,12 +443,13 @@ const ManualAccount: React.FC<{
<button
className="btn btn-primary btn-block d-block w-100 text-break remixui_disabled"
style={{
cursor: `${(selectedAccount?.deployed_networks.includes(networkName) ??
false) ||
cursor: `${
(selectedAccount?.deployed_networks.includes(networkName) ??
false) ||
accountDeploying
? 'not-allowed'
: 'pointer'
}`
? 'not-allowed'
: 'pointer'
}`
}}
disabled={
(selectedAccount?.deployed_networks.includes(networkName) ?? false) ||
@@ -455,22 +466,22 @@ const ManualAccount: React.FC<{
>
{accountDeploying
? (
<>
<span
className="spinner-border spinner-border-sm"
role="status"
aria-hidden="true"
/>
<span style={{ paddingLeft: '0.5rem' }}>Deploying Account...</span>
</>
<>
<span
className="spinner-border spinner-border-sm"
role="status"
aria-hidden="true"
/>
<span style={{ paddingLeft: '0.5rem' }}>Deploying Account...</span>
</>
)
: selectedAccount?.deployed_networks.includes(networkName) ??
false
false
? (
<>
<MdCheckCircleOutline color="#0fd543" size={18} />
<span style={{ paddingLeft: '0.5rem' }}>Account Deployed</span>
</>
<>
<MdCheckCircleOutline color="#0fd543" size={18} />
<span style={{ paddingLeft: '0.5rem' }}>Account Deployed</span>
</>
)
: (
'Deploy Account'
Loading