Interface IContractStorage
- Namespace
- NArk.Abstractions.Contracts
- Assembly
- NArk.Abstractions.dll
Persistence for Arkade contracts; also drives active-script subscription via IActiveScriptsProvider.
public interface IContractStorage : IActiveScriptsProvider
- Inherited Members
Methods
DeactivateAwaitingContractsByScript(string, CancellationToken)
Deactivates all contracts with the given script that are in AwaitingFundsBeforeDeactivate state. Called when a VTXO is received to auto-deactivate one-time-use contracts (like refund addresses).
Task<int> DeactivateAwaitingContractsByScript(string script, CancellationToken cancellationToken = default)
Parameters
scriptstringThe script hex to match against contracts
cancellationTokenCancellationTokenCancellation token
Returns
DeleteContract(string, string, CancellationToken)
Deletes a contract by script. Wallet ID guards ownership.
Task<bool> DeleteContract(string walletId, string script, CancellationToken cancellationToken = default)
Parameters
walletIdstringThe wallet ID that owns the contract
scriptstringThe script hex of the contract to delete
cancellationTokenCancellationTokenCancellation token
Returns
GetContracts(string[]?, string[]?, bool?, string[]?, string?, int?, int?, ContractScope?, CancellationToken)
Query contracts with explicit filter parameters. Adding new parameters will cause compile errors for implementors, ensuring they handle new filters.
Task<IReadOnlyCollection<ArkContractEntity>> GetContracts(string[]? walletIds = null, string[]? scripts = null, bool? isActive = null, string[]? contractTypes = null, string? searchText = null, int? skip = null, int? take = null, ContractScope? scope = null, CancellationToken cancellationToken = default)
Parameters
walletIdsstring[]Filter by wallet IDs. If null, all wallets.
scriptsstring[]Filter by script hex strings. If null, no script filter.
isActivebool?If true, only active (not Inactive); if false, only Inactive; if null, all.
contractTypesstring[]Filter by contract types. If null, no type filter.
searchTextstringFilter by script containing this text. If null, no text filter.
skipint?Number of records to skip (for pagination). If null, no skip.
takeint?Number of records to take (for pagination). If null, no limit.
scopeContractScope?Filter by contract scope (on-chain/off-chain) via bitwise include
(Scope & scope) == scope. If null, no scope filter.cancellationTokenCancellationTokenCancellation token.
Returns
SaveContract(ArkContractEntity, CancellationToken)
Inserts or updates a contract record.
Task SaveContract(ArkContractEntity walletEntity, CancellationToken cancellationToken = default)
Parameters
walletEntityArkContractEntitycancellationTokenCancellationToken
Returns
UpdateContractActivityState(string, string, ContractActivityState, CancellationToken)
Updates the activity state of a contract.
Task<bool> UpdateContractActivityState(string walletId, string script, ContractActivityState activityState, CancellationToken cancellationToken = default)
Parameters
walletIdstringThe wallet ID that owns the contract
scriptstringThe script hex of the contract
activityStateContractActivityStateThe new activity state
cancellationTokenCancellationTokenCancellation token
Returns
Events
ContractsChanged
Raised when a contract is saved or its activity state changes.
event EventHandler<ArkContractEntity>? ContractsChanged