Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/streams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,14 @@ function parseStreamInfo(id: bigint, address: string, val: xdr.ScVal): StreamInf
// (see contracts/stream/src/storage.rs). Reading `m['paused']` etc. always
// yields `undefined`; derive the booleans by masking `flags`, mirroring
// `StreamInfo::is_paused()` / `is_cancelled()` / `is_clawback_enabled()`.
const flags = m['flags'] ? scValToU32(m['flags']) : 0;
let flags = 0;
if (m['flags']) {
try {
flags = scValToU32(m['flags']);
} catch {
flags = 0;
}
}

const info: StreamInfo = {
id,
Expand Down
13 changes: 13 additions & 0 deletions src/tests/parse-stream-info.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,17 @@ describe('parseStreamInfo — flags (#521)', () => {
expect(info.clawbackEnabled).toBe(true);
expect(info.cancelled).toBe(false);
});

it('falls back to flags=0 when flags is not a u32 ScVal (#617)', async () => {
mockSimulate.mockResolvedValue(simSuccess(baseStreamMap({
flags: xdr.ScVal.scvString('not-a-u32'),
})));
const { StreamsModule } = await import('../streams.js');
const sdk = new StreamsModule({ network: 'testnet', factoryAddress: FACTORY_ADDR, keypair: Keypair.random() });

const info = await sdk.get(1n);
expect(info.paused).toBe(false);
expect(info.cancelled).toBe(false);
expect(info.clawbackEnabled).toBe(false);
});
});