-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
166 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
137 changes: 108 additions & 29 deletions
137
apps/scoutgameadmin/components/contract/ContractDashboard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,46 @@ | ||
import { getPublicClient } from '@packages/onchain/getPublicClient'; | ||
import { builderContractReadonlyApiClient } from '@packages/scoutgame/builderNfts/clients/builderContractReadClient'; | ||
import { builderProxyContractReadonlyApiClient } from '@packages/scoutgame/builderNfts/clients/builderProxyContractReadClient'; | ||
import { getBuilderContractAddress } from '@packages/scoutgame/builderNfts/constants'; | ||
import { | ||
getBuilderContractAddress, | ||
usdcOptimismMainnetContractAddress | ||
} from '@packages/scoutgame/builderNfts/constants'; | ||
import { UsdcErc20ABIClient } from '@packages/scoutgame/builderNfts/usdcContractApiClient'; | ||
import type { Address } from 'viem'; | ||
import { optimism } from 'viem/chains'; | ||
|
||
export type BuilderNFTContractData = { | ||
currentAdmin: Address; | ||
currentMinter: Address; | ||
currentImplementation: Address; | ||
proceedsReceiver: Address; | ||
totalSupply: bigint; | ||
contractAddress: Address; | ||
receiverUsdcBalance: number; | ||
}; | ||
|
||
export async function getContractData(): Promise<BuilderNFTContractData> { | ||
const [currentAdmin, currentImplementation, proceedsReceiver, totalSupply] = await Promise.all([ | ||
const [currentAdmin, currentMinter, currentImplementation, proceedsReceiver, totalSupply] = await Promise.all([ | ||
builderProxyContractReadonlyApiClient.admin(), | ||
builderContractReadonlyApiClient.getMinter(), | ||
builderProxyContractReadonlyApiClient.implementation(), | ||
builderProxyContractReadonlyApiClient.getProceedsReceiver(), | ||
builderContractReadonlyApiClient.totalBuilderTokens() | ||
]); | ||
|
||
const balance = await new UsdcErc20ABIClient({ | ||
chain: optimism, | ||
publicClient: getPublicClient(optimism.id), | ||
contractAddress: usdcOptimismMainnetContractAddress | ||
}).balanceOf({ args: { account: proceedsReceiver } }); | ||
|
||
return { | ||
currentAdmin: currentAdmin as Address, | ||
currentMinter: currentMinter as Address, | ||
currentImplementation: currentImplementation as Address, | ||
proceedsReceiver: proceedsReceiver as Address, | ||
totalSupply, | ||
contractAddress: getBuilderContractAddress() | ||
contractAddress: getBuilderContractAddress(), | ||
receiverUsdcBalance: Number(balance / BigInt(1e6)) | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters