diff --git a/package.json b/package.json index c53cb25..9decc8c 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "author": "", "license": "ISC", "dependencies": { - "@covalenthq/client-sdk": "^0.9.4", + "@covalenthq/client-sdk": "^1.0.2", "cors": "^2.8.5", "dotenv": "^16.3.1", "enquirer": "^2.4.1", diff --git a/services/decoder/protocols/wormhole/abis/wormhole-eth-core.abi.json b/services/decoder/protocols/wormhole/abis/wormhole-eth-core.abi.json new file mode 100644 index 0000000..b131484 --- /dev/null +++ b/services/decoder/protocols/wormhole/abis/wormhole-eth-core.abi.json @@ -0,0 +1,812 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldContract", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newContract", + "type": "address" + } + ], + "name": "ContractUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint32", + "name": "index", + "type": "uint32" + } + ], + "name": "GuardianSetAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "sequence", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "nonce", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "payload", + "type": "bytes" + }, + { + "indexed": false, + "internalType": "uint8", + "name": "consistencyLevel", + "type": "uint8" + } + ], + "name": "LogMessagePublished", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { "stateMutability": "payable", "type": "fallback" }, + { + "inputs": [], + "name": "chainId", + "outputs": [{ "internalType": "uint16", "name": "", "type": "uint16" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentGuardianSetIndex", + "outputs": [{ "internalType": "uint32", "name": "", "type": "uint32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint32", "name": "index", "type": "uint32" } + ], + "name": "getGuardianSet", + "outputs": [ + { + "components": [ + { + "internalType": "address[]", + "name": "keys", + "type": "address[]" + }, + { + "internalType": "uint32", + "name": "expirationTime", + "type": "uint32" + } + ], + "internalType": "struct Structs.GuardianSet", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getGuardianSetExpiry", + "outputs": [{ "internalType": "uint32", "name": "", "type": "uint32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "hash", "type": "bytes32" } + ], + "name": "governanceActionIsConsumed", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "governanceChainId", + "outputs": [{ "internalType": "uint16", "name": "", "type": "uint16" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "governanceContract", + "outputs": [ + { "internalType": "bytes32", "name": "", "type": "bytes32" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "impl", "type": "address" } + ], + "name": "isInitialized", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "messageFee", + "outputs": [ + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "emitter", "type": "address" } + ], + "name": "nextSequence", + "outputs": [{ "internalType": "uint64", "name": "", "type": "uint64" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes", "name": "encodedVM", "type": "bytes" } + ], + "name": "parseAndVerifyVM", + "outputs": [ + { + "components": [ + { + "internalType": "uint8", + "name": "version", + "type": "uint8" + }, + { + "internalType": "uint32", + "name": "timestamp", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "nonce", + "type": "uint32" + }, + { + "internalType": "uint16", + "name": "emitterChainId", + "type": "uint16" + }, + { + "internalType": "bytes32", + "name": "emitterAddress", + "type": "bytes32" + }, + { + "internalType": "uint64", + "name": "sequence", + "type": "uint64" + }, + { + "internalType": "uint8", + "name": "consistencyLevel", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "payload", + "type": "bytes" + }, + { + "internalType": "uint32", + "name": "guardianSetIndex", + "type": "uint32" + }, + { + "components": [ + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "guardianIndex", + "type": "uint8" + } + ], + "internalType": "struct Structs.Signature[]", + "name": "signatures", + "type": "tuple[]" + }, + { + "internalType": "bytes32", + "name": "hash", + "type": "bytes32" + } + ], + "internalType": "struct Structs.VM", + "name": "vm", + "type": "tuple" + }, + { "internalType": "bool", "name": "valid", "type": "bool" }, + { "internalType": "string", "name": "reason", "type": "string" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "encodedUpgrade", + "type": "bytes" + } + ], + "name": "parseContractUpgrade", + "outputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "module", + "type": "bytes32" + }, + { + "internalType": "uint8", + "name": "action", + "type": "uint8" + }, + { + "internalType": "uint16", + "name": "chain", + "type": "uint16" + }, + { + "internalType": "address", + "name": "newContract", + "type": "address" + } + ], + "internalType": "struct GovernanceStructs.ContractUpgrade", + "name": "cu", + "type": "tuple" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "encodedUpgrade", + "type": "bytes" + } + ], + "name": "parseGuardianSetUpgrade", + "outputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "module", + "type": "bytes32" + }, + { + "internalType": "uint8", + "name": "action", + "type": "uint8" + }, + { + "internalType": "uint16", + "name": "chain", + "type": "uint16" + }, + { + "components": [ + { + "internalType": "address[]", + "name": "keys", + "type": "address[]" + }, + { + "internalType": "uint32", + "name": "expirationTime", + "type": "uint32" + } + ], + "internalType": "struct Structs.GuardianSet", + "name": "newGuardianSet", + "type": "tuple" + }, + { + "internalType": "uint32", + "name": "newGuardianSetIndex", + "type": "uint32" + } + ], + "internalType": "struct GovernanceStructs.GuardianSetUpgrade", + "name": "gsu", + "type": "tuple" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "encodedSetMessageFee", + "type": "bytes" + } + ], + "name": "parseSetMessageFee", + "outputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "module", + "type": "bytes32" + }, + { + "internalType": "uint8", + "name": "action", + "type": "uint8" + }, + { + "internalType": "uint16", + "name": "chain", + "type": "uint16" + }, + { + "internalType": "uint256", + "name": "messageFee", + "type": "uint256" + } + ], + "internalType": "struct GovernanceStructs.SetMessageFee", + "name": "smf", + "type": "tuple" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "encodedTransferFees", + "type": "bytes" + } + ], + "name": "parseTransferFees", + "outputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "module", + "type": "bytes32" + }, + { + "internalType": "uint8", + "name": "action", + "type": "uint8" + }, + { + "internalType": "uint16", + "name": "chain", + "type": "uint16" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "recipient", + "type": "bytes32" + } + ], + "internalType": "struct GovernanceStructs.TransferFees", + "name": "tf", + "type": "tuple" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes", "name": "encodedVM", "type": "bytes" } + ], + "name": "parseVM", + "outputs": [ + { + "components": [ + { + "internalType": "uint8", + "name": "version", + "type": "uint8" + }, + { + "internalType": "uint32", + "name": "timestamp", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "nonce", + "type": "uint32" + }, + { + "internalType": "uint16", + "name": "emitterChainId", + "type": "uint16" + }, + { + "internalType": "bytes32", + "name": "emitterAddress", + "type": "bytes32" + }, + { + "internalType": "uint64", + "name": "sequence", + "type": "uint64" + }, + { + "internalType": "uint8", + "name": "consistencyLevel", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "payload", + "type": "bytes" + }, + { + "internalType": "uint32", + "name": "guardianSetIndex", + "type": "uint32" + }, + { + "components": [ + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "guardianIndex", + "type": "uint8" + } + ], + "internalType": "struct Structs.Signature[]", + "name": "signatures", + "type": "tuple[]" + }, + { + "internalType": "bytes32", + "name": "hash", + "type": "bytes32" + } + ], + "internalType": "struct Structs.VM", + "name": "vm", + "type": "tuple" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint32", "name": "nonce", "type": "uint32" }, + { "internalType": "bytes", "name": "payload", "type": "bytes" }, + { + "internalType": "uint8", + "name": "consistencyLevel", + "type": "uint8" + } + ], + "name": "publishMessage", + "outputs": [ + { "internalType": "uint64", "name": "sequence", "type": "uint64" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "numGuardians", + "type": "uint256" + } + ], + "name": "quorum", + "outputs": [ + { + "internalType": "uint256", + "name": "numSignaturesRequiredForQuorum", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [{ "internalType": "bytes", "name": "_vm", "type": "bytes" }], + "name": "submitContractUpgrade", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "bytes", "name": "_vm", "type": "bytes" }], + "name": "submitNewGuardianSet", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "bytes", "name": "_vm", "type": "bytes" }], + "name": "submitSetMessageFee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "bytes", "name": "_vm", "type": "bytes" }], + "name": "submitTransferFees", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "hash", "type": "bytes32" }, + { + "components": [ + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { + "internalType": "uint8", + "name": "guardianIndex", + "type": "uint8" + } + ], + "internalType": "struct Structs.Signature[]", + "name": "signatures", + "type": "tuple[]" + }, + { + "components": [ + { + "internalType": "address[]", + "name": "keys", + "type": "address[]" + }, + { + "internalType": "uint32", + "name": "expirationTime", + "type": "uint32" + } + ], + "internalType": "struct Structs.GuardianSet", + "name": "guardianSet", + "type": "tuple" + } + ], + "name": "verifySignatures", + "outputs": [ + { "internalType": "bool", "name": "valid", "type": "bool" }, + { "internalType": "string", "name": "reason", "type": "string" } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint8", + "name": "version", + "type": "uint8" + }, + { + "internalType": "uint32", + "name": "timestamp", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "nonce", + "type": "uint32" + }, + { + "internalType": "uint16", + "name": "emitterChainId", + "type": "uint16" + }, + { + "internalType": "bytes32", + "name": "emitterAddress", + "type": "bytes32" + }, + { + "internalType": "uint64", + "name": "sequence", + "type": "uint64" + }, + { + "internalType": "uint8", + "name": "consistencyLevel", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "payload", + "type": "bytes" + }, + { + "internalType": "uint32", + "name": "guardianSetIndex", + "type": "uint32" + }, + { + "components": [ + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "guardianIndex", + "type": "uint8" + } + ], + "internalType": "struct Structs.Signature[]", + "name": "signatures", + "type": "tuple[]" + }, + { + "internalType": "bytes32", + "name": "hash", + "type": "bytes32" + } + ], + "internalType": "struct Structs.VM", + "name": "vm", + "type": "tuple" + } + ], + "name": "verifyVM", + "outputs": [ + { "internalType": "bool", "name": "valid", "type": "bool" }, + { "internalType": "string", "name": "reason", "type": "string" } + ], + "stateMutability": "view", + "type": "function" + }, + { "stateMutability": "payable", "type": "receive" } +] diff --git a/services/decoder/protocols/wormhole/abis/wormhole-portal-bridge.abi.json b/services/decoder/protocols/wormhole/abis/wormhole-portal-bridge.abi.json new file mode 100644 index 0000000..2d766f2 --- /dev/null +++ b/services/decoder/protocols/wormhole/abis/wormhole-portal-bridge.abi.json @@ -0,0 +1,959 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldContract", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newContract", + "type": "address" + } + ], + "name": "ContractUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint16", + "name": "emitterChainId", + "type": "uint16" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "emitterAddress", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "uint64", + "name": "sequence", + "type": "uint64" + } + ], + "name": "TransferRedeemed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "inputs": [], + "name": "WETH", + "outputs": [ + { "internalType": "contract IWETH", "name": "", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes", "name": "encoded", "type": "bytes" } + ], + "name": "_parseTransferCommon", + "outputs": [ + { + "components": [ + { + "internalType": "uint8", + "name": "payloadID", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "tokenAddress", + "type": "bytes32" + }, + { + "internalType": "uint16", + "name": "tokenChain", + "type": "uint16" + }, + { + "internalType": "bytes32", + "name": "to", + "type": "bytes32" + }, + { + "internalType": "uint16", + "name": "toChain", + "type": "uint16" + }, + { + "internalType": "uint256", + "name": "fee", + "type": "uint256" + } + ], + "internalType": "struct BridgeStructs.Transfer", + "name": "transfer", + "type": "tuple" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "tokenAddress", + "type": "address" + }, + { "internalType": "uint32", "name": "nonce", "type": "uint32" } + ], + "name": "attestToken", + "outputs": [ + { "internalType": "uint64", "name": "sequence", "type": "uint64" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint16", "name": "chainId_", "type": "uint16" } + ], + "name": "bridgeContracts", + "outputs": [ + { "internalType": "bytes32", "name": "", "type": "bytes32" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "chainId", + "outputs": [{ "internalType": "uint16", "name": "", "type": "uint16" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes", "name": "encodedVm", "type": "bytes" } + ], + "name": "completeTransfer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes", "name": "encodedVm", "type": "bytes" } + ], + "name": "completeTransferAndUnwrapETH", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes", "name": "encodedVm", "type": "bytes" } + ], + "name": "completeTransferAndUnwrapETHWithPayload", + "outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes", "name": "encodedVm", "type": "bytes" } + ], + "name": "completeTransferWithPayload", + "outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes", "name": "encodedVm", "type": "bytes" } + ], + "name": "createWrapped", + "outputs": [ + { "internalType": "address", "name": "token", "type": "address" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint8", + "name": "payloadID", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "tokenAddress", + "type": "bytes32" + }, + { + "internalType": "uint16", + "name": "tokenChain", + "type": "uint16" + }, + { + "internalType": "uint8", + "name": "decimals", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "symbol", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "name", + "type": "bytes32" + } + ], + "internalType": "struct BridgeStructs.AssetMeta", + "name": "meta", + "type": "tuple" + } + ], + "name": "encodeAssetMeta", + "outputs": [ + { "internalType": "bytes", "name": "encoded", "type": "bytes" } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint8", + "name": "payloadID", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "tokenAddress", + "type": "bytes32" + }, + { + "internalType": "uint16", + "name": "tokenChain", + "type": "uint16" + }, + { + "internalType": "bytes32", + "name": "to", + "type": "bytes32" + }, + { + "internalType": "uint16", + "name": "toChain", + "type": "uint16" + }, + { + "internalType": "uint256", + "name": "fee", + "type": "uint256" + } + ], + "internalType": "struct BridgeStructs.Transfer", + "name": "transfer", + "type": "tuple" + } + ], + "name": "encodeTransfer", + "outputs": [ + { "internalType": "bytes", "name": "encoded", "type": "bytes" } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint8", + "name": "payloadID", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "tokenAddress", + "type": "bytes32" + }, + { + "internalType": "uint16", + "name": "tokenChain", + "type": "uint16" + }, + { + "internalType": "bytes32", + "name": "to", + "type": "bytes32" + }, + { + "internalType": "uint16", + "name": "toChain", + "type": "uint16" + }, + { + "internalType": "bytes32", + "name": "fromAddress", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "payload", + "type": "bytes" + } + ], + "internalType": "struct BridgeStructs.TransferWithPayload", + "name": "transfer", + "type": "tuple" + } + ], + "name": "encodeTransferWithPayload", + "outputs": [ + { "internalType": "bytes", "name": "encoded", "type": "bytes" } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "evmChainId", + "outputs": [ + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "finality", + "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "hash", "type": "bytes32" } + ], + "name": "governanceActionIsConsumed", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "governanceChainId", + "outputs": [{ "internalType": "uint16", "name": "", "type": "uint16" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "governanceContract", + "outputs": [ + { "internalType": "bytes32", "name": "", "type": "bytes32" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { "internalType": "address", "name": "", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "isFork", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "impl", "type": "address" } + ], + "name": "isInitialized", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "hash", "type": "bytes32" } + ], + "name": "isTransferCompleted", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" } + ], + "name": "isWrappedAsset", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" } + ], + "name": "outstandingBridged", + "outputs": [ + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes", "name": "encoded", "type": "bytes" } + ], + "name": "parseAssetMeta", + "outputs": [ + { + "components": [ + { + "internalType": "uint8", + "name": "payloadID", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "tokenAddress", + "type": "bytes32" + }, + { + "internalType": "uint16", + "name": "tokenChain", + "type": "uint16" + }, + { + "internalType": "uint8", + "name": "decimals", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "symbol", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "name", + "type": "bytes32" + } + ], + "internalType": "struct BridgeStructs.AssetMeta", + "name": "meta", + "type": "tuple" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes", "name": "encoded", "type": "bytes" } + ], + "name": "parsePayloadID", + "outputs": [ + { "internalType": "uint8", "name": "payloadID", "type": "uint8" } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "encodedRecoverChainId", + "type": "bytes" + } + ], + "name": "parseRecoverChainId", + "outputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "module", + "type": "bytes32" + }, + { + "internalType": "uint8", + "name": "action", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "evmChainId", + "type": "uint256" + }, + { + "internalType": "uint16", + "name": "newChainId", + "type": "uint16" + } + ], + "internalType": "struct BridgeStructs.RecoverChainId", + "name": "rci", + "type": "tuple" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes", "name": "encoded", "type": "bytes" } + ], + "name": "parseRegisterChain", + "outputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "module", + "type": "bytes32" + }, + { + "internalType": "uint8", + "name": "action", + "type": "uint8" + }, + { + "internalType": "uint16", + "name": "chainId", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "emitterChainID", + "type": "uint16" + }, + { + "internalType": "bytes32", + "name": "emitterAddress", + "type": "bytes32" + } + ], + "internalType": "struct BridgeStructs.RegisterChain", + "name": "chain", + "type": "tuple" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes", "name": "encoded", "type": "bytes" } + ], + "name": "parseTransfer", + "outputs": [ + { + "components": [ + { + "internalType": "uint8", + "name": "payloadID", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "tokenAddress", + "type": "bytes32" + }, + { + "internalType": "uint16", + "name": "tokenChain", + "type": "uint16" + }, + { + "internalType": "bytes32", + "name": "to", + "type": "bytes32" + }, + { + "internalType": "uint16", + "name": "toChain", + "type": "uint16" + }, + { + "internalType": "uint256", + "name": "fee", + "type": "uint256" + } + ], + "internalType": "struct BridgeStructs.Transfer", + "name": "transfer", + "type": "tuple" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes", "name": "encoded", "type": "bytes" } + ], + "name": "parseTransferWithPayload", + "outputs": [ + { + "components": [ + { + "internalType": "uint8", + "name": "payloadID", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "tokenAddress", + "type": "bytes32" + }, + { + "internalType": "uint16", + "name": "tokenChain", + "type": "uint16" + }, + { + "internalType": "bytes32", + "name": "to", + "type": "bytes32" + }, + { + "internalType": "uint16", + "name": "toChain", + "type": "uint16" + }, + { + "internalType": "bytes32", + "name": "fromAddress", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "payload", + "type": "bytes" + } + ], + "internalType": "struct BridgeStructs.TransferWithPayload", + "name": "transfer", + "type": "tuple" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes", "name": "encoded", "type": "bytes" } + ], + "name": "parseUpgrade", + "outputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "module", + "type": "bytes32" + }, + { + "internalType": "uint8", + "name": "action", + "type": "uint8" + }, + { + "internalType": "uint16", + "name": "chainId", + "type": "uint16" + }, + { + "internalType": "bytes32", + "name": "newContract", + "type": "bytes32" + } + ], + "internalType": "struct BridgeStructs.UpgradeContract", + "name": "chain", + "type": "tuple" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes", "name": "encodedVM", "type": "bytes" } + ], + "name": "registerChain", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes", "name": "encodedVM", "type": "bytes" } + ], + "name": "submitRecoverChainId", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "tokenImplementation", + "outputs": [ + { "internalType": "address", "name": "", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" }, + { + "internalType": "uint16", + "name": "recipientChain", + "type": "uint16" + }, + { + "internalType": "bytes32", + "name": "recipient", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "arbiterFee", + "type": "uint256" + }, + { "internalType": "uint32", "name": "nonce", "type": "uint32" } + ], + "name": "transferTokens", + "outputs": [ + { "internalType": "uint64", "name": "sequence", "type": "uint64" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" }, + { + "internalType": "uint16", + "name": "recipientChain", + "type": "uint16" + }, + { + "internalType": "bytes32", + "name": "recipient", + "type": "bytes32" + }, + { "internalType": "uint32", "name": "nonce", "type": "uint32" }, + { "internalType": "bytes", "name": "payload", "type": "bytes" } + ], + "name": "transferTokensWithPayload", + "outputs": [ + { "internalType": "uint64", "name": "sequence", "type": "uint64" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes", "name": "encodedVm", "type": "bytes" } + ], + "name": "updateWrapped", + "outputs": [ + { "internalType": "address", "name": "token", "type": "address" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes", "name": "encodedVM", "type": "bytes" } + ], + "name": "upgrade", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "wormhole", + "outputs": [ + { + "internalType": "contract IWormhole", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint16", + "name": "recipientChain", + "type": "uint16" + }, + { + "internalType": "bytes32", + "name": "recipient", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "arbiterFee", + "type": "uint256" + }, + { "internalType": "uint32", "name": "nonce", "type": "uint32" } + ], + "name": "wrapAndTransferETH", + "outputs": [ + { "internalType": "uint64", "name": "sequence", "type": "uint64" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint16", + "name": "recipientChain", + "type": "uint16" + }, + { + "internalType": "bytes32", + "name": "recipient", + "type": "bytes32" + }, + { "internalType": "uint32", "name": "nonce", "type": "uint32" }, + { "internalType": "bytes", "name": "payload", "type": "bytes" } + ], + "name": "wrapAndTransferETHWithPayload", + "outputs": [ + { "internalType": "uint64", "name": "sequence", "type": "uint64" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint16", + "name": "tokenChainId", + "type": "uint16" + }, + { + "internalType": "bytes32", + "name": "tokenAddress", + "type": "bytes32" + } + ], + "name": "wrappedAsset", + "outputs": [ + { "internalType": "address", "name": "", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { "stateMutability": "payable", "type": "receive" } +] diff --git a/services/decoder/protocols/wormhole/wormhole.configs.ts b/services/decoder/protocols/wormhole/wormhole.configs.ts new file mode 100644 index 0000000..57236d5 --- /dev/null +++ b/services/decoder/protocols/wormhole/wormhole.configs.ts @@ -0,0 +1,144 @@ +import { type Configs } from "../../decoder.types"; + +const configs: Configs = [ + { + address: "0x3ee18b2214aff97000d974cf647e7c347e8fa585", + is_factory: false, + protocol_name: "wormhole", + chain_name: "eth-mainnet", + }, + { + address: "0x98f3c9e6E3fAce36bAAd05FE09d375Ef1464288B", + is_factory: false, + protocol_name: "wormhole", + chain_name: "eth-mainnet", + }, + { + address: "0xB6F6D86a8f9879A9c87f643768d9efc38c1Da6E7", + is_factory: false, + protocol_name: "wormhole", + chain_name: "bsc-mainnet", + }, + { + address: "0x98f3c9e6E3fAce36bAAd05FE09d375Ef1464288B", + is_factory: false, + protocol_name: "wormhole", + chain_name: "bsc-mainnet", + }, + { + address: "0x5a58505a96D1dbf8dF91cB21B54419FC36e93fdE", + is_factory: false, + protocol_name: "wormhole", + chain_name: "matic-mainnet", + }, + { + address: "0x7A4B5a56256163F07b2C80A7cA55aBE66c4ec4d7", + is_factory: false, + protocol_name: "wormhole", + chain_name: "matic-mainnet", + }, + { + address: "0x0e082F06FF657D94310cB8cE8B0D9a04541d8052", + is_factory: false, + protocol_name: "wormhole", + chain_name: "avalanche-mainnet", + }, + { + address: "0x54a8e5f9c4CbA08F9943965859F6c34eAF03E26c", + is_factory: false, + protocol_name: "wormhole", + chain_name: "avalanche-mainnet", + }, + { + address: "0x5848C791e09901b40A9Ef749f2a6735b418d7564", + is_factory: false, + protocol_name: "wormhole", + chain_name: "emerald-paratime-mainnet", + }, + { + address: "0xfE8cD454b4A1CA468B57D79c0cc77Ef5B6f64585", + is_factory: false, + protocol_name: "wormhole", + chain_name: "emerald-paratime-mainnet", + }, + { + address: "0xa321448d90d4e5b0A732867c18eA198e75CAC48E", + is_factory: false, + protocol_name: "wormhole", + chain_name: "aurora-mainnet", + }, + { + address: "0x51b5123a7b0F9b2bA265f9c4C8de7D78D52f510F", + is_factory: false, + protocol_name: "wormhole", + chain_name: "aurora-mainnet", + }, + { + address: "0x796Dff6D74F3E27060B71255Fe517BFb23C93eed", + is_factory: false, + protocol_name: "wormhole", + chain_name: "celo-mainnet", + }, + { + address: "0xa321448d90d4e5b0A732867c18eA198e75CAC48E", + is_factory: false, + protocol_name: "wormhole", + chain_name: "celo-mainnet", + }, + { + address: "0xb1731c586ca89a23809861c6103f0b96b3f57d92", + is_factory: false, + protocol_name: "wormhole", + chain_name: "moonbeam-mainnet", + }, + { + address: "0xC8e2b0cD52Cf01b0Ce87d389Daa3d414d4cE29f3", + is_factory: false, + protocol_name: "wormhole", + chain_name: "moonbeam-mainnet", + }, + { + address: "0xa5f208e072434bC67592E4C49C1B991BA79BCA46", + is_factory: false, + protocol_name: "wormhole", + chain_name: "arbitrum-mainnet", + }, + { + address: "0x0b2402144Bb366A632D14B83F244D2e0e21bD39c", + is_factory: false, + protocol_name: "wormhole", + chain_name: "arbitrum-mainnet", + }, + { + address: "0x1D68124e65faFC907325e3EDbF8c4d84499DAa8b", + is_factory: false, + protocol_name: "wormhole", + chain_name: "optimism-mainnet", + }, + { + address: "0xEe91C335eab126dF5fDB3797EA9d6aD93aeC9722", + is_factory: false, + protocol_name: "wormhole", + chain_name: "optimism-mainnet", + }, + { + address: "0xa321448d90d4e5b0A732867c18eA198e75CAC48E", + is_factory: false, + protocol_name: "wormhole", + chain_name: "gnosis-mainnet", + }, + { + address: "0x8d2de8d2f73F1F4cAB472AC9A881C9b123C79627", + is_factory: false, + protocol_name: "wormhole", + chain_name: "base-mainnet", + }, + { + address: "0xbebdb6C8ddC678FfA9f8748f85C815C556Dd8ac6", + is_factory: false, + protocol_name: "wormhole", + chain_name: "base-mainnet", + }, +]; + +export default configs; diff --git a/services/decoder/protocols/wormhole/wormhole.decoders.ts b/services/decoder/protocols/wormhole/wormhole.decoders.ts new file mode 100644 index 0000000..08db792 --- /dev/null +++ b/services/decoder/protocols/wormhole/wormhole.decoders.ts @@ -0,0 +1,151 @@ +import { GoldRushDecoder } from "../../decoder"; +import type { EventDetails } from "../../decoder.types"; +import { type EventType } from "../../decoder.types"; +import { + DECODED_ACTION, + DECODED_EVENT_CATEGORY, +} from "../../decoder.constants"; +import { decodeEventLog, type Abi } from "viem"; +import PORTAL_BRIDGE_ABI from "./abis/wormhole-portal-bridge.abi.json"; +import ETH_CORE_ABI from "./abis/wormhole-eth-core.abi.json"; + +GoldRushDecoder.on( + "wormhole:TransferRedeemed", + [ + "eth-mainnet", + "arbitrum-mainnet", + "bsc-mainnet", + "matic-mainnet", + "avalanche-mainnet", + "emerald-paratime-mainnet", + "aurora-mainnet", + "celo-mainnet", + "moonbeam-mainnet", + "optimism-mainnet", + "base-mainnet", + ], + PORTAL_BRIDGE_ABI as Abi, + async (log_event, tx, chain_name, covalent_client): Promise => { + const { raw_log_data, raw_log_topics } = log_event; + + const { args: decoded } = decodeEventLog({ + abi: PORTAL_BRIDGE_ABI, + topics: raw_log_topics as [], + data: raw_log_data as `0x${string}`, + eventName: "TransferRedeemed", + }) as { + eventName: "TransferRedeemed"; + args: { + emitterChainId: string; + emitterAddress: string; + sequence: bigint; + }; + }; + + const details: EventDetails = [ + { + heading: "Emitter Chain ID", + value: decoded.emitterChainId, + type: "text", + }, + { + heading: "Emitter Address", + value: decoded.emitterAddress, + type: "address", + }, + { + heading: "Sequence", + value: decoded.sequence.toLocaleString(), + type: "text", + }, + ]; + + return { + action: DECODED_ACTION.RECEIVED_BRIDGE, + category: DECODED_EVENT_CATEGORY.BRIDGE, + name: "TransferRedeemed", + protocol: { + logo: log_event.sender_logo_url as string, + name: log_event.sender_name as string, + }, + details, + }; + } +); + +GoldRushDecoder.on( + "wormhole:LogMessagePublished", + [ + "eth-mainnet", + "arbitrum-mainnet", + "bsc-mainnet", + "matic-mainnet", + "avalanche-mainnet", + "emerald-paratime-mainnet", + "aurora-mainnet", + "celo-mainnet", + "moonbeam-mainnet", + "optimism-mainnet", + "base-mainnet", + "gnosis-mainnet", + ], + ETH_CORE_ABI as Abi, + async (log_event, tx, chain_name, covalent_client): Promise => { + const { raw_log_data, raw_log_topics } = log_event; + + const { args: decoded } = decodeEventLog({ + abi: ETH_CORE_ABI, + topics: raw_log_topics as [], + data: raw_log_data as `0x${string}`, + eventName: "LogMessagePublished", + }) as { + eventName: "LogMessagePublished"; + args: { + sender: string; + consistencyLevel: bigint; + sequence: bigint; + nonce: bigint; + payload: string; + }; + }; + + const details: EventDetails = [ + { + heading: "Sender", + value: decoded.sender, + type: "address", + }, + { + heading: "Consistency Level", + value: decoded.consistencyLevel.toLocaleString(), + type: "text", + }, + { + heading: "Sequence", + value: decoded.sequence.toLocaleString(), + type: "text", + }, + { + heading: "Nonce", + value: decoded.nonce.toLocaleString(), + type: "text", + }, + { + heading: "Payload", + value: decoded.payload, + type: "text", + }, + ]; + + return { + action: DECODED_ACTION.TRANSFERRED, + category: DECODED_EVENT_CATEGORY.BRIDGE, + name: "LogMessagePublished", + protocol: { + logo: log_event.sender_logo_url as string, + name: log_event.sender_name as string, + }, + details, + }; + } +); diff --git a/services/decoder/protocols/wormhole/wormhole.test.ts b/services/decoder/protocols/wormhole/wormhole.test.ts new file mode 100644 index 0000000..7615de7 --- /dev/null +++ b/services/decoder/protocols/wormhole/wormhole.test.ts @@ -0,0 +1,41 @@ +import request from "supertest"; +import app from "../../../../api"; +import { type EventType } from "../../decoder.types"; + +describe("wormhole", () => { + test("eth-mainnet:LogMessagePublished", async () => { + const res = await request(app) + .post("/api/v1/tx/decode") + .set({ "x-covalent-api-key": process.env.TEST_COVALENT_API_KEY }) + .send({ + chain_name: "eth-mainnet", + tx_hash: + "0x126f334fc80dc36189b2b1ef6c0fce2fcca4b16b287cf5ce8a7394a3c6710ba3", + }); + const { events } = res.body as { events: EventType[] }; + const event = events.find(({ name }) => name === "LogMessagePublished"); + if (!event) { + throw Error("Event not found"); + } + expect(event?.details?.length).toEqual(5); + }); +}); + +describe("wormhole", () => { + test("eth-mainnet:TransferRedeemed", async () => { + const res = await request(app) + .post("/api/v1/tx/decode") + .set({ "x-covalent-api-key": process.env.TEST_COVALENT_API_KEY }) + .send({ + chain_name: "eth-mainnet", + tx_hash: + "0x3fbb9deb7b0e93bc0d474dbbea82371199430f560439851cdf5a64034344ef2c", + }); + const { events } = res.body as { events: EventType[] }; + const event = events.find(({ name }) => name === "TransferRedeemed"); + if (!event) { + throw Error("Event not found"); + } + expect(event?.details?.length).toEqual(3); + }); +}); diff --git a/yarn.lock b/yarn.lock index 4a1a892..6525f8a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -314,10 +314,10 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@covalenthq/client-sdk@^0.9.4": - version "0.9.4" - resolved "https://registry.yarnpkg.com/@covalenthq/client-sdk/-/client-sdk-0.9.4.tgz#7a8e5e73a0b8f190cb6d4adb6140d6f0fbaea421" - integrity sha512-BBR2c7ST1i5dtcK8YOGKsI+wFsHO5bxrhG/bIl1rRhaKWKBS3imnDjMd+crspzpvtpKYcpHJMuX/ByVLEUco1g== +"@covalenthq/client-sdk@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@covalenthq/client-sdk/-/client-sdk-1.0.2.tgz#58937f405f65e0e5eb1c7a6264da0da9b3371aac" + integrity sha512-jOFUW83qiONMm3jDeEEtQotJXPkQ9qJW9VRqxpLPifi+Nm6HPFKdRWwSRrpE5SZMDpZuK9VZQFk3t5tiJzys7w== dependencies: "@rollup/plugin-commonjs" "^25.0.4" "@rollup/plugin-node-resolve" "^15.2.1"