fix: missing exports in barrel file

This commit is contained in:
ppe
2022-11-16 21:34:16 +01:00
parent 4efe018517
commit 51c572056d
5 changed files with 499 additions and 927 deletions

View File

@@ -100,9 +100,9 @@
"ts-jest": "^28.0.7",
"ts-node": "^10.2.1",
"typescript": "^4.7.4",
"warp-contracts-lmdb": "^1.1.0",
"warp-contracts-pubsub": "1.0.3",
"ws": "^8.11.0"
"ws": "^8.11.0",
"warp-contracts-subscription-plugin": "1.0.2"
},
"browser": {
"fs": false,

View File

@@ -39,6 +39,7 @@ export * from './core/ContractCallRecord';
export * from './core/WarpFactory';
export * from './core/Warp';
export * from './core/WarpBuilder';
export * from './core/WarpPlugin';
export * from './contract/Contract';
export * from './contract/HandlerBasedContract';

View File

@@ -1,11 +1,9 @@
/* eslint-disable */
import {defaultCacheOptions, LoggerFactory, Warp, WarpFactory} from '../src';
import os from 'os';
import {WarpPlugin, WarpPluginType} from "../src/core/WarpPlugin";
import {GQLNodeInterface} from "smartweave/lib/interfaces/gqlResult";
import {initPubSub, subscribe} from "warp-contracts-pubsub";
import {JWKInterface} from "arweave/web/lib/wallet";
import fs from "fs";
import {StateUpdatePlugin} from "warp-contracts-subscription-plugin";
const logger = LoggerFactory.INST.create('Contract');
@@ -14,90 +12,28 @@ LoggerFactory.INST.logLevel('info');
LoggerFactory.INST.logLevel('debug', 'WarpSubscriptionPlugin');
//LoggerFactory.INST.logLevel('debug', 'CacheableStateEvaluator');
global.WebSocket = require('ws');
initPubSub()
async function main() {
printTestInfo();
const heapUsedBefore = Math.round((process.memoryUsage().heapUsed / 1024 / 1024) * 100) / 100;
const rssUsedBefore = Math.round((process.memoryUsage().rss / 1024 / 1024) * 100) / 100;
interface InteractionMessage {
contractTxId: string,
sortKey: string,
lastSortKey: string,
interaction: GQLNodeInterface
}
abstract class WarpSubscriptionPlugin<R> implements WarpPlugin<InteractionMessage, Promise<R>> {
protected readonly logger = LoggerFactory.INST.create(WarpSubscriptionPlugin.name);
constructor(protected readonly contractTxId: string, protected readonly warp: Warp) {
subscribe(`interactions/${contractTxId}`, async ({data}) => {
const message = JSON.parse(data);
this.logger.debug('New message received', message);
await this.process(message);
}, console.error)
.then(() => {
this.logger.debug('Subscribed to interactions for', this.contractTxId);
})
.catch(e => {
this.logger.error('Error while subscribing', e);
});
}
abstract process(input: InteractionMessage): Promise<R>;
type(): WarpPluginType {
return 'subscription';
}
}
class StateUpdatePlugin extends WarpSubscriptionPlugin<Promise<any>> {
async process(input: InteractionMessage): Promise<any> {
this.logger.debug('From implementation', input);
const lastStoredKey = (await warp.stateEvaluator.latestAvailableState(this.contractTxId))?.sortKey;
if (lastStoredKey?.localeCompare(input.lastSortKey) === 0) {
this.logger.debug('Safe to use new interaction');
return await warp.contract(this.contractTxId)
.readStateFor([input.interaction]);
} else {
this.logger.debug('Unsafe to use new interaction');
return await warp.contract(this.contractTxId).readState();
}
}
}
const warp = WarpFactory
.forMainnet({...defaultCacheOptions, inMemory: false});
const plugin = new StateUpdatePlugin("Ws9hhYckc-zSnVmbBep6q_kZD5zmzYzDmgMC50nMiuE", warp)
warp.use(plugin);
let wallet: JWKInterface = readJSON('./.secrets/33F0QHcb22W7LwWR1iRC8Az1ntZG09XQ03YWuw2ABqA.json');
;
try {
const contract = warp
.contract("Ws9hhYckc-zSnVmbBep6q_kZD5zmzYzDmgMC50nMiuE")
.contract("47Fo4Mgpj_xzvImqIqMOZ_rwPJETqt1Fn0kMDwzUcZE")
.connect(wallet);
await contract.writeInteraction({
function: 'vrf'
}, {vrf: true});
/* const cacheResult = await contract
const cacheResult = await contract
.setEvaluationOptions({
})
.readState();
console.log(cacheResult.cachedValue.state);*/
console.log(cacheResult.cachedValue.state);
} catch (e) {
console.error(e);
}

View File

@@ -81,7 +81,7 @@ async function main() {
srcTxId: "5wXT-A0iugP9pWEyw-iTbB0plZ_AbmvlNKyBfGS3AUY",
});*/
const contract = warp.contract<any>('OZBvm55O2fmoeotAphv0_4mhcrBspaTyBSDQ-ZmAWwA')
/*const contract = warp.contract<any>('OZBvm55O2fmoeotAphv0_4mhcrBspaTyBSDQ-ZmAWwA')
.setEvaluationOptions({
})
.connect(wallet);
@@ -102,7 +102,7 @@ async function main() {
target: "M-mpNeJbg9h7mZ-uHaNsa5jwFFRAq0PsTkNWXJ-ojwI",
qty: 100
})
]);
]);*/
/*const {cachedValue} = await contract.readState();

1345
yarn.lock

File diff suppressed because it is too large Load Diff