Compare commits

...

3 Commits

5 changed files with 19 additions and 12 deletions

View File

@ -1,3 +1,5 @@
# [0.1.0-develop.20](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.19...v0.1.0-develop.20) (2023-07-11)
# [0.1.0-develop.19](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.18...v0.1.0-develop.19) (2023-07-11) # [0.1.0-develop.19](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.18...v0.1.0-develop.19) (2023-07-11)

4
npm-shrinkwrap.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "@lumeweb/libethclient", "name": "@lumeweb/libethclient",
"version": "0.1.0-develop.19", "version": "0.1.0-develop.20",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@lumeweb/libethclient", "name": "@lumeweb/libethclient",
"version": "0.1.0-develop.19", "version": "0.1.0-develop.20",
"dependencies": { "dependencies": {
"@chainsafe/as-sha256": "^0.3.1", "@chainsafe/as-sha256": "^0.3.1",
"@chainsafe/bls": "7.1.1", "@chainsafe/bls": "7.1.1",

View File

@ -1,6 +1,6 @@
{ {
"name": "@lumeweb/libethsync", "name": "@lumeweb/libethsync",
"version": "0.1.0-develop.19", "version": "0.1.0-develop.20",
"type": "module", "type": "module",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -13,10 +13,11 @@ import {
optimisticUpdateVerify, optimisticUpdateVerify,
} from "#util.js"; } from "#util.js";
import { equalBytes } from "@noble/curves/abstract/utils.js"; import { equalBytes } from "@noble/curves/abstract/utils.js";
import { IClientVerifyingProvider } from "#client/verifyingProvider.js";
interface Config extends BaseClientOptions { interface Config extends BaseClientOptions {
prover: IClientProver; prover: IClientProver;
provider: IVerifyingProviderConstructor; provider: IVerifyingProviderConstructor<IClientVerifyingProvider>;
rpcHandler: Function; rpcHandler: Function;
} }
@ -27,16 +28,12 @@ export default class Client extends BaseClient {
super(options); super(options);
} }
private _provider?: IVerifyingProvider; private provider?: IClientVerifyingProvider;
get provider(): IVerifyingProvider {
return this._provider as IVerifyingProvider;
}
async sync(): Promise<void> { async sync(): Promise<void> {
await super.sync(); await super.sync();
if (!this._provider) { if (!this.provider) {
const { blockHash, blockNumber } = await this.getNextValidExecutionInfo(); const { blockHash, blockNumber } = await this.getNextValidExecutionInfo();
const factory = this.options.provider; const factory = this.options.provider;
const provider = new factory( const provider = new factory(
@ -51,7 +48,7 @@ export default class Client extends BaseClient {
provider.update(ei.blockNumber, ei.blockHash); provider.update(ei.blockNumber, ei.blockHash);
}); });
this._provider = provider; this.provider = provider;
this.booted = true; this.booted = true;
} }
} }
@ -123,4 +120,8 @@ export default class Client extends BaseClient {
return committee; return committee;
} }
public async rpcCall(method: string, params: any) {
return this.provider?.rpcMethod(method, params);
}
} }

View File

@ -48,7 +48,11 @@ import { keccak256 } from "ethereum-cryptography/keccak";
import { fromHexString } from "@chainsafe/ssz"; import { fromHexString } from "@chainsafe/ssz";
import { RPC } from "#client/rpc.js"; import { RPC } from "#client/rpc.js";
export default class VerifyingProvider implements IVerifyingProvider { export interface IClientVerifyingProvider extends IVerifyingProvider {
rpcMethod(method: string, params: any);
}
export default class VerifyingProvider implements IClientVerifyingProvider {
common: Common; common: Common;
vm: VM | null = null; vm: VM | null = null;
private blockHashes: { [blockNumberHex: string]: Bytes32 } = {}; private blockHashes: { [blockNumberHex: string]: Bytes32 } = {};