diff --git a/.eslintignore b/.eslintignore
index 18115e8..3dd49f8 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -2,3 +2,4 @@ node_modules
.yarn
build
dist
+**/*.generated.*
\ No newline at end of file
diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index 5752d50..f9731c8 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -49,8 +49,8 @@ jobs:
echo "::set-output name=enable_demo_features::false"
else
echo "::set-output name=app_env::dev"
- echo "::set-output name=testnet_squid_api_url::https://subsquid.squids.live/subsquid-network-testnet/v/v3/graphql"
- echo "::set-output name=mainnet_squid_api_url::https://subsquid.squids.live/subsquid-network-mainnet/v/v3/graphql"
+ echo "::set-output name=testnet_squid_api_url::https://subsquid.squids.live/subsquid-network-testnet/v/v5/graphql"
+ echo "::set-output name=mainnet_squid_api_url::https://subsquid.squids.live/subsquid-network-mainnet/v/v5/graphql"
echo "::set-output name=enable_demo_features::true"
fi
if [ "$NETWORK" = "mainnet" ]; then
diff --git a/src/api/subsquid-network-squid/graphql.config.ts b/graphql.config.ts
similarity index 81%
rename from src/api/subsquid-network-squid/graphql.config.ts
rename to graphql.config.ts
index 93c2878..199c1ed 100644
--- a/src/api/subsquid-network-squid/graphql.config.ts
+++ b/graphql.config.ts
@@ -6,8 +6,9 @@ import { CodegenConfig } from '@graphql-codegen/cli';
export default {
overwrite: true,
schema:
- process.env.SQUID_API_URL || 'https://subsquid.squids.live/subsquid-network-mainnet/graphql',
- documents: ['src/api/subsquid-network-squid/*.graphql'],
+ process.env.SQUID_API_URL ||
+ 'https://subsquid.squids.live/subsquid-network-testnet/v/v5/graphql',
+ documents: ['src/api/subsquid-network-squid/schema.graphql'],
hooks: {
afterOneFileWrite: ['prettier --write'],
},
diff --git a/package.json b/package.json
index 7130a99..8d1b51a 100644
--- a/package.json
+++ b/package.json
@@ -13,7 +13,7 @@
"preview": "vite preview --outDir build --host 127.0.0.1 --port 3005",
"upg": "yarn upgrade-interactive",
"prepare": "husky install",
- "codegen": "graphql-codegen --config src/api/subsquid-network-squid/graphql.config.ts"
+ "codegen": "graphql-codegen --config graphql.config.ts"
},
"lint-staged": {
"src/**/*.{js,jsx,ts,tsx}": "eslint --cache --fix"
@@ -39,11 +39,11 @@
"graphql": "^16.9.0",
"lodash-es": "^4.17.21",
"material-ui-popup-state": "^5.1.2",
- "notistack": "^3.0.1",
"pretty-bytes": "^6.1.1",
"qs": "^6.12.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
+ "react-hot-toast": "^2.4.1",
"react-router-dom": "^6.24.0",
"react-scroll": "^1.9.0",
"react-syntax-highlighter": "^15.5.0",
@@ -52,8 +52,8 @@
"use-debounce": "^10.0.1",
"use-element-position": "^1.0.13",
"use-local-storage-state": "^19.3.1",
- "viem": "^2.16.5",
- "wagmi": "^2.10.8",
+ "viem": "^2.21.25",
+ "wagmi": "^2.12.17",
"yup": "^1.4.0"
},
"devDependencies": {
@@ -76,6 +76,7 @@
"@typescript-eslint/eslint-plugin": "^7.14.1",
"@typescript-eslint/parser": "^7.14.1",
"@vitejs/plugin-react": "^4.3.1",
+ "@wagmi/cli": "^2.1.16",
"dotenv": "^16.4.5",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
@@ -90,8 +91,8 @@
"husky": "^9.0.11",
"lint-staged": "^15.2.7",
"prettier": "^3.3.2",
- "type-fest": "^4.20.1",
- "typescript": "^5.5.2",
+ "type-fest": "^4.26.1",
+ "typescript": "^5.6.3",
"vite": "^5.4.2",
"vite-plugin-html": "^3.2.2",
"vite-plugin-html-env": "^1.2.8",
diff --git a/src/App.tsx b/src/App.tsx
index 6d98fc8..e53430f 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -3,14 +3,14 @@ import React from 'react';
import { CssBaseline, ThemeProvider } from '@mui/material';
import { RainbowKitProvider } from '@rainbow-me/rainbowkit';
import { QueryClientProvider } from '@tanstack/react-query';
-import { SnackbarProvider } from 'notistack';
import { BrowserRouter } from 'react-router-dom';
import { WagmiProvider } from 'wagmi';
import { queryClient } from '@api/client';
-import { Alert } from '@components/Alert';
+import { Toaster } from '@components/Toaster';
import { SquidHeightProvider } from '@hooks/useSquidNetworkHeightHooks';
-import { wagmiConfig } from '@network/config';
+import { rainbowConfig } from '@network/config';
+import { getChainId, getSubsquidNetwork } from '@network/useSubsquidNetwork';
import { AppRoutes } from './AppRoutes';
import { useCreateRainbowKitTheme, useCreateTheme, useThemeState } from './theme';
@@ -19,32 +19,31 @@ function App() {
const [themeName] = useThemeState();
const theme = useCreateTheme(themeName);
const rainbowkitTheme = useCreateRainbowKitTheme(themeName);
+ const network = getSubsquidNetwork();
return (
-
-
-
+ <>
+
+
-
-
+
+
-
+
+ {/* */}
+
-
-
-
+
+
+ >
);
}
diff --git a/src/AppRoutes.tsx b/src/AppRoutes.tsx
index 82a238d..6ee64f9 100644
--- a/src/AppRoutes.tsx
+++ b/src/AppRoutes.tsx
@@ -7,12 +7,9 @@ import { AssetsPage } from '@pages/AssetsPage/AssetsPage.tsx';
import { Vesting } from '@pages/AssetsPage/Vesting.tsx';
import { DashboardPage } from '@pages/DashboardPage/DashboardPage.tsx';
import { DelegationsPage } from '@pages/DelegationsPage/DelegationsPage.tsx';
-import { AddNewGateway } from '@pages/GatewaysPage/AddNewGateway.tsx';
import { Gateway } from '@pages/GatewaysPage/Gateway.tsx';
import { GatewaysPage } from '@pages/GatewaysPage/GatewaysPage.tsx';
-import { AddNewWorker } from '@pages/WorkersPage/AddNewWorker.tsx';
import { Worker } from '@pages/WorkersPage/Worker.tsx';
-import { WorkerEdit } from '@pages/WorkersPage/WorkerEdit.tsx';
import { WorkersPage } from '@pages/WorkersPage/WorkersPage.tsx';
import { hideLoader } from './index.tsx';
@@ -35,18 +32,17 @@ export const AppRoutes = () => {
} index />
- } path="add" />
+ {/* } path="add" /> */}
} path=":peerId" />
- } path=":peerId/edit" />
} index />
-
+
} index />
- } path="add" />
- } path=":peerId" />
+ } path=":peerId" />
+ } />
} path="*" />
diff --git a/src/api/contracts/claim.ts b/src/api/contracts/claim.ts
deleted file mode 100644
index fb04248..0000000
--- a/src/api/contracts/claim.ts
+++ /dev/null
@@ -1,105 +0,0 @@
-import { useState } from 'react';
-
-import { encodeFunctionData } from 'viem';
-import { waitForTransactionReceipt } from 'viem/actions';
-import { useWriteContract, useClient } from 'wagmi';
-
-import { REWARD_TREASURY_CONTRACT_ABI } from '@api/contracts/reaward-treasury.abi';
-import { VESTING_CONTRACT_ABI } from '@api/contracts/vesting.abi';
-import { AccountType, SourceWallet } from '@api/subsquid-network-squid';
-import { useSquidNetworkHeight } from '@hooks/useSquidNetworkHeightHooks';
-import { useAccount } from '@network/useAccount.ts';
-import { useContracts } from '@network/useContracts.ts';
-
-import { TxResult, errorMessage, WriteContractRes } from './utils';
-
-export type ClaimRequest = {
- wallet: SourceWallet;
-};
-
-function useClaimFromWallet() {
- const contracts = useContracts();
- const { writeContractAsync } = useWriteContract({});
-
- return async ({ wallet }: ClaimRequest): Promise => {
- try {
- return {
- tx: await writeContractAsync({
- address: contracts.REWARD_TREASURY,
- abi: REWARD_TREASURY_CONTRACT_ABI,
- functionName: 'claimFor',
- args: [contracts.REWARD_DISTRIBUTION, wallet.id as `0x${string}`],
- }),
- };
- } catch (e) {
- return { error: errorMessage(e) };
- }
- };
-}
-
-function useClaimFromVestingContract() {
- const contracts = useContracts();
- const { address: account } = useAccount();
- const { writeContractAsync } = useWriteContract({});
-
- return async ({ wallet }: ClaimRequest): Promise => {
- try {
- const data = encodeFunctionData({
- abi: REWARD_TREASURY_CONTRACT_ABI,
- functionName: 'claimFor',
- args: [contracts.REWARD_DISTRIBUTION, account as `0x${string}`],
- });
-
- return {
- tx: await writeContractAsync({
- account,
- address: wallet.id as `0x${string}`,
- abi: VESTING_CONTRACT_ABI,
- functionName: 'execute',
- args: [contracts.REWARD_TREASURY, data],
- }),
- };
- } catch (e: unknown) {
- return { error: errorMessage(e) };
- }
- };
-}
-
-export function useClaim() {
- const client = useClient();
- const { setWaitHeight } = useSquidNetworkHeight();
- const [isPending, setLoading] = useState(false);
- const [error, setError] = useState(null);
-
- const claimFromWallet = useClaimFromWallet();
- const claimFromVestingContract = useClaimFromVestingContract();
-
- const claim = async ({ wallet }: ClaimRequest): Promise => {
- setLoading(true);
-
- const res =
- wallet.type === AccountType.User
- ? await claimFromWallet({ wallet })
- : await claimFromVestingContract({ wallet });
-
- if (!res.tx) {
- setLoading(false);
- setError(res.error);
-
- return { success: false, failedReason: res.error };
- }
-
- const receipt = await waitForTransactionReceipt(client!, { hash: res.tx });
- setWaitHeight(receipt.blockNumber, []);
-
- setLoading(false);
-
- return { success: true };
- };
-
- return {
- claim,
- isPending,
- error,
- };
-}
diff --git a/src/api/contracts/gateway-registration/GatewayRegistration.abi.ts b/src/api/contracts/gateway-registration/GatewayRegistration.abi.ts
deleted file mode 100644
index 123451e..0000000
--- a/src/api/contracts/gateway-registration/GatewayRegistration.abi.ts
+++ /dev/null
@@ -1,105 +0,0 @@
-export const GATEWAY_REGISTRATION_CONTRACT_ABI = [
- {
- type: 'function',
- name: 'register',
- inputs: [
- {
- name: 'peerId',
- type: 'bytes',
- internalType: 'bytes',
- },
- {
- name: 'metadata',
- type: 'string',
- internalType: 'string',
- },
- ],
- outputs: [],
- stateMutability: 'nonpayable',
- },
- {
- type: 'function',
- name: 'setMetadata',
- inputs: [
- {
- name: 'peerId',
- type: 'bytes',
- internalType: 'bytes',
- },
- {
- name: 'metadata',
- type: 'string',
- internalType: 'string',
- },
- ],
- outputs: [],
- stateMutability: 'nonpayable',
- },
- {
- type: 'function',
- name: 'stake',
- inputs: [
- {
- name: 'amount',
- type: 'uint256',
- internalType: 'uint256',
- },
- {
- name: 'durationBlocks',
- type: 'uint128',
- internalType: 'uint128',
- },
- {
- name: 'withAutoExtension',
- type: 'bool',
- internalType: 'bool',
- },
- ],
- outputs: [],
- stateMutability: 'nonpayable',
- },
- {
- type: 'function',
- name: 'unregister',
- inputs: [
- {
- name: 'peerId',
- type: 'bytes',
- internalType: 'bytes',
- },
- ],
- outputs: [],
- stateMutability: 'nonpayable',
- },
- {
- type: 'function',
- name: 'unstake',
- inputs: [],
- outputs: [],
- stateMutability: 'nonpayable',
- },
- {
- type: 'function',
- name: 'computationUnitsAmount',
- inputs: [
- {
- name: 'amount',
- type: 'uint256',
- internalType: 'uint256',
- },
- {
- name: 'durationBlocks',
- type: 'uint256',
- internalType: 'uint256',
- },
- ],
- outputs: [
- {
- name: '',
- type: 'uint256',
- internalType: 'uint256',
- },
- ],
- stateMutability: 'view',
- },
-] as const;
diff --git a/src/api/contracts/gateway-registration/useComputationUnits.ts b/src/api/contracts/gateway-registration/useComputationUnits.ts
deleted file mode 100644
index 8a50a88..0000000
--- a/src/api/contracts/gateway-registration/useComputationUnits.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import { useReadContract } from 'wagmi';
-
-import { useContracts } from '@network/useContracts';
-
-import { GATEWAY_REGISTRATION_CONTRACT_ABI } from './GatewayRegistration.abi';
-
-export function useComputationUnits({
- amount,
- lockDuration,
-}: {
- amount: string;
- lockDuration: number;
-}) {
- const contracts = useContracts();
-
- const { data, isLoading, isPending } = useReadContract({
- address: contracts.GATEWAY_REGISTRATION,
- abi: GATEWAY_REGISTRATION_CONTRACT_ABI,
- functionName: 'computationUnitsAmount',
- args: [BigInt(amount), BigInt(lockDuration)],
- });
-
- return {
- data: data?.toString(),
- isLoading,
- isPending,
- };
-}
diff --git a/src/api/contracts/gateway-registration/useRegisterGateway.ts b/src/api/contracts/gateway-registration/useRegisterGateway.ts
deleted file mode 100644
index 24a89ab..0000000
--- a/src/api/contracts/gateway-registration/useRegisterGateway.ts
+++ /dev/null
@@ -1,117 +0,0 @@
-import { useState } from 'react';
-
-import { peerIdToHex } from '@lib/network';
-import { logger } from '@logger';
-import { encodeFunctionData } from 'viem';
-import { usePublicClient, useWriteContract } from 'wagmi';
-
-import { AccountType } from '@api/subsquid-network-squid';
-import { useSquidNetworkHeight } from '@hooks/useSquidNetworkHeightHooks';
-import { useAccount } from '@network/useAccount';
-import { useContracts } from '@network/useContracts.ts';
-
-import { TxResult, errorMessage, WriteContractRes } from '../utils';
-import { VESTING_CONTRACT_ABI } from '../vesting.abi';
-
-import { encodeGatewayMetadata, GetawayMetadata } from './GatewayMetadata';
-import { GATEWAY_REGISTRATION_CONTRACT_ABI } from './GatewayRegistration.abi';
-
-export interface RegisterGatewayRequest extends GetawayMetadata {
- peerId: string;
- source: {
- id: string;
- type: AccountType;
- };
-}
-
-function useRegisterGatewayFromWallet() {
- const contracts = useContracts();
- const { writeContractAsync } = useWriteContract({});
-
- return async ({ peerId, ...rest }: RegisterGatewayRequest): Promise => {
- logger.debug(`registering gateway via worker contract...`);
-
- try {
- return {
- tx: await writeContractAsync({
- address: contracts.GATEWAY_REGISTRATION,
- abi: GATEWAY_REGISTRATION_CONTRACT_ABI,
- functionName: 'register',
- args: [peerIdToHex(peerId), encodeGatewayMetadata(rest)],
- }),
- };
- } catch (e: unknown) {
- return {
- error: errorMessage(e),
- };
- }
- };
-}
-
-function useRegisterGatewayFromVestingContract() {
- const contracts = useContracts();
- const { address: account } = useAccount();
- const { writeContractAsync } = useWriteContract({});
-
- return async ({ peerId, source, ...rest }: RegisterGatewayRequest): Promise => {
- try {
- const data = encodeFunctionData({
- abi: GATEWAY_REGISTRATION_CONTRACT_ABI,
- functionName: 'register',
- args: [peerIdToHex(peerId), encodeGatewayMetadata(rest)], // encodeMetadata(rest)
- });
-
- return {
- tx: await writeContractAsync({
- account,
- address: source.id as `0x${string}`,
- abi: VESTING_CONTRACT_ABI,
- functionName: 'execute',
- args: [contracts.GATEWAY_REGISTRATION, data],
- }),
- };
- } catch (e: unknown) {
- return { error: errorMessage(e) };
- }
- };
-}
-
-export function useRegisterGateway() {
- const client = usePublicClient();
- const { address } = useAccount();
- const [error, setError] = useState(null);
- const [isLoading, setLoading] = useState(false);
-
- const { setWaitHeight } = useSquidNetworkHeight();
- const registerGatewayFromWallet = useRegisterGatewayFromWallet();
- const registerGatewayFromVestingContract = useRegisterGatewayFromVestingContract();
-
- const registerGateway = async (req: RegisterGatewayRequest): Promise => {
- setLoading(true);
-
- const { tx, error } =
- req.source.type === AccountType.User
- ? await registerGatewayFromWallet(req)
- : await registerGatewayFromVestingContract(req);
-
- if (!tx) {
- logger.debug(`registering gateway failed ${error}`);
- setLoading(false);
- setError(error);
- return { success: false, failedReason: error };
- }
-
- if (!client) {
- return { success: false, failedReason: 'missing client' };
- }
-
- const receipt = await client.waitForTransactionReceipt({ hash: tx });
- setWaitHeight(receipt.blockNumber, ['myGateways', { address }]);
- setLoading(false);
- setError(null);
-
- return { success: true };
- };
-
- return { registerGateway, isLoading, error };
-}
diff --git a/src/api/contracts/gateway-registration/useStakeGateway.ts b/src/api/contracts/gateway-registration/useStakeGateway.ts
deleted file mode 100644
index e80d8c5..0000000
--- a/src/api/contracts/gateway-registration/useStakeGateway.ts
+++ /dev/null
@@ -1,147 +0,0 @@
-import { useState } from 'react';
-
-import { logger } from '@logger';
-import { encodeFunctionData } from 'viem';
-import { usePublicClient, useWriteContract } from 'wagmi';
-
-import { AccountType, SourceWallet } from '@api/subsquid-network-squid';
-import { useSquidNetworkHeight } from '@hooks/useSquidNetworkHeightHooks';
-import { useAccount } from '@network/useAccount';
-import { useContracts } from '@network/useContracts.ts';
-
-import { useApproveSqd } from '../sqd';
-import { errorMessage, TxResult, isApproveRequiredError, WriteContractRes } from '../utils';
-import { VESTING_CONTRACT_ABI } from '../vesting.abi';
-
-import { GATEWAY_REGISTRATION_CONTRACT_ABI } from './GatewayRegistration.abi';
-
-type StakeGatewayRequest = {
- amount: string;
- durationBlocks: number;
- autoExtension: boolean;
- wallet: SourceWallet;
-};
-
-function useStakeFromWallet() {
- const contracts = useContracts();
- const { writeContractAsync } = useWriteContract({});
-
- const [approveSqd] = useApproveSqd();
-
- const tryCallContract = async ({
- autoExtension,
- amount,
- durationBlocks,
- }: StakeGatewayRequest) => {
- try {
- return {
- tx: await writeContractAsync({
- address: contracts.GATEWAY_REGISTRATION,
- abi: GATEWAY_REGISTRATION_CONTRACT_ABI,
- functionName: 'stake',
- args: [BigInt(amount), BigInt(durationBlocks), autoExtension],
- }),
- };
- } catch (e) {
- return { error: errorMessage(e) };
- }
- };
-
- return async (req: StakeGatewayRequest): Promise => {
- logger.debug(`stake to gateway via worker contract...`);
-
- const res = await tryCallContract(req);
- // Try to approve SQD
- if (isApproveRequiredError(res.error)) {
- const approveRes = await approveSqd({
- contractAddress: contracts.GATEWAY_REGISTRATION,
- amount: req.amount,
- });
- if (!approveRes.success) {
- return { error: approveRes.failedReason };
- }
-
- logger.debug(`approved SQD successfully, now trying to register one more time...`);
-
- return tryCallContract(req);
- }
-
- return res;
- };
-}
-
-function useStakeFromVestingContract() {
- const contracts = useContracts();
- const { address: account } = useAccount();
- const { writeContractAsync } = useWriteContract({});
-
- return async ({
- amount,
- wallet,
- autoExtension,
- durationBlocks,
- }: StakeGatewayRequest): Promise => {
- try {
- const data = encodeFunctionData({
- abi: GATEWAY_REGISTRATION_CONTRACT_ABI,
- functionName: 'stake',
- args: [BigInt(amount), BigInt(durationBlocks), autoExtension],
- });
-
- return {
- tx: await writeContractAsync({
- account,
- address: wallet.id as `0x${string}`,
- abi: VESTING_CONTRACT_ABI,
- functionName: 'execute',
- args: [contracts.GATEWAY_REGISTRATION, data, BigInt(amount)],
- }),
- };
- } catch (e: unknown) {
- return { error: errorMessage(e) };
- }
- };
-}
-
-export function useStakeGateway() {
- const client = usePublicClient();
- const { setWaitHeight } = useSquidNetworkHeight();
- const [isLoading, setLoading] = useState(false);
- const [error, setError] = useState(null);
-
- const stakeFromWallet = useStakeFromWallet();
- const stakeFromVestingContract = useStakeFromVestingContract();
-
- const stakeToGateway = async (req: StakeGatewayRequest): Promise => {
- setLoading(true);
-
- const res =
- req.wallet.type === AccountType.User
- ? await stakeFromWallet(req)
- : await stakeFromVestingContract(req);
-
- if (!res.tx) {
- setLoading(false);
- setError(res.error);
-
- return { success: false, failedReason: res.error };
- }
-
- if (!client) {
- return { success: false, failedReason: 'missing client' };
- }
-
- const receipt = await client.waitForTransactionReceipt({ hash: res.tx });
- setWaitHeight(receipt.blockNumber, []);
-
- setLoading(false);
-
- return { success: true };
- };
-
- return {
- stakeToGateway,
- isLoading,
- error,
- };
-}
diff --git a/src/api/contracts/gateway-registration/useUnregisterGateway.ts b/src/api/contracts/gateway-registration/useUnregisterGateway.ts
deleted file mode 100644
index 4549036..0000000
--- a/src/api/contracts/gateway-registration/useUnregisterGateway.ts
+++ /dev/null
@@ -1,113 +0,0 @@
-import { useState } from 'react';
-
-import { peerIdToHex } from '@lib/network';
-import { logger } from '@logger';
-import { encodeFunctionData } from 'viem';
-import { useWriteContract, usePublicClient } from 'wagmi';
-
-import { AccountType } from '@api/subsquid-network-squid';
-import { BlockchainGateway } from '@api/subsquid-network-squid/gateways-graphql';
-import { useSquidNetworkHeight } from '@hooks/useSquidNetworkHeightHooks';
-import { useAccount } from '@network/useAccount';
-import { useContracts } from '@network/useContracts.ts';
-
-import { TxResult, errorMessage, WriteContractRes } from '../utils';
-import { VESTING_CONTRACT_ABI } from '../vesting.abi';
-
-import { GATEWAY_REGISTRATION_CONTRACT_ABI } from './GatewayRegistration.abi';
-
-export interface UnregisterGatewayRequest {
- gateway: BlockchainGateway;
-}
-
-function useUnregisterGatewayFromWallet() {
- const contracts = useContracts();
- const { writeContractAsync } = useWriteContract();
-
- return async ({ gateway }: UnregisterGatewayRequest): Promise => {
- logger.debug(`unregistering gateway via worker contract...`);
-
- try {
- return {
- tx: await writeContractAsync({
- address: contracts.GATEWAY_REGISTRATION,
- abi: GATEWAY_REGISTRATION_CONTRACT_ABI,
- functionName: 'unregister',
- args: [peerIdToHex(gateway.id)],
- }),
- };
- } catch (e: unknown) {
- return {
- error: errorMessage(e),
- };
- }
- };
-}
-
-function useUnregisterGatewayFromVestingContract() {
- const contracts = useContracts();
- const { address: account } = useAccount();
- const { writeContractAsync } = useWriteContract();
-
- return async ({ gateway }: UnregisterGatewayRequest): Promise => {
- try {
- const data = encodeFunctionData({
- abi: GATEWAY_REGISTRATION_CONTRACT_ABI,
- functionName: 'unregister',
- args: [peerIdToHex(gateway.id)],
- });
-
- return {
- tx: await writeContractAsync({
- account,
- address: gateway.owner.id as `0x${string}`,
- abi: VESTING_CONTRACT_ABI,
- functionName: 'execute',
- args: [contracts.GATEWAY_REGISTRATION, data],
- }),
- };
- } catch (e: unknown) {
- return { error: errorMessage(e) };
- }
- };
-}
-
-export function useUnregisterGateway() {
- const client = usePublicClient();
- const { address } = useAccount();
- const [error, setError] = useState(null);
- const [isLoading, setLoading] = useState(false);
-
- const { setWaitHeight } = useSquidNetworkHeight();
- const unregisterGatewayFromWallet = useUnregisterGatewayFromWallet();
- const unregisterGatewayFromVestingContract = useUnregisterGatewayFromVestingContract();
-
- const unregisterGateway = async (req: UnregisterGatewayRequest): Promise => {
- setLoading(true);
-
- const { tx, error } =
- req.gateway.owner.type === AccountType.User
- ? await unregisterGatewayFromWallet(req)
- : await unregisterGatewayFromVestingContract(req);
-
- if (!tx) {
- logger.debug(`unregistering gateway failed ${error}`);
- setLoading(false);
- setError(error);
- return { success: false, failedReason: error };
- }
-
- if (!client) {
- return { success: false, failedReason: 'missing client' };
- }
-
- const receipt = await client.waitForTransactionReceipt({ hash: tx });
- setWaitHeight(receipt.blockNumber, ['myGateways', { address }]);
- setLoading(false);
- setError(null);
-
- return { success: true };
- };
-
- return { unregisterGateway, isLoading, error };
-}
diff --git a/src/api/contracts/gateway-registration/useUnstakeGateway.ts b/src/api/contracts/gateway-registration/useUnstakeGateway.ts
deleted file mode 100644
index d08aba5..0000000
--- a/src/api/contracts/gateway-registration/useUnstakeGateway.ts
+++ /dev/null
@@ -1,107 +0,0 @@
-import { useState } from 'react';
-
-import { encodeFunctionData } from 'viem';
-import { useWriteContract, usePublicClient } from 'wagmi';
-
-import { AccountType, GatewayStakeFragmentFragment } from '@api/subsquid-network-squid';
-import { useSquidNetworkHeight } from '@hooks/useSquidNetworkHeightHooks';
-import { useAccount } from '@network/useAccount';
-import { useContracts } from '@network/useContracts.ts';
-
-import { TxResult, errorMessage, WriteContractRes } from '../utils';
-import { VESTING_CONTRACT_ABI } from '../vesting.abi';
-
-import { GATEWAY_REGISTRATION_CONTRACT_ABI } from './GatewayRegistration.abi';
-
-type UnstakeGatewayRequest = {
- operator: GatewayStakeFragmentFragment;
-};
-
-function useUnstakeFromWallet() {
- const contracts = useContracts();
- const { writeContractAsync } = useWriteContract({});
-
- return async ({}: UnstakeGatewayRequest): Promise => {
- try {
- return {
- tx: await writeContractAsync({
- address: contracts.GATEWAY_REGISTRATION,
- abi: GATEWAY_REGISTRATION_CONTRACT_ABI,
- functionName: 'unstake',
- }),
- };
- } catch (e) {
- return { error: errorMessage(e) };
- }
- };
-}
-
-function useUnstakeFromVestingContract() {
- const contracts = useContracts();
- const { address: account } = useAccount();
- const { writeContractAsync } = useWriteContract({});
-
- return async ({ operator }: UnstakeGatewayRequest): Promise => {
- try {
- const data = encodeFunctionData({
- abi: GATEWAY_REGISTRATION_CONTRACT_ABI,
- functionName: 'unstake',
- });
-
- return {
- tx: await writeContractAsync({
- account,
- address: operator.account.id as `0x${string}`,
- abi: VESTING_CONTRACT_ABI,
- functionName: 'execute',
- args: [contracts.GATEWAY_REGISTRATION, data],
- }),
- };
- } catch (e: unknown) {
- return { error: errorMessage(e) };
- }
- };
-}
-
-export function useUnstakeGateway() {
- const client = usePublicClient();
- const { setWaitHeight } = useSquidNetworkHeight();
- const [isLoading, setLoading] = useState(false);
- const [error, setError] = useState(null);
-
- const unstakeFromWallet = useUnstakeFromWallet();
- const unstakeFromVestingContract = useUnstakeFromVestingContract();
-
- const unstakeFromGateway = async (req: UnstakeGatewayRequest): Promise => {
- setLoading(true);
-
- const res =
- req.operator.account.type === AccountType.User
- ? await unstakeFromWallet(req)
- : await unstakeFromVestingContract(req);
-
- if (!res.tx) {
- setLoading(false);
- setError(res.error);
-
- return { success: false, failedReason: res.error };
- }
-
- if (!client) {
- return { success: false, failedReason: 'missing client' };
- }
-
- const receipt = await client.waitForTransactionReceipt({ hash: res.tx });
- setWaitHeight(receipt.blockNumber, []);
-
- setLoading(false);
-
- return { success: true };
- };
-
- return {
- unstakeFromGateway,
- isLoading,
- error,
- };
-}
diff --git a/src/api/contracts/index.ts b/src/api/contracts/index.ts
new file mode 100644
index 0000000..d325827
--- /dev/null
+++ b/src/api/contracts/index.ts
@@ -0,0 +1 @@
+export * from './subsquid.generated';
diff --git a/src/api/contracts/reaward-treasury.abi.ts b/src/api/contracts/reaward-treasury.abi.ts
deleted file mode 100644
index f51a666..0000000
--- a/src/api/contracts/reaward-treasury.abi.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-export const REWARD_TREASURY_CONTRACT_ABI = [
- {
- type: 'function',
- name: 'claimFor',
- inputs: [
- {
- name: 'rewardDistribution',
- type: 'address',
- internalType: 'contract IRewardsDistribution',
- },
- {
- name: 'receiver',
- type: 'address',
- internalType: 'address',
- },
- ],
- outputs: [],
- stateMutability: 'nonpayable',
- },
-] as const;
diff --git a/src/api/contracts/soft-cap.abi.ts b/src/api/contracts/soft-cap.abi.ts
deleted file mode 100644
index 2f3a6f8..0000000
--- a/src/api/contracts/soft-cap.abi.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-export const SOFT_CAP_ABI = [
- {
- type: 'function',
- name: 'cap',
- inputs: [{ name: 'x', type: 'uint256', internalType: 'UD60x18' }],
- outputs: [{ name: '', type: 'uint256', internalType: 'UD60x18' }],
- stateMutability: 'pure',
- },
- {
- type: 'function',
- name: 'capedStake',
- inputs: [{ name: 'workerId', type: 'uint256', internalType: 'uint256' }],
- outputs: [{ name: '', type: 'uint256', internalType: 'uint256' }],
- stateMutability: 'view',
- },
- {
- type: 'function',
- name: 'capedStakeAfterDelegation',
- inputs: [
- { name: 'workerId', type: 'uint256', internalType: 'uint256' },
- { name: 'delegationAmount', type: 'int256', internalType: 'int256' },
- ],
- outputs: [{ name: '', type: 'uint256', internalType: 'uint256' }],
- stateMutability: 'view',
- },
-] as const;
diff --git a/src/api/contracts/sqd.ts b/src/api/contracts/sqd.ts
index 7f87cef..bc30880 100644
--- a/src/api/contracts/sqd.ts
+++ b/src/api/contracts/sqd.ts
@@ -11,7 +11,7 @@ import { WriteContractRes, errorMessage } from './utils';
export function useApproveSqd() {
const client = useClient();
const contracts = useContracts();
- const { writeContractAsync } = useWriteContract({});
+ const { writeContractAsync } = useWriteContract();
async function approve({
contractAddress,
diff --git a/src/api/contracts/staking.abi.ts b/src/api/contracts/staking.abi.ts
deleted file mode 100644
index c0493ad..0000000
--- a/src/api/contracts/staking.abi.ts
+++ /dev/null
@@ -1,74 +0,0 @@
-export const STAKING_CONTRACT_ABI = [
- {
- type: 'function',
- name: 'deposit',
- inputs: [
- {
- name: 'worker',
- type: 'uint256',
- internalType: 'uint256',
- },
- {
- name: 'amount',
- type: 'uint256',
- internalType: 'uint256',
- },
- ],
- outputs: [],
- stateMutability: 'nonpayable',
- },
- {
- type: 'function',
- name: 'withdraw',
- inputs: [
- {
- type: 'uint256',
- name: 'worker',
- },
- {
- type: 'uint256',
- name: 'amount',
- },
- ],
- outputs: [],
- stateMutability: 'nonpayable',
- },
- {
- type: 'function',
- name: 'claimable',
- inputs: [
- {
- name: 'staker',
- type: 'address',
- internalType: 'address',
- },
- ],
- outputs: [
- {
- name: '',
- type: 'uint256',
- internalType: 'uint256',
- },
- ],
- stateMutability: 'view',
- },
- {
- type: 'function',
- name: 'delegated',
- inputs: [
- {
- name: 'worker',
- type: 'uint256',
- internalType: 'uint256',
- },
- ],
- outputs: [
- {
- name: '',
- type: 'uint256',
- internalType: 'uint256',
- },
- ],
- stateMutability: 'view',
- },
-] as const;
diff --git a/src/api/contracts/staking.ts b/src/api/contracts/staking.ts
index fa2067c..803b64e 100644
--- a/src/api/contracts/staking.ts
+++ b/src/api/contracts/staking.ts
@@ -14,14 +14,12 @@ import {
} from 'wagmi';
import { useApproveSqd } from '@api/contracts/sqd';
-import { VESTING_CONTRACT_ABI } from '@api/contracts/vesting.abi';
import { AccountType, Worker, SourceWallet } from '@api/subsquid-network-squid';
-import { useSquidNetworkHeight } from '@hooks/useSquidNetworkHeightHooks';
+import { useSquidHeight } from '@hooks/useSquidNetworkHeightHooks';
import { useAccount } from '@network/useAccount';
import { useContracts } from '@network/useContracts.ts';
-import { SOFT_CAP_ABI } from './soft-cap.abi';
-import { STAKING_CONTRACT_ABI } from './staking.abi';
+import { softCapAbi, stakingAbi, vestingAbi } from './subsquid.generated';
import { errorMessage, TxResult, isApproveRequiredError, WriteContractRes } from './utils';
type WorkerDepositRequest = {
@@ -41,7 +39,7 @@ function useDelegateFromWallet() {
return {
tx: await writeContractAsync({
address: contracts.STAKING,
- abi: STAKING_CONTRACT_ABI,
+ abi: stakingAbi,
functionName: 'deposit',
args: [BigInt(worker.id), BigInt(amount)],
}),
@@ -82,7 +80,7 @@ function useDepositFromVestingContract() {
return async ({ worker, amount, wallet }: WorkerDepositRequest): Promise => {
try {
const data = encodeFunctionData({
- abi: STAKING_CONTRACT_ABI,
+ abi: stakingAbi,
functionName: 'deposit',
args: [BigInt(worker.id), BigInt(amount)],
});
@@ -91,7 +89,7 @@ function useDepositFromVestingContract() {
tx: await writeContractAsync({
account,
address: wallet.id as `0x${string}`,
- abi: VESTING_CONTRACT_ABI,
+ abi: vestingAbi,
functionName: 'execute',
args: [contracts.STAKING, data, BigInt(amount)],
}),
@@ -104,7 +102,7 @@ function useDepositFromVestingContract() {
export function useWorkerDelegate() {
const client = useClient();
- const { setWaitHeight } = useSquidNetworkHeight();
+ const { setWaitHeight } = useSquidHeight();
const [isPending, setLoading] = useState(false);
const [error, setError] = useState(null);
@@ -154,7 +152,7 @@ function useUndelegateFromWallet() {
return {
tx: await writeContractAsync({
address: contracts.STAKING,
- abi: STAKING_CONTRACT_ABI,
+ abi: stakingAbi,
functionName: 'withdraw',
args: [BigInt(worker.id), BigInt(amount)],
}),
@@ -173,7 +171,7 @@ function useUndelegateFromVestingContract() {
return async ({ worker, amount, wallet }: WorkerDepositRequest): Promise => {
try {
const data = encodeFunctionData({
- abi: STAKING_CONTRACT_ABI,
+ abi: stakingAbi,
functionName: 'withdraw',
args: [BigInt(worker.id), BigInt(amount)],
});
@@ -182,7 +180,7 @@ function useUndelegateFromVestingContract() {
tx: await writeContractAsync({
account,
address: wallet.id as `0x${string}`,
- abi: VESTING_CONTRACT_ABI,
+ abi: vestingAbi,
functionName: 'execute',
args: [contracts.STAKING, data, BigInt(amount)],
}),
@@ -195,7 +193,7 @@ function useUndelegateFromVestingContract() {
export function useWorkerUndelegate() {
const client = usePublicClient();
- const { setWaitHeight } = useSquidNetworkHeight();
+ const { setWaitHeight } = useSquidHeight();
const [isPending, setLoading] = useState(false);
const [error, setError] = useState(null);
@@ -238,11 +236,11 @@ export function useWorkerUndelegate() {
export function useCapedStake({ workerId }: { workerId?: string }) {
const contracts = useContracts();
- const { currentHeight, isLoading: isHeightLoading } = useSquidNetworkHeight();
+ const { currentHeight, isLoading: isHeightLoading } = useSquidHeight();
const { data, isLoading } = useReadContract({
address: contracts.SOFT_CAP,
- abi: SOFT_CAP_ABI,
+ abi: softCapAbi,
functionName: 'capedStake',
args: [BigInt(workerId || -1)],
blockNumber: BigInt(currentHeight),
@@ -279,13 +277,13 @@ export function useCapedStakeAfterDelegation({
contracts: [
{
address: contracts.SOFT_CAP,
- abi: SOFT_CAP_ABI,
+ abi: softCapAbi,
functionName: 'capedStakeAfterDelegation',
args: [BigInt(workerId), BigInt(amount || 0n) * (undelegate ? -1n : 1n)],
},
{
address: contracts.STAKING,
- abi: STAKING_CONTRACT_ABI,
+ abi: stakingAbi,
functionName: 'delegated',
args: [BigInt(workerId)],
},
diff --git a/src/api/contracts/subsquid.generated.ts b/src/api/contracts/subsquid.generated.ts
new file mode 100644
index 0000000..9ff2a35
--- /dev/null
+++ b/src/api/contracts/subsquid.generated.ts
@@ -0,0 +1,1479 @@
+import {
+ createUseReadContract,
+ createUseWriteContract,
+ createUseSimulateContract,
+ createUseWatchContractEvent,
+} from 'wagmi/codegen'
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// ArbMulticall
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+export const arbMulticallAbi = [
+ {
+ type: 'function',
+ inputs: [],
+ name: 'getCurrentBlockTimestamp',
+ outputs: [{ name: 'timestamp', internalType: 'uint256', type: 'uint256' }],
+ stateMutability: 'view',
+ },
+ {
+ type: 'function',
+ inputs: [],
+ name: 'getL1BlockNumber',
+ outputs: [
+ { name: 'l1BlockNumber', internalType: 'uint256', type: 'uint256' },
+ ],
+ stateMutability: 'view',
+ },
+] as const
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// GatewayRegistry
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+export const gatewayRegistryAbi = [
+ {
+ type: 'function',
+ inputs: [
+ { name: 'peerId', internalType: 'bytes', type: 'bytes' },
+ { name: 'metadata', internalType: 'string', type: 'string' },
+ ],
+ name: 'register',
+ outputs: [],
+ stateMutability: 'nonpayable',
+ },
+ {
+ type: 'function',
+ inputs: [
+ { name: 'peerId', internalType: 'bytes', type: 'bytes' },
+ { name: 'metadata', internalType: 'string', type: 'string' },
+ ],
+ name: 'setMetadata',
+ outputs: [],
+ stateMutability: 'nonpayable',
+ },
+ {
+ type: 'function',
+ inputs: [
+ { name: 'amount', internalType: 'uint256', type: 'uint256' },
+ { name: 'durationBlocks', internalType: 'uint128', type: 'uint128' },
+ { name: 'withAutoExtension', internalType: 'bool', type: 'bool' },
+ ],
+ name: 'stake',
+ outputs: [],
+ stateMutability: 'nonpayable',
+ },
+ {
+ type: 'function',
+ inputs: [{ name: 'peerId', internalType: 'bytes', type: 'bytes' }],
+ name: 'unregister',
+ outputs: [],
+ stateMutability: 'nonpayable',
+ },
+ {
+ type: 'function',
+ inputs: [],
+ name: 'unstake',
+ outputs: [],
+ stateMutability: 'nonpayable',
+ },
+ {
+ type: 'function',
+ inputs: [
+ { name: 'amount', internalType: 'uint256', type: 'uint256' },
+ { name: 'durationBlocks', internalType: 'uint256', type: 'uint256' },
+ ],
+ name: 'computationUnitsAmount',
+ outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }],
+ stateMutability: 'view',
+ },
+ {
+ type: 'function',
+ inputs: [{ name: 'amount', internalType: 'uint256', type: 'uint256' }],
+ name: 'addStake',
+ outputs: [],
+ stateMutability: 'nonpayable',
+ },
+ {
+ type: 'function',
+ inputs: [],
+ name: 'disableAutoExtension',
+ outputs: [],
+ stateMutability: 'nonpayable',
+ },
+ {
+ type: 'function',
+ inputs: [],
+ name: 'enableAutoExtension',
+ outputs: [],
+ stateMutability: 'nonpayable',
+ },
+ {
+ type: 'function',
+ inputs: [{ name: 'operator', internalType: 'address', type: 'address' }],
+ name: 'canUnstake',
+ outputs: [{ name: '', internalType: 'bool', type: 'bool' }],
+ stateMutability: 'view',
+ },
+ {
+ type: 'function',
+ inputs: [
+ { name: 'amount', internalType: 'uint256', type: 'uint256' },
+ { name: 'durationBlocks', internalType: 'uint256', type: 'uint256' },
+ ],
+ name: 'computationUnitsAmount',
+ outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }],
+ stateMutability: 'view',
+ },
+ {
+ type: 'function',
+ inputs: [{ name: 'operator', internalType: 'address', type: 'address' }],
+ name: 'getStake',
+ outputs: [
+ {
+ name: '',
+ internalType: 'struct IGatewayRegistry.Stake',
+ type: 'tuple',
+ components: [
+ { name: 'amount', internalType: 'uint256', type: 'uint256' },
+ { name: 'lockStart', internalType: 'uint128', type: 'uint128' },
+ { name: 'lockEnd', internalType: 'uint128', type: 'uint128' },
+ { name: 'duration', internalType: 'uint128', type: 'uint128' },
+ { name: 'autoExtension', internalType: 'bool', type: 'bool' },
+ { name: 'oldCUs', internalType: 'uint256', type: 'uint256' },
+ ],
+ },
+ ],
+ stateMutability: 'view',
+ },
+ {
+ type: 'function',
+ inputs: [],
+ name: 'minStake',
+ outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }],
+ stateMutability: 'view',
+ },
+] as const
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// NetworkController
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+export const networkControllerAbi = [
+ {
+ type: 'function',
+ inputs: [],
+ name: 'bondAmount',
+ outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }],
+ stateMutability: 'view',
+ },
+ {
+ type: 'function',
+ inputs: [],
+ name: 'epochLength',
+ outputs: [{ name: '', internalType: 'uint128', type: 'uint128' }],
+ stateMutability: 'view',
+ },
+ {
+ type: 'function',
+ inputs: [],
+ name: 'workerEpochLength',
+ outputs: [{ name: '', internalType: 'uint128', type: 'uint128' }],
+ stateMutability: 'view',
+ },
+] as const
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// RewardTreasury
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+export const rewardTreasuryAbi = [
+ {
+ type: 'function',
+ inputs: [
+ {
+ name: 'rewardDistribution',
+ internalType: 'contract IRewardsDistribution',
+ type: 'address',
+ },
+ { name: 'receiver', internalType: 'address', type: 'address' },
+ ],
+ name: 'claimFor',
+ outputs: [],
+ stateMutability: 'nonpayable',
+ },
+] as const
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Router
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+export const routerAbi = [
+ {
+ type: 'function',
+ inputs: [],
+ name: 'networkController',
+ outputs: [
+ {
+ name: '',
+ internalType: 'contract INetworkController',
+ type: 'address',
+ },
+ ],
+ stateMutability: 'view',
+ },
+ {
+ type: 'function',
+ inputs: [],
+ name: 'rewardCalculation',
+ outputs: [
+ {
+ name: '',
+ internalType: 'contract IRewardCalculation',
+ type: 'address',
+ },
+ ],
+ stateMutability: 'view',
+ },
+ {
+ type: 'function',
+ inputs: [],
+ name: 'rewardTreasury',
+ outputs: [{ name: '', internalType: 'address', type: 'address' }],
+ stateMutability: 'view',
+ },
+ {
+ type: 'function',
+ inputs: [],
+ name: 'staking',
+ outputs: [{ name: '', internalType: 'contract IStaking', type: 'address' }],
+ stateMutability: 'view',
+ },
+ {
+ type: 'function',
+ inputs: [],
+ name: 'workerRegistration',
+ outputs: [
+ {
+ name: '',
+ internalType: 'contract IWorkerRegistration',
+ type: 'address',
+ },
+ ],
+ stateMutability: 'view',
+ },
+] as const
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// SQD
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+export const sqdAbi = [
+ {
+ type: 'event',
+ inputs: [
+ { name: 'owner', type: 'address', indexed: true },
+ { name: 'spender', type: 'address', indexed: true },
+ { name: 'value', type: 'uint256', indexed: false },
+ ],
+ name: 'Approval',
+ },
+ {
+ type: 'event',
+ inputs: [
+ { name: 'from', type: 'address', indexed: true },
+ { name: 'to', type: 'address', indexed: true },
+ { name: 'value', type: 'uint256', indexed: false },
+ ],
+ name: 'Transfer',
+ },
+ {
+ type: 'function',
+ inputs: [
+ { name: 'owner', type: 'address' },
+ { name: 'spender', type: 'address' },
+ ],
+ name: 'allowance',
+ outputs: [{ type: 'uint256' }],
+ stateMutability: 'view',
+ },
+ {
+ type: 'function',
+ inputs: [
+ { name: 'spender', type: 'address' },
+ { name: 'amount', type: 'uint256' },
+ ],
+ name: 'approve',
+ outputs: [{ type: 'bool' }],
+ stateMutability: 'nonpayable',
+ },
+ {
+ type: 'function',
+ inputs: [{ name: 'account', type: 'address' }],
+ name: 'balanceOf',
+ outputs: [{ type: 'uint256' }],
+ stateMutability: 'view',
+ },
+ {
+ type: 'function',
+ inputs: [],
+ name: 'decimals',
+ outputs: [{ type: 'uint8' }],
+ stateMutability: 'view',
+ },
+ {
+ type: 'function',
+ inputs: [],
+ name: 'name',
+ outputs: [{ type: 'string' }],
+ stateMutability: 'view',
+ },
+ {
+ type: 'function',
+ inputs: [],
+ name: 'symbol',
+ outputs: [{ type: 'string' }],
+ stateMutability: 'view',
+ },
+ {
+ type: 'function',
+ inputs: [],
+ name: 'totalSupply',
+ outputs: [{ type: 'uint256' }],
+ stateMutability: 'view',
+ },
+ {
+ type: 'function',
+ inputs: [
+ { name: 'recipient', type: 'address' },
+ { name: 'amount', type: 'uint256' },
+ ],
+ name: 'transfer',
+ outputs: [{ type: 'bool' }],
+ stateMutability: 'nonpayable',
+ },
+ {
+ type: 'function',
+ inputs: [
+ { name: 'sender', type: 'address' },
+ { name: 'recipient', type: 'address' },
+ { name: 'amount', type: 'uint256' },
+ ],
+ name: 'transferFrom',
+ outputs: [{ type: 'bool' }],
+ stateMutability: 'nonpayable',
+ },
+] as const
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// SoftCap
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+export const softCapAbi = [
+ {
+ type: 'function',
+ inputs: [{ name: 'x', internalType: 'UD60x18', type: 'uint256' }],
+ name: 'cap',
+ outputs: [{ name: '', internalType: 'UD60x18', type: 'uint256' }],
+ stateMutability: 'pure',
+ },
+ {
+ type: 'function',
+ inputs: [{ name: 'workerId', internalType: 'uint256', type: 'uint256' }],
+ name: 'capedStake',
+ outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }],
+ stateMutability: 'view',
+ },
+ {
+ type: 'function',
+ inputs: [
+ { name: 'workerId', internalType: 'uint256', type: 'uint256' },
+ { name: 'delegationAmount', internalType: 'int256', type: 'int256' },
+ ],
+ name: 'capedStakeAfterDelegation',
+ outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }],
+ stateMutability: 'view',
+ },
+] as const
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Staking
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+export const stakingAbi = [
+ {
+ type: 'function',
+ inputs: [
+ { name: 'staker', internalType: 'address', type: 'address' },
+ { name: 'worker', internalType: 'uint256', type: 'uint256' },
+ ],
+ name: 'getDeposit',
+ outputs: [
+ { name: 'depositAmount', internalType: 'uint256', type: 'uint256' },
+ { name: 'withdrawAllowed', internalType: 'uint256', type: 'uint256' },
+ ],
+ stateMutability: 'view',
+ },
+ {
+ type: 'function',
+ inputs: [
+ { name: 'worker', internalType: 'uint256', type: 'uint256' },
+ { name: 'amount', internalType: 'uint256', type: 'uint256' },
+ ],
+ name: 'deposit',
+ outputs: [],
+ stateMutability: 'nonpayable',
+ },
+ {
+ type: 'function',
+ inputs: [
+ { name: 'worker', type: 'uint256' },
+ { name: 'amount', type: 'uint256' },
+ ],
+ name: 'withdraw',
+ outputs: [],
+ stateMutability: 'nonpayable',
+ },
+ {
+ type: 'function',
+ inputs: [{ name: 'staker', internalType: 'address', type: 'address' }],
+ name: 'claimable',
+ outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }],
+ stateMutability: 'view',
+ },
+ {
+ type: 'function',
+ inputs: [{ name: 'worker', internalType: 'uint256', type: 'uint256' }],
+ name: 'delegated',
+ outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }],
+ stateMutability: 'view',
+ },
+] as const
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Vesting
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+export const vestingAbi = [
+ {
+ type: 'function',
+ inputs: [],
+ name: 'depositedIntoProtocol',
+ outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }],
+ stateMutability: 'view',
+ },
+ {
+ type: 'function',
+ inputs: [],
+ name: 'duration',
+ outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }],
+ stateMutability: 'view',
+ },
+ {
+ type: 'function',
+ inputs: [],
+ name: 'end',
+ outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }],
+ stateMutability: 'view',
+ },
+ {
+ type: 'function',
+ inputs: [
+ { name: 'to', internalType: 'address', type: 'address' },
+ { name: 'data', internalType: 'bytes', type: 'bytes' },
+ ],
+ name: 'execute',
+ outputs: [],
+ stateMutability: 'nonpayable',
+ },
+ {
+ type: 'function',
+ inputs: [
+ { name: 'to', internalType: 'address', type: 'address' },
+ { name: 'data', internalType: 'bytes', type: 'bytes' },
+ { name: 'requiredApprove', internalType: 'uint256', type: 'uint256' },
+ ],
+ name: 'execute',
+ outputs: [{ name: '', internalType: 'bytes', type: 'bytes' }],
+ stateMutability: 'nonpayable',
+ },
+ {
+ type: 'function',
+ inputs: [],
+ name: 'expectedTotalAmount',
+ outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }],
+ stateMutability: 'view',
+ },
+ {
+ type: 'function',
+ inputs: [],
+ name: 'immediateReleaseBIP',
+ outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }],
+ stateMutability: 'view',
+ },
+ {
+ type: 'function',
+ inputs: [{ name: 'token', internalType: 'address', type: 'address' }],
+ name: 'releasable',
+ outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }],
+ stateMutability: 'view',
+ },
+ {
+ type: 'function',
+ inputs: [],
+ name: 'releasable',
+ outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }],
+ stateMutability: 'view',
+ },
+ {
+ type: 'function',
+ inputs: [{ name: 'token', internalType: 'address', type: 'address' }],
+ name: 'release',
+ outputs: [],
+ stateMutability: 'nonpayable',
+ },
+ {
+ type: 'function',
+ inputs: [{ name: 'token', internalType: 'address', type: 'address' }],
+ name: 'released',
+ outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }],
+ stateMutability: 'view',
+ },
+ {
+ type: 'function',
+ inputs: [],
+ name: 'start',
+ outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }],
+ stateMutability: 'view',
+ },
+ {
+ type: 'function',
+ inputs: [
+ { name: 'token', internalType: 'address', type: 'address' },
+ { name: 'timestamp', internalType: 'uint64', type: 'uint64' },
+ ],
+ name: 'vestedAmount',
+ outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }],
+ stateMutability: 'view',
+ },
+] as const
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// WorkerRegistry
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+export const workerRegistryAbi = [
+ {
+ type: 'function',
+ inputs: [],
+ name: 'bondAmount',
+ outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }],
+ stateMutability: 'view',
+ },
+ {
+ type: 'function',
+ inputs: [
+ { name: 'peerId', internalType: 'bytes', type: 'bytes' },
+ { name: 'metadata', internalType: 'string', type: 'string' },
+ ],
+ name: 'register',
+ outputs: [],
+ stateMutability: 'nonpayable',
+ },
+ {
+ type: 'function',
+ inputs: [
+ { name: 'peerId', internalType: 'bytes', type: 'bytes' },
+ { name: 'metadata', internalType: 'string', type: 'string' },
+ ],
+ name: 'updateMetadata',
+ outputs: [],
+ stateMutability: 'nonpayable',
+ },
+ {
+ type: 'function',
+ inputs: [{ name: 'peerId', internalType: 'bytes', type: 'bytes' }],
+ name: 'deregister',
+ outputs: [],
+ stateMutability: 'nonpayable',
+ },
+ {
+ type: 'function',
+ inputs: [{ name: 'peerId', internalType: 'bytes', type: 'bytes' }],
+ name: 'withdraw',
+ outputs: [],
+ stateMutability: 'nonpayable',
+ },
+ {
+ type: 'function',
+ inputs: [],
+ name: 'lockPeriod',
+ outputs: [{ name: '', internalType: 'uint128', type: 'uint128' }],
+ stateMutability: 'view',
+ },
+ {
+ type: 'function',
+ inputs: [{ name: 'workerId', internalType: 'uint256', type: 'uint256' }],
+ name: 'getWorker',
+ outputs: [
+ {
+ name: '',
+ internalType: 'struct WorkerRegistration.Worker',
+ type: 'tuple',
+ components: [
+ { name: 'creator', internalType: 'address', type: 'address' },
+ { name: 'peerId', internalType: 'bytes', type: 'bytes' },
+ { name: 'bond', internalType: 'uint256', type: 'uint256' },
+ { name: 'registeredAt', internalType: 'uint128', type: 'uint128' },
+ { name: 'deregisteredAt', internalType: 'uint128', type: 'uint128' },
+ { name: 'metadata', internalType: 'string', type: 'string' },
+ ],
+ },
+ ],
+ stateMutability: 'view',
+ },
+] as const
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// React
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link arbMulticallAbi}__
+ */
+export const useReadArbMulticall = /*#__PURE__*/ createUseReadContract({
+ abi: arbMulticallAbi,
+})
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link arbMulticallAbi}__ and `functionName` set to `"getCurrentBlockTimestamp"`
+ */
+export const useReadArbMulticallGetCurrentBlockTimestamp =
+ /*#__PURE__*/ createUseReadContract({
+ abi: arbMulticallAbi,
+ functionName: 'getCurrentBlockTimestamp',
+ })
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link arbMulticallAbi}__ and `functionName` set to `"getL1BlockNumber"`
+ */
+export const useReadArbMulticallGetL1BlockNumber =
+ /*#__PURE__*/ createUseReadContract({
+ abi: arbMulticallAbi,
+ functionName: 'getL1BlockNumber',
+ })
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link gatewayRegistryAbi}__
+ */
+export const useReadGatewayRegistry = /*#__PURE__*/ createUseReadContract({
+ abi: gatewayRegistryAbi,
+})
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link gatewayRegistryAbi}__ and `functionName` set to `"computationUnitsAmount"`
+ */
+export const useReadGatewayRegistryComputationUnitsAmount =
+ /*#__PURE__*/ createUseReadContract({
+ abi: gatewayRegistryAbi,
+ functionName: 'computationUnitsAmount',
+ })
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link gatewayRegistryAbi}__ and `functionName` set to `"canUnstake"`
+ */
+export const useReadGatewayRegistryCanUnstake =
+ /*#__PURE__*/ createUseReadContract({
+ abi: gatewayRegistryAbi,
+ functionName: 'canUnstake',
+ })
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link gatewayRegistryAbi}__ and `functionName` set to `"getStake"`
+ */
+export const useReadGatewayRegistryGetStake =
+ /*#__PURE__*/ createUseReadContract({
+ abi: gatewayRegistryAbi,
+ functionName: 'getStake',
+ })
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link gatewayRegistryAbi}__ and `functionName` set to `"minStake"`
+ */
+export const useReadGatewayRegistryMinStake =
+ /*#__PURE__*/ createUseReadContract({
+ abi: gatewayRegistryAbi,
+ functionName: 'minStake',
+ })
+
+/**
+ * Wraps __{@link useWriteContract}__ with `abi` set to __{@link gatewayRegistryAbi}__
+ */
+export const useWriteGatewayRegistry = /*#__PURE__*/ createUseWriteContract({
+ abi: gatewayRegistryAbi,
+})
+
+/**
+ * Wraps __{@link useWriteContract}__ with `abi` set to __{@link gatewayRegistryAbi}__ and `functionName` set to `"register"`
+ */
+export const useWriteGatewayRegistryRegister =
+ /*#__PURE__*/ createUseWriteContract({
+ abi: gatewayRegistryAbi,
+ functionName: 'register',
+ })
+
+/**
+ * Wraps __{@link useWriteContract}__ with `abi` set to __{@link gatewayRegistryAbi}__ and `functionName` set to `"setMetadata"`
+ */
+export const useWriteGatewayRegistrySetMetadata =
+ /*#__PURE__*/ createUseWriteContract({
+ abi: gatewayRegistryAbi,
+ functionName: 'setMetadata',
+ })
+
+/**
+ * Wraps __{@link useWriteContract}__ with `abi` set to __{@link gatewayRegistryAbi}__ and `functionName` set to `"stake"`
+ */
+export const useWriteGatewayRegistryStake =
+ /*#__PURE__*/ createUseWriteContract({
+ abi: gatewayRegistryAbi,
+ functionName: 'stake',
+ })
+
+/**
+ * Wraps __{@link useWriteContract}__ with `abi` set to __{@link gatewayRegistryAbi}__ and `functionName` set to `"unregister"`
+ */
+export const useWriteGatewayRegistryUnregister =
+ /*#__PURE__*/ createUseWriteContract({
+ abi: gatewayRegistryAbi,
+ functionName: 'unregister',
+ })
+
+/**
+ * Wraps __{@link useWriteContract}__ with `abi` set to __{@link gatewayRegistryAbi}__ and `functionName` set to `"unstake"`
+ */
+export const useWriteGatewayRegistryUnstake =
+ /*#__PURE__*/ createUseWriteContract({
+ abi: gatewayRegistryAbi,
+ functionName: 'unstake',
+ })
+
+/**
+ * Wraps __{@link useWriteContract}__ with `abi` set to __{@link gatewayRegistryAbi}__ and `functionName` set to `"addStake"`
+ */
+export const useWriteGatewayRegistryAddStake =
+ /*#__PURE__*/ createUseWriteContract({
+ abi: gatewayRegistryAbi,
+ functionName: 'addStake',
+ })
+
+/**
+ * Wraps __{@link useWriteContract}__ with `abi` set to __{@link gatewayRegistryAbi}__ and `functionName` set to `"disableAutoExtension"`
+ */
+export const useWriteGatewayRegistryDisableAutoExtension =
+ /*#__PURE__*/ createUseWriteContract({
+ abi: gatewayRegistryAbi,
+ functionName: 'disableAutoExtension',
+ })
+
+/**
+ * Wraps __{@link useWriteContract}__ with `abi` set to __{@link gatewayRegistryAbi}__ and `functionName` set to `"enableAutoExtension"`
+ */
+export const useWriteGatewayRegistryEnableAutoExtension =
+ /*#__PURE__*/ createUseWriteContract({
+ abi: gatewayRegistryAbi,
+ functionName: 'enableAutoExtension',
+ })
+
+/**
+ * Wraps __{@link useSimulateContract}__ with `abi` set to __{@link gatewayRegistryAbi}__
+ */
+export const useSimulateGatewayRegistry =
+ /*#__PURE__*/ createUseSimulateContract({ abi: gatewayRegistryAbi })
+
+/**
+ * Wraps __{@link useSimulateContract}__ with `abi` set to __{@link gatewayRegistryAbi}__ and `functionName` set to `"register"`
+ */
+export const useSimulateGatewayRegistryRegister =
+ /*#__PURE__*/ createUseSimulateContract({
+ abi: gatewayRegistryAbi,
+ functionName: 'register',
+ })
+
+/**
+ * Wraps __{@link useSimulateContract}__ with `abi` set to __{@link gatewayRegistryAbi}__ and `functionName` set to `"setMetadata"`
+ */
+export const useSimulateGatewayRegistrySetMetadata =
+ /*#__PURE__*/ createUseSimulateContract({
+ abi: gatewayRegistryAbi,
+ functionName: 'setMetadata',
+ })
+
+/**
+ * Wraps __{@link useSimulateContract}__ with `abi` set to __{@link gatewayRegistryAbi}__ and `functionName` set to `"stake"`
+ */
+export const useSimulateGatewayRegistryStake =
+ /*#__PURE__*/ createUseSimulateContract({
+ abi: gatewayRegistryAbi,
+ functionName: 'stake',
+ })
+
+/**
+ * Wraps __{@link useSimulateContract}__ with `abi` set to __{@link gatewayRegistryAbi}__ and `functionName` set to `"unregister"`
+ */
+export const useSimulateGatewayRegistryUnregister =
+ /*#__PURE__*/ createUseSimulateContract({
+ abi: gatewayRegistryAbi,
+ functionName: 'unregister',
+ })
+
+/**
+ * Wraps __{@link useSimulateContract}__ with `abi` set to __{@link gatewayRegistryAbi}__ and `functionName` set to `"unstake"`
+ */
+export const useSimulateGatewayRegistryUnstake =
+ /*#__PURE__*/ createUseSimulateContract({
+ abi: gatewayRegistryAbi,
+ functionName: 'unstake',
+ })
+
+/**
+ * Wraps __{@link useSimulateContract}__ with `abi` set to __{@link gatewayRegistryAbi}__ and `functionName` set to `"addStake"`
+ */
+export const useSimulateGatewayRegistryAddStake =
+ /*#__PURE__*/ createUseSimulateContract({
+ abi: gatewayRegistryAbi,
+ functionName: 'addStake',
+ })
+
+/**
+ * Wraps __{@link useSimulateContract}__ with `abi` set to __{@link gatewayRegistryAbi}__ and `functionName` set to `"disableAutoExtension"`
+ */
+export const useSimulateGatewayRegistryDisableAutoExtension =
+ /*#__PURE__*/ createUseSimulateContract({
+ abi: gatewayRegistryAbi,
+ functionName: 'disableAutoExtension',
+ })
+
+/**
+ * Wraps __{@link useSimulateContract}__ with `abi` set to __{@link gatewayRegistryAbi}__ and `functionName` set to `"enableAutoExtension"`
+ */
+export const useSimulateGatewayRegistryEnableAutoExtension =
+ /*#__PURE__*/ createUseSimulateContract({
+ abi: gatewayRegistryAbi,
+ functionName: 'enableAutoExtension',
+ })
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link networkControllerAbi}__
+ */
+export const useReadNetworkController = /*#__PURE__*/ createUseReadContract({
+ abi: networkControllerAbi,
+})
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link networkControllerAbi}__ and `functionName` set to `"bondAmount"`
+ */
+export const useReadNetworkControllerBondAmount =
+ /*#__PURE__*/ createUseReadContract({
+ abi: networkControllerAbi,
+ functionName: 'bondAmount',
+ })
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link networkControllerAbi}__ and `functionName` set to `"epochLength"`
+ */
+export const useReadNetworkControllerEpochLength =
+ /*#__PURE__*/ createUseReadContract({
+ abi: networkControllerAbi,
+ functionName: 'epochLength',
+ })
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link networkControllerAbi}__ and `functionName` set to `"workerEpochLength"`
+ */
+export const useReadNetworkControllerWorkerEpochLength =
+ /*#__PURE__*/ createUseReadContract({
+ abi: networkControllerAbi,
+ functionName: 'workerEpochLength',
+ })
+
+/**
+ * Wraps __{@link useWriteContract}__ with `abi` set to __{@link rewardTreasuryAbi}__
+ */
+export const useWriteRewardTreasury = /*#__PURE__*/ createUseWriteContract({
+ abi: rewardTreasuryAbi,
+})
+
+/**
+ * Wraps __{@link useWriteContract}__ with `abi` set to __{@link rewardTreasuryAbi}__ and `functionName` set to `"claimFor"`
+ */
+export const useWriteRewardTreasuryClaimFor =
+ /*#__PURE__*/ createUseWriteContract({
+ abi: rewardTreasuryAbi,
+ functionName: 'claimFor',
+ })
+
+/**
+ * Wraps __{@link useSimulateContract}__ with `abi` set to __{@link rewardTreasuryAbi}__
+ */
+export const useSimulateRewardTreasury =
+ /*#__PURE__*/ createUseSimulateContract({ abi: rewardTreasuryAbi })
+
+/**
+ * Wraps __{@link useSimulateContract}__ with `abi` set to __{@link rewardTreasuryAbi}__ and `functionName` set to `"claimFor"`
+ */
+export const useSimulateRewardTreasuryClaimFor =
+ /*#__PURE__*/ createUseSimulateContract({
+ abi: rewardTreasuryAbi,
+ functionName: 'claimFor',
+ })
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link routerAbi}__
+ */
+export const useReadRouter = /*#__PURE__*/ createUseReadContract({
+ abi: routerAbi,
+})
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link routerAbi}__ and `functionName` set to `"networkController"`
+ */
+export const useReadRouterNetworkController =
+ /*#__PURE__*/ createUseReadContract({
+ abi: routerAbi,
+ functionName: 'networkController',
+ })
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link routerAbi}__ and `functionName` set to `"rewardCalculation"`
+ */
+export const useReadRouterRewardCalculation =
+ /*#__PURE__*/ createUseReadContract({
+ abi: routerAbi,
+ functionName: 'rewardCalculation',
+ })
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link routerAbi}__ and `functionName` set to `"rewardTreasury"`
+ */
+export const useReadRouterRewardTreasury = /*#__PURE__*/ createUseReadContract({
+ abi: routerAbi,
+ functionName: 'rewardTreasury',
+})
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link routerAbi}__ and `functionName` set to `"staking"`
+ */
+export const useReadRouterStaking = /*#__PURE__*/ createUseReadContract({
+ abi: routerAbi,
+ functionName: 'staking',
+})
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link routerAbi}__ and `functionName` set to `"workerRegistration"`
+ */
+export const useReadRouterWorkerRegistration =
+ /*#__PURE__*/ createUseReadContract({
+ abi: routerAbi,
+ functionName: 'workerRegistration',
+ })
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link sqdAbi}__
+ */
+export const useReadSqd = /*#__PURE__*/ createUseReadContract({ abi: sqdAbi })
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link sqdAbi}__ and `functionName` set to `"allowance"`
+ */
+export const useReadSqdAllowance = /*#__PURE__*/ createUseReadContract({
+ abi: sqdAbi,
+ functionName: 'allowance',
+})
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link sqdAbi}__ and `functionName` set to `"balanceOf"`
+ */
+export const useReadSqdBalanceOf = /*#__PURE__*/ createUseReadContract({
+ abi: sqdAbi,
+ functionName: 'balanceOf',
+})
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link sqdAbi}__ and `functionName` set to `"decimals"`
+ */
+export const useReadSqdDecimals = /*#__PURE__*/ createUseReadContract({
+ abi: sqdAbi,
+ functionName: 'decimals',
+})
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link sqdAbi}__ and `functionName` set to `"name"`
+ */
+export const useReadSqdName = /*#__PURE__*/ createUseReadContract({
+ abi: sqdAbi,
+ functionName: 'name',
+})
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link sqdAbi}__ and `functionName` set to `"symbol"`
+ */
+export const useReadSqdSymbol = /*#__PURE__*/ createUseReadContract({
+ abi: sqdAbi,
+ functionName: 'symbol',
+})
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link sqdAbi}__ and `functionName` set to `"totalSupply"`
+ */
+export const useReadSqdTotalSupply = /*#__PURE__*/ createUseReadContract({
+ abi: sqdAbi,
+ functionName: 'totalSupply',
+})
+
+/**
+ * Wraps __{@link useWriteContract}__ with `abi` set to __{@link sqdAbi}__
+ */
+export const useWriteSqd = /*#__PURE__*/ createUseWriteContract({ abi: sqdAbi })
+
+/**
+ * Wraps __{@link useWriteContract}__ with `abi` set to __{@link sqdAbi}__ and `functionName` set to `"approve"`
+ */
+export const useWriteSqdApprove = /*#__PURE__*/ createUseWriteContract({
+ abi: sqdAbi,
+ functionName: 'approve',
+})
+
+/**
+ * Wraps __{@link useWriteContract}__ with `abi` set to __{@link sqdAbi}__ and `functionName` set to `"transfer"`
+ */
+export const useWriteSqdTransfer = /*#__PURE__*/ createUseWriteContract({
+ abi: sqdAbi,
+ functionName: 'transfer',
+})
+
+/**
+ * Wraps __{@link useWriteContract}__ with `abi` set to __{@link sqdAbi}__ and `functionName` set to `"transferFrom"`
+ */
+export const useWriteSqdTransferFrom = /*#__PURE__*/ createUseWriteContract({
+ abi: sqdAbi,
+ functionName: 'transferFrom',
+})
+
+/**
+ * Wraps __{@link useSimulateContract}__ with `abi` set to __{@link sqdAbi}__
+ */
+export const useSimulateSqd = /*#__PURE__*/ createUseSimulateContract({
+ abi: sqdAbi,
+})
+
+/**
+ * Wraps __{@link useSimulateContract}__ with `abi` set to __{@link sqdAbi}__ and `functionName` set to `"approve"`
+ */
+export const useSimulateSqdApprove = /*#__PURE__*/ createUseSimulateContract({
+ abi: sqdAbi,
+ functionName: 'approve',
+})
+
+/**
+ * Wraps __{@link useSimulateContract}__ with `abi` set to __{@link sqdAbi}__ and `functionName` set to `"transfer"`
+ */
+export const useSimulateSqdTransfer = /*#__PURE__*/ createUseSimulateContract({
+ abi: sqdAbi,
+ functionName: 'transfer',
+})
+
+/**
+ * Wraps __{@link useSimulateContract}__ with `abi` set to __{@link sqdAbi}__ and `functionName` set to `"transferFrom"`
+ */
+export const useSimulateSqdTransferFrom =
+ /*#__PURE__*/ createUseSimulateContract({
+ abi: sqdAbi,
+ functionName: 'transferFrom',
+ })
+
+/**
+ * Wraps __{@link useWatchContractEvent}__ with `abi` set to __{@link sqdAbi}__
+ */
+export const useWatchSqdEvent = /*#__PURE__*/ createUseWatchContractEvent({
+ abi: sqdAbi,
+})
+
+/**
+ * Wraps __{@link useWatchContractEvent}__ with `abi` set to __{@link sqdAbi}__ and `eventName` set to `"Approval"`
+ */
+export const useWatchSqdApprovalEvent =
+ /*#__PURE__*/ createUseWatchContractEvent({
+ abi: sqdAbi,
+ eventName: 'Approval',
+ })
+
+/**
+ * Wraps __{@link useWatchContractEvent}__ with `abi` set to __{@link sqdAbi}__ and `eventName` set to `"Transfer"`
+ */
+export const useWatchSqdTransferEvent =
+ /*#__PURE__*/ createUseWatchContractEvent({
+ abi: sqdAbi,
+ eventName: 'Transfer',
+ })
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link softCapAbi}__
+ */
+export const useReadSoftCap = /*#__PURE__*/ createUseReadContract({
+ abi: softCapAbi,
+})
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link softCapAbi}__ and `functionName` set to `"cap"`
+ */
+export const useReadSoftCapCap = /*#__PURE__*/ createUseReadContract({
+ abi: softCapAbi,
+ functionName: 'cap',
+})
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link softCapAbi}__ and `functionName` set to `"capedStake"`
+ */
+export const useReadSoftCapCapedStake = /*#__PURE__*/ createUseReadContract({
+ abi: softCapAbi,
+ functionName: 'capedStake',
+})
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link softCapAbi}__ and `functionName` set to `"capedStakeAfterDelegation"`
+ */
+export const useReadSoftCapCapedStakeAfterDelegation =
+ /*#__PURE__*/ createUseReadContract({
+ abi: softCapAbi,
+ functionName: 'capedStakeAfterDelegation',
+ })
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link stakingAbi}__
+ */
+export const useReadStaking = /*#__PURE__*/ createUseReadContract({
+ abi: stakingAbi,
+})
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link stakingAbi}__ and `functionName` set to `"getDeposit"`
+ */
+export const useReadStakingGetDeposit = /*#__PURE__*/ createUseReadContract({
+ abi: stakingAbi,
+ functionName: 'getDeposit',
+})
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link stakingAbi}__ and `functionName` set to `"claimable"`
+ */
+export const useReadStakingClaimable = /*#__PURE__*/ createUseReadContract({
+ abi: stakingAbi,
+ functionName: 'claimable',
+})
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link stakingAbi}__ and `functionName` set to `"delegated"`
+ */
+export const useReadStakingDelegated = /*#__PURE__*/ createUseReadContract({
+ abi: stakingAbi,
+ functionName: 'delegated',
+})
+
+/**
+ * Wraps __{@link useWriteContract}__ with `abi` set to __{@link stakingAbi}__
+ */
+export const useWriteStaking = /*#__PURE__*/ createUseWriteContract({
+ abi: stakingAbi,
+})
+
+/**
+ * Wraps __{@link useWriteContract}__ with `abi` set to __{@link stakingAbi}__ and `functionName` set to `"deposit"`
+ */
+export const useWriteStakingDeposit = /*#__PURE__*/ createUseWriteContract({
+ abi: stakingAbi,
+ functionName: 'deposit',
+})
+
+/**
+ * Wraps __{@link useWriteContract}__ with `abi` set to __{@link stakingAbi}__ and `functionName` set to `"withdraw"`
+ */
+export const useWriteStakingWithdraw = /*#__PURE__*/ createUseWriteContract({
+ abi: stakingAbi,
+ functionName: 'withdraw',
+})
+
+/**
+ * Wraps __{@link useSimulateContract}__ with `abi` set to __{@link stakingAbi}__
+ */
+export const useSimulateStaking = /*#__PURE__*/ createUseSimulateContract({
+ abi: stakingAbi,
+})
+
+/**
+ * Wraps __{@link useSimulateContract}__ with `abi` set to __{@link stakingAbi}__ and `functionName` set to `"deposit"`
+ */
+export const useSimulateStakingDeposit =
+ /*#__PURE__*/ createUseSimulateContract({
+ abi: stakingAbi,
+ functionName: 'deposit',
+ })
+
+/**
+ * Wraps __{@link useSimulateContract}__ with `abi` set to __{@link stakingAbi}__ and `functionName` set to `"withdraw"`
+ */
+export const useSimulateStakingWithdraw =
+ /*#__PURE__*/ createUseSimulateContract({
+ abi: stakingAbi,
+ functionName: 'withdraw',
+ })
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link vestingAbi}__
+ */
+export const useReadVesting = /*#__PURE__*/ createUseReadContract({
+ abi: vestingAbi,
+})
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link vestingAbi}__ and `functionName` set to `"depositedIntoProtocol"`
+ */
+export const useReadVestingDepositedIntoProtocol =
+ /*#__PURE__*/ createUseReadContract({
+ abi: vestingAbi,
+ functionName: 'depositedIntoProtocol',
+ })
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link vestingAbi}__ and `functionName` set to `"duration"`
+ */
+export const useReadVestingDuration = /*#__PURE__*/ createUseReadContract({
+ abi: vestingAbi,
+ functionName: 'duration',
+})
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link vestingAbi}__ and `functionName` set to `"end"`
+ */
+export const useReadVestingEnd = /*#__PURE__*/ createUseReadContract({
+ abi: vestingAbi,
+ functionName: 'end',
+})
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link vestingAbi}__ and `functionName` set to `"expectedTotalAmount"`
+ */
+export const useReadVestingExpectedTotalAmount =
+ /*#__PURE__*/ createUseReadContract({
+ abi: vestingAbi,
+ functionName: 'expectedTotalAmount',
+ })
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link vestingAbi}__ and `functionName` set to `"immediateReleaseBIP"`
+ */
+export const useReadVestingImmediateReleaseBip =
+ /*#__PURE__*/ createUseReadContract({
+ abi: vestingAbi,
+ functionName: 'immediateReleaseBIP',
+ })
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link vestingAbi}__ and `functionName` set to `"releasable"`
+ */
+export const useReadVestingReleasable = /*#__PURE__*/ createUseReadContract({
+ abi: vestingAbi,
+ functionName: 'releasable',
+})
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link vestingAbi}__ and `functionName` set to `"released"`
+ */
+export const useReadVestingReleased = /*#__PURE__*/ createUseReadContract({
+ abi: vestingAbi,
+ functionName: 'released',
+})
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link vestingAbi}__ and `functionName` set to `"start"`
+ */
+export const useReadVestingStart = /*#__PURE__*/ createUseReadContract({
+ abi: vestingAbi,
+ functionName: 'start',
+})
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link vestingAbi}__ and `functionName` set to `"vestedAmount"`
+ */
+export const useReadVestingVestedAmount = /*#__PURE__*/ createUseReadContract({
+ abi: vestingAbi,
+ functionName: 'vestedAmount',
+})
+
+/**
+ * Wraps __{@link useWriteContract}__ with `abi` set to __{@link vestingAbi}__
+ */
+export const useWriteVesting = /*#__PURE__*/ createUseWriteContract({
+ abi: vestingAbi,
+})
+
+/**
+ * Wraps __{@link useWriteContract}__ with `abi` set to __{@link vestingAbi}__ and `functionName` set to `"execute"`
+ */
+export const useWriteVestingExecute = /*#__PURE__*/ createUseWriteContract({
+ abi: vestingAbi,
+ functionName: 'execute',
+})
+
+/**
+ * Wraps __{@link useWriteContract}__ with `abi` set to __{@link vestingAbi}__ and `functionName` set to `"release"`
+ */
+export const useWriteVestingRelease = /*#__PURE__*/ createUseWriteContract({
+ abi: vestingAbi,
+ functionName: 'release',
+})
+
+/**
+ * Wraps __{@link useSimulateContract}__ with `abi` set to __{@link vestingAbi}__
+ */
+export const useSimulateVesting = /*#__PURE__*/ createUseSimulateContract({
+ abi: vestingAbi,
+})
+
+/**
+ * Wraps __{@link useSimulateContract}__ with `abi` set to __{@link vestingAbi}__ and `functionName` set to `"execute"`
+ */
+export const useSimulateVestingExecute =
+ /*#__PURE__*/ createUseSimulateContract({
+ abi: vestingAbi,
+ functionName: 'execute',
+ })
+
+/**
+ * Wraps __{@link useSimulateContract}__ with `abi` set to __{@link vestingAbi}__ and `functionName` set to `"release"`
+ */
+export const useSimulateVestingRelease =
+ /*#__PURE__*/ createUseSimulateContract({
+ abi: vestingAbi,
+ functionName: 'release',
+ })
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link workerRegistryAbi}__
+ */
+export const useReadWorkerRegistry = /*#__PURE__*/ createUseReadContract({
+ abi: workerRegistryAbi,
+})
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link workerRegistryAbi}__ and `functionName` set to `"bondAmount"`
+ */
+export const useReadWorkerRegistryBondAmount =
+ /*#__PURE__*/ createUseReadContract({
+ abi: workerRegistryAbi,
+ functionName: 'bondAmount',
+ })
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link workerRegistryAbi}__ and `functionName` set to `"lockPeriod"`
+ */
+export const useReadWorkerRegistryLockPeriod =
+ /*#__PURE__*/ createUseReadContract({
+ abi: workerRegistryAbi,
+ functionName: 'lockPeriod',
+ })
+
+/**
+ * Wraps __{@link useReadContract}__ with `abi` set to __{@link workerRegistryAbi}__ and `functionName` set to `"getWorker"`
+ */
+export const useReadWorkerRegistryGetWorker =
+ /*#__PURE__*/ createUseReadContract({
+ abi: workerRegistryAbi,
+ functionName: 'getWorker',
+ })
+
+/**
+ * Wraps __{@link useWriteContract}__ with `abi` set to __{@link workerRegistryAbi}__
+ */
+export const useWriteWorkerRegistry = /*#__PURE__*/ createUseWriteContract({
+ abi: workerRegistryAbi,
+})
+
+/**
+ * Wraps __{@link useWriteContract}__ with `abi` set to __{@link workerRegistryAbi}__ and `functionName` set to `"register"`
+ */
+export const useWriteWorkerRegistryRegister =
+ /*#__PURE__*/ createUseWriteContract({
+ abi: workerRegistryAbi,
+ functionName: 'register',
+ })
+
+/**
+ * Wraps __{@link useWriteContract}__ with `abi` set to __{@link workerRegistryAbi}__ and `functionName` set to `"updateMetadata"`
+ */
+export const useWriteWorkerRegistryUpdateMetadata =
+ /*#__PURE__*/ createUseWriteContract({
+ abi: workerRegistryAbi,
+ functionName: 'updateMetadata',
+ })
+
+/**
+ * Wraps __{@link useWriteContract}__ with `abi` set to __{@link workerRegistryAbi}__ and `functionName` set to `"deregister"`
+ */
+export const useWriteWorkerRegistryDeregister =
+ /*#__PURE__*/ createUseWriteContract({
+ abi: workerRegistryAbi,
+ functionName: 'deregister',
+ })
+
+/**
+ * Wraps __{@link useWriteContract}__ with `abi` set to __{@link workerRegistryAbi}__ and `functionName` set to `"withdraw"`
+ */
+export const useWriteWorkerRegistryWithdraw =
+ /*#__PURE__*/ createUseWriteContract({
+ abi: workerRegistryAbi,
+ functionName: 'withdraw',
+ })
+
+/**
+ * Wraps __{@link useSimulateContract}__ with `abi` set to __{@link workerRegistryAbi}__
+ */
+export const useSimulateWorkerRegistry =
+ /*#__PURE__*/ createUseSimulateContract({ abi: workerRegistryAbi })
+
+/**
+ * Wraps __{@link useSimulateContract}__ with `abi` set to __{@link workerRegistryAbi}__ and `functionName` set to `"register"`
+ */
+export const useSimulateWorkerRegistryRegister =
+ /*#__PURE__*/ createUseSimulateContract({
+ abi: workerRegistryAbi,
+ functionName: 'register',
+ })
+
+/**
+ * Wraps __{@link useSimulateContract}__ with `abi` set to __{@link workerRegistryAbi}__ and `functionName` set to `"updateMetadata"`
+ */
+export const useSimulateWorkerRegistryUpdateMetadata =
+ /*#__PURE__*/ createUseSimulateContract({
+ abi: workerRegistryAbi,
+ functionName: 'updateMetadata',
+ })
+
+/**
+ * Wraps __{@link useSimulateContract}__ with `abi` set to __{@link workerRegistryAbi}__ and `functionName` set to `"deregister"`
+ */
+export const useSimulateWorkerRegistryDeregister =
+ /*#__PURE__*/ createUseSimulateContract({
+ abi: workerRegistryAbi,
+ functionName: 'deregister',
+ })
+
+/**
+ * Wraps __{@link useSimulateContract}__ with `abi` set to __{@link workerRegistryAbi}__ and `functionName` set to `"withdraw"`
+ */
+export const useSimulateWorkerRegistryWithdraw =
+ /*#__PURE__*/ createUseSimulateContract({
+ abi: workerRegistryAbi,
+ functionName: 'withdraw',
+ })
diff --git a/src/api/contracts/useWriteTransaction.ts b/src/api/contracts/useWriteTransaction.ts
new file mode 100644
index 0000000..c0d125c
--- /dev/null
+++ b/src/api/contracts/useWriteTransaction.ts
@@ -0,0 +1,159 @@
+import { useState } from 'react';
+
+import { MutateOptions } from '@tanstack/react-query';
+import {
+ readContract,
+ waitForTransactionReceipt,
+ WaitForTransactionReceiptReturnType,
+ writeContract,
+} from '@wagmi/core';
+import {
+ Abi,
+ Address,
+ ContractFunctionArgs,
+ ContractFunctionName,
+ encodeFunctionData,
+ erc20Abi,
+ WriteContractErrorType,
+} from 'viem';
+import {
+ Config,
+ ResolvedRegister,
+ useAccount,
+ useConfig,
+ useWriteContract,
+ UseWriteContractParameters,
+ UseWriteContractReturnType,
+} from 'wagmi';
+import { WriteContractData, WriteContractVariables } from 'wagmi/query';
+
+import { useContracts } from '@network/useContracts';
+
+import { vestingAbi } from './subsquid.generated';
+
+export type UseWriteTransactionParameters<
+ config extends Config,
+ context,
+> = UseWriteContractParameters;
+
+export type UseWriteTransactionReturnType = Omit<
+ UseWriteContractReturnType,
+ 'writeContractAsync' | 'writeContract'
+> & {
+ writeTransactionAsync: WriteTransactionMutateAsync;
+};
+
+export type WriteTransactionMutateAsync = <
+ const abi extends Abi | readonly unknown[],
+ functionName extends ContractFunctionName,
+ args extends ContractFunctionArgs,
+ chainId extends config['chains'][number]['id'],
+>(
+ variables: WriteContractVariables & {
+ approve?: bigint;
+ vesting?: Address;
+ },
+ options?:
+ | MutateOptions<
+ WriteContractData,
+ WriteContractErrorType,
+ WriteContractVariables<
+ abi,
+ functionName,
+ args,
+ config,
+ chainId,
+ // use `functionName` to make sure it's not union of all possible function names
+ functionName
+ >,
+ context
+ >
+ | undefined,
+) => Promise>;
+
+export function useWriteSQDTransaction<
+ config extends Config = ResolvedRegister['config'],
+ context = unknown,
+>(
+ parameters: UseWriteTransactionParameters = {},
+): UseWriteTransactionReturnType {
+ const account = useAccount();
+ const config = useConfig(parameters);
+ const { writeContractAsync, ...result } = useWriteContract(parameters);
+ const [isPending, setPending] = useState(false);
+ const [error, setError] = useState(null);
+ const { SQD } = useContracts();
+
+ return {
+ ...(result as any),
+ isPending,
+ error,
+ isError: !!error,
+ writeTransactionAsync: async (
+ ...args: Parameters>
+ ) => {
+ setPending(true);
+ try {
+ const address =
+ (typeof args[0].account === 'string' ? args[0].account : args[0].account?.address) ||
+ account.address;
+ if (!address) return;
+
+ let hash: `0x${string}`;
+ if (args[0].vesting) {
+ const { vesting, address, ...rest } = args[0];
+
+ const encodedFunctionData = encodeFunctionData({
+ abi: args[0].abi,
+ functionName: args[0].functionName,
+ args: args[0].args,
+ });
+
+ hash = await writeContractAsync(
+ {
+ ...(args[0] as any),
+ address: vesting,
+ abi: vestingAbi,
+ functionName: 'execute',
+ args: args[0].approve
+ ? [address, encodedFunctionData, rest.approve]
+ : [address, encodedFunctionData],
+ },
+ args[1] as any,
+ );
+ } else {
+ if (args[0].approve) {
+ const amount = args[0].approve;
+
+ const allowance = await readContract(config, {
+ abi: erc20Abi,
+ functionName: 'allowance',
+ address: SQD,
+ args: [address, args[0].address],
+ });
+
+ if (allowance < amount) {
+ const hash = await writeContract(config as any, {
+ ...(args[0] as any),
+ abi: erc20Abi,
+ functionName: 'approve',
+ address: SQD,
+ args: [args[0].address, amount],
+ });
+ await waitForTransactionReceipt(config, { hash });
+ }
+ }
+
+ hash = await writeContractAsync(args[0], args[1] as any);
+ }
+
+ return await waitForTransactionReceipt(config, { hash });
+ } catch (e) {
+ setError(e as WriteContractErrorType);
+ throw e;
+ } finally {
+ setPending(false);
+ }
+ },
+ };
+}
diff --git a/src/api/contracts/vesting.abi.ts b/src/api/contracts/vesting.abi.ts
deleted file mode 100644
index 7c2108e..0000000
--- a/src/api/contracts/vesting.abi.ts
+++ /dev/null
@@ -1,215 +0,0 @@
-export const VESTING_CONTRACT_ABI = [
- {
- type: 'function',
- name: 'depositedIntoProtocol',
- inputs: [],
- outputs: [
- {
- name: '',
- type: 'uint256',
- internalType: 'uint256',
- },
- ],
- stateMutability: 'view',
- },
- {
- type: 'function',
- name: 'duration',
- inputs: [],
- outputs: [
- {
- name: '',
- type: 'uint256',
- internalType: 'uint256',
- },
- ],
- stateMutability: 'view',
- },
- {
- type: 'function',
- name: 'end',
- inputs: [],
- outputs: [
- {
- name: '',
- type: 'uint256',
- internalType: 'uint256',
- },
- ],
- stateMutability: 'view',
- },
- {
- type: 'function',
- name: 'execute',
- inputs: [
- {
- name: 'to',
- type: 'address',
- internalType: 'address',
- },
- {
- name: 'data',
- type: 'bytes',
- internalType: 'bytes',
- },
- ],
- outputs: [],
- stateMutability: 'nonpayable',
- },
- {
- type: 'function',
- name: 'execute',
- inputs: [
- {
- name: 'to',
- type: 'address',
- internalType: 'address',
- },
- {
- name: 'data',
- type: 'bytes',
- internalType: 'bytes',
- },
- {
- name: 'requiredApprove',
- type: 'uint256',
- internalType: 'uint256',
- },
- ],
- outputs: [
- {
- name: '',
- type: 'bytes',
- internalType: 'bytes',
- },
- ],
- stateMutability: 'nonpayable',
- },
- {
- type: 'function',
- name: 'expectedTotalAmount',
- inputs: [],
- outputs: [
- {
- name: '',
- type: 'uint256',
- internalType: 'uint256',
- },
- ],
- stateMutability: 'view',
- },
- {
- type: 'function',
- name: 'immediateReleaseBIP',
- inputs: [],
- outputs: [
- {
- name: '',
- type: 'uint256',
- internalType: 'uint256',
- },
- ],
- stateMutability: 'view',
- },
- {
- type: 'function',
- name: 'releasable',
- inputs: [
- {
- name: 'token',
- type: 'address',
- internalType: 'address',
- },
- ],
- outputs: [
- {
- name: '',
- type: 'uint256',
- internalType: 'uint256',
- },
- ],
- stateMutability: 'view',
- },
- {
- type: 'function',
- name: 'releasable',
- inputs: [],
- outputs: [
- {
- name: '',
- type: 'uint256',
- internalType: 'uint256',
- },
- ],
- stateMutability: 'view',
- },
- {
- type: 'function',
- name: 'release',
- inputs: [
- {
- name: 'token',
- type: 'address',
- internalType: 'address',
- },
- ],
- outputs: [],
- stateMutability: 'nonpayable',
- },
- {
- type: 'function',
- name: 'released',
- inputs: [
- {
- name: 'token',
- type: 'address',
- internalType: 'address',
- },
- ],
- outputs: [
- {
- name: '',
- type: 'uint256',
- internalType: 'uint256',
- },
- ],
- stateMutability: 'view',
- },
- {
- type: 'function',
- name: 'start',
- inputs: [],
- outputs: [
- {
- name: '',
- type: 'uint256',
- internalType: 'uint256',
- },
- ],
- stateMutability: 'view',
- },
- {
- type: 'function',
- name: 'vestedAmount',
- inputs: [
- {
- name: 'token',
- type: 'address',
- internalType: 'address',
- },
- {
- name: 'timestamp',
- type: 'uint64',
- internalType: 'uint64',
- },
- ],
- outputs: [
- {
- name: '',
- type: 'uint256',
- internalType: 'uint256',
- },
- ],
- stateMutability: 'view',
- },
-] as const;
diff --git a/src/api/contracts/vesting.ts b/src/api/contracts/vesting.ts
deleted file mode 100644
index 6e55445..0000000
--- a/src/api/contracts/vesting.ts
+++ /dev/null
@@ -1,144 +0,0 @@
-import { useState } from 'react';
-
-import { keepPreviousData } from '@tanstack/react-query';
-import { chunk } from 'lodash-es';
-import { erc20Abi, MulticallResponse } from 'viem';
-import { waitForTransactionReceipt } from 'viem/actions';
-import { useReadContracts, useWriteContract, useClient } from 'wagmi';
-
-import { useSquidNetworkHeight } from '@hooks/useSquidNetworkHeightHooks';
-import { useContracts } from '@network/useContracts';
-
-import { errorMessage, WriteContractRes } from './utils';
-import { VESTING_CONTRACT_ABI } from './vesting.abi';
-
-export function useVestingContracts({ addresses }: { addresses?: `0x${string}`[] }) {
- const contracts = useContracts();
- const { currentHeight, isLoading: isSquidHeightLoading } = useSquidNetworkHeight();
-
- const { data, isLoading } = useReadContracts({
- contracts: addresses?.flatMap(address => {
- const vestingContract = { abi: VESTING_CONTRACT_ABI, address } as const;
- return [
- {
- ...vestingContract,
- functionName: 'start',
- },
- {
- ...vestingContract,
- functionName: 'end',
- },
- {
- ...vestingContract,
- functionName: 'depositedIntoProtocol',
- },
- {
- ...vestingContract,
- functionName: 'releasable',
- args: [contracts.SQD],
- },
- {
- ...vestingContract,
- functionName: 'released',
- args: [contracts.SQD],
- },
- {
- abi: erc20Abi,
- address: contracts.SQD,
- functionName: 'balanceOf',
- args: [address],
- },
- {
- ...vestingContract,
- functionName: 'immediateReleaseBIP',
- },
- {
- ...vestingContract,
- functionName: 'expectedTotalAmount',
- },
- ] as const;
- }),
- allowFailure: true,
- // blockNumber: BigInt(currentHeight),
- query: {
- // enabled: !isSquidHeightLoading && !!addresses?.length,
- placeholderData: keepPreviousData,
- select: res => {
- if (res?.some(r => r.status === 'success')) {
- return chunk(res, 8).map(ch => ({
- start: Number(unwrapResult(ch[0])) * 1000,
- end: Number(unwrapResult(ch[1])) * 1000,
- deposited: unwrapResult(ch[2])?.toString(),
- releasable: unwrapResult(ch[3])?.toString(),
- released: unwrapResult(ch[4])?.toString(),
- balance: unwrapResult(ch[5])?.toString(),
- initialRelease: Number(unwrapResult(ch[6]) || 0) / 100,
- expectedTotal: unwrapResult(ch[7])?.toString(),
- }));
- } else if (res?.length === 0) {
- return [];
- }
-
- return undefined;
- },
- },
- });
-
- return {
- data,
- isLoading: isLoading,
- };
-}
-
-export function useVestingContract({ address }: { address?: `0x${string}` }) {
- const { data, isLoading } = useVestingContracts({ addresses: address ? [address] : [] });
-
- return {
- data: data?.[0],
- isLoading,
- };
-}
-
-function unwrapResult(result?: MulticallResponse): T | undefined {
- return result?.status === 'success' ? (result.result as T) : undefined;
-}
-
-export function useVestingContractRelease() {
- const client = useClient();
- const { setWaitHeight } = useSquidNetworkHeight();
- const [isLoading, setLoading] = useState(false);
- const [error, setError] = useState(null);
- const { SQD } = useContracts();
-
- const { writeContractAsync } = useWriteContract({});
-
- const release = async ({ address }: { address: `0x${string}` }): Promise => {
- setLoading(true);
-
- try {
- const hash = await writeContractAsync({
- abi: VESTING_CONTRACT_ABI,
- functionName: 'release',
- args: [SQD],
- address,
- });
-
- const receipt = await waitForTransactionReceipt(client!, { hash });
- setWaitHeight(receipt.blockNumber, []);
-
- return { success: true };
- } catch (e) {
- const failedReason = errorMessage(e);
- setError(failedReason);
- return { success: false, failedReason };
- } finally {
- setLoading(false);
- }
- };
-
- return {
- release,
- isLoading,
- error,
- };
-}
diff --git a/src/api/contracts/worker-registration/WorkerMetadata.ts b/src/api/contracts/worker-registration/WorkerMetadata.ts
index 5c86c37..86bdc06 100644
--- a/src/api/contracts/worker-registration/WorkerMetadata.ts
+++ b/src/api/contracts/worker-registration/WorkerMetadata.ts
@@ -2,9 +2,9 @@ import { pickBy } from 'lodash-es';
import isEmpty from 'lodash-es/isEmpty';
export interface WorkerMetadata {
- name: string;
- email: string;
- description: string;
+ name?: string;
+ email?: string;
+ description?: string;
website?: string;
}
diff --git a/src/api/contracts/worker-registration/WorkerRegistration.abi.ts b/src/api/contracts/worker-registration/WorkerRegistration.abi.ts
deleted file mode 100644
index 8f2c7a8..0000000
--- a/src/api/contracts/worker-registration/WorkerRegistration.abi.ts
+++ /dev/null
@@ -1,78 +0,0 @@
-export const WORKER_REGISTRATION_CONTRACT_ABI = [
- {
- type: 'function',
- name: 'bondAmount',
- inputs: [],
- outputs: [
- {
- name: '',
- type: 'uint256',
- internalType: 'uint256',
- },
- ],
- stateMutability: 'view',
- },
- {
- type: 'function',
- name: 'register',
- inputs: [
- {
- name: 'peerId',
- type: 'bytes',
- internalType: 'bytes',
- },
- {
- name: 'metadata',
- type: 'string',
- internalType: 'string',
- },
- ],
- outputs: [],
- stateMutability: 'nonpayable',
- },
- {
- type: 'function',
- name: 'updateMetadata',
- inputs: [
- {
- name: 'peerId',
- type: 'bytes',
- internalType: 'bytes',
- },
- {
- name: 'metadata',
- type: 'string',
- internalType: 'string',
- },
- ],
- outputs: [],
- stateMutability: 'nonpayable',
- },
- {
- inputs: [
- {
- internalType: 'bytes',
- name: 'peerId',
- type: 'bytes',
- },
- ],
- name: 'deregister',
- outputs: [],
- stateMutability: 'nonpayable',
- type: 'function',
- },
-
- {
- type: 'function',
- name: 'withdraw',
- inputs: [
- {
- name: 'peerId',
- type: 'bytes',
- internalType: 'bytes',
- },
- ],
- outputs: [],
- stateMutability: 'nonpayable',
- },
-] as const;
diff --git a/src/api/contracts/worker-registration/useRegisterWorker.ts b/src/api/contracts/worker-registration/useRegisterWorker.ts
deleted file mode 100644
index 457bae0..0000000
--- a/src/api/contracts/worker-registration/useRegisterWorker.ts
+++ /dev/null
@@ -1,151 +0,0 @@
-import { useState } from 'react';
-
-import { peerIdToHex } from '@lib/network';
-import { logger } from '@logger';
-import { encodeFunctionData } from 'viem';
-import { waitForTransactionReceipt } from 'viem/actions';
-import { useWriteContract, usePublicClient, useClient } from 'wagmi';
-
-import { useApproveSqd } from '@api/contracts/sqd';
-import { VESTING_CONTRACT_ABI } from '@api/contracts/vesting.abi';
-import { AccountType, SourceWallet } from '@api/subsquid-network-squid';
-import { useSquidNetworkHeight } from '@hooks/useSquidNetworkHeightHooks';
-import { useAccount } from '@network/useAccount';
-import { useContracts } from '@network/useContracts.ts';
-
-import { TxResult, errorMessage, isApproveRequiredError, WriteContractRes } from '../utils';
-
-import { encodeWorkerMetadata, WorkerMetadata } from './WorkerMetadata';
-import { WORKER_REGISTRATION_CONTRACT_ABI } from './WorkerRegistration.abi';
-
-export interface AddWorkerRequest extends WorkerMetadata {
- peerId: string;
- source: SourceWallet;
-}
-
-function useRegisterFromWallet() {
- const contracts = useContracts();
- const publicClient = usePublicClient();
- const [approveSqd] = useApproveSqd();
-
- const { writeContractAsync } = useWriteContract({});
-
- const tryCallRegistrationContract = async ({
- peerId,
- ...rest
- }: AddWorkerRequest): Promise => {
- try {
- return {
- tx: await writeContractAsync({
- address: contracts.WORKER_REGISTRATION,
- abi: WORKER_REGISTRATION_CONTRACT_ABI,
- functionName: 'register',
- args: [peerIdToHex(peerId), encodeWorkerMetadata(rest)],
- }),
- };
- } catch (e: unknown) {
- return {
- error: errorMessage(e),
- };
- }
- };
-
- return async (req: AddWorkerRequest): Promise => {
- logger.debug(`registering worker via worker contract...`);
-
- const res = await tryCallRegistrationContract(req);
- // Try to approve SQD
- if (isApproveRequiredError(res.error)) {
- const bond = await publicClient!.readContract({
- address: contracts.WORKER_REGISTRATION,
- abi: WORKER_REGISTRATION_CONTRACT_ABI,
- functionName: 'bondAmount',
- });
-
- const approveRes = await approveSqd({
- contractAddress: contracts.WORKER_REGISTRATION,
- amount: bond.toString(),
- });
- if (!approveRes.success) {
- return { error: approveRes.failedReason };
- }
-
- logger.debug(`approved SQD successfully, now trying to register one more time...`);
-
- return tryCallRegistrationContract(req);
- }
-
- return res;
- };
-}
-
-function useRegisterWorkerFromVestingContract() {
- const contracts = useContracts();
- const publicClient = usePublicClient();
- const { address: account } = useAccount();
- const { writeContractAsync } = useWriteContract({});
-
- return async ({ peerId, source, ...rest }: AddWorkerRequest): Promise => {
- try {
- const bond = await publicClient!.readContract({
- address: contracts.WORKER_REGISTRATION,
- abi: WORKER_REGISTRATION_CONTRACT_ABI,
- functionName: 'bondAmount',
- });
-
- const data = encodeFunctionData({
- abi: WORKER_REGISTRATION_CONTRACT_ABI,
- functionName: 'register',
- args: [peerIdToHex(peerId), encodeWorkerMetadata(rest)],
- });
-
- return {
- tx: await writeContractAsync({
- account,
- address: source.id as `0x${string}`,
- abi: VESTING_CONTRACT_ABI,
- functionName: 'execute',
- args: [contracts.WORKER_REGISTRATION, data, bond],
- }),
- };
- } catch (e: unknown) {
- return { error: errorMessage(e) };
- }
- };
-}
-
-export function useRegisterWorker() {
- const client = useClient();
- const { address } = useAccount();
- const [error, setError] = useState(null);
- const [isLoading, setLoading] = useState(false);
-
- const { setWaitHeight } = useSquidNetworkHeight();
- const registerWorkerContract = useRegisterFromWallet();
- const registerVestingContract = useRegisterWorkerFromVestingContract();
-
- const registerWorker = async (req: AddWorkerRequest): Promise => {
- setLoading(true);
-
- const { tx, error } =
- req.source.type === AccountType.Vesting
- ? await registerVestingContract(req)
- : await registerWorkerContract(req);
-
- if (!tx) {
- logger.debug(`registering worker failed ${error}`);
- setLoading(false);
- setError(error);
- return { success: false, failedReason: error };
- }
-
- const receipt = await waitForTransactionReceipt(client!, { hash: tx });
- setWaitHeight(receipt.blockNumber, ['myWorkers', { address }]);
- setLoading(false);
- setError(null);
-
- return { success: true };
- };
-
- return { registerWorker, isLoading, error };
-}
diff --git a/src/api/contracts/worker-registration/useUnregisterWorker.ts b/src/api/contracts/worker-registration/useUnregisterWorker.ts
deleted file mode 100644
index bea5a0a..0000000
--- a/src/api/contracts/worker-registration/useUnregisterWorker.ts
+++ /dev/null
@@ -1,113 +0,0 @@
-import { useState } from 'react';
-
-import { peerIdToHex } from '@lib/network';
-import { logger } from '@logger';
-import { encodeFunctionData } from 'viem';
-import { waitForTransactionReceipt } from 'viem/actions';
-import { useWriteContract, useClient } from 'wagmi';
-
-import { VESTING_CONTRACT_ABI } from '@api/contracts/vesting.abi';
-import { AccountType } from '@api/subsquid-network-squid';
-import { useSquidNetworkHeight } from '@hooks/useSquidNetworkHeightHooks';
-import { useAccount } from '@network/useAccount';
-import { useContracts } from '@network/useContracts.ts';
-
-import { TxResult, errorMessage, WriteContractRes } from '../utils';
-
-import { WORKER_REGISTRATION_CONTRACT_ABI } from './WorkerRegistration.abi';
-
-export interface UnregisterWorkerRequest {
- peerId: string;
- source: {
- id: string;
- type: AccountType;
- };
-}
-
-function useUnregisterWorkerFromWallet() {
- const contracts = useContracts();
- const { writeContractAsync } = useWriteContract({});
-
- return async ({ peerId }: { peerId: string }): Promise => {
- try {
- return {
- tx: await writeContractAsync({
- address: contracts.WORKER_REGISTRATION,
- abi: WORKER_REGISTRATION_CONTRACT_ABI,
- functionName: 'deregister',
- args: [peerIdToHex(peerId)],
- }),
- };
- } catch (e) {
- return { error: errorMessage(e) };
- }
- };
-}
-
-function useUnregisterWorkerFromVestingContract() {
- const contracts = useContracts();
- const { address: account } = useAccount();
- const { writeContractAsync } = useWriteContract({});
-
- return async ({ peerId, source }: UnregisterWorkerRequest): Promise => {
- try {
- const data = encodeFunctionData({
- abi: WORKER_REGISTRATION_CONTRACT_ABI,
- functionName: 'deregister',
- args: [peerIdToHex(peerId)],
- });
-
- return {
- tx: await writeContractAsync({
- account,
- address: source.id as `0x${string}`,
- abi: VESTING_CONTRACT_ABI,
- functionName: 'execute',
- args: [contracts.WORKER_REGISTRATION, data],
- }),
- };
- } catch (e: unknown) {
- return { error: errorMessage(e) };
- }
- };
-}
-
-export function useUnregisterWorker() {
- const client = useClient();
- const { address } = useAccount();
- const [isLoading, setLoading] = useState(false);
- const { setWaitHeight } = useSquidNetworkHeight();
- const [error, setError] = useState(null);
-
- const unregisterWorkerFromWallet = useUnregisterWorkerFromWallet();
- const unregisterWorkerFromVestingContract = useUnregisterWorkerFromVestingContract();
-
- const unregisterWorker = async (req: UnregisterWorkerRequest): Promise => {
- setLoading(true);
-
- const { tx, error } =
- req.source.type === AccountType.User
- ? await unregisterWorkerFromWallet(req)
- : await unregisterWorkerFromVestingContract(req);
-
- if (!tx) {
- logger.debug(`update worker failed ${error}`);
- setLoading(false);
- setError(error);
- return { success: false, failedReason: error };
- }
-
- const receipt = await waitForTransactionReceipt(client!, { hash: tx });
- setWaitHeight(receipt.blockNumber, ['myWorkers', { address }]);
- setLoading(false);
- setError(null);
-
- return { success: true };
- };
-
- return {
- unregisterWorker,
- isLoading,
- error,
- };
-}
diff --git a/src/api/contracts/worker-registration/useUpdateWorker.ts b/src/api/contracts/worker-registration/useUpdateWorker.ts
deleted file mode 100644
index 5f3581f..0000000
--- a/src/api/contracts/worker-registration/useUpdateWorker.ts
+++ /dev/null
@@ -1,110 +0,0 @@
-import { useState } from 'react';
-
-import { peerIdToHex } from '@lib/network';
-import { logger } from '@logger';
-import { encodeFunctionData } from 'viem';
-import { waitForTransactionReceipt } from 'viem/actions';
-import { useWriteContract, useClient } from 'wagmi';
-
-import { AccountType } from '@api/subsquid-network-squid';
-import { useSquidNetworkHeight } from '@hooks/useSquidNetworkHeightHooks';
-import { useAccount } from '@network/useAccount';
-import { useContracts } from '@network/useContracts.ts';
-
-import { TxResult, errorMessage, WriteContractRes } from '../utils';
-import { VESTING_CONTRACT_ABI } from '../vesting.abi';
-
-import { encodeWorkerMetadata, WorkerMetadata } from './WorkerMetadata';
-import { WORKER_REGISTRATION_CONTRACT_ABI } from './WorkerRegistration.abi';
-
-export interface UpdateWorkerRequest extends WorkerMetadata {
- peerId: string;
- source: {
- id: string;
- type: AccountType;
- };
-}
-
-function useUpdateWorkerFromWallet() {
- const contracts = useContracts();
- const { writeContractAsync } = useWriteContract({});
-
- return async ({ peerId, ...rest }: UpdateWorkerRequest): Promise => {
- try {
- return {
- tx: await writeContractAsync({
- address: contracts.WORKER_REGISTRATION,
- abi: WORKER_REGISTRATION_CONTRACT_ABI,
- functionName: 'updateMetadata',
- args: [peerIdToHex(peerId), encodeWorkerMetadata(rest)],
- }),
- };
- } catch (e) {
- return { error: errorMessage(e) };
- }
- };
-}
-
-function useUpdateWorkerFromVestingContract() {
- const contracts = useContracts();
- const { address: account } = useAccount();
- const { writeContractAsync } = useWriteContract({});
-
- return async ({ peerId, source, ...rest }: UpdateWorkerRequest): Promise => {
- try {
- const data = encodeFunctionData({
- abi: WORKER_REGISTRATION_CONTRACT_ABI,
- functionName: 'updateMetadata',
- args: [peerIdToHex(peerId), encodeWorkerMetadata(rest)],
- });
-
- return {
- tx: await writeContractAsync({
- account,
- address: source.id as `0x${string}`,
- abi: VESTING_CONTRACT_ABI,
- functionName: 'execute',
- args: [contracts.WORKER_REGISTRATION, data],
- }),
- };
- } catch (e: unknown) {
- return { error: errorMessage(e) };
- }
- };
-}
-
-export function useUpdateWorker() {
- const client = useClient();
- const { address } = useAccount();
- const [error, setError] = useState(null);
- const [isLoading, setLoading] = useState(false);
-
- const { setWaitHeight } = useSquidNetworkHeight();
- const updateWorkerFromWallet = useUpdateWorkerFromWallet();
- const updateWorkerFromVestingContract = useUpdateWorkerFromVestingContract();
-
- const updateWorker = async (req: UpdateWorkerRequest): Promise => {
- setLoading(true);
-
- const { tx, error } =
- req.source.type === AccountType.User
- ? await updateWorkerFromWallet(req)
- : await updateWorkerFromVestingContract(req);
-
- if (!tx) {
- logger.debug(`update worker failed ${error}`);
- setLoading(false);
- setError(error);
- return { success: false, failedReason: error };
- }
-
- const receipt = await waitForTransactionReceipt(client!, { hash: tx });
- setWaitHeight(receipt.blockNumber, ['myWorkers', { address }]);
- setLoading(false);
- setError(null);
-
- return { success: true };
- };
-
- return { updateWorker, isLoading, error };
-}
diff --git a/src/api/contracts/worker-registration/useWithdrawWorker.ts b/src/api/contracts/worker-registration/useWithdrawWorker.ts
deleted file mode 100644
index c72ac25..0000000
--- a/src/api/contracts/worker-registration/useWithdrawWorker.ts
+++ /dev/null
@@ -1,106 +0,0 @@
-import { useState } from 'react';
-
-import { peerIdToHex } from '@lib/network';
-import { logger } from '@logger';
-import { encodeFunctionData } from 'viem';
-import { waitForTransactionReceipt } from 'viem/actions';
-import { useWriteContract, useClient } from 'wagmi';
-
-import { VESTING_CONTRACT_ABI } from '@api/contracts/vesting.abi';
-import { UnregisterWorkerRequest } from '@api/contracts/worker-registration/useUnregisterWorker';
-import { AccountType } from '@api/subsquid-network-squid';
-import { useSquidNetworkHeight } from '@hooks/useSquidNetworkHeightHooks';
-import { useAccount } from '@network/useAccount';
-import { useContracts } from '@network/useContracts.ts';
-
-import { TxResult, errorMessage, WriteContractRes } from '../utils';
-
-import { WORKER_REGISTRATION_CONTRACT_ABI } from './WorkerRegistration.abi';
-
-function useWithdrawWorkerFromWallet() {
- const contracts = useContracts();
- const { writeContractAsync } = useWriteContract({});
-
- return async ({ peerId }: { peerId: string }): Promise => {
- try {
- return {
- tx: await writeContractAsync({
- address: contracts.WORKER_REGISTRATION,
- abi: WORKER_REGISTRATION_CONTRACT_ABI,
- functionName: 'withdraw',
- args: [peerIdToHex(peerId)],
- }),
- };
- } catch (e) {
- return { error: errorMessage(e) };
- }
- };
-}
-
-function useWithdrawWorkerFromVestingContract() {
- const contracts = useContracts();
- const { address: account } = useAccount();
- const { writeContractAsync } = useWriteContract({});
-
- return async ({ peerId, source }: UnregisterWorkerRequest): Promise => {
- try {
- const data = encodeFunctionData({
- abi: WORKER_REGISTRATION_CONTRACT_ABI,
- functionName: 'withdraw',
- args: [peerIdToHex(peerId)],
- });
-
- return {
- tx: await writeContractAsync({
- account,
- address: source.id as `0x${string}`,
- abi: VESTING_CONTRACT_ABI,
- functionName: 'execute',
- args: [contracts.WORKER_REGISTRATION, data],
- }),
- };
- } catch (e: unknown) {
- return { error: errorMessage(e) };
- }
- };
-}
-
-export function useWithdrawWorker() {
- const client = useClient();
- const { address } = useAccount();
- const [isLoading, setLoading] = useState(false);
- const { setWaitHeight } = useSquidNetworkHeight();
- const [error, setError] = useState(null);
-
- const withdrawWorkerFromWallet = useWithdrawWorkerFromWallet();
- const withdrawWorkerFromVestingContract = useWithdrawWorkerFromVestingContract();
-
- const withdrawWorker = async (req: UnregisterWorkerRequest): Promise => {
- setLoading(true);
-
- const { tx, error } =
- req.source.type === AccountType.User
- ? await withdrawWorkerFromWallet(req)
- : await withdrawWorkerFromVestingContract(req);
-
- if (!tx) {
- logger.debug(`withdraw worker failed ${error}`);
- setLoading(false);
- setError(error);
- return { success: false, failedReason: error };
- }
-
- const receipt = await waitForTransactionReceipt(client!, { hash: tx });
- setWaitHeight(receipt.blockNumber, ['myWorkers', { address }]);
- setLoading(false);
- setError(null);
-
- return { success: true };
- };
-
- return {
- withdrawWorker,
- isLoading,
- error,
- };
-}
diff --git a/src/api/subsquid-network-squid/accounts-graphql.ts b/src/api/subsquid-network-squid/accounts-graphql.ts
index f316701..6d85ecb 100644
--- a/src/api/subsquid-network-squid/accounts-graphql.ts
+++ b/src/api/subsquid-network-squid/accounts-graphql.ts
@@ -1,14 +1,13 @@
import { useMemo } from 'react';
-import BigNumber from 'bignumber.js';
+import { UseQueryOptions } from '@tanstack/react-query';
import { useAccount } from '@network/useAccount';
-import { useSquidDataSource } from './datasource';
+import { useSquid } from './datasource';
import {
AccountType,
- useAccountQuery,
- useMyAssetsQuery,
+ useSourcesQuery,
useVestingByAddressQuery,
VestingFragmentFragment,
} from './graphql';
@@ -22,108 +21,40 @@ export type SourceWalletWithBalance = SourceWallet & {
balance: string;
};
-export function useMySources({ enabled }: { enabled?: boolean } = {}) {
- const datasource = useSquidDataSource();
+export function useMySources({
+ enabled,
+ select = data => data as TData,
+}: {
+ enabled?: boolean;
+ select?: UseQueryOptions['select'];
+} = {}) {
+ const squid = useSquid();
const { address } = useAccount();
- const requestEnabled = enabled && !!address;
- const { data: data, isPending } = useAccountQuery(
- datasource,
- {
- address: address || '',
- },
- {
- enabled: requestEnabled,
- },
- );
-
- const wallet = data?.accountById;
-
- const res = useMemo((): SourceWalletWithBalance[] => {
- return !wallet
- ? [
- {
- type: AccountType.User,
- id: address as string,
- balance: '0',
- },
- ]
- : [wallet, ...wallet.owned].map(a => ({
- type: a.type,
- id: a.id,
- balance: a.balance,
- }));
- }, [address, wallet]);
-
- const vestingContracts = useMemo(() => {
- return res.filter(a => a.type === AccountType.Vesting);
- }, [res]);
- return {
- sources: res,
- vestingContracts,
- isPending,
- };
-}
-
-export function useMyAssets() {
- const datasource = useSquidDataSource();
- const { address } = useAccount();
-
- const enabled = !!address;
- const { data, isLoading } = useMyAssetsQuery(
- datasource,
- {
- address: address || '',
- },
+ const { data: sourcesQuery, isLoading } = useSourcesQuery(
+ squid,
+ { address: address || '0x' },
{ enabled },
);
- const assets = useMemo(() => {
- const accounts = data?.accounts || [];
- const delegations = data?.delegations || [];
- const workers = data?.workers || [];
-
- let balance = BigNumber(0);
- let locked = BigNumber(0);
- let bonded = BigNumber(0);
- let claimable = BigNumber(0);
- let delegated = BigNumber(0);
- const vestings: SourceWalletWithBalance[] = [];
-
- for (const a of accounts) {
- balance = balance.plus(a.balance);
-
- for (const o of a.owned) {
- locked = locked.plus(o.balance);
- vestings.push({
- id: o.id,
- type: AccountType.Vesting,
- balance: BigNumber(o.balance).toFixed(0),
- });
- }
- }
- for (const w of workers) {
- bonded = bonded.plus(w.bond);
- claimable = claimable.plus(w.claimableReward);
- }
- for (const d of delegations) {
- claimable = claimable.plus(d.claimableReward);
- delegated = delegated.plus(d.deposit);
- }
-
- return {
- balance: balance.toFixed(0),
- locked: locked.toFixed(0),
- bonded: bonded.toFixed(0),
- claimable: claimable.toFixed(0),
- delegated: delegated.toFixed(0),
- vestings,
- total: balance.plus(locked).plus(bonded).plus(claimable).plus(delegated).toFixed(0),
- };
- }, [data]);
+ const data: SourceWalletWithBalance[] = useMemo(
+ () =>
+ !sourcesQuery?.accounts?.length
+ ? [
+ {
+ id: address || '0x',
+ type: AccountType.User,
+ balance: '0',
+ },
+ ]
+ : sourcesQuery?.accounts,
+ [address, sourcesQuery?.accounts],
+ );
+
+ const tData: TData = useMemo(() => select(data), [data, select]);
return {
- assets,
+ data: tData,
isLoading,
};
}
@@ -144,7 +75,7 @@ export class BlockchainApiVesting {
}
export function useVestingByAddress({ address }: { address?: string }) {
- const datasource = useSquidDataSource();
+ const datasource = useSquid();
const account = useAccount();
const { data, isPending } = useVestingByAddressQuery(
diff --git a/src/api/subsquid-network-squid/datasource.ts b/src/api/subsquid-network-squid/datasource.ts
index bb378bd..5832d6b 100644
--- a/src/api/subsquid-network-squid/datasource.ts
+++ b/src/api/subsquid-network-squid/datasource.ts
@@ -1,6 +1,6 @@
import { NetworkName, getSubsquidNetwork } from '@network/useSubsquidNetwork';
-export function useSquidDataSource() {
+export function useSquid() {
const network = getSubsquidNetwork();
return {
diff --git a/src/api/subsquid-network-squid/fixes.ts b/src/api/subsquid-network-squid/fixes.ts
new file mode 100644
index 0000000..3bfd987
--- /dev/null
+++ b/src/api/subsquid-network-squid/fixes.ts
@@ -0,0 +1,176 @@
+import { useMemo } from 'react';
+
+import { getBlockTime } from '@lib/network';
+import { Simplify } from 'type-fest';
+import { useBlock, useReadContracts } from 'wagmi';
+
+import { Worker, WorkerStatus } from '@api/subsquid-network-squid';
+import { useContracts } from '@network/useContracts';
+
+import {
+ stakingAbi,
+ useReadRouterStaking,
+ useReadRouterWorkerRegistration,
+ useReadWorkerRegistryLockPeriod,
+ workerRegistryAbi,
+} from '../contracts/subsquid.generated';
+
+export function useFixWorkers>({
+ workers,
+}: {
+ workers?: T[];
+}) {
+ const { ROUTER, CHAIN_ID_L1 } = useContracts();
+
+ const { data: registryAddress, isLoading: isRegistryAddressLoading } =
+ useReadRouterWorkerRegistration({
+ address: ROUTER,
+ query: { enabled: !!ROUTER },
+ });
+
+ const { data: lockPeriod, isLoading: isLockPeriodLoading } = useReadWorkerRegistryLockPeriod({
+ address: registryAddress || '0x',
+ });
+
+ const { data: lastL1Block, isLoading: isLastL1BlockLoading } = useBlock({
+ chainId: CHAIN_ID_L1,
+ includeTransactions: false,
+ });
+
+ const { data: workersInfo, isLoading: isWorkersInfoLoading } = useReadContracts({
+ contracts: workers?.map(worker => {
+ return {
+ abi: workerRegistryAbi,
+ address: registryAddress || '0x',
+ functionName: 'getWorker',
+ args: [BigInt(worker.id)],
+ } as const;
+ }),
+ allowFailure: false,
+ query: {
+ enabled: !!workers && !!registryAddress,
+ },
+ });
+
+ const data = useMemo(() => {
+ if (!workersInfo || !lastL1Block) return workers;
+
+ return workers?.map((worker, i) => {
+ const workerInfo = workersInfo?.[i];
+
+ const registerBlock = workerInfo.registeredAt;
+ const deregisterBlock = workerInfo.deregisteredAt;
+ const unlockBlock = deregisterBlock + (lockPeriod ?? 0n);
+ const timestamp = Number(lastL1Block.timestamp) * 1000;
+
+ const { status, statusChangeAt } =
+ lastL1Block.number < registerBlock
+ ? {
+ status: WorkerStatus.Registering,
+ statusChangeAt: new Date(
+ timestamp + getBlockTime(registerBlock - lastL1Block.number),
+ ).toString(),
+ }
+ : lastL1Block.number < deregisterBlock
+ ? {
+ status: WorkerStatus.Deregistering,
+ statusChangeAt: new Date(
+ timestamp + getBlockTime(deregisterBlock - lastL1Block.number),
+ ).toString(),
+ }
+ : { status: worker.status };
+
+ const { locked, unlockedAt } =
+ lastL1Block.number < unlockBlock
+ ? {
+ locked: true,
+ unlockedAt: new Date(
+ timestamp + getBlockTime(unlockBlock - lastL1Block.number),
+ ).toISOString(),
+ }
+ : { locked: false };
+
+ return {
+ ...worker,
+ status,
+ statusChangeAt,
+ locked,
+ unlockedAt,
+ };
+ });
+ }, [workers, workersInfo, lastL1Block, lockPeriod]);
+
+ return {
+ isLoading:
+ isRegistryAddressLoading ||
+ isLockPeriodLoading ||
+ isLastL1BlockLoading ||
+ isWorkersInfoLoading,
+ data,
+ };
+}
+
+export function useFixDelegations<
+ T extends { id: string; delegations: { owner: { id: string } }[] },
+>({ workers }: { workers?: T[] }) {
+ const { ROUTER, CHAIN_ID_L1 } = useContracts();
+
+ const { data: stakingAddress, isLoading: isStakingAddressLoading } = useReadRouterStaking({
+ address: ROUTER,
+ query: { enabled: !!ROUTER },
+ });
+
+ const { data: lastL1Block, isLoading: isLastL1BlockLoading } = useBlock({
+ chainId: CHAIN_ID_L1,
+ includeTransactions: false,
+ });
+
+ const { data: delegationsInfo, isLoading: isDelegationsInfoLoading } = useReadContracts({
+ contracts: workers?.flatMap(worker =>
+ worker.delegations.map(
+ delegation =>
+ ({
+ abi: stakingAbi,
+ address: stakingAddress || '0x',
+ functionName: 'getDeposit',
+ args: [delegation.owner.id as `0x${string}`, worker.id],
+ }) as const,
+ ),
+ ),
+ allowFailure: false,
+ query: { enabled: !!workers && !!stakingAddress },
+ });
+
+ type R = Simplify<
+ Omit & {
+ delegations: Simplify[];
+ }
+ >;
+
+ const data = useMemo(() => {
+ if (!delegationsInfo || !lastL1Block || !workers) return workers;
+
+ let index = 0;
+ return workers.map(
+ worker =>
+ ({
+ ...worker,
+ delegations: worker.delegations.map(delegation => {
+ const [, unlockBlock] = delegationsInfo[index++];
+ const timestamp = Number(lastL1Block.timestamp) * 1000;
+ const locked = lastL1Block.number < unlockBlock;
+ const unlockedAt = locked
+ ? new Date(timestamp + getBlockTime(unlockBlock - lastL1Block.number)).toISOString()
+ : undefined;
+
+ return { ...delegation, locked, unlockedAt };
+ }),
+ }) as R,
+ );
+ }, [delegationsInfo, lastL1Block, workers]);
+
+ return {
+ data,
+ isLoading: isDelegationsInfoLoading || isLastL1BlockLoading || isStakingAddressLoading,
+ };
+}
diff --git a/src/api/subsquid-network-squid/gateways-graphql.ts b/src/api/subsquid-network-squid/gateways-graphql.ts
index c548f44..19b1950 100644
--- a/src/api/subsquid-network-squid/gateways-graphql.ts
+++ b/src/api/subsquid-network-squid/gateways-graphql.ts
@@ -1,32 +1,27 @@
-import { useSquidDataSource } from '@api/subsquid-network-squid/datasource';
+import { useSquid } from '@api/subsquid-network-squid/datasource';
import { useAccount } from '@network/useAccount';
-import {
- GatewayFragmentFragment,
- useGatewayByPeerIdQuery,
- useMyGatewaysQuery,
- useMyGatewayStakesQuery,
-} from './graphql';
+import { useGatewayByPeerIdQuery, useMyGatewaysQuery, useMyGatewayStakesQuery } from './graphql';
// inherit API interface for internal class
-export interface BlockchainGateway extends GatewayFragmentFragment {
- owner: Exclude;
-}
+// export interface BlockchainGateway extends GatewayFragmentFragment {
+// owner: Exclude;
+// }
-export class BlockchainGateway {
- ownedByMe?: boolean;
+// export class BlockchainGateway {
+// ownedByMe?: boolean;
- constructor({ gateway, address }: { gateway: GatewayFragmentFragment; address?: `0x${string}` }) {
- Object.assign(this, {
- ...gateway,
- createdAt: new Date(),
- ownedByMe: gateway?.owner?.id === address,
- });
- }
-}
+// constructor({ gateway, address }: { gateway: GatewayFragmentFragment; address?: `0x${string}` }) {
+// Object.assign(this, {
+// ...gateway,
+// createdAt: new Date(),
+// ownedByMe: gateway?.owner?.id === address,
+// });
+// }
+// }
export function useMyGateways() {
- const datasource = useSquidDataSource();
+ const datasource = useSquid();
const { address } = useAccount();
const enabled = !!address;
@@ -37,13 +32,7 @@ export function useMyGateways() {
},
{
select: res => {
- return res.gateways.map(
- gateway =>
- new BlockchainGateway({
- gateway,
- address,
- }),
- );
+ return res.gateways;
},
enabled,
},
@@ -56,8 +45,7 @@ export function useMyGateways() {
}
export function useGatewayByPeerId(peerId?: string) {
- const datasource = useSquidDataSource();
- const { address } = useAccount();
+ const datasource = useSquid();
const enabled = !!peerId;
const { data, isLoading } = useGatewayByPeerIdQuery(
@@ -69,10 +57,7 @@ export function useGatewayByPeerId(peerId?: string) {
select: res => {
if (!res.gatewayById) return;
- return new BlockchainGateway({
- gateway: res.gatewayById,
- address,
- });
+ return res.gatewayById;
},
enabled,
},
@@ -84,8 +69,8 @@ export function useGatewayByPeerId(peerId?: string) {
};
}
-export function useMyGatewayStakes() {
- const datasource = useSquidDataSource();
+export function useMyGatewayStake() {
+ const datasource = useSquid();
const { address } = useAccount();
const enabled = !!address;
@@ -97,7 +82,7 @@ export function useMyGatewayStakes() {
{
select: res => {
return {
- operators: res.gatewayOperators.filter(o => o.pendingStake || o.stake),
+ stake: res.gatewayStakes.length ? res.gatewayStakes[0] : undefined,
...res.networkStats,
};
},
diff --git a/src/api/subsquid-network-squid/graphql.tsx b/src/api/subsquid-network-squid/graphql.tsx
index 3ab0771..56c25f5 100644
--- a/src/api/subsquid-network-squid/graphql.tsx
+++ b/src/api/subsquid-network-squid/graphql.tsx
@@ -53,7 +53,7 @@ export type Account = {
claimableDelegationCount: Scalars['Int']['output'];
claims: Array;
delegations: Array;
- gatewayOperator?: Maybe;
+ delegations2: Array;
gatewayStakes: Array;
gateways: Array;
id: Scalars['String']['output'];
@@ -64,6 +64,7 @@ export type Account = {
transfersTo: Array;
type: AccountType;
workers: Array;
+ workers2: Array;
};
export type AccountClaimsArgs = {
@@ -80,6 +81,13 @@ export type AccountDelegationsArgs = {
where?: InputMaybe;
};
+export type AccountDelegations2Args = {
+ limit?: InputMaybe;
+ offset?: InputMaybe;
+ orderBy?: InputMaybe>;
+ where?: InputMaybe;
+};
+
export type AccountGatewayStakesArgs = {
limit?: InputMaybe;
offset?: InputMaybe;
@@ -129,6 +137,13 @@ export type AccountWorkersArgs = {
where?: InputMaybe;
};
+export type AccountWorkers2Args = {
+ limit?: InputMaybe;
+ offset?: InputMaybe;
+ orderBy?: InputMaybe>;
+ where?: InputMaybe;
+};
+
export type AccountEdge = {
__typename?: 'AccountEdge';
cursor: Scalars['String']['output'];
@@ -148,18 +163,6 @@ export enum AccountOrderByInput {
ClaimableDelegationCountDesc = 'claimableDelegationCount_DESC',
ClaimableDelegationCountDescNullsFirst = 'claimableDelegationCount_DESC_NULLS_FIRST',
ClaimableDelegationCountDescNullsLast = 'claimableDelegationCount_DESC_NULLS_LAST',
- GatewayOperatorAutoExtensionAsc = 'gatewayOperator_autoExtension_ASC',
- GatewayOperatorAutoExtensionAscNullsFirst = 'gatewayOperator_autoExtension_ASC_NULLS_FIRST',
- GatewayOperatorAutoExtensionAscNullsLast = 'gatewayOperator_autoExtension_ASC_NULLS_LAST',
- GatewayOperatorAutoExtensionDesc = 'gatewayOperator_autoExtension_DESC',
- GatewayOperatorAutoExtensionDescNullsFirst = 'gatewayOperator_autoExtension_DESC_NULLS_FIRST',
- GatewayOperatorAutoExtensionDescNullsLast = 'gatewayOperator_autoExtension_DESC_NULLS_LAST',
- GatewayOperatorIdAsc = 'gatewayOperator_id_ASC',
- GatewayOperatorIdAscNullsFirst = 'gatewayOperator_id_ASC_NULLS_FIRST',
- GatewayOperatorIdAscNullsLast = 'gatewayOperator_id_ASC_NULLS_LAST',
- GatewayOperatorIdDesc = 'gatewayOperator_id_DESC',
- GatewayOperatorIdDescNullsFirst = 'gatewayOperator_id_DESC_NULLS_FIRST',
- GatewayOperatorIdDescNullsLast = 'gatewayOperator_id_DESC_NULLS_LAST',
IdAsc = 'id_ASC',
IdAscNullsFirst = 'id_ASC_NULLS_FIRST',
IdAscNullsLast = 'id_ASC_NULLS_LAST',
@@ -342,11 +345,12 @@ export type AccountWhereInput = {
claims_every?: InputMaybe;
claims_none?: InputMaybe;
claims_some?: InputMaybe;
+ delegations2_every?: InputMaybe;
+ delegations2_none?: InputMaybe;
+ delegations2_some?: InputMaybe;
delegations_every?: InputMaybe;
delegations_none?: InputMaybe;
delegations_some?: InputMaybe;
- gatewayOperator?: InputMaybe;
- gatewayOperator_isNull?: InputMaybe;
gatewayStakes_every?: InputMaybe;
gatewayStakes_none?: InputMaybe;
gatewayStakes_some?: InputMaybe;
@@ -389,6 +393,9 @@ export type AccountWhereInput = {
type_isNull?: InputMaybe;
type_not_eq?: InputMaybe;
type_not_in?: InputMaybe>;
+ workers2_every?: InputMaybe;
+ workers2_none?: InputMaybe;
+ workers2_some?: InputMaybe;
workers_every?: InputMaybe;
workers_none?: InputMaybe;
workers_some?: InputMaybe;
@@ -1808,8 +1815,9 @@ export type Gateway = {
endpointUrl?: Maybe;
id: Scalars['String']['output'];
name?: Maybe;
- operator?: Maybe;
- owner?: Maybe;
+ owner: Account;
+ realOwner: Account;
+ stake: GatewayStake;
status: GatewayStatus;
statusHistory: Array;
website?: Maybe;
@@ -1828,193 +1836,6 @@ export type GatewayEdge = {
node: Gateway;
};
-export type GatewayOperator = {
- __typename?: 'GatewayOperator';
- account: Account;
- autoExtension: Scalars['Boolean']['output'];
- gateways: Array;
- id: Scalars['String']['output'];
- pendingStake?: Maybe;
- stake?: Maybe;
-};
-
-export type GatewayOperatorGatewaysArgs = {
- limit?: InputMaybe;
- offset?: InputMaybe;
- orderBy?: InputMaybe>;
- where?: InputMaybe;
-};
-
-export type GatewayOperatorEdge = {
- __typename?: 'GatewayOperatorEdge';
- cursor: Scalars['String']['output'];
- node: GatewayOperator;
-};
-
-export enum GatewayOperatorOrderByInput {
- AccountBalanceAsc = 'account_balance_ASC',
- AccountBalanceAscNullsFirst = 'account_balance_ASC_NULLS_FIRST',
- AccountBalanceAscNullsLast = 'account_balance_ASC_NULLS_LAST',
- AccountBalanceDesc = 'account_balance_DESC',
- AccountBalanceDescNullsFirst = 'account_balance_DESC_NULLS_FIRST',
- AccountBalanceDescNullsLast = 'account_balance_DESC_NULLS_LAST',
- AccountClaimableDelegationCountAsc = 'account_claimableDelegationCount_ASC',
- AccountClaimableDelegationCountAscNullsFirst = 'account_claimableDelegationCount_ASC_NULLS_FIRST',
- AccountClaimableDelegationCountAscNullsLast = 'account_claimableDelegationCount_ASC_NULLS_LAST',
- AccountClaimableDelegationCountDesc = 'account_claimableDelegationCount_DESC',
- AccountClaimableDelegationCountDescNullsFirst = 'account_claimableDelegationCount_DESC_NULLS_FIRST',
- AccountClaimableDelegationCountDescNullsLast = 'account_claimableDelegationCount_DESC_NULLS_LAST',
- AccountIdAsc = 'account_id_ASC',
- AccountIdAscNullsFirst = 'account_id_ASC_NULLS_FIRST',
- AccountIdAscNullsLast = 'account_id_ASC_NULLS_LAST',
- AccountIdDesc = 'account_id_DESC',
- AccountIdDescNullsFirst = 'account_id_DESC_NULLS_FIRST',
- AccountIdDescNullsLast = 'account_id_DESC_NULLS_LAST',
- AccountTypeAsc = 'account_type_ASC',
- AccountTypeAscNullsFirst = 'account_type_ASC_NULLS_FIRST',
- AccountTypeAscNullsLast = 'account_type_ASC_NULLS_LAST',
- AccountTypeDesc = 'account_type_DESC',
- AccountTypeDescNullsFirst = 'account_type_DESC_NULLS_FIRST',
- AccountTypeDescNullsLast = 'account_type_DESC_NULLS_LAST',
- AutoExtensionAsc = 'autoExtension_ASC',
- AutoExtensionAscNullsFirst = 'autoExtension_ASC_NULLS_FIRST',
- AutoExtensionAscNullsLast = 'autoExtension_ASC_NULLS_LAST',
- AutoExtensionDesc = 'autoExtension_DESC',
- AutoExtensionDescNullsFirst = 'autoExtension_DESC_NULLS_FIRST',
- AutoExtensionDescNullsLast = 'autoExtension_DESC_NULLS_LAST',
- IdAsc = 'id_ASC',
- IdAscNullsFirst = 'id_ASC_NULLS_FIRST',
- IdAscNullsLast = 'id_ASC_NULLS_LAST',
- IdDesc = 'id_DESC',
- IdDescNullsFirst = 'id_DESC_NULLS_FIRST',
- IdDescNullsLast = 'id_DESC_NULLS_LAST',
- PendingStakeAmountAsc = 'pendingStake_amount_ASC',
- PendingStakeAmountAscNullsFirst = 'pendingStake_amount_ASC_NULLS_FIRST',
- PendingStakeAmountAscNullsLast = 'pendingStake_amount_ASC_NULLS_LAST',
- PendingStakeAmountDesc = 'pendingStake_amount_DESC',
- PendingStakeAmountDescNullsFirst = 'pendingStake_amount_DESC_NULLS_FIRST',
- PendingStakeAmountDescNullsLast = 'pendingStake_amount_DESC_NULLS_LAST',
- PendingStakeComputationUnitsAsc = 'pendingStake_computationUnits_ASC',
- PendingStakeComputationUnitsAscNullsFirst = 'pendingStake_computationUnits_ASC_NULLS_FIRST',
- PendingStakeComputationUnitsAscNullsLast = 'pendingStake_computationUnits_ASC_NULLS_LAST',
- PendingStakeComputationUnitsDesc = 'pendingStake_computationUnits_DESC',
- PendingStakeComputationUnitsDescNullsFirst = 'pendingStake_computationUnits_DESC_NULLS_FIRST',
- PendingStakeComputationUnitsDescNullsLast = 'pendingStake_computationUnits_DESC_NULLS_LAST',
- PendingStakeIdAsc = 'pendingStake_id_ASC',
- PendingStakeIdAscNullsFirst = 'pendingStake_id_ASC_NULLS_FIRST',
- PendingStakeIdAscNullsLast = 'pendingStake_id_ASC_NULLS_LAST',
- PendingStakeIdDesc = 'pendingStake_id_DESC',
- PendingStakeIdDescNullsFirst = 'pendingStake_id_DESC_NULLS_FIRST',
- PendingStakeIdDescNullsLast = 'pendingStake_id_DESC_NULLS_LAST',
- PendingStakeIndexAsc = 'pendingStake_index_ASC',
- PendingStakeIndexAscNullsFirst = 'pendingStake_index_ASC_NULLS_FIRST',
- PendingStakeIndexAscNullsLast = 'pendingStake_index_ASC_NULLS_LAST',
- PendingStakeIndexDesc = 'pendingStake_index_DESC',
- PendingStakeIndexDescNullsFirst = 'pendingStake_index_DESC_NULLS_FIRST',
- PendingStakeIndexDescNullsLast = 'pendingStake_index_DESC_NULLS_LAST',
- PendingStakeLockEndAsc = 'pendingStake_lockEnd_ASC',
- PendingStakeLockEndAscNullsFirst = 'pendingStake_lockEnd_ASC_NULLS_FIRST',
- PendingStakeLockEndAscNullsLast = 'pendingStake_lockEnd_ASC_NULLS_LAST',
- PendingStakeLockEndDesc = 'pendingStake_lockEnd_DESC',
- PendingStakeLockEndDescNullsFirst = 'pendingStake_lockEnd_DESC_NULLS_FIRST',
- PendingStakeLockEndDescNullsLast = 'pendingStake_lockEnd_DESC_NULLS_LAST',
- PendingStakeLockStartAsc = 'pendingStake_lockStart_ASC',
- PendingStakeLockStartAscNullsFirst = 'pendingStake_lockStart_ASC_NULLS_FIRST',
- PendingStakeLockStartAscNullsLast = 'pendingStake_lockStart_ASC_NULLS_LAST',
- PendingStakeLockStartDesc = 'pendingStake_lockStart_DESC',
- PendingStakeLockStartDescNullsFirst = 'pendingStake_lockStart_DESC_NULLS_FIRST',
- PendingStakeLockStartDescNullsLast = 'pendingStake_lockStart_DESC_NULLS_LAST',
- PendingStakeLockedAsc = 'pendingStake_locked_ASC',
- PendingStakeLockedAscNullsFirst = 'pendingStake_locked_ASC_NULLS_FIRST',
- PendingStakeLockedAscNullsLast = 'pendingStake_locked_ASC_NULLS_LAST',
- PendingStakeLockedDesc = 'pendingStake_locked_DESC',
- PendingStakeLockedDescNullsFirst = 'pendingStake_locked_DESC_NULLS_FIRST',
- PendingStakeLockedDescNullsLast = 'pendingStake_locked_DESC_NULLS_LAST',
- StakeAmountAsc = 'stake_amount_ASC',
- StakeAmountAscNullsFirst = 'stake_amount_ASC_NULLS_FIRST',
- StakeAmountAscNullsLast = 'stake_amount_ASC_NULLS_LAST',
- StakeAmountDesc = 'stake_amount_DESC',
- StakeAmountDescNullsFirst = 'stake_amount_DESC_NULLS_FIRST',
- StakeAmountDescNullsLast = 'stake_amount_DESC_NULLS_LAST',
- StakeComputationUnitsAsc = 'stake_computationUnits_ASC',
- StakeComputationUnitsAscNullsFirst = 'stake_computationUnits_ASC_NULLS_FIRST',
- StakeComputationUnitsAscNullsLast = 'stake_computationUnits_ASC_NULLS_LAST',
- StakeComputationUnitsDesc = 'stake_computationUnits_DESC',
- StakeComputationUnitsDescNullsFirst = 'stake_computationUnits_DESC_NULLS_FIRST',
- StakeComputationUnitsDescNullsLast = 'stake_computationUnits_DESC_NULLS_LAST',
- StakeIdAsc = 'stake_id_ASC',
- StakeIdAscNullsFirst = 'stake_id_ASC_NULLS_FIRST',
- StakeIdAscNullsLast = 'stake_id_ASC_NULLS_LAST',
- StakeIdDesc = 'stake_id_DESC',
- StakeIdDescNullsFirst = 'stake_id_DESC_NULLS_FIRST',
- StakeIdDescNullsLast = 'stake_id_DESC_NULLS_LAST',
- StakeIndexAsc = 'stake_index_ASC',
- StakeIndexAscNullsFirst = 'stake_index_ASC_NULLS_FIRST',
- StakeIndexAscNullsLast = 'stake_index_ASC_NULLS_LAST',
- StakeIndexDesc = 'stake_index_DESC',
- StakeIndexDescNullsFirst = 'stake_index_DESC_NULLS_FIRST',
- StakeIndexDescNullsLast = 'stake_index_DESC_NULLS_LAST',
- StakeLockEndAsc = 'stake_lockEnd_ASC',
- StakeLockEndAscNullsFirst = 'stake_lockEnd_ASC_NULLS_FIRST',
- StakeLockEndAscNullsLast = 'stake_lockEnd_ASC_NULLS_LAST',
- StakeLockEndDesc = 'stake_lockEnd_DESC',
- StakeLockEndDescNullsFirst = 'stake_lockEnd_DESC_NULLS_FIRST',
- StakeLockEndDescNullsLast = 'stake_lockEnd_DESC_NULLS_LAST',
- StakeLockStartAsc = 'stake_lockStart_ASC',
- StakeLockStartAscNullsFirst = 'stake_lockStart_ASC_NULLS_FIRST',
- StakeLockStartAscNullsLast = 'stake_lockStart_ASC_NULLS_LAST',
- StakeLockStartDesc = 'stake_lockStart_DESC',
- StakeLockStartDescNullsFirst = 'stake_lockStart_DESC_NULLS_FIRST',
- StakeLockStartDescNullsLast = 'stake_lockStart_DESC_NULLS_LAST',
- StakeLockedAsc = 'stake_locked_ASC',
- StakeLockedAscNullsFirst = 'stake_locked_ASC_NULLS_FIRST',
- StakeLockedAscNullsLast = 'stake_locked_ASC_NULLS_LAST',
- StakeLockedDesc = 'stake_locked_DESC',
- StakeLockedDescNullsFirst = 'stake_locked_DESC_NULLS_FIRST',
- StakeLockedDescNullsLast = 'stake_locked_DESC_NULLS_LAST',
-}
-
-export type GatewayOperatorWhereInput = {
- AND?: InputMaybe>;
- OR?: InputMaybe>;
- account?: InputMaybe;
- account_isNull?: InputMaybe;
- autoExtension_eq?: InputMaybe;
- autoExtension_isNull?: InputMaybe;
- autoExtension_not_eq?: InputMaybe;
- gateways_every?: InputMaybe;
- gateways_none?: InputMaybe;
- gateways_some?: InputMaybe;
- id_contains?: InputMaybe;
- id_containsInsensitive?: InputMaybe;
- id_endsWith?: InputMaybe;
- id_eq?: InputMaybe;
- id_gt?: InputMaybe;
- id_gte?: InputMaybe;
- id_in?: InputMaybe>;
- id_isNull?: InputMaybe;
- id_lt?: InputMaybe;
- id_lte?: InputMaybe;
- id_not_contains?: InputMaybe;
- id_not_containsInsensitive?: InputMaybe;
- id_not_endsWith?: InputMaybe;
- id_not_eq?: InputMaybe;
- id_not_in?: InputMaybe>;
- id_not_startsWith?: InputMaybe;
- id_startsWith?: InputMaybe;
- pendingStake?: InputMaybe;
- pendingStake_isNull?: InputMaybe;
- stake?: InputMaybe;
- stake_isNull?: InputMaybe;
-};
-
-export type GatewayOperatorsConnection = {
- __typename?: 'GatewayOperatorsConnection';
- edges: Array;
- pageInfo: PageInfo;
- totalCount: Scalars['Int']['output'];
-};
-
export enum GatewayOrderByInput {
CreatedAtAsc = 'createdAt_ASC',
CreatedAtAscNullsFirst = 'createdAt_ASC_NULLS_FIRST',
@@ -2052,18 +1873,6 @@ export enum GatewayOrderByInput {
NameDesc = 'name_DESC',
NameDescNullsFirst = 'name_DESC_NULLS_FIRST',
NameDescNullsLast = 'name_DESC_NULLS_LAST',
- OperatorAutoExtensionAsc = 'operator_autoExtension_ASC',
- OperatorAutoExtensionAscNullsFirst = 'operator_autoExtension_ASC_NULLS_FIRST',
- OperatorAutoExtensionAscNullsLast = 'operator_autoExtension_ASC_NULLS_LAST',
- OperatorAutoExtensionDesc = 'operator_autoExtension_DESC',
- OperatorAutoExtensionDescNullsFirst = 'operator_autoExtension_DESC_NULLS_FIRST',
- OperatorAutoExtensionDescNullsLast = 'operator_autoExtension_DESC_NULLS_LAST',
- OperatorIdAsc = 'operator_id_ASC',
- OperatorIdAscNullsFirst = 'operator_id_ASC_NULLS_FIRST',
- OperatorIdAscNullsLast = 'operator_id_ASC_NULLS_LAST',
- OperatorIdDesc = 'operator_id_DESC',
- OperatorIdDescNullsFirst = 'operator_id_DESC_NULLS_FIRST',
- OperatorIdDescNullsLast = 'operator_id_DESC_NULLS_LAST',
OwnerBalanceAsc = 'owner_balance_ASC',
OwnerBalanceAscNullsFirst = 'owner_balance_ASC_NULLS_FIRST',
OwnerBalanceAscNullsLast = 'owner_balance_ASC_NULLS_LAST',
@@ -2088,6 +1897,78 @@ export enum GatewayOrderByInput {
OwnerTypeDesc = 'owner_type_DESC',
OwnerTypeDescNullsFirst = 'owner_type_DESC_NULLS_FIRST',
OwnerTypeDescNullsLast = 'owner_type_DESC_NULLS_LAST',
+ RealOwnerBalanceAsc = 'realOwner_balance_ASC',
+ RealOwnerBalanceAscNullsFirst = 'realOwner_balance_ASC_NULLS_FIRST',
+ RealOwnerBalanceAscNullsLast = 'realOwner_balance_ASC_NULLS_LAST',
+ RealOwnerBalanceDesc = 'realOwner_balance_DESC',
+ RealOwnerBalanceDescNullsFirst = 'realOwner_balance_DESC_NULLS_FIRST',
+ RealOwnerBalanceDescNullsLast = 'realOwner_balance_DESC_NULLS_LAST',
+ RealOwnerClaimableDelegationCountAsc = 'realOwner_claimableDelegationCount_ASC',
+ RealOwnerClaimableDelegationCountAscNullsFirst = 'realOwner_claimableDelegationCount_ASC_NULLS_FIRST',
+ RealOwnerClaimableDelegationCountAscNullsLast = 'realOwner_claimableDelegationCount_ASC_NULLS_LAST',
+ RealOwnerClaimableDelegationCountDesc = 'realOwner_claimableDelegationCount_DESC',
+ RealOwnerClaimableDelegationCountDescNullsFirst = 'realOwner_claimableDelegationCount_DESC_NULLS_FIRST',
+ RealOwnerClaimableDelegationCountDescNullsLast = 'realOwner_claimableDelegationCount_DESC_NULLS_LAST',
+ RealOwnerIdAsc = 'realOwner_id_ASC',
+ RealOwnerIdAscNullsFirst = 'realOwner_id_ASC_NULLS_FIRST',
+ RealOwnerIdAscNullsLast = 'realOwner_id_ASC_NULLS_LAST',
+ RealOwnerIdDesc = 'realOwner_id_DESC',
+ RealOwnerIdDescNullsFirst = 'realOwner_id_DESC_NULLS_FIRST',
+ RealOwnerIdDescNullsLast = 'realOwner_id_DESC_NULLS_LAST',
+ RealOwnerTypeAsc = 'realOwner_type_ASC',
+ RealOwnerTypeAscNullsFirst = 'realOwner_type_ASC_NULLS_FIRST',
+ RealOwnerTypeAscNullsLast = 'realOwner_type_ASC_NULLS_LAST',
+ RealOwnerTypeDesc = 'realOwner_type_DESC',
+ RealOwnerTypeDescNullsFirst = 'realOwner_type_DESC_NULLS_FIRST',
+ RealOwnerTypeDescNullsLast = 'realOwner_type_DESC_NULLS_LAST',
+ StakeAmountAsc = 'stake_amount_ASC',
+ StakeAmountAscNullsFirst = 'stake_amount_ASC_NULLS_FIRST',
+ StakeAmountAscNullsLast = 'stake_amount_ASC_NULLS_LAST',
+ StakeAmountDesc = 'stake_amount_DESC',
+ StakeAmountDescNullsFirst = 'stake_amount_DESC_NULLS_FIRST',
+ StakeAmountDescNullsLast = 'stake_amount_DESC_NULLS_LAST',
+ StakeAutoExtensionAsc = 'stake_autoExtension_ASC',
+ StakeAutoExtensionAscNullsFirst = 'stake_autoExtension_ASC_NULLS_FIRST',
+ StakeAutoExtensionAscNullsLast = 'stake_autoExtension_ASC_NULLS_LAST',
+ StakeAutoExtensionDesc = 'stake_autoExtension_DESC',
+ StakeAutoExtensionDescNullsFirst = 'stake_autoExtension_DESC_NULLS_FIRST',
+ StakeAutoExtensionDescNullsLast = 'stake_autoExtension_DESC_NULLS_LAST',
+ StakeComputationUnitsPendingAsc = 'stake_computationUnitsPending_ASC',
+ StakeComputationUnitsPendingAscNullsFirst = 'stake_computationUnitsPending_ASC_NULLS_FIRST',
+ StakeComputationUnitsPendingAscNullsLast = 'stake_computationUnitsPending_ASC_NULLS_LAST',
+ StakeComputationUnitsPendingDesc = 'stake_computationUnitsPending_DESC',
+ StakeComputationUnitsPendingDescNullsFirst = 'stake_computationUnitsPending_DESC_NULLS_FIRST',
+ StakeComputationUnitsPendingDescNullsLast = 'stake_computationUnitsPending_DESC_NULLS_LAST',
+ StakeComputationUnitsAsc = 'stake_computationUnits_ASC',
+ StakeComputationUnitsAscNullsFirst = 'stake_computationUnits_ASC_NULLS_FIRST',
+ StakeComputationUnitsAscNullsLast = 'stake_computationUnits_ASC_NULLS_LAST',
+ StakeComputationUnitsDesc = 'stake_computationUnits_DESC',
+ StakeComputationUnitsDescNullsFirst = 'stake_computationUnits_DESC_NULLS_FIRST',
+ StakeComputationUnitsDescNullsLast = 'stake_computationUnits_DESC_NULLS_LAST',
+ StakeIdAsc = 'stake_id_ASC',
+ StakeIdAscNullsFirst = 'stake_id_ASC_NULLS_FIRST',
+ StakeIdAscNullsLast = 'stake_id_ASC_NULLS_LAST',
+ StakeIdDesc = 'stake_id_DESC',
+ StakeIdDescNullsFirst = 'stake_id_DESC_NULLS_FIRST',
+ StakeIdDescNullsLast = 'stake_id_DESC_NULLS_LAST',
+ StakeLockEndAsc = 'stake_lockEnd_ASC',
+ StakeLockEndAscNullsFirst = 'stake_lockEnd_ASC_NULLS_FIRST',
+ StakeLockEndAscNullsLast = 'stake_lockEnd_ASC_NULLS_LAST',
+ StakeLockEndDesc = 'stake_lockEnd_DESC',
+ StakeLockEndDescNullsFirst = 'stake_lockEnd_DESC_NULLS_FIRST',
+ StakeLockEndDescNullsLast = 'stake_lockEnd_DESC_NULLS_LAST',
+ StakeLockStartAsc = 'stake_lockStart_ASC',
+ StakeLockStartAscNullsFirst = 'stake_lockStart_ASC_NULLS_FIRST',
+ StakeLockStartAscNullsLast = 'stake_lockStart_ASC_NULLS_LAST',
+ StakeLockStartDesc = 'stake_lockStart_DESC',
+ StakeLockStartDescNullsFirst = 'stake_lockStart_DESC_NULLS_FIRST',
+ StakeLockStartDescNullsLast = 'stake_lockStart_DESC_NULLS_LAST',
+ StakeLockedAsc = 'stake_locked_ASC',
+ StakeLockedAscNullsFirst = 'stake_locked_ASC_NULLS_FIRST',
+ StakeLockedAscNullsLast = 'stake_locked_ASC_NULLS_LAST',
+ StakeLockedDesc = 'stake_locked_DESC',
+ StakeLockedDescNullsFirst = 'stake_locked_DESC_NULLS_FIRST',
+ StakeLockedDescNullsLast = 'stake_locked_DESC_NULLS_LAST',
StatusAsc = 'status_ASC',
StatusAscNullsFirst = 'status_ASC_NULLS_FIRST',
StatusAscNullsLast = 'status_ASC_NULLS_LAST',
@@ -2105,14 +1986,23 @@ export enum GatewayOrderByInput {
export type GatewayStake = {
__typename?: 'GatewayStake';
amount: Scalars['BigInt']['output'];
+ autoExtension: Scalars['Boolean']['output'];
computationUnits: Scalars['BigInt']['output'];
+ computationUnitsPending?: Maybe;
+ gateways: Array;
id: Scalars['String']['output'];
- index: Scalars['Int']['output'];
- lockEnd: Scalars['Int']['output'];
- lockStart: Scalars['Int']['output'];
+ lockEnd?: Maybe;
+ lockStart?: Maybe;
locked: Scalars['Boolean']['output'];
- operator: GatewayOperator;
owner: Account;
+ realOwner: Account;
+};
+
+export type GatewayStakeGatewaysArgs = {
+ limit?: InputMaybe;
+ offset?: InputMaybe;
+ orderBy?: InputMaybe>;
+ where?: InputMaybe;
};
export type GatewayStakeEdge = {
@@ -2128,6 +2018,18 @@ export enum GatewayStakeOrderByInput {
AmountDesc = 'amount_DESC',
AmountDescNullsFirst = 'amount_DESC_NULLS_FIRST',
AmountDescNullsLast = 'amount_DESC_NULLS_LAST',
+ AutoExtensionAsc = 'autoExtension_ASC',
+ AutoExtensionAscNullsFirst = 'autoExtension_ASC_NULLS_FIRST',
+ AutoExtensionAscNullsLast = 'autoExtension_ASC_NULLS_LAST',
+ AutoExtensionDesc = 'autoExtension_DESC',
+ AutoExtensionDescNullsFirst = 'autoExtension_DESC_NULLS_FIRST',
+ AutoExtensionDescNullsLast = 'autoExtension_DESC_NULLS_LAST',
+ ComputationUnitsPendingAsc = 'computationUnitsPending_ASC',
+ ComputationUnitsPendingAscNullsFirst = 'computationUnitsPending_ASC_NULLS_FIRST',
+ ComputationUnitsPendingAscNullsLast = 'computationUnitsPending_ASC_NULLS_LAST',
+ ComputationUnitsPendingDesc = 'computationUnitsPending_DESC',
+ ComputationUnitsPendingDescNullsFirst = 'computationUnitsPending_DESC_NULLS_FIRST',
+ ComputationUnitsPendingDescNullsLast = 'computationUnitsPending_DESC_NULLS_LAST',
ComputationUnitsAsc = 'computationUnits_ASC',
ComputationUnitsAscNullsFirst = 'computationUnits_ASC_NULLS_FIRST',
ComputationUnitsAscNullsLast = 'computationUnits_ASC_NULLS_LAST',
@@ -2140,12 +2042,6 @@ export enum GatewayStakeOrderByInput {
IdDesc = 'id_DESC',
IdDescNullsFirst = 'id_DESC_NULLS_FIRST',
IdDescNullsLast = 'id_DESC_NULLS_LAST',
- IndexAsc = 'index_ASC',
- IndexAscNullsFirst = 'index_ASC_NULLS_FIRST',
- IndexAscNullsLast = 'index_ASC_NULLS_LAST',
- IndexDesc = 'index_DESC',
- IndexDescNullsFirst = 'index_DESC_NULLS_FIRST',
- IndexDescNullsLast = 'index_DESC_NULLS_LAST',
LockEndAsc = 'lockEnd_ASC',
LockEndAscNullsFirst = 'lockEnd_ASC_NULLS_FIRST',
LockEndAscNullsLast = 'lockEnd_ASC_NULLS_LAST',
@@ -2164,18 +2060,6 @@ export enum GatewayStakeOrderByInput {
LockedDesc = 'locked_DESC',
LockedDescNullsFirst = 'locked_DESC_NULLS_FIRST',
LockedDescNullsLast = 'locked_DESC_NULLS_LAST',
- OperatorAutoExtensionAsc = 'operator_autoExtension_ASC',
- OperatorAutoExtensionAscNullsFirst = 'operator_autoExtension_ASC_NULLS_FIRST',
- OperatorAutoExtensionAscNullsLast = 'operator_autoExtension_ASC_NULLS_LAST',
- OperatorAutoExtensionDesc = 'operator_autoExtension_DESC',
- OperatorAutoExtensionDescNullsFirst = 'operator_autoExtension_DESC_NULLS_FIRST',
- OperatorAutoExtensionDescNullsLast = 'operator_autoExtension_DESC_NULLS_LAST',
- OperatorIdAsc = 'operator_id_ASC',
- OperatorIdAscNullsFirst = 'operator_id_ASC_NULLS_FIRST',
- OperatorIdAscNullsLast = 'operator_id_ASC_NULLS_LAST',
- OperatorIdDesc = 'operator_id_DESC',
- OperatorIdDescNullsFirst = 'operator_id_DESC_NULLS_FIRST',
- OperatorIdDescNullsLast = 'operator_id_DESC_NULLS_LAST',
OwnerBalanceAsc = 'owner_balance_ASC',
OwnerBalanceAscNullsFirst = 'owner_balance_ASC_NULLS_FIRST',
OwnerBalanceAscNullsLast = 'owner_balance_ASC_NULLS_LAST',
@@ -2200,6 +2084,30 @@ export enum GatewayStakeOrderByInput {
OwnerTypeDesc = 'owner_type_DESC',
OwnerTypeDescNullsFirst = 'owner_type_DESC_NULLS_FIRST',
OwnerTypeDescNullsLast = 'owner_type_DESC_NULLS_LAST',
+ RealOwnerBalanceAsc = 'realOwner_balance_ASC',
+ RealOwnerBalanceAscNullsFirst = 'realOwner_balance_ASC_NULLS_FIRST',
+ RealOwnerBalanceAscNullsLast = 'realOwner_balance_ASC_NULLS_LAST',
+ RealOwnerBalanceDesc = 'realOwner_balance_DESC',
+ RealOwnerBalanceDescNullsFirst = 'realOwner_balance_DESC_NULLS_FIRST',
+ RealOwnerBalanceDescNullsLast = 'realOwner_balance_DESC_NULLS_LAST',
+ RealOwnerClaimableDelegationCountAsc = 'realOwner_claimableDelegationCount_ASC',
+ RealOwnerClaimableDelegationCountAscNullsFirst = 'realOwner_claimableDelegationCount_ASC_NULLS_FIRST',
+ RealOwnerClaimableDelegationCountAscNullsLast = 'realOwner_claimableDelegationCount_ASC_NULLS_LAST',
+ RealOwnerClaimableDelegationCountDesc = 'realOwner_claimableDelegationCount_DESC',
+ RealOwnerClaimableDelegationCountDescNullsFirst = 'realOwner_claimableDelegationCount_DESC_NULLS_FIRST',
+ RealOwnerClaimableDelegationCountDescNullsLast = 'realOwner_claimableDelegationCount_DESC_NULLS_LAST',
+ RealOwnerIdAsc = 'realOwner_id_ASC',
+ RealOwnerIdAscNullsFirst = 'realOwner_id_ASC_NULLS_FIRST',
+ RealOwnerIdAscNullsLast = 'realOwner_id_ASC_NULLS_LAST',
+ RealOwnerIdDesc = 'realOwner_id_DESC',
+ RealOwnerIdDescNullsFirst = 'realOwner_id_DESC_NULLS_FIRST',
+ RealOwnerIdDescNullsLast = 'realOwner_id_DESC_NULLS_LAST',
+ RealOwnerTypeAsc = 'realOwner_type_ASC',
+ RealOwnerTypeAscNullsFirst = 'realOwner_type_ASC_NULLS_FIRST',
+ RealOwnerTypeAscNullsLast = 'realOwner_type_ASC_NULLS_LAST',
+ RealOwnerTypeDesc = 'realOwner_type_DESC',
+ RealOwnerTypeDescNullsFirst = 'realOwner_type_DESC_NULLS_FIRST',
+ RealOwnerTypeDescNullsLast = 'realOwner_type_DESC_NULLS_LAST',
}
export type GatewayStakeWhereInput = {
@@ -2214,6 +2122,18 @@ export type GatewayStakeWhereInput = {
amount_lte?: InputMaybe;
amount_not_eq?: InputMaybe;
amount_not_in?: InputMaybe>;
+ autoExtension_eq?: InputMaybe;
+ autoExtension_isNull?: InputMaybe;
+ autoExtension_not_eq?: InputMaybe;
+ computationUnitsPending_eq?: InputMaybe;
+ computationUnitsPending_gt?: InputMaybe;
+ computationUnitsPending_gte?: InputMaybe;
+ computationUnitsPending_in?: InputMaybe>;
+ computationUnitsPending_isNull?: InputMaybe;
+ computationUnitsPending_lt?: InputMaybe;
+ computationUnitsPending_lte?: InputMaybe;
+ computationUnitsPending_not_eq?: InputMaybe;
+ computationUnitsPending_not_in?: InputMaybe>;
computationUnits_eq?: InputMaybe;
computationUnits_gt?: InputMaybe;
computationUnits_gte?: InputMaybe;
@@ -2223,6 +2143,9 @@ export type GatewayStakeWhereInput = {
computationUnits_lte?: InputMaybe;
computationUnits_not_eq?: InputMaybe;
computationUnits_not_in?: InputMaybe>;
+ gateways_every?: InputMaybe;
+ gateways_none?: InputMaybe;
+ gateways_some?: InputMaybe;
id_contains?: InputMaybe;
id_containsInsensitive?: InputMaybe;
id_endsWith?: InputMaybe;
@@ -2240,15 +2163,6 @@ export type GatewayStakeWhereInput = {
id_not_in?: InputMaybe>;
id_not_startsWith?: InputMaybe;
id_startsWith?: InputMaybe;
- index_eq?: InputMaybe;
- index_gt?: InputMaybe;
- index_gte?: InputMaybe;
- index_in?: InputMaybe>;
- index_isNull?: InputMaybe;
- index_lt?: InputMaybe;
- index_lte?: InputMaybe;
- index_not_eq?: InputMaybe;
- index_not_in?: InputMaybe>;
lockEnd_eq?: InputMaybe;
lockEnd_gt?: InputMaybe;
lockEnd_gte?: InputMaybe;
@@ -2270,10 +2184,10 @@ export type GatewayStakeWhereInput = {
locked_eq?: InputMaybe;
locked_isNull?: InputMaybe;
locked_not_eq?: InputMaybe;
- operator?: InputMaybe;
- operator_isNull?: InputMaybe;
owner?: InputMaybe;
owner_isNull?: InputMaybe;
+ realOwner?: InputMaybe;
+ realOwner_isNull?: InputMaybe;
};
export type GatewayStakesConnection = {
@@ -2530,10 +2444,12 @@ export type GatewayWhereInput = {
name_not_in?: InputMaybe>;
name_not_startsWith?: InputMaybe;
name_startsWith?: InputMaybe;
- operator?: InputMaybe;
- operator_isNull?: InputMaybe;
owner?: InputMaybe;
owner_isNull?: InputMaybe;
+ realOwner?: InputMaybe;
+ realOwner_isNull?: InputMaybe;
+ stake?: InputMaybe;
+ stake_isNull?: InputMaybe;
statusHistory_every?: InputMaybe;
statusHistory_none?: InputMaybe;
statusHistory_some?: InputMaybe;
@@ -2601,61 +2517,34 @@ export type PageInfo = {
export type Query = {
__typename?: 'Query';
accountById?: Maybe;
- /** @deprecated Use accountById */
- accountByUniqueInput?: Maybe;
accountTransferById?: Maybe;
- /** @deprecated Use accountTransferById */
- accountTransferByUniqueInput?: Maybe;
accountTransfers: Array;
accountTransfersConnection: AccountTransfersConnection;
accounts: Array;
accountsConnection: AccountsConnection;
blockById?: Maybe;
- /** @deprecated Use blockById */
- blockByUniqueInput?: Maybe;
blocks: Array;
blocksConnection: BlocksConnection;
claimById?: Maybe;
- /** @deprecated Use claimById */
- claimByUniqueInput?: Maybe;
claims: Array;
claimsConnection: ClaimsConnection;
commitmentById?: Maybe;
- /** @deprecated Use commitmentById */
- commitmentByUniqueInput?: Maybe;
commitments: Array;
commitmentsConnection: CommitmentsConnection;
delegationById?: Maybe;
- /** @deprecated Use delegationById */
- delegationByUniqueInput?: Maybe;
delegationRewardById?: Maybe;
- /** @deprecated Use delegationRewardById */
- delegationRewardByUniqueInput?: Maybe;
delegationRewards: Array;
delegationRewardsConnection: DelegationRewardsConnection;
delegations: Array;
delegationsConnection: DelegationsConnection;
epochById?: Maybe;
- /** @deprecated Use epochById */
- epochByUniqueInput?: Maybe;
epoches: Array;
epochesConnection: EpochesConnection;
gatewayById?: Maybe;
- /** @deprecated Use gatewayById */
- gatewayByUniqueInput?: Maybe;
- gatewayOperatorById?: Maybe