diff --git a/.gitignore b/.gitignore index d4d737a3..f72715cd 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,8 @@ broadcast/ .gas-snapshot .cursorrules + +deployments/local_addresses.json +deployments/local_verification.json + +testScript.sh \ No newline at end of file diff --git a/contracts/base/AppGatewayBase.sol b/contracts/base/AppGatewayBase.sol index 156f98bd..46639cad 100644 --- a/contracts/base/AppGatewayBase.sol +++ b/contracts/base/AppGatewayBase.sol @@ -10,18 +10,13 @@ import "../interfaces/IPromise.sol"; import {FeesPlugin} from "../protocol/utils/FeesPlugin.sol"; import {InvalidPromise, FeesNotSet} from "../protocol/utils/common/Errors.sol"; import {FAST} from "../protocol/utils/common/Constants.sol"; - /// @title AppGatewayBase /// @notice Abstract contract for the app gateway abstract contract AppGatewayBase is AddressResolverUtil, IAppGateway, FeesPlugin { - Read public override isReadCall; - Parallel public override isParallelCall; - uint256 public override gasLimit; - + OverrideParams public overrideParams; address public auctionManager; bytes public onCompleteData; bytes32 public sbType; - bool public isAsyncModifierSet; mapping(address => bool) public isValidPromise; @@ -34,6 +29,7 @@ abstract contract AppGatewayBase is AddressResolverUtil, IAppGateway, FeesPlugin isAsyncModifierSet = true; deliveryHelper().clearQueue(); addressResolver__.clearPromises(); + _clearOverrides(); _; isAsyncModifierSet = false; deliveryHelper().batch(fees, auctionManager, onCompleteData, sbType); @@ -120,17 +116,22 @@ abstract contract AppGatewayBase is AddressResolverUtil, IAppGateway, FeesPlugin IPromise(asyncPromise).then(this.setAddress.selector, abi.encode(chainSlug_, contractId_)); onCompleteData = abi.encode(chainSlug_, true); - IDeliveryHelper(deliveryHelper()).queue( - isPlug_, - isParallelCall, - chainSlug_, - address(0), - asyncPromise, - 0, - CallType.DEPLOY, - creationCodeWithArgs[contractId_], - initCallData_ - ); + + CallParams memory callParams = CallParams({ + isPlug: isPlug_, + isParallel: overrideParams.isParallelCall, + chainSlug: chainSlug_, + target: address(0), + asyncPromise: asyncPromise, + value: 0, + gasLimit: overrideParams.gasLimit, + callType: CallType.DEPLOY, + writeFinality: overrideParams.writeFinality, + readAt: overrideParams.readAt, + payload: creationCodeWithArgs[contractId_], + initCallData: initCallData_ + }); + IDeliveryHelper(deliveryHelper()).queue(callParams); } /// @notice Sets the address for a deployed contract @@ -179,46 +180,76 @@ abstract contract AppGatewayBase is AddressResolverUtil, IAppGateway, FeesPlugin uint256 gasLimit_, Fees memory fees_ ) internal { - isReadCall = isReadCall_; - isParallelCall = isParallelCall_; - gasLimit = gasLimit_; + overrideParams.isReadCall = isReadCall_; + overrideParams.isParallelCall = isParallelCall_; + overrideParams.gasLimit = gasLimit_; fees = fees_; } + function _clearOverrides() internal { + overrideParams.isReadCall = Read.OFF; + overrideParams.isParallelCall = Parallel.OFF; + overrideParams.gasLimit = 0; + overrideParams.readAt = 0; + overrideParams.writeFinality = WriteFinality.LOW; + } + /// @notice Sets isReadCall, fees and gasLimit overrides /// @param isReadCall_ The read call flag /// @param isParallelCall_ The sequential call flag /// @param gasLimit_ The gas limit function _setOverrides(Read isReadCall_, Parallel isParallelCall_, uint256 gasLimit_) internal { - isReadCall = isReadCall_; - isParallelCall = isParallelCall_; - gasLimit = gasLimit_; + overrideParams.isReadCall = isReadCall_; + overrideParams.isParallelCall = isParallelCall_; + overrideParams.gasLimit = gasLimit_; } /// @notice Sets isReadCall and isParallelCall overrides /// @param isReadCall_ The read call flag /// @param isParallelCall_ The sequential call flag function _setOverrides(Read isReadCall_, Parallel isParallelCall_) internal { - isReadCall = isReadCall_; - isParallelCall = isParallelCall_; + overrideParams.isReadCall = isReadCall_; + overrideParams.isParallelCall = isParallelCall_; + } + + /// @notice Sets isParallelCall overrides + /// @param writeFinality_ The write finality + function _setOverrides(WriteFinality writeFinality_) internal { + overrideParams.writeFinality = writeFinality_; } /// @notice Sets isParallelCall overrides /// @param isParallelCall_ The sequential call flag function _setOverrides(Parallel isParallelCall_) internal { - isParallelCall = isParallelCall_; + overrideParams.isParallelCall = isParallelCall_; + } + + /// @notice Sets isParallelCall overrides + /// @param isParallelCall_ The sequential call flag + /// @param readAt_ The read anchor value. Currently block number. + function _setOverrides(Parallel isParallelCall_, uint256 readAt_) internal { + overrideParams.isParallelCall = isParallelCall_; + overrideParams.readAt = readAt_; } /// @notice Sets isReadCall overrides /// @param isReadCall_ The read call flag function _setOverrides(Read isReadCall_) internal { - isReadCall = isReadCall_; + overrideParams.isReadCall = isReadCall_; + } + + /// @notice Sets isReadCall overrides + /// @param isReadCall_ The read call flag + /// @param readAt_ The read anchor value. Currently block number. + function _setOverrides(Read isReadCall_, uint256 readAt_) internal { + overrideParams.isReadCall = isReadCall_; + overrideParams.readAt = readAt_; } /// @notice Sets gasLimit overrides /// @param gasLimit_ The gas limit function _setOverrides(uint256 gasLimit_) internal { - gasLimit = gasLimit_; + overrideParams.gasLimit = gasLimit_; } /// @notice Sets fees overrides @@ -227,6 +258,20 @@ abstract contract AppGatewayBase is AddressResolverUtil, IAppGateway, FeesPlugin fees = fees_; } + function getOverrideParams() + public + view + returns (Read, Parallel, WriteFinality, uint256, uint256) + { + return ( + overrideParams.isReadCall, + overrideParams.isParallelCall, + overrideParams.writeFinality, + overrideParams.readAt, + overrideParams.gasLimit + ); + } + //////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////// ASYNC BATCH HELPERS ///////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/contracts/interfaces/IAppGateway.sol b/contracts/interfaces/IAppGateway.sol index 38e68fee..1b32ea80 100644 --- a/contracts/interfaces/IAppGateway.sol +++ b/contracts/interfaces/IAppGateway.sol @@ -1,16 +1,14 @@ // SPDX-License-Identifier: Unlicense pragma solidity ^0.8.21; -import {Fees, Read, Parallel, DeployParams, CallType, PayloadBatch} from "../protocol/utils/common/Structs.sol"; +import {Fees, Read, Parallel, CallParams, DeployParams, OverrideParams, CallType, WriteFinality, PayloadBatch} from "../protocol/utils/common/Structs.sol"; interface IAppGateway { - function isReadCall() external view returns (Read); - - function isParallelCall() external view returns (Parallel); - - function gasLimit() external view returns (uint256); - function isAsyncModifierSet() external view returns (bool); + function getOverrideParams() + external + view + returns (Read, Parallel, WriteFinality, uint256, uint256); function onBatchComplete(bytes32 asyncId_, PayloadBatch memory payloadBatch_) external; diff --git a/contracts/interfaces/IDeliveryHelper.sol b/contracts/interfaces/IDeliveryHelper.sol index 2f9d15ae..e8d94c83 100644 --- a/contracts/interfaces/IDeliveryHelper.sol +++ b/contracts/interfaces/IDeliveryHelper.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.3; -import {PayloadDetails, Bid, Fees, DeployParams, CallType, PayloadBatch, Parallel, IsPlug} from "../protocol/utils/common/Structs.sol"; +import {PayloadDetails, CallParams, Bid, Fees, WriteFinality, DeployParams, CallType, PayloadBatch, Parallel, IsPlug} from "../protocol/utils/common/Structs.sol"; interface IDeliveryHelper { event BidPlaced( @@ -19,17 +19,7 @@ interface IDeliveryHelper { function clearQueue() external; - function queue( - IsPlug isPlug_, - Parallel isParallel_, - uint32 chainSlug_, - address target_, - address asyncPromise_, - uint256 value_, - CallType callType_, - bytes memory payload_, - bytes memory initCallData_ - ) external; + function queue(CallParams memory callParams_) external; function batch( Fees memory fees_, diff --git a/contracts/interfaces/IWatcherPrecompile.sol b/contracts/interfaces/IWatcherPrecompile.sol index 0a54fa6a..23aef31b 100644 --- a/contracts/interfaces/IWatcherPrecompile.sol +++ b/contracts/interfaces/IWatcherPrecompile.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Unlicense pragma solidity ^0.8.21; -import {PayloadDetails, AsyncRequest, FinalizeParams, PayloadDigestParams, AppGatewayConfig, PlugConfig, ResolvedPromises} from "../protocol/utils/common/Structs.sol"; +import {PayloadDetails, AsyncRequest, FinalizeParams, WriteFinality, PayloadDigestParams, AppGatewayConfig, PlugConfig, ResolvedPromises} from "../protocol/utils/common/Structs.sol"; /// @title IWatcherPrecompile /// @notice Interface for the Watcher Precompile system that handles payload verification and execution @@ -59,7 +59,8 @@ interface IWatcherPrecompile { address targetAddress_, address appGateway_, address[] memory asyncPromises_, - bytes memory payload_ + bytes memory payload_, + uint256 readAt_ ) external returns (bytes32 payloadId); /// @notice Marks a request as finalized with a proof diff --git a/contracts/protocol/Forwarder.sol b/contracts/protocol/Forwarder.sol index 13785b7b..aeb01109 100644 --- a/contracts/protocol/Forwarder.sol +++ b/contracts/protocol/Forwarder.sol @@ -96,20 +96,30 @@ contract Forwarder is ForwarderStorage, Initializable { ); // Determine if the call is a read or write operation. - Read isReadCall = IAppGateway(msg.sender).isReadCall(); - Parallel isParallelCall = IAppGateway(msg.sender).isParallelCall(); + ( + Read isReadCall, + Parallel isParallelCall, + WriteFinality writeFinality, + uint256 readAt, + uint256 gasLimit + ) = IAppGateway(msg.sender).getOverrideParams(); // Queue the call in the auction house. IDeliveryHelper(deliveryHelper).queue( - IsPlug.NO, - isParallelCall, - chainSlug, - onChainAddress, - latestAsyncPromise, - 0, - isReadCall == Read.ON ? CallType.READ : CallType.WRITE, - msg.data, - bytes("") + CallParams({ + isPlug: IsPlug.NO, + isParallel: isParallelCall, + chainSlug: chainSlug, + target: onChainAddress, + asyncPromise: latestAsyncPromise, + value: 0, + gasLimit: gasLimit, + callType: isReadCall == Read.ON ? CallType.READ : CallType.WRITE, + writeFinality: writeFinality, + readAt: readAt, + payload: msg.data, + initCallData: bytes("") + }) ); } diff --git a/contracts/protocol/payload-delivery/FeesManager.sol b/contracts/protocol/payload-delivery/FeesManager.sol index 58a9323f..6fc5f826 100644 --- a/contracts/protocol/payload-delivery/FeesManager.sol +++ b/contracts/protocol/payload-delivery/FeesManager.sol @@ -11,7 +11,7 @@ import {IFeesManager} from "../../interfaces/IFeesManager.sol"; import {AddressResolverUtil} from "../utils/AddressResolverUtil.sol"; import {WITHDRAW} from "../utils/common/Constants.sol"; import {NotAuctionManager} from "../utils/common/Errors.sol"; -import {Bid, Fees, PayloadDetails, CallType, FinalizeParams, Parallel} from "../utils/common/Structs.sol"; +import {Bid, Fees, PayloadDetails, CallType, FinalizeParams, Parallel, WriteFinality} from "../utils/common/Structs.sol"; abstract contract FeesManagerStorage is IFeesManager { // slots [0-49] reserved for gap @@ -331,6 +331,8 @@ contract FeesManager is FeesManagerStorage, Initializable, Ownable, AddressResol target: _getFeesPlugAddress(chainSlug_), payload: payload_, callType: callType_, + writeFinality: WriteFinality.LOW, + readAt: 0, value: 0, executionGasLimit: 1000000, next: new address[](2), diff --git a/contracts/protocol/payload-delivery/app-gateway/BatchAsync.sol b/contracts/protocol/payload-delivery/app-gateway/BatchAsync.sol index 825a3149..9d6ebd3c 100644 --- a/contracts/protocol/payload-delivery/app-gateway/BatchAsync.sol +++ b/contracts/protocol/payload-delivery/app-gateway/BatchAsync.sol @@ -160,7 +160,8 @@ abstract contract BatchAsync is QueueAsync { payloadDetails_[i].target, payloadDetails_[i].appGateway, payloadDetails_[i].next, - payloadDetails_[i].payload + payloadDetails_[i].payload, + payloadDetails_[i].readAt ); payloadIdToBatchHash[payloadId] = asyncId; payloadBatchDetails[asyncId].push(payloadDetails_[i]); diff --git a/contracts/protocol/payload-delivery/app-gateway/DeliveryHelper.sol b/contracts/protocol/payload-delivery/app-gateway/DeliveryHelper.sol index c3e5de15..68d42546 100644 --- a/contracts/protocol/payload-delivery/app-gateway/DeliveryHelper.sol +++ b/contracts/protocol/payload-delivery/app-gateway/DeliveryHelper.sol @@ -142,7 +142,8 @@ contract DeliveryHelper is BatchAsync { payloadDetails_.target, payloadDetails_.appGateway, payloadDetails_.next, - payloadDetails_.payload + payloadDetails_.payload, + payloadDetails_.readAt ); digest = bytes32(0); } else { diff --git a/contracts/protocol/payload-delivery/app-gateway/DeliveryHelperStorage.sol b/contracts/protocol/payload-delivery/app-gateway/DeliveryHelperStorage.sol index 1801385a..9aa0da39 100644 --- a/contracts/protocol/payload-delivery/app-gateway/DeliveryHelperStorage.sol +++ b/contracts/protocol/payload-delivery/app-gateway/DeliveryHelperStorage.sol @@ -11,7 +11,7 @@ import {IAddressResolver} from "../../../interfaces/IAddressResolver.sol"; import {IAuctionManager} from "../../../interfaces/IAuctionManager.sol"; import {IFeesManager} from "../../../interfaces/IFeesManager.sol"; -import {CallParams, Fees, PayloadDetails, CallType, Bid, PayloadBatch, Parallel, IsPlug, FinalizeParams} from "../../utils/common/Structs.sol"; +import {CallParams, Fees, PayloadDetails, CallType, Bid, PayloadBatch, Parallel, IsPlug, FinalizeParams, WriteFinality} from "../../utils/common/Structs.sol"; import {NotAuctionManager, InvalidPromise, InvalidIndex, PromisesNotResolved, InvalidTransmitter} from "../../utils/common/Errors.sol"; import {FORWARD_CALL, DISTRIBUTE_FEE, DEPLOY, WITHDRAW, QUERY, FINALIZE} from "../../utils/common/Constants.sol"; diff --git a/contracts/protocol/payload-delivery/app-gateway/QueueAsync.sol b/contracts/protocol/payload-delivery/app-gateway/QueueAsync.sol index c08b0f93..91830f36 100644 --- a/contracts/protocol/payload-delivery/app-gateway/QueueAsync.sol +++ b/contracts/protocol/payload-delivery/app-gateway/QueueAsync.sol @@ -7,7 +7,6 @@ import "solady/utils/Initializable.sol"; import {AddressResolverUtil} from "../../utils/AddressResolverUtil.sol"; import "./DeliveryHelperStorage.sol"; - /// @notice Abstract contract for managing asynchronous payloads abstract contract QueueAsync is DeliveryHelperStorage, Initializable, Ownable, AddressResolverUtil { // slots [0-108] reserved for delivery helper storage and [109-159] reserved for addr resolver util @@ -41,37 +40,10 @@ abstract contract QueueAsync is DeliveryHelperStorage, Initializable, Ownable, A } /// @notice Queues a new payload - /// @param chainSlug_ The chain identifier - /// @param target_ The target address - /// @param asyncPromise_ The async promise or ID - /// @param callType_ The call type - /// @param payload_ The payload - function queue( - IsPlug isPlug_, - Parallel isParallel_, - uint32 chainSlug_, - address target_, - address asyncPromise_, - uint256 value_, - CallType callType_, - bytes memory payload_, - bytes memory initCallData_ - ) external { - // todo: sb related details - callParamsArray.push( - CallParams({ - isPlug: isPlug_, - callType: callType_, - asyncPromise: asyncPromise_, - chainSlug: chainSlug_, - target: target_, - payload: payload_, - value: value_, - gasLimit: 10000000, - isParallel: isParallel_, - initCallData: initCallData_ - }) - ); + /// @param callParams_ The call parameters + function queue(CallParams memory callParams_) external { + callParams_.gasLimit = callParams_.gasLimit == 0 ? 10_000_000 : callParams_.gasLimit; + callParamsArray.push(callParams_); } /// @notice Creates an array of payload details @@ -138,6 +110,8 @@ abstract contract QueueAsync is DeliveryHelperStorage, Initializable, Ownable, A value: params_.value, payload: payload_, callType: params_.callType, + writeFinality: params_.writeFinality, + readAt: params_.readAt, executionGasLimit: params_.gasLimit == 0 ? 1_000_000 : params_.gasLimit, next: next, isParallel: params_.isParallel diff --git a/contracts/protocol/utils/common/Structs.sol b/contracts/protocol/utils/common/Structs.sol index 3774291b..011de914 100644 --- a/contracts/protocol/utils/common/Structs.sol +++ b/contracts/protocol/utils/common/Structs.sol @@ -25,6 +25,12 @@ enum Read { ON } +enum WriteFinality { + LOW, + MEDIUM, + HIGH +} + //// STRUCTS //// struct AppGatewayConfig { @@ -46,8 +52,12 @@ struct AsyncRequest { bytes32 digest; bytes payload; address[] next; + WriteFinality writeFinality; + uint256 readAt; } + + struct AttestAndExecutePayloadParams { bytes32 payloadId; bytes32 digest; @@ -78,6 +88,8 @@ struct CallParams { uint256 value; bytes payload; bytes initCallData; + WriteFinality writeFinality; + uint256 readAt; } struct CallFromChainParams { @@ -113,6 +125,14 @@ struct LimitParams { uint256 lastUpdateLimit; } +struct OverrideParams { + Read isReadCall; + Parallel isParallelCall; + uint256 gasLimit; + WriteFinality writeFinality; + uint256 readAt; +} + struct PayloadBatch { address appGateway; address auctionManager; @@ -136,6 +156,8 @@ struct PayloadDetails { uint256 executionGasLimit; bytes payload; address[] next; + WriteFinality writeFinality; + uint256 readAt; } struct PayloadDigestParams { diff --git a/contracts/protocol/watcherPrecompile/WatcherPrecompile.sol b/contracts/protocol/watcherPrecompile/WatcherPrecompile.sol index d9c55f32..44f13966 100644 --- a/contracts/protocol/watcherPrecompile/WatcherPrecompile.sol +++ b/contracts/protocol/watcherPrecompile/WatcherPrecompile.sol @@ -33,7 +33,13 @@ contract WatcherPrecompile is WatcherPrecompileConfig { /// @param targetAddress The address of the target contract /// @param payloadId The unique identifier for the query /// @param payload The query data - event QueryRequested(uint32 chainSlug, address targetAddress, bytes32 payloadId, bytes payload); + event QueryRequested( + uint32 chainSlug, + address targetAddress, + bytes32 payloadId, + bytes payload, + uint256 readAt + ); /// @notice Emitted when a finalize request is made /// @param payloadId The unique identifier for the request @@ -230,7 +236,9 @@ contract WatcherPrecompile is WatcherPrecompileConfig { params_.asyncId, digest, params_.payloadDetails.payload, - params_.payloadDetails.next + params_.payloadDetails.next, + params_.payloadDetails.writeFinality, + params_.payloadDetails.readAt ); asyncRequests[payloadId_] = asyncRequest; emit FinalizeRequested(payloadId_, asyncRequest); @@ -248,7 +256,8 @@ contract WatcherPrecompile is WatcherPrecompileConfig { address targetAddress_, address appGateway_, address[] memory asyncPromises_, - bytes memory payload_ + bytes memory payload_, + uint256 readAt_ ) public returns (bytes32 payloadId) { // from payload delivery _consumeLimit(appGateway_, QUERY, 1); @@ -268,10 +277,12 @@ contract WatcherPrecompile is WatcherPrecompileConfig { bytes32(0), bytes32(0), payload_, - asyncPromises_ + asyncPromises_, + WriteFinality.LOW, + readAt_ ); asyncRequests[payloadId] = asyncRequest_; - emit QueryRequested(chainSlug_, targetAddress_, payloadId, payload_); + emit QueryRequested(chainSlug_, targetAddress_, payloadId, payload_, readAt_); } /// @notice Marks a request as finalized with a proof on digest diff --git a/contracts/protocol/watcherPrecompile/WatcherPrecompileStorage.sol b/contracts/protocol/watcherPrecompile/WatcherPrecompileStorage.sol index e5142824..d58dadb9 100644 --- a/contracts/protocol/watcherPrecompile/WatcherPrecompileStorage.sol +++ b/contracts/protocol/watcherPrecompile/WatcherPrecompileStorage.sol @@ -8,7 +8,7 @@ import {IPromise} from "../../interfaces/IPromise.sol"; import {QUERY, FINALIZE, SCHEDULE} from "../utils/common/Constants.sol"; import {TimeoutDelayTooLarge, TimeoutAlreadyResolved, InvalidInboxCaller, ResolvingTimeoutTooEarly, CallFailed, AppGatewayAlreadyCalled, InvalidWatcherSignature, NonceUsed} from "../utils/common/Errors.sol"; -import {ResolvedPromises, AppGatewayConfig, LimitParams, UpdateLimitParams, PlugConfig, PayloadDigestParams, AsyncRequest, FinalizeParams, TimeoutRequest, CallFromChainParams} from "../utils/common/Structs.sol"; +import {ResolvedPromises, AppGatewayConfig, LimitParams, WriteFinality, UpdateLimitParams, PlugConfig, PayloadDigestParams, AsyncRequest, FinalizeParams, TimeoutRequest, CallFromChainParams} from "../utils/common/Structs.sol"; abstract contract WatcherPrecompileStorage is IWatcherPrecompile { // slot 0-49: gap for future storage variables diff --git a/deployments/stage_addresses.json b/deployments/stage_addresses.json index 103ae35c..09b48a65 100644 --- a/deployments/stage_addresses.json +++ b/deployments/stage_addresses.json @@ -1,11 +1,11 @@ { "43": { "AddressResolver": "0xf3046B22F98C25305E8040286fB1b33378BA10a1", - "AddressResolverImpl": "0x208dC31cd6042a09bbFDdB31614A337a51b870ba", + "AddressResolverImpl": "0x12103e799d8887034d4560A960C2410ceE751004", "AuctionManager": "0x5d6d4DCb0F719F01441377F633F3EdD186e19360", "AuctionManagerImpl": "0xF4D3BDe438416938217d4624c82AEbEb46CeD371", "DeliveryHelper": "0x39bC71cC9AfeeA50B0638532e45b0462A5e62111", - "DeliveryHelperImpl": "0x8F18fC10a8b40b548C6F04Fb252481c783A9ace0", + "DeliveryHelperImpl": "0x6dc109Ac040bC88F97B317bBb1a23236c5da1Cf6", "ERC1967Factory": "0x47116C0E101C4c1b5f21f0A57A86c0aa3F14D994", "FeesManager": "0x603723100172D30171B7Fd9870ba80F8baf6FaD4", "FeesManagerImpl": "0x8662FC08dEC7c61Dd3432fAF45a5bC024BB60B00", diff --git a/deployments/stage_verification.json b/deployments/stage_verification.json index 030eaa6b..9287cf4a 100644 --- a/deployments/stage_verification.json +++ b/deployments/stage_verification.json @@ -1,5 +1,17 @@ { "43": [ + [ + "0x6dc109Ac040bC88F97B317bBb1a23236c5da1Cf6", + "DeliveryHelper", + "contracts/protocol/payload-delivery/app-gateway/DeliveryHelper.sol", + [] + ], + [ + "0x12103e799d8887034d4560A960C2410ceE751004", + "AddressResolver", + "contracts/protocol/AddressResolver.sol", + [] + ], [ "0xF4D3BDe438416938217d4624c82AEbEb46CeD371", "AuctionManager", @@ -115,11 +127,7 @@ "0x6D54668ba18B425a1DbFC0BD720145c0aeE97f65", "Socket", "contracts/protocol/socket/Socket.sol", - [ - 84532, - "0x3339Cf48f1F9cf31b6F8c2664d144c7444eBBB18", - "EVMX" - ] + [84532, "0x3339Cf48f1F9cf31b6F8c2664d144c7444eBBB18", "EVMX"] ] ], "421614": [], diff --git a/hardhat-scripts/addChain/index.ts b/hardhat-scripts/addChain/index.ts new file mode 100644 index 00000000..0e771571 --- /dev/null +++ b/hardhat-scripts/addChain/index.ts @@ -0,0 +1,41 @@ +import prompts from "prompts"; + +import { addChainToSDK } from "./writeConfigs"; + +async function main() { + const response = await prompts([ + { + name: "option", + type: "select", + message: "What would you like to do?", + choices: [ + { + title: "Add chain configs", + value: "add", + }, + { + title: "Exit", + value: "exit", + }, + ], + }, + ]); + + switch (response.option) { + case "add": + await addChainToSDK(); + break; + case "exit": + process.exit(0); + } +} + +async function start() { + while (true) { + await main(); + } +} + +(async () => { + start(); +})(); diff --git a/hardhat-scripts/addChain/utils.ts b/hardhat-scripts/addChain/utils.ts new file mode 100644 index 00000000..0a7d2c3d --- /dev/null +++ b/hardhat-scripts/addChain/utils.ts @@ -0,0 +1,151 @@ +import fs from "fs"; +import path from "path"; + +import { ChainId, ChainType, NativeTokens } from "../../src"; + +const enumFolderPath = path.join( + __dirname, + `/../../src/constants/chain-enums/` +); + +export const updateSDK = async ( + chainName: string, + chainId: number, + nativeToken: string, + chainType: number, + isMainnet: boolean, + isNewNative: boolean +) => { + if (!fs.existsSync(enumFolderPath)) { + throw new Error(`Folder not found! ${enumFolderPath}`); + } + + const filteredChain = Object.values(ChainId).filter((c) => c == chainId); + if (filteredChain.length > 0) { + console.log("Chain already added!"); + return; + } + + await updateFile( + "hardhatChainName.ts", + `,\n ${chainName.toUpperCase()} = "${chainName.toLowerCase()}",\n}\n`, + ",\n}" + ); + await updateFile( + "chainId.ts", + `,\n ${chainName.toUpperCase()} = ${chainId},\n}\n`, + ",\n}" + ); + await updateFile( + "chainSlug.ts", + `,\n ${chainName.toUpperCase()} = ChainId.${chainName.toUpperCase()},\n}\n`, + ",\n}" + ); + await updateFile( + "chainSlugToKey.ts", + `,\n [ChainSlug.${chainName.toUpperCase()}]: HardhatChainName.${chainName.toUpperCase()},\n};\n`, + ",\n};" + ); + await updateFile( + "chainSlugToId.ts", + `,\n [ChainSlug.${chainName.toUpperCase()}]: ChainId.${chainName.toUpperCase()},\n};\n`, + ",\n};" + ); + await updateFile( + "hardhatChainNameToSlug.ts", + `,\n [HardhatChainName.${chainName.toUpperCase()}]: ChainSlug.${chainName.toUpperCase()},\n};\n`, + ",\n};" + ); + await updateFile( + "chainSlugToHardhatChainName.ts", + `,\n [ChainSlug.${chainName.toUpperCase()}]: HardhatChainName.${chainName.toUpperCase()},\n};\n`, + ",\n};" + ); + + if (isNewNative) { + await updateFile( + "native-tokens.ts", + `,\n "${nativeToken.toLowerCase()}" = "${nativeToken.toLowerCase()}",\n}\n`, + ",\n}" + ); + } + + if (nativeToken !== NativeTokens.ethereum) { + await updateFile( + "currency.ts", + `,\n [ChainSlug.${chainName.toUpperCase()}]: NativeTokens["${nativeToken}"],\n};\n`, + ",\n};" + ); + } + + const chainTypeInString = Object.keys(ChainType)[chainType]; + if (chainTypeInString === ChainType.arbChain) { + await updateFile( + "arbChains.ts", + `,\n ChainSlug.${chainName.toUpperCase()},\n];`, + ",\n];" + ); + } else if (chainTypeInString === ChainType.arbL3Chain) { + await updateFile( + "arbL3Chains.ts", + `,\n ChainSlug.${chainName.toUpperCase()},\n];`, + ",\n];" + ); + } else if (chainTypeInString === ChainType.opStackL2Chain) { + await updateFile( + "opStackChains.ts", + `,\n ChainSlug.${chainName.toUpperCase()},\n];`, + ",\n];" + ); + } else if (chainTypeInString === ChainType.polygonCDKChain) { + await updateFile( + "polygonCDKChains.ts", + `,\n ChainSlug.${chainName.toUpperCase()},\n];`, + ",\n];" + ); + } else if (chainTypeInString === ChainType.zkStackChain) { + await updateFile( + "zkStackChain.ts", + `,\n ChainSlug.${chainName.toUpperCase()},\n];`, + ",\n];" + ); + } else { + await updateFile( + "ethLikeChains.ts", + `,\n ChainSlug.${chainName.toUpperCase()},\n];`, + ",\n];" + ); + } + + if (isMainnet) { + await updateFile( + "mainnetIds.ts", + `,\n ChainSlug.${chainName.toUpperCase()},\n];\n`, + ",\n];" + ); + } else + await updateFile( + "testnetIds.ts", + `,\n ChainSlug.${chainName.toUpperCase()},\n];\n`, + ",\n];" + ); +}; + +const updateFile = async ( + fileName: string, + newChainDetails: string, + replaceWith: string +) => { + const filePath = enumFolderPath + fileName; + const outputExists = fs.existsSync(filePath); + if (!outputExists) throw new Error(`${fileName} enum not found! ${filePath}`); + + const verificationDetailsString = fs.readFileSync(filePath, "utf-8"); + + // replace last bracket with new line + const verificationDetails = verificationDetailsString + .trimEnd() + .replace(replaceWith, newChainDetails); + + fs.writeFileSync(filePath, verificationDetails); +}; diff --git a/hardhat-scripts/addChain/writeConfigs.ts b/hardhat-scripts/addChain/writeConfigs.ts new file mode 100644 index 00000000..bb9f6549 --- /dev/null +++ b/hardhat-scripts/addChain/writeConfigs.ts @@ -0,0 +1,118 @@ +import { StaticJsonRpcProvider } from "@ethersproject/providers"; +import { utils } from "ethers"; +import prompts from "prompts"; + +import { ChainId, ChainType, NativeTokens } from "../../src"; +import { updateSDK } from "./utils"; + +export async function addChainToSDK() { + const currencyChoices = [...Object.keys(NativeTokens), "other"]; + + const rpcResponse = await prompts([ + { + name: "rpc", + type: "text", + message: "Enter rpc url", + validate: validateRpc, + }, + { + name: "chainName", + type: "text", + message: + "Enter chain name (without spaces, use underscore instead of spaces)", + }, + ]); + + const chainId = await getChainId(rpcResponse.rpc); + + const filteredChain = Object.values(ChainId).filter((c) => c == chainId); + if (filteredChain.length > 0) { + console.log("Chain already added!"); + return { + response: { rpc: rpcResponse.rpc, chainName: rpcResponse.chainName }, + chainId, + isAlreadyAdded: true, + }; + } + + const response = await prompts([ + { + name: "isMainnet", + type: "toggle", + message: "Is it a mainnet?", + }, + { + name: "chainType", + type: "select", + message: "Select the rollup type (select default if not)", + choices: [...Object.keys(ChainType)].map((type) => ({ + title: type, + value: type, + })), + }, + { + name: "currency", + type: "select", + message: "Select the native token", + choices: currencyChoices.map((choice) => ({ + title: choice, + value: choice, + })), + }, + ]); + + let isNewNative = false; + let currency = currencyChoices[response.currency]; + if (response.currency == currencyChoices.length - 1) { + const currencyPromptResponse = await prompts([ + { + name: "coingeckoId", + type: "text", + message: "Enter coingecko id of your token", + validate: validateCoingeckoId, + }, + ]); + + isNewNative = true; + currency = currencyPromptResponse.coingeckoId; + } + + // update types and enums + await updateSDK( + rpcResponse.chainName, + chainId, + currency, + response.chainType, + response.isMainnet, + isNewNative + ); + + return { response, chainId, isAlreadyAdded: false }; +} + +const validateCoingeckoId = async (coingeckoId: string) => { + if (!coingeckoId) { + return "Invalid coingecko Id"; + } + return true; +}; + +const validateRpc = async (rpcUrl: string) => { + if (!rpcUrl) { + return "Invalid RPC"; + } + return getChainId(rpcUrl) + .then((a) => true) + .catch((e) => `Invalid RPC: ${e}`); +}; + +const validateAddress = (address: string) => { + if (!address || address.length === 0) return true; + return utils.isAddress(address); +}; + +const getChainId = async (rpcUrl: string) => { + const provider = new StaticJsonRpcProvider(rpcUrl); + const network = await provider.getNetwork(); + return network.chainId; +}; diff --git a/hardhat-scripts/config/config.ts b/hardhat-scripts/config/config.ts index 6cea0d30..1c51441f 100644 --- a/hardhat-scripts/config/config.ts +++ b/hardhat-scripts/config/config.ts @@ -1,7 +1,7 @@ import { config as dotenvConfig } from "dotenv"; dotenvConfig(); import { ethers } from "ethers"; -import { ChainSlug, DeploymentMode } from "@socket.tech/socket-protocol-common"; +import { ChainSlug, DeploymentMode } from "../../src"; export const mode = process.env.DEPLOYMENT_MODE as | DeploymentMode @@ -26,15 +26,15 @@ export const logConfig = () => { export const chains: Array = [ ChainSlug.ARBITRUM_SEPOLIA, ChainSlug.OPTIMISM_SEPOLIA, - // ChainSlug.SEPOLIA, ChainSlug.BASE_SEPOLIA, + // ChainSlug.SEPOLIA, ]; export const EVM_CHAIN_ID_MAP: Record = { [DeploymentMode.LOCAL]: 7625382, [DeploymentMode.DEV]: 7625382, [DeploymentMode.STAGE]: 43, [DeploymentMode.PROD]: 3605, -} +}; export const auctionEndDelaySeconds = 0; export const watcher = "0xb62505feacC486e809392c65614Ce4d7b051923b"; export const MAX_FEES = ethers.utils.parseEther("0.001"); diff --git a/hardhat-scripts/constants/constants.ts b/hardhat-scripts/constants/constants.ts index 1ae8e8f5..2937a81d 100644 --- a/hardhat-scripts/constants/constants.ts +++ b/hardhat-scripts/constants/constants.ts @@ -1 +1,5 @@ export const ETH_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"; + + +export const IMPLEMENTATION_SLOT = + "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc"; \ No newline at end of file diff --git a/hardhat-scripts/constants/relayers.ts b/hardhat-scripts/constants/relayers.ts deleted file mode 100644 index 589291d9..00000000 --- a/hardhat-scripts/constants/relayers.ts +++ /dev/null @@ -1,22 +0,0 @@ -export const relayerAddressList = [ - "0x59D24CD3A0b2b646F980A62DCb0aA4115506FFc9", - "0x762783712FD12231601d6d8591F3a5718812D534", - "0x9f5C9941306E7B57583E99033BedB7eA7889EEA4", - "0xd35F262d6f2D3F6D610bAf6635dE57c349ca83A1", - "0xce6b9c352f864515d7E8BBEA67d80d18245937F2", - "0xE651eDb3F16D9e6b1145ae5eee388f0e48D2d44b", - "0xc176E88dE45747743699fAeA58814Ce98a2faC2D", - "0x88220692264EEc280Bd5AaF9278CdE0737Feb2D6", - "0x2d68551354226c7321130f122055F049F8F67791", - "0xA7C89619ceaC009a23c6C3bC5F74d41BBaC68fD1", - "0x7893D79718860DF30e5Fd21AAA6Be05edD22465D", - "0x6386c83e994331c6a41A4420294D130930AEDF9e", - "0xfF33A0afc88CbF48C9DB31Fc2D2EC2F36D598184", - "0xB756B6D986eE448433542A60A1f590EE3B0DFCda", - "0x76943F947D5622624444aeFF135a5121d6732299", - "0x049B750045fdE15F347aF9E86FB80dD879C848ea", - "0x9c653569C32473F40210495128BB5A40ef10c65B", - "0x0291a40beF28E3606b8208a665F900d141E9A8B3", - "0x2e498dFB44CC79D2ef80Afd7C4439BEC8822E216", - "0x049E701A690E885467E54A1B0595f90BDc8324B0", -]; diff --git a/hardhat-scripts/constants/types.ts b/hardhat-scripts/constants/types.ts index 97603b2c..0cd19bef 100644 --- a/hardhat-scripts/constants/types.ts +++ b/hardhat-scripts/constants/types.ts @@ -1,7 +1,4 @@ -import { - ChainAddressesObj, - ChainSlug, -} from "@socket.tech/socket-protocol-common"; +import { ChainAddressesObj, ChainSlug } from "../../src"; export type DeploymentAddresses = { [chainSlug in ChainSlug]?: ChainAddressesObj; diff --git a/hardhat-scripts/deploy/1.deploy.ts b/hardhat-scripts/deploy/1.deploy.ts index 645e82f7..5a07d9a1 100644 --- a/hardhat-scripts/deploy/1.deploy.ts +++ b/hardhat-scripts/deploy/1.deploy.ts @@ -1,31 +1,31 @@ -import { - ChainAddressesObj, - ChainSlug -} from "@socket.tech/socket-protocol-common"; +import { ChainAddressesObj, ChainSlug } from "../../src"; import { config } from "dotenv"; -import { Contract, Signer, Wallet, providers } from "ethers"; +import { Contract, Signer, utils, Wallet } from "ethers"; import { formatEther } from "ethers/lib/utils"; import { ethers } from "hardhat"; -import { BID_TIMEOUT, EVMX_CHAIN_ID, EXPIRY_TIME, MAX_LIMIT } from "../config"; -import { - auctionEndDelaySeconds, - chains, - logConfig, - mode, -} from "../config/config"; import { CORE_CONTRACTS, DeploymentAddresses, EVMxCoreContracts, + IMPLEMENTATION_SLOT, } from "../constants"; -import { getImplementationAddress } from "../migration/migrate-proxies"; import { DeployParams, getAddresses, getOrDeploy, - getProviderFromChainSlug, storeAddresses, } from "../utils"; +import { getSocketSigner, getWatcherSigner } from "../utils/sign"; +import { + auctionEndDelaySeconds, + BID_TIMEOUT, + chains, + EVMX_CHAIN_ID, + EXPIRY_TIME, + logConfig, + MAX_LIMIT, + mode, +} from "../config/config"; config(); let EVMxOwner: string; @@ -38,27 +38,35 @@ const main = async () => { }; const logBalances = async () => { - const evmxDeployer = new ethers.Wallet(process.env.WATCHER_PRIVATE_KEY as string); - const socketDeployer = new ethers.Wallet(process.env.SOCKET_SIGNER_KEY as string); - let provider = getProviderFromChainSlug(EVMX_CHAIN_ID as ChainSlug); - const evmxBalance = await provider.getBalance(evmxDeployer.address); - console.log(`EVMx Deployer ${evmxDeployer.address} balance on ${EVMX_CHAIN_ID}:`, formatEther(evmxBalance)); - await Promise.all(chains.map(async (chain) => { - const provider = getProviderFromChainSlug(chain); - const socketBalance = await provider.getBalance(socketDeployer.address); - console.log(`Socket Deployer ${socketDeployer.address} balance on ${chain}:`, formatEther(socketBalance)); - })); + const evmxDeployer = await getWatcherSigner(); + const evmxBalance = await evmxDeployer.provider.getBalance( + evmxDeployer.address + ); + console.log( + `EVMx Deployer ${evmxDeployer.address} balance on ${EVMX_CHAIN_ID}:`, + formatEther(evmxBalance) + ); + await Promise.all( + chains.map(async (chain) => { + const socketDeployer = await getSocketSigner(chain as ChainSlug); + const socketBalance = await socketDeployer.provider.getBalance( + socketDeployer.address + ); + console.log( + `Socket Deployer ${socketDeployer.address} balance on ${chain}:`, + formatEther(socketBalance) + ); + }) + ); }; - - const deployEVMxContracts = async () => { try { let addresses: DeploymentAddresses; let deployUtils: DeployParams = { addresses: {} as ChainAddressesObj, mode, - signer: new ethers.Wallet(process.env.WATCHER_PRIVATE_KEY as string), + signer: getWatcherSigner(), currentChainSlug: EVMX_CHAIN_ID as ChainSlug, }; const chain = EVMX_CHAIN_ID; @@ -69,13 +77,7 @@ const deployEVMxContracts = async () => { ? (addresses[chain] as ChainAddressesObj) : ({} as ChainAddressesObj); - const providerInstance = new providers.StaticJsonRpcProvider( - process.env.EVMX_RPC as string - ); - const signer: Wallet = new ethers.Wallet( - process.env.WATCHER_PRIVATE_KEY as string, - providerInstance - ); + const signer: Wallet = getWatcherSigner(); EVMxOwner = signer.address; deployUtils = { @@ -209,7 +211,7 @@ const deploySocketContracts = async () => { let deployUtils: DeployParams = { addresses: {} as ChainAddressesObj, mode, - signer: new ethers.Wallet(process.env.SOCKET_SIGNER_KEY as string), + signer: getSocketSigner(EVMX_CHAIN_ID as ChainSlug), currentChainSlug: EVMX_CHAIN_ID as ChainSlug, }; console.log("Deploying Socket contracts"); @@ -221,11 +223,7 @@ const deploySocketContracts = async () => { ? (addresses[chain] as ChainAddressesObj) : ({} as ChainAddressesObj); - const providerInstance = getProviderFromChainSlug(chain); - const signer: Wallet = new ethers.Wallet( - process.env.SOCKET_SIGNER_KEY as string, - providerInstance - ); + const signer: Wallet = getSocketSigner(chain as ChainSlug); const socketOwner = signer.address; deployUtils = { @@ -418,9 +416,29 @@ const deployContractWithProxy = async ( return deployUtils; }; + +export async function getImplementationAddress( + proxyAddress: string +): Promise { + const customProvider = new ethers.providers.JsonRpcProvider( + process.env.EVMX_RPC as string + ); + + // Fallback to standard storage slot for other proxy types + const implHex = await customProvider.getStorageAt( + proxyAddress, + IMPLEMENTATION_SLOT + ); + + return utils.getAddress("0x" + implHex.slice(-40)); +} + + main() .then(() => process.exit(0)) .catch((error: Error) => { console.error(error); process.exit(1); }); + + diff --git a/hardhat-scripts/deploy/2.roles.ts b/hardhat-scripts/deploy/2.roles.ts index 8aa12732..9c000c44 100644 --- a/hardhat-scripts/deploy/2.roles.ts +++ b/hardhat-scripts/deploy/2.roles.ts @@ -2,7 +2,6 @@ import { config as dotenvConfig } from "dotenv"; dotenvConfig(); import { Wallet } from "ethers"; -import { ethers } from "hardhat"; import { chains, EVMX_CHAIN_ID, mode, watcher } from "../config"; import { CORE_CONTRACTS, @@ -16,10 +15,9 @@ import { getRoleHash, overrides, } from "../utils"; -import { relayerAddressList } from "../constants/relayers"; -import { ChainAddressesObj } from "@socket.tech/socket-protocol-common"; +import { ChainAddressesObj, ChainSlug } from "../../src"; import { ROLES } from "../constants/roles"; - +import { getWatcherSigner, getSocketSigner } from "../utils/sign"; export const REQUIRED_ROLES = { FastSwitchboard: [ROLES.WATCHER_ROLE, ROLES.RESCUE_ROLE], Socket: [ROLES.GOVERNANCE_ROLE, ROLES.RESCUE_ROLE], @@ -63,13 +61,9 @@ async function setRoleForContract( } async function getSigner(chain: number, isWatcher: boolean = false) { - const providerInstance = getProviderFromChainSlug(chain); - const signer: Wallet = new ethers.Wallet( - isWatcher - ? (process.env.WATCHER_PRIVATE_KEY as string) - : (process.env.SOCKET_SIGNER_KEY as string), - providerInstance - ); + const signer: Wallet = isWatcher + ? getWatcherSigner() + : getSocketSigner(chain as ChainSlug); return signer; } diff --git a/hardhat-scripts/deploy/3.upgradeManagers.ts b/hardhat-scripts/deploy/3.upgradeManagers.ts index eaf3592f..03eea53d 100644 --- a/hardhat-scripts/deploy/3.upgradeManagers.ts +++ b/hardhat-scripts/deploy/3.upgradeManagers.ts @@ -1,8 +1,4 @@ -import { - ChainSlug, - ChainAddressesObj, - DeploymentMode, -} from "@socket.tech/socket-protocol-common"; +import { ChainAddressesObj, ChainSlug } from "../../src"; import { config as dotenvConfig } from "dotenv"; dotenvConfig(); @@ -19,6 +15,8 @@ import { getAddresses, getInstance, getProviderFromChainSlug, + getSocketSigner, + getWatcherSigner, storeAddresses, } from "../utils"; @@ -33,11 +31,7 @@ export const main = async () => { ? (addresses[chain] as ChainAddressesObj) : ({} as ChainAddressesObj); - const providerInstance = getProviderFromChainSlug(chain); - const signer: Wallet = new ethers.Wallet( - process.env.SOCKET_SIGNER_KEY as string, - providerInstance - ); + const signer: Wallet = getSocketSigner(chain as ChainSlug); const socketContract = ( await getInstance( @@ -62,11 +56,7 @@ export const main = async () => { }; async function setOnchainContracts(chain, addresses) { - const providerInstance = getProviderFromChainSlug(EVMX_CHAIN_ID as ChainSlug); - const signer: Wallet = new ethers.Wallet( - process.env.WATCHER_PRIVATE_KEY as string, - providerInstance - ); + const signer: Wallet = getWatcherSigner(); const EVMxAddresses = addresses[EVMX_CHAIN_ID]!; const watcherPrecompile = ( await getInstance( diff --git a/hardhat-scripts/deploy/4.connect.ts b/hardhat-scripts/deploy/4.connect.ts index 0de5a503..cb5ffa70 100644 --- a/hardhat-scripts/deploy/4.connect.ts +++ b/hardhat-scripts/deploy/4.connect.ts @@ -1,5 +1,5 @@ -import { ChainAddressesObj } from "@socket.tech/socket-protocol-common"; -import { Contract, ethers, providers, Wallet } from "ethers"; +import { Contract, ethers, Wallet } from "ethers"; +import { ChainAddressesObj, ChainSlug } from "../../src"; import { chains, EVMX_CHAIN_ID, mode } from "../config"; import { CORE_CONTRACTS, @@ -9,10 +9,10 @@ import { import { getAddresses, getInstance, - getProviderFromChainSlug, + getSocketSigner, overrides, } from "../utils"; -import { signWatcherMessage } from "../utils/sign"; +import { getWatcherSigner, signWatcherMessage } from "../utils/sign"; const plugs = [CORE_CONTRACTS.ContractFactoryPlug, CORE_CONTRACTS.FeesPlug]; export type AppGatewayConfig = { plug: string; @@ -113,11 +113,7 @@ export const connectPlugsOnSocket = async () => { chains.map(async (chain) => { if (!addresses[chain]) return; - const providerInstance = getProviderFromChainSlug(chain); - const socketSigner = new Wallet( - process.env.SOCKET_SIGNER_KEY as string, - providerInstance - ); + const socketSigner = getSocketSigner(chain as ChainSlug); const addr = addresses[chain]!; // Connect each plug contract for (const plugContract of plugs) { @@ -149,13 +145,7 @@ export const updateConfigEVMx = async () => { const appConfigs: AppGatewayConfig[] = []; // Set up Watcher contract - const providerInstance = new providers.StaticJsonRpcProvider( - process.env.EVMX_RPC as string - ); - const signer = new ethers.Wallet( - process.env.WATCHER_PRIVATE_KEY as string, - providerInstance - ); + const signer = getWatcherSigner(); const EVMxAddresses = addresses[EVMX_CHAIN_ID]!; const watcher = ( await getInstance( diff --git a/hardhat-scripts/deploy/5.upload.ts b/hardhat-scripts/deploy/5.upload.ts index b6d5aebb..4eaccb8f 100644 --- a/hardhat-scripts/deploy/5.upload.ts +++ b/hardhat-scripts/deploy/5.upload.ts @@ -1,20 +1,15 @@ import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3"; -import { - ChainAddressesObj, - DeploymentMode, - EVMxAddressesObj, - chainSlugToHardhatChainName, - ChainSlug -} from "@socket.tech/socket-protocol-common"; +import { DeploymentMode } from "../../src"; import { config as dotenvConfig } from "dotenv"; -import fs from "fs"; -import path from "path"; -import { EVMX_CHAIN_ID, mode, chains } from "../config/config"; +import { mode } from "../config/config"; +import { getS3Config } from "../s3Config/buildConfig"; dotenvConfig(); const getBucketName = () => { switch (mode) { + case DeploymentMode.LOCAL: + return "socketpoc"; case DeploymentMode.DEV: return "socketpoc"; case DeploymentMode.STAGE: @@ -28,6 +23,8 @@ const getBucketName = () => { const getFileName = () => { switch (mode) { + case DeploymentMode.LOCAL: + return "pocConfig.json"; case DeploymentMode.DEV: return "devConfig.json"; case DeploymentMode.STAGE: @@ -38,75 +35,17 @@ const getFileName = () => { throw new Error(`Invalid deployment mode: ${mode}`); } }; - -const getAddressesPath = () => { - switch (mode) { - case DeploymentMode.DEV: - return "../../deployments/dev_addresses.json"; - case DeploymentMode.STAGE: - return "../../deployments/stage_addresses.json"; - case DeploymentMode.PROD: - return "../../deployments/prod_addresses.json"; - default: - throw new Error(`Invalid deployment mode: ${mode}`); - } -}; -type ConfigEntry = { - eventBlockRangePerCron: number; - rpc: string | undefined; - wssRpc: string | undefined; - confirmations: number; - eventBlockRange: number; - addresses?: ChainAddressesObj | EVMxAddressesObj; -}; -type S3Config = { - [chainId: string]: ConfigEntry; -}; - -const supportedChainSlugs = [EVMX_CHAIN_ID as ChainSlug, ...chains]; - -export let config: S3Config = { - //@ts-ignore - supportedChainSlugs, -}; - -// Add config for each supported chain -supportedChainSlugs.forEach(chainSlug => { - let chainName = - chainSlug === EVMX_CHAIN_ID ? "EVMX" : chainSlugToHardhatChainName[chainSlug].toString().replace("-", "_"); - let rpcKey = `${chainName.toUpperCase()}_RPC`; - let wssRpcKey = `${chainName.toUpperCase()}_WSS_RPC`; - if (!process.env[rpcKey] || !process.env[wssRpcKey]) { - console.log(`Missing RPC or WSS RPC for chain ${chainName}`); - return; - } - config[chainSlug] = { - eventBlockRangePerCron: 5000, - rpc: process.env[rpcKey], - wssRpc: process.env[wssRpcKey], - confirmations: 0, - eventBlockRange: 5000, - }; -}); -// Read the addresses.json file -const addressesPath = path.join(__dirname, getAddressesPath()); -const addresses = JSON.parse(fs.readFileSync(addressesPath, "utf8")); - -// Update config with addresses -for (const chainId in config) { - if (addresses[chainId]) { - console.log(`Updating addresses for chainId ${chainId}`); - config[chainId].addresses = addresses[chainId]; - } -} -console.log(JSON.stringify(config, null, 2)); // Initialize S3 client const s3Client = new S3Client({ region: "us-east-1" }); // Replace with your preferred region // Function to upload to S3 -async function uploadToS3(data: any, fileName: string = getFileName()) { +async function uploadToS3() { + const fileName = getFileName(); + const bucketName = getBucketName(); + const data = getS3Config(); + console.log(JSON.stringify(data, null, 2)); const params = { - Bucket: getBucketName(), + Bucket: bucketName, Key: fileName, Body: JSON.stringify(data, null, 2), ContentType: "application/json", @@ -115,12 +54,10 @@ async function uploadToS3(data: any, fileName: string = getFileName()) { try { const command = new PutObjectCommand(params); await s3Client.send(command); - console.log(`Successfully uploaded ${fileName} to S3`); + console.log(`Successfully uploaded ${fileName} to S3 bucket ${bucketName}`); } catch (error) { console.error(`Error uploading ${fileName} to S3:`, error); } } -// Upload config to S3 -// uploadToS3(config, "pocConfig.json"); -uploadToS3(config); +uploadToS3(); diff --git a/hardhat-scripts/deploy/6.setupEnv.ts b/hardhat-scripts/deploy/6.setupEnv.ts index 17707fed..6f9a7f83 100644 --- a/hardhat-scripts/deploy/6.setupEnv.ts +++ b/hardhat-scripts/deploy/6.setupEnv.ts @@ -1,4 +1,4 @@ -import { ChainSlug } from "@socket.tech/socket-protocol-common"; +import { ChainSlug } from "../../src"; import fs from "fs"; import path from "path"; import { EVMX_CHAIN_ID, mode } from "../config/config"; diff --git a/hardhat-scripts/migration/migrate-proxies.ts b/hardhat-scripts/migration/migrate-proxies.ts deleted file mode 100644 index ca8068c1..00000000 --- a/hardhat-scripts/migration/migrate-proxies.ts +++ /dev/null @@ -1,220 +0,0 @@ -import { ethers } from "hardhat"; -import { Contract, utils, Wallet } from "ethers"; -import { EVMX_CHAIN_ID, UPGRADE_VERSION } from "../config/config"; -import { getProviderFromChainSlug } from "../utils"; -import { ChainSlug } from "@socket.tech/socket-protocol-common"; -import { getAddresses } from "../utils"; -import { mode } from "../config/config"; -// Implementation slot from ERC1967 -const IMPLEMENTATION_SLOT = - "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc"; - -const upgradeableContracts = [ - "AddressResolver", - "WatcherPrecompile", - "FeesManager", - "DeliveryHelper", - "AuctionManager", -]; - -export async function getImplementationAddress( - proxyAddress: string -): Promise { - const customProvider = new ethers.providers.JsonRpcProvider( - process.env.EVMX_RPC as string - ); - - // Fallback to standard storage slot for other proxy types - const implHex = await customProvider.getStorageAt( - proxyAddress, - IMPLEMENTATION_SLOT - ); - - return utils.getAddress("0x" + implHex.slice(-40)); -} - -async function setupSigner() { - const providerInstance = getProviderFromChainSlug(EVMX_CHAIN_ID as ChainSlug); - return new ethers.Wallet( - process.env.WATCHER_PRIVATE_KEY as string, - providerInstance - ); -} - -async function setupProxyFactory(addresses: any, signer: Wallet) { - let proxyFactory = await ethers.getContractAt( - "ERC1967Factory", - addresses[EVMX_CHAIN_ID].ERC1967Factory - ); - return proxyFactory.connect(signer); -} - -async function upgradeContract( - contractName: string, - addresses: any, - proxyFactory: Contract, - signer: Wallet -) { - console.log(`\nProcessing ${contractName}...`); - - const PROXY_ADDRESS = addresses[EVMX_CHAIN_ID][contractName]; - if (!PROXY_ADDRESS) { - console.log(`Contract address not found for ${contractName}`); - return; - } - - try { - const currentImplAddress = await getImplementationAddress(PROXY_ADDRESS); - console.log( - `Current implementation for ${contractName}: ${currentImplAddress}` - ); - - const newImplementation = addresses[EVMX_CHAIN_ID][`${contractName}Impl`]; - if (!newImplementation) { - console.log(`No implementation address found for ${contractName}`); - return; - } - - let contract = await ethers.getContractAt(contractName, PROXY_ADDRESS); - contract = contract.connect(signer); - - await verifyAndUpgradeContract( - contract, - contractName, - currentImplAddress, - newImplementation, - proxyFactory, - signer - ); - } catch (error) { - console.error(`Error upgrading ${contractName}:`, error); - process.exit(1); - } -} - -async function verifyAndUpgradeContract( - contract: Contract, - contractName: string, - currentImplAddress: string, - newImplementation: string, - proxyFactory: Contract, - signer: Wallet -) { - let version; - try { - version = await contract.version(); - console.log("Version on contract before upgrade:", version); - } catch (error) { - console.log("version variable not found"); - } - - if (contractName === "AddressResolver") - await verifyBeaconImplementation(contract, signer); - - if (currentImplAddress.toLowerCase() === newImplementation.toLowerCase()) { - console.log("Implementation is already up to date"); - return; - } - - await performUpgrade(contract, proxyFactory, newImplementation); - await verifyUpgrade(contract, newImplementation, contractName, signer); -} - -async function performUpgrade( - contract: Contract, - proxyFactory: Contract, - newImplementation: string -) { - console.log("Upgrading proxy..."); - const initializeFn = contract.interface.getFunction("initialize"); - const initData = contract.interface.encodeFunctionData(initializeFn, [ - UPGRADE_VERSION, - ]); - - const tx = await proxyFactory.upgradeAndCall( - contract.address, - newImplementation, - initData - ); - console.log("tx", tx.hash); - await tx.wait(); -} - -async function verifyUpgrade( - contract: Contract, - newImplementation: string, - contractName: string, - signer: Wallet -) { - const updatedImplAddress = await getImplementationAddress(contract.address); - console.log("New implementation:", updatedImplAddress); - - if (updatedImplAddress.toLowerCase() !== newImplementation.toLowerCase()) { - throw new Error("Upgrade verification failed - implementation mismatch"); - } - - const version = await contract.version(); - console.log("Version on contract after upgrade:", version); - - if (contractName === "AddressResolver") { - await verifyBeaconImplementation(contract, signer); - } - - console.log("Upgrade successful and verified"); -} - -async function verifyBeaconImplementation(contract: Contract, signer: Wallet) { - console.log("Verifying beacon implementations..."); - const forwarderBeaconAddress = await contract.forwarderBeacon(); - const forwarderImplementationAddress = - await contract.forwarderImplementation(); - const asyncPromiseBeaconAddress = await contract.asyncPromiseBeacon(); - const asyncPromiseImplementationAddress = - await contract.asyncPromiseImplementation(); - - const upgradeableBeaconAbi = [ - "function implementation() view returns (address)", - ]; - - const forwarderBeacon = new ethers.Contract( - forwarderBeaconAddress, - upgradeableBeaconAbi - ); - const asyncPromiseBeacon = new ethers.Contract( - asyncPromiseBeaconAddress, - upgradeableBeaconAbi - ); - - // Verify forwarder beacon implementation - const forwarderBeaconImplementation = await forwarderBeacon - .connect(signer) - .implementation(); - if ( - forwarderBeaconImplementation.toLowerCase() !== - forwarderImplementationAddress.toLowerCase() - ) { - throw new Error("Forwarder beacon implementation mismatch"); - } - - // Verify async promise beacon implementation - const asyncPromiseBeaconImplementation = await asyncPromiseBeacon - .connect(signer) - .implementation(); - if ( - asyncPromiseBeaconImplementation.toLowerCase() !== - asyncPromiseImplementationAddress.toLowerCase() - ) { - throw new Error("Async promise beacon implementation mismatch"); - } -} - -async function main() { - // @ts-ignore - Hardhat Runtime Environment will be injected by hardhat - const addresses = getAddresses(mode); - const signer = await setupSigner(); - const proxyFactory = await setupProxyFactory(addresses, signer); - - for (const contractName of upgradeableContracts) { - await upgradeContract(contractName, addresses, proxyFactory, signer); - } -} diff --git a/hardhat-scripts/s3Config/buildConfig.ts b/hardhat-scripts/s3Config/buildConfig.ts new file mode 100644 index 00000000..7d51681b --- /dev/null +++ b/hardhat-scripts/s3Config/buildConfig.ts @@ -0,0 +1,44 @@ +import { config as dotenvConfig } from "dotenv"; +import { ChainConfig, ChainSlug, S3Config, getFinalityBlocks } from "../../src"; +import { EVMX_CHAIN_ID, chains, mode } from "../config/config"; +import { getAddresses } from "../utils/address"; +import { getChainName, rpcKeys, wssRpcKeys } from "../utils/networks"; +import { getChainType } from "./utils"; +import { version } from "./version"; + +dotenvConfig(); +const addresses = getAddresses(mode); + +export const getS3Config = () => { + const supportedChainSlugs = [EVMX_CHAIN_ID as ChainSlug, ...chains]; + const config: S3Config = { + supportedChainSlugs, + version: version[mode], + chains: {}, + }; + supportedChainSlugs.forEach((chainSlug) => { + config.chains[chainSlug] = getChainConfig(chainSlug); + }); + return config; +}; + +export const getChainConfig = (chainSlug: ChainSlug) => { + let rpcKey = rpcKeys(chainSlug); + let wssRpcKey = wssRpcKeys(chainSlug); + if (!process.env[rpcKey] || !process.env[wssRpcKey]) { + throw new Error( + `Missing RPC or WSS RPC for chain ${getChainName(chainSlug)}` + ); + } + const chainConfig: ChainConfig = { + eventBlockRangePerCron: 5000, + rpc: process.env[rpcKey], + wssRpc: process.env[wssRpcKey], + confirmations: 0, + eventBlockRange: 5000, + addresses: addresses[chainSlug], + chainType: getChainType(chainSlug), + finalityBlocks: getFinalityBlocks(chainSlug), + }; + return chainConfig; +}; diff --git a/hardhat-scripts/s3Config/utils.ts b/hardhat-scripts/s3Config/utils.ts new file mode 100644 index 00000000..f5fe6412 --- /dev/null +++ b/hardhat-scripts/s3Config/utils.ts @@ -0,0 +1,23 @@ +import { + arbChains, + arbL3Chains, + ChainSlug, + ChainType, + opStackL2Chain, + polygonCDKChains, + zkStackChain, +} from "../../src"; + +export const getChainType = (chainSlug: ChainSlug) => { + if (opStackL2Chain.includes(chainSlug)) { + return ChainType.opStackL2Chain; + } else if (arbChains.includes(chainSlug)) { + return ChainType.arbChain; + } else if (arbL3Chains.includes(chainSlug)) { + return ChainType.arbL3Chain; + } else if (polygonCDKChains.includes(chainSlug)) { + return ChainType.zkStackChain; + } else if (zkStackChain.includes(chainSlug)) { + return ChainType.polygonCDKChain; + } else return ChainType.default; +}; diff --git a/hardhat-scripts/s3Config/version.ts b/hardhat-scripts/s3Config/version.ts new file mode 100644 index 00000000..ad7863dd --- /dev/null +++ b/hardhat-scripts/s3Config/version.ts @@ -0,0 +1,8 @@ +import { DeploymentMode } from "../../src"; + +export const version = { + [DeploymentMode.LOCAL]: "1.0.17", + [DeploymentMode.DEV]: "1.0.17", + [DeploymentMode.STAGE]: "1.0.17", + [DeploymentMode.PROD]: "1.0.17", +}; diff --git a/hardhat-scripts/utils/address.ts b/hardhat-scripts/utils/address.ts index d74f1313..d14082eb 100644 --- a/hardhat-scripts/utils/address.ts +++ b/hardhat-scripts/utils/address.ts @@ -1,16 +1,18 @@ import dev_addresses from "../../deployments/dev_addresses.json"; import stage_addresses from "../../deployments/stage_addresses.json"; -import prod_addresses from "../../deployments/prod_addresses.json"; -import { DeploymentMode } from "@socket.tech/socket-protocol-common"; +import local_addresses from "../../deployments/local_addresses.json"; +import { ChainAddressesObj, DeploymentMode, EVMxAddressesObj } from "../../src"; -export const getAddresses = (mode: DeploymentMode) => { +export const getAddresses = ( + mode: DeploymentMode +): { [chainSlug: string | number]: ChainAddressesObj | EVMxAddressesObj } => { switch (mode) { + case DeploymentMode.LOCAL: + return local_addresses; case DeploymentMode.DEV: return dev_addresses; case DeploymentMode.STAGE: return stage_addresses; - case DeploymentMode.PROD: - return prod_addresses; default: throw new Error(`Invalid deployment mode: ${mode}`); } diff --git a/hardhat-scripts/utils/deployUtils.ts b/hardhat-scripts/utils/deployUtils.ts index a3accdf2..d8bb1efe 100644 --- a/hardhat-scripts/utils/deployUtils.ts +++ b/hardhat-scripts/utils/deployUtils.ts @@ -9,7 +9,7 @@ import { ChainAddressesObj, ChainSlug, DeploymentMode, -} from "@socket.tech/socket-protocol-common"; +} from "../../src"; import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers"; import { overrides } from "../utils"; import { VerifyArgs } from "../verify"; diff --git a/hardhat-scripts/utils/index.ts b/hardhat-scripts/utils/index.ts index b0ec6153..e11a036e 100644 --- a/hardhat-scripts/utils/index.ts +++ b/hardhat-scripts/utils/index.ts @@ -3,3 +3,4 @@ export * from "./networks"; export * from "./overrides"; export * from "./accounts"; export * from "./deployUtils"; +export * from "./sign"; diff --git a/hardhat-scripts/utils/networks.ts b/hardhat-scripts/utils/networks.ts index b2f55ebe..a8cc205c 100644 --- a/hardhat-scripts/utils/networks.ts +++ b/hardhat-scripts/utils/networks.ts @@ -6,7 +6,7 @@ import { hardhatChainNameToSlug, HardhatChainName, chainSlugToHardhatChainName, -} from "@socket.tech/socket-protocol-common"; +} from "../../src"; import { EVMX_CHAIN_ID } from "../config/config"; const dotenvConfigPath: string = process.env.DOTENV_CONFIG_PATH || "./.env"; @@ -21,15 +21,23 @@ function createReverseEnumMap(enumObj: any) { return reverseMap; } -export const rpcKeys = (chainSlug: ChainSlug) => { - if (chainSlug == (EVMX_CHAIN_ID as ChainSlug)) { - return "EVMX_RPC"; +export const getChainName = (chainSlug: ChainSlug) => { + if (chainSlug === EVMX_CHAIN_ID) { + return "EVMX"; } - let chainName = chainSlugToHardhatChainName[chainSlug].toString(); - chainName = chainName.replace("-", "_"); + return chainSlugToHardhatChainName[chainSlug].toString().replace("-", "_"); +}; + +export const rpcKeys = (chainSlug: ChainSlug) => { + const chainName = getChainName(chainSlug); return `${chainName.toUpperCase()}_RPC`; }; +export const wssRpcKeys = (chainSlug: ChainSlug) => { + const chainName = getChainName(chainSlug); + return `${chainName.toUpperCase()}_WSS_RPC`; +}; + export function getJsonRpcUrl(chain: ChainSlug): string { let chainRpcKey = rpcKeys(chain); if (!chainRpcKey) throw Error(`Chain ${chain} not found in rpcKey`); diff --git a/hardhat-scripts/utils/overrides.ts b/hardhat-scripts/utils/overrides.ts index 7d9ccc96..d4cfdafc 100644 --- a/hardhat-scripts/utils/overrides.ts +++ b/hardhat-scripts/utils/overrides.ts @@ -1,4 +1,4 @@ -import { ChainSlug } from "@socket.tech/socket-protocol-common"; +import { ChainSlug } from "../../src"; import { BigNumber, BigNumberish, providers } from "ethers"; import { EVMX_CHAIN_ID } from "../config/config"; import { getProviderFromChainSlug } from "./networks"; diff --git a/hardhat-scripts/utils/sign.ts b/hardhat-scripts/utils/sign.ts index 2bd67a08..fdc40311 100644 --- a/hardhat-scripts/utils/sign.ts +++ b/hardhat-scripts/utils/sign.ts @@ -2,7 +2,8 @@ import { ethers, Wallet } from "ethers"; import { EVMX_CHAIN_ID, mode } from "../config/config"; import { EVMxCoreContracts } from "../constants"; import { getAddresses } from "./address"; - +import { getProviderFromChainSlug } from "./networks"; +import { ChainSlug } from "../../src"; export const signWatcherMessage = async (encodedMessage: string) => { const signatureNonce = Date.now(); const signer = new Wallet(process.env.WATCHER_PRIVATE_KEY!); @@ -17,3 +18,13 @@ export const signWatcherMessage = async (encodedMessage: string) => { const signature = await signer.signMessage(ethers.utils.arrayify(digest)); return { nonce: signatureNonce, signature }; }; + +export const getWatcherSigner = () => { + const provider = getProviderFromChainSlug(EVMX_CHAIN_ID as ChainSlug); + return new ethers.Wallet(process.env.WATCHER_PRIVATE_KEY as string, provider); +}; + +export const getSocketSigner = (chainSlug: ChainSlug) => { + const provider = getProviderFromChainSlug(chainSlug); + return new ethers.Wallet(process.env.SOCKET_SIGNER_KEY as string, provider); +}; diff --git a/hardhat-scripts/verify/verify.ts b/hardhat-scripts/verify/verify.ts index 4afabe63..7a1e5e06 100644 --- a/hardhat-scripts/verify/verify.ts +++ b/hardhat-scripts/verify/verify.ts @@ -1,15 +1,9 @@ -import { - ChainSlug, - ChainSlugToKey, - DeploymentMode, - HardhatChainName, -} from "@socket.tech/socket-protocol-common"; +import { ChainSlug, HardhatChainName, DeploymentMode, ChainSlugToKey } from "../../src"; import hre from "hardhat"; import { EVMX_CHAIN_ID, mode } from "../config/config"; import { storeUnVerifiedParams, verify } from "../utils"; import dev_verification from "../../deployments/dev_verification.json"; -import prod_verification from "../../deployments/prod_verification.json"; import stage_verification from "../../deployments/stage_verification.json"; const getVerificationParams = (mode: DeploymentMode) => { @@ -18,8 +12,6 @@ const getVerificationParams = (mode: DeploymentMode) => { return dev_verification; case DeploymentMode.STAGE: return stage_verification; - case DeploymentMode.PROD: - return prod_verification; default: throw new Error(`Invalid deployment mode: ${mode}`); } diff --git a/hardhat.config.ts b/hardhat.config.ts index 72ce85e8..63eff13e 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -22,9 +22,8 @@ import { ChainSlugToId, HardhatChainName, hardhatChainNameToSlug, -} from "@socket.tech/socket-protocol-common"; +} from "./src"; import { EVMX_CHAIN_ID } from "./hardhat-scripts/config/config"; -import { BASE_SEPOLIA_CHAIN_ID } from "./hardhat-scripts/constants"; const dotenvConfigPath: string = process.env.DOTENV_CONFIG_PATH || "./.env"; dotenvConfig({ path: resolve(__dirname, dotenvConfigPath) }); @@ -59,16 +58,12 @@ let liveNetworks = { ChainSlug.OPTIMISM_SEPOLIA ), [HardhatChainName.SEPOLIA]: getChainConfig(ChainSlug.SEPOLIA), + [HardhatChainName.BASE_SEPOLIA]: getChainConfig(ChainSlug.BASE_SEPOLIA), EVMX: { accounts: [`0x${privateKey}`], chainId: EVMX_CHAIN_ID, url: process.env.EVMX_RPC, }, - ["base_sepolia"]: { - accounts: [`0x${privateKey}`], - chainId: BASE_SEPOLIA_CHAIN_ID, - url: process.env.BASE_SEPOLIA_RPC, - }, }; const config: HardhatUserConfig = { @@ -121,7 +116,7 @@ const config: HardhatUserConfig = { }, { network: "baseTestnet", - chainId: BASE_SEPOLIA_CHAIN_ID, + chainId: ChainId.BASE_SEPOLIA, urls: { apiURL: "https://api-sepolia.basescan.org/api", browserURL: "https://sepolia.basescan.org/", diff --git a/package.json b/package.json index aee7ad7e..f0fb3b1b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@socket.tech/socket-protocol", - "main": "./dist/src/index.js", - "types": "./dist/src/index.d.ts", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", "files": [ "dist", "artifacts/abi" @@ -9,16 +9,17 @@ "publishConfig": { "access": "public" }, - "version": "1.0.15", + "version": "1.1.1", "description": "socket protocol", "scripts": { - "build": "hardhat export-abi && tsc --project lib.tsconfig.json", + "build": "yarn abi && tsc --project lib.tsconfig.json", "tsc": "tsc --project lib.tsconfig.json", "abi": "hardhat export-abi", "lint": "prettier \"./**\" --write", "lintContracts": "prettier \"./**\" --write --plugin=prettier-plugin-solidity", "compile": "forge build", - "deploy": "bash setupInfraContracts.sh" + "deploy": "bash setupInfraContracts.sh", + "update-version": "npm version patch --no-git-tag-version" }, "pre-commit": [], "author": "", @@ -27,21 +28,26 @@ "@aws-sdk/client-s3": "^3.670.0", "@nomicfoundation/hardhat-verify": "^2.0.12", "@nomiclabs/hardhat-ethers": "2.2.3", - "@socket.tech/socket-protocol-common": "1.1.31", + "@socket.tech/socket-protocol-common": "1.1.44", "@typechain/ethers-v5": "^10.0.0", "@typechain/hardhat": "6.0.0", + "@types/node": "^22.13.9", + "@types/prompts": "^2.4.9", "dotenv": "^16.0.3", "ethers": "5.6.6", "forge-std": "^1.1.2", + "fs": "^0.0.1-security", "hardhat": "2.12.2", "hardhat-abi-exporter": "2.10.1", "hardhat-change-network": "^0.0.7", "hardhat-deploy": "0.11.20", "hardhat-preprocessor": "0.1.4", "http-server": "^14.1.1", + "path": "^0.12.7", "pre-commit": "^1.2.2", "prettier": "^2.3.1", "prettier-plugin-solidity": "^1.4.1", + "prompts": "^2.4.2", "ts-node": "^10.7.0", "typechain": "^8.0.0", "typescript": "^4.6.4" diff --git a/publish.sh b/publish.sh new file mode 100755 index 00000000..6d4331ee --- /dev/null +++ b/publish.sh @@ -0,0 +1,2 @@ +yarn build +yarn publish \ No newline at end of file diff --git a/script/helpers/PayFeesInArbitrumETH.s.sol b/script/helpers/PayFeesInArbitrumETH.s.sol index 50da4fc1..9b3ef165 100644 --- a/script/helpers/PayFeesInArbitrumETH.s.sol +++ b/script/helpers/PayFeesInArbitrumETH.s.sol @@ -20,7 +20,8 @@ contract DepositFees is Script { console.log("Sender address:", sender); uint256 balance = sender.balance; console.log("Sender balance in wei:", balance); - + console.log("App Gateway:", appGateway); + console.log("Fees Plug:", address(feesPlug)); uint feesAmount = 0.001 ether; feesPlug.deposit{value: feesAmount}(ETH_ADDRESS, appGateway, feesAmount); } diff --git a/src/chain-enums/arbChains.ts b/src/chain-enums/arbChains.ts new file mode 100644 index 00000000..5a7a9e81 --- /dev/null +++ b/src/chain-enums/arbChains.ts @@ -0,0 +1,11 @@ +import { ChainSlug } from "./chainSlug"; + +export const arbChains = [ + ChainSlug.ARBITRUM, + ChainSlug.ARBITRUM_GOERLI, + ChainSlug.ARBITRUM_SEPOLIA, + ChainSlug.PARALLEL, + ChainSlug.REYA_CRONOS, + ChainSlug.REYA, + ChainSlug.GEIST, +]; diff --git a/src/chain-enums/arbL3Chains.ts b/src/chain-enums/arbL3Chains.ts new file mode 100644 index 00000000..a400f5da --- /dev/null +++ b/src/chain-enums/arbL3Chains.ts @@ -0,0 +1,9 @@ +import { ChainSlug } from "./chainSlug"; + +export const arbL3Chains = [ + ChainSlug.SYNDR_SEPOLIA_L3, + ChainSlug.KINTO, + ChainSlug.KINTO_DEVNET, + ChainSlug.WINR, + ChainSlug.SYNDR, +]; diff --git a/src/chain-enums/chainId.ts b/src/chain-enums/chainId.ts new file mode 100644 index 00000000..4c7cf31c --- /dev/null +++ b/src/chain-enums/chainId.ts @@ -0,0 +1,60 @@ +export enum ChainId { + ARBITRUM = 42161, + ARBITRUM_GOERLI = 421613, + ARBITRUM_SEPOLIA = 421614, + OPTIMISM = 10, + OPTIMISM_GOERLI = 420, + OPTIMISM_SEPOLIA = 11155420, + BSC = 56, + MAINNET = 1, + GOERLI = 5, + SEPOLIA = 11155111, + POLYGON_MAINNET = 137, + AEVO_TESTNET = 11155112, + AEVO = 2999, + HARDHAT = 31337, + LYRA_TESTNET = 901, + LYRA = 957, + XAI_TESTNET = 47279324479, + CDK_TESTNET = 686669576, + SX_NETWORK_TESTNET = 647, + SX_NETWORK = 416, + MODE_TESTNET = 919, + VICTION_TESTNET = 89, + BASE = 8453, + BASE_SEPOLIA = 84532, + MODE = 34443, + ANCIENT8_TESTNET = 2863311531, + ANCIENT8_TESTNET2 = 28122024, + PARALLEL = 1024, + MANTLE = 5000, + REYA_CRONOS = 89346162, + REYA = 1729, + SYNDR_SEPOLIA_L3 = 444444, + POLYNOMIAL_TESTNET = 80008, + BOB = 60808, + KINTO = 7887, + KINTO_DEVNET = 412346, + SIPHER_FUNKI_TESTNET = 3397901, + WINR = 777777, + BLAST = 81457, + BSC_TESTNET = 97, + POLYNOMIAL = 8008, + SYNDR = 404, + NEOX_TESTNET = 12227331, + NEOX_T4_TESTNET = 12227332, + NEOX = 47763, + GNOSIS = 100, + LINEA = 59144, + ZKEVM = 1101, + AVALANCHE = 43114, + XLAYER = 196, + MANTA_PACIFIC = 169, + POLTER_TESTNET = 631571, + POLYGON_AMOY = 80002, + OPBNB = 204, + GEIST = 63157, + ZERO_SEPOLIA = 4457845, + INTEROP_ALPHA_0 = 420120000, + INTEROP_ALPHA_1 = 420120001, +} diff --git a/src/chain-enums/chainSlug.ts b/src/chain-enums/chainSlug.ts new file mode 100644 index 00000000..6dd18494 --- /dev/null +++ b/src/chain-enums/chainSlug.ts @@ -0,0 +1,62 @@ +import { ChainId } from "./chainId"; + +export enum ChainSlug { + ARBITRUM = ChainId.ARBITRUM, + ARBITRUM_GOERLI = ChainId.ARBITRUM_GOERLI, + ARBITRUM_SEPOLIA = ChainId.ARBITRUM_SEPOLIA, + OPTIMISM = ChainId.OPTIMISM, + OPTIMISM_GOERLI = ChainId.OPTIMISM_GOERLI, + OPTIMISM_SEPOLIA = ChainId.OPTIMISM_SEPOLIA, + BSC = ChainId.BSC, + MAINNET = ChainId.MAINNET, + GOERLI = ChainId.GOERLI, + SEPOLIA = ChainId.SEPOLIA, + POLYGON_MAINNET = ChainId.POLYGON_MAINNET, + AEVO_TESTNET = ChainId.AEVO_TESTNET, + AEVO = ChainId.AEVO, + HARDHAT = ChainId.HARDHAT, + LYRA_TESTNET = ChainId.LYRA_TESTNET, + LYRA = ChainId.LYRA, + XAI_TESTNET = 1399904803, + SX_NETWORK_TESTNET = ChainId.SX_NETWORK_TESTNET, + SX_NETWORK = ChainId.SX_NETWORK, + MODE_TESTNET = ChainId.MODE_TESTNET, + VICTION_TESTNET = ChainId.VICTION_TESTNET, + CDK_TESTNET = ChainId.CDK_TESTNET, + BASE = ChainId.BASE, + BASE_SEPOLIA = ChainId.BASE_SEPOLIA, + MODE = ChainId.MODE, + ANCIENT8_TESTNET = ChainId.ANCIENT8_TESTNET, + ANCIENT8_TESTNET2 = ChainId.ANCIENT8_TESTNET2, + PARALLEL = ChainId.PARALLEL, + MANTLE = ChainId.MANTLE, + REYA_CRONOS = ChainId.REYA_CRONOS, + REYA = 1324967486, + SYNDR_SEPOLIA_L3 = ChainId.SYNDR_SEPOLIA_L3, + POLYNOMIAL_TESTNET = ChainId.POLYNOMIAL_TESTNET, + BOB = ChainId.BOB, + KINTO = ChainId.KINTO, + KINTO_DEVNET = ChainId.KINTO_DEVNET, + SIPHER_FUNKI_TESTNET = ChainId.SIPHER_FUNKI_TESTNET, + WINR = ChainId.WINR, + BLAST = ChainId.BLAST, + BSC_TESTNET = ChainId.BSC_TESTNET, + POLYNOMIAL = ChainId.POLYNOMIAL, + SYNDR = ChainId.SYNDR, + NEOX_TESTNET = ChainId.NEOX_TESTNET, + NEOX_T4_TESTNET = ChainId.NEOX_T4_TESTNET, + NEOX = ChainId.NEOX, + GNOSIS = ChainId.GNOSIS, + LINEA = ChainId.LINEA, + ZKEVM = ChainId.ZKEVM, + AVALANCHE = ChainId.AVALANCHE, + XLAYER = ChainId.XLAYER, + MANTA_PACIFIC = ChainId.MANTA_PACIFIC, + POLTER_TESTNET = ChainId.POLTER_TESTNET, + POLYGON_AMOY = ChainId.POLYGON_AMOY, + OPBNB = ChainId.OPBNB, + GEIST = ChainId.GEIST, + ZERO_SEPOLIA = ChainId.ZERO_SEPOLIA, + INTEROP_ALPHA_0 = ChainId.INTEROP_ALPHA_0, + INTEROP_ALPHA_1 = ChainId.INTEROP_ALPHA_1, +} diff --git a/src/chain-enums/chainSlugToHardhatChainName.ts b/src/chain-enums/chainSlugToHardhatChainName.ts new file mode 100644 index 00000000..02b6b0ae --- /dev/null +++ b/src/chain-enums/chainSlugToHardhatChainName.ts @@ -0,0 +1,63 @@ +import { ChainSlug } from "./chainSlug"; +import { HardhatChainName } from "./hardhatChainName"; + +export const chainSlugToHardhatChainName = { + [ChainSlug.ARBITRUM]: HardhatChainName.ARBITRUM, + [ChainSlug.ARBITRUM_GOERLI]: HardhatChainName.ARBITRUM_GOERLI, + [ChainSlug.ARBITRUM_SEPOLIA]: HardhatChainName.ARBITRUM_SEPOLIA, + [ChainSlug.OPTIMISM]: HardhatChainName.OPTIMISM, + [ChainSlug.OPTIMISM_GOERLI]: HardhatChainName.OPTIMISM_GOERLI, + [ChainSlug.OPTIMISM_SEPOLIA]: HardhatChainName.OPTIMISM_SEPOLIA, + [ChainSlug.BSC]: HardhatChainName.BSC, + [ChainSlug.MAINNET]: HardhatChainName.MAINNET, + [ChainSlug.GOERLI]: HardhatChainName.GOERLI, + [ChainSlug.SEPOLIA]: HardhatChainName.SEPOLIA, + [ChainSlug.POLYGON_MAINNET]: HardhatChainName.POLYGON_MAINNET, + [ChainSlug.AEVO_TESTNET]: HardhatChainName.AEVO_TESTNET, + [ChainSlug.AEVO]: HardhatChainName.AEVO, + [ChainSlug.HARDHAT]: HardhatChainName.HARDHAT, + [ChainSlug.LYRA_TESTNET]: HardhatChainName.LYRA_TESTNET, + [ChainSlug.LYRA]: HardhatChainName.LYRA, + [ChainSlug.XAI_TESTNET]: HardhatChainName.XAI_TESTNET, + [ChainSlug.SX_NETWORK_TESTNET]: HardhatChainName.SX_NETWORK_TESTNET, + [ChainSlug.SX_NETWORK]: HardhatChainName.SX_NETWORK, + [ChainSlug.MODE_TESTNET]: HardhatChainName.MODE_TESTNET, + [ChainSlug.VICTION_TESTNET]: HardhatChainName.VICTION_TESTNET, + [ChainSlug.CDK_TESTNET]: HardhatChainName.CDK_TESTNET, + [ChainSlug.BASE]: HardhatChainName.BASE, + [ChainSlug.BASE_SEPOLIA]: HardhatChainName.BASE_SEPOLIA, + [ChainSlug.MODE]: HardhatChainName.MODE, + [ChainSlug.ANCIENT8_TESTNET]: HardhatChainName.ANCIENT8_TESTNET, + [ChainSlug.ANCIENT8_TESTNET2]: HardhatChainName.ANCIENT8_TESTNET2, + [ChainSlug.PARALLEL]: HardhatChainName.PARALLEL, + [ChainSlug.MANTLE]: HardhatChainName.MANTLE, + [ChainSlug.REYA_CRONOS]: HardhatChainName.REYA_CRONOS, + [ChainSlug.REYA]: HardhatChainName.REYA, + [ChainSlug.SYNDR_SEPOLIA_L3]: HardhatChainName.SYNDR_SEPOLIA_L3, + [ChainSlug.POLYNOMIAL_TESTNET]: HardhatChainName.POLYNOMIAL_TESTNET, + [ChainSlug.BOB]: HardhatChainName.BOB, + [ChainSlug.KINTO]: HardhatChainName.KINTO, + [ChainSlug.KINTO_DEVNET]: HardhatChainName.KINTO_DEVNET, + [ChainSlug.SIPHER_FUNKI_TESTNET]: HardhatChainName.SIPHER_FUNKI_TESTNET, + [ChainSlug.WINR]: HardhatChainName.WINR, + [ChainSlug.BLAST]: HardhatChainName.BLAST, + [ChainSlug.BSC_TESTNET]: HardhatChainName.BSC_TESTNET, + [ChainSlug.POLYNOMIAL]: HardhatChainName.POLYNOMIAL, + [ChainSlug.SYNDR]: HardhatChainName.SYNDR, + [ChainSlug.NEOX_TESTNET]: HardhatChainName.NEOX_TESTNET, + [ChainSlug.NEOX_T4_TESTNET]: HardhatChainName.NEOX_T4_TESTNET, + [ChainSlug.NEOX]: HardhatChainName.NEOX, + [ChainSlug.GNOSIS]: HardhatChainName.GNOSIS, + [ChainSlug.LINEA]: HardhatChainName.LINEA, + [ChainSlug.ZKEVM]: HardhatChainName.ZKEVM, + [ChainSlug.AVALANCHE]: HardhatChainName.AVALANCHE, + [ChainSlug.XLAYER]: HardhatChainName.XLAYER, + [ChainSlug.MANTA_PACIFIC]: HardhatChainName.MANTA_PACIFIC, + [ChainSlug.POLTER_TESTNET]: HardhatChainName.POLTER_TESTNET, + [ChainSlug.POLYGON_AMOY]: HardhatChainName.POLYGON_AMOY, + [ChainSlug.OPBNB]: HardhatChainName.OPBNB, + [ChainSlug.GEIST]: HardhatChainName.GEIST, + [ChainSlug.ZERO_SEPOLIA]: HardhatChainName.ZERO_SEPOLIA, + [ChainSlug.INTEROP_ALPHA_0]: HardhatChainName.INTEROP_ALPHA_0, + [ChainSlug.INTEROP_ALPHA_1]: HardhatChainName.INTEROP_ALPHA_1, +}; diff --git a/src/chain-enums/chainSlugToId.ts b/src/chain-enums/chainSlugToId.ts new file mode 100644 index 00000000..07b27268 --- /dev/null +++ b/src/chain-enums/chainSlugToId.ts @@ -0,0 +1,63 @@ +import { ChainId } from "./chainId"; +import { ChainSlug } from "./chainSlug"; + +export const ChainSlugToId = { + [ChainSlug.ARBITRUM]: ChainId.ARBITRUM, + [ChainSlug.ARBITRUM_GOERLI]: ChainId.ARBITRUM_GOERLI, + [ChainSlug.ARBITRUM_SEPOLIA]: ChainId.ARBITRUM_SEPOLIA, + [ChainSlug.OPTIMISM]: ChainId.OPTIMISM, + [ChainSlug.OPTIMISM_GOERLI]: ChainId.OPTIMISM_GOERLI, + [ChainSlug.OPTIMISM_SEPOLIA]: ChainId.OPTIMISM_SEPOLIA, + [ChainSlug.BSC]: ChainId.BSC, + [ChainSlug.MAINNET]: ChainId.MAINNET, + [ChainSlug.GOERLI]: ChainId.GOERLI, + [ChainSlug.SEPOLIA]: ChainId.SEPOLIA, + [ChainSlug.POLYGON_MAINNET]: ChainId.POLYGON_MAINNET, + [ChainSlug.AEVO_TESTNET]: ChainId.AEVO_TESTNET, + [ChainSlug.AEVO]: ChainId.AEVO, + [ChainSlug.HARDHAT]: ChainId.HARDHAT, + [ChainSlug.LYRA_TESTNET]: ChainId.LYRA_TESTNET, + [ChainSlug.LYRA]: ChainId.LYRA, + [ChainSlug.XAI_TESTNET]: ChainId.XAI_TESTNET, + [ChainSlug.SX_NETWORK_TESTNET]: ChainId.SX_NETWORK_TESTNET, + [ChainSlug.SX_NETWORK]: ChainId.SX_NETWORK, + [ChainSlug.MODE_TESTNET]: ChainId.MODE_TESTNET, + [ChainSlug.VICTION_TESTNET]: ChainId.VICTION_TESTNET, + [ChainSlug.CDK_TESTNET]: ChainId.CDK_TESTNET, + [ChainSlug.BASE]: ChainId.BASE, + [ChainSlug.BASE_SEPOLIA]: ChainId.BASE_SEPOLIA, + [ChainSlug.MODE]: ChainId.MODE, + [ChainSlug.ANCIENT8_TESTNET]: ChainId.ANCIENT8_TESTNET, + [ChainSlug.ANCIENT8_TESTNET2]: ChainId.ANCIENT8_TESTNET2, + [ChainSlug.PARALLEL]: ChainId.PARALLEL, + [ChainSlug.MANTLE]: ChainId.MANTLE, + [ChainSlug.REYA_CRONOS]: ChainId.REYA_CRONOS, + [ChainSlug.REYA]: ChainId.REYA, + [ChainSlug.SYNDR_SEPOLIA_L3]: ChainId.SYNDR_SEPOLIA_L3, + [ChainSlug.POLYNOMIAL_TESTNET]: ChainId.POLYNOMIAL_TESTNET, + [ChainSlug.BOB]: ChainId.BOB, + [ChainSlug.KINTO]: ChainId.KINTO, + [ChainSlug.KINTO_DEVNET]: ChainId.KINTO_DEVNET, + [ChainSlug.SIPHER_FUNKI_TESTNET]: ChainId.SIPHER_FUNKI_TESTNET, + [ChainSlug.WINR]: ChainId.WINR, + [ChainSlug.BLAST]: ChainId.BLAST, + [ChainSlug.BSC_TESTNET]: ChainId.BSC_TESTNET, + [ChainSlug.POLYNOMIAL]: ChainId.POLYNOMIAL, + [ChainSlug.SYNDR]: ChainId.SYNDR, + [ChainSlug.NEOX_TESTNET]: ChainId.NEOX_TESTNET, + [ChainSlug.NEOX_T4_TESTNET]: ChainId.NEOX_T4_TESTNET, + [ChainSlug.NEOX]: ChainId.NEOX, + [ChainSlug.GNOSIS]: ChainId.GNOSIS, + [ChainSlug.LINEA]: ChainId.LINEA, + [ChainSlug.ZKEVM]: ChainId.ZKEVM, + [ChainSlug.AVALANCHE]: ChainId.AVALANCHE, + [ChainSlug.XLAYER]: ChainId.XLAYER, + [ChainSlug.MANTA_PACIFIC]: ChainId.MANTA_PACIFIC, + [ChainSlug.POLTER_TESTNET]: ChainId.POLTER_TESTNET, + [ChainSlug.POLYGON_AMOY]: ChainId.POLYGON_AMOY, + [ChainSlug.OPBNB]: ChainId.OPBNB, + [ChainSlug.GEIST]: ChainId.GEIST, + [ChainSlug.ZERO_SEPOLIA]: ChainId.ZERO_SEPOLIA, + [ChainSlug.INTEROP_ALPHA_0]: ChainId.INTEROP_ALPHA_0, + [ChainSlug.INTEROP_ALPHA_1]: ChainId.INTEROP_ALPHA_1, +}; diff --git a/src/chain-enums/chainSlugToKey.ts b/src/chain-enums/chainSlugToKey.ts new file mode 100644 index 00000000..43c601a4 --- /dev/null +++ b/src/chain-enums/chainSlugToKey.ts @@ -0,0 +1,63 @@ +import { ChainSlug } from "./chainSlug"; +import { HardhatChainName } from "./hardhatChainName"; + +export const ChainSlugToKey = { + [ChainSlug.ARBITRUM]: HardhatChainName.ARBITRUM, + [ChainSlug.ARBITRUM_GOERLI]: HardhatChainName.ARBITRUM_GOERLI, + [ChainSlug.ARBITRUM_SEPOLIA]: HardhatChainName.ARBITRUM_SEPOLIA, + [ChainSlug.OPTIMISM]: HardhatChainName.OPTIMISM, + [ChainSlug.OPTIMISM_GOERLI]: HardhatChainName.OPTIMISM_GOERLI, + [ChainSlug.OPTIMISM_SEPOLIA]: HardhatChainName.OPTIMISM_SEPOLIA, + [ChainSlug.BSC]: HardhatChainName.BSC, + [ChainSlug.MAINNET]: HardhatChainName.MAINNET, + [ChainSlug.GOERLI]: HardhatChainName.GOERLI, + [ChainSlug.SEPOLIA]: HardhatChainName.SEPOLIA, + [ChainSlug.POLYGON_MAINNET]: HardhatChainName.POLYGON_MAINNET, + [ChainSlug.AEVO_TESTNET]: HardhatChainName.AEVO_TESTNET, + [ChainSlug.AEVO]: HardhatChainName.AEVO, + [ChainSlug.HARDHAT]: HardhatChainName.HARDHAT, + [ChainSlug.LYRA_TESTNET]: HardhatChainName.LYRA_TESTNET, + [ChainSlug.LYRA]: HardhatChainName.LYRA, + [ChainSlug.XAI_TESTNET]: HardhatChainName.XAI_TESTNET, + [ChainSlug.SX_NETWORK_TESTNET]: HardhatChainName.SX_NETWORK_TESTNET, + [ChainSlug.SX_NETWORK]: HardhatChainName.SX_NETWORK, + [ChainSlug.MODE_TESTNET]: HardhatChainName.MODE_TESTNET, + [ChainSlug.VICTION_TESTNET]: HardhatChainName.VICTION_TESTNET, + [ChainSlug.CDK_TESTNET]: HardhatChainName.CDK_TESTNET, + [ChainSlug.BASE]: HardhatChainName.BASE, + [ChainSlug.BASE_SEPOLIA]: HardhatChainName.BASE_SEPOLIA, + [ChainSlug.MODE]: HardhatChainName.MODE, + [ChainSlug.ANCIENT8_TESTNET]: HardhatChainName.ANCIENT8_TESTNET, + [ChainSlug.ANCIENT8_TESTNET2]: HardhatChainName.ANCIENT8_TESTNET2, + [ChainSlug.PARALLEL]: HardhatChainName.PARALLEL, + [ChainSlug.MANTLE]: HardhatChainName.MANTLE, + [ChainSlug.REYA_CRONOS]: HardhatChainName.REYA_CRONOS, + [ChainSlug.REYA]: HardhatChainName.REYA, + [ChainSlug.SYNDR_SEPOLIA_L3]: HardhatChainName.SYNDR_SEPOLIA_L3, + [ChainSlug.POLYNOMIAL_TESTNET]: HardhatChainName.POLYNOMIAL_TESTNET, + [ChainSlug.BOB]: HardhatChainName.BOB, + [ChainSlug.KINTO]: HardhatChainName.KINTO, + [ChainSlug.KINTO_DEVNET]: HardhatChainName.KINTO_DEVNET, + [ChainSlug.SIPHER_FUNKI_TESTNET]: HardhatChainName.SIPHER_FUNKI_TESTNET, + [ChainSlug.WINR]: HardhatChainName.WINR, + [ChainSlug.BLAST]: HardhatChainName.BLAST, + [ChainSlug.BSC_TESTNET]: HardhatChainName.BSC_TESTNET, + [ChainSlug.POLYNOMIAL]: HardhatChainName.POLYNOMIAL, + [ChainSlug.SYNDR]: HardhatChainName.SYNDR, + [ChainSlug.NEOX_TESTNET]: HardhatChainName.NEOX_TESTNET, + [ChainSlug.NEOX_T4_TESTNET]: HardhatChainName.NEOX_T4_TESTNET, + [ChainSlug.NEOX]: HardhatChainName.NEOX, + [ChainSlug.GNOSIS]: HardhatChainName.GNOSIS, + [ChainSlug.LINEA]: HardhatChainName.LINEA, + [ChainSlug.ZKEVM]: HardhatChainName.ZKEVM, + [ChainSlug.AVALANCHE]: HardhatChainName.AVALANCHE, + [ChainSlug.XLAYER]: HardhatChainName.XLAYER, + [ChainSlug.MANTA_PACIFIC]: HardhatChainName.MANTA_PACIFIC, + [ChainSlug.POLTER_TESTNET]: HardhatChainName.POLTER_TESTNET, + [ChainSlug.POLYGON_AMOY]: HardhatChainName.POLYGON_AMOY, + [ChainSlug.OPBNB]: HardhatChainName.OPBNB, + [ChainSlug.GEIST]: HardhatChainName.GEIST, + [ChainSlug.ZERO_SEPOLIA]: HardhatChainName.ZERO_SEPOLIA, + [ChainSlug.INTEROP_ALPHA_0]: HardhatChainName.INTEROP_ALPHA_0, + [ChainSlug.INTEROP_ALPHA_1]: HardhatChainName.INTEROP_ALPHA_1, +}; diff --git a/src/chain-enums/currency.ts b/src/chain-enums/currency.ts new file mode 100644 index 00000000..1f9448db --- /dev/null +++ b/src/chain-enums/currency.ts @@ -0,0 +1,22 @@ +import { ChainSlug } from "./chainSlug"; +import { NativeTokens } from "./native-tokens"; + +export const Currency = { + [ChainSlug.BSC]: NativeTokens.binancecoin, + [ChainSlug.POLYGON_MAINNET]: NativeTokens["matic-network"], + [ChainSlug.SX_NETWORK_TESTNET]: NativeTokens["sx-network-2"], + [ChainSlug.SX_NETWORK]: NativeTokens["sx-network-2"], + [ChainSlug.MANTLE]: NativeTokens.mantle, + [ChainSlug.BSC_TESTNET]: NativeTokens["binancecoin"], + [ChainSlug.WINR]: NativeTokens["winr"], + [ChainSlug.NEOX_TESTNET]: NativeTokens["gas"], + [ChainSlug.NEOX_T4_TESTNET]: NativeTokens["gas"], + [ChainSlug.NEOX]: NativeTokens["gas"], + [ChainSlug.GNOSIS]: NativeTokens["dai"], + [ChainSlug.AVALANCHE]: NativeTokens["avalanche-2"], + [ChainSlug.XLAYER]: NativeTokens["okb"], + [ChainSlug.POLTER_TESTNET]: NativeTokens["aavegotchi"], + [ChainSlug.POLYGON_AMOY]: NativeTokens["matic-network"], + [ChainSlug.OPBNB]: NativeTokens["binancecoin"], + [ChainSlug.GEIST]: NativeTokens["aavegotchi"], +}; diff --git a/src/chain-enums/ethLikeChains.ts b/src/chain-enums/ethLikeChains.ts new file mode 100644 index 00000000..dde62f66 --- /dev/null +++ b/src/chain-enums/ethLikeChains.ts @@ -0,0 +1,29 @@ +import { ChainSlug } from "./chainSlug"; + +// chains having constant gas limits +export const ethLikeChains = [ + ChainSlug.MAINNET, + ChainSlug.BSC, + ChainSlug.POLYGON_MAINNET, + ChainSlug.SEPOLIA, + ChainSlug.SX_NETWORK, + ChainSlug.SX_NETWORK_TESTNET, + ChainSlug.ANCIENT8_TESTNET, + ChainSlug.ANCIENT8_TESTNET2, + ChainSlug.REYA_CRONOS, + ChainSlug.REYA, + ChainSlug.GOERLI, + ChainSlug.VICTION_TESTNET, + ChainSlug.SYNDR_SEPOLIA_L3, + ChainSlug.BSC_TESTNET, + ChainSlug.NEOX_TESTNET, + ChainSlug.NEOX_T4_TESTNET, + ChainSlug.NEOX, + ChainSlug.GNOSIS, + ChainSlug.LINEA, + ChainSlug.ZKEVM, + ChainSlug.AVALANCHE, + ChainSlug.POLYGON_AMOY, + ChainSlug.INTEROP_ALPHA_0, + ChainSlug.INTEROP_ALPHA_1, +]; diff --git a/src/chain-enums/hardhatChainName.ts b/src/chain-enums/hardhatChainName.ts new file mode 100644 index 00000000..c74be92e --- /dev/null +++ b/src/chain-enums/hardhatChainName.ts @@ -0,0 +1,60 @@ +export enum HardhatChainName { + ARBITRUM = "arbitrum", + ARBITRUM_GOERLI = "arbitrum_goerli", + ARBITRUM_SEPOLIA = "arbitrum_sepolia", + OPTIMISM = "optimism", + OPTIMISM_GOERLI = "optimism_goerli", + OPTIMISM_SEPOLIA = "optimism_sepolia", + BSC = "bsc", + MAINNET = "mainnet", + GOERLI = "goerli", + SEPOLIA = "sepolia", + POLYGON_MAINNET = "polygon_mainnet", + AEVO_TESTNET = "aevo_testnet", + AEVO = "aevo", + LYRA_TESTNET = "lyra_testnet", + LYRA = "lyra", + XAI_TESTNET = "xai_testnet", + SX_NETWORK_TESTNET = "sxn_testnet", + SX_NETWORK = "sxn", + MODE_TESTNET = "mode_testnet", + VICTION_TESTNET = "viction_testnet", + CDK_TESTNET = "cdk_testnet", + HARDHAT = "hardhat", + BASE = "base", + BASE_SEPOLIA = "base_sepolia", + MODE = "mode", + ANCIENT8_TESTNET = "ancient8_testnet", + ANCIENT8_TESTNET2 = "ancient8_testnet2", + PARALLEL = "parallel", + MANTLE = "mantle", + REYA_CRONOS = "reya_cronos", + REYA = "reya", + SYNDR_SEPOLIA_L3 = "syndr_sepolia_l3", + POLYNOMIAL_TESTNET = "polynomial_testnet", + BOB = "bob", + KINTO = "kinto", + KINTO_DEVNET = "kinto_devnet", + SIPHER_FUNKI_TESTNET = "sipher_funki_testnet", + WINR = "winr", + BLAST = "blast", + BSC_TESTNET = "bsc_testnet", + POLYNOMIAL = "polynomial", + SYNDR = "syndr", + NEOX_TESTNET = "neox_testnet", + NEOX_T4_TESTNET = "neox_t4_testnet", + NEOX = "neox", + GNOSIS = "gnosis", + LINEA = "linea", + ZKEVM = "zkevm", + AVALANCHE = "avalanche", + XLAYER = "xlayer", + MANTA_PACIFIC = "manta_pacific", + POLTER_TESTNET = "polter_testnet", + POLYGON_AMOY = "polygon_amoy", + OPBNB = "opbnb", + GEIST = "geist", + ZERO_SEPOLIA = "zero_sepolia", + INTEROP_ALPHA_0 = "interop_alpha_0", + INTEROP_ALPHA_1 = "interop_alpha_1", +} diff --git a/src/chain-enums/hardhatChainNameToSlug.ts b/src/chain-enums/hardhatChainNameToSlug.ts new file mode 100644 index 00000000..110b45c9 --- /dev/null +++ b/src/chain-enums/hardhatChainNameToSlug.ts @@ -0,0 +1,63 @@ +import { ChainSlug } from "./chainSlug"; +import { HardhatChainName } from "./hardhatChainName"; + +export const hardhatChainNameToSlug = { + [HardhatChainName.ARBITRUM]: ChainSlug.ARBITRUM, + [HardhatChainName.ARBITRUM_GOERLI]: ChainSlug.ARBITRUM_GOERLI, + [HardhatChainName.ARBITRUM_SEPOLIA]: ChainSlug.ARBITRUM_SEPOLIA, + [HardhatChainName.OPTIMISM]: ChainSlug.OPTIMISM, + [HardhatChainName.OPTIMISM_GOERLI]: ChainSlug.OPTIMISM_GOERLI, + [HardhatChainName.OPTIMISM_SEPOLIA]: ChainSlug.OPTIMISM_SEPOLIA, + [HardhatChainName.BSC]: ChainSlug.BSC, + [HardhatChainName.MAINNET]: ChainSlug.MAINNET, + [HardhatChainName.GOERLI]: ChainSlug.GOERLI, + [HardhatChainName.SEPOLIA]: ChainSlug.SEPOLIA, + [HardhatChainName.POLYGON_MAINNET]: ChainSlug.POLYGON_MAINNET, + [HardhatChainName.AEVO_TESTNET]: ChainSlug.AEVO_TESTNET, + [HardhatChainName.AEVO]: ChainSlug.AEVO, + [HardhatChainName.HARDHAT]: ChainSlug.HARDHAT, + [HardhatChainName.LYRA_TESTNET]: ChainSlug.LYRA_TESTNET, + [HardhatChainName.LYRA]: ChainSlug.LYRA, + [HardhatChainName.XAI_TESTNET]: ChainSlug.XAI_TESTNET, + [HardhatChainName.SX_NETWORK_TESTNET]: ChainSlug.SX_NETWORK_TESTNET, + [HardhatChainName.SX_NETWORK]: ChainSlug.SX_NETWORK, + [HardhatChainName.MODE_TESTNET]: ChainSlug.MODE_TESTNET, + [HardhatChainName.VICTION_TESTNET]: ChainSlug.VICTION_TESTNET, + [HardhatChainName.CDK_TESTNET]: ChainSlug.CDK_TESTNET, + [HardhatChainName.BASE]: ChainSlug.BASE, + [HardhatChainName.BASE_SEPOLIA]: ChainSlug.BASE_SEPOLIA, + [HardhatChainName.MODE]: ChainSlug.MODE, + [HardhatChainName.ANCIENT8_TESTNET]: ChainSlug.ANCIENT8_TESTNET, + [HardhatChainName.ANCIENT8_TESTNET2]: ChainSlug.ANCIENT8_TESTNET2, + [HardhatChainName.PARALLEL]: ChainSlug.PARALLEL, + [HardhatChainName.MANTLE]: ChainSlug.MANTLE, + [HardhatChainName.REYA_CRONOS]: ChainSlug.REYA_CRONOS, + [HardhatChainName.REYA]: ChainSlug.REYA, + [HardhatChainName.SYNDR_SEPOLIA_L3]: ChainSlug.SYNDR_SEPOLIA_L3, + [HardhatChainName.POLYNOMIAL_TESTNET]: ChainSlug.POLYNOMIAL_TESTNET, + [HardhatChainName.BOB]: ChainSlug.BOB, + [HardhatChainName.KINTO]: ChainSlug.KINTO, + [HardhatChainName.KINTO_DEVNET]: ChainSlug.KINTO_DEVNET, + [HardhatChainName.SIPHER_FUNKI_TESTNET]: ChainSlug.SIPHER_FUNKI_TESTNET, + [HardhatChainName.WINR]: ChainSlug.WINR, + [HardhatChainName.BLAST]: ChainSlug.BLAST, + [HardhatChainName.BSC_TESTNET]: ChainSlug.BSC_TESTNET, + [HardhatChainName.POLYNOMIAL]: ChainSlug.POLYNOMIAL, + [HardhatChainName.SYNDR]: ChainSlug.SYNDR, + [HardhatChainName.NEOX_TESTNET]: ChainSlug.NEOX_TESTNET, + [HardhatChainName.NEOX_T4_TESTNET]: ChainSlug.NEOX_T4_TESTNET, + [HardhatChainName.NEOX]: ChainSlug.NEOX, + [HardhatChainName.GNOSIS]: ChainSlug.GNOSIS, + [HardhatChainName.LINEA]: ChainSlug.LINEA, + [HardhatChainName.ZKEVM]: ChainSlug.ZKEVM, + [HardhatChainName.AVALANCHE]: ChainSlug.AVALANCHE, + [HardhatChainName.XLAYER]: ChainSlug.XLAYER, + [HardhatChainName.MANTA_PACIFIC]: ChainSlug.MANTA_PACIFIC, + [HardhatChainName.POLTER_TESTNET]: ChainSlug.POLTER_TESTNET, + [HardhatChainName.POLYGON_AMOY]: ChainSlug.POLYGON_AMOY, + [HardhatChainName.OPBNB]: ChainSlug.OPBNB, + [HardhatChainName.GEIST]: ChainSlug.GEIST, + [HardhatChainName.ZERO_SEPOLIA]: ChainSlug.ZERO_SEPOLIA, + [HardhatChainName.INTEROP_ALPHA_0]: ChainSlug.INTEROP_ALPHA_0, + [HardhatChainName.INTEROP_ALPHA_1]: ChainSlug.INTEROP_ALPHA_1, +}; diff --git a/src/chain-enums/index.ts b/src/chain-enums/index.ts new file mode 100644 index 00000000..417392a0 --- /dev/null +++ b/src/chain-enums/index.ts @@ -0,0 +1,17 @@ +export * from "./arbChains"; +export * from "./arbL3Chains"; +export * from "./chainId"; +export * from "./chainSlug"; +export * from "./chainSlugToHardhatChainName"; +export * from "./chainSlugToId"; +export * from "./chainSlugToKey"; +export * from "./currency"; +export * from "./ethLikeChains"; +export * from "./hardhatChainName"; +export * from "./hardhatChainNameToSlug"; +export * from "./mainnetIds"; +export * from "./native-tokens"; +export * from "./opStackChains"; +export * from "./polygonCDKChains"; +export * from "./testnetIds"; +export * from "./zkStackChain"; diff --git a/src/chain-enums/mainnetIds.ts b/src/chain-enums/mainnetIds.ts new file mode 100644 index 00000000..eaaeced7 --- /dev/null +++ b/src/chain-enums/mainnetIds.ts @@ -0,0 +1,32 @@ +import { ChainSlug } from "./chainSlug"; + +export const MainnetIds: ChainSlug[] = [ + ChainSlug.MAINNET, + ChainSlug.POLYGON_MAINNET, + ChainSlug.ARBITRUM, + ChainSlug.OPTIMISM, + ChainSlug.BSC, + ChainSlug.AEVO, + ChainSlug.LYRA, + ChainSlug.BASE, + ChainSlug.MODE, + ChainSlug.PARALLEL, + ChainSlug.MANTLE, + ChainSlug.REYA, + ChainSlug.SX_NETWORK, + ChainSlug.BOB, + ChainSlug.KINTO, + ChainSlug.WINR, + ChainSlug.BLAST, + ChainSlug.POLYNOMIAL, + ChainSlug.SYNDR, + ChainSlug.NEOX, + ChainSlug.GNOSIS, + ChainSlug.LINEA, + ChainSlug.ZKEVM, + ChainSlug.AVALANCHE, + ChainSlug.XLAYER, + ChainSlug.MANTA_PACIFIC, + ChainSlug.OPBNB, + ChainSlug.GEIST, +]; diff --git a/src/chain-enums/native-tokens.ts b/src/chain-enums/native-tokens.ts new file mode 100644 index 00000000..1e70d1bf --- /dev/null +++ b/src/chain-enums/native-tokens.ts @@ -0,0 +1,15 @@ +// add coingecko token id here +export enum NativeTokens { + "ethereum" = "ethereum", + "matic-network" = "matic-network", + "binancecoin" = "binancecoin", + "sx-network-2" = "sx-network-2", + "mantle" = "mantle", + "winr" = "winr-protocol", + "no-token" = "no-token", + "gas" = "gas", + "dai" = "dai", + "avalanche-2" = "avalanche-2", + "okb" = "okb", + "aavegotchi" = "aavegotchi", +} diff --git a/src/chain-enums/opStackChains.ts b/src/chain-enums/opStackChains.ts new file mode 100644 index 00000000..d1e6aa3e --- /dev/null +++ b/src/chain-enums/opStackChains.ts @@ -0,0 +1,24 @@ +import { ChainSlug } from "./chainSlug"; + +export const opStackL2Chain = [ + ChainSlug.AEVO, + ChainSlug.AEVO_TESTNET, + ChainSlug.LYRA, + ChainSlug.MODE_TESTNET, + ChainSlug.LYRA_TESTNET, + ChainSlug.MODE, + ChainSlug.OPTIMISM, + ChainSlug.OPTIMISM_SEPOLIA, + ChainSlug.OPTIMISM_GOERLI, + ChainSlug.BASE, + ChainSlug.BASE_SEPOLIA, + ChainSlug.MANTLE, + ChainSlug.POLYNOMIAL_TESTNET, + ChainSlug.BOB, + ChainSlug.SIPHER_FUNKI_TESTNET, + ChainSlug.BLAST, + ChainSlug.POLYNOMIAL, + ChainSlug.MANTA_PACIFIC, + ChainSlug.POLTER_TESTNET, + ChainSlug.OPBNB, +]; diff --git a/src/chain-enums/polygonCDKChains.ts b/src/chain-enums/polygonCDKChains.ts new file mode 100644 index 00000000..4a29a7ab --- /dev/null +++ b/src/chain-enums/polygonCDKChains.ts @@ -0,0 +1,10 @@ +import { ChainSlug } from "./chainSlug"; + +export const polygonCDKChains = [ + ChainSlug.CDK_TESTNET, + ChainSlug.ANCIENT8_TESTNET2, + ChainSlug.SX_NETWORK_TESTNET, + ChainSlug.SX_NETWORK, + ChainSlug.XAI_TESTNET, + ChainSlug.XLAYER, +]; diff --git a/src/chain-enums/testnetIds.ts b/src/chain-enums/testnetIds.ts new file mode 100644 index 00000000..efe3e6d4 --- /dev/null +++ b/src/chain-enums/testnetIds.ts @@ -0,0 +1,33 @@ +import { ChainSlug } from "./chainSlug"; + +export const TestnetIds: ChainSlug[] = [ + ChainSlug.GOERLI, + ChainSlug.SEPOLIA, + ChainSlug.ARBITRUM_GOERLI, + ChainSlug.ARBITRUM_SEPOLIA, + ChainSlug.OPTIMISM_GOERLI, + ChainSlug.OPTIMISM_SEPOLIA, + ChainSlug.AEVO_TESTNET, + ChainSlug.LYRA_TESTNET, + ChainSlug.XAI_TESTNET, + ChainSlug.SX_NETWORK_TESTNET, + ChainSlug.MODE_TESTNET, + ChainSlug.VICTION_TESTNET, + ChainSlug.CDK_TESTNET, + ChainSlug.ANCIENT8_TESTNET, + ChainSlug.ANCIENT8_TESTNET2, + ChainSlug.REYA_CRONOS, + ChainSlug.SYNDR_SEPOLIA_L3, + ChainSlug.POLYNOMIAL_TESTNET, + ChainSlug.KINTO_DEVNET, + ChainSlug.SIPHER_FUNKI_TESTNET, + ChainSlug.BSC_TESTNET, + ChainSlug.NEOX_TESTNET, + ChainSlug.NEOX_T4_TESTNET, + ChainSlug.POLTER_TESTNET, + ChainSlug.POLYGON_AMOY, + ChainSlug.ZERO_SEPOLIA, + ChainSlug.BASE_SEPOLIA, + ChainSlug.INTEROP_ALPHA_0, + ChainSlug.INTEROP_ALPHA_1, +]; diff --git a/src/chain-enums/zkStackChain.ts b/src/chain-enums/zkStackChain.ts new file mode 100644 index 00000000..70ad4151 --- /dev/null +++ b/src/chain-enums/zkStackChain.ts @@ -0,0 +1,3 @@ +import { ChainSlug } from "./chainSlug"; + +export const zkStackChain = [ChainSlug.ZERO_SEPOLIA]; diff --git a/src/enums.ts b/src/enums.ts new file mode 100644 index 00000000..73a07c83 --- /dev/null +++ b/src/enums.ts @@ -0,0 +1,61 @@ +export enum DeploymentMode { + LOCAL = "local", + DEV = "dev", + PROD = "prod", + STAGE = "stage", +} + +export enum Events { + ExecutionSuccess = "ExecutionSuccess", + ExecutionFailed = "ExecutionFailed", + PlugConnected = "PlugConnected", + CalledAppGateway = "CalledAppGateway", + AppGatewayCallRequested = "AppGatewayCallRequested", + QueryRequested = "QueryRequested", + FinalizeRequested = "FinalizeRequested", + PromiseResolved = "PromiseResolved", + PromiseNotResolved = "PromiseNotResolved", + TimeoutRequested = "TimeoutRequested", + TimeoutResolved = "TimeoutResolved", + AuctionEnded = "AuctionEnded", + AuctionRestarted = "AuctionRestarted", + PayloadSubmitted = "PayloadSubmitted", + PayloadAsyncRequested = "PayloadAsyncRequested", + Finalized = "Finalized", + FeesDeposited = "FeesDeposited", + FeesIncreased = "FeesIncreased", +} + +export enum Contracts { + Socket = "Socket", + FeesPlug = "FeesPlug", + WatcherPrecompile = "WatcherPrecompile", + AuctionManager = "AuctionManager", + DeliveryHelper = "DeliveryHelper", +} + +export enum CallType { + READ, + WRITE, + DEPLOY, + WITHDRAW, +} + +export enum CallTypeNames { + READ = "READ", + WRITE = "WRITE", + DEPLOY = "DEPLOY", + WITHDRAW = "WITHDRAW", +} + +export enum FinalityBucket { + LOW = 1, // low confirmations / latest + MEDIUM = 2, // medium confirmations / data posted + HIGH = 3, // high confirmations / data posted and finalized +} + +export enum FinalityBucketNames { + LOW = "LOW", + MEDIUM = "MEDIUM", + HIGH = "HIGH", +} diff --git a/src/events.ts b/src/events.ts new file mode 100644 index 00000000..7a6e677a --- /dev/null +++ b/src/events.ts @@ -0,0 +1,32 @@ +import { Events } from "./enums"; + +export const socketEvents = [ + Events.ExecutionSuccess, + Events.ExecutionFailed, + Events.PlugConnected, + Events.AppGatewayCallRequested, +]; + +export const feesPlugEvents = [Events.FeesDeposited]; + +export const watcherPrecompileEvents = [ + Events.QueryRequested, + Events.FinalizeRequested, + Events.Finalized, + Events.PromiseResolved, + Events.TimeoutRequested, + Events.TimeoutResolved, + Events.CalledAppGateway, + Events.PromiseNotResolved, +]; + +export const deliveryHelperEvents = [ + Events.PayloadSubmitted, + Events.PayloadAsyncRequested, + Events.FeesIncreased, +]; + +export const auctionManagerEvents = [ + Events.AuctionEnded, + Events.AuctionRestarted, +]; diff --git a/src/finality.ts b/src/finality.ts new file mode 100644 index 00000000..e9693f7b --- /dev/null +++ b/src/finality.ts @@ -0,0 +1,52 @@ +import { ChainSlug } from "./chain-enums"; +import { ChainFinalityBlocks, FinalityBucket } from "./types"; + +export const DEFAULT_FINALITY_BUCKET = FinalityBucket.LOW; + +export const defaultFinalityBlocks: ChainFinalityBlocks = { + [FinalityBucket.LOW]: 1, + [FinalityBucket.MEDIUM]: "safe", + [FinalityBucket.HIGH]: "finalized", +}; + +export const getFinalityBlocks = ( + chainSlug: ChainSlug +): ChainFinalityBlocks => { + return finalityBlockOverrides[chainSlug] ?? defaultFinalityBlocks; +}; + +export const finalityBlockOverrides: { + [chainSlug in ChainSlug]?: ChainFinalityBlocks; +} = { + [ChainSlug.MAINNET]: { + [FinalityBucket.LOW]: 6, + [FinalityBucket.MEDIUM]: "safe", + [FinalityBucket.HIGH]: "finalized", + }, + + [ChainSlug.POLYGON_MAINNET]: { + [FinalityBucket.LOW]: 256, + [FinalityBucket.MEDIUM]: 512, + [FinalityBucket.HIGH]: 1000, + }, + [ChainSlug.NEOX_TESTNET]: { + [FinalityBucket.LOW]: 1, + [FinalityBucket.MEDIUM]: 10, + [FinalityBucket.HIGH]: 100, + }, + [ChainSlug.NEOX_T4_TESTNET]: { + [FinalityBucket.LOW]: 1, + [FinalityBucket.MEDIUM]: 10, + [FinalityBucket.HIGH]: 100, + }, + [ChainSlug.NEOX]: { + [FinalityBucket.LOW]: 1, + [FinalityBucket.MEDIUM]: 10, + [FinalityBucket.HIGH]: 100, + }, + [ChainSlug.LINEA]: { + [FinalityBucket.LOW]: 1, + [FinalityBucket.MEDIUM]: 10, + [FinalityBucket.HIGH]: 100, + }, +}; diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 00000000..24e89c47 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,5 @@ +export * from "./chain-enums"; +export * from "./enums"; +export * from "./events"; +export * from "./finality"; +export * from "./types"; diff --git a/src/types.ts b/src/types.ts new file mode 100644 index 00000000..4fc00cf2 --- /dev/null +++ b/src/types.ts @@ -0,0 +1,53 @@ +import { FinalityBucket } from "./enums"; + +export enum ChainType { + opStackL2Chain = "opStackL2Chain", + arbL3Chain = "arbL3Chain", + arbChain = "arbChain", + polygonCDKChain = "polygonCDKChain", + zkStackChain = "zkStackChain", + default = "default", +} + +export type ChainFinalityBlocks = { + [FinalityBucket.LOW]: number | "safe" | "finalized"; + [FinalityBucket.MEDIUM]: number | "safe" | "finalized"; + [FinalityBucket.HIGH]: number | "safe" | "finalized"; +}; + +export type ChainAddressesObj = { + Socket: string; + SocketBatcher: string; + FastSwitchboard: string; + FeesPlug: string; + ContractFactoryPlug: string; + startBlock: number; +}; + +export type EVMxAddressesObj = { + AddressResolver: string; + WatcherPrecompile: string; + AuctionManager: string; + FeesManager: string; + DeliveryHelper: string; + startBlock: number; +}; + +export type S3Config = { + version: string; + chains: { [chainSlug: number]: ChainConfig }; + supportedChainSlugs: number[]; +}; + +export type ChainConfig = { + eventBlockRangePerCron: number; + rpc: string | undefined; + wssRpc: string | undefined; + confirmations: number; + eventBlockRange: number; + addresses: ChainAddressesObj | EVMxAddressesObj; + finalityBlocks: ChainFinalityBlocks; + chainType: ChainType; +}; + +export { FinalityBucket }; diff --git a/test/DeliveryHelper.t.sol b/test/DeliveryHelper.t.sol index 597c113f..2840aec9 100644 --- a/test/DeliveryHelper.t.sol +++ b/test/DeliveryHelper.t.sol @@ -442,6 +442,8 @@ contract DeliveryHelperTest is SetupTest { target: target_, payload: payload_, callType: callType_, + writeFinality: WriteFinality.LOW, + readAt: 0, executionGasLimit: executionGasLimit_, value: 0, next: next_, @@ -489,7 +491,7 @@ contract DeliveryHelperTest is SetupTest { PayloadDetails memory payloadDetails ) internal view returns (bytes memory, bytes32) { SocketContracts memory socketConfig = getSocketConfig(payloadDetails.chainSlug); - (, , , , , , uint256 deadline, , , ) = watcherPrecompile.asyncRequests(payloadId); + (, , , , , , uint256 deadline, , , , , ) = watcherPrecompile.asyncRequests(payloadId); PayloadDigestParams memory digestParams_ = PayloadDigestParams( payloadDetails.appGateway, diff --git a/test/FeesTest.t.sol b/test/FeesTest.t.sol index 793b4622..437f6f19 100644 --- a/test/FeesTest.t.sol +++ b/test/FeesTest.t.sol @@ -20,10 +20,7 @@ contract FeesTest is DeliveryHelperTest { setUpDeliveryHelper(); feesConfig = getSocketConfig(feesChainSlug); - counterGateway = new CounterAppGateway( - address(addressResolver), - createFees(feesAmount) - ); + counterGateway = new CounterAppGateway(address(addressResolver), createFees(feesAmount)); depositFees(address(counterGateway), createFees(depositAmount)); bytes32[] memory contractIds = new bytes32[](1); diff --git a/test/Inbox.t.sol b/test/Inbox.t.sol index 07bad0a5..d832148a 100644 --- a/test/Inbox.t.sol +++ b/test/Inbox.t.sol @@ -18,10 +18,7 @@ contract InboxTest is DeliveryHelperTest { inbox = new Counter(); // Deploy the gateway with fees - gateway = new CounterAppGateway( - address(addressResolver), - createFees(feesAmount) - ); + gateway = new CounterAppGateway(address(addressResolver), createFees(feesAmount)); gateway.setIsValidPlug(arbChainSlug, address(inbox)); // Connect the inbox to the gateway and socket diff --git a/test/SetupTest.t.sol b/test/SetupTest.t.sol index fa419020..df8f3932 100644 --- a/test/SetupTest.t.sol +++ b/test/SetupTest.t.sol @@ -181,7 +181,7 @@ contract SetupTest is Test { bytes32 transmitterDigest = keccak256(abi.encode(address(socketConfig.socket), payloadId)); bytes memory transmitterSig = _createSignature(transmitterDigest, transmitterPrivateKey); - (, , , , , , uint256 deadline, , , ) = watcherPrecompile.asyncRequests(payloadId); + (, , , , , , uint256 deadline, , , , , ) = watcherPrecompile.asyncRequests(payloadId); vm.startPrank(transmitterEOA); AttestAndExecutePayloadParams memory params = AttestAndExecutePayloadParams({ diff --git a/test/apps/Counter.t.sol b/test/apps/Counter.t.sol index cd029d40..99c760fc 100644 --- a/test/apps/Counter.t.sol +++ b/test/apps/Counter.t.sol @@ -16,10 +16,7 @@ contract CounterTest is DeliveryHelperTest { function deploySetup() internal { setUpDeliveryHelper(); - counterGateway = new CounterAppGateway( - address(addressResolver), - createFees(feesAmount) - ); + counterGateway = new CounterAppGateway(address(addressResolver), createFees(feesAmount)); depositFees(address(counterGateway), createFees(1 ether)); counterId = counterGateway.counter(); diff --git a/test/apps/SuperTokenLockable.t.sol b/test/apps/SuperTokenLockable.t.sol index b1161169..47d4b007 100644 --- a/test/apps/SuperTokenLockable.t.sol +++ b/test/apps/SuperTokenLockable.t.sol @@ -303,7 +303,9 @@ contract SuperTokenLockableTest is DeliveryHelperTest { bridgeAsyncId, bytes32(0), payloadDetails.payload, - payloadDetails.next + payloadDetails.next, + WriteFinality.LOW, + 0 ) ); finalizeQuery(payloadIds[1], abi.encode(srcAmount)); diff --git a/test/apps/app-gateways/counter/Counter.sol b/test/apps/app-gateways/counter/Counter.sol index b4d585ef..9625635d 100644 --- a/test/apps/app-gateways/counter/Counter.sol +++ b/test/apps/app-gateways/counter/Counter.sol @@ -6,9 +6,10 @@ import "../../../../contracts/base/PlugBase.sol"; contract Counter is Ownable, PlugBase { uint256 public counter; - + event CounterIncreased(uint256 value); function increase() external onlySocket { counter++; + emit CounterIncreased(counter); } function getCounter() external view returns (uint256) { diff --git a/test/apps/app-gateways/counter/CounterAppGateway.sol b/test/apps/app-gateways/counter/CounterAppGateway.sol index bb415e70..21824a05 100644 --- a/test/apps/app-gateways/counter/CounterAppGateway.sol +++ b/test/apps/app-gateways/counter/CounterAppGateway.sol @@ -17,10 +17,7 @@ contract CounterAppGateway is AppGatewayBase, Ownable { uint256 optCounter; event TimeoutResolved(uint256 creationTimestamp, uint256 executionTimestamp); - constructor( - address addressResolver_, - Fees memory fees_ - ) AppGatewayBase(addressResolver_) { + constructor(address addressResolver_, Fees memory fees_) AppGatewayBase(addressResolver_) { creationCodeWithArgs[counter] = abi.encodePacked(type(Counter).creationCode); creationCodeWithArgs[counter1] = abi.encodePacked(type(Counter).creationCode); _setOverrides(fees_); @@ -80,6 +77,13 @@ contract CounterAppGateway is AppGatewayBase, Ownable { ICounter(instances_[0]).increase(); } + function readCounterAtBlock(address instance_, uint256 blockNumber_) public async { + uint32 chainSlug = IForwarder(instance_).getChainSlug(); + _setOverrides(Read.ON, Parallel.ON, blockNumber_); + ICounter(instance_).getCounter(); + IPromise(instance_).then(this.setCounterValues.selector, abi.encode(chainSlug)); + } + function setCounterValues(bytes memory data, bytes memory returnData) external onlyPromises { uint256 counterValue = abi.decode(returnData, (uint256)); uint32 chainSlug = abi.decode(data, (uint32)); diff --git a/test/mock/MockWatcherPrecompile.sol b/test/mock/MockWatcherPrecompile.sol index d1886b89..8898deb7 100644 --- a/test/mock/MockWatcherPrecompile.sol +++ b/test/mock/MockWatcherPrecompile.sol @@ -148,7 +148,9 @@ contract MockWatcherPrecompile { params_.asyncId, bytes32(0), bytes(""), - next + next, + params_.payloadDetails.writeFinality, + params_.payloadDetails.readAt ) ); } diff --git a/testScript.sh b/testScript.sh deleted file mode 100644 index c3a1f30c..00000000 --- a/testScript.sh +++ /dev/null @@ -1,61 +0,0 @@ - - -## Parallel Counter -source .env && forge script script/parallel-counter/deployOnEVMx.s.sol --broadcast --skip-simulation -## set limits for the app gateway using API -source .env && cast send $APP_GATEWAY "deployMultiChainContracts(uint32[])" '[421614, 11155420]' --private-key $PRIVATE_KEY -source .env && forge script script/parallel-counter/checkCounters.s.sol --broadcast --skip-simulation - - -## Counter -source .env && forge script script/counter/deployEVMxCounterApp.s.sol --broadcast --skip-simulation --legacy --gas-price 0 -source .env && forge script script/counter/DeployCounterOnchain.s.sol --broadcast --skip-simulation -## set limits for the app gateway using API -source .env && cast send $APP_GATEWAY "deployContracts(uint32)" 421614 --private-key $PRIVATE_KEY --legacy --gas-price 0 -cast call $APP_GATEWAY "getOnChainAddress(bytes32,uint32)(address)" 0x5ab1536adcb0c297300e651c684f844c311727059d17eb2be15c313b5839b9eb 421614 -cast call $APP_GATEWAY "forwarderAddresses(bytes32,uint32)(address)" 0x5ab1536adcb0c297300e651c684f844c311727059d17eb2be15c313b5839b9eb 421614 -source .env && cast send $APP_GATEWAY "incrementCounters(address[])" '[0xB491b4b9343471d79d33A7c45Dc4d0a7EA818F93]' --private-key $PRIVATE_KEY --legacy --gas-price 0 -source .env && cast send $APP_GATEWAY "readCounters(address[])" '[0x18a93d520879524e0c215b64f05914da5883540f]' --private-key $PRIVATE_KEY --legacy --gas-price 0 -source .env && cast send $APP_GATEWAY "withdrawFeeTokens(uint32,address,uint256,address)" 421614 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE 987793576908782 0x3339Cf48f1F9cf31b6F8c2664d144c7444eBBB18 --private-key $PRIVATE_KEY --legacy --gas-price 0 - -forge script script/counter/incrementCounters.s.sol --broadcast --skip-simulation -forge script script/counter/checkCounters.s.sol --broadcast --skip-simulation - -## Cron -source .env && forge script script/cron/DeployGateway.s.sol:DeployGateway --broadcast --skip-simulation -source .env && forge script script/cron/SetTimeout.s.sol:SetTimeoutScript --broadcast --skip-simulation -source .env && cast send $APP_GATEWAY "setTimeout(uint256)" 0 --private-key $PRIVATE_KEY - -## Super Token Lockable -forge script script/super-token-lockable/DeployGateway.s.sol --broadcast --skip-simulation -source .env && cast send $APP_GATEWAY "deployContracts(uint32)" 421614 --private-key $PRIVATE_KEY -source .env && cast send $APP_GATEWAY "deployContracts(uint32)" 11155420 --private-key $PRIVATE_KEY -forge script script/super-token-lockable/Bridge.s.sol --broadcast --skip-simulation -source .env && cast send $APP_GATEWAY $data --private-key $PRIVATE_KEY - - -## Counter Inbox -source .env && forge script script/counter-inbox/DeployCounterAndGateway.s.sol --broadcast --skip-simulation -source .env && cast send $COUNTER_INBOX "connectSocket(address,address,address)" $APP_GATEWAY $SOCKET $SWITCHBOARD --rpc-url $ARBITRUM_SEPOLIA_RPC --private-key $SPONSOR_KEY -source .env && cast send $COUNTER_INBOX "increaseOnGateway(uint256)" 100 --rpc-url $ARBITRUM_SEPOLIA_RPC --private-key $SPONSOR_KEY -source .env && forge script script/counter-inbox/CheckGatewayCounter.s.sol --broadcast --skip-simulation - - - -## Mock Testing -source .env && forge script script/mock/DeployEVMx.s.sol --broadcast --skip-simulation -source .env && forge script script/mock/DeploySocket.s.sol --broadcast --skip-simulation -source .env && forge script script/mock/Timeout.s.sol --broadcast --skip-simulation -source .env && forge script script/mock/Query.s.sol --broadcast --skip-simulation -source .env && forge script script/mock/Inbox.s.sol --broadcast --skip-simulation -source .env && forge script script/mock/FinalizeAndExecution.s.sol --broadcast --skip-simulation - - -## Check Limits -source .env && forge script script/admin/checkLimits.s.sol --broadcast --skip-simulation -source .env && forge script script/admin/UpdateLimits.s.sol --broadcast --skip-simulation - - -# add fees -source .env && forge script script/helpers/PayFeesInArbitrumETH.s.sol --broadcast --skip-simulation -source .env && forge script script/helpers/AppGatewayFeeBalance.s.sol diff --git a/tsconfig.json b/tsconfig.json index 39cbab7d..7356b140 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,6 +6,7 @@ "moduleResolution": "Node", "allowSyntheticDefaultImports": true, "esModuleInterop": true, + "types": ["node"], "importHelpers": true, "resolveJsonModule": true, "sourceMap": true, diff --git a/yarn.lock b/yarn.lock index 3cf308a7..d5c77bfa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2071,21 +2071,21 @@ "@smithy/types" "^4.1.0" tslib "^2.6.2" -"@socket.tech/socket-protocol-common@1.1.31": - version "1.1.31" - resolved "https://registry.yarnpkg.com/@socket.tech/socket-protocol-common/-/socket-protocol-common-1.1.31.tgz#d95b1b6caf69a11c6bd13b18b7871c57e7d283fb" - integrity sha512-Hp1er4kRqCfeuvQFFgxooT0XBbO4nBrpL8/SYB/BNMdWfR9hk6PVE8MUnoIqTUJJTvIePKk+GOajl8MVqPD3VQ== +"@socket.tech/socket-protocol-common@1.1.44": + version "1.1.44" + resolved "https://registry.yarnpkg.com/@socket.tech/socket-protocol-common/-/socket-protocol-common-1.1.44.tgz#ee78da13cad3e5544ceed5a352ef7988c55e4044" + integrity sha512-ntrx/71ETxl4xN62F+D8jVNWUMrrpReLUX16DK9M1oAggQHBT1mem4e9EhvoRBriXFmGBmFHs1xJ35BvHsFPDQ== dependencies: - "@socket.tech/socket-protocol" "^1.0.15" + "@socket.tech/socket-protocol" "1.0.16" axios "^1.7.9" ethers "^5.6.5" pino "^9.6.0" sequelize "^6.21.6" -"@socket.tech/socket-protocol@^1.0.15": - version "1.0.15" - resolved "https://registry.yarnpkg.com/@socket.tech/socket-protocol/-/socket-protocol-1.0.15.tgz#091eaaf954a58658fa74370880a6fe54f09a7ee8" - integrity sha512-aBDYdpFkQro+NVNGUbridJQbtGSEk9ZoqMmtRPA+ti0gT0X2ZAryta0lS2TfqsL4sF2fqbmz1Vd+IuK3wb5dTg== +"@socket.tech/socket-protocol@1.0.16": + version "1.0.16" + resolved "https://registry.yarnpkg.com/@socket.tech/socket-protocol/-/socket-protocol-1.0.16.tgz#06820a213fa8d0661d3c22b3f871db4058ef1440" + integrity sha512-8r68OPqld3fzitu53SDuwGOCEHxECF+6GKBRQ8UtyDS6sAt3HHYGXdYGJ8sYvLtwZePwplautRKVcpDwk/LAgg== "@solidity-parser/parser@^0.19.0": version "0.19.0" @@ -2178,6 +2178,13 @@ dependencies: undici-types "~6.20.0" +"@types/node@^22.13.9": + version "22.13.9" + resolved "https://registry.yarnpkg.com/@types/node/-/node-22.13.9.tgz#5d9a8f7a975a5bd3ef267352deb96fb13ec02eca" + integrity sha512-acBjXdRJ3A6Pb3tqnw9HZmyR3Fiol3aGxRCK1x3d+6CDAMjl7I649wpSd+yNURCjbOUGu9tqtLKnTGxmK6CyGw== + dependencies: + undici-types "~6.20.0" + "@types/pbkdf2@^3.0.0": version "3.1.2" resolved "https://registry.yarnpkg.com/@types/pbkdf2/-/pbkdf2-3.1.2.tgz#2dc43808e9985a2c69ff02e2d2027bd4fe33e8dc" @@ -2190,6 +2197,14 @@ resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.7.3.tgz#3e51a17e291d01d17d3fc61422015a933af7a08f" integrity sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA== +"@types/prompts@^2.4.9": + version "2.4.9" + resolved "https://registry.yarnpkg.com/@types/prompts/-/prompts-2.4.9.tgz#8775a31e40ad227af511aa0d7f19a044ccbd371e" + integrity sha512-qTxFi6Buiu8+50/+3DGIWLHM6QuWsEKugJnnP6iv2Mc4ncxE4A/OJkjuVOA+5X0X1S/nq5VJRa8Lu+nwcvbrKA== + dependencies: + "@types/node" "*" + kleur "^3.0.3" + "@types/qs@^6.9.7": version "6.9.18" resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.18.tgz#877292caa91f7c1b213032b34626505b746624c2" @@ -2239,6 +2254,11 @@ acorn@^8.11.0, acorn@^8.4.1: resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.14.0.tgz#063e2c70cac5fb4f6467f0b11152e04c682795b0" integrity sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA== +add@^2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/add/-/add-2.0.6.tgz#248f0a9f6e5a528ef2295dbeec30532130ae2235" + integrity sha512-j5QzrmsokwWWp6kUcJQySpbG+xfOBqqKnup3OIk1pz+kB/80SLorZ9V8zHFLO92Lcd+hbvq8bT+zOGoPkmBV0Q== + adm-zip@^0.4.16: version "0.4.16" resolved "https://registry.yarnpkg.com/adm-zip/-/adm-zip-0.4.16.tgz#cf4c508fdffab02c269cbc7f471a875f05570365" @@ -3222,6 +3242,11 @@ fs.realpath@^1.0.0: resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== +fs@^0.0.1-security: + version "0.0.1-security" + resolved "https://registry.yarnpkg.com/fs/-/fs-0.0.1-security.tgz#8a7bd37186b6dddf3813f23858b57ecaaf5e41d4" + integrity sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w== + fsevents@~2.3.2: version "2.3.3" resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" @@ -3591,6 +3616,11 @@ inherits@2, inherits@2.0.4, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4, i resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== +inherits@2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + integrity sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw== + io-ts@1.10.4: version "1.10.4" resolved "https://registry.yarnpkg.com/io-ts/-/io-ts-1.10.4.tgz#cd5401b138de88e4f920adbcb7026e2d1967e6e2" @@ -3713,6 +3743,11 @@ klaw@^1.0.0: optionalDependencies: graceful-fs "^4.1.9" +kleur@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e" + integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w== + level-supports@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/level-supports/-/level-supports-4.0.1.tgz#431546f9d81f10ff0fea0e74533a0e875c08c66a" @@ -4095,6 +4130,14 @@ path-starts-with@^2.0.0: resolved "https://registry.yarnpkg.com/path-starts-with/-/path-starts-with-2.0.1.tgz#cd8b6213c141a9f2dd86c748310acdfa6493abb1" integrity sha512-wZ3AeiRBRlNwkdUxvBANh0+esnt38DLffHDujZyRHkqkaKHTglnY2EP5UX3b8rdeiSutgO4y9NEJwXezNP5vHg== +path@^0.12.7: + version "0.12.7" + resolved "https://registry.yarnpkg.com/path/-/path-0.12.7.tgz#d4dc2a506c4ce2197eb481ebfcd5b36c0140b10f" + integrity sha512-aXXC6s+1w7otVF9UletFkFcDsJeO7lSZBPUQhtb5O0xJe8LtYhj/GxldoL09bBj9+ZmE2hNoHqQSFMN5fikh4Q== + dependencies: + process "^0.11.1" + util "^0.10.3" + pbkdf2@^3.0.17: version "3.1.2" resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.1.2.tgz#dd822aa0887580e52f1a039dc3eda108efae3075" @@ -4191,6 +4234,19 @@ process-warning@^4.0.0: resolved "https://registry.yarnpkg.com/process-warning/-/process-warning-4.0.1.tgz#5c1db66007c67c756e4e09eb170cdece15da32fb" integrity sha512-3c2LzQ3rY9d0hc1emcsHhfT9Jwz0cChib/QN89oME2R451w5fy3f0afAhERFZAwrbDU43wk12d0ORBpDVME50Q== +process@^0.11.1: + version "0.11.10" + resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" + integrity sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A== + +prompts@^2.4.2: + version "2.4.2" + resolved "https://registry.yarnpkg.com/prompts/-/prompts-2.4.2.tgz#7b57e73b3a48029ad10ebd44f74b01722a4cb069" + integrity sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q== + dependencies: + kleur "^3.0.3" + sisteransi "^1.0.5" + proxy-from-env@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" @@ -4493,6 +4549,11 @@ side-channel@^1.1.0: side-channel-map "^1.0.1" side-channel-weakmap "^1.0.2" +sisteransi@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed" + integrity sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg== + slice-ansi@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-4.0.0.tgz#500e8dd0fd55b05815086255b3195adf2a45fe6b" @@ -4836,6 +4897,13 @@ util-deprecate@^1.0.1, util-deprecate@~1.0.1: resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw== +util@^0.10.3: + version "0.10.4" + resolved "https://registry.yarnpkg.com/util/-/util-0.10.4.tgz#3aa0125bfe668a4672de58857d3ace27ecb76901" + integrity sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A== + dependencies: + inherits "2.0.3" + uuid@^8.3.2: version "8.3.2" resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" @@ -4969,6 +5037,11 @@ yargs@^16.2.0: y18n "^5.0.5" yargs-parser "^20.2.2" +yarn@^1.22.22: + version "1.22.22" + resolved "https://registry.yarnpkg.com/yarn/-/yarn-1.22.22.tgz#ac34549e6aa8e7ead463a7407e1c7390f61a6610" + integrity sha512-prL3kGtyG7o9Z9Sv8IPfBNrWTDmXB4Qbes8A9rEzt6wkJV8mUvoirjU0Mp3GGAU06Y0XQyA3/2/RQFVuK7MTfg== + yn@3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50"