create-midnight-app
Version:
🌙 Scaffold for building Midnight smart contracts with dynamic type detection and automated CLI generation
26 lines (18 loc) • 1.04 kB
text/typescript
import { contracts, type CounterPrivateState } from '@midnight-ntwrk/contract';
import type { ImpureCircuitId, MidnightProviders } from '@midnight-ntwrk/midnight-js-types';
import type { DeployedContract, FoundContract } from '@midnight-ntwrk/midnight-js-contracts';
// Get the dynamic contract module
const getContractModule = () => {
const contractNames = Object.keys(contracts);
if (contractNames.length === 0) {
throw new Error('No contract found in contracts object');
}
return contracts[contractNames[0]];
};
const contractModule = getContractModule();
export type { CounterPrivateState };
export type CounterCircuits = ImpureCircuitId<typeof contractModule.Contract>;
export const CounterPrivateStateId = 'counterPrivateState';
export type CounterProviders = MidnightProviders<CounterCircuits, typeof CounterPrivateStateId, CounterPrivateState>;
export type CounterContract = typeof contractModule.Contract;
export type DeployedCounterContract = DeployedContract<CounterContract> | FoundContract<CounterContract>;