smartweave to warp renaming hell
This commit is contained in:
65
src/core/Warp.ts
Normal file
65
src/core/Warp.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
import {
|
||||
DefinitionLoader,
|
||||
ExecutorFactory,
|
||||
HandlerApi,
|
||||
InteractionsLoader,
|
||||
InteractionsSorter,
|
||||
WarpBuilder,
|
||||
StateEvaluator
|
||||
} from '@warp/core';
|
||||
import Arweave from 'arweave';
|
||||
import { Contract, HandlerBasedContract, CreateContract, DefaultCreateContract, PstContract, PstContractImpl } from '@warp/contract';
|
||||
import { GQLNodeInterface } from '@warp/legacy';
|
||||
|
||||
/**
|
||||
* The Warp "motherboard" ;-).
|
||||
* This is the base class that supplies the implementation of the SmartWeave protocol
|
||||
* Allows to plug-in different implementation of all the modules defined in the constructor.
|
||||
*
|
||||
* After being fully configured, it allows to "connect" to
|
||||
* contract and perform operations on them (see {@link Contract})
|
||||
*/
|
||||
export class Warp {
|
||||
readonly createContract: CreateContract;
|
||||
|
||||
constructor(
|
||||
readonly arweave: Arweave,
|
||||
readonly definitionLoader: DefinitionLoader,
|
||||
readonly interactionsLoader: InteractionsLoader,
|
||||
readonly interactionsSorter: InteractionsSorter,
|
||||
readonly executorFactory: ExecutorFactory<HandlerApi<unknown>>,
|
||||
readonly stateEvaluator: StateEvaluator,
|
||||
readonly useRedstoneGwInfo: boolean = false
|
||||
) {
|
||||
this.createContract = new DefaultCreateContract(arweave);
|
||||
}
|
||||
|
||||
static builder(arweave: Arweave): WarpBuilder {
|
||||
return new WarpBuilder(arweave);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows to connect to any contract using its transaction id.
|
||||
* @param contractTxId
|
||||
* @param callingContract
|
||||
*/
|
||||
contract<State>(
|
||||
contractTxId: string,
|
||||
callingContract?: Contract,
|
||||
callingInteraction?: GQLNodeInterface
|
||||
): Contract<State> {
|
||||
return new HandlerBasedContract<State>(contractTxId, this, callingContract, callingInteraction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows to connect to a contract that conforms to the Profit Sharing Token standard
|
||||
* @param contractTxId
|
||||
*/
|
||||
pst(contractTxId: string): PstContract {
|
||||
return new PstContractImpl(contractTxId, this);
|
||||
}
|
||||
|
||||
async flushCache(): Promise<void> {
|
||||
await this.stateEvaluator.flushCache();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user