diff --git a/packages/agw-client/src/abis/BridgeHubAbi.ts b/packages/agw-client/src/abis/BridgeHubAbi.ts new file mode 100644 index 0000000..9913e75 --- /dev/null +++ b/packages/agw-client/src/abis/BridgeHubAbi.ts @@ -0,0 +1,945 @@ +export const BridgeHubAbi = [ + { + inputs: [], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + name: 'AddressTooLow', + type: 'error', + }, + { + inputs: [], + name: 'BridgeHubAlreadyRegistered', + type: 'error', + }, + { + inputs: [], + name: 'ChainIdTooBig', + type: 'error', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'expectedMsgValue', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'providedMsgValue', + type: 'uint256', + }, + ], + name: 'MsgValueMismatch', + type: 'error', + }, + { + inputs: [], + name: 'NotInitializedReentrancyGuard', + type: 'error', + }, + { + inputs: [], + name: 'Reentrancy', + type: 'error', + }, + { + inputs: [], + name: 'STMAlreadyRegistered', + type: 'error', + }, + { + inputs: [], + name: 'STMNotRegistered', + type: 'error', + }, + { + inputs: [], + name: 'SharedBridgeNotSet', + type: 'error', + }, + { + inputs: [], + name: 'SlotOccupied', + type: 'error', + }, + { + inputs: [ + { + internalType: 'address', + name: 'token', + type: 'address', + }, + ], + name: 'TokenAlreadyRegistered', + type: 'error', + }, + { + inputs: [ + { + internalType: 'address', + name: 'token', + type: 'address', + }, + ], + name: 'TokenNotRegistered', + type: 'error', + }, + { + inputs: [ + { + internalType: 'address', + name: 'caller', + type: 'address', + }, + ], + name: 'Unauthorized', + type: 'error', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'expectedMagicValue', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'providedMagicValue', + type: 'uint256', + }, + ], + name: 'WrongMagicValue', + type: 'error', + }, + { + inputs: [], + name: 'ZeroAddress', + type: 'error', + }, + { + inputs: [], + name: 'ZeroChainId', + type: 'error', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint8', + name: 'version', + type: 'uint8', + }, + ], + name: 'Initialized', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'oldAdmin', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'newAdmin', + type: 'address', + }, + ], + name: 'NewAdmin', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'uint256', + name: 'chainId', + type: 'uint256', + }, + { + indexed: false, + internalType: 'address', + name: 'stateTransitionManager', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'chainGovernance', + type: 'address', + }, + ], + name: 'NewChain', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'oldPendingAdmin', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'newPendingAdmin', + type: 'address', + }, + ], + name: 'NewPendingAdmin', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'previousOwner', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'newOwner', + type: 'address', + }, + ], + name: 'OwnershipTransferStarted', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'previousOwner', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'newOwner', + type: 'address', + }, + ], + name: 'OwnershipTransferred', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'address', + name: 'account', + type: 'address', + }, + ], + name: 'Paused', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'address', + name: 'account', + type: 'address', + }, + ], + name: 'Unpaused', + type: 'event', + }, + { + inputs: [], + name: 'acceptAdmin', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'acceptOwnership', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_stateTransitionManager', + type: 'address', + }, + ], + name: 'addStateTransitionManager', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_token', + type: 'address', + }, + ], + name: 'addToken', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'admin', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: '_chainId', + type: 'uint256', + }, + ], + name: 'baseToken', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: '_chainId', + type: 'uint256', + }, + { + internalType: 'address', + name: '_stateTransitionManager', + type: 'address', + }, + { + internalType: 'address', + name: '_baseToken', + type: 'address', + }, + { + internalType: 'uint256', + name: '_salt', + type: 'uint256', + }, + { + internalType: 'address', + name: '_admin', + type: 'address', + }, + { + internalType: 'bytes', + name: '_initData', + type: 'bytes', + }, + ], + name: 'createNewChain', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: '_chainId', + type: 'uint256', + }, + ], + name: 'getHyperchain', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_owner', + type: 'address', + }, + ], + name: 'initialize', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: '_chainId', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '_gasPrice', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '_l2GasLimit', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '_l2GasPerPubdataByteLimit', + type: 'uint256', + }, + ], + name: 'l2TransactionBaseCost', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'owner', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'pause', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'paused', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'pendingOwner', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: '_chainId', + type: 'uint256', + }, + { + internalType: 'bytes32', + name: '_l2TxHash', + type: 'bytes32', + }, + { + internalType: 'uint256', + name: '_l2BatchNumber', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '_l2MessageIndex', + type: 'uint256', + }, + { + internalType: 'uint16', + name: '_l2TxNumberInBatch', + type: 'uint16', + }, + { + internalType: 'bytes32[]', + name: '_merkleProof', + type: 'bytes32[]', + }, + { + internalType: 'enum TxStatus', + name: '_status', + type: 'uint8', + }, + ], + name: 'proveL1ToL2TransactionStatus', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: '_chainId', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '_batchNumber', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '_index', + type: 'uint256', + }, + { + components: [ + { + internalType: 'uint8', + name: 'l2ShardId', + type: 'uint8', + }, + { + internalType: 'bool', + name: 'isService', + type: 'bool', + }, + { + internalType: 'uint16', + name: 'txNumberInBatch', + type: 'uint16', + }, + { + internalType: 'address', + name: 'sender', + type: 'address', + }, + { + internalType: 'bytes32', + name: 'key', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 'value', + type: 'bytes32', + }, + ], + internalType: 'struct L2Log', + name: '_log', + type: 'tuple', + }, + { + internalType: 'bytes32[]', + name: '_proof', + type: 'bytes32[]', + }, + ], + name: 'proveL2LogInclusion', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: '_chainId', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '_batchNumber', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '_index', + type: 'uint256', + }, + { + components: [ + { + internalType: 'uint16', + name: 'txNumberInBatch', + type: 'uint16', + }, + { + internalType: 'address', + name: 'sender', + type: 'address', + }, + { + internalType: 'bytes', + name: 'data', + type: 'bytes', + }, + ], + internalType: 'struct L2Message', + name: '_message', + type: 'tuple', + }, + { + internalType: 'bytes32[]', + name: '_proof', + type: 'bytes32[]', + }, + ], + name: 'proveL2MessageInclusion', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_stateTransitionManager', + type: 'address', + }, + ], + name: 'removeStateTransitionManager', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'renounceOwnership', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + components: [ + { + internalType: 'uint256', + name: 'chainId', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'mintValue', + type: 'uint256', + }, + { + internalType: 'address', + name: 'l2Contract', + type: 'address', + }, + { + internalType: 'uint256', + name: 'l2Value', + type: 'uint256', + }, + { + internalType: 'bytes', + name: 'l2Calldata', + type: 'bytes', + }, + { + internalType: 'uint256', + name: 'l2GasLimit', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'l2GasPerPubdataByteLimit', + type: 'uint256', + }, + { + internalType: 'bytes[]', + name: 'factoryDeps', + type: 'bytes[]', + }, + { + internalType: 'address', + name: 'refundRecipient', + type: 'address', + }, + ], + internalType: 'struct L2TransactionRequestDirect', + name: '_request', + type: 'tuple', + }, + ], + name: 'requestL2TransactionDirect', + outputs: [ + { + internalType: 'bytes32', + name: 'canonicalTxHash', + type: 'bytes32', + }, + ], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + components: [ + { + internalType: 'uint256', + name: 'chainId', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'mintValue', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'l2Value', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'l2GasLimit', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'l2GasPerPubdataByteLimit', + type: 'uint256', + }, + { + internalType: 'address', + name: 'refundRecipient', + type: 'address', + }, + { + internalType: 'address', + name: 'secondBridgeAddress', + type: 'address', + }, + { + internalType: 'uint256', + name: 'secondBridgeValue', + type: 'uint256', + }, + { + internalType: 'bytes', + name: 'secondBridgeCalldata', + type: 'bytes', + }, + ], + internalType: 'struct L2TransactionRequestTwoBridgesOuter', + name: '_request', + type: 'tuple', + }, + ], + name: 'requestL2TransactionTwoBridges', + outputs: [ + { + internalType: 'bytes32', + name: 'canonicalTxHash', + type: 'bytes32', + }, + ], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_newPendingAdmin', + type: 'address', + }, + ], + name: 'setPendingAdmin', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_sharedBridge', + type: 'address', + }, + ], + name: 'setSharedBridge', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'sharedBridge', + outputs: [ + { + internalType: 'contract IL1SharedBridge', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: '_chainId', + type: 'uint256', + }, + ], + name: 'stateTransitionManager', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_stateTransitionManager', + type: 'address', + }, + ], + name: 'stateTransitionManagerIsRegistered', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_token', + type: 'address', + }, + ], + name: 'tokenIsRegistered', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'newOwner', + type: 'address', + }, + ], + name: 'transferOwnership', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'unpause', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const; diff --git a/packages/agw-client/src/abis/DelegateRegistry.ts b/packages/agw-client/src/abis/DelegateRegistry.ts new file mode 100644 index 0000000..1dd2691 --- /dev/null +++ b/packages/agw-client/src/abis/DelegateRegistry.ts @@ -0,0 +1,837 @@ +export const DelegateRegistryAbi = [ + { + type: 'function', + name: 'checkDelegateForAll', + inputs: [ + { + name: 'to', + type: 'address', + internalType: 'address', + }, + { + name: 'from', + type: 'address', + internalType: 'address', + }, + { + name: 'rights', + type: 'bytes32', + internalType: 'bytes32', + }, + ], + outputs: [ + { + name: 'valid', + type: 'bool', + internalType: 'bool', + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'checkDelegateForContract', + inputs: [ + { + name: 'to', + type: 'address', + internalType: 'address', + }, + { + name: 'from', + type: 'address', + internalType: 'address', + }, + { + name: 'contract_', + type: 'address', + internalType: 'address', + }, + { + name: 'rights', + type: 'bytes32', + internalType: 'bytes32', + }, + ], + outputs: [ + { + name: 'valid', + type: 'bool', + internalType: 'bool', + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'checkDelegateForERC1155', + inputs: [ + { + name: 'to', + type: 'address', + internalType: 'address', + }, + { + name: 'from', + type: 'address', + internalType: 'address', + }, + { + name: 'contract_', + type: 'address', + internalType: 'address', + }, + { + name: 'tokenId', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'rights', + type: 'bytes32', + internalType: 'bytes32', + }, + ], + outputs: [ + { + name: 'amount', + type: 'uint256', + internalType: 'uint256', + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'checkDelegateForERC20', + inputs: [ + { + name: 'to', + type: 'address', + internalType: 'address', + }, + { + name: 'from', + type: 'address', + internalType: 'address', + }, + { + name: 'contract_', + type: 'address', + internalType: 'address', + }, + { + name: 'rights', + type: 'bytes32', + internalType: 'bytes32', + }, + ], + outputs: [ + { + name: 'amount', + type: 'uint256', + internalType: 'uint256', + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'checkDelegateForERC721', + inputs: [ + { + name: 'to', + type: 'address', + internalType: 'address', + }, + { + name: 'from', + type: 'address', + internalType: 'address', + }, + { + name: 'contract_', + type: 'address', + internalType: 'address', + }, + { + name: 'tokenId', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'rights', + type: 'bytes32', + internalType: 'bytes32', + }, + ], + outputs: [ + { + name: 'valid', + type: 'bool', + internalType: 'bool', + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'delegateAll', + inputs: [ + { + name: 'to', + type: 'address', + internalType: 'address', + }, + { + name: 'rights', + type: 'bytes32', + internalType: 'bytes32', + }, + { + name: 'enable', + type: 'bool', + internalType: 'bool', + }, + ], + outputs: [ + { + name: 'hash', + type: 'bytes32', + internalType: 'bytes32', + }, + ], + stateMutability: 'payable', + }, + { + type: 'function', + name: 'delegateContract', + inputs: [ + { + name: 'to', + type: 'address', + internalType: 'address', + }, + { + name: 'contract_', + type: 'address', + internalType: 'address', + }, + { + name: 'rights', + type: 'bytes32', + internalType: 'bytes32', + }, + { + name: 'enable', + type: 'bool', + internalType: 'bool', + }, + ], + outputs: [ + { + name: 'hash', + type: 'bytes32', + internalType: 'bytes32', + }, + ], + stateMutability: 'payable', + }, + { + type: 'function', + name: 'delegateERC1155', + inputs: [ + { + name: 'to', + type: 'address', + internalType: 'address', + }, + { + name: 'contract_', + type: 'address', + internalType: 'address', + }, + { + name: 'tokenId', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'rights', + type: 'bytes32', + internalType: 'bytes32', + }, + { + name: 'amount', + type: 'uint256', + internalType: 'uint256', + }, + ], + outputs: [ + { + name: 'hash', + type: 'bytes32', + internalType: 'bytes32', + }, + ], + stateMutability: 'payable', + }, + { + type: 'function', + name: 'delegateERC20', + inputs: [ + { + name: 'to', + type: 'address', + internalType: 'address', + }, + { + name: 'contract_', + type: 'address', + internalType: 'address', + }, + { + name: 'rights', + type: 'bytes32', + internalType: 'bytes32', + }, + { + name: 'amount', + type: 'uint256', + internalType: 'uint256', + }, + ], + outputs: [ + { + name: 'hash', + type: 'bytes32', + internalType: 'bytes32', + }, + ], + stateMutability: 'payable', + }, + { + type: 'function', + name: 'delegateERC721', + inputs: [ + { + name: 'to', + type: 'address', + internalType: 'address', + }, + { + name: 'contract_', + type: 'address', + internalType: 'address', + }, + { + name: 'tokenId', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'rights', + type: 'bytes32', + internalType: 'bytes32', + }, + { + name: 'enable', + type: 'bool', + internalType: 'bool', + }, + ], + outputs: [ + { + name: 'hash', + type: 'bytes32', + internalType: 'bytes32', + }, + ], + stateMutability: 'payable', + }, + { + type: 'function', + name: 'getDelegationsFromHashes', + inputs: [ + { + name: 'hashes', + type: 'bytes32[]', + internalType: 'bytes32[]', + }, + ], + outputs: [ + { + name: 'delegations_', + type: 'tuple[]', + internalType: 'struct IDelegateRegistry.Delegation[]', + components: [ + { + name: 'type_', + type: 'uint8', + internalType: 'enum IDelegateRegistry.DelegationType', + }, + { + name: 'to', + type: 'address', + internalType: 'address', + }, + { + name: 'from', + type: 'address', + internalType: 'address', + }, + { + name: 'rights', + type: 'bytes32', + internalType: 'bytes32', + }, + { + name: 'contract_', + type: 'address', + internalType: 'address', + }, + { + name: 'tokenId', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'amount', + type: 'uint256', + internalType: 'uint256', + }, + ], + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'getIncomingDelegationHashes', + inputs: [ + { + name: 'to', + type: 'address', + internalType: 'address', + }, + ], + outputs: [ + { + name: 'delegationHashes', + type: 'bytes32[]', + internalType: 'bytes32[]', + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'getIncomingDelegations', + inputs: [ + { + name: 'to', + type: 'address', + internalType: 'address', + }, + ], + outputs: [ + { + name: 'delegations_', + type: 'tuple[]', + internalType: 'struct IDelegateRegistry.Delegation[]', + components: [ + { + name: 'type_', + type: 'uint8', + internalType: 'enum IDelegateRegistry.DelegationType', + }, + { + name: 'to', + type: 'address', + internalType: 'address', + }, + { + name: 'from', + type: 'address', + internalType: 'address', + }, + { + name: 'rights', + type: 'bytes32', + internalType: 'bytes32', + }, + { + name: 'contract_', + type: 'address', + internalType: 'address', + }, + { + name: 'tokenId', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'amount', + type: 'uint256', + internalType: 'uint256', + }, + ], + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'getOutgoingDelegationHashes', + inputs: [ + { + name: 'from', + type: 'address', + internalType: 'address', + }, + ], + outputs: [ + { + name: 'delegationHashes', + type: 'bytes32[]', + internalType: 'bytes32[]', + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'getOutgoingDelegations', + inputs: [ + { + name: 'from', + type: 'address', + internalType: 'address', + }, + ], + outputs: [ + { + name: 'delegations_', + type: 'tuple[]', + internalType: 'struct IDelegateRegistry.Delegation[]', + components: [ + { + name: 'type_', + type: 'uint8', + internalType: 'enum IDelegateRegistry.DelegationType', + }, + { + name: 'to', + type: 'address', + internalType: 'address', + }, + { + name: 'from', + type: 'address', + internalType: 'address', + }, + { + name: 'rights', + type: 'bytes32', + internalType: 'bytes32', + }, + { + name: 'contract_', + type: 'address', + internalType: 'address', + }, + { + name: 'tokenId', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'amount', + type: 'uint256', + internalType: 'uint256', + }, + ], + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'multicall', + inputs: [ + { + name: 'data', + type: 'bytes[]', + internalType: 'bytes[]', + }, + ], + outputs: [ + { + name: 'results', + type: 'bytes[]', + internalType: 'bytes[]', + }, + ], + stateMutability: 'payable', + }, + { + type: 'function', + name: 'readSlot', + inputs: [ + { + name: 'location', + type: 'bytes32', + internalType: 'bytes32', + }, + ], + outputs: [ + { + name: 'contents', + type: 'bytes32', + internalType: 'bytes32', + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'readSlots', + inputs: [ + { + name: 'locations', + type: 'bytes32[]', + internalType: 'bytes32[]', + }, + ], + outputs: [ + { + name: 'contents', + type: 'bytes32[]', + internalType: 'bytes32[]', + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'supportsInterface', + inputs: [ + { + name: 'interfaceId', + type: 'bytes4', + internalType: 'bytes4', + }, + ], + outputs: [ + { + name: '', + type: 'bool', + internalType: 'bool', + }, + ], + stateMutability: 'pure', + }, + { + type: 'function', + name: 'sweep', + inputs: [], + outputs: [], + stateMutability: 'nonpayable', + }, + { + type: 'event', + name: 'DelegateAll', + inputs: [ + { + name: 'from', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'to', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'rights', + type: 'bytes32', + indexed: false, + internalType: 'bytes32', + }, + { + name: 'enable', + type: 'bool', + indexed: false, + internalType: 'bool', + }, + ], + anonymous: false, + }, + { + type: 'event', + name: 'DelegateContract', + inputs: [ + { + name: 'from', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'to', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'contract_', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'rights', + type: 'bytes32', + indexed: false, + internalType: 'bytes32', + }, + { + name: 'enable', + type: 'bool', + indexed: false, + internalType: 'bool', + }, + ], + anonymous: false, + }, + { + type: 'event', + name: 'DelegateERC1155', + inputs: [ + { + name: 'from', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'to', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'contract_', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'tokenId', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + { + name: 'rights', + type: 'bytes32', + indexed: false, + internalType: 'bytes32', + }, + { + name: 'amount', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + ], + anonymous: false, + }, + { + type: 'event', + name: 'DelegateERC20', + inputs: [ + { + name: 'from', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'to', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'contract_', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'rights', + type: 'bytes32', + indexed: false, + internalType: 'bytes32', + }, + { + name: 'amount', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + ], + anonymous: false, + }, + { + type: 'event', + name: 'DelegateERC721', + inputs: [ + { + name: 'from', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'to', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'contract_', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'tokenId', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + { + name: 'rights', + type: 'bytes32', + indexed: false, + internalType: 'bytes32', + }, + { + name: 'enable', + type: 'bool', + indexed: false, + internalType: 'bool', + }, + ], + anonymous: false, + }, + { + type: 'error', + name: 'MulticallFailed', + inputs: [], + }, +] as const; diff --git a/packages/agw-client/src/abis/ExclusiveDelegateResolver.ts b/packages/agw-client/src/abis/ExclusiveDelegateResolver.ts new file mode 100644 index 0000000..b47bf1a --- /dev/null +++ b/packages/agw-client/src/abis/ExclusiveDelegateResolver.ts @@ -0,0 +1,153 @@ +export const ExclusiveDelegateResolverAbi = [ + { + type: 'function', + name: 'DELEGATE_REGISTRY', + inputs: [], + outputs: [ + { + name: '', + type: 'address', + internalType: 'address', + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'GLOBAL_DELEGATION', + inputs: [], + outputs: [ + { + name: '', + type: 'bytes24', + internalType: 'bytes24', + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'decodeRightsExpiration', + inputs: [ + { + name: 'rights', + type: 'bytes32', + internalType: 'bytes32', + }, + ], + outputs: [ + { + name: '', + type: 'bytes24', + internalType: 'bytes24', + }, + { + name: '', + type: 'uint40', + internalType: 'uint40', + }, + ], + stateMutability: 'pure', + }, + { + type: 'function', + name: 'delegatedWalletsByRights', + inputs: [ + { + name: 'wallet', + type: 'address', + internalType: 'address', + }, + { + name: 'rights', + type: 'bytes24', + internalType: 'bytes24', + }, + ], + outputs: [ + { + name: '', + type: 'address[]', + internalType: 'address[]', + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'exclusiveOwnerByRights', + inputs: [ + { + name: 'contractAddress', + type: 'address', + internalType: 'address', + }, + { + name: 'tokenId', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'rights', + type: 'bytes24', + internalType: 'bytes24', + }, + ], + outputs: [ + { + name: 'owner', + type: 'address', + internalType: 'address', + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'exclusiveWalletByRights', + inputs: [ + { + name: 'vault', + type: 'address', + internalType: 'address', + }, + { + name: 'rights', + type: 'bytes24', + internalType: 'bytes24', + }, + ], + outputs: [ + { + name: '', + type: 'address', + internalType: 'address', + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'generateRightsWithExpiration', + inputs: [ + { + name: 'rightsIdentifier', + type: 'bytes24', + internalType: 'bytes24', + }, + { + name: 'expiration', + type: 'uint40', + internalType: 'uint40', + }, + ], + outputs: [ + { + name: '', + type: 'bytes32', + internalType: 'bytes32', + }, + ], + stateMutability: 'pure', + }, +] as const; diff --git a/packages/agw-client/src/abis/ZkSyncAbi.ts b/packages/agw-client/src/abis/ZkSyncAbi.ts new file mode 100644 index 0000000..36f336b --- /dev/null +++ b/packages/agw-client/src/abis/ZkSyncAbi.ts @@ -0,0 +1,2407 @@ +export const ZkSyncAbi = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'uint256', + name: 'batchNumber', + type: 'uint256', + }, + { + indexed: true, + internalType: 'bytes32', + name: 'batchHash', + type: 'bytes32', + }, + { + indexed: true, + internalType: 'bytes32', + name: 'commitment', + type: 'bytes32', + }, + ], + name: 'BlockCommit', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'uint256', + name: 'batchNumber', + type: 'uint256', + }, + { + indexed: true, + internalType: 'bytes32', + name: 'batchHash', + type: 'bytes32', + }, + { + indexed: true, + internalType: 'bytes32', + name: 'commitment', + type: 'bytes32', + }, + ], + name: 'BlockExecution', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint256', + name: 'totalBatchesCommitted', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'totalBatchesVerified', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'totalBatchesExecuted', + type: 'uint256', + }, + ], + name: 'BlocksRevert', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'uint256', + name: 'previousLastVerifiedBatch', + type: 'uint256', + }, + { + indexed: true, + internalType: 'uint256', + name: 'currentLastVerifiedBatch', + type: 'uint256', + }, + ], + name: 'BlocksVerification', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + components: [ + { + components: [ + { + internalType: 'address', + name: 'facet', + type: 'address', + }, + { + internalType: 'enum Diamond.Action', + name: 'action', + type: 'uint8', + }, + { + internalType: 'bool', + name: 'isFreezable', + type: 'bool', + }, + { + internalType: 'bytes4[]', + name: 'selectors', + type: 'bytes4[]', + }, + ], + internalType: 'struct Diamond.FacetCut[]', + name: 'facetCuts', + type: 'tuple[]', + }, + { + internalType: 'address', + name: 'initAddress', + type: 'address', + }, + { + internalType: 'bytes', + name: 'initCalldata', + type: 'bytes', + }, + ], + indexed: false, + internalType: 'struct Diamond.DiamondCutData', + name: 'diamondCut', + type: 'tuple', + }, + ], + name: 'ExecuteUpgrade', + type: 'event', + }, + { + anonymous: false, + inputs: [], + name: 'Freeze', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'bool', + name: 'isPorterAvailable', + type: 'bool', + }, + ], + name: 'IsPorterAvailableStatusUpdate', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'oldAdmin', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'newAdmin', + type: 'address', + }, + ], + name: 'NewAdmin', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint128', + name: 'oldNominator', + type: 'uint128', + }, + { + indexed: false, + internalType: 'uint128', + name: 'oldDenominator', + type: 'uint128', + }, + { + indexed: false, + internalType: 'uint128', + name: 'newNominator', + type: 'uint128', + }, + { + indexed: false, + internalType: 'uint128', + name: 'newDenominator', + type: 'uint128', + }, + ], + name: 'NewBaseTokenMultiplier', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + components: [ + { + internalType: 'enum PubdataPricingMode', + name: 'pubdataPricingMode', + type: 'uint8', + }, + { + internalType: 'uint32', + name: 'batchOverheadL1Gas', + type: 'uint32', + }, + { + internalType: 'uint32', + name: 'maxPubdataPerBatch', + type: 'uint32', + }, + { + internalType: 'uint32', + name: 'maxL2GasPerBatch', + type: 'uint32', + }, + { + internalType: 'uint32', + name: 'priorityTxMaxPubdata', + type: 'uint32', + }, + { + internalType: 'uint64', + name: 'minimalL2GasPrice', + type: 'uint64', + }, + ], + indexed: false, + internalType: 'struct FeeParams', + name: 'oldFeeParams', + type: 'tuple', + }, + { + components: [ + { + internalType: 'enum PubdataPricingMode', + name: 'pubdataPricingMode', + type: 'uint8', + }, + { + internalType: 'uint32', + name: 'batchOverheadL1Gas', + type: 'uint32', + }, + { + internalType: 'uint32', + name: 'maxPubdataPerBatch', + type: 'uint32', + }, + { + internalType: 'uint32', + name: 'maxL2GasPerBatch', + type: 'uint32', + }, + { + internalType: 'uint32', + name: 'priorityTxMaxPubdata', + type: 'uint32', + }, + { + internalType: 'uint64', + name: 'minimalL2GasPrice', + type: 'uint64', + }, + ], + indexed: false, + internalType: 'struct FeeParams', + name: 'newFeeParams', + type: 'tuple', + }, + ], + name: 'NewFeeParams', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'oldPendingAdmin', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'newPendingAdmin', + type: 'address', + }, + ], + name: 'NewPendingAdmin', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint256', + name: 'txId', + type: 'uint256', + }, + { + indexed: false, + internalType: 'bytes32', + name: 'txHash', + type: 'bytes32', + }, + { + indexed: false, + internalType: 'uint64', + name: 'expirationTimestamp', + type: 'uint64', + }, + { + components: [ + { + internalType: 'uint256', + name: 'txType', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'from', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'to', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'gasLimit', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'gasPerPubdataByteLimit', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'maxFeePerGas', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'maxPriorityFeePerGas', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'paymaster', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'nonce', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + { + internalType: 'uint256[4]', + name: 'reserved', + type: 'uint256[4]', + }, + { + internalType: 'bytes', + name: 'data', + type: 'bytes', + }, + { + internalType: 'bytes', + name: 'signature', + type: 'bytes', + }, + { + internalType: 'uint256[]', + name: 'factoryDeps', + type: 'uint256[]', + }, + { + internalType: 'bytes', + name: 'paymasterInput', + type: 'bytes', + }, + { + internalType: 'bytes', + name: 'reservedDynamic', + type: 'bytes', + }, + ], + indexed: false, + internalType: 'struct L2CanonicalTransaction', + name: 'transaction', + type: 'tuple', + }, + { + indexed: false, + internalType: 'bytes[]', + name: 'factoryDeps', + type: 'bytes[]', + }, + ], + name: 'NewPriorityRequest', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint256', + name: 'oldPriorityTxMaxGasLimit', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'newPriorityTxMaxGasLimit', + type: 'uint256', + }, + ], + name: 'NewPriorityTxMaxGasLimit', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'address', + name: 'oldTransactionFilterer', + type: 'address', + }, + { + indexed: false, + internalType: 'address', + name: 'newTransactionFilterer', + type: 'address', + }, + ], + name: 'NewTransactionFilterer', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + components: [ + { + components: [ + { + internalType: 'address', + name: 'facet', + type: 'address', + }, + { + internalType: 'enum Diamond.Action', + name: 'action', + type: 'uint8', + }, + { + internalType: 'bool', + name: 'isFreezable', + type: 'bool', + }, + { + internalType: 'bytes4[]', + name: 'selectors', + type: 'bytes4[]', + }, + ], + internalType: 'struct Diamond.FacetCut[]', + name: 'facetCuts', + type: 'tuple[]', + }, + { + internalType: 'address', + name: 'initAddress', + type: 'address', + }, + { + internalType: 'bytes', + name: 'initCalldata', + type: 'bytes', + }, + ], + indexed: false, + internalType: 'struct Diamond.DiamondCutData', + name: 'diamondCut', + type: 'tuple', + }, + { + indexed: true, + internalType: 'uint256', + name: 'proposalId', + type: 'uint256', + }, + { + indexed: false, + internalType: 'bytes32', + name: 'proposalSalt', + type: 'bytes32', + }, + ], + name: 'ProposeTransparentUpgrade', + type: 'event', + }, + { + anonymous: false, + inputs: [], + name: 'Unfreeze', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'validatorAddress', + type: 'address', + }, + { + indexed: false, + internalType: 'bool', + name: 'isActive', + type: 'bool', + }, + ], + name: 'ValidatorStatusUpdate', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'enum PubdataPricingMode', + name: 'validiumMode', + type: 'uint8', + }, + ], + name: 'ValidiumModeStatusUpdate', + type: 'event', + }, + { + inputs: [], + name: 'acceptAdmin', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'baseTokenGasPriceMultiplierDenominator', + outputs: [ + { + internalType: 'uint128', + name: '', + type: 'uint128', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'baseTokenGasPriceMultiplierNominator', + outputs: [ + { + internalType: 'uint128', + name: '', + type: 'uint128', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + components: [ + { + internalType: 'address', + name: 'sender', + type: 'address', + }, + { + internalType: 'address', + name: 'contractL2', + type: 'address', + }, + { + internalType: 'uint256', + name: 'mintValue', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'l2Value', + type: 'uint256', + }, + { + internalType: 'bytes', + name: 'l2Calldata', + type: 'bytes', + }, + { + internalType: 'uint256', + name: 'l2GasLimit', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'l2GasPerPubdataByteLimit', + type: 'uint256', + }, + { + internalType: 'bytes[]', + name: 'factoryDeps', + type: 'bytes[]', + }, + { + internalType: 'address', + name: 'refundRecipient', + type: 'address', + }, + ], + internalType: 'struct BridgehubL2TransactionRequest', + name: '_request', + type: 'tuple', + }, + ], + name: 'bridgehubRequestL2Transaction', + outputs: [ + { + internalType: 'bytes32', + name: 'canonicalTxHash', + type: 'bytes32', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + components: [ + { + internalType: 'enum PubdataPricingMode', + name: 'pubdataPricingMode', + type: 'uint8', + }, + { + internalType: 'uint32', + name: 'batchOverheadL1Gas', + type: 'uint32', + }, + { + internalType: 'uint32', + name: 'maxPubdataPerBatch', + type: 'uint32', + }, + { + internalType: 'uint32', + name: 'maxL2GasPerBatch', + type: 'uint32', + }, + { + internalType: 'uint32', + name: 'priorityTxMaxPubdata', + type: 'uint32', + }, + { + internalType: 'uint64', + name: 'minimalL2GasPrice', + type: 'uint64', + }, + ], + internalType: 'struct FeeParams', + name: '_newFeeParams', + type: 'tuple', + }, + ], + name: 'changeFeeParams', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + components: [ + { + internalType: 'uint64', + name: 'batchNumber', + type: 'uint64', + }, + { + internalType: 'bytes32', + name: 'batchHash', + type: 'bytes32', + }, + { + internalType: 'uint64', + name: 'indexRepeatedStorageChanges', + type: 'uint64', + }, + { + internalType: 'uint256', + name: 'numberOfLayer1Txs', + type: 'uint256', + }, + { + internalType: 'bytes32', + name: 'priorityOperationsHash', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 'l2LogsTreeRoot', + type: 'bytes32', + }, + { + internalType: 'uint256', + name: 'timestamp', + type: 'uint256', + }, + { + internalType: 'bytes32', + name: 'commitment', + type: 'bytes32', + }, + ], + internalType: 'struct IExecutor.StoredBatchInfo', + name: '_lastCommittedBatchData', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint64', + name: 'batchNumber', + type: 'uint64', + }, + { + internalType: 'uint64', + name: 'timestamp', + type: 'uint64', + }, + { + internalType: 'uint64', + name: 'indexRepeatedStorageChanges', + type: 'uint64', + }, + { + internalType: 'bytes32', + name: 'newStateRoot', + type: 'bytes32', + }, + { + internalType: 'uint256', + name: 'numberOfLayer1Txs', + type: 'uint256', + }, + { + internalType: 'bytes32', + name: 'priorityOperationsHash', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 'bootloaderHeapInitialContentsHash', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 'eventsQueueStateHash', + type: 'bytes32', + }, + { + internalType: 'bytes', + name: 'systemLogs', + type: 'bytes', + }, + { + internalType: 'bytes', + name: 'pubdataCommitments', + type: 'bytes', + }, + ], + internalType: 'struct IExecutor.CommitBatchInfo[]', + name: '_newBatchesData', + type: 'tuple[]', + }, + ], + name: 'commitBatches', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: '_chainId', + type: 'uint256', + }, + { + components: [ + { + internalType: 'uint64', + name: 'batchNumber', + type: 'uint64', + }, + { + internalType: 'bytes32', + name: 'batchHash', + type: 'bytes32', + }, + { + internalType: 'uint64', + name: 'indexRepeatedStorageChanges', + type: 'uint64', + }, + { + internalType: 'uint256', + name: 'numberOfLayer1Txs', + type: 'uint256', + }, + { + internalType: 'bytes32', + name: 'priorityOperationsHash', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 'l2LogsTreeRoot', + type: 'bytes32', + }, + { + internalType: 'uint256', + name: 'timestamp', + type: 'uint256', + }, + { + internalType: 'bytes32', + name: 'commitment', + type: 'bytes32', + }, + ], + internalType: 'struct IExecutor.StoredBatchInfo', + name: '_lastCommittedBatchData', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint64', + name: 'batchNumber', + type: 'uint64', + }, + { + internalType: 'uint64', + name: 'timestamp', + type: 'uint64', + }, + { + internalType: 'uint64', + name: 'indexRepeatedStorageChanges', + type: 'uint64', + }, + { + internalType: 'bytes32', + name: 'newStateRoot', + type: 'bytes32', + }, + { + internalType: 'uint256', + name: 'numberOfLayer1Txs', + type: 'uint256', + }, + { + internalType: 'bytes32', + name: 'priorityOperationsHash', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 'bootloaderHeapInitialContentsHash', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 'eventsQueueStateHash', + type: 'bytes32', + }, + { + internalType: 'bytes', + name: 'systemLogs', + type: 'bytes', + }, + { + internalType: 'bytes', + name: 'pubdataCommitments', + type: 'bytes', + }, + ], + internalType: 'struct IExecutor.CommitBatchInfo[]', + name: '_newBatchesData', + type: 'tuple[]', + }, + ], + name: 'commitBatchesSharedBridge', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + components: [ + { + internalType: 'uint64', + name: 'batchNumber', + type: 'uint64', + }, + { + internalType: 'bytes32', + name: 'batchHash', + type: 'bytes32', + }, + { + internalType: 'uint64', + name: 'indexRepeatedStorageChanges', + type: 'uint64', + }, + { + internalType: 'uint256', + name: 'numberOfLayer1Txs', + type: 'uint256', + }, + { + internalType: 'bytes32', + name: 'priorityOperationsHash', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 'l2LogsTreeRoot', + type: 'bytes32', + }, + { + internalType: 'uint256', + name: 'timestamp', + type: 'uint256', + }, + { + internalType: 'bytes32', + name: 'commitment', + type: 'bytes32', + }, + ], + internalType: 'struct IExecutor.StoredBatchInfo[]', + name: '_batchesData', + type: 'tuple[]', + }, + ], + name: 'executeBatches', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: '_chainId', + type: 'uint256', + }, + { + components: [ + { + internalType: 'uint64', + name: 'batchNumber', + type: 'uint64', + }, + { + internalType: 'bytes32', + name: 'batchHash', + type: 'bytes32', + }, + { + internalType: 'uint64', + name: 'indexRepeatedStorageChanges', + type: 'uint64', + }, + { + internalType: 'uint256', + name: 'numberOfLayer1Txs', + type: 'uint256', + }, + { + internalType: 'bytes32', + name: 'priorityOperationsHash', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 'l2LogsTreeRoot', + type: 'bytes32', + }, + { + internalType: 'uint256', + name: 'timestamp', + type: 'uint256', + }, + { + internalType: 'bytes32', + name: 'commitment', + type: 'bytes32', + }, + ], + internalType: 'struct IExecutor.StoredBatchInfo[]', + name: '_batchesData', + type: 'tuple[]', + }, + ], + name: 'executeBatchesSharedBridge', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + components: [ + { + components: [ + { + internalType: 'address', + name: 'facet', + type: 'address', + }, + { + internalType: 'enum Diamond.Action', + name: 'action', + type: 'uint8', + }, + { + internalType: 'bool', + name: 'isFreezable', + type: 'bool', + }, + { + internalType: 'bytes4[]', + name: 'selectors', + type: 'bytes4[]', + }, + ], + internalType: 'struct Diamond.FacetCut[]', + name: 'facetCuts', + type: 'tuple[]', + }, + { + internalType: 'address', + name: 'initAddress', + type: 'address', + }, + { + internalType: 'bytes', + name: 'initCalldata', + type: 'bytes', + }, + ], + internalType: 'struct Diamond.DiamondCutData', + name: '_diamondCut', + type: 'tuple', + }, + ], + name: 'executeUpgrade', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes4', + name: '_selector', + type: 'bytes4', + }, + ], + name: 'facetAddress', + outputs: [ + { + internalType: 'address', + name: 'facet', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'facetAddresses', + outputs: [ + { + internalType: 'address[]', + name: 'facets', + type: 'address[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_facet', + type: 'address', + }, + ], + name: 'facetFunctionSelectors', + outputs: [ + { + internalType: 'bytes4[]', + name: '', + type: 'bytes4[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'facets', + outputs: [ + { + components: [ + { + internalType: 'address', + name: 'addr', + type: 'address', + }, + { + internalType: 'bytes4[]', + name: 'selectors', + type: 'bytes4[]', + }, + ], + internalType: 'struct IGetters.Facet[]', + name: '', + type: 'tuple[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: '_l2BatchNumber', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '_l2MessageIndex', + type: 'uint256', + }, + { + internalType: 'uint16', + name: '_l2TxNumberInBatch', + type: 'uint16', + }, + { + internalType: 'bytes', + name: '_message', + type: 'bytes', + }, + { + internalType: 'bytes32[]', + name: '_merkleProof', + type: 'bytes32[]', + }, + ], + name: 'finalizeEthWithdrawal', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'freezeDiamond', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'getAdmin', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getBaseToken', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getBaseTokenBridge', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getBridgehub', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getFirstUnprocessedPriorityTx', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getL2BootloaderBytecodeHash', + outputs: [ + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getL2DefaultAccountBytecodeHash', + outputs: [ + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getL2SystemContractsUpgradeBatchNumber', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getL2SystemContractsUpgradeTxHash', + outputs: [ + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getName', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getPendingAdmin', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getPriorityQueueSize', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getPriorityTxMaxGasLimit', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getProtocolVersion', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getPubdataPricingMode', + outputs: [ + { + internalType: 'enum PubdataPricingMode', + name: '', + type: 'uint8', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getSemverProtocolVersion', + outputs: [ + { + internalType: 'uint32', + name: '', + type: 'uint32', + }, + { + internalType: 'uint32', + name: '', + type: 'uint32', + }, + { + internalType: 'uint32', + name: '', + type: 'uint32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getStateTransitionManager', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getTotalBatchesCommitted', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getTotalBatchesExecuted', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getTotalBatchesVerified', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getTotalPriorityTxs', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getVerifier', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getVerifierParams', + outputs: [ + { + components: [ + { + internalType: 'bytes32', + name: 'recursionNodeLevelVkHash', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 'recursionLeafLevelVkHash', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 'recursionCircuitsSetVksHash', + type: 'bytes32', + }, + ], + internalType: 'struct VerifierParams', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'isDiamondStorageFrozen', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: '_l2BatchNumber', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '_l2MessageIndex', + type: 'uint256', + }, + ], + name: 'isEthWithdrawalFinalized', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_facet', + type: 'address', + }, + ], + name: 'isFacetFreezable', + outputs: [ + { + internalType: 'bool', + name: 'isFreezable', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes4', + name: '_selector', + type: 'bytes4', + }, + ], + name: 'isFunctionFreezable', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_address', + type: 'address', + }, + ], + name: 'isValidator', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: '_batchNumber', + type: 'uint256', + }, + ], + name: 'l2LogsRootHash', + outputs: [ + { + internalType: 'bytes32', + name: 'merkleRoot', + type: 'bytes32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: '_gasPrice', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '_l2GasLimit', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '_l2GasPerPubdataByteLimit', + type: 'uint256', + }, + ], + name: 'l2TransactionBaseCost', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'priorityQueueFrontOperation', + outputs: [ + { + components: [ + { + internalType: 'bytes32', + name: 'canonicalTxHash', + type: 'bytes32', + }, + { + internalType: 'uint64', + name: 'expirationTimestamp', + type: 'uint64', + }, + { + internalType: 'uint192', + name: 'layer2Tip', + type: 'uint192', + }, + ], + internalType: 'struct PriorityOperation', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + components: [ + { + internalType: 'uint64', + name: 'batchNumber', + type: 'uint64', + }, + { + internalType: 'bytes32', + name: 'batchHash', + type: 'bytes32', + }, + { + internalType: 'uint64', + name: 'indexRepeatedStorageChanges', + type: 'uint64', + }, + { + internalType: 'uint256', + name: 'numberOfLayer1Txs', + type: 'uint256', + }, + { + internalType: 'bytes32', + name: 'priorityOperationsHash', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 'l2LogsTreeRoot', + type: 'bytes32', + }, + { + internalType: 'uint256', + name: 'timestamp', + type: 'uint256', + }, + { + internalType: 'bytes32', + name: 'commitment', + type: 'bytes32', + }, + ], + internalType: 'struct IExecutor.StoredBatchInfo', + name: '_prevBatch', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint64', + name: 'batchNumber', + type: 'uint64', + }, + { + internalType: 'bytes32', + name: 'batchHash', + type: 'bytes32', + }, + { + internalType: 'uint64', + name: 'indexRepeatedStorageChanges', + type: 'uint64', + }, + { + internalType: 'uint256', + name: 'numberOfLayer1Txs', + type: 'uint256', + }, + { + internalType: 'bytes32', + name: 'priorityOperationsHash', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 'l2LogsTreeRoot', + type: 'bytes32', + }, + { + internalType: 'uint256', + name: 'timestamp', + type: 'uint256', + }, + { + internalType: 'bytes32', + name: 'commitment', + type: 'bytes32', + }, + ], + internalType: 'struct IExecutor.StoredBatchInfo[]', + name: '_committedBatches', + type: 'tuple[]', + }, + { + components: [ + { + internalType: 'uint256[]', + name: 'recursiveAggregationInput', + type: 'uint256[]', + }, + { + internalType: 'uint256[]', + name: 'serializedProof', + type: 'uint256[]', + }, + ], + internalType: 'struct IExecutor.ProofInput', + name: '_proof', + type: 'tuple', + }, + ], + name: 'proveBatches', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: '_chainId', + type: 'uint256', + }, + { + components: [ + { + internalType: 'uint64', + name: 'batchNumber', + type: 'uint64', + }, + { + internalType: 'bytes32', + name: 'batchHash', + type: 'bytes32', + }, + { + internalType: 'uint64', + name: 'indexRepeatedStorageChanges', + type: 'uint64', + }, + { + internalType: 'uint256', + name: 'numberOfLayer1Txs', + type: 'uint256', + }, + { + internalType: 'bytes32', + name: 'priorityOperationsHash', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 'l2LogsTreeRoot', + type: 'bytes32', + }, + { + internalType: 'uint256', + name: 'timestamp', + type: 'uint256', + }, + { + internalType: 'bytes32', + name: 'commitment', + type: 'bytes32', + }, + ], + internalType: 'struct IExecutor.StoredBatchInfo', + name: '_prevBatch', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint64', + name: 'batchNumber', + type: 'uint64', + }, + { + internalType: 'bytes32', + name: 'batchHash', + type: 'bytes32', + }, + { + internalType: 'uint64', + name: 'indexRepeatedStorageChanges', + type: 'uint64', + }, + { + internalType: 'uint256', + name: 'numberOfLayer1Txs', + type: 'uint256', + }, + { + internalType: 'bytes32', + name: 'priorityOperationsHash', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 'l2LogsTreeRoot', + type: 'bytes32', + }, + { + internalType: 'uint256', + name: 'timestamp', + type: 'uint256', + }, + { + internalType: 'bytes32', + name: 'commitment', + type: 'bytes32', + }, + ], + internalType: 'struct IExecutor.StoredBatchInfo[]', + name: '_committedBatches', + type: 'tuple[]', + }, + { + components: [ + { + internalType: 'uint256[]', + name: 'recursiveAggregationInput', + type: 'uint256[]', + }, + { + internalType: 'uint256[]', + name: 'serializedProof', + type: 'uint256[]', + }, + ], + internalType: 'struct IExecutor.ProofInput', + name: '_proof', + type: 'tuple', + }, + ], + name: 'proveBatchesSharedBridge', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes32', + name: '_l2TxHash', + type: 'bytes32', + }, + { + internalType: 'uint256', + name: '_l2BatchNumber', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '_l2MessageIndex', + type: 'uint256', + }, + { + internalType: 'uint16', + name: '_l2TxNumberInBatch', + type: 'uint16', + }, + { + internalType: 'bytes32[]', + name: '_merkleProof', + type: 'bytes32[]', + }, + { + internalType: 'enum TxStatus', + name: '_status', + type: 'uint8', + }, + ], + name: 'proveL1ToL2TransactionStatus', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: '_batchNumber', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '_index', + type: 'uint256', + }, + { + components: [ + { + internalType: 'uint8', + name: 'l2ShardId', + type: 'uint8', + }, + { + internalType: 'bool', + name: 'isService', + type: 'bool', + }, + { + internalType: 'uint16', + name: 'txNumberInBatch', + type: 'uint16', + }, + { + internalType: 'address', + name: 'sender', + type: 'address', + }, + { + internalType: 'bytes32', + name: 'key', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 'value', + type: 'bytes32', + }, + ], + internalType: 'struct L2Log', + name: '_log', + type: 'tuple', + }, + { + internalType: 'bytes32[]', + name: '_proof', + type: 'bytes32[]', + }, + ], + name: 'proveL2LogInclusion', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: '_batchNumber', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '_index', + type: 'uint256', + }, + { + components: [ + { + internalType: 'uint16', + name: 'txNumberInBatch', + type: 'uint16', + }, + { + internalType: 'address', + name: 'sender', + type: 'address', + }, + { + internalType: 'bytes', + name: 'data', + type: 'bytes', + }, + ], + internalType: 'struct L2Message', + name: '_message', + type: 'tuple', + }, + { + internalType: 'bytes32[]', + name: '_proof', + type: 'bytes32[]', + }, + ], + name: 'proveL2MessageInclusion', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_contractL2', + type: 'address', + }, + { + internalType: 'uint256', + name: '_l2Value', + type: 'uint256', + }, + { + internalType: 'bytes', + name: '_calldata', + type: 'bytes', + }, + { + internalType: 'uint256', + name: '_l2GasLimit', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '_l2GasPerPubdataByteLimit', + type: 'uint256', + }, + { + internalType: 'bytes[]', + name: '_factoryDeps', + type: 'bytes[]', + }, + { + internalType: 'address', + name: '_refundRecipient', + type: 'address', + }, + ], + name: 'requestL2Transaction', + outputs: [ + { + internalType: 'bytes32', + name: 'canonicalTxHash', + type: 'bytes32', + }, + ], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: '_newLastBatch', + type: 'uint256', + }, + ], + name: 'revertBatches', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: '_chainId', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '_newLastBatch', + type: 'uint256', + }, + ], + name: 'revertBatchesSharedBridge', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_newPendingAdmin', + type: 'address', + }, + ], + name: 'setPendingAdmin', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bool', + name: '_zkPorterIsAvailable', + type: 'bool', + }, + ], + name: 'setPorterAvailability', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: '_newPriorityTxMaxGasLimit', + type: 'uint256', + }, + ], + name: 'setPriorityTxMaxGasLimit', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'enum PubdataPricingMode', + name: '_pricingMode', + type: 'uint8', + }, + ], + name: 'setPubdataPricingMode', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint128', + name: '_nominator', + type: 'uint128', + }, + { + internalType: 'uint128', + name: '_denominator', + type: 'uint128', + }, + ], + name: 'setTokenMultiplier', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_transactionFilterer', + type: 'address', + }, + ], + name: 'setTransactionFilterer', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_validator', + type: 'address', + }, + { + internalType: 'bool', + name: '_active', + type: 'bool', + }, + ], + name: 'setValidator', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: '_batchNumber', + type: 'uint256', + }, + ], + name: 'storedBatchHash', + outputs: [ + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'transferEthToSharedBridge', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'unfreezeDiamond', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: '_protocolVersion', + type: 'uint256', + }, + { + components: [ + { + components: [ + { + internalType: 'address', + name: 'facet', + type: 'address', + }, + { + internalType: 'enum Diamond.Action', + name: 'action', + type: 'uint8', + }, + { + internalType: 'bool', + name: 'isFreezable', + type: 'bool', + }, + { + internalType: 'bytes4[]', + name: 'selectors', + type: 'bytes4[]', + }, + ], + internalType: 'struct Diamond.FacetCut[]', + name: 'facetCuts', + type: 'tuple[]', + }, + { + internalType: 'address', + name: 'initAddress', + type: 'address', + }, + { + internalType: 'bytes', + name: 'initCalldata', + type: 'bytes', + }, + ], + internalType: 'struct Diamond.DiamondCutData', + name: '_cutData', + type: 'tuple', + }, + ], + name: 'upgradeChainFromVersion', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const; diff --git a/packages/agw-client/src/actions/getLinkedAccounts.ts b/packages/agw-client/src/actions/getLinkedAccounts.ts new file mode 100644 index 0000000..e18abdc --- /dev/null +++ b/packages/agw-client/src/actions/getLinkedAccounts.ts @@ -0,0 +1,78 @@ +import { + type Account, + type Address, + checksumAddress, + type Client, + getAddress, + InvalidAddressError, + isAddress, + type Transport, +} from 'viem'; +import { readContract } from 'viem/actions'; +import { getAction, parseAccount } from 'viem/utils'; +import { type ChainEIP712 } from 'viem/zksync'; + +import { ExclusiveDelegateResolverAbi } from '../abis/ExclusiveDelegateResolver.js'; +import { + AGW_LINK_DELEGATION_RIGHTS, + CANONICAL_EXCLUSIVE_DELEGATE_RESOLVER_ADDRESS, +} from '../constants.js'; +import { AccountNotFoundError } from '../errors/account.js'; + +export interface GetLinkedAccountsReturnType { + linkedAccounts: Address[]; +} + +export interface GetLinkedAccountsParameters { + agwAddress: Address; +} + +export interface IsLinkedAccountParameters { + address: Address; +} + +export async function getLinkedAccounts( + client: Client, + parameters: GetLinkedAccountsParameters, +): Promise { + const { agwAddress } = parameters; + + if (!isAddress(agwAddress, { strict: false })) { + throw new InvalidAddressError({ address: agwAddress }); + } + + const checksummedAddress = getAddress(agwAddress); + + const result = await getAction( + client, + readContract, + 'readContract', + )({ + abi: ExclusiveDelegateResolverAbi, + address: CANONICAL_EXCLUSIVE_DELEGATE_RESOLVER_ADDRESS, + functionName: 'delegatedWalletsByRights', + args: [checksummedAddress, AGW_LINK_DELEGATION_RIGHTS], + }); + + return { + linkedAccounts: [...result], + }; +} + +export async function isLinkedAccount( + client: Client, + parameters: IsLinkedAccountParameters, +): Promise { + const { address } = parameters; + if (!client.account) { + throw new AccountNotFoundError({ + docsPath: '/docs/contract/readContract', + }); + } + const clientAccount = parseAccount(client.account); + const { linkedAccounts } = await getLinkedAccounts(client, { + agwAddress: clientAccount.address, + }); + + return linkedAccounts.includes(checksumAddress(address)); +} diff --git a/packages/agw-client/src/actions/getLinkedAgw.ts b/packages/agw-client/src/actions/getLinkedAgw.ts new file mode 100644 index 0000000..20db95b --- /dev/null +++ b/packages/agw-client/src/actions/getLinkedAgw.ts @@ -0,0 +1,83 @@ +import { + type Account, + type Address, + type Client, + getAddress, + InvalidAddressError, + isAddress, + type Transport, +} from 'viem'; +import { readContract } from 'viem/actions'; +import { getAction, parseAccount } from 'viem/utils'; +import { type ChainEIP712 } from 'viem/zksync'; + +import { ExclusiveDelegateResolverAbi } from '../abis/ExclusiveDelegateResolver.js'; +import { + AGW_LINK_DELEGATION_RIGHTS, + CANONICAL_EXCLUSIVE_DELEGATE_RESOLVER_ADDRESS, +} from '../constants.js'; +import { AccountNotFoundError } from '../errors/account.js'; + +export interface GetLinkedAgwReturnType { + agw: Address | undefined; +} + +export interface GetLinkedAgwParameters { + address: Address; +} + +export interface IsLinkedAccountParameters { + address: Address; +} + +export async function getLinkedAgw( + client: Client, + parameters: GetLinkedAgwParameters, +): Promise { + const { address } = parameters; + + if (!isAddress(address, { strict: false })) { + throw new InvalidAddressError({ address }); + } + + const checksummedAddress = getAddress(address); + + const result = await getAction( + client, + readContract, + 'readContract', + )({ + abi: ExclusiveDelegateResolverAbi, + address: CANONICAL_EXCLUSIVE_DELEGATE_RESOLVER_ADDRESS, + functionName: 'exclusiveWalletByRights', + args: [checksummedAddress, AGW_LINK_DELEGATION_RIGHTS], + }); + + if (result === checksummedAddress) { + return { + agw: undefined, + }; + } + + return { + agw: result, + }; +} + +export async function isLinkedAccount( + client: Client, + parameters: IsLinkedAccountParameters, +): Promise { + const { address } = parameters; + + if (client.account === undefined) { + throw new AccountNotFoundError({ + docsPath: '/docs/contract/readContract', + }); + } + + const clientAccount = parseAccount(client.account); + + const { agw } = await getLinkedAgw(client, { address }); + return agw === clientAccount.address; +} diff --git a/packages/agw-client/src/actions/linkToAgw.ts b/packages/agw-client/src/actions/linkToAgw.ts new file mode 100644 index 0000000..5ed0624 --- /dev/null +++ b/packages/agw-client/src/actions/linkToAgw.ts @@ -0,0 +1,183 @@ +import { BaseError } from 'abitype'; +import { + type Account, + type Address, + type Chain, + createPublicClient, + decodeEventLog, + encodeFunctionData, + type Hash, + http, + type PublicClient, + type Transport, + type WalletClient, +} from 'viem'; +import { writeContract } from 'viem/actions'; +import { getAction, parseAccount } from 'viem/utils'; +import { publicActionsL2 } from 'viem/zksync'; + +import { BridgeHubAbi } from '../abis/BridgeHubAbi.js'; +import { DelegateRegistryAbi } from '../abis/DelegateRegistry.js'; +import { ZkSyncAbi } from '../abis/ZkSyncAbi.js'; +import { + BASE_GAS_PER_PUBDATA_BYTE, + BRIDGEHUB_ADDRESS, + CANONICAL_DELEGATE_REGISTRY_ADDRESS, + NON_EXPIRING_DELEGATION_RIGHTS, +} from '../constants.js'; +import { AccountNotFoundError } from '../errors/account.js'; +import { VALID_CHAINS } from '../utils.js'; + +export interface LinkToAgwParameters { + agwAddress: Address; + enabled: boolean; + l2Chain: Chain; + account?: Account; +} + +export interface LinkToAgwReturnType { + l1TransactionHash: Hash; + getL2TransactionHash: () => Promise; +} + +export async function linkToAgw( + client: WalletClient, + parameters: LinkToAgwParameters, +): Promise { + const { + account: account_ = client.account, + agwAddress, + enabled, + l2Chain, + } = parameters; + + if (!account_) + throw new AccountNotFoundError({ + docsPath: '/docs/contract/writeContract', + }); + const account = parseAccount(account_); + + if (!VALID_CHAINS[l2Chain.id]) { + throw new BaseError('Unsupported L2 Chain'); + } + + const bridgehubAddress = BRIDGEHUB_ADDRESS[l2Chain.id] as Address; + + const l1PublicClient = createPublicClient({ + chain: client.chain, + transport: http(), + }); + + const l2PublicClient = createPublicClient({ + chain: l2Chain, + transport: http(), + }).extend(publicActionsL2()); + + const l2Value = 0n; + const operatorTip = 0n; + + const l2Calldata = encodeFunctionData({ + abi: DelegateRegistryAbi, + functionName: 'delegateAll', + args: [agwAddress, NON_EXPIRING_DELEGATION_RIGHTS, enabled], + }); + + const l2GasLimit = await l2PublicClient.estimateGasL1ToL2({ + chain: l2PublicClient.chain, + account: account.address, + to: CANONICAL_DELEGATE_REGISTRY_ADDRESS, + data: l2Calldata, + value: 0n, + }); + + const baseFee = await l1PublicClient.getGasPrice(); + const maxPriorityFeePerGas = + await l1PublicClient.estimateMaxPriorityFeePerGas(); + const maxFeePerGas = (baseFee * 3n) / 2n + maxPriorityFeePerGas; + const gasPriceForEstimation = maxFeePerGas; + + const baseCost = await l1PublicClient.readContract({ + address: bridgehubAddress, + abi: BridgeHubAbi, + functionName: 'l2TransactionBaseCost', + args: [ + BigInt(l2PublicClient.chain.id), + gasPriceForEstimation, + l2GasLimit, + BASE_GAS_PER_PUBDATA_BYTE, + ], + }); + + const l2Costs = baseCost + operatorTip + l2Value; + const providedValue = l2Costs; + + if (baseCost > providedValue) { + console.error('Base cost is greater than provided value'); + } + + const bridgeArgs = { + chainId: BigInt(l2PublicClient.chain.id), + mintValue: providedValue, + l2Contract: CANONICAL_DELEGATE_REGISTRY_ADDRESS, + l2Value, + l2Calldata, + l2GasLimit, + l2GasPerPubdataByteLimit: BASE_GAS_PER_PUBDATA_BYTE, + factoryDeps: [], + refundRecipient: agwAddress, + } as const; + + const l1TransactionHash = await getAction( + client, + writeContract, + 'writeContract', + )({ + abi: BridgeHubAbi, + address: bridgehubAddress, + chain: client.chain, + account, + functionName: 'requestL2TransactionDirect', + value: providedValue, + args: [bridgeArgs], + maxFeePerGas, + maxPriorityFeePerGas, + }); + + return { + l1TransactionHash, + getL2TransactionHash: async () => + getL2HashFromPriorityOp(l1PublicClient, l1TransactionHash), + }; +} + +async function getL2HashFromPriorityOp( + publicClient: PublicClient, + l1TransactionHash: Hash, +): Promise { + const receipt = await publicClient.waitForTransactionReceipt({ + hash: l1TransactionHash, + }); + if (receipt.status !== 'success') { + throw new BaseError('L1 transaction failed'); + } + let hash: Hash | undefined; + for (const log of receipt.logs) { + try { + const priorityQueueLog = decodeEventLog({ + abi: ZkSyncAbi, + data: log.data, + topics: log.topics, + strict: false, + }); + if (priorityQueueLog && (priorityQueueLog.args as any).txHash !== null) + hash = (priorityQueueLog.args as any).txHash; + } catch (_e) { + // Usually gets here if one of the events is not in the abi which is ok + } + } + + if (!hash) { + throw new BaseError('Error getting L2 hash from L1 transaction'); + } + return hash; +} diff --git a/packages/agw-client/src/constants.ts b/packages/agw-client/src/constants.ts index 3b49a3d..89dfa52 100644 --- a/packages/agw-client/src/constants.ts +++ b/packages/agw-client/src/constants.ts @@ -1,3 +1,6 @@ +import type { Address } from 'viem'; +import { abstractTestnet } from 'viem/chains'; + // AA smart contract deployment const SMART_ACCOUNT_FACTORY_ADDRESS = '0x9B947df68D35281C972511B3E7BC875926f26C1A' as const; @@ -16,11 +19,35 @@ const AGW_REGISTRY_ADDRESS = const INSUFFICIENT_BALANCE_SELECTOR = '0xe7931438' as const; +const CANONICAL_DELEGATE_REGISTRY_ADDRESS = + '0x0000000059A24EB229eED07Ac44229DB56C5d797'; + +const CANONICAL_EXCLUSIVE_DELEGATE_RESOLVER_ADDRESS = + '0x0000000078CC4Cc1C14E27c0fa35ED6E5E58825D'; + +const AGW_LINK_DELEGATION_RIGHTS = + '0xc10dcfe266c1f71ef476efbd3223555750dc271e4115626b'; + +const NON_EXPIRING_DELEGATION_RIGHTS = `${AGW_LINK_DELEGATION_RIGHTS}000000ffffffffff`; + +const BASE_GAS_PER_PUBDATA_BYTE = 800n; + +const BRIDGEHUB_ADDRESS: Record = { + [abstractTestnet.id]: '0x35A54c8C757806eB6820629bc82d90E056394C92', + [2741]: '0x303a465b659cbb0ab36ee643ea362c509eeb5213', +}; + export { + AGW_LINK_DELEGATION_RIGHTS, AGW_REGISTRY_ADDRESS, + BASE_GAS_PER_PUBDATA_BYTE, + BRIDGEHUB_ADDRESS, + CANONICAL_DELEGATE_REGISTRY_ADDRESS, + CANONICAL_EXCLUSIVE_DELEGATE_RESOLVER_ADDRESS, CONTRACT_DEPLOYER_ADDRESS, EOA_VALIDATOR_ADDRESS, INSUFFICIENT_BALANCE_SELECTOR, + NON_EXPIRING_DELEGATION_RIGHTS, SESSION_KEY_VALIDATOR_ADDRESS, SMART_ACCOUNT_FACTORY_ADDRESS, }; diff --git a/packages/agw-client/src/exports/constants.ts b/packages/agw-client/src/exports/constants.ts index 8b27eae..039d8df 100644 --- a/packages/agw-client/src/exports/constants.ts +++ b/packages/agw-client/src/exports/constants.ts @@ -1,6 +1,9 @@ import AGWAccountAbi from '../abis/AGWAccount.js'; import { AGW_REGISTRY_ADDRESS, + BRIDGEHUB_ADDRESS, + CANONICAL_DELEGATE_REGISTRY_ADDRESS, + CANONICAL_EXCLUSIVE_DELEGATE_RESOLVER_ADDRESS, EOA_VALIDATOR_ADDRESS, SESSION_KEY_VALIDATOR_ADDRESS, SMART_ACCOUNT_FACTORY_ADDRESS, @@ -9,6 +12,9 @@ import { export { AGWAccountAbi as AGWAccountAbi, AGW_REGISTRY_ADDRESS as agwRegistryAddress, + BRIDGEHUB_ADDRESS as bridgehubAddress, + CANONICAL_DELEGATE_REGISTRY_ADDRESS as delegateRegistryAddress, + CANONICAL_EXCLUSIVE_DELEGATE_RESOLVER_ADDRESS as exclusiveDelegateResolverAddress, SESSION_KEY_VALIDATOR_ADDRESS as sessionKeyValidatorAddress, SMART_ACCOUNT_FACTORY_ADDRESS as smartAccountFactoryAddress, EOA_VALIDATOR_ADDRESS as validatorAddress, diff --git a/packages/agw-client/src/exports/index.ts b/packages/agw-client/src/exports/index.ts index dd904b2..ee0e066 100644 --- a/packages/agw-client/src/exports/index.ts +++ b/packages/agw-client/src/exports/index.ts @@ -9,3 +9,7 @@ export { isAGWAccount, VALID_CHAINS as validChains, } from '../utils.js'; +export { + linkablePublicActions, + linkableWalletActions, +} from '../walletActions.js'; diff --git a/packages/agw-client/src/walletActions.ts b/packages/agw-client/src/walletActions.ts index 30defed..63d3885 100644 --- a/packages/agw-client/src/walletActions.ts +++ b/packages/agw-client/src/walletActions.ts @@ -18,6 +18,7 @@ import { type WalletClient, type WriteContractParameters, } from 'viem'; +import { parseAccount } from 'viem/accounts'; import { getChainId } from 'viem/actions'; import { type ChainEIP712, @@ -33,6 +34,23 @@ import { type CreateSessionReturnType, } from './actions/createSession.js'; import { deployContract } from './actions/deployContract.js'; +import { + getLinkedAccounts, + type GetLinkedAccountsParameters, + type GetLinkedAccountsReturnType, +} from './actions/getLinkedAccounts.js'; +import { + getLinkedAgw, + type GetLinkedAgwParameters, + type GetLinkedAgwReturnType, + isLinkedAccount, + type IsLinkedAccountParameters, +} from './actions/getLinkedAgw.js'; +import { + linkToAgw, + type LinkToAgwParameters, + type LinkToAgwReturnType, +} from './actions/linkToAgw.js'; import { prepareTransactionRequest, type PrepareTransactionRequestParameters, @@ -63,6 +81,10 @@ export type AbstractWalletActions< account extends Account | undefined = Account | undefined, > = Eip712WalletActions & { getChainId: () => Promise; + getLinkedAccounts: ( + args: GetLinkedAccountsParameters, + ) => Promise; + isLinkedAccount: (args: IsLinkedAccountParameters) => Promise; createSession: ( args: CreateSessionParameters, ) => Promise; @@ -120,6 +142,20 @@ export type SessionClientActions< writeContract: WalletActions['writeContract']; }; +export interface LinkableWalletActions { + linkToAgw: (args: LinkToAgwParameters) => Promise; + getLinkedAgw: () => Promise; +} + +export interface LinkablePublicActions { + getLinkedAgw: ( + args: GetLinkedAgwParameters, + ) => Promise; + getLinkedAccounts: ( + args: GetLinkedAccountsParameters, + ) => Promise; +} + export function sessionWalletActions( signerClient: WalletClient, publicClient: PublicClient, @@ -159,6 +195,8 @@ export function globalWalletActions< client: Client, ): AbstractWalletActions => ({ getChainId: () => getChainId(client), + getLinkedAccounts: (args) => getLinkedAccounts(client, args), + isLinkedAccount: (args) => isLinkedAccount(client, args), createSession: (args) => createSession(client, publicClient, args), revokeSessions: (args) => revokeSessions(client, args), prepareAbstractTransactionRequest: (args) => @@ -230,3 +268,22 @@ export function globalWalletActions< }), }); } + +export function linkableWalletActions() { + return ( + client: WalletClient, + ): LinkableWalletActions => ({ + linkToAgw: (args) => linkToAgw(client, args), + getLinkedAgw: () => + getLinkedAgw(client, { address: parseAccount(client.account).address }), + }); +} + +export function linkablePublicActions() { + return ( + client: Client, + ): LinkablePublicActions => ({ + getLinkedAgw: (args) => getLinkedAgw(client, args), + getLinkedAccounts: (args) => getLinkedAccounts(client, args), + }); +}