Skip to content

Commit

Permalink
Merge pull request #211 from NethermindEth/starknet-abi-forms
Browse files Browse the repository at this point in the history
integrate starknet abi form
  • Loading branch information
rjnrohit authored Dec 4, 2023
2 parents 885aa0b + 214c253 commit aa18a6a
Show file tree
Hide file tree
Showing 7 changed files with 294 additions and 771 deletions.
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
Expand Up @@ -27,6 +27,7 @@
"react-dom": "^18.2.0",
"react-icons": "^4.10.1",
"starknet": "5.19.5",
"starknet-abi-forms": "^0.1.3",
"vite-plugin-svgr": "^4.0.0",
"web-vitals": "^2.1.4",
"yup": "^1.2.0"
Expand Down
14 changes: 14 additions & 0 deletions plugin/pnpm-lock.yaml

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

66 changes: 49 additions & 17 deletions plugin/src/features/Deployment/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,6 @@ const Deployment: React.FC<DeploymentProps> = ({ setActiveTab }) => {
}, [selectedContract])

const deploy = async (calldata: BigNumberish[]): Promise<void> => {
// if (
// env === 'wallet' &&
// starknetWindowObject !== null &&
// starknetWindowObject.id === 'argentX'
// ) {
// await remixClient.call(
// 'notification' as any,
// 'toast',
// `⚠️ You are connected to ${starknetWindowObject.id} wallet, please use the Braavos wallet instead!`
// )
// // return
// }

setIsDeploying(true)
remixClient.emit('statusChanged', {
key: 'loading',
Expand Down Expand Up @@ -134,6 +121,10 @@ const Deployment: React.FC<DeploymentProps> = ({ setActiveTab }) => {
)} already has been declared, proceeding to deployment...`
)
} catch (error) {
await remixClient.call('terminal', 'log', {
value: `------------------------ Declaring contract: ${selectedContract.name} ------------------------`,
type: 'info'
})
const declareResponse = await account.declare({
contract: selectedContract.sierra,
classHash: selectedContract.classHash,
Expand All @@ -143,6 +134,10 @@ const Deployment: React.FC<DeploymentProps> = ({ setActiveTab }) => {
value: JSON.stringify(declareResponse, null, 2),
type: 'info'
})
await remixClient.call('terminal', 'log', {
value: `---------------------- End Declaring contract: ${selectedContract.name} ----------------------`,
type: 'info'
})
updatedTransactions = [
{
type: 'declare',
Expand All @@ -155,7 +150,19 @@ const Deployment: React.FC<DeploymentProps> = ({ setActiveTab }) => {
]
setTransactions(updatedTransactions)
classHash = declareResponse.class_hash
await account.waitForTransaction(declareResponse.transaction_hash)
await remixClient.call('terminal', 'log', {
value: `--------------------- Getting declare contract: ${selectedContract.name} tx receipt --------------------`,
type: 'info'
})
const txReceipt = await account.waitForTransaction(declareResponse.transaction_hash)
await remixClient.call('terminal', 'log', {
value: JSON.stringify(txReceipt, null, 2),
type: 'info'
})
await remixClient.call('terminal', 'log', {
value: `--------------------- End getting declare contract: ${selectedContract.name} tx receipt ------------------`,
type: 'info'
})
}
} catch (error) {
if (error instanceof Error) {
Expand All @@ -172,15 +179,26 @@ const Deployment: React.FC<DeploymentProps> = ({ setActiveTab }) => {

setDeployStatus('Deploying...')

await remixClient.call('terminal', 'log', {
value: `------------------------ Deploying contract: ${selectedContract.name} ------------------------`,
type: 'info'
})

const deployResponse = await account.deployContract({
classHash: classHash ?? selectedContract.classHash,
constructorCalldata: calldata
})

await remixClient.call('terminal', 'log', {
value: JSON.stringify(deployResponse, null, 2),
type: 'info'
})

await remixClient.call('terminal', 'log', {
value: `---------------------- End Deploying contract: ${selectedContract.name} ----------------------`,
type: 'info'
})

setTransactions([
{
type: 'deploy',
Expand All @@ -191,7 +209,23 @@ const Deployment: React.FC<DeploymentProps> = ({ setActiveTab }) => {
},
...updatedTransactions
])
await account.waitForTransaction(deployResponse.transaction_hash)

await remixClient.call('terminal', 'log', {
value: `--------------------- Getting deploy contract: ${selectedContract.name} tx receipt --------------------`,
type: 'info'
})

const txReceipt = await account.waitForTransaction(deployResponse.transaction_hash)
await remixClient.call('terminal', 'log', {
value: JSON.stringify(txReceipt, null, 2),
type: 'info'
})

await remixClient.call('terminal', 'log', {
value: `--------------------- End getting deploy contract: ${selectedContract.name} tx receipt ------------------`,
type: 'info'
})

setDeployStatus('done')
setActiveTab('interaction')
setContractDeployment(selectedContract, deployResponse.contract_address)
Expand All @@ -200,7 +234,6 @@ const Deployment: React.FC<DeploymentProps> = ({ setActiveTab }) => {
type: 'success',
title: `Contract ${selectedContract?.name} deployed!`
})
// setContractAsDeployed(selectedContract as Contract);
} catch (error) {
setDeployStatus('error')
if (error instanceof Error) {
Expand Down Expand Up @@ -236,7 +269,6 @@ const Deployment: React.FC<DeploymentProps> = ({ setActiveTab }) => {
} else {
setNotEnoughInputs(false)
const calldata = getFormattedCalldata()
// setFinalCallData(calldata)
handleDeploy(calldata)
}
}
Expand Down
Loading

0 comments on commit aa18a6a

Please sign in to comment.