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

Fix/more deep decode #462

Merged
merged 2 commits into from
Dec 19, 2023
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
Expand Up @@ -60,8 +60,7 @@ export const ProposalDetailsContainer = ({
let shouldUpdate = true;
const fetchPropActions = async (
chainId: ValidNetwork,
actionData: string,
_actionMeta?: MulticallAction[]
actionData: string
) => {
const proposalActions = await decodeProposalActions({
chainId,
Expand All @@ -78,12 +77,12 @@ export const ProposalDetailsContainer = ({
};

if (!isValidNetwork(daoChain) || !proposal) return;
fetchPropActions(daoChain, proposal.proposalData, actionsMeta);
fetchPropActions(daoChain, proposal.proposalData);

return () => {
shouldUpdate = false;
};
}, [daoChain, proposal, actionsMeta]);
}, [daoChain, proposal]);
return (
<>
<ProposalDetails
Expand Down
55 changes: 53 additions & 2 deletions libs/tx-builder/src/utils/deepDecoding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,10 @@ const decodeMethod = (options: {
name: input.name,
type: input.type,
value: Array.isArray(result.args?.[index])
? (result.args?.[index] as Array<any>).length
? (result.args?.[index] as Array<any>).toString()
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
(result.args?.[index] as Array<any>).length
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
(result.args?.[index] as Array<any>).toString()
: '[]'
: result.args?.[index]?.toString() || '0x',
}));
Expand Down Expand Up @@ -190,6 +192,7 @@ const actionDecoders: Record<
);
}
const input = decodedMethod.inputs[0];

if (input.type !== 'bytes') {
return createActionError(
action.data,
Expand Down Expand Up @@ -333,6 +336,54 @@ const actionDecoders: Record<
decodedActions: [],
};
},

// multicall(bytes)
'0xac9650d8': async (options, action, decodedMethod) => {
if (
decodedMethod.functionName !== 'multicall' ||
decodedMethod.inputs.length !== 1
) {
return createActionError(
action.data,
'Could not decode action: multiSend'
);
}
const input = decodedMethod.inputs[0];

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

const actions = input.value.split(',');

const res = await Promise.all(
actions.map(async (act, i) => {
const lol = await decodeAction(options, {
to: action.to as `0x${string}`,
data: act as `0x${string}`,
value: decodeValue(action.value),
operation:
decodeValue(action.operation) === '1'
? OperationType.DelegateCall
: OperationType.Call,
});

return lol;
})
);

return {
to: action.to,
operation: action.operation || OperationType.DelegateCall,
name: decodedMethod.functionName,
value: decodeValue(action.value),
params: decodedMethod.inputs,
decodedActions: res,
};
},
};

const decodeAction = async (
Expand Down
Loading