kwilteam / kwil-db

Kwil DB, the database for web3
https://www.kwil.com/
Other
36 stars 12 forks source link

jsonrpc/usersvc: use best block height/time in view call #1094

Closed jchappelow closed 1 day ago

jchappelow commented 2 days ago

Alternative to https://github.com/kwilteam/kwil-db/pull/1088 Resolves https://github.com/kwilteam/kwil-db/issues/1084

action get_post($id) public view {
    SELECT *, @block_timestamp as stamp, @height as height
    FROM posts
    WHERE id = $id;
}
 $  kwil-cli database call -i xc4503ccf15daada96e36cbbacf641f48ebc6226e28906c8757866b91 -a get_post 'id:3'
| content | height | id |   stamp    | title  | user_id |
+---------+--------+----+------------+--------+---------+
| hihi    |    842 |  3 | 1732569623 | title2 |       1 |

$  kwil-cli database call -i xc4503ccf15daada96e36cbbacf641f48ebc6226e28906c8757866b91 -a get_post 'id:3'
| content | height | id |   stamp    | title  | user_id |
+---------+--------+----+------------+--------+---------+
| hihi    |    843 |  3 | 1732569630 | title2 |       1 |
brennanjl commented 1 day ago

@jchappelow could you also backport to preview?

jchappelow commented 1 day ago

Sure, just a sec.