This repository has been archived by the owner on Jul 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: get wallets and contracts from config
- Loading branch information
Showing
23 changed files
with
5,584 additions
and
3,834 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 0 additions & 20 deletions
20
toolchains/solidity/extension/sidepanel/src/components/InteractButton/InteractButton.css
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
toolchains/solidity/extension/sidepanel/src/components/InteractButton/InteractButton.tsx
This file was deleted.
Oops, something went wrong.
82 changes: 0 additions & 82 deletions
82
...xtension/sidepanel/src/components/InteractContractContainer/InteractContractContainer.tsx
This file was deleted.
Oops, something went wrong.
File renamed without changes.
46 changes: 46 additions & 0 deletions
46
.../solidity/extension/sidepanel/src/components/InteractContracts/InteractContracts.logic.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { useContext } from 'react'; | ||
import { InteractContext } from '../../contexts/InteractContext.tsx'; | ||
import { Wallet } from '../../../../src/actions/WalletRepository.ts'; | ||
import { Contract } from '../../../../src/actions/ContractRepository.ts'; | ||
|
||
export const useInteractContracts = () => { | ||
const { state, dispatch } = useContext(InteractContext); | ||
|
||
const handleWalletChange = (wallet: Wallet) => { | ||
dispatch({ type: 'SET_SELECTED_WALLET', wallet: wallet }); | ||
}; | ||
|
||
const handleContractChange = (contract: Contract) => { | ||
dispatch({ type: 'SET_SELECTED_CONTRACT', contract: contract }); | ||
}; | ||
|
||
const handleFunctionChange = (func: string) => { | ||
dispatch({ type: 'SET_SELECTED_FUNCTION', func: func }); | ||
}; | ||
|
||
const handleGasLimitChange = (event: any) => { | ||
const gasLimit = event.target.value; | ||
|
||
dispatch({ type: 'SET_GAS_LIMIT', gasLimit: parseInt(gasLimit) }); | ||
}; | ||
|
||
const handleValueChange = (event: any) => { | ||
const value = event.target.value; | ||
dispatch({ type: 'SET_VALUE', value: BigInt(value) }); | ||
}; | ||
|
||
const handleUnitChange = (event: any) => { | ||
dispatch({ type: 'SET_UNIT', unit: event.target.value }); | ||
}; | ||
|
||
return { | ||
state, | ||
handleWalletChange, | ||
handleContractChange, | ||
handleFunctionChange, | ||
handleGasLimitChange, | ||
handleValueChange, | ||
handleUnitChange, | ||
}; | ||
}; |
65 changes: 65 additions & 0 deletions
65
...hains/solidity/extension/sidepanel/src/components/InteractContracts/InteractContracts.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { VSCodeDropdown, VSCodeOption, VSCodeTextField } from '@vscode/webview-ui-toolkit/react'; | ||
import './InteractContracts.css'; | ||
import { useInteractContracts } from './InteractContracts.logic.ts'; | ||
|
||
export const InteractContracts = () => { | ||
const logic = useInteractContracts(); | ||
|
||
return ( | ||
<div> | ||
<div className="dropdown-container"> | ||
<label htmlFor="dropdown-wallets" className="label">Select account:</label> | ||
<VSCodeDropdown id="dropdown-wallets"> | ||
{ | ||
logic.state.wallets.map((wallet) => ( | ||
<VSCodeOption onClick={() => { | ||
logic.handleWalletChange(wallet); | ||
}}>{wallet.address} ({wallet.name})</VSCodeOption> | ||
)) | ||
} | ||
</VSCodeDropdown> | ||
</div> | ||
<div className="dropdown-container"> | ||
<label htmlFor="dropdown-contracts" className="label">Select contract:</label> | ||
<VSCodeDropdown id="dropdown-contracts"> | ||
{ | ||
logic.state.contracts.map((contract) => ( | ||
<VSCodeOption onClick={() => { | ||
logic.handleContractChange(contract); | ||
}}>{contract.address} ({contract.name})</VSCodeOption> | ||
)) | ||
} | ||
</VSCodeDropdown> | ||
</div> | ||
<div className="dropdown-container"> | ||
<label htmlFor="dropdown" className="label">Select function:</label> | ||
<VSCodeDropdown id="dropdown"> | ||
{ | ||
logic.state.selectedContract?.abi.map((abi) => { | ||
if (abi.type === 'function') { | ||
return <VSCodeOption onClick={() => { | ||
logic.handleFunctionChange(abi.name); | ||
}}>{abi.name}</VSCodeOption>; | ||
} | ||
}) | ||
} | ||
</VSCodeDropdown> | ||
</div> | ||
<div className="gas-limit-container"> | ||
<VSCodeTextField className="gas-limit-textfield" onChange={logic.handleGasLimitChange}>Gas | ||
limit</VSCodeTextField> | ||
</div> | ||
<div className="value-container"> | ||
<label className="label">Value:</label> | ||
<div className="value-field-container"> | ||
<VSCodeTextField className="value-textfield" onChange={logic.handleValueChange} /> | ||
<VSCodeDropdown onChange={logic.handleUnitChange} className="value-dropdown" id="dropdown"> | ||
<VSCodeOption>Wei</VSCodeOption> | ||
<VSCodeOption>Gwei</VSCodeOption> | ||
<VSCodeOption>Eth</VSCodeOption> | ||
</VSCodeDropdown> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.