-
Notifications
You must be signed in to change notification settings - Fork 958
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
calculateSafeTransactionHash function error response #688
Comments
Please share a better code example. From your example, it's unclear what the type of variables you're passing to the function. |
I just update the code @mmv08 . You can copy paste and run it (add the params on .env file). I have the below dependancies: "dependencies": { If you change the address param on the new Contract function and make an invalid one, you see that the message returns the value of the incorrect param but it is saying undefined if you add a correct address. |
You're passing a safe-core-sdk transaction into the function. They're incompatible. You should look into the safe-core-sdk documentation on how to obtain a hash for the transaction. |
What type of SafeTransaction i need to pass? Thank you |
import {calculateSafeTransactionHash} from "@safe-global/safe-contracts"; configDotenv() const provider = new ethers.providers.JsonRpcProvider(process.env.JSON_URL, 'optimism') const etherAdapter = new EthersAdapter({ ethers, signerOrProvider: new Wallet(Wallet.createRandom().privateKey, provider) })
/**
const safeTransactionRaw = await safeSdk.createTransaction( { safeTransactionData }) const safeTransaction = { const keck = calculateSafeTransactionHash(new Contract(process.env.MY_SAFE_ADDRESS,gnosisProxyAbi,provider),safeTransaction, (await provider.getNetwork()).chainId) The above code, returns the same error. I changed the SafeTransactionType |
Description
Hello, there is a weird issue when i am trying to run the calculateSafeTransactionHash function. The thing is that, when i pass a correct address i am getting an error:
Error: invalid address (argument="address", value=undefined, code=INVALID_ARGUMENT, version=address/5.7.0)
reason: 'invalid address',
code: 'INVALID_ARGUMENT',
argument: 'address',
value: undefined
When i run the same function with an incorrect address i am getting the following error:
Error: invalid address (argument="address", value=0x, code=INVALID_ARGUMENT, version=address/5.7.0)
reason: 'invalid address',
code: 'INVALID_ARGUMENT',
argument: 'address',
value: 0x
So, when i pass a correct address the function returns value=undefined. When i pass an incorrect address the function returns the same message WITH the value displayed. I will share the code below.
Environment
Running locally with:
Steps to reproduce
I am sharing the code:
import {calculateSafeTransactionHash} from "@safe-global/safe-contracts";
import {Contract, ethers, Wallet} from "ethers";
import gnosisProxyAbi from "./abi/gnosisProxyAbi.json" assert {type: "json"};
import SafeProtocol, {EthersAdapter} from "@safe-global/protocol-kit";
import {configDotenv} from "dotenv";
configDotenv()
const provider = new ethers.providers.JsonRpcProvider(process.env.JSON_URL, 'optimism')
const safeTransactionData = {
to: "0x",
data: "0xdata",
value: 1,
operation: 1,
}
const etherAdapter = new EthersAdapter({ ethers, signerOrProvider: new Wallet(Wallet.createRandom().privateKey, provider) })
const Safe = SafeProtocol.default
/**
*
*/
const safeSdk = await Safe.create({ ethAdapter: etherAdapter, safeAddress: process.env.MY_SAFE_ADDRESS })
/**
*
*/
const safeTransaction = await safeSdk.createTransaction( {
safeTransactionData: safeTransactionData,
options: {
value: 1,
}
})
const res = calculateSafeTransactionHash(new Contract(process.env.MY_SAFE_ADDRESS,gnosisProxyAbi,provider),safeTransaction, (await provider.getNetwork()).chainId)
console.log(res)
I am waiting for your response.Thanks
The text was updated successfully, but these errors were encountered: