|
| 1 | +import { AztecAddress, type AztecNode, type ContractArtifact, type Wallet } from '@aztec/aztec.js'; |
| 2 | + |
| 3 | +import { createContext } from 'react'; |
| 4 | +import { type UserTx } from './utils/txs'; |
| 5 | +import type { Network } from './utils/networks'; |
| 6 | +import { PlaygroundDB } from './utils/storage'; |
| 7 | +import { type Log } from './utils/web_logger'; |
| 8 | + |
| 9 | +export const AztecContext = createContext<{ |
| 10 | + network: Network; |
| 11 | + node: AztecNode; |
| 12 | + wallet: Wallet | null; |
| 13 | + playgroundDB: PlaygroundDB; |
| 14 | + from: AztecAddress; |
| 15 | + currentContractAddress: AztecAddress; |
| 16 | + currentTx: UserTx; |
| 17 | + showContractInterface: boolean; |
| 18 | + currentContractArtifact: ContractArtifact; |
| 19 | + defaultContractCreationParams: Record<string, unknown>; |
| 20 | + pendingTxUpdateCounter: number; |
| 21 | + isNetworkCongested: boolean; |
| 22 | + logs: Log[]; |
| 23 | + totalLogCount: number; |
| 24 | + logsOpen: boolean; |
| 25 | + embeddedWalletSelected: boolean; |
| 26 | + setIsEmbeddedWalletSelected: (selected: boolean) => void; |
| 27 | + setLogsOpen: (open: boolean) => void; |
| 28 | + setLogs: (logs: Log[]) => void; |
| 29 | + setTotalLogCount: (count: number) => void; |
| 30 | + setShowContractInterface: (showContractInterface: boolean) => void; |
| 31 | + setNode: (node: AztecNode) => void; |
| 32 | + setWallet: (wallet: Wallet) => void; |
| 33 | + setPlaygroundDB: (playgroundDB: PlaygroundDB) => void; |
| 34 | + setFrom: (address: AztecAddress) => void; |
| 35 | + setNetwork: (network: Network) => void; |
| 36 | + setCurrentTx: (currentTx: UserTx) => void; |
| 37 | + setCurrentContractArtifact: (currentContract: ContractArtifact) => void; |
| 38 | + setCurrentContractAddress: (currentContractAddress: AztecAddress) => void; |
| 39 | + setDefaultContractCreationParams: (defaultContractCreationParams: Record<string, unknown>) => void; |
| 40 | + setPendingTxUpdateCounter: (pendingTxUpdateCounter: number) => void; |
| 41 | + setIsNetworkCongested: (isNetworkCongested: boolean) => void; |
| 42 | +}>({ |
| 43 | + network: null, |
| 44 | + node: null, |
| 45 | + wallet: null, |
| 46 | + playgroundDB: null, |
| 47 | + from: null, |
| 48 | + currentContractArtifact: null, |
| 49 | + currentContractAddress: null, |
| 50 | + currentTx: null, |
| 51 | + showContractInterface: false, |
| 52 | + defaultContractCreationParams: {}, |
| 53 | + pendingTxUpdateCounter: 0, |
| 54 | + isNetworkCongested: false, |
| 55 | + totalLogCount: 0, |
| 56 | + logs: [], |
| 57 | + logsOpen: false, |
| 58 | + embeddedWalletSelected: false, |
| 59 | + setIsEmbeddedWalletSelected: () => {}, |
| 60 | + setLogsOpen: () => {}, |
| 61 | + setLogs: () => {}, |
| 62 | + setTotalLogCount: () => {}, |
| 63 | + setShowContractInterface: () => {}, |
| 64 | + setWallet: () => {}, |
| 65 | + setNode: () => {}, |
| 66 | + setPlaygroundDB: () => {}, |
| 67 | + setFrom: () => {}, |
| 68 | + setNetwork: () => {}, |
| 69 | + setCurrentTx: () => {}, |
| 70 | + setCurrentContractArtifact: () => {}, |
| 71 | + setCurrentContractAddress: () => {}, |
| 72 | + setDefaultContractCreationParams: () => {}, |
| 73 | + setPendingTxUpdateCounter: () => {}, |
| 74 | + setIsNetworkCongested: () => {}, |
| 75 | +}); |
0 commit comments