Skip to content

Commit

Permalink
improve approval setup
Browse files Browse the repository at this point in the history
  • Loading branch information
maxklenk committed Jun 26, 2024
1 parent 86ad496 commit 71a157d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
4 changes: 2 additions & 2 deletions script/config.example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ DEPLOY_CONFIG_FILE_PATH="config/"
# exclude all test networks: EXCLUDE_NETWORKS="bsctest,goerli,sepolia,mumbai,lineatest,localanvil"
# exclude all production networks: EXCLUDE_NETWORKS="mainnet,polygon,bsc,gnosis,fantom,okx,avalanche,arbitrum,optimism,moonriver,moonbeam,celo,fuse,cronos,velas,harmony,evmos,aurora,boba,nova"
#EXCLUDE_NETWORKS="gnosis,okx,moonbeam,celo,fuse,cronos,velas,harmony,evmos,boba,nova,bsctest,goerli,sepolia,mumbai,lineatest"
EXCLUDE_NETWORKS="lineatest,localanvil"
EXCLUDE_NETWORKS="bsc-testnet,goerli,sepolia,mumbai,lineatest,localanvil,velas"

# a list of all networks that are testnets
TEST_NETWORKS="bsc-testnet,goerli,sepolia,mumbai,lineatest,localanvil"
Expand All @@ -59,7 +59,7 @@ TEST_NETWORKS="bsc-testnet,goerli,sepolia,mumbai,lineatest,localanvil"
DEBUG=true

# defines if newly deployed contracts should be verified or not
VERIFY_CONTRACTS=false
VERIFY_CONTRACTS=true

# contract verification will be deactivated for any network listed here
DO_NOT_VERIFY_IN_THESE_NETWORKS="gnosis,testNetwork,aurora,localanvil"
Expand Down
2 changes: 1 addition & 1 deletion script/tasks/diamondSyncSigs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function diamondSyncSigs {
# ensure that gas price is below maximum threshold (for mainnet only)
doNotContinueUnlessGasIsBelowThreshold "$NETWORK"

tsx ./script/tasks/diamondSyncSigs.ts --network "$NETWORK" --rpcUrl "$RPC_URL" --privateKey "$PRIVATE_KEY"
ts-node ./script/tasks/diamondSyncSigs.ts --network "$NETWORK" --rpcUrl "$RPC_URL" --privateKey "$PRIVATE_KEY"

# check the return code of the last call
if [ $? -eq 0 ]; then
Expand Down
30 changes: 18 additions & 12 deletions script/tasks/diamondSyncSigs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ const main = defineCommand({
const chainName = chainNameMappings[network] || network
const chain: Chain = chainMap[chainName]

console.log(`Checking signature for ${chain.name}`)

// Fetch list of deployed contracts
const deployedContracts = await import(
`../../deployments/${network.toLowerCase()}.json`
Expand Down Expand Up @@ -101,19 +103,23 @@ const main = defineCommand({
account,
})

// Approve function signatures
console.log('Approving function signatures...')
const tx = await walletClient.writeContract({
address: deployedContracts['LiFiDiamond'],
abi: parseAbi([
'function batchSetFunctionApprovalBySignature(bytes4[],bool) external',
]),
functionName: 'batchSetFunctionApprovalBySignature',
args: [sigsToApprove, true],
account,
})
if (sigsToApprove.length > 0) {
// Approve function signatures
console.log('Approving function signatures...')
const tx = await walletClient.writeContract({
address: deployedContracts['LiFiDiamond'],
abi: parseAbi([
'function batchSetFunctionApprovalBySignature(bytes4[],bool) external',
]),
functionName: 'batchSetFunctionApprovalBySignature',
args: [sigsToApprove, true],
account,
})

console.log('Transaction:', tx)
console.log('Transaction:', tx)
} else {
console.log('All Signatures are already approved.')
}
},
})

Expand Down

0 comments on commit 71a157d

Please sign in to comment.