Skip to content

Commit

Permalink
Wrong contract read bytes32[] (#1216)
Browse files Browse the repository at this point in the history
Fixes #1176
  • Loading branch information
tom2drum authored Sep 29, 2023
1 parent dbd4452 commit e82a7a0
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 4 deletions.
19 changes: 19 additions & 0 deletions mocks/contract/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,25 @@ export const read: Array<SmartContractReadMethod> = [
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
method_id: '69598efe',
name: 'totalPartitions',
constant: true,
payable: false,
outputs: [
{
type: 'bytes32[]',
name: 'bytes32[]',
value: [
'0x7265736572766564000000000000000000000000000000000000000000000000',
'0x6973737565640000000000000000000000000000000000000000000000000000',
],
},
],
stateMutability: 'view',
type: 'function',
},
];

export const readResultSuccess: SmartContractQueryMethodReadSuccess = {
Expand Down
4 changes: 2 additions & 2 deletions types/api/contract.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Abi } from 'abitype';

export type SmartContractMethodArgType = 'address' | 'uint256' | 'bool' | 'string' | 'bytes' | 'bytes32';
export type SmartContractMethodArgType = 'address' | 'uint256' | 'bool' | 'string' | 'bytes' | 'bytes32' | 'bytes32[]';
export type SmartContractMethodStateMutability = 'view' | 'nonpayable' | 'payable';

export interface SmartContract {
Expand Down Expand Up @@ -91,7 +91,7 @@ export interface SmartContractMethodInput {
}

export interface SmartContractMethodOutput extends SmartContractMethodInput {
value?: string | boolean;
value?: string | boolean | object;
}

export interface SmartContractQueryMethodReadSuccess {
Expand Down
6 changes: 4 additions & 2 deletions ui/address/contract/ContractMethodConstant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import config from 'configs/app';
import { WEI } from 'lib/consts';
import AddressEntity from 'ui/shared/entities/address/AddressEntity';

function castValueToString(value: number | string | boolean | bigint | undefined): string {
function castValueToString(value: number | string | boolean | object | bigint | undefined): string {
switch (typeof value) {
case 'string':
return value;
Expand All @@ -21,6 +21,8 @@ function castValueToString(value: number | string | boolean | bigint | undefined
return value.toLocaleString(undefined, { useGrouping: false });
case 'bigint':
return value.toString();
case 'object':
return JSON.stringify(value, undefined, 2);
}
}

Expand Down Expand Up @@ -54,7 +56,7 @@ const ContractMethodStatic = ({ data }: Props) => {
);
}

return <chakra.span wordBreak="break-all">({ data.type }): { String(value) }</chakra.span>;
return <chakra.span wordBreak="break-all" whiteSpace="pre-wrap">({ data.type }): { String(value) }</chakra.span>;
})();

return (
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e82a7a0

Please sign in to comment.