Skip to content
Open
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ logs

midnight-concurrent-test-db
.claude

.worktrees
6 changes: 3 additions & 3 deletions packages/contracts/src/call-constructor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
/**
* Describes the target of a circuit invocation.
*/
export type ContractConstructorOptionsBase<C extends Contract.Any> = {
export interface ContractConstructorOptionsBase<C extends Contract.Any> {
/**
* The compiled contract defining the circuit to call.
*/
Expand All @@ -47,7 +47,7 @@ export type ContractConstructorOptionsWithArguments<C extends Contract.Any> =
/**
* Data retrieved via providers that should be included in the constructor call options.
*/
export type ContractConstructorOptionsProviderDataDependencies = {
export interface ContractConstructorOptionsProviderDataDependencies {
/**
* The current user's ZSwap public key.
*/
Expand Down Expand Up @@ -83,7 +83,7 @@ export type ContractConstructorOptions<C extends Contract.Any> =
/**
* The updated states resulting from executing a contract constructor.
*/
export type ContractConstructorResult<C extends Contract.Any> = {
export interface ContractConstructorResult<C extends Contract.Any> {
/**
* The public state resulting from executing the contract constructor.
*/
Expand Down
22 changes: 11 additions & 11 deletions packages/contracts/src/call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ import {
/**
* Describes the target of a circuit invocation.
*/
export type CallOptionsBase<C extends Contract.Any, ICK extends Contract.ImpureCircuitId<C>> = {
export interface CallOptionsBase<C extends Contract.Any, ICK extends Contract.ImpureCircuitId<C>> {
/**
* The contract defining the circuit to call.
*/
readonly compiledContract: CompiledContract.CompiledContract<C, any>; // eslint-disable-line @typescript-eslint/no-explicit-any

/**
* The identifier of the circuit to call.
*/
Expand All @@ -46,7 +46,7 @@ export type CallOptionsBase<C extends Contract.Any, ICK extends Contract.ImpureC
* The address of the contract being executed.
*/
readonly contractAddress: ContractAddress;
};
}

/**
* Conditional type that optionally adds the inferred circuit argument types to
Expand All @@ -65,7 +65,7 @@ export type CallOptionsWithArguments<C extends Contract.Any, ICK extends Contrac
/**
* Data retrieved via providers that should be included in the call options.
*/
export type CallOptionsProviderDataDependencies = {
export interface CallOptionsProviderDataDependencies {
/**
* The Zswap public key of the current user.
*/
Expand All @@ -78,7 +78,7 @@ export type CallOptionsProviderDataDependencies = {
* The initial public Zswap state of the contract to run the circuit against.
*/
readonly initialZswapChainState: ZswapChainState;
};
}

/**
* Call options with circuit arguments and data
Expand Down Expand Up @@ -111,7 +111,7 @@ export type CallOptions<C extends Contract.Any, ICK extends Contract.ImpureCircu
/**
* The private (sensitive) portions of the call result.
*/
export type CallResultPrivate<C extends Contract.Any, ICK extends Contract.ImpureCircuitId<C>> = {
export interface CallResultPrivate<C extends Contract.Any, ICK extends Contract.ImpureCircuitId<C>> {
/**
* ZK representation of the circuit arguments.
*/
Expand All @@ -136,12 +136,12 @@ export type CallResultPrivate<C extends Contract.Any, ICK extends Contract.Impur
* The Zswap local state resulting from executing the circuit.
*/
readonly nextZswapLocalState: ZswapLocalState;
};
}

/**
* The public portions of the call result.
*/
export type CallResultPublic = {
export interface CallResultPublic {
/**
* The public state resulting from executing the circuit.
*/
Expand All @@ -157,12 +157,12 @@ export type CallResultPublic = {
* can fail without invalidating the transaction, as long as the guaranteed section succeeds.
*/
readonly partitionedTranscript: PartitionedTranscript;
};
}

/**
* Contains all information resulting from circuit execution.
*/
export type CallResult<C extends Contract.Any, ICK extends Contract.ImpureCircuitId<C>> = {
export interface CallResult<C extends Contract.Any, ICK extends Contract.ImpureCircuitId<C>> {
/**
* The public/non-sensitive data produced by the circuit execution.
*/
Expand All @@ -171,4 +171,4 @@ export type CallResult<C extends Contract.Any, ICK extends Contract.ImpureCircui
* The private/sensitive data produced by the circuit execution.
*/
readonly private: CallResultPrivate<C, ICK>;
};
}
4 changes: 2 additions & 2 deletions packages/contracts/src/deploy-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ export type DeployContractOptions<C extends Contract.Any> =
/**
* Interface for a contract that has been deployed to the blockchain.
*/
export type DeployedContract<C extends Contract.Any> = FoundContract<C> & {
export interface DeployedContract<C extends Contract.Any> extends FoundContract<C> {
/**
* Data resulting from the deployment transaction that created this contract. The information in a
* {@link deployTxData} contains additional private information that does not
* exist in {@link FoundContract.deployTxData} because certain private data is only available to
* the deployer of a contract.
*/
readonly deployTxData: FinalizedDeployTxData<C>;
};
}

const createDeployTxOptions = <C extends Contract.Any>(
deployContractOptions: DeployContractOptions<C>
Expand Down
27 changes: 14 additions & 13 deletions packages/contracts/src/find-deployed-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export const verifyContractState = (
/**
* Base type for the configuration options for {@link findDeployedContract}.
*/
export type FindDeployedContractOptionsBase<C extends Contract.Any> = {
export interface FindDeployedContractOptionsBase<C extends Contract.Any> {
/**
* The compiled contract to use to execute circuits.
*/
Expand Down Expand Up @@ -162,28 +162,29 @@ export type FindDeployedContractOptionsBase<C extends Contract.Any> = {
* the intention is to overwrite the private state currently stored at the given
* private state ID.
*/
export type FindDeployedContractOptionsExistingPrivateState<C extends Contract.Any> = FindDeployedContractOptionsBase<C> & {
export interface FindDeployedContractOptionsExistingPrivateState<C extends Contract.Any>
extends FindDeployedContractOptionsBase<C> {
/**
* An identifier for the private state of the contract being found.
*/
readonly privateStateId: PrivateStateId;
};
}

/**
* {@link findDeployedContract} configuration that includes an initial private
* state to store and the private state ID at which to store it. Only used if
* the intention is to overwrite the private state currently stored at the given
* private state ID.
*/
export type FindDeployedContractOptionsStorePrivateState<C extends Contract.Any> =
FindDeployedContractOptionsExistingPrivateState<C> & {
/**
* For types of contract that make no use of private state and or witnesses that operate upon it, this
* property may be `undefined`. Otherwise, the value provided via this property should be same initial
* state that was used when calling {@link deployContract}.
*/
readonly initialPrivateState: Contract.PrivateState<C>;
};
export interface FindDeployedContractOptionsStorePrivateState<C extends Contract.Any>
extends FindDeployedContractOptionsExistingPrivateState<C> {
/**
* For types of contract that make no use of private state and or witnesses that operate upon it, this
* property may be `undefined`. Otherwise, the value provided via this property should be same initial
* state that was used when calling {@link deployContract}.
*/
readonly initialPrivateState: Contract.PrivateState<C>;
}

/**
* Configuration for {@link findDeployedContract}.
Expand All @@ -196,7 +197,7 @@ export type FindDeployedContractOptions<C extends Contract.Any> =
/**
* Base type for a deployed contract that has been found on the blockchain.
*/
export type FoundContract<C extends Contract.Any> = {
export interface FoundContract<C extends Contract.Any> {
/**
* Data for the finalized deploy transaction corresponding to this contract.
*/
Expand Down
6 changes: 3 additions & 3 deletions packages/contracts/src/get-states.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { assertDefined, assertIsContractAddress } from '@midnight-ntwrk/midnight
/**
* Object containing the publicly visible states of a contract.
*/
export type PublicContractStates = {
export interface PublicContractStates {
/**
* The (public) Zswap chain state of a contract.
*/
Expand All @@ -36,12 +36,12 @@ export type PublicContractStates = {
* Object containing the publicly visible states of a contract and the private
* state of a contract.
*/
export type ContractStates<PS> = PublicContractStates & {
export interface ContractStates<PS> extends PublicContractStates {
/**
* The private state of a contract.
*/
readonly privateState: PS;
};
}

/**
* Fetches only the public visible (Zswap and ledger) states of a contract.
Expand Down
4 changes: 4 additions & 0 deletions packages/contracts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,17 @@ export {
createContractMaintenanceTxInterface} from './tx-interfaces';
export {
FinalizedCallTxData,
FinalizedCallTxPublicData,
FinalizedDeployTxData,
FinalizedDeployTxDataBase,
FinalizedDeployTxPublicData,
SubmittedCallTx,
UnsubmittedCallTxData,
UnsubmittedCallTxPrivateData,
UnsubmittedDeployTxData,
UnsubmittedDeployTxDataBase,
UnsubmittedDeployTxPrivateData,
UnsubmittedDeployTxPrivateDataFull,
UnsubmittedDeployTxPublicData,
UnsubmittedTxData} from './tx-model';
export {
Expand Down
78 changes: 50 additions & 28 deletions packages/contracts/src/tx-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ import type {
FinalizedTxData
} from '@midnight-ntwrk/midnight-js-types';

import type { CallResult } from './call';
import type { CallResult, CallResultPrivate, CallResultPublic } from './call';

/**
* Data relevant to any unsubmitted transaction.
*/
export type UnsubmittedTxData = {
export interface UnsubmittedTxData {
/**
* The unproven ledger transaction produced.
*/
Expand All @@ -39,7 +39,7 @@ export type UnsubmittedTxData = {
/**
* Base type for public data relevant to an unsubmitted deployment transaction.
*/
export type UnsubmittedDeployTxPublicData = {
export interface UnsubmittedDeployTxPublicData {
/**
* The ledger address of the contract that was deployed.
*/
Expand All @@ -53,7 +53,7 @@ export type UnsubmittedDeployTxPublicData = {
/**
* Base type for private data relevant to an unsubmitted deployment transaction.
*/
export type UnsubmittedDeployTxPrivateData<C extends Contract.Any> = {
export interface UnsubmittedDeployTxPrivateData<C extends Contract.Any> {
/**
* The signing key that was added as the deployed contract's maintenance authority.
*/
Expand All @@ -68,7 +68,7 @@ export type UnsubmittedDeployTxPrivateData<C extends Contract.Any> = {
/**
* Base type for data relevant to an unsubmitted deployment transaction.
*/
export type UnsubmittedDeployTxDataBase<C extends Contract.Any> = {
export interface UnsubmittedDeployTxDataBase<C extends Contract.Any> {
/**
* The public data (data that will be revealed upon tx submission) relevant to the deployment transaction.
*/
Expand All @@ -79,67 +79,89 @@ export type UnsubmittedDeployTxDataBase<C extends Contract.Any> = {
readonly private: UnsubmittedDeployTxPrivateData<C>;
}

/**
* Full private data for an unsubmitted deployment transaction, combining the base private data
* with transaction data and the initial Zswap state.
*/
export interface UnsubmittedDeployTxPrivateDataFull<C extends Contract.Any>
extends UnsubmittedDeployTxPrivateData<C>, UnsubmittedTxData {
readonly initialZswapState: ZswapLocalState;
}

/**
* Data for an unsubmitted deployment transaction.
*/
export type UnsubmittedDeployTxData<C extends Contract.Any> = UnsubmittedDeployTxDataBase<C> & {
export interface UnsubmittedDeployTxData<C extends Contract.Any> extends UnsubmittedDeployTxDataBase<C> {
/**
* The data of this transaction that is only visible on the user device.
*/
readonly private: UnsubmittedTxData & {
/**
* The Zswap state produced as a result of running the contract constructor. Useful for when
* inputs or outputs are created in the contract constructor.
*/
readonly initialZswapState: ZswapLocalState;
};
};
readonly private: UnsubmittedDeployTxPrivateDataFull<C>;
}

/**
* Public data for a finalized deployment transaction, combining the base public data
* with finalization data.
*/
export interface FinalizedDeployTxPublicData extends UnsubmittedDeployTxPublicData, FinalizedTxData {}

/**
* Data for a finalized deploy transaction submitted in this process.
*/
export type FinalizedDeployTxDataBase<C extends Contract.Any> = UnsubmittedDeployTxDataBase<C> & {
export interface FinalizedDeployTxDataBase<C extends Contract.Any> extends UnsubmittedDeployTxDataBase<C> {
/**
* The data of this transaction that is visible on the blockchain.
*/
readonly public: FinalizedTxData;
};
readonly public: FinalizedDeployTxPublicData;
}

/**
* Data for a finalized deploy transaction submitted in this process.
*/
export type FinalizedDeployTxData<C extends Contract.Any> = UnsubmittedDeployTxData<C> & {
export interface FinalizedDeployTxData<C extends Contract.Any> extends UnsubmittedDeployTxData<C> {
/**
* The data of this transaction that is visible on the blockchain.
*/
readonly public: FinalizedTxData;
};
readonly public: FinalizedDeployTxPublicData;
}

/**
* Private data for an unsubmitted call transaction, combining the call result private data
* with transaction data.
*/
export interface UnsubmittedCallTxPrivateData<C extends Contract.Any, ICK extends Contract.ImpureCircuitId<C>>
extends CallResultPrivate<C, ICK>, UnsubmittedTxData {}

/**
* Data for an unsubmitted call transaction.
*/
export type UnsubmittedCallTxData<C extends Contract.Any, ICK extends Contract.ImpureCircuitId<C>> = CallResult<C, ICK> & {
export interface UnsubmittedCallTxData<C extends Contract.Any, ICK extends Contract.ImpureCircuitId<C>> extends CallResult<C, ICK> {
/**
* Private data relevant to this call transaction.
*/
readonly private: UnsubmittedTxData;
};
readonly private: UnsubmittedCallTxPrivateData<C, ICK>;
}

/**
* Public data for a finalized call transaction, combining the call result public data
* with finalization data.
*/
export interface FinalizedCallTxPublicData extends CallResultPublic, FinalizedTxData {}

/**
* Data for a submitted, finalized call transaction.
*/
export type FinalizedCallTxData<C extends Contract.Any, ICK extends Contract.ImpureCircuitId<C>> = UnsubmittedCallTxData<C, ICK> & {
export interface FinalizedCallTxData<C extends Contract.Any, ICK extends Contract.ImpureCircuitId<C>> extends UnsubmittedCallTxData<C, ICK> {
/**
* Public data relevant to this call transaction.
*/
readonly public: FinalizedTxData;
};
readonly public: FinalizedCallTxPublicData;
}

/**
* Data returned from an asynchronous call transaction submission.
* Contains the transaction ID and call transaction data without waiting for finalization.
*/
export type SubmittedCallTx<C extends Contract.Any, ICK extends Contract.ImpureCircuitId<C>> = {
export interface SubmittedCallTx<C extends Contract.Any, ICK extends Contract.ImpureCircuitId<C>> {
/**
* The transaction ID returned from submission.
*/
Expand All @@ -148,4 +170,4 @@ export type SubmittedCallTx<C extends Contract.Any, ICK extends Contract.ImpureC
* The unproven call transaction data including private state.
*/
readonly callTxData: UnsubmittedCallTxData<C, ICK>;
};
}
Loading
Loading