fix: viewState interaction transaction does not take 'evolve' into account #14
This commit is contained in:
committed by
Piotr Pędziwiatr
parent
717c325a36
commit
ce5a589b10
@@ -47,7 +47,7 @@ export class CacheableStateEvaluator extends DefaultStateEvaluator {
|
||||
executionContext.contractDefinition.txId,
|
||||
requestedBlockHeight
|
||||
)) as BlockHeightCacheResult<EvalStateResult<State>>;
|
||||
logger.trace('Retrieving value from cache', benchmark.elapsed());
|
||||
this.cLogger.trace('Retrieving value from cache', benchmark.elapsed());
|
||||
|
||||
if (cachedState != null) {
|
||||
this.cLogger.debug(`Cached state for ${executionContext.contractDefinition.txId}`, {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
DefinitionLoader,
|
||||
EvolveState,
|
||||
ExecutionContext,
|
||||
ExecutionContextModifier,
|
||||
ExecutorFactory,
|
||||
@@ -9,12 +10,6 @@ import {
|
||||
SmartWeaveErrorType
|
||||
} from '@smartweave';
|
||||
|
||||
export interface EvolveCompatibleState {
|
||||
settings: any[]; // some..erm..settings?
|
||||
canEvolve: boolean; // whether contract is allowed to evolve. seems to default to true..
|
||||
evolve: string; // the transaction id of the Arweave transaction with the updated source code. odd naming convention..
|
||||
}
|
||||
|
||||
/*
|
||||
...I'm still not fully convinced to the whole "evolve" idea.
|
||||
|
||||
@@ -33,7 +28,7 @@ without the need of hard-coding contract's txId in the client's source code.
|
||||
This also makes it easier to audit given contract - as you keep all its versions in one place.
|
||||
*/
|
||||
|
||||
function isEvolveCompatible(state: any): state is EvolveCompatibleState {
|
||||
function isEvolveCompatible(state: any): state is EvolveState {
|
||||
if (!state) {
|
||||
return false;
|
||||
}
|
||||
@@ -90,17 +85,18 @@ export class Evolve implements ExecutionContextModifier {
|
||||
const newContractDefinition = await this.definitionLoader.load<State>(contractTxId, evolve);
|
||||
const newHandler = (await this.executorFactory.create<State>(newContractDefinition)) as HandlerApi<State>;
|
||||
|
||||
const modifiedContext = {
|
||||
...executionContext,
|
||||
contractDefinition: newContractDefinition,
|
||||
handler: newHandler
|
||||
};
|
||||
//FIXME: side-effect...
|
||||
executionContext.contractDefinition = newContractDefinition;
|
||||
executionContext.handler = newHandler;
|
||||
|
||||
this.logger.debug('evolved to:', {
|
||||
txId: modifiedContext.contractDefinition.txId,
|
||||
srcTxId: modifiedContext.contractDefinition.srcTxId
|
||||
evolve: evolve,
|
||||
newSrcTxId: executionContext.contractDefinition.srcTxId,
|
||||
current: currentSrcTxId,
|
||||
txId: executionContext.contractDefinition.txId,
|
||||
});
|
||||
|
||||
return modifiedContext;
|
||||
return executionContext;
|
||||
} catch (e) {
|
||||
throw new SmartWeaveError(SmartWeaveErrorType.CONTRACT_NOT_FOUND, {
|
||||
message: `Contract having txId: ${contractTxId} not found`,
|
||||
|
||||
Reference in New Issue
Block a user