fix: Simplify nonceOffset logic
Set new role addresses for all chains Took 1 hour 43 minutes
This commit is contained in:
@@ -1,44 +1,50 @@
|
|||||||
{
|
{
|
||||||
"ethereum": {
|
"ethereum": {
|
||||||
"EXECUTOR_SETTER_ROLE": [
|
"EXECUTOR_SETTER_ROLE": [
|
||||||
"0x58Dc7Bf9eD1f4890A7505D5bE4E4252978eAF655"
|
"0x06e580B872a37402764f909FCcAb0Eb5bb38fe23"
|
||||||
],
|
],
|
||||||
"PAUSER_ROLE": [
|
"PAUSER_ROLE": [
|
||||||
"0x58Dc7Bf9eD1f4890A7505D5bE4E4252978eAF655"
|
"0xB279A562C726F9F3011c1945c9c23Fe1FB631B59",
|
||||||
|
"0xAC3649A6DFBBB230632604f2fc43773977ec6E67"
|
||||||
],
|
],
|
||||||
"UNPAUSER_ROLE": [
|
"UNPAUSER_ROLE": [
|
||||||
"0x58Dc7Bf9eD1f4890A7505D5bE4E4252978eAF655"
|
"0xB279A562C726F9F3011c1945c9c23Fe1FB631B59",
|
||||||
|
"0xAC3649A6DFBBB230632604f2fc43773977ec6E67"
|
||||||
],
|
],
|
||||||
"FUND_RESCUER_ROLE": [
|
"FUND_RESCUER_ROLE": [
|
||||||
"0x58Dc7Bf9eD1f4890A7505D5bE4E4252978eAF655"
|
"0xF621770E96bcf1335150faecf77D757faf7ca4A9"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"base": {
|
"base": {
|
||||||
"EXECUTOR_SETTER_ROLE": [
|
"EXECUTOR_SETTER_ROLE": [
|
||||||
"0x58Dc7Bf9eD1f4890A7505D5bE4E4252978eAF655"
|
"0x06e580B872a37402764f909FCcAb0Eb5bb38fe23"
|
||||||
],
|
],
|
||||||
"PAUSER_ROLE": [
|
"PAUSER_ROLE": [
|
||||||
"0x58Dc7Bf9eD1f4890A7505D5bE4E4252978eAF655"
|
"0xB279A562C726F9F3011c1945c9c23Fe1FB631B59",
|
||||||
|
"0xAC3649A6DFBBB230632604f2fc43773977ec6E67"
|
||||||
],
|
],
|
||||||
"UNPAUSER_ROLE": [
|
"UNPAUSER_ROLE": [
|
||||||
"0x58Dc7Bf9eD1f4890A7505D5bE4E4252978eAF655"
|
"0xB279A562C726F9F3011c1945c9c23Fe1FB631B59",
|
||||||
|
"0xAC3649A6DFBBB230632604f2fc43773977ec6E67"
|
||||||
],
|
],
|
||||||
"FUND_RESCUER_ROLE": [
|
"FUND_RESCUER_ROLE": [
|
||||||
"0x58Dc7Bf9eD1f4890A7505D5bE4E4252978eAF655"
|
"0xF621770E96bcf1335150faecf77D757faf7ca4A9"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"unichain": {
|
"unichain": {
|
||||||
"EXECUTOR_SETTER_ROLE": [
|
"EXECUTOR_SETTER_ROLE": [
|
||||||
"0x58Dc7Bf9eD1f4890A7505D5bE4E4252978eAF655"
|
"0x06e580B872a37402764f909FCcAb0Eb5bb38fe23"
|
||||||
],
|
],
|
||||||
"PAUSER_ROLE": [
|
"PAUSER_ROLE": [
|
||||||
"0x58Dc7Bf9eD1f4890A7505D5bE4E4252978eAF655"
|
"0xB279A562C726F9F3011c1945c9c23Fe1FB631B59",
|
||||||
|
"0xAC3649A6DFBBB230632604f2fc43773977ec6E67"
|
||||||
],
|
],
|
||||||
"UNPAUSER_ROLE": [
|
"UNPAUSER_ROLE": [
|
||||||
"0x58Dc7Bf9eD1f4890A7505D5bE4E4252978eAF655"
|
"0xB279A562C726F9F3011c1945c9c23Fe1FB631B59",
|
||||||
|
"0xAC3649A6DFBBB230632604f2fc43773977ec6E67"
|
||||||
],
|
],
|
||||||
"FUND_RESCUER_ROLE": [
|
"FUND_RESCUER_ROLE": [
|
||||||
"0x58Dc7Bf9eD1f4890A7505D5bE4E4252978eAF655"
|
"0xF621770E96bcf1335150faecf77D757faf7ca4A9"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -26,14 +26,12 @@ async function main() {
|
|||||||
|
|
||||||
const roles = {
|
const roles = {
|
||||||
EXECUTOR_SETTER_ROLE: "0x6a1dd52dcad5bd732e45b6af4e7344fa284e2d7d4b23b5b09cb55d36b0685c87",
|
EXECUTOR_SETTER_ROLE: "0x6a1dd52dcad5bd732e45b6af4e7344fa284e2d7d4b23b5b09cb55d36b0685c87",
|
||||||
FEE_SETTER_ROLE: "0xe6ad9a47fbda1dc18de1eb5eeb7d935e5e81b4748f3cfc61e233e64f88182060",
|
|
||||||
PAUSER_ROLE: "0x65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a",
|
PAUSER_ROLE: "0x65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a",
|
||||||
UNPAUSER_ROLE: "0x427da25fe773164f88948d3e215c94b6554e2ed5e5f203a821c9f2f6131cf75a",
|
UNPAUSER_ROLE: "0x427da25fe773164f88948d3e215c94b6554e2ed5e5f203a821c9f2f6131cf75a",
|
||||||
FUND_RESCUER_ROLE: "0x912e45d663a6f4cc1d0491d8f046e06c616f40352565ea1cdb86a0e1aaefa41b"
|
FUND_RESCUER_ROLE: "0x912e45d663a6f4cc1d0491d8f046e06c616f40352565ea1cdb86a0e1aaefa41b"
|
||||||
};
|
};
|
||||||
|
|
||||||
// Iterate through roles and grant them to the corresponding addresses
|
// Iterate through roles and grant them to the corresponding addresses
|
||||||
let nonceOffset = 0
|
|
||||||
for (const [roleName, roleHash] of Object.entries(roles)) {
|
for (const [roleName, roleHash] of Object.entries(roles)) {
|
||||||
const addresses = rolesDict[network][roleName];
|
const addresses = rolesDict[network][roleName];
|
||||||
if (addresses && addresses.length > 0) {
|
if (addresses && addresses.length > 0) {
|
||||||
@@ -45,8 +43,7 @@ async function main() {
|
|||||||
value: "0",
|
value: "0",
|
||||||
};
|
};
|
||||||
|
|
||||||
const txHash = await proposeOrSendTransaction(safeAddress, txData, signer, "batchGrantRole", nonceOffset);
|
const txHash = await proposeOrSendTransaction(safeAddress, txData, signer, "batchGrantRole");
|
||||||
nonceOffset += 1
|
|
||||||
console.log(`Role ${roleName} granted at TX hash: ${txHash}`);
|
console.log(`Role ${roleName} granted at TX hash: ${txHash}`);
|
||||||
} else {
|
} else {
|
||||||
console.log(`No addresses found for role ${roleName}`);
|
console.log(`No addresses found for role ${roleName}`);
|
||||||
|
|||||||
@@ -3,11 +3,17 @@ const Safe = require('@safe-global/protocol-kit').default;
|
|||||||
const {EthersAdapter} = require('@safe-global/protocol-kit');
|
const {EthersAdapter} = require('@safe-global/protocol-kit');
|
||||||
const {default: SafeApiKit} = require("@safe-global/api-kit");
|
const {default: SafeApiKit} = require("@safe-global/api-kit");
|
||||||
|
|
||||||
const txServiceUrl = 'https://safe-transaction-mainnet.safe.global';
|
const txServiceUrls = {
|
||||||
|
mainnet: "https://safe-transaction-mainnet.safe.global",
|
||||||
|
base: "https://safe-transaction-base.safe.global",
|
||||||
|
unichain: "https://safe-transaction-unichain.safe.global",
|
||||||
|
};
|
||||||
|
|
||||||
async function proposeOrSendTransaction(safeAddress, txData, signer, methodName, nonceOffset = 0) {
|
const txServiceUrl = txServiceUrls[hre.network.name];
|
||||||
|
|
||||||
|
async function proposeOrSendTransaction(safeAddress, txData, signer, methodName) {
|
||||||
if (safeAddress) {
|
if (safeAddress) {
|
||||||
return proposeTransaction(safeAddress, txData, signer, methodName, nonceOffset);
|
return proposeTransaction(safeAddress, txData, signer, methodName);
|
||||||
} else {
|
} else {
|
||||||
console.log(`Executing the transaction directly`);
|
console.log(`Executing the transaction directly`);
|
||||||
const tx = await signer.sendTransaction(txData);
|
const tx = await signer.sendTransaction(txData);
|
||||||
@@ -16,7 +22,7 @@ async function proposeOrSendTransaction(safeAddress, txData, signer, methodName,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function proposeTransaction(safeAddress, txData, signer, methodName, nonceOffset = 0) {
|
async function proposeTransaction(safeAddress, txData, signer, methodName) {
|
||||||
const signerAddress = await signer.getAddress();
|
const signerAddress = await signer.getAddress();
|
||||||
console.log(`Proposing transaction to Safe: ${safeAddress} with account: ${signerAddress}`);
|
console.log(`Proposing transaction to Safe: ${safeAddress} with account: ${signerAddress}`);
|
||||||
|
|
||||||
@@ -31,8 +37,13 @@ async function proposeTransaction(safeAddress, txData, signer, methodName, nonce
|
|||||||
ethAdapter,
|
ethAdapter,
|
||||||
safeAddress,
|
safeAddress,
|
||||||
});
|
});
|
||||||
|
let next_nonce = await safeService.getNextNonce(safeAddress);
|
||||||
const safeTransaction = await safeSdk.createTransaction({safeTransactionData: txData});
|
const safeTransaction = await safeSdk.createTransaction({
|
||||||
|
safeTransactionData: {
|
||||||
|
...txData,
|
||||||
|
nonce: next_nonce
|
||||||
|
}
|
||||||
|
});
|
||||||
const safeTxHash = await safeSdk.getTransactionHash(safeTransaction);
|
const safeTxHash = await safeSdk.getTransactionHash(safeTransaction);
|
||||||
const senderSignature = await safeSdk.signTransactionHash(safeTxHash);
|
const senderSignature = await safeSdk.signTransactionHash(safeTxHash);
|
||||||
|
|
||||||
@@ -43,7 +54,7 @@ async function proposeTransaction(safeAddress, txData, signer, methodName, nonce
|
|||||||
senderAddress: signerAddress,
|
senderAddress: signerAddress,
|
||||||
senderSignature: senderSignature.data,
|
senderSignature: senderSignature.data,
|
||||||
origin: `Proposed from hardhat: ${methodName}`,
|
origin: `Proposed from hardhat: ${methodName}`,
|
||||||
nonce: await safeService.getNextNonce(safeAddress) + nonceOffset,
|
nonce: next_nonce,
|
||||||
};
|
};
|
||||||
|
|
||||||
await safeService.proposeTransaction(proposeArgs);
|
await safeService.proposeTransaction(proposeArgs);
|
||||||
|
|||||||
Reference in New Issue
Block a user