Skip to content
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

feat: monitor failed tx for governance contracts [AXE-2530] #110

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,34 @@ const handleFailedTxFn = async (context, event) => {
throw new Error('INVALID_RESPONSE_LENGTH');
}

const { flowLimitExceeded, missingRole, missingAllRoles, missingAnyOfRoles, reEntrancy, notService } = await context.storage.getJson(
'ErrorsABI',
);
const {
flowLimitExceeded,
missingRole,
missingAllRoles,
missingAnyOfRoles,
reEntrancy,
notService,
notSigner,
alreadyVoted,
invalidSigners,
invalidSignerThreshold,
duplicateSigner,
notGovernance,
notSelf,
} = await context.storage.getJson('ErrorsABI');
const flowLimitExceededHash = ethers.utils.keccak256(toUtf8Bytes(flowLimitExceeded)).slice(0, 10);
const missingRoleHash = ethers.utils.keccak256(toUtf8Bytes(missingRole)).slice(0, 10);
const missingAllRolesHash = ethers.utils.keccak256(toUtf8Bytes(missingAllRoles)).slice(0, 10);
const missingAnyOfRolesHash = ethers.utils.keccak256(toUtf8Bytes(missingAnyOfRoles)).slice(0, 10);
const reEntrancyHash = ethers.utils.keccak256(toUtf8Bytes(reEntrancy)).slice(0, 10);
const notServiceHash = ethers.utils.keccak256(toUtf8Bytes(notService)).slice(0, 10);
const notSignerHash = ethers.utils.keccak256(toUtf8Bytes(notSigner)).slice(0, 10);
const alreadyVotedHash = ethers.utils.keccak256(toUtf8Bytes(alreadyVoted)).slice(0, 10);
const invalidSignersHash = ethers.utils.keccak256(toUtf8Bytes(invalidSigners)).slice(0, 10);
const invalidSignerThresholdHash = ethers.utils.keccak256(toUtf8Bytes(invalidSignerThreshold)).slice(0, 10);
const duplicateSignerHash = ethers.utils.keccak256(toUtf8Bytes(duplicateSigner)).slice(0, 10);
const notGovernanceHash = ethers.utils.keccak256(toUtf8Bytes(notGovernance)).slice(0, 10);
const notSelfHash = ethers.utils.keccak256(toUtf8Bytes(notSelf)).slice(0, 10);

const errorHash = response.slice(0, 10);
console.log('errorHash: ', errorHash);
Expand All @@ -69,7 +88,7 @@ const handleFailedTxFn = async (context, event) => {
case flowLimitExceededHash:
warningOptions = ['FlowLimitExceeded', 'TokenManager'];
console.log(
`Tx reverted due to error ${toUtf8Bytes(flowLimitExceeded)} with values flowLimit ${parseInt(
`Tx reverted due to error ${flowLimitExceeded} with values flowLimit ${parseInt(
response.slice(10, 74),
16,
)} and flowAmount ${parseInt(response.slice(74, 134), 16)} for address ${event.to}`,
Expand All @@ -78,7 +97,7 @@ const handleFailedTxFn = async (context, event) => {
case missingRoleHash:
warningOptions = ['MissingRole', event.to];
console.log(
`Tx reverted due to error ${toUtf8Bytes(missingRole)} with values account ${response.slice(34, 74)} and role ${parseInt(
`Tx reverted due to error ${missingRole} with values account ${response.slice(34, 74)} and role ${parseInt(
response.slice(74, 138),
16,
)} for address ${event.to}`,
Expand All @@ -87,7 +106,7 @@ const handleFailedTxFn = async (context, event) => {
case missingAllRolesHash:
warningOptions = ['MissingAllRoles', event.to];
console.log(
`Tx reverted due to error ${toUtf8Bytes(missingAllRoles)} with values account ${response.slice(34, 74)} and role ${parseInt(
`Tx reverted due to error ${missingAllRoles} with values account ${response.slice(34, 74)} and role ${parseInt(
response.slice(74, 138),
16,
)} for address ${event.to}`,
Expand All @@ -96,21 +115,47 @@ const handleFailedTxFn = async (context, event) => {
case missingAnyOfRolesHash:
warningOptions = ['MissingAnyOfRoles', event.to];
console.log(
`Tx reverted due to error ${toUtf8Bytes(missingAnyOfRoles)} with values account ${response.slice(
34,
74,
)} and role ${parseInt(response.slice(74, 138), 16)} for address ${event.to}`,
`Tx reverted due to error ${missingAnyOfRoles} with values account ${response.slice(34, 74)} and role ${parseInt(
response.slice(74, 138),
16,
)} for address ${event.to}`,
);
break;
case reEntrancyHash:
warningOptions = ['ReEntrancy', event.to];
console.log(`Tx reverted due to error ${toUtf8Bytes(reEntrancy)} for address ${event.to}`);
console.log(`Tx reverted due to error ${reEntrancy} for address ${event.to}`);
break;
case notServiceHash:
warningOptions = ['NotService', 'TokenManager'];
console.log(
`Tx reverted due to error ${toUtf8Bytes(notService)} with value caller ${response.slice(34, 74)} for address ${event.to}`,
);
console.log(`Tx reverted due to error ${notService} with value caller ${response.slice(34, 74)} for address ${event.to}`);
break;
case notSignerHash:
warningOptions = ['NotSigner', event.to];
console.log(`Tx reverted due to error ${notSigner} for address ${event.to}`);
break;
case alreadyVotedHash:
warningOptions = ['AlreadyVoted', event.to];
console.log(`Tx reverted due to error ${alreadyVoted} for address ${event.to}`);
break;
case invalidSignersHash:
warningOptions = ['InvalidSigners', event.to];
console.log(`Tx reverted due to error ${invalidSigners} for address ${event.to}`);
break;
case invalidSignerThresholdHash:
warningOptions = ['InvalidSignerThreshold', event.to];
console.log(`Tx reverted due to error ${invalidSignerThreshold} for address ${event.to}`);
break;
case duplicateSignerHash:
warningOptions = ['DuplicateSigner', event.to];
console.log(`Tx reverted due to error ${duplicateSigner} with value account ${response.slice(34, 74)} for address ${event.to}`);
break;
case notGovernanceHash:
warningOptions = ['NotGovernance', 'InterchainGovernance'];
console.log(`Tx reverted due to error ${notGovernance} for address ${event.to}`);
break;
case notSelfHash:
warningOptions = ['NotSelf', 'InterchainGovernance'];
console.log(`Tx reverted due to error ${notSelf} for address ${event.to}`);
break;
default:
console.log('No Error match found');
Expand Down
Loading