From 0a57341aba942db54fd8d57277aabf69ea183f83 Mon Sep 17 00:00:00 2001 From: Gajesh Naik Date: Tue, 21 May 2024 19:07:15 +0530 Subject: [PATCH] doc update --- Makefile | 4 +- README.md | 5 ++- dist/index.js | 105 ---------------------------------------------- package-lock.json | 24 ++++++++--- package.json | 3 +- yarn.lock | 20 +++++++-- 6 files changed, 43 insertions(+), 118 deletions(-) delete mode 100644 dist/index.js diff --git a/Makefile b/Makefile index eabfaf12..0ce3f756 100644 --- a/Makefile +++ b/Makefile @@ -46,10 +46,10 @@ send-fund: ## sends fund to the operator saved in tests/keys/test.ecdsa.key.json # TODO: piping to zap-pretty only works when zapper environment is set to production, unsure why ____OFFCHAIN_SOFTWARE___: ## start-operator: - node dist/index.js + tsc && node dist/index.js spam-tasks: - node dist/createNewTasks.js + tsc && node dist/createNewTasks.js -----------------------------: ## _____HELPER_____: ## diff --git a/README.md b/README.md index 6615c32c..f9b3361d 100644 --- a/README.md +++ b/README.md @@ -36,8 +36,11 @@ Where additional sophistication with AVSs come into the picture: 1. Make sure Docker is running 2. Run `make start-chain-with-contracts-deployed` - 2.1 This will build the contracts, start an Anvil chain, deploy the contracts to it, and leaves the chain running in the current terminal +3. Open new terminal tab and run `make start-operator` + 3.1 This will compile the AVS software and start monitering new tasks +4. Open new terminal tab and run `make spam-tasks` (Optional) + 4.1 This will spam the AVS with random names every 15 seconds ## Extensions diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e79c4447..00000000 --- a/dist/index.js +++ /dev/null @@ -1,105 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const ethers_1 = require("ethers"); -const dotenv = __importStar(require("dotenv")); -dotenv.config(); -const provider = new ethers_1.ethers.providers.JsonRpcProvider(process.env.RPC_URL); -const wallet = new ethers_1.ethers.Wallet(process.env.PRIVATE_KEY, provider); -const delegationManagerAddress = process.env.DELEGATION_MANAGER_ADDRESS; -const contractAddress = process.env.CONTRACT_ADDRESS; -const stakeRegistryAddress = process.env.STAKE_REGISTRY_ADDRESS; -const avsDirectoryAddress = process.env.AVS_DIRECTORY_ADDRESS; -const delegationABI = [{ "type": "function", "name": "DELEGATION_APPROVAL_TYPEHASH", "inputs": [], "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], "stateMutability": "view" }, { "type": "function", "name": "DOMAIN_TYPEHASH", "inputs": [], "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], "stateMutability": "view" }, { "type": "function", "name": "STAKER_DELEGATION_TYPEHASH", "inputs": [], "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], "stateMutability": "view" }, { "type": "function", "name": "beaconChainETHStrategy", "inputs": [], "outputs": [{ "name": "", "type": "address", "internalType": "contract IStrategy" }], "stateMutability": "view" }, { "type": "function", "name": "calculateCurrentStakerDelegationDigestHash", "inputs": [{ "name": "staker", "type": "address", "internalType": "address" }, { "name": "operator", "type": "address", "internalType": "address" }, { "name": "expiry", "type": "uint256", "internalType": "uint256" }], "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], "stateMutability": "view" }, { "type": "function", "name": "calculateDelegationApprovalDigestHash", "inputs": [{ "name": "staker", "type": "address", "internalType": "address" }, { "name": "operator", "type": "address", "internalType": "address" }, { "name": "_delegationApprover", "type": "address", "internalType": "address" }, { "name": "approverSalt", "type": "bytes32", "internalType": "bytes32" }, { "name": "expiry", "type": "uint256", "internalType": "uint256" }], "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], "stateMutability": "view" }, { "type": "function", "name": "calculateStakerDelegationDigestHash", "inputs": [{ "name": "staker", "type": "address", "internalType": "address" }, { "name": "_stakerNonce", "type": "uint256", "internalType": "uint256" }, { "name": "operator", "type": "address", "internalType": "address" }, { "name": "expiry", "type": "uint256", "internalType": "uint256" }], "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], "stateMutability": "view" }, { "type": "function", "name": "calculateWithdrawalRoot", "inputs": [{ "name": "withdrawal", "type": "tuple", "internalType": "struct IDelegationManager.Withdrawal", "components": [{ "name": "staker", "type": "address", "internalType": "address" }, { "name": "delegatedTo", "type": "address", "internalType": "address" }, { "name": "withdrawer", "type": "address", "internalType": "address" }, { "name": "nonce", "type": "uint256", "internalType": "uint256" }, { "name": "startBlock", "type": "uint32", "internalType": "uint32" }, { "name": "strategies", "type": "address[]", "internalType": "contract IStrategy[]" }, { "name": "shares", "type": "uint256[]", "internalType": "uint256[]" }] }], "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], "stateMutability": "pure" }, { "type": "function", "name": "completeQueuedWithdrawal", "inputs": [{ "name": "withdrawal", "type": "tuple", "internalType": "struct IDelegationManager.Withdrawal", "components": [{ "name": "staker", "type": "address", "internalType": "address" }, { "name": "delegatedTo", "type": "address", "internalType": "address" }, { "name": "withdrawer", "type": "address", "internalType": "address" }, { "name": "nonce", "type": "uint256", "internalType": "uint256" }, { "name": "startBlock", "type": "uint32", "internalType": "uint32" }, { "name": "strategies", "type": "address[]", "internalType": "contract IStrategy[]" }, { "name": "shares", "type": "uint256[]", "internalType": "uint256[]" }] }, { "name": "tokens", "type": "address[]", "internalType": "contract IERC20[]" }, { "name": "middlewareTimesIndex", "type": "uint256", "internalType": "uint256" }, { "name": "receiveAsTokens", "type": "bool", "internalType": "bool" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "completeQueuedWithdrawals", "inputs": [{ "name": "withdrawals", "type": "tuple[]", "internalType": "struct IDelegationManager.Withdrawal[]", "components": [{ "name": "staker", "type": "address", "internalType": "address" }, { "name": "delegatedTo", "type": "address", "internalType": "address" }, { "name": "withdrawer", "type": "address", "internalType": "address" }, { "name": "nonce", "type": "uint256", "internalType": "uint256" }, { "name": "startBlock", "type": "uint32", "internalType": "uint32" }, { "name": "strategies", "type": "address[]", "internalType": "contract IStrategy[]" }, { "name": "shares", "type": "uint256[]", "internalType": "uint256[]" }] }, { "name": "tokens", "type": "address[][]", "internalType": "contract IERC20[][]" }, { "name": "middlewareTimesIndexes", "type": "uint256[]", "internalType": "uint256[]" }, { "name": "receiveAsTokens", "type": "bool[]", "internalType": "bool[]" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "cumulativeWithdrawalsQueued", "inputs": [{ "name": "staker", "type": "address", "internalType": "address" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "decreaseDelegatedShares", "inputs": [{ "name": "staker", "type": "address", "internalType": "address" }, { "name": "strategy", "type": "address", "internalType": "contract IStrategy" }, { "name": "shares", "type": "uint256", "internalType": "uint256" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "delegateTo", "inputs": [{ "name": "operator", "type": "address", "internalType": "address" }, { "name": "approverSignatureAndExpiry", "type": "tuple", "internalType": "struct ISignatureUtils.SignatureWithExpiry", "components": [{ "name": "signature", "type": "bytes", "internalType": "bytes" }, { "name": "expiry", "type": "uint256", "internalType": "uint256" }] }, { "name": "approverSalt", "type": "bytes32", "internalType": "bytes32" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "delegateToBySignature", "inputs": [{ "name": "staker", "type": "address", "internalType": "address" }, { "name": "operator", "type": "address", "internalType": "address" }, { "name": "stakerSignatureAndExpiry", "type": "tuple", "internalType": "struct ISignatureUtils.SignatureWithExpiry", "components": [{ "name": "signature", "type": "bytes", "internalType": "bytes" }, { "name": "expiry", "type": "uint256", "internalType": "uint256" }] }, { "name": "approverSignatureAndExpiry", "type": "tuple", "internalType": "struct ISignatureUtils.SignatureWithExpiry", "components": [{ "name": "signature", "type": "bytes", "internalType": "bytes" }, { "name": "expiry", "type": "uint256", "internalType": "uint256" }] }, { "name": "approverSalt", "type": "bytes32", "internalType": "bytes32" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "delegatedTo", "inputs": [{ "name": "staker", "type": "address", "internalType": "address" }], "outputs": [{ "name": "", "type": "address", "internalType": "address" }], "stateMutability": "view" }, { "type": "function", "name": "delegationApprover", "inputs": [{ "name": "operator", "type": "address", "internalType": "address" }], "outputs": [{ "name": "", "type": "address", "internalType": "address" }], "stateMutability": "view" }, { "type": "function", "name": "delegationApproverSaltIsSpent", "inputs": [{ "name": "_delegationApprover", "type": "address", "internalType": "address" }, { "name": "salt", "type": "bytes32", "internalType": "bytes32" }], "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }], "stateMutability": "view" }, { "type": "function", "name": "domainSeparator", "inputs": [], "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], "stateMutability": "view" }, { "type": "function", "name": "earningsReceiver", "inputs": [{ "name": "operator", "type": "address", "internalType": "address" }], "outputs": [{ "name": "", "type": "address", "internalType": "address" }], "stateMutability": "view" }, { "type": "function", "name": "getOperatorShares", "inputs": [{ "name": "operator", "type": "address", "internalType": "address" }, { "name": "strategies", "type": "address[]", "internalType": "contract IStrategy[]" }], "outputs": [{ "name": "", "type": "uint256[]", "internalType": "uint256[]" }], "stateMutability": "view" }, { "type": "function", "name": "getWithdrawalDelay", "inputs": [{ "name": "strategies", "type": "address[]", "internalType": "contract IStrategy[]" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "increaseDelegatedShares", "inputs": [{ "name": "staker", "type": "address", "internalType": "address" }, { "name": "strategy", "type": "address", "internalType": "contract IStrategy" }, { "name": "shares", "type": "uint256", "internalType": "uint256" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "isDelegated", "inputs": [{ "name": "staker", "type": "address", "internalType": "address" }], "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }], "stateMutability": "view" }, { "type": "function", "name": "isOperator", "inputs": [{ "name": "operator", "type": "address", "internalType": "address" }], "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }], "stateMutability": "view" }, { "type": "function", "name": "migrateQueuedWithdrawals", "inputs": [{ "name": "withdrawalsToQueue", "type": "tuple[]", "internalType": "struct IStrategyManager.DeprecatedStruct_QueuedWithdrawal[]", "components": [{ "name": "strategies", "type": "address[]", "internalType": "contract IStrategy[]" }, { "name": "shares", "type": "uint256[]", "internalType": "uint256[]" }, { "name": "staker", "type": "address", "internalType": "address" }, { "name": "withdrawerAndNonce", "type": "tuple", "internalType": "struct IStrategyManager.DeprecatedStruct_WithdrawerAndNonce", "components": [{ "name": "withdrawer", "type": "address", "internalType": "address" }, { "name": "nonce", "type": "uint96", "internalType": "uint96" }] }, { "name": "withdrawalStartBlock", "type": "uint32", "internalType": "uint32" }, { "name": "delegatedAddress", "type": "address", "internalType": "address" }] }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "minWithdrawalDelayBlocks", "inputs": [], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "modifyOperatorDetails", "inputs": [{ "name": "newOperatorDetails", "type": "tuple", "internalType": "struct IDelegationManager.OperatorDetails", "components": [{ "name": "earningsReceiver", "type": "address", "internalType": "address" }, { "name": "delegationApprover", "type": "address", "internalType": "address" }, { "name": "stakerOptOutWindowBlocks", "type": "uint32", "internalType": "uint32" }] }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "operatorDetails", "inputs": [{ "name": "operator", "type": "address", "internalType": "address" }], "outputs": [{ "name": "", "type": "tuple", "internalType": "struct IDelegationManager.OperatorDetails", "components": [{ "name": "earningsReceiver", "type": "address", "internalType": "address" }, { "name": "delegationApprover", "type": "address", "internalType": "address" }, { "name": "stakerOptOutWindowBlocks", "type": "uint32", "internalType": "uint32" }] }], "stateMutability": "view" }, { "type": "function", "name": "operatorShares", "inputs": [{ "name": "operator", "type": "address", "internalType": "address" }, { "name": "strategy", "type": "address", "internalType": "contract IStrategy" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "queueWithdrawals", "inputs": [{ "name": "queuedWithdrawalParams", "type": "tuple[]", "internalType": "struct IDelegationManager.QueuedWithdrawalParams[]", "components": [{ "name": "strategies", "type": "address[]", "internalType": "contract IStrategy[]" }, { "name": "shares", "type": "uint256[]", "internalType": "uint256[]" }, { "name": "withdrawer", "type": "address", "internalType": "address" }] }], "outputs": [{ "name": "", "type": "bytes32[]", "internalType": "bytes32[]" }], "stateMutability": "nonpayable" }, { "type": "function", "name": "registerAsOperator", "inputs": [{ "name": "registeringOperatorDetails", "type": "tuple", "internalType": "struct IDelegationManager.OperatorDetails", "components": [{ "name": "earningsReceiver", "type": "address", "internalType": "address" }, { "name": "delegationApprover", "type": "address", "internalType": "address" }, { "name": "stakerOptOutWindowBlocks", "type": "uint32", "internalType": "uint32" }] }, { "name": "metadataURI", "type": "string", "internalType": "string" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "stakerNonce", "inputs": [{ "name": "staker", "type": "address", "internalType": "address" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "stakerOptOutWindowBlocks", "inputs": [{ "name": "operator", "type": "address", "internalType": "address" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "strategyWithdrawalDelayBlocks", "inputs": [{ "name": "strategy", "type": "address", "internalType": "contract IStrategy" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "undelegate", "inputs": [{ "name": "staker", "type": "address", "internalType": "address" }], "outputs": [{ "name": "withdrawalRoot", "type": "bytes32[]", "internalType": "bytes32[]" }], "stateMutability": "nonpayable" }, { "type": "function", "name": "updateOperatorMetadataURI", "inputs": [{ "name": "metadataURI", "type": "string", "internalType": "string" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "event", "name": "MinWithdrawalDelayBlocksSet", "inputs": [{ "name": "previousValue", "type": "uint256", "indexed": false, "internalType": "uint256" }, { "name": "newValue", "type": "uint256", "indexed": false, "internalType": "uint256" }], "anonymous": false }, { "type": "event", "name": "OperatorDetailsModified", "inputs": [{ "name": "operator", "type": "address", "indexed": true, "internalType": "address" }, { "name": "newOperatorDetails", "type": "tuple", "indexed": false, "internalType": "struct IDelegationManager.OperatorDetails", "components": [{ "name": "earningsReceiver", "type": "address", "internalType": "address" }, { "name": "delegationApprover", "type": "address", "internalType": "address" }, { "name": "stakerOptOutWindowBlocks", "type": "uint32", "internalType": "uint32" }] }], "anonymous": false }, { "type": "event", "name": "OperatorMetadataURIUpdated", "inputs": [{ "name": "operator", "type": "address", "indexed": true, "internalType": "address" }, { "name": "metadataURI", "type": "string", "indexed": false, "internalType": "string" }], "anonymous": false }, { "type": "event", "name": "OperatorRegistered", "inputs": [{ "name": "operator", "type": "address", "indexed": true, "internalType": "address" }, { "name": "operatorDetails", "type": "tuple", "indexed": false, "internalType": "struct IDelegationManager.OperatorDetails", "components": [{ "name": "earningsReceiver", "type": "address", "internalType": "address" }, { "name": "delegationApprover", "type": "address", "internalType": "address" }, { "name": "stakerOptOutWindowBlocks", "type": "uint32", "internalType": "uint32" }] }], "anonymous": false }, { "type": "event", "name": "OperatorSharesDecreased", "inputs": [{ "name": "operator", "type": "address", "indexed": true, "internalType": "address" }, { "name": "staker", "type": "address", "indexed": false, "internalType": "address" }, { "name": "strategy", "type": "address", "indexed": false, "internalType": "contract IStrategy" }, { "name": "shares", "type": "uint256", "indexed": false, "internalType": "uint256" }], "anonymous": false }, { "type": "event", "name": "OperatorSharesIncreased", "inputs": [{ "name": "operator", "type": "address", "indexed": true, "internalType": "address" }, { "name": "staker", "type": "address", "indexed": false, "internalType": "address" }, { "name": "strategy", "type": "address", "indexed": false, "internalType": "contract IStrategy" }, { "name": "shares", "type": "uint256", "indexed": false, "internalType": "uint256" }], "anonymous": false }, { "type": "event", "name": "StakerDelegated", "inputs": [{ "name": "staker", "type": "address", "indexed": true, "internalType": "address" }, { "name": "operator", "type": "address", "indexed": true, "internalType": "address" }], "anonymous": false }, { "type": "event", "name": "StakerForceUndelegated", "inputs": [{ "name": "staker", "type": "address", "indexed": true, "internalType": "address" }, { "name": "operator", "type": "address", "indexed": true, "internalType": "address" }], "anonymous": false }, { "type": "event", "name": "StakerUndelegated", "inputs": [{ "name": "staker", "type": "address", "indexed": true, "internalType": "address" }, { "name": "operator", "type": "address", "indexed": true, "internalType": "address" }], "anonymous": false }, { "type": "event", "name": "StrategyWithdrawalDelayBlocksSet", "inputs": [{ "name": "strategy", "type": "address", "indexed": false, "internalType": "contract IStrategy" }, { "name": "previousValue", "type": "uint256", "indexed": false, "internalType": "uint256" }, { "name": "newValue", "type": "uint256", "indexed": false, "internalType": "uint256" }], "anonymous": false }, { "type": "event", "name": "WithdrawalCompleted", "inputs": [{ "name": "withdrawalRoot", "type": "bytes32", "indexed": false, "internalType": "bytes32" }], "anonymous": false }, { "type": "event", "name": "WithdrawalMigrated", "inputs": [{ "name": "oldWithdrawalRoot", "type": "bytes32", "indexed": false, "internalType": "bytes32" }, { "name": "newWithdrawalRoot", "type": "bytes32", "indexed": false, "internalType": "bytes32" }], "anonymous": false }, { "type": "event", "name": "WithdrawalQueued", "inputs": [{ "name": "withdrawalRoot", "type": "bytes32", "indexed": false, "internalType": "bytes32" }, { "name": "withdrawal", "type": "tuple", "indexed": false, "internalType": "struct IDelegationManager.Withdrawal", "components": [{ "name": "staker", "type": "address", "internalType": "address" }, { "name": "delegatedTo", "type": "address", "internalType": "address" }, { "name": "withdrawer", "type": "address", "internalType": "address" }, { "name": "nonce", "type": "uint256", "internalType": "uint256" }, { "name": "startBlock", "type": "uint32", "internalType": "uint32" }, { "name": "strategies", "type": "address[]", "internalType": "contract IStrategy[]" }, { "name": "shares", "type": "uint256[]", "internalType": "uint256[]" }] }], "anonymous": false }]; -const contractABI = [{ "type": "constructor", "inputs": [{ "name": "_avsDirectory", "type": "address", "internalType": "contract IAVSDirectory" }, { "name": "_registryCoordinator", "type": "address", "internalType": "contract IRegistryCoordinator" }, { "name": "_stakeRegistry", "type": "address", "internalType": "contract IStakeRegistry" }], "stateMutability": "nonpayable" }, { "type": "function", "name": "allTaskHashes", "inputs": [{ "name": "", "type": "uint32", "internalType": "uint32" }], "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], "stateMutability": "view" }, { "type": "function", "name": "allTaskResponses", "inputs": [{ "name": "", "type": "address", "internalType": "address" }, { "name": "", "type": "uint32", "internalType": "uint32" }], "outputs": [{ "name": "", "type": "bytes", "internalType": "bytes" }], "stateMutability": "view" }, { "type": "function", "name": "avsDirectory", "inputs": [], "outputs": [{ "name": "", "type": "address", "internalType": "address" }], "stateMutability": "view" }, { "type": "function", "name": "createNewTask", "inputs": [{ "name": "name", "type": "string", "internalType": "string" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "deregisterOperatorFromAVS", "inputs": [{ "name": "operator", "type": "address", "internalType": "address" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "getOperatorRestakedStrategies", "inputs": [{ "name": "operator", "type": "address", "internalType": "address" }], "outputs": [{ "name": "", "type": "address[]", "internalType": "address[]" }], "stateMutability": "view" }, { "type": "function", "name": "getRestakeableStrategies", "inputs": [], "outputs": [{ "name": "", "type": "address[]", "internalType": "address[]" }], "stateMutability": "view" }, { "type": "function", "name": "latestTaskNum", "inputs": [], "outputs": [{ "name": "", "type": "uint32", "internalType": "uint32" }], "stateMutability": "view" }, { "type": "function", "name": "owner", "inputs": [], "outputs": [{ "name": "", "type": "address", "internalType": "address" }], "stateMutability": "view" }, { "type": "function", "name": "pause", "inputs": [{ "name": "newPausedStatus", "type": "uint256", "internalType": "uint256" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "pauseAll", "inputs": [], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "paused", "inputs": [{ "name": "index", "type": "uint8", "internalType": "uint8" }], "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }], "stateMutability": "view" }, { "type": "function", "name": "paused", "inputs": [], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "pauserRegistry", "inputs": [], "outputs": [{ "name": "", "type": "address", "internalType": "contract IPauserRegistry" }], "stateMutability": "view" }, { "type": "function", "name": "payForRange", "inputs": [{ "name": "rangePayments", "type": "tuple[]", "internalType": "struct IPaymentCoordinator.RangePayment[]", "components": [{ "name": "strategiesAndMultipliers", "type": "tuple[]", "internalType": "struct IPaymentCoordinator.StrategyAndMultiplier[]", "components": [{ "name": "strategy", "type": "address", "internalType": "contract IStrategy" }, { "name": "multiplier", "type": "uint96", "internalType": "uint96" }] }, { "name": "token", "type": "address", "internalType": "contract IERC20" }, { "name": "amount", "type": "uint256", "internalType": "uint256" }, { "name": "startTimestamp", "type": "uint32", "internalType": "uint32" }, { "name": "duration", "type": "uint32", "internalType": "uint32" }] }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "registerOperatorToAVS", "inputs": [{ "name": "operator", "type": "address", "internalType": "address" }, { "name": "operatorSignature", "type": "tuple", "internalType": "struct ISignatureUtils.SignatureWithSaltAndExpiry", "components": [{ "name": "signature", "type": "bytes", "internalType": "bytes" }, { "name": "salt", "type": "bytes32", "internalType": "bytes32" }, { "name": "expiry", "type": "uint256", "internalType": "uint256" }] }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "registryCoordinator", "inputs": [], "outputs": [{ "name": "", "type": "address", "internalType": "contract IRegistryCoordinator" }], "stateMutability": "view" }, { "type": "function", "name": "renounceOwnership", "inputs": [], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "respondToTask", "inputs": [{ "name": "task", "type": "tuple", "internalType": "struct IHelloWorldServiceManager.Task", "components": [{ "name": "name", "type": "string", "internalType": "string" }, { "name": "taskCreatedBlock", "type": "uint32", "internalType": "uint32" }] }, { "name": "referenceTaskIndex", "type": "uint32", "internalType": "uint32" }, { "name": "signature", "type": "bytes", "internalType": "bytes" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "setPauserRegistry", "inputs": [{ "name": "newPauserRegistry", "type": "address", "internalType": "contract IPauserRegistry" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "transferOwnership", "inputs": [{ "name": "newOwner", "type": "address", "internalType": "address" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "unpause", "inputs": [{ "name": "newPausedStatus", "type": "uint256", "internalType": "uint256" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "updateAVSMetadataURI", "inputs": [{ "name": "_metadataURI", "type": "string", "internalType": "string" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "event", "name": "Initialized", "inputs": [{ "name": "version", "type": "uint8", "indexed": false, "internalType": "uint8" }], "anonymous": false }, { "type": "event", "name": "NewTaskCreated", "inputs": [{ "name": "taskIndex", "type": "uint32", "indexed": true, "internalType": "uint32" }, { "name": "task", "type": "tuple", "indexed": false, "internalType": "struct IHelloWorldServiceManager.Task", "components": [{ "name": "name", "type": "string", "internalType": "string" }, { "name": "taskCreatedBlock", "type": "uint32", "internalType": "uint32" }] }], "anonymous": false }, { "type": "event", "name": "OwnershipTransferred", "inputs": [{ "name": "previousOwner", "type": "address", "indexed": true, "internalType": "address" }, { "name": "newOwner", "type": "address", "indexed": true, "internalType": "address" }], "anonymous": false }, { "type": "event", "name": "Paused", "inputs": [{ "name": "account", "type": "address", "indexed": true, "internalType": "address" }, { "name": "newPausedStatus", "type": "uint256", "indexed": false, "internalType": "uint256" }], "anonymous": false }, { "type": "event", "name": "PauserRegistrySet", "inputs": [{ "name": "pauserRegistry", "type": "address", "indexed": false, "internalType": "contract IPauserRegistry" }, { "name": "newPauserRegistry", "type": "address", "indexed": false, "internalType": "contract IPauserRegistry" }], "anonymous": false }, { "type": "event", "name": "TaskResponded", "inputs": [{ "name": "taskIndex", "type": "uint32", "indexed": true, "internalType": "uint32" }, { "name": "task", "type": "tuple", "indexed": false, "internalType": "struct IHelloWorldServiceManager.Task", "components": [{ "name": "name", "type": "string", "internalType": "string" }, { "name": "taskCreatedBlock", "type": "uint32", "internalType": "uint32" }] }, { "name": "operator", "type": "address", "indexed": false, "internalType": "address" }], "anonymous": false }, { "type": "event", "name": "Unpaused", "inputs": [{ "name": "account", "type": "address", "indexed": true, "internalType": "address" }, { "name": "newPausedStatus", "type": "uint256", "indexed": false, "internalType": "uint256" }], "anonymous": false }]; -const registryABI = [{ "type": "constructor", "inputs": [{ "name": "_delegationManager", "type": "address", "internalType": "contract IDelegationManager" }], "stateMutability": "nonpayable" }, { "type": "function", "name": "deregisterOperator", "inputs": [], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "getLastCheckpointOperatorWeight", "inputs": [{ "name": "_operator", "type": "address", "internalType": "address" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "getLastCheckpointThresholdWeight", "inputs": [], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "getLastCheckpointThresholdWeightAtBlock", "inputs": [{ "name": "_blockNumber", "type": "uint32", "internalType": "uint32" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "getLastCheckpointTotalWeight", "inputs": [], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "getLastCheckpointTotalWeightAtBlock", "inputs": [{ "name": "_blockNumber", "type": "uint32", "internalType": "uint32" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "getOperatorWeight", "inputs": [{ "name": "_operator", "type": "address", "internalType": "address" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "getOperatorWeightAtBlock", "inputs": [{ "name": "_operator", "type": "address", "internalType": "address" }, { "name": "_blockNumber", "type": "uint32", "internalType": "uint32" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "initialize", "inputs": [{ "name": "_serviceManager", "type": "address", "internalType": "address" }, { "name": "_thresholdWeight", "type": "uint256", "internalType": "uint256" }, { "name": "_quorum", "type": "tuple", "internalType": "struct Quorum", "components": [{ "name": "strategies", "type": "tuple[]", "internalType": "struct StrategyParams[]", "components": [{ "name": "strategy", "type": "address", "internalType": "contract IStrategy" }, { "name": "multiplier", "type": "uint96", "internalType": "uint96" }] }] }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "isValidSignature", "inputs": [{ "name": "_dataHash", "type": "bytes32", "internalType": "bytes32" }, { "name": "_signatureData", "type": "bytes", "internalType": "bytes" }], "outputs": [{ "name": "", "type": "bytes4", "internalType": "bytes4" }], "stateMutability": "view" }, { "type": "function", "name": "minimumWeight", "inputs": [], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "operatorRegistered", "inputs": [{ "name": "_operator", "type": "address", "internalType": "address" }], "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }], "stateMutability": "view" }, { "type": "function", "name": "owner", "inputs": [], "outputs": [{ "name": "", "type": "address", "internalType": "address" }], "stateMutability": "view" }, { "type": "function", "name": "quorum", "inputs": [], "outputs": [{ "name": "", "type": "tuple", "internalType": "struct Quorum", "components": [{ "name": "strategies", "type": "tuple[]", "internalType": "struct StrategyParams[]", "components": [{ "name": "strategy", "type": "address", "internalType": "contract IStrategy" }, { "name": "multiplier", "type": "uint96", "internalType": "uint96" }] }] }], "stateMutability": "view" }, { "type": "function", "name": "registerOperatorWithSignature", "inputs": [{ "name": "_operator", "type": "address", "internalType": "address" }, { "name": "_operatorSignature", "type": "tuple", "internalType": "struct ISignatureUtils.SignatureWithSaltAndExpiry", "components": [{ "name": "signature", "type": "bytes", "internalType": "bytes" }, { "name": "salt", "type": "bytes32", "internalType": "bytes32" }, { "name": "expiry", "type": "uint256", "internalType": "uint256" }] }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "renounceOwnership", "inputs": [], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "transferOwnership", "inputs": [{ "name": "newOwner", "type": "address", "internalType": "address" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "updateMinimumWeight", "inputs": [{ "name": "_newMinimumWeight", "type": "uint256", "internalType": "uint256" }, { "name": "_operators", "type": "address[]", "internalType": "address[]" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "updateOperators", "inputs": [{ "name": "_operators", "type": "address[]", "internalType": "address[]" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "updateOperatorsForQuorum", "inputs": [{ "name": "operatorsPerQuorum", "type": "address[][]", "internalType": "address[][]" }, { "name": "", "type": "bytes", "internalType": "bytes" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "updateQuorumConfig", "inputs": [{ "name": "_quorum", "type": "tuple", "internalType": "struct Quorum", "components": [{ "name": "strategies", "type": "tuple[]", "internalType": "struct StrategyParams[]", "components": [{ "name": "strategy", "type": "address", "internalType": "contract IStrategy" }, { "name": "multiplier", "type": "uint96", "internalType": "uint96" }] }] }, { "name": "_operators", "type": "address[]", "internalType": "address[]" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "updateStakeThreshold", "inputs": [{ "name": "_thresholdWeight", "type": "uint256", "internalType": "uint256" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "event", "name": "Initialized", "inputs": [{ "name": "version", "type": "uint8", "indexed": false, "internalType": "uint8" }], "anonymous": false }, { "type": "event", "name": "MinimumWeightUpdated", "inputs": [{ "name": "_old", "type": "uint256", "indexed": false, "internalType": "uint256" }, { "name": "_new", "type": "uint256", "indexed": false, "internalType": "uint256" }], "anonymous": false }, { "type": "event", "name": "OperatorDeregistered", "inputs": [{ "name": "_operator", "type": "address", "indexed": true, "internalType": "address" }, { "name": "_avs", "type": "address", "indexed": true, "internalType": "address" }], "anonymous": false }, { "type": "event", "name": "OperatorRegistered", "inputs": [{ "name": "_operator", "type": "address", "indexed": true, "internalType": "address" }, { "name": "_avs", "type": "address", "indexed": true, "internalType": "address" }], "anonymous": false }, { "type": "event", "name": "OperatorWeightUpdated", "inputs": [{ "name": "_operator", "type": "address", "indexed": true, "internalType": "address" }, { "name": "oldWeight", "type": "uint256", "indexed": false, "internalType": "uint256" }, { "name": "newWeight", "type": "uint256", "indexed": false, "internalType": "uint256" }], "anonymous": false }, { "type": "event", "name": "OwnershipTransferred", "inputs": [{ "name": "previousOwner", "type": "address", "indexed": true, "internalType": "address" }, { "name": "newOwner", "type": "address", "indexed": true, "internalType": "address" }], "anonymous": false }, { "type": "event", "name": "QuorumUpdated", "inputs": [{ "name": "_old", "type": "tuple", "indexed": false, "internalType": "struct Quorum", "components": [{ "name": "strategies", "type": "tuple[]", "internalType": "struct StrategyParams[]", "components": [{ "name": "strategy", "type": "address", "internalType": "contract IStrategy" }, { "name": "multiplier", "type": "uint96", "internalType": "uint96" }] }] }, { "name": "_new", "type": "tuple", "indexed": false, "internalType": "struct Quorum", "components": [{ "name": "strategies", "type": "tuple[]", "internalType": "struct StrategyParams[]", "components": [{ "name": "strategy", "type": "address", "internalType": "contract IStrategy" }, { "name": "multiplier", "type": "uint96", "internalType": "uint96" }] }] }], "anonymous": false }, { "type": "event", "name": "ThresholdWeightUpdated", "inputs": [{ "name": "_thresholdWeight", "type": "uint256", "indexed": false, "internalType": "uint256" }], "anonymous": false }, { "type": "event", "name": "TotalWeightUpdated", "inputs": [{ "name": "oldTotalWeight", "type": "uint256", "indexed": false, "internalType": "uint256" }, { "name": "newTotalWeight", "type": "uint256", "indexed": false, "internalType": "uint256" }], "anonymous": false }, { "type": "event", "name": "UpdateMinimumWeight", "inputs": [{ "name": "oldMinimumWeight", "type": "uint256", "indexed": false, "internalType": "uint256" }, { "name": "newMinimumWeight", "type": "uint256", "indexed": false, "internalType": "uint256" }], "anonymous": false }, { "type": "error", "name": "InsufficientSignedStake", "inputs": [] }, { "type": "error", "name": "InsufficientWeight", "inputs": [] }, { "type": "error", "name": "InvalidLength", "inputs": [] }, { "type": "error", "name": "InvalidQuorum", "inputs": [] }, { "type": "error", "name": "InvalidSignature", "inputs": [] }, { "type": "error", "name": "InvalidSignedWeight", "inputs": [] }, { "type": "error", "name": "InvalidThreshold", "inputs": [] }, { "type": "error", "name": "LengthMismatch", "inputs": [] }, { "type": "error", "name": "MustUpdateAllOperators", "inputs": [] }, { "type": "error", "name": "NotSorted", "inputs": [] }, { "type": "error", "name": "OperatorAlreadyRegistered", "inputs": [] }, { "type": "error", "name": "OperatorNotRegistered", "inputs": [] }]; -const avsDirectoryABI = [{ "type": "constructor", "inputs": [{ "name": "_delegation", "type": "address", "internalType": "contract IDelegationManager" }], "stateMutability": "nonpayable" }, { "type": "function", "name": "DOMAIN_TYPEHASH", "inputs": [], "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], "stateMutability": "view" }, { "type": "function", "name": "OPERATOR_AVS_REGISTRATION_TYPEHASH", "inputs": [], "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], "stateMutability": "view" }, { "type": "function", "name": "avsOperatorStatus", "inputs": [{ "name": "", "type": "address", "internalType": "address" }, { "name": "", "type": "address", "internalType": "address" }], "outputs": [{ "name": "", "type": "uint8", "internalType": "enum IAVSDirectory.OperatorAVSRegistrationStatus" }], "stateMutability": "view" }, { "type": "function", "name": "calculateOperatorAVSRegistrationDigestHash", "inputs": [{ "name": "operator", "type": "address", "internalType": "address" }, { "name": "avs", "type": "address", "internalType": "address" }, { "name": "salt", "type": "bytes32", "internalType": "bytes32" }, { "name": "expiry", "type": "uint256", "internalType": "uint256" }], "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], "stateMutability": "view" }, { "type": "function", "name": "cancelSalt", "inputs": [{ "name": "salt", "type": "bytes32", "internalType": "bytes32" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "delegation", "inputs": [], "outputs": [{ "name": "", "type": "address", "internalType": "contract IDelegationManager" }], "stateMutability": "view" }, { "type": "function", "name": "deregisterOperatorFromAVS", "inputs": [{ "name": "operator", "type": "address", "internalType": "address" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "domainSeparator", "inputs": [], "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], "stateMutability": "view" }, { "type": "function", "name": "initialize", "inputs": [{ "name": "initialOwner", "type": "address", "internalType": "address" }, { "name": "_pauserRegistry", "type": "address", "internalType": "contract IPauserRegistry" }, { "name": "initialPausedStatus", "type": "uint256", "internalType": "uint256" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "operatorSaltIsSpent", "inputs": [{ "name": "", "type": "address", "internalType": "address" }, { "name": "", "type": "bytes32", "internalType": "bytes32" }], "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }], "stateMutability": "view" }, { "type": "function", "name": "owner", "inputs": [], "outputs": [{ "name": "", "type": "address", "internalType": "address" }], "stateMutability": "view" }, { "type": "function", "name": "pause", "inputs": [{ "name": "newPausedStatus", "type": "uint256", "internalType": "uint256" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "pauseAll", "inputs": [], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "paused", "inputs": [{ "name": "index", "type": "uint8", "internalType": "uint8" }], "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }], "stateMutability": "view" }, { "type": "function", "name": "paused", "inputs": [], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "pauserRegistry", "inputs": [], "outputs": [{ "name": "", "type": "address", "internalType": "contract IPauserRegistry" }], "stateMutability": "view" }, { "type": "function", "name": "registerOperatorToAVS", "inputs": [{ "name": "operator", "type": "address", "internalType": "address" }, { "name": "operatorSignature", "type": "tuple", "internalType": "struct ISignatureUtils.SignatureWithSaltAndExpiry", "components": [{ "name": "signature", "type": "bytes", "internalType": "bytes" }, { "name": "salt", "type": "bytes32", "internalType": "bytes32" }, { "name": "expiry", "type": "uint256", "internalType": "uint256" }] }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "renounceOwnership", "inputs": [], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "setPauserRegistry", "inputs": [{ "name": "newPauserRegistry", "type": "address", "internalType": "contract IPauserRegistry" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "transferOwnership", "inputs": [{ "name": "newOwner", "type": "address", "internalType": "address" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "unpause", "inputs": [{ "name": "newPausedStatus", "type": "uint256", "internalType": "uint256" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "updateAVSMetadataURI", "inputs": [{ "name": "metadataURI", "type": "string", "internalType": "string" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "event", "name": "AVSMetadataURIUpdated", "inputs": [{ "name": "avs", "type": "address", "indexed": true, "internalType": "address" }, { "name": "metadataURI", "type": "string", "indexed": false, "internalType": "string" }], "anonymous": false }, { "type": "event", "name": "Initialized", "inputs": [{ "name": "version", "type": "uint8", "indexed": false, "internalType": "uint8" }], "anonymous": false }, { "type": "event", "name": "OperatorAVSRegistrationStatusUpdated", "inputs": [{ "name": "operator", "type": "address", "indexed": true, "internalType": "address" }, { "name": "avs", "type": "address", "indexed": true, "internalType": "address" }, { "name": "status", "type": "uint8", "indexed": false, "internalType": "enum IAVSDirectory.OperatorAVSRegistrationStatus" }], "anonymous": false }, { "type": "event", "name": "OwnershipTransferred", "inputs": [{ "name": "previousOwner", "type": "address", "indexed": true, "internalType": "address" }, { "name": "newOwner", "type": "address", "indexed": true, "internalType": "address" }], "anonymous": false }, { "type": "event", "name": "Paused", "inputs": [{ "name": "account", "type": "address", "indexed": true, "internalType": "address" }, { "name": "newPausedStatus", "type": "uint256", "indexed": false, "internalType": "uint256" }], "anonymous": false }, { "type": "event", "name": "PauserRegistrySet", "inputs": [{ "name": "pauserRegistry", "type": "address", "indexed": false, "internalType": "contract IPauserRegistry" }, { "name": "newPauserRegistry", "type": "address", "indexed": false, "internalType": "contract IPauserRegistry" }], "anonymous": false }, { "type": "event", "name": "Unpaused", "inputs": [{ "name": "account", "type": "address", "indexed": true, "internalType": "address" }, { "name": "newPausedStatus", "type": "uint256", "indexed": false, "internalType": "uint256" }], "anonymous": false }]; -const delegationManager = new ethers_1.ethers.Contract(delegationManagerAddress, delegationABI, wallet); -const contract = new ethers_1.ethers.Contract(contractAddress, contractABI, wallet); -const registryContract = new ethers_1.ethers.Contract(stakeRegistryAddress, registryABI, wallet); -const avsDirectory = new ethers_1.ethers.Contract(avsDirectoryAddress, avsDirectoryABI, wallet); -const signAndRespondToTask = (taskIndex, taskCreatedBlock, taskName) => __awaiter(void 0, void 0, void 0, function* () { - const message = `Hello, ${taskName}`; - const messageHash = ethers_1.ethers.utils.solidityKeccak256(["string"], [message]); - const messageBytes = ethers_1.ethers.utils.arrayify(messageHash); - const signature = yield wallet.signMessage(messageBytes); - console.log(`Signing and responding to task ${taskIndex}`); - const tx = yield contract.respondToTask({ name: taskName, taskCreatedBlock: taskCreatedBlock }, taskIndex, signature); - yield tx.wait(); - console.log(`Responded to task.`); -}); -const registerOperator = () => __awaiter(void 0, void 0, void 0, function* () { - const tx1 = yield delegationManager.registerAsOperator({ - earningsReceiver: yield wallet.address, - delegationApprover: "0x0000000000000000000000000000000000000000", - stakerOptOutWindowBlocks: 0 - }, ""); - yield tx1.wait(); - console.log("Operator registered on EL successfully"); - const salt = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.randomBytes(32)); - const expiry = Math.floor(Date.now() / 1000) + 3600; // Example expiry, 1 hour from now - // Define the output structure - let operatorSignature = { - expiry: expiry, - salt: salt, - signature: "" - }; - // Calculate the digest hash using the avsDirectory's method - const digestHash = yield avsDirectory.calculateOperatorAVSRegistrationDigestHash(wallet.address, contract.address, salt, expiry); - // Sign the digest hash with the operator's private key - const signingKey = new ethers_1.ethers.utils.SigningKey(process.env.PRIVATE_KEY); - const signature = signingKey.signDigest(digestHash); - // Encode the signature in the required format - operatorSignature.signature = ethers_1.ethers.utils.joinSignature(signature); - const tx2 = yield registryContract.registerOperatorWithSignature(wallet.address, operatorSignature); - yield tx2.wait(); - console.log("Operator registered on AVS successfully"); -}); -const monitorNewTasks = () => __awaiter(void 0, void 0, void 0, function* () { - yield contract.createNewTask("EigenWorld"); - contract.on("NewTaskCreated", (taskIndex, task) => __awaiter(void 0, void 0, void 0, function* () { - console.log(`New task detected: Hello, ${task.name}`); - yield signAndRespondToTask(taskIndex, task.taskCreatedBlock, task.name); - })); - console.log("Monitoring for new tasks..."); -}); -const main = () => __awaiter(void 0, void 0, void 0, function* () { - yield registerOperator(); - monitorNewTasks().catch((error) => { - console.error("Error monitoring tasks:", error); - }); -}); -main().catch((error) => { - console.error("Error in main function:", error); -}); diff --git a/package-lock.json b/package-lock.json index d35ff85c..e908b572 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,12 +8,13 @@ "name": "hello-world-avs", "version": "1.0.0", "dependencies": { + "@types/node": "^20.12.12", "bls-signatures": "^2.0.3", "dotenv": "^10.0.0", "ethers": "^5.7.2" }, "devDependencies": { - "typescript": "^4.4.3" + "typescript": "^5.4.5" } }, "node_modules/@ethersproject/abi": { @@ -687,6 +688,14 @@ "@ethersproject/strings": "^5.7.0" } }, + "node_modules/@types/node": { + "version": "20.12.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.12.tgz", + "integrity": "sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw==", + "dependencies": { + "undici-types": "~5.26.4" + } + }, "node_modules/aes-js": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.0.0.tgz", @@ -850,18 +859,23 @@ "integrity": "sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA==" }, "node_modules/typescript": { - "version": "4.9.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", - "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "version": "5.4.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", + "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", "dev": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=4.2.0" + "node": ">=14.17" } }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" + }, "node_modules/ws": { "version": "7.4.6", "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz", diff --git a/package.json b/package.json index d67d4b26..c4266ebe 100644 --- a/package.json +++ b/package.json @@ -6,11 +6,12 @@ "start": "node dist/index.js" }, "dependencies": { + "@types/node": "^20.12.12", "bls-signatures": "^2.0.3", "dotenv": "^10.0.0", "ethers": "^5.7.2" }, "devDependencies": { - "typescript": "^4.4.3" + "typescript": "^5.4.5" } } diff --git a/yarn.lock b/yarn.lock index 95104683..f03f4bc3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -344,6 +344,13 @@ "@ethersproject/properties" "^5.7.0" "@ethersproject/strings" "^5.7.0" +"@types/node@^20.12.12": + version "20.12.12" + resolved "https://registry.npmjs.org/@types/node/-/node-20.12.12.tgz" + integrity sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw== + dependencies: + undici-types "~5.26.4" + aes-js@3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/aes-js/-/aes-js-3.0.0.tgz" @@ -483,10 +490,15 @@ scrypt-js@3.0.1: resolved "https://registry.npmjs.org/scrypt-js/-/scrypt-js-3.0.1.tgz" integrity sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA== -typescript@^4.4.3: - version "4.9.5" - resolved "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz" - integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g== +typescript@^5.4.5: + version "5.4.5" + resolved "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz" + integrity sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ== + +undici-types@~5.26.4: + version "5.26.5" + resolved "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz" + integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== ws@7.4.6: version "7.4.6"