Skip to content

Commit

Permalink
Add pausing integration (#413)
Browse files Browse the repository at this point in the history
  • Loading branch information
WuBruno authored Feb 6, 2024
1 parent 8532f20 commit 12806f5
Show file tree
Hide file tree
Showing 2 changed files with 204 additions and 1 deletion.
25 changes: 25 additions & 0 deletions products/bridge/bridge-web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -191,6 +197,7 @@ function App() {
hasValidAddress &&
hasEnoughAllowance &&
hasEnoughBalance &&
!paused &&
(fromChainConfig.isZilliqa
? !isLoadingBridgeFromZilliqa
: !isLoadingBridge);
Expand Down Expand Up @@ -575,6 +582,24 @@ function App() {
</button>
)}
</div>
{paused && (
<div role="alert" className="alert alert-warning mt-3">
<svg
xmlns="http://www.w3.org/2000/svg"
className="stroke-current shrink-0 h-6 w-6"
fill="none"
viewBox="0 0 24 24"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
/>
</svg>
<span>Warning: bridge is currently under maintenance.</span>
</div>
)}
</div>
</div>
</div>
Expand Down
180 changes: 179 additions & 1 deletion products/bridge/bridge-web/src/abi/TokenManager.ts
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -64,13 +71,34 @@ export const tokenManagerAbi = [
],
stateMutability: "view",
},
{
type: "function",
name: "owner",
inputs: [],
outputs: [{ name: "", type: "address", internalType: "address" }],
stateMutability: "view",
},
{
type: "function",
name: "pause",
inputs: [],
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",
Expand All @@ -94,6 +122,13 @@ export const tokenManagerAbi = [
outputs: [],
stateMutability: "nonpayable",
},
{
type: "function",
name: "renounceOwnership",
inputs: [],
outputs: [],
stateMutability: "nonpayable",
},
{
type: "function",
name: "setFees",
Expand Down Expand Up @@ -128,13 +163,34 @@ export const tokenManagerAbi = [
outputs: [],
stateMutability: "payable",
},
{
type: "function",
name: "transferOwnership",
inputs: [{ name: "newOwner", type: "address", internalType: "address" }],
outputs: [],
stateMutability: "nonpayable",
},
{
type: "function",
name: "unpause",
inputs: [],
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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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;

0 comments on commit 12806f5

Please sign in to comment.