From 7cdd7d9531455bbd413b5ba0fd6db3f2d0c31fb4 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Wed, 12 Jul 2023 02:23:32 -0400 Subject: [PATCH] refactor: consensus_optimistic_update should return client.latestOptimisticUpdate if it is set or return an error --- npm-shrinkwrap.json | 8 ++++---- package.json | 2 +- src/index.ts | 7 ++++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 97751e9..f2bbc24 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -10,7 +10,7 @@ "hasInstallScript": true, "dependencies": { "@lumeweb/interface-relay": "^0.0.2-develop.1", - "@lumeweb/libethsync": "^0.1.0-develop.16", + "@lumeweb/libethsync": "^0.1.0-develop.17", "axios": "^1.4.0" }, "devDependencies": { @@ -4123,9 +4123,9 @@ } }, "node_modules/@lumeweb/libethsync": { - "version": "0.1.0-develop.16", - "resolved": "https://registry.npmjs.org/@lumeweb/libethsync/-/libethsync-0.1.0-develop.16.tgz", - "integrity": "sha512-0m6GD9hkYtYQBhBTQ9ZK1VeJ84zyyocFwIBaFuXibxdxTzT3dqK10TYZgYjnstQVgsWI4O1v2irWcB8wp965dQ==", + "version": "0.1.0-develop.25", + "resolved": "https://registry.npmjs.org/@lumeweb/libethsync/-/libethsync-0.1.0-develop.25.tgz", + "integrity": "sha512-yn3uzWCg1kAWWLyhlbrAKEAydhh3IB4aFE2Y2Yz0cpgQgfnsXLQwFF35VmCIIye908yLYc9aGmCgVvPqRkEz5Q==", "dependencies": { "@chainsafe/as-sha256": "^0.3.1", "@chainsafe/bls": "7.1.1", diff --git a/package.json b/package.json index d2ce570..7d7140b 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ }, "dependencies": { "@lumeweb/interface-relay": "^0.0.2-develop.1", - "@lumeweb/libethsync": "^0.1.0-develop.16", + "@lumeweb/libethsync": "^0.1.0-develop.17", "axios": "^1.4.0" } } diff --git a/src/index.ts b/src/index.ts index cfdec87..d6d5bb4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -104,7 +104,12 @@ const plugin: Plugin = { api.registerMethod("consensus_optimistic_update", { cacheable: false, async handler(): Promise { - return getConsensusOptimisticUpdate(); + console.log("consensus_optimistic_update request received"); + if (!client.latestOptimisticUpdate) { + throw new Error("optimistic update not ready"); + } + + return client.latestOptimisticUpdate; }, }); },