Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
684ffbb
chore: add instruction for contract upload
saleel Apr 14, 2025
18b1054
chore: add contract compile instructions
saleel Apr 14, 2025
2a869ec
chore: add profiler button
saleel Apr 15, 2025
fb32ff6
Merge tag 'tags/v0.85.0' into saleel/playground-fix
saleel Apr 15, 2025
054cb37
update inspuration button
saleel Apr 15, 2025
d9bf9eb
update logs button
saleel Apr 15, 2025
ee6deee
update add contact styles
saleel Apr 15, 2025
30763da
update all dialog box
saleel Apr 15, 2025
9239e81
update contract/account label in sidebar
saleel Apr 15, 2025
69078fc
load contract create modal by default
saleel Apr 15, 2025
af12b1e
add version to upload contract page
saleel Apr 15, 2025
82f992b
add version to sandbox network
saleel Apr 15, 2025
0cd3c4a
add tooltips for function buttons
saleel Apr 15, 2025
9c4fdba
fix authwite copy
saleel Apr 15, 2025
12ed74f
add data type label, fix input type
saleel Apr 15, 2025
789eb06
improve upload copy
saleel Apr 15, 2025
b68d171
fix button css
saleel Apr 15, 2025
cf13e3d
set timeout to 2mins
saleel Apr 15, 2025
a5bfdbe
update bundle size limit
saleel Apr 15, 2025
6a49db3
chore: Update slash factory on alpha (#13586)
PhilWindle Apr 16, 2025
05999f5
fix: blobscan url (#13618)
alexghr Apr 16, 2025
e407e52
update devent
saleel Apr 18, 2025
d7f44e4
Merge tag 'v0.85.0-alpha-testnet.2' into saleel/playground-fix
saleel Apr 18, 2025
7d3ebaf
update fun facts
saleel Apr 18, 2025
ad7089a
chore: add contract ordering and descriptions
saleel Apr 18, 2025
02449b0
chore: keep contract methods minimized
saleel Apr 18, 2025
4789bd6
style fix
saleel Apr 18, 2025
6e8e3ae
update upload link
saleel Apr 18, 2025
c1d5adf
connect to testnet automatically
saleel Apr 18, 2025
7a68d3c
add buttons to landing page
saleel Apr 18, 2025
294bae1
update testnet url
saleel Apr 18, 2025
3d32ebe
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Apr 21, 2025
c9ae9af
bundle size
Thunkar Apr 21, 2025
e4d645a
fix docs button css in mobile
saleel Apr 22, 2025
6562fa4
update contract button css
saleel Apr 22, 2025
769438a
update function card button css
saleel Apr 22, 2025
1df57f4
revert prettier
saleel Apr 22, 2025
c81c26c
Merge branch 'master' into saleel/playground-fix
saleel Apr 22, 2025
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
32 changes: 30 additions & 2 deletions playground/src/components/common/FnParameter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,34 @@ export function FunctionParameter({ parameter, required, onParameterChange }: Fu
}
};

function getParameterType(type: AbiType) {
switch (type.kind) {
case 'field':
return 'number';
case 'integer':
return 'number';
case 'string':
return 'text';
default:
return 'text';
}
}

function getParameterLabel(type: AbiType) {
switch (type.kind) {
case 'field':
return 'number';
case 'integer':
return 'int';
case 'string':
return 'string';
case 'boolean':
return 'bool';
default:
return '';
}
}

return (
<div css={container}>
{isAddressStruct(parameter.type) && !manualInput ? (
Expand Down Expand Up @@ -112,8 +140,8 @@ export function FunctionParameter({ parameter, required, onParameterChange }: Fu
variant="outlined"
disabled={['array', 'struct', 'tuple'].includes(parameter.type.kind) && !isAddressStruct(parameter.type)}
key={parameter.name}
type="text"
label={capitalize(parameter.name)}
type={getParameterType(parameter.type)}
label={`${capitalize(parameter.name)} (${getParameterLabel(parameter.type)})`}
onChange={e => handleParameterChange(e.target.value, parameter.type)}
/>
)}
Expand Down
8 changes: 6 additions & 2 deletions playground/src/components/common/LoadingModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,15 @@ const funFacts = [
'The Aztec protocol was founded in 2017',
"We're almost there...",
'Aztec Connect was the first private DeFi application',
'Aztec invented PLONK which is really cool',
'Aztec invented PLONK which is really cool and underpins all modern zkVMs',
'Aztec supports private, public, and hybrid smart contract execution',
'Aztec enables privacy and full composability',
'Aztec enables privacy and full composability across private and public calls',
'All transactions on Aztec start off private (since all accounts and transaction entrypoints are private)',
'Aztec is the first L2 to launch a decentralized testnet on day 1',
'While you wait for this proof, check out somethinghappened.wtf',
];


export function LoadingModal() {
const { currentTx, setCurrentTx, logs } = useContext(AztecContext);
const [currentFunFact, setCurrentFunFact] = useState(0);
Expand Down
128 changes: 96 additions & 32 deletions playground/src/components/contract/Contract.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@ import { formatFrAsString } from '../../utils/conversion';
import { CreateContractDialog } from './components/CreateContractDialog';
import ClearIcon from '@mui/icons-material/Clear';
import { CopyToClipboardButton } from '../common/CopyToClipboardButton';

import { ContractUpload } from './components/ContractUpload';
import { ContractFilter } from './components/ContractFilter';
import { FunctionCard } from './components/FunctionCard';
import { useTransaction } from '../../hooks/useTransaction';
import { ContractDescriptions, ContractDocumentationLinks, ContractMethodOrder } from '../../utils/constants';
import Box from '@mui/material/Box';
import CardContent from '@mui/material/CardContent';
import Card from '@mui/material/Card';

const container = css({
display: 'flex',
Expand Down Expand Up @@ -55,15 +60,39 @@ const headerContainer = css({

const header = css({
display: 'flex',
flexDirection: 'column',
width: '100%',
alignItems: 'flex-start',
justifyContent: 'space-between',
});

const titleContainer = css({
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
width: '100%',
marginBottom: '1rem',
});

const contractActions = css({
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
minWidth: '150px',
});

const deployButton = css({
background: '#8C7EFF',
height: '30px',
fontSize: '14px',
fontWeight: 600,
padding: '20px 16px',
borderRadius: '6px',
'@media (max-width: 900px)': {
padding: '4px',
height: 'auto',
},
});

const loadingArtifactContainer = css({
Expand Down Expand Up @@ -137,6 +166,12 @@ export function ContractComponent() {
}
}, [currentContractArtifact, currentContractAddress, wallet]);

useEffect(() => {
if (!currentContractAddress) {
setOpenCreateContractDialog(true);
}
}, [currentContractAddress]);

const handleContractCreation = async (
contract?: ContractInstanceWithAddress,
publiclyDeploy?: boolean,
Expand Down Expand Up @@ -173,39 +208,51 @@ export function ContractComponent() {
<div css={contractFnContainer}>
<div css={headerContainer}>
<div css={header}>
<Typography variant="h3" css={contractName}>
{currentContractArtifact.name}
</Typography>
{!currentContractAddress && wallet && (
<div css={contractActions}>
<Button size="small" variant="contained" onClick={() => setOpenCreateContractDialog(true)}>
Register/Deploy
</Button>
{openCreateContractDialog && (
<CreateContractDialog
contractArtifact={currentContractArtifact}
open={openCreateContractDialog}
onClose={handleContractCreation}
/>
)}
</div>
)}
{currentContractAddress && (
<div css={contractActions}>
<Typography color="text.secondary">{formatFrAsString(currentContractAddress.toString())}</Typography>
<CopyToClipboardButton disabled={false} data={currentContractAddress.toString()} />
<IconButton
onClick={() => {
setCurrentContractAddress(null);
setCurrentContract(null);
setCurrentContractArtifact(null);
}}
>
<ClearIcon />
</IconButton>
</div>
<Box sx={titleContainer}>
<Typography variant="h3" css={contractName}>
{currentContractArtifact.name}
</Typography>

{!currentContractAddress && wallet && (
<div css={contractActions}>
<Button size="small" variant="contained" css={deployButton} onClick={() => setOpenCreateContractDialog(true)}>
Deploy / Load Contract
</Button>
{openCreateContractDialog && (
<CreateContractDialog
contractArtifact={currentContractArtifact}
open={openCreateContractDialog}
onClose={handleContractCreation}
/>
)}
</div>
)}

{currentContractAddress && (
<div css={contractActions}>
<Typography color="text.secondary">{formatFrAsString(currentContractAddress.toString())}</Typography>
<CopyToClipboardButton disabled={false} data={currentContractAddress.toString()} />
<IconButton
onClick={() => {
setCurrentContractAddress(null);
setCurrentContract(null);
setCurrentContractArtifact(null);
}}
>
<ClearIcon />
</IconButton>
</div>
)}

</Box>

{!!ContractDescriptions[currentContractArtifact.name] && (
<Typography variant="body1" css={{ marginBottom: '2rem' }}>
{ContractDescriptions[currentContractArtifact.name]}
</Typography>
)}
</div>

<ContractFilter filters={filters} onFilterChange={setFilters} />
</div>
{functionAbis
Expand All @@ -218,9 +265,26 @@ export function ContractComponent() {
(filters.utility && fn.functionType === FunctionType.UTILITY)) &&
(filters.searchTerm === '' || fn.name.includes(filters.searchTerm)),
)
.sort((a, b) => {
if (ContractMethodOrder[currentContractArtifact.name]) {
return ContractMethodOrder[currentContractArtifact.name]?.indexOf(a.name) - ContractMethodOrder[currentContractArtifact.name]?.indexOf(b.name)
}
return 0;
})
.map(fn => (
<FunctionCard fn={fn} key={fn.name} contract={currentContract} onSendTxRequested={sendTx} />
<FunctionCard fn={fn} key={fn.name} contract={currentContract} contractArtifact={currentContractArtifact} onSendTxRequested={sendTx} />
))}

{!!ContractDocumentationLinks[currentContractArtifact.name] && (
<Card sx={{ margin: '3rem 0.5rem' }}>
<CardContent>
<Typography variant="body1">
<span>Find the in-depth tutorial for {currentContractArtifact.name} </span>
<a href={ContractDocumentationLinks[currentContractArtifact.name]} target="_blank" rel="noopener noreferrer">here</a>
</Typography>
</CardContent>
</Card>
)}
</div>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const search = css({
'@media (width > 800px)': {
maxWidth: '500px',
},
marginBottom: '1rem',
});

const checkBoxLabel = css({
Expand Down Expand Up @@ -58,7 +59,7 @@ export function ContractFilter({ filters, onFilterChange }: ContractFilterProps)
}}
>
<Tooltip
title="These functions are simulated locally and only proofs are sent to Aztec"
title="Function signature and execution are kept private by executing locally and generating a zk proof of correct execution. The proof is sent to Aztec."
arrow
slotProps={{
tooltip: {
Expand Down Expand Up @@ -112,7 +113,7 @@ export function ContractFilter({ filters, onFilterChange }: ContractFilterProps)
</Tooltip>

<Tooltip
title="Only invoked by applications that interact with contracts to perform state queries from an off-chain client. They are unconstrained, meaning no proofs are generated"
title="These are off-chain getters (for you to query the state) without generating any proofs. They are unconstrained, so no proof is generated and data is fetched locally."
arrow
slotProps={{
tooltip: {
Expand Down
33 changes: 29 additions & 4 deletions playground/src/components/contract/components/ContractUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import Typography from '@mui/material/Typography';
import UploadFileIcon from '@mui/icons-material/UploadFile';
import { useContext } from 'react';
import { AztecContext } from '../../../aztecEnv';
import Box from '@mui/material/Box';
import { VERSION } from '../../../utils/constants';

const dropZoneContainer = css({
display: 'flex',
Expand All @@ -29,7 +31,7 @@ const uploadIcon = css({
export function ContractUpload() {
const { setCurrentContractArtifact } = useContext(AztecContext);

const { getRootProps, getInputProps } = useDropzone({
const { getRootProps, getInputProps, } = useDropzone({
onDrop: async files => {
const file = files[0];
const reader = new FileReader();
Expand All @@ -43,6 +45,7 @@ export function ContractUpload() {
'application/json': ['.json'],
},
multiple: false,
noDragEventsBubbling: true,
});

return (
Expand All @@ -54,9 +57,31 @@ export function ContractUpload() {
Upload Contract JSON Artifact
</Typography>
<Typography>Drag and drop a contract JSON file here, or click to select a file</Typography>
<Typography variant="caption" color="text.secondary" sx={{ mt: 1, mb: 3, display: 'block' }}>
The contract artifact should be a JSON file exported from your Noir/Aztec project
</Typography>


<Box sx={{ textAlign: 'left', backgroundColor: 'var(--mui-palette-grey-A200)', p: 2, borderRadius: '5px', my: 3 }}>
<Box>
<a href="https://docs.aztec.network/developers/tutorials/codealong/contract_tutorials/counter_contract" target="_blank" rel="noopener noreferrer">Learn</a>
<span> to write your own Aztec smart contracts and upload them here when ready.</span>
</Box>

<Box sx={{ mt: 2 }}>
<Typography
variant="body2"
color="text.secondary"
onClick={(e) => {
e.stopPropagation();
}}
>
1. Install Aztec CLI by running `aztec-up {VERSION}`
<br />
2. Run `aztec-nargo compile` in your project directory
<br />
3. Look for `{'<your-project-name>'}.json` file in the ./target directory
</Typography>
</Box>
</Box>

<Button
variant="contained"
color="primary"
Expand Down
Loading