From af4210698293281e8821a0e1521ec2b260b4f0d5 Mon Sep 17 00:00:00 2001 From: Kyle Date: Mon, 10 Feb 2025 16:26:40 -0600 Subject: [PATCH] chore: update hardware rental event --- src/actions-local/artifact.spec.ts | 12 +- .../payload-artifact-rented-new-fuji.json | 146 +++ src/actions/artifact.ts | 2 +- src/actions/constants.ts | 4 + .../contracts/ArtifactHardwareProviderNew.ts | 898 ++++++++++++++++++ src/actions/logParsing.ts | 34 +- src/actions/types.ts | 11 +- tenderly.yaml | 6 + 8 files changed, 1099 insertions(+), 14 deletions(-) create mode 100644 src/actions-local/payload/payload-artifact-rented-new-fuji.json create mode 100644 src/actions/generated/contracts/ArtifactHardwareProviderNew.ts diff --git a/src/actions-local/artifact.spec.ts b/src/actions-local/artifact.spec.ts index 0fd49c2..201adeb 100644 --- a/src/actions-local/artifact.spec.ts +++ b/src/actions-local/artifact.spec.ts @@ -1,5 +1,5 @@ -import { config } from "dotenv"; import { TestRuntime } from "@tenderly/actions-test"; +import { config } from "dotenv"; import { beforeAll, describe, test } from "vitest"; @@ -17,7 +17,7 @@ describe("Artifact Hardware Provider", () => { } }); - describe("Hardware Rented", () => { + describe("Hardware Rented Old", () => { test.concurrent("hardware rented event", async () => { await testRuntime.execute( hardwareRented, @@ -31,4 +31,12 @@ describe("Artifact Hardware Provider", () => { ); }); }); + describe("Hardware Rented", () => { + test.concurrent("hardware rented event", async () => { + await testRuntime.execute( + hardwareRented, + require("./payload/payload-artifact-rented-new-fuji.json") + ); + }); + }); }); diff --git a/src/actions-local/payload/payload-artifact-rented-new-fuji.json b/src/actions-local/payload/payload-artifact-rented-new-fuji.json new file mode 100644 index 0000000..6f5201d --- /dev/null +++ b/src/actions-local/payload/payload-artifact-rented-new-fuji.json @@ -0,0 +1,146 @@ +{ + "network": "43113", + "blockHash": "0xcbe2f0e397bf75a96a644ae2d230489682bb978a12fc737d991acc6310ecdcb5", + "blockNumber": 37949824, + "hash": "0x8308a0b6bb781aa0f463da59fdbf58542a5c0e5e7748abb85547b188d0e430d7", + "from": "0x8640577C7e9C906C6b1CdCeF532f030F21D2381A", + "to": "0x9D2498375B7b1EB6262B421935B948C6adBe24e1", + "logs": [ + { + "address": "0xd00ae08403B9bbb9124bB305C09058E32C39A48c", + "topics": [ + "0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c", + "0x000000000000000000000000b4315e873dbcf96ffd0acd8ea43f689d8c20fb30" + ], + "data": "0x000000000000000000000000000000000000000000000000002386f26fc10000" + }, + { + "address": "0xd00ae08403B9bbb9124bB305C09058E32C39A48c", + "topics": [ + "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", + "0x000000000000000000000000b4315e873dbcf96ffd0acd8ea43f689d8c20fb30", + "0x0000000000000000000000006fc0ae8f34b011d81fa3f89a3d877e5d7c7f9fb5" + ], + "data": "0x000000000000000000000000000000000000000000000000002386f26fc10000" + }, + { + "address": "0xACdDAEfab64c8038ED294BAA45183Cf4d6454dF7", + "topics": [ + "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", + "0x0000000000000000000000006fc0ae8f34b011d81fa3f89a3d877e5d7c7f9fb5", + "0x0000000000000000000000009d2498375b7b1eb6262b421935b948c6adbe24e1" + ], + "data": "0x00000000000000000000000000000000000000000000000000002084abb8e894" + }, + { + "address": "0x6fc0aE8F34B011D81Fa3F89a3D877e5d7c7F9fb5", + "topics": [ + "0x1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1" + ], + "data": "0x0000000000000000000000000000000000000000000000000ae382054069aeff00000000000000000000000000000000000000000000000bdc6fc5c3e218caa9" + }, + { + "address": "0x6fc0aE8F34B011D81Fa3F89a3D877e5d7c7F9fb5", + "topics": [ + "0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822", + "0x000000000000000000000000b4315e873dbcf96ffd0acd8ea43f689d8c20fb30", + "0x0000000000000000000000009d2498375b7b1eb6262b421935b948c6adbe24e1" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000002084abb8e8940000000000000000000000000000000000000000000000000000000000000000" + }, + { + "address": "0xACdDAEfab64c8038ED294BAA45183Cf4d6454dF7", + "topics": [ + "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", + "0x0000000000000000000000009d2498375b7b1eb6262b421935b948c6adbe24e1", + "0x000000000000000000000000823de3b24c6461aa91234cfb42c571def8035b9b" + ], + "data": "0x00000000000000000000000000000000000000000000000000002084abb8e894" + }, + { + "address": "0xACdDAEfab64c8038ED294BAA45183Cf4d6454dF7", + "topics": [ + "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", + "0x0000000000000000000000009d2498375b7b1eb6262b421935b948c6adbe24e1", + "0x000000000000000000000000823de3b24c6461aa91234cfb42c571def8035b9b" + ], + "data": "0x00000000000000000000000000000000000000000000000000002084abb8e894" + }, + { + "address": "0x823de3b24C6461aA91234cFb42C571dEf8035B9b", + "topics": [ + "0x3cd32fbc628a7c1c5a309e823125e5a4b8d98b9b31ad71d8338cc5f05829b199", + "0x0000000000000000000000008640577c7e9c906c6b1cdcef532f030f21d2381a" + ], + "data": "0x00000000000000000000000000000000000000000000000000002084abb8e894" + }, + { + "address": "0xACdDAEfab64c8038ED294BAA45183Cf4d6454dF7", + "topics": [ + "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", + "0x000000000000000000000000823de3b24c6461aa91234cfb42c571def8035b9b", + "0x000000000000000000000000aaa95d2e271a8293fc16e339080db83c9beb6fcf" + ], + "data": "0x00000000000000000000000000000000000000000000000000002084abb8e894" + }, + { + "address": "0xaaA95D2E271a8293FC16E339080DB83C9bEB6Fcf", + "topics": [ + "0xc4c24354aa86aa3532ebd9da7ff92230de931c78c77fcdf84544f11bf8fae753", + "0xb6e5041d5be52fb06762b7cdbdbe290c545b1c43853437eaa90e372a86bf8ecc", + "0x000000000000000000000000acddaefab64c8038ed294baa45183cf4d6454df7" + ], + "data": "0x00000000000000000000000000000000000000000000000000002084abb8e894" + }, + { + "address": "0xACdDAEfab64c8038ED294BAA45183Cf4d6454dF7", + "topics": [ + "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", + "0x000000000000000000000000823de3b24c6461aa91234cfb42c571def8035b9b", + "0x000000000000000000000000aaa95d2e271a8293fc16e339080db83c9beb6fcf" + ], + "data": "0x00000000000000000000000000000000000000000000000000002084abb8e894" + }, + { + "address": "0x827A6Ec01Bb586ac05856740BF7E06070eE555C5", + "topics": [ + "0x74fb56bc8c9f23cef4fc9e445812f596a70e1473a1c1653d15b3711751406b9d" + ], + "data": "0x0000000000000000000000008640577c7e9c906c6b1cdcef532f030f21d2381a00000000000000000000000000000000000000000000000000000000000000e09e8a01bb951fb38ff9aa0ddecfcda59c7d92b7e1569928f14e6d7bd3cce2f8600000000000000000000000000000000000000000000000000000000000015f9049f18ed70c3220abb735efdc7fce309e384d008d4bc14c846dcce9e31050e29b000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014676c0f3b7906c3472e364eb937af83b89a60bd3c000000000000000000000000" + }, + { + "address": "0x9779eF3E309337A5F1043878886e5de1cdA4B6EB", + "topics": [ + "0xc9c043637725967252aedd2704cc65fee962e7b8a1e3cf8098587a66601e50c5", + "0x000000000000000000000000676c0f3b7906c3472e364eb937af83b89a60bd3c", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ], + "data": "0x" + }, + { + "address": "0xaaA95D2E271a8293FC16E339080DB83C9bEB6Fcf", + "topics": [ + "0xd4502e0d4f9dc8fb9302d686a2b2bff55a6ed89cc5549f55b64490dff5d3e559", + "0xdc9f46fd71d4bf9bb05b835608e68c9394b627d9f45ac7ee85b2772e827e321e" + ], + "data": "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000" + }, + { + "address": "0x9D2498375B7b1EB6262B421935B948C6adBe24e1", + "topics": [ + "0xaf1005964e27ad5f17fe27fe24bb7248ecff702f011c192a9493e34b29854fca" + ], + "data": "0x000000000000000000000000676c0f3b7906c3472e364eb937af83b89a60bd3c0000000000000000000000008640577c7e9c906c6b1cdcef532f030f21d2381a9e8a01bb951fb38ff9aa0ddecfcda59c7d92b7e1569928f14e6d7bd3cce2f860000000000000000000000000000000000000000000000000002386f26fc100000000000000000000000000000000000000000000000000000000000000015f90" + } + ], + "input": "0x088ec131000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000676c0f3b7906c3472e364eb937af83b89a60bd3c00000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000015f900000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000002386f26fc100009e8a01bb951fb38ff9aa0ddecfcda59c7d92b7e1569928f14e6d7bd3cce2f8600000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000003091cb9266bce7f7570e44632d0a1313b2d3baa8d74f011fd5d31f9e221e8d9214b6ac9f1af52dbe53c1d63fdf058c2d6300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006080cebfa5e793465c3ed5db85b79d8aa9b066f980532cf809cc2db4e3a89cde4af558fd30a2aaa12f67684e5e12215e6d05388d3fd48039386404ca791e1454c78a96baafc8134b16b2e0dbfe64022aa81512451abb22e9ca4718a73920d33123", + "value": "0xe27c49886e60000", + "nonce": "0x219", + "gas": "0x10e5a0", + "gasUsed": "0x10780c", + "cumulativeGasUsed": "0x10780c", + "gasPrice": "0x3b9aca01", + "gasTipCap": "0x3b9aca01", + "gasFeeCap": "0x3b9aca01", + "alertId": null +} \ No newline at end of file diff --git a/src/actions/artifact.ts b/src/actions/artifact.ts index 5b1e6e0..cd82739 100644 --- a/src/actions/artifact.ts +++ b/src/actions/artifact.ts @@ -22,7 +22,7 @@ const handleHardwareRentedEvents = async ( // Send one message per user with all their rented nodes for (const [user, events] of Object.entries(eventsByUser)) { const nodeIDs = events.map(event => nodeHexToID(event.nodeID)); - const totalPayment = events.reduce((sum, event) => sum + BigInt(event.payment.toString()), BigInt(0)); + const totalPayment = events.reduce((sum, event) => sum + BigInt(event.paymentAmount.toString()), BigInt(0)); const duration = events[0].duration; // Assuming same duration for batch rentals const slackMessage = await SLACK_HARDWARE_RENTED_TEMPLATE({ diff --git a/src/actions/constants.ts b/src/actions/constants.ts index cfc62e3..966ef70 100644 --- a/src/actions/constants.ts +++ b/src/actions/constants.ts @@ -11,6 +11,7 @@ import { abi as GGPVault } from "./abis/ggpvault"; import { abi as Vault } from "./abis/vault"; import { MAINNET_ADDRESSES } from "./generated/addresses/43114"; import { FUJI_ADDRESSES } from "./generated/addresses/43113"; +import ArtifactHardwareProviderNew from "./generated/contracts/ArtifactHardwareProviderNew"; export const isDev = process.env.NODE_ENV === "development"; @@ -50,3 +51,6 @@ export const GGP_VAULT_INTERFACE = new utils.Interface(GGPVault); export const HARDWARE_PROVIDER_INTERFACE = new utils.Interface( ArtifactHardwareProvider ); +export const HARDWARE_PROVIDER_NEW_INTERFACE = new utils.Interface( + ArtifactHardwareProviderNew +); diff --git a/src/actions/generated/contracts/ArtifactHardwareProviderNew.ts b/src/actions/generated/contracts/ArtifactHardwareProviderNew.ts new file mode 100644 index 0000000..c50acd7 --- /dev/null +++ b/src/actions/generated/contracts/ArtifactHardwareProviderNew.ts @@ -0,0 +1,898 @@ +const ArtifactHardwareProviderNew = [ + { + inputs: [], + stateMutability: "nonpayable", + type: "constructor", + }, + { + inputs: [ + { + internalType: "uint256", + name: "expectedPayment", + type: "uint256", + }, + { + internalType: "uint256", + name: "actualPayment", + type: "uint256", + }, + ], + name: "ExcessivePayment", + type: "error", + }, + { + inputs: [ + { + internalType: "uint256", + name: "expectedPaymentAVAX", + type: "uint256", + }, + { + internalType: "uint256", + name: "userPaymentAVAX", + type: "uint256", + }, + ], + name: "InsufficientAVAXPayment", + type: "error", + }, + { + inputs: [ + { + internalType: "uint256", + name: "expectedPayment", + type: "uint256", + }, + { + internalType: "uint256", + name: "actualPayment", + type: "uint256", + }, + ], + name: "InsufficientPayment", + type: "error", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "hardwareProviderName", + type: "bytes32", + }, + ], + name: "InvalidHardwareProvider", + type: "error", + }, + { + inputs: [], + name: "InvalidPaymentReceiver", + type: "error", + }, + { + inputs: [], + name: "InvalidSubnetContract", + type: "error", + }, + { + inputs: [], + name: "PaymentPeriodNotSet", + type: "error", + }, + { + inputs: [], + name: "SubnetAlreadyRegistered", + type: "error", + }, + { + inputs: [], + name: "SwapFailed", + type: "error", + }, + { + inputs: [], + name: "ZeroAddress", + type: "error", + }, + { + inputs: [], + name: "ZeroDuration", + type: "error", + }, + { + inputs: [], + name: "ZeroNodeID", + type: "error", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "hardwareProviderName", + type: "bytes32", + }, + { + indexed: true, + internalType: "address", + name: "paymentReceiver", + type: "address", + }, + ], + name: "HardwareProviderAdded", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "hardwareProviderName", + type: "bytes32", + }, + { + indexed: true, + internalType: "address", + name: "paymentReceiver", + type: "address", + }, + ], + name: "HardwareProviderRemoved", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "user", + type: "address", + }, + { + indexed: false, + internalType: "bytes", + name: "nodeID", + type: "bytes", + }, + { + indexed: false, + internalType: "bytes32", + name: "hardwareProviderName", + type: "bytes32", + }, + { + indexed: false, + internalType: "uint256", + name: "duration", + type: "uint256", + }, + { + indexed: false, + internalType: "bytes32", + name: "paymentCurrency", + type: "bytes32", + }, + { + indexed: false, + internalType: "uint256", + name: "paymentAmount", + type: "uint256", + }, + { + indexed: false, + internalType: "bytes32", + name: "subnetID", + type: "bytes32", + }, + ], + name: "HardwareRented", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint8", + name: "version", + type: "uint8", + }, + ], + name: "Initialized", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "role", + type: "bytes32", + }, + { + indexed: true, + internalType: "bytes32", + name: "previousAdminRole", + type: "bytes32", + }, + { + indexed: true, + internalType: "bytes32", + name: "newAdminRole", + type: "bytes32", + }, + ], + name: "RoleAdminChanged", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "role", + type: "bytes32", + }, + { + indexed: true, + internalType: "address", + name: "account", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "sender", + type: "address", + }, + ], + name: "RoleGranted", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "role", + type: "bytes32", + }, + { + indexed: true, + internalType: "address", + name: "account", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "sender", + type: "address", + }, + ], + name: "RoleRevoked", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "subnetId", + type: "bytes32", + }, + { + indexed: true, + internalType: "address", + name: "contractAddress", + type: "address", + }, + ], + name: "SubnetHardwareRentalContractAdded", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "subnetId", + type: "bytes32", + }, + { + indexed: true, + internalType: "address", + name: "contractAddress", + type: "address", + }, + ], + name: "SubnetHardwareRentalContractRemoved", + type: "event", + }, + { + inputs: [], + name: "DEFAULT_ADMIN_ROLE", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "GGP_ADDR", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "JOE_LB_ROUTER", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "RENTER_ROLE", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "WAVAX_ADDR", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "providerName", + type: "bytes32", + }, + { + internalType: "address", + name: "paymentReceiver", + type: "address", + }, + ], + name: "addHardwareProvider", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + name: "approvedHardwareProviders", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "avaxPriceFeed", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getAvaxUsdPrice", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "duration", + type: "uint256", + }, + ], + name: "getExpectedPaymentAVAX", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "duration", + type: "uint256", + }, + ], + name: "getExpectedPaymentUSD", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "hardwareProviderName", + type: "bytes32", + }, + ], + name: "getHardwareProviderPaymentAddress", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getPaymentCurrency", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "role", + type: "bytes32", + }, + ], + name: "getRoleAdmin", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getSubnetID", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getSubnetName", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "role", + type: "bytes32", + }, + { + internalType: "address", + name: "account", + type: "address", + }, + ], + name: "grantRole", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "role", + type: "bytes32", + }, + { + internalType: "address", + name: "account", + type: "address", + }, + ], + name: "hasRole", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "admin", + type: "address", + }, + { + internalType: "address", + name: "_avaxPriceFeed", + type: "address", + }, + { + internalType: "uint256", + name: "_initialPayPeriod", + type: "uint256", + }, + { + internalType: "uint256", + name: "_initialPayIncrementUsd", + type: "uint256", + }, + { + internalType: "address", + name: "_ggpAddr", + type: "address", + }, + { + internalType: "address", + name: "_wavaxAddr", + type: "address", + }, + { + internalType: "address", + name: "_tjRouter", + type: "address", + }, + ], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "payIncrementUsd", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "payMargin", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "payPeriod", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "paymentCurrency", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "providerName", + type: "bytes32", + }, + { + internalType: "address", + name: "paymentReceiver", + type: "address", + }, + ], + name: "removeHardwareProvider", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "role", + type: "bytes32", + }, + { + internalType: "address", + name: "account", + type: "address", + }, + ], + name: "renounceRole", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "user", + type: "address", + }, + { + internalType: "bytes", + name: "nodeID", + type: "bytes", + }, + { + internalType: "uint256", + name: "duration", + type: "uint256", + }, + { + internalType: "bytes32", + name: "hardwareProviderName", + type: "bytes32", + }, + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + name: "rentHardware", + outputs: [], + stateMutability: "payable", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "role", + type: "bytes32", + }, + { + internalType: "address", + name: "account", + type: "address", + }, + ], + name: "revokeRole", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "newAvaxPriceFeed", + type: "address", + }, + ], + name: "setAvaxPriceFeed", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "newPayMargin", + type: "uint256", + }, + ], + name: "setPayMargin", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "newPaymentCurrency", + type: "bytes32", + }, + ], + name: "setPaymentCurrency", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "newPaymentIncrementUsd", + type: "uint256", + }, + ], + name: "setPaymentIncrementUsd", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "newPaymentPeriod", + type: "uint256", + }, + ], + name: "setPaymentPeriod", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "subnetID", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "subnetName", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes4", + name: "interfaceId", + type: "bytes4", + }, + ], + name: "supportsInterface", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, +] as const; + +export default ArtifactHardwareProviderNew; diff --git a/src/actions/logParsing.ts b/src/actions/logParsing.ts index 6a30893..facc1fb 100644 --- a/src/actions/logParsing.ts +++ b/src/actions/logParsing.ts @@ -1,8 +1,10 @@ import { Log, TransactionEvent } from "@tenderly/actions"; import { Interface } from "ethers/lib/utils"; +import { zeroHash } from "viem"; import { GGP_VAULT_INTERFACE, HARDWARE_PROVIDER_INTERFACE, + HARDWARE_PROVIDER_NEW_INTERFACE, MINIPOOL_MANAGER_INTERFACE, STAKING_INTERFACE, TOKEN_GGAVAX_INTERFACE, @@ -15,6 +17,7 @@ import { GGPStaked, GGPWithdrawn, HardwareRented, + HardwareRentedOld, MinipoolLaunched, RewardsDistributed, TargetAPRUpdated, @@ -117,22 +120,33 @@ export const getGgAvaxDepositEvent = async ( export const getHardwareRentedEvents = async ( transactionEvent: TransactionEvent ): Promise => { + let events: HardwareRented[] = []; try { - return getMatchingEvents( + // First try to get the old version (currently on mainnet) + events = getMatchingEvents( transactionEvent, HARDWARE_PROVIDER_INTERFACE, "HardwareRented" - ); + ).map((event) => ({ + ...event, + paymentAmount: event.payment, + subnetID: zeroHash, + })); } catch (e) { - return []; + console.log("Error getting hardware rented events", e); } -}; - -export const getHardwareRentedEvent = async ( - transactionEvent: TransactionEvent -): Promise => { - const events = await getHardwareRentedEvents(transactionEvent); - return events[0]; + if (!events.length) { + try { + events = getMatchingEvents( + transactionEvent, + HARDWARE_PROVIDER_NEW_INTERFACE, + "HardwareRented" + ); + } catch (e) { + console.log("Error getting hardware rented new events", e); + } + } + return events; }; export const getMinipoolLaunchedEvent = async ( diff --git a/src/actions/types.ts b/src/actions/types.ts index 9127192..a37f412 100644 --- a/src/actions/types.ts +++ b/src/actions/types.ts @@ -61,7 +61,7 @@ export interface TargetAPRUpdated extends Event { newTargetAPR: bigint; } -export interface HardwareRented extends Event { +export interface HardwareRentedOld extends Event { user: string; nodeID: string; hardwareProviderName: string; @@ -69,6 +69,15 @@ export interface HardwareRented extends Event { payment: bigint; } +export interface HardwareRented extends Event { + user: string; + nodeID: string; + hardwareProviderName: string; + duration: bigint; + paymentAmount: bigint; + subnetID: string; +} + export interface MinipoolLaunched extends Event { nodeID: string; hardwareProvider: string; diff --git a/tenderly.yaml b/tenderly.yaml index 914caab..8f06a96 100644 --- a/tenderly.yaml +++ b/tenderly.yaml @@ -25,6 +25,12 @@ actions: type: transaction transaction: filters: + - network: 43113 + eventEmitted: + contract: + address: 0x827A6Ec01Bb586ac05856740BF7E06070eE555C5 + name: HardwareRented + status: success - network: 43113 eventEmitted: contract: