How to use decodeAbiParameters on a tuple? #1801
Answered
by
jxom
BravoNatalie
asked this question in
Question
-
I've been trying to transition from ethers to viem, but still wasn't able to figure out the best way to use So, how can I convert this function to viem? const abiCoder: AbiCoder = AbiCoder.defaultAbiCoder()
function decodeDeploymentConfig(input: string): DeploymentConfig {
const decodedConfig = abiCoder.decode(
[
'tuple(bytes32 contractType, uint32 chainType, bytes32 salt, bytes byteCode, bytes initCode) config',
'tuple(bytes32 r, bytes32 s, uint8 v) signature',
'address signer',
],
input,
)
return {
config: {
contractType: decodedConfig.config.contractType,
chainType: decodedConfig.config.chainType,
salt: decodedConfig.config.salt,
byteCode: decodedConfig.config.byteCode,
initCode: decodedConfig.config.initCode,
},
signature: {
r: decodedConfig.signature.r,
s: decodedConfig.signature.s,
v: decodedConfig.signature.v,
},
signer: decodedConfig.signer,
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
jxom
Feb 12, 2024
Replies: 1 comment 1 reply
-
const [config, signature, signer] = decodeAbiParameters(
parseAbiParameters([
'(bytes32 contractType, uint32 chainType, bytes32 salt, bytes byteCode, bytes initCode) config',
'(bytes32 r, bytes32 s, uint8 v) signature',
'address signer',
]),
input,
)
return { config, signature, signer } should work |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
jxom
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
should work