diff --git a/jest/setup.ts b/jest/setup.ts index c371af3c56..6ccc67ad4c 100644 --- a/jest/setup.ts +++ b/jest/setup.ts @@ -1,4 +1,5 @@ import dotenv from 'dotenv'; +import { TextEncoder, TextDecoder } from 'util'; import fetchMock from 'jest-fetch-mock'; @@ -6,6 +7,8 @@ fetchMock.enableMocks(); const envs = dotenv.config({ path: './configs/envs/.env.jest' }); +Object.assign(global, { TextDecoder, TextEncoder }); + Object.defineProperty(window, 'matchMedia', { writable: true, value: jest.fn().mockImplementation(query => ({ diff --git a/lib/hooks/useContractTabs.tsx b/lib/hooks/useContractTabs.tsx index 5736495c71..ca02f16ddd 100644 --- a/lib/hooks/useContractTabs.tsx +++ b/lib/hooks/useContractTabs.tsx @@ -15,22 +15,22 @@ export default function useContractTabs(data: Address | undefined) { // { id: 'contact_decompiled_code', title: 'Decompiled code', component:
{ data.outputs.map(({ type, name }, index) => {
diff --git a/ui/address/contract/ContractMethodCallableRow.tsx b/ui/address/contract/ContractMethodCallableRow.tsx
new file mode 100644
index 0000000000..2cc01d7861
--- /dev/null
+++ b/ui/address/contract/ContractMethodCallableRow.tsx
@@ -0,0 +1,84 @@
+import { Box, Flex, useColorModeValue } from '@chakra-ui/react';
+import React from 'react';
+import { useFormContext } from 'react-hook-form';
+
+import type { MethodFormFields } from './types';
+import type { SmartContractMethodArgType, SmartContractMethodInput } from 'types/api/contract';
+
+import ContractMethodField from './ContractMethodField';
+import ContractMethodFieldArray from './ContractMethodFieldArray';
+import { ARRAY_REGEXP } from './utils';
+
+interface Props {
+ fieldName: string;
+ fieldType?: SmartContractMethodInput['fieldType'];
+ argName: string;
+ argType: SmartContractMethodArgType;
+ onChange: () => void;
+ isDisabled: boolean;
+ isGrouped?: boolean;
+ isOptional?: boolean;
+}
+
+const ContractMethodCallableRow = ({ argName, fieldName, fieldType, argType, onChange, isDisabled, isGrouped, isOptional }: Props) => {
+ const { control, getValues, setValue } = useFormContext