vechain / vechain-sdk-js

The official JavaScript SDK for VeChain.
23 stars 9 forks source link

Support for `next` revision #1075

Open nwbrettski opened 1 month ago

nwbrettski commented 1 month ago

Thor v2.1.3 introduces support for a newly supported revision next which is the best block + 1. It should be used when estimating clauses. POST /accounts/* should now be POST /accounts/*?revision=next.

The next revision is only available on nodes that are running v2.1.3 and later, older nodes will not be aware of the revision next. Error handling should be in place to work around this limitation.

Tasks:

Acceptance Criteria:

nwbrettski commented 1 month ago

Blocked until Thor v2.1.3 is released.

darrenvechain commented 1 month ago

@nwbrettski it's very important to only use next if the thor version is v2.1.2, otherwise the API call fails

API version can be extracted from the headers (suggest maybe getting the genesis block when thor client is constructed)

example:

curl -I https://mainnet.vechain.org/blocks/0

Output (see the last line)

HTTP/2 405
date: Fri, 26 Jul 2024 10:35:22 GMT
set-cookie: AWSALB=dLZ4sagS6AQxeHl4iDDygphi5sJaukT9Wi+KNPOHgaH0LpJWcAkilcWFXrC2xHnjdJfY9b3SDi9k+Ljq960qgC/wj9gzObvbPr8pST/8Boc0rFux8uiERS3oeMLL; Expires=Fri, 02 Aug 2024 10:35:22 GMT; Path=/
set-cookie: AWSALBCORS=dLZ4sagS6AQxeHl4iDDygphi5sJaukT9Wi+KNPOHgaH0LpJWcAkilcWFXrC2xHnjdJfY9b3SDi9k+Ljq960qgC/wj9gzObvbPr8pST/8Boc0rFux8uiERS3oeMLL; Expires=Fri, 02 Aug 2024 10:35:22 GMT; Path=/; SameSite=None; Secure
vary: Accept-Encoding
x-genesis-id: 0x00000000851caf3cfdb6e899cf5958bfb1ac3413d346d43539627e6be7ec1b4a
x-thorest-ver: 2.1.2