This repository has been archived by the owner on Nov 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecode-data.js
21 lines (18 loc) · 2.15 KB
/
decode-data.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { decodeFunctionData } from 'viem'
import { llamaCoreAbi, llamaAccountAbi, llamaPolicyAbi, llamaGovernanceScriptAbi } from './abi.js'
const targetToAbi = {
'0x21f45e61213a13Dc6B7Ba2eC157c4e95810cD335': llamaGovernanceScriptAbi,
'0xeCCB99806ce0738918F20253F304A373FF197CDd': llamaPolicyAbi,
'0x48E6a039bcF6d99806Ce4595fC59e4A7C0CaAB19': llamaAccountAbi,
'0x39a74CD1CF5c8316E4D73FdE4E4fCf6Ac46a4D0b': llamaAccountAbi,
'0x4C18b41AC340E18D7622310D193aa9cA2350A404': llamaCoreAbi,
}
const decodeActionData = (target, data) => {
const abi = targetToAbi[target]
return decodeFunctionData({ abi, data })
}
// Example usage
const data =
'0x9ec3871e00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000500000000000000000000000039a74cd1cf5c8316e4d73fde4e4fcf6ac46a4d0b512883560000000000000000000000000000000000000000000000000000000000000000000000000000000079773cb6f180fe9498b0b17f4233edb862c6b4a80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000039a74cd1cf5c8316e4d73fde4e4fcf6ac46a4d0b2cff3e670000000000000000000000000000000000000000000000000000000000000000000000000000000079773cb6f180fe9498b0b17f4233edb862c6b4a80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000039a74cd1cf5c8316e4d73fde4e4fcf6ac46a4d0bffc29ab20000000000000000000000000000000000000000000000000000000000000000000000000000000079773cb6f180fe9498b0b17f4233edb862c6b4a80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000039a74cd1cf5c8316e4d73fde4e4fcf6ac46a4d0b5f85c0150000000000000000000000000000000000000000000000000000000000000000000000000000000079773cb6f180fe9498b0b17f4233edb862c6b4a80000000000000000000000000000000000000000000000000000000000000000'
const decodedActionData = decodeActionData('0x21f45e61213a13Dc6B7Ba2eC157c4e95810cD335', data)
console.log(decodedActionData)