refactor: consensus_optimistic_update should return client.latestOptimisticUpdate if it is set or return an error

This commit is contained in:
Derrick Hammer 2023-07-12 02:23:32 -04:00
parent 2cd40af902
commit 7cdd7d9531
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
3 changed files with 11 additions and 6 deletions

8
npm-shrinkwrap.json generated
View File

@ -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",

View File

@ -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"
}
}

View File

@ -104,7 +104,12 @@ const plugin: Plugin = {
api.registerMethod("consensus_optimistic_update", {
cacheable: false,
async handler(): Promise<object> {
return getConsensusOptimisticUpdate();
console.log("consensus_optimistic_update request received");
if (!client.latestOptimisticUpdate) {
throw new Error("optimistic update not ready");
}
return client.latestOptimisticUpdate;
},
});
},