Skip to content

Commit

Permalink
Executing Dry Running
Browse files Browse the repository at this point in the history
  • Loading branch information
henrypalacios committed Nov 15, 2023
1 parent 9a2fd56 commit f29e5d2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { ContractInteractionProps } from '.'
import { AbiParam } from '@/services/substrate/types'
import { useDryRunExecution } from '../useDryRunExecution'
import { MethodDocumentation } from '../MethodDocumentation'
import { ButtonCall } from './styled'
import { CopyBlock, atomOneDark } from 'react-code-blocks'

type Props = React.PropsWithChildren<
Omit<ContractInteractionProps, 'type'> & {
Expand All @@ -11,13 +13,19 @@ type Props = React.PropsWithChildren<
}
>

export function WriteMethodsForm({ children, abiParams, abiMessage }: Props) {
// const { outcome, executeDryRun } = useDryRunExecution({
// contractPromise,
// message: abiMessage,
// params: inputData,
// autoRun: false
// })
export function WriteMethodsForm({
children,
abiParams,
abiMessage,
contractPromise,
inputData
}: Props) {
const { outcome, executeDryRun, isSubmitting } = useDryRunExecution({
contractPromise,
message: abiMessage,
params: inputData,
autoRun: false
})

return (
<Stack
Expand All @@ -34,7 +42,7 @@ export function WriteMethodsForm({ children, abiParams, abiMessage }: Props) {
<Typography variant="caption">Outcome</Typography>
</Box>

{/* <Stack direction="row" justifyContent="space-between">
<Stack direction="row" justifyContent="space-between">
<Box
sx={{
minWidth: '45%',
Expand All @@ -43,19 +51,20 @@ export function WriteMethodsForm({ children, abiParams, abiMessage }: Props) {
justifyContent: 'center'
}}
>
{caller.isSubmitting ? (
{isSubmitting ? (
<CircularProgress color="primary" />
) : (
<CopyBlock
text={outcome}
language="text"
theme={atomOneDark}
showLineNumbers={false}
wrapLongLines={true}
/>
)}
</Box>
<ButtonCall onClick={() => caller.send(inputData)}>Call</ButtonCall>
</Stack> */}
<ButtonCall onClick={() => executeDryRun(inputData)}>Call</ButtonCall>

Check failure on line 66 in src/view/ContractDetailView/ContractInteractionForm/WriteMethodsForm.tsx

View workflow job for this annotation

GitHub Actions / Run tests (18.x)

Expected 0 arguments, but got 1.
</Stack>
</Box>
<Box sx={{ maxWidth: '45%', minWidth: '40%' }}>
<MethodDocumentation abiMessage={abiMessage} />
Expand Down
2 changes: 1 addition & 1 deletion src/view/ContractDetailView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export default function ContractDetail({ userContract }: Props): JSX.Element {
</Tooltip>
</Typography>
<Stack direction="row" alignItems="center">
<Typography variant="caption">Added by</Typography>
<Typography variant="caption">By</Typography>
{''}
<MonoTypography sx={{ fontSize: '0.8rem' }}>
{truncateAddress(userContract.userAddress, 4)}
Expand Down
1 change: 0 additions & 1 deletion src/view/ContractDetailView/useDryRunExecution.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export function useDryRunExecution({

const executeDryRun = useCallback(async () => {
const result = await dryRun.send(memoizedParams)
console.log('__dryRun', dryRun)
if (result?.ok) {
setOutcome(
`Contract call will be successful executed with ${result.value.partialFee.toString()} fee`
Expand Down

0 comments on commit f29e5d2

Please sign in to comment.