Skip to content

Commit

Permalink
stuck in a loop
Browse files Browse the repository at this point in the history
  • Loading branch information
skuhlmann committed Dec 18, 2023
1 parent 84d433c commit 2f527c3
Showing 1 changed file with 69 additions and 2 deletions.
71 changes: 69 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,8 @@ const actionDecoders: Record<
);
}
const input = decodedMethod.inputs[0];

console.log('input', input);
if (input.type !== 'bytes') {
return createActionError(
action.data,
Expand All @@ -212,6 +216,67 @@ const actionDecoders: Record<
};
},

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

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

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

console.log('actions', actions.length);

// const decodedActions = await decodeMultiCall(
// options,
// action.data as `0x${string}`
// );

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(act),
operation:
decodeValue(action.operation) === '1'
? OperationType.DelegateCall
: OperationType.Call,
});

console.log('lol', i, lol);
return lol;
})
);

console.log('res', res);

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

// execTransactionFromModule(address,uint256,bytes,uint8)
'0x468721a7': async (options, action, decodedMethod) => {
if (
Expand Down Expand Up @@ -379,6 +444,8 @@ const decodeAction = async (

const methodSignature = data.slice(0, 10);

console.log('methodSignature', methodSignature);

const actionDecoder = actionDecoders[methodSignature];
if (actionDecoder) {
return await actionDecoder(options, action, decodedMethod);
Expand Down

0 comments on commit 2f527c3

Please sign in to comment.