Skip to content

Commit

Permalink
feat: add locked STX events and balance info to tx and address endpoi…
Browse files Browse the repository at this point in the history
…nts #282 #268
  • Loading branch information
zone117x committed Nov 12, 2020
1 parent e20f4df commit 67cb65d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/datastore/postgres-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1736,11 +1736,12 @@ export class PgDataStore extends (EventEmitter as { new (): DataStoreEventEmitte
`
SELECT locked_amount, unlock_height
FROM stx_lock_events
WHERE canonical = true AND locked_address = $1 AND block_height >= $2 AND unlock_height < $2
WHERE canonical = true AND locked_address = $1
AND block_height <= $2 AND unlock_height > $2
`,
[stxAddress, currentBlockHeight]
);
if (lockQuery.rowCount !== 0 || lockQuery.rowCount > 1) {
if (lockQuery.rowCount > 1) {
throw new Error(
`stx_lock_events event query for ${stxAddress} should return zero or one rows but returned ${lockQuery.rowCount}`
);
Expand Down Expand Up @@ -1805,11 +1806,12 @@ export class PgDataStore extends (EventEmitter as { new (): DataStoreEventEmitte
`
SELECT locked_amount, unlock_height
FROM stx_lock_events
WHERE canonical = true AND locked_address = $1 AND block_height >= $2 AND unlock_height < $2
WHERE canonical = true AND locked_address = $1
AND block_height <= $2 AND unlock_height > $2
`,
[stxAddress, blockHeight]
);
if (lockQuery.rowCount !== 0 || lockQuery.rowCount > 1) {
if (lockQuery.rowCount > 1) {
throw new Error(
`stx_lock_events event query for ${stxAddress} should return zero or one rows but returned ${lockQuery.rowCount}`
);
Expand Down

0 comments on commit 67cb65d

Please sign in to comment.