Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deploy #491

Merged
merged 4 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ReactNode, useState } from 'react';
import { isValidNetwork } from '@daohaus/keychain-utils';
import { ValidNetwork, isValidNetwork } from '@daohaus/keychain-utils';
import { MolochV3Proposal } from '@daohaus/moloch-v3-data';
import {
ActionError,
Expand All @@ -12,12 +12,13 @@
Bold,
DataSm,
Divider,
H4,

Check warning on line 15 in libs/moloch-v3-macro-ui/src/components/ProposalActionData/ProposalActionData.tsx

View workflow job for this annotation

GitHub Actions / build

'H4' is defined but never used

Check warning on line 15 in libs/moloch-v3-macro-ui/src/components/ProposalActionData/ProposalActionData.tsx

View workflow job for this annotation

GitHub Actions / build

'H4' is defined but never used
ParMd,
Loading,
useBreakpoint,
widthQuery,
ParLg,
DataMd,
} from '@daohaus/ui';
import {
DAO_METHOD_TO_PROPOSAL_TYPE,
Expand Down Expand Up @@ -210,20 +211,52 @@

const ActionSectionError = ({
action,
actionHeader,
daoChain,
index,
isMobile,
}: {
action: ActionError;
actionHeader: string;
daoChain?: ValidNetwork;
index: number;
isMobile?: boolean;
}) => {
return (
<div className="display-segment data" key={`${action.message}-${index}`}>
<H4 className="space">Action {index + 1}: Error</H4>
<DataSm className="space">{action.message}</DataSm>
<Divider className="space" />
<DataSm className="space">
<Bold>HEX DATA:</Bold>
</DataSm>
<DataSm className="space">{action.data}</DataSm>
<ActionToggle actionHeader={actionHeader} action={action}>
<>
<DataMd className="space">Action {index + 1}</DataMd>
<DataSm className="space">Error: {action.message}</DataSm>
<Divider className="space" />
{action.contractAddress && (
<>
<DataSm className="space">
<Bold>TARGET</Bold>
</DataSm>
<AddressDisplay
className="space"
address={action.contractAddress}
copy
explorerNetworkId={daoChain}
truncate={isMobile}
/>
</>
)}
<DataSm className="space">
<Bold>HEX DATA:</Bold>
</DataSm>
<DataSm className="space">{action.data}</DataSm>
{action.value && (
<>
<DataSm className="space">
<Bold>VALUE</Bold>
</DataSm>
<DataSm className="space">{action.value}</DataSm>
</>
)}
</>
</ActionToggle>
</div>
);
};
Expand All @@ -249,7 +282,15 @@
const isMobile = useBreakpoint(widthQuery.sm);

if (isActionError(action)) {
return <ActionSectionError index={index} action={action} />;
return (
<ActionSectionError
index={index}
action={action}
actionHeader={actionHeader}
daoChain={network}
isMobile={isMobile}
/>
);
}

return (
Expand Down
2 changes: 2 additions & 0 deletions libs/tx-builder/src/utils/decoding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export type ActionError = {
error: boolean;
message: string;
data: string;
contractAddress?: string;
value?: string;
};

export type DecodedMultiTX = (DecodedAction | ActionError)[];
Expand Down
47 changes: 36 additions & 11 deletions libs/tx-builder/src/utils/deepDecoding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,17 @@
return decodeMultiCall(options, actionData as `0x${string}`);
};

const createActionError = (data: string, message: string): ActionError => ({
const createActionError = (
data: string,
message: string,
contractAddress?: string,
value?: string
): ActionError => ({
error: true,
message,
data,
contractAddress,
value,
});

const decodeMultiCall = async (
Expand Down Expand Up @@ -159,7 +166,7 @@
type: input.type,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
value:
(result.args?.[index] as any).constructor === {}.constructor

Check warning on line 169 in libs/tx-builder/src/utils/deepDecoding.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type

Check warning on line 169 in libs/tx-builder/src/utils/deepDecoding.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
? JSON.stringify(result.args?.[index]) // struct as json object
: Array.isArray(result.args?.[index]) // array
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down Expand Up @@ -192,15 +199,17 @@
) {
return createActionError(
action.data,
'Could not decode action: multiSend'
'Could not decode action: multiSend',
action.to
);
}
const input = decodedMethod.inputs[0];

if (input.type !== 'bytes') {
return createActionError(
action.data,
'Could not decode action: multiSend'
'Could not decode action: multiSend',
action.to
);
}

Expand All @@ -227,7 +236,8 @@
) {
return createActionError(
action.data,
'Could not decode action: execTransactionFromModule'
'Could not decode action: execTransactionFromModule',
action.to
);
}
const inputTo = decodedMethod.inputs[0];
Expand All @@ -243,7 +253,8 @@
) {
return createActionError(
action.data,
'Could not decode action: execTransactionFromModule'
'Could not decode action: execTransactionFromModule',
action.to
);
}

Expand Down Expand Up @@ -274,7 +285,8 @@
) {
return createActionError(
action.data,
'Could not decode action: executeAsBaal'
'Could not decode action: executeAsBaal',
action.to
);
}
const inputTo = decodedMethod.inputs[0];
Expand All @@ -288,7 +300,8 @@
) {
return createActionError(
action.data,
'Could not decode action: executeAsBaal'
'Could not decode action: executeAsBaal',
action.to
);
}

Expand Down Expand Up @@ -349,15 +362,17 @@
) {
return createActionError(
action.data,
'Could not decode action: multiSend'
'Could not decode action: multiSend',
action.to
);
}
const input = decodedMethod.inputs[0];

if (input.type !== 'bytes[]') {
return createActionError(
action.data,
'Could not decode action: multicall'
'Could not decode action: multicall',
action.to
);
}

Expand Down Expand Up @@ -420,7 +435,12 @@
});

if (!abi || !abi?.length) {
return createActionError(data, 'Could not decode action: abi not found');
return createActionError(
data,
'Could not decode action: abi not found',
to,
decodeValue(value)
);
}

const decodedMethod = decodeMethod({
Expand All @@ -429,7 +449,12 @@
});

if (!decodedMethod) {
return createActionError(data, 'Could not decode action: method not found');
return createActionError(
data,
'Could not decode action: method not found',
to,
decodeValue(value)
);
}

const methodSignature = data.slice(0, 10);
Expand Down
9 changes: 7 additions & 2 deletions libs/tx-builder/src/utils/multicall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,13 @@ const handleMulticallFormActions = ({
if (!validTxs.length) {
throw new Error('No actions found');
}
// TODO: sort by tx.actionId.index
return validTxs.map((actionId: string) => {
const sortedTxs = validTxs.sort((actionA: string, actionB: string) =>
Number(appState.formValues.tx[actionA].index) >
Number(appState.formValues.tx[actionB].index)
? 1
: -1
);
return sortedTxs.map((actionId: string) => {
const action = appState.formValues.tx[actionId];
const { to, data, value, operation } = action;
return {
Expand Down
Loading