From 12806f5998fff429844fb016414a6d4e943d56ec Mon Sep 17 00:00:00 2001 From: Bruno Wu Date: Tue, 6 Feb 2024 17:34:30 +0000 Subject: [PATCH] Add pausing integration (#413) --- products/bridge/bridge-web/src/App.tsx | 25 +++ .../bridge/bridge-web/src/abi/TokenManager.ts | 180 +++++++++++++++++- 2 files changed, 204 insertions(+), 1 deletion(-) diff --git a/products/bridge/bridge-web/src/App.tsx b/products/bridge/bridge-web/src/App.tsx index 7f848792e..4ea9acf37 100644 --- a/products/bridge/bridge-web/src/App.tsx +++ b/products/bridge/bridge-web/src/App.tsx @@ -88,6 +88,12 @@ function App() { address: fromChainConfig.tokenManagerAddress, enabled: !!fromChainConfig.tokenManagerAddress, }); + const { data: paused } = useContractRead({ + abi: tokenManagerAbi, + functionName: "paused", + address: fromChainConfig.tokenManagerAddress, + enabled: !!fromChainConfig.tokenManagerAddress, + }); const { data: balance } = useContractRead({ abi: erc20ABI, functionName: "balanceOf", @@ -191,6 +197,7 @@ function App() { hasValidAddress && hasEnoughAllowance && hasEnoughBalance && + !paused && (fromChainConfig.isZilliqa ? !isLoadingBridgeFromZilliqa : !isLoadingBridge); @@ -575,6 +582,24 @@ function App() { )} + {paused && ( +
+ + + + Warning: bridge is currently under maintenance. +
+ )} diff --git a/products/bridge/bridge-web/src/abi/TokenManager.ts b/products/bridge/bridge-web/src/abi/TokenManager.ts index d0f966959..658c9a299 100644 --- a/products/bridge/bridge-web/src/abi/TokenManager.ts +++ b/products/bridge/bridge-web/src/abi/TokenManager.ts @@ -1,4 +1,11 @@ export const tokenManagerAbi = [ + { + type: "function", + name: "UPGRADE_INTERFACE_VERSION", + inputs: [], + outputs: [{ name: "", type: "string", internalType: "string" }], + stateMutability: "view", + }, { type: "function", name: "accept", @@ -16,7 +23,7 @@ export const tokenManagerAbi = [ { name: "sender", type: "address", internalType: "address" }, ], }, - { name: "args", type: "bytes", internalType: "bytes" }, + { name: "_args", type: "bytes", internalType: "bytes" }, ], outputs: [], stateMutability: "nonpayable", @@ -64,6 +71,13 @@ export const tokenManagerAbi = [ ], stateMutability: "view", }, + { + type: "function", + name: "owner", + inputs: [], + outputs: [{ name: "", type: "address", internalType: "address" }], + stateMutability: "view", + }, { type: "function", name: "pause", @@ -71,6 +85,20 @@ export const tokenManagerAbi = [ outputs: [], stateMutability: "nonpayable", }, + { + type: "function", + name: "paused", + inputs: [], + outputs: [{ name: "", type: "bool", internalType: "bool" }], + stateMutability: "view", + }, + { + type: "function", + name: "proxiableUUID", + inputs: [], + outputs: [{ name: "", type: "bytes32", internalType: "bytes32" }], + stateMutability: "view", + }, { type: "function", name: "registerToken", @@ -94,6 +122,13 @@ export const tokenManagerAbi = [ outputs: [], stateMutability: "nonpayable", }, + { + type: "function", + name: "renounceOwnership", + inputs: [], + outputs: [], + stateMutability: "nonpayable", + }, { type: "function", name: "setFees", @@ -128,6 +163,13 @@ export const tokenManagerAbi = [ outputs: [], stateMutability: "payable", }, + { + type: "function", + name: "transferOwnership", + inputs: [{ name: "newOwner", type: "address", internalType: "address" }], + outputs: [], + stateMutability: "nonpayable", + }, { type: "function", name: "unpause", @@ -135,6 +177,20 @@ export const tokenManagerAbi = [ outputs: [], stateMutability: "nonpayable", }, + { + type: "function", + name: "upgradeToAndCall", + inputs: [ + { + name: "newImplementation", + type: "address", + internalType: "address", + }, + { name: "data", type: "bytes", internalType: "bytes" }, + ], + outputs: [], + stateMutability: "payable", + }, { type: "function", name: "withdrawFees", @@ -161,6 +217,64 @@ export const tokenManagerAbi = [ ], anonymous: false, }, + { + type: "event", + name: "FeesWithdrawn", + inputs: [ + { + name: "amount", + type: "uint256", + indexed: false, + internalType: "uint256", + }, + ], + anonymous: false, + }, + { + type: "event", + name: "Initialized", + inputs: [ + { + name: "version", + type: "uint64", + indexed: false, + internalType: "uint64", + }, + ], + anonymous: false, + }, + { + type: "event", + name: "OwnershipTransferred", + inputs: [ + { + name: "previousOwner", + type: "address", + indexed: true, + internalType: "address", + }, + { + name: "newOwner", + type: "address", + indexed: true, + internalType: "address", + }, + ], + anonymous: false, + }, + { + type: "event", + name: "Paused", + inputs: [ + { + name: "account", + type: "address", + indexed: false, + internalType: "address", + }, + ], + anonymous: false, + }, { type: "event", name: "TokenRegistered", @@ -211,6 +325,52 @@ export const tokenManagerAbi = [ ], anonymous: false, }, + { + type: "event", + name: "Unpaused", + inputs: [ + { + name: "account", + type: "address", + indexed: false, + internalType: "address", + }, + ], + anonymous: false, + }, + { + type: "event", + name: "Upgraded", + inputs: [ + { + name: "implementation", + type: "address", + indexed: true, + internalType: "address", + }, + ], + anonymous: false, + }, + { + type: "error", + name: "AddressEmptyCode", + inputs: [{ name: "target", type: "address", internalType: "address" }], + }, + { + type: "error", + name: "ERC1967InvalidImplementation", + inputs: [ + { + name: "implementation", + type: "address", + internalType: "address", + }, + ], + }, + { type: "error", name: "ERC1967NonPayable", inputs: [] }, + { type: "error", name: "EnforcedPause", inputs: [] }, + { type: "error", name: "ExpectedPause", inputs: [] }, + { type: "error", name: "FailedInnerCall", inputs: [] }, { type: "error", name: "InsufficientFees", @@ -219,7 +379,25 @@ export const tokenManagerAbi = [ { name: "expected", type: "uint256", internalType: "uint256" }, ], }, + { type: "error", name: "InvalidInitialization", inputs: [] }, { type: "error", name: "InvalidSourceChainId", inputs: [] }, { type: "error", name: "InvalidTokenManager", inputs: [] }, { type: "error", name: "NotGateway", inputs: [] }, + { type: "error", name: "NotInitializing", inputs: [] }, + { + type: "error", + name: "OwnableInvalidOwner", + inputs: [{ name: "owner", type: "address", internalType: "address" }], + }, + { + type: "error", + name: "OwnableUnauthorizedAccount", + inputs: [{ name: "account", type: "address", internalType: "address" }], + }, + { type: "error", name: "UUPSUnauthorizedCallContext", inputs: [] }, + { + type: "error", + name: "UUPSUnsupportedProxiableUUID", + inputs: [{ name: "slot", type: "bytes32", internalType: "bytes32" }], + }, ] as const;