fix: extract VRF to a plugin #248

This commit is contained in:
ppedziwiatr
2023-04-25 10:52:36 +02:00
committed by just_ppe
parent 244a5d6059
commit e22d949485
13 changed files with 126 additions and 100 deletions

View File

@@ -31,7 +31,6 @@ import {
} from './Contract';
import { ArTransfer, ArWallet, emptyTransfer, Tags } from './deploy/CreateContract';
import { InnerWritesEvaluator } from './InnerWritesEvaluator';
import { generateMockVrf } from '../utils/vrf';
import { CustomSignature, Signature } from './Signature';
import { EvaluationOptionsEvaluator } from './EvaluationOptionsEvaluator';
import { WarpFetchWrapper } from '../core/WarpFetchWrapper';
@@ -40,6 +39,7 @@ import { TransactionStatusResponse } from '../utils/types/arweave-types';
import { InteractionState } from './states/InteractionState';
import { ContractInteractionState } from './states/ContractInteractionState';
import { Crypto } from 'warp-isomorphic';
import { VrfPluginFunctions } from '../core/WarpPlugin';
/**
* An implementation of {@link Contract} that is backwards compatible with current style
@@ -688,7 +688,12 @@ export class HandlerBasedContract<State> implements Contract<State> {
dummyTx.sortKey = await this._sorter.createSortKey(dummyTx.block.id, dummyTx.id, dummyTx.block.height, true);
dummyTx.strict = strict;
if (vrf) {
dummyTx.vrf = generateMockVrf(dummyTx.sortKey, arweave);
const vrfPlugin = this.warp.maybeLoadPlugin<void, VrfPluginFunctions>('vrf');
if (vrfPlugin) {
dummyTx.vrf = vrfPlugin.process().generateMockVrf(dummyTx.sortKey);
} else {
this.logger.warn('Cannot generate mock vrf for interaction - no "warp-contracts-plugin-vrf" attached!');
}
}
const handleResult = await this.evalInteraction<Input, View>(