Skip to content

Commit 087258a

Browse files
Merge pull request #301 from blockfrost/fix/account-active
fix: active and pool_id in stake address
2 parents d6f9374 + 8132ede commit 087258a

File tree

9 files changed

+56
-12
lines changed

9 files changed

+56
-12
lines changed

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
## [6.1.1] - 2025-01-30
10+
## [6.2.0] - 2026-02-12
11+
12+
### Added
13+
14+
- New `registered` field in `/accounts/:stake_address` response indicating whether the stake address is currently registered
15+
16+
### Fixed
17+
18+
- `pool_id` in `/accounts/:stake_address` now correctly returns `null` if delegation occurred before the latest deregistration
19+
20+
## [6.1.1] - 2026-01-30
1121

1222
### Changed
1323

default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
pkgs ? import nixpkgs {},
1010
blockfrost-tests ? (builtins.fetchGit {
1111
url = "ssh://git@github.com/blockfrost/blockfrost-tests-internal.git";
12-
rev = "a2f4b5b98d256d3e8beeb92c51692ead0a1f710a";
12+
rev = "019223c9c0eb8f7c91581f542672b08983c55c20";
1313
submodules = true;
1414
allRefs = true;
1515
}),

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "blockfrost-backend-ryo",
3-
"version": "6.1.1",
3+
"version": "6.2.0",
44
"description": "",
55
"keywords": [],
66
"license": "Apache-2.0",
@@ -23,7 +23,7 @@
2323
"dependencies": {
2424
"@blockfrost/blockfrost-js": "6.1.0",
2525
"@blockfrost/blockfrost-utils": "2.9.0",
26-
"@blockfrost/openapi": "0.1.84",
26+
"@blockfrost/openapi": "0.1.85",
2727
"@fastify/cors": "^11.1.0",
2828
"@fastify/http-proxy": "^11.4.1",
2929
"@fastify/postgres": "^6.0.2",

src/sql/accounts/accounts_stake_address.sql

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ queried_pool AS (
3232
WHERE addr_id = sa.id
3333
)
3434
)
35+
AND (
36+
d.tx_id > (
37+
SELECT COALESCE(MAX(tx_id), 0) -- delegation must be after latest deregistration
38+
FROM stake_deregistration
39+
WHERE addr_id = sa.id
40+
)
41+
)
3542
),
3643
queried_drep AS (
3744
SELECT
@@ -108,6 +115,15 @@ SELECT sa.view AS "stake_address",
108115
)
109116
)
110117
) AS "active_epoch",
118+
(
119+
COALESCE(
120+
(SELECT MAX(tx_id) FROM stake_registration WHERE addr_id = (SELECT * FROM queried_addr)),
121+
0
122+
) > COALESCE(
123+
(SELECT MAX(tx_id) FROM stake_deregistration WHERE addr_id = (SELECT * FROM queried_addr)),
124+
0
125+
)
126+
) AS "registered",
111127
(
112128
(
113129
SELECT COALESCE(SUM(txo.value), 0)

src/types/queries/accounts.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export interface Account {
2828
stake_address: string;
2929
active: boolean;
3030
active_epoch: number;
31+
registered: boolean;
3132
controlled_amount: string;
3233
rewards_sum: string;
3334
withdrawals_sum: string;

test/unit/fixtures/accounts.fixtures.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const query_accounts_regular_1 = {
44
stake_address: 'stake1ux3g2c9dx2nhhehyrezyxpkstartcqmu9hk63qgfkccw5rqttygt7',
55
active: true,
66
active_epoch: 210,
7+
registered: true,
78
controlled_amount: '12436175589',
89
rewards_sum: '76597044006',
910
withdrawals_sum: '64185306317',
@@ -18,6 +19,7 @@ const response_accounts_regular_1 = {
1819
stake_address: 'stake1ux3g2c9dx2nhhehyrezyxpkstartcqmu9hk63qgfkccw5rqttygt7',
1920
active: true,
2021
active_epoch: 210,
22+
registered: true,
2123
controlled_amount: '12436175589',
2224
rewards_sum: '76597044006',
2325
withdrawals_sum: '64185306317',
@@ -32,6 +34,7 @@ const query_accounts_regular_testnet_1 = {
3234
stake_address: 'stake1tp5t0t5y6cqkaz7rfsyrx7mld77kpvksgkwasdweqeqesadqwewew',
3335
active: true,
3436
active_epoch: 94,
37+
registered: true,
3538
controlled_amount: '874776395',
3639
rewards_sum: '2978218',
3740
withdrawals_sum: '0',
@@ -46,6 +49,7 @@ const response_accounts_regular_testnet_1 = {
4649
stake_address: 'stake1tp5t0t5y6cqkaz7rfsyrx7mld77kpvksgkwasdweqeqesadqwewew',
4750
active: true,
4851
active_epoch: 94,
52+
registered: true,
4953
controlled_amount: '874776395',
5054
rewards_sum: '2978218',
5155
withdrawals_sum: '0',

test/unit/tests/routes/accounts.unit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as databaseUtils from '../../../../src/utils/database.js';
88

99
describe('accounts service', () => {
1010
fixtures.map(fixture => {
11-
test(fixture.name, async () => {
11+
test(`[${fixture.name}] ${fixture.endpoint}`, async () => {
1212
vi.spyOn(config, 'getConfig').mockReturnValue({
1313
...config.mainConfig,
1414
network: fixture.network === 'preview' ? 'preview' : 'mainnet',

yarn-project.nix

Lines changed: 7 additions & 6 deletions
Large diffs are not rendered by default.

yarn.lock

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,18 @@ __metadata:
114114
languageName: node
115115
linkType: hard
116116

117+
"@blockfrost/openapi@npm:0.1.85":
118+
version: 0.1.85
119+
resolution: "@blockfrost/openapi@npm:0.1.85"
120+
dependencies:
121+
ajv: ^8.17.1
122+
cbor: ^9.0.2
123+
rimraf: 6.0.1
124+
yaml: ^2.6.1
125+
checksum: 3c5d3cd8ad707cd5a0e8a5f6d547fb0a2c37d649a8d92fcdecf40095f9c5d7a5f3dc81627dda665f81a6cc3d2c229fb777c39944af92d7404b018dc9cdc7354b
126+
languageName: node
127+
linkType: hard
128+
117129
"@cspotcode/source-map-support@npm:^0.8.0":
118130
version: 0.8.1
119131
resolution: "@cspotcode/source-map-support@npm:0.8.1"
@@ -2651,7 +2663,7 @@ __metadata:
26512663
dependencies:
26522664
"@blockfrost/blockfrost-js": 6.1.0
26532665
"@blockfrost/blockfrost-utils": 2.9.0
2654-
"@blockfrost/openapi": 0.1.84
2666+
"@blockfrost/openapi": 0.1.85
26552667
"@eslint/compat": ^2.0.0
26562668
"@eslint/eslintrc": ^3.3.3
26572669
"@eslint/js": ^9.39.1

0 commit comments

Comments
 (0)