Skip to content

Commit 6cb088c

Browse files
authored
Optional disbursements in progress (#938)
# Motivation The maturity_disbursements_in_progress field is new, and not all test environments support it yet. To ensure ic-js works consistently across all environments, this PR makes the field optional. # Changes - Check for `maturity_disbursements_in_progress` existence before reading it. # Tests - Updated. - Verified locally that the nns-dapp doesn't break against the outdated NNS dapp canister (ic-js returns undefined). ![Screenshot 2025-05-26 at 14 24 17](https://github.com/user-attachments/assets/6c067dd7-81f4-44f8-a9f7-398f6c61b171) # Todos - [ ] Add entry to changelog (if necessary). Not necessary.
1 parent ea76251 commit 6cb088c

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

packages/nns/src/canisters/governance/response.converters.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,20 @@ describe("response.converters", () => {
306306
maturityDisbursementsInProgress: undefined,
307307
});
308308

309+
expect(
310+
toNeuron({
311+
neuron: {
312+
...defaultCandidNeuron,
313+
// Test against the outdated nns governance canister.
314+
maturity_disbursements_in_progress: undefined as unknown as [],
315+
},
316+
canisterId,
317+
}),
318+
).toEqual({
319+
...defaultNeuron,
320+
maturityDisbursementsInProgress: undefined,
321+
});
322+
309323
expect(
310324
toNeuron({
311325
neuron: {

packages/nns/src/canisters/governance/response.converters.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,9 @@ export const toNeuron = ({
196196
.joined_community_fund_timestamp_seconds.length
197197
? neuron.joined_community_fund_timestamp_seconds[0]
198198
: undefined,
199-
maturityDisbursementsInProgress:
200-
neuron.maturity_disbursements_in_progress[0]?.map(
201-
toMaturityDisbursementInProgress,
202-
),
199+
maturityDisbursementsInProgress: fromNullable(
200+
neuron.maturity_disbursements_in_progress,
201+
)?.map(toMaturityDisbursementInProgress),
203202
dissolveState: neuron.dissolve_state.length
204203
? toDissolveState(neuron.dissolve_state[0])
205204
: undefined,

0 commit comments

Comments
 (0)