Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
47c9ffc
Add upward type
soerenbf Aug 29, 2025
797c4de
Update block item summary
soerenbf Aug 29, 2025
386c1e2
Add docs explaining possible unknowns
soerenbf Sep 1, 2025
aa680e3
Update changelog
soerenbf Sep 1, 2025
cc18768
Fix unit test compile errors
soerenbf Sep 1, 2025
d1490dd
Update token and stake related events with unknown variants
soerenbf Sep 2, 2025
b14bf79
Update examples
soerenbf Sep 2, 2025
c7ed2a2
Update changelog
soerenbf Sep 2, 2025
14ee429
Wrap response for special events in `Upward`
soerenbf Sep 2, 2025
a771112
Wrap pending update effects in `Upward`
soerenbf Sep 2, 2025
c465f14
add jsdoc
soerenbf Sep 2, 2025
d18dd35
Add jsdoc
soerenbf Sep 2, 2025
76049de
Wrap `UpdateInstructionPayload` in `Upward` for read-only types
soerenbf Sep 2, 2025
2ec30f0
JSDoc
soerenbf Sep 2, 2025
5804114
..
soerenbf Sep 2, 2025
d494537
Changelog
soerenbf Sep 2, 2025
7596357
Merge pull request #481 from Concordium/forwards-comp/block-item-summary
soerenbf Sep 2, 2025
7218e48
Restructure token module types + add reject reason
soerenbf Sep 3, 2025
5fb2020
Fix build
soerenbf Sep 3, 2025
8b9c0cc
Add missing jsdoc
soerenbf Sep 3, 2025
5fb33b0
Merge pull request #484 from Concordium/forward-comp/chain-updates
soerenbf Sep 3, 2025
3ca55b8
Merge pull request #483 from Concordium/forward-comp/special-events
soerenbf Sep 3, 2025
c3a6e9b
Merge branch 'feature/forwards-compatibility' into forward-comp/events
soerenbf Sep 3, 2025
c3e2080
Merge pull request #482 from Concordium/forward-comp/events
soerenbf Sep 3, 2025
3615c99
Wrapped NodeInfoConsensusStatus and NodeCatchupStatus with Upward
Sep 3, 2025
fa505a4
ran Prettier for some style issue
Sep 3, 2025
46fe10c
Wrapped Upward around PassiveCommitteeInfo
Sep 3, 2025
859210a
ran prettier
Sep 3, 2025
40ae3c8
Merge pull request #491 from Concordium/forward-com/COR-1841-NodeCatc…
rbaconcordium Sep 3, 2025
9b043f9
Merge branch 'feature/forwards-compatibility' into forward-com/COR-18…
rbaconcordium Sep 3, 2025
b5a9fb0
Merge pull request #493 from Concordium/forward-com/COR-1841-PassiveC…
rbaconcordium Sep 3, 2025
0450bed
changed to case undefined instead of default
Sep 4, 2025
5b015b4
Merge pull request #495 from Concordium/forward-comp/COR-1841-case-un…
rbaconcordium Sep 4, 2025
460aab9
Wrap Upward around RejectReason
Sep 4, 2025
0203bce
wrapped Upward for RejectReason in blockItemSummary
Sep 4, 2025
4f20370
Merge pull request #488 from Concordium/cbor-types-refactor
soerenbf Sep 4, 2025
6ce0679
Update examples/nodejs/client/getBlockItemStatus.ts
rbaconcordium Sep 4, 2025
119cf44
Update examples/nodejs/plt/update-supply.ts
rbaconcordium Sep 4, 2025
8848c47
Update examples/nodejs/plt/transfer.ts
rbaconcordium Sep 4, 2025
c88c599
Update examples/nodejs/plt/modify-list.ts
rbaconcordium Sep 4, 2025
f8f514a
Update examples/nodejs/plt/pause.ts
rbaconcordium Sep 4, 2025
181caaf
Update packages/sdk/src/types/blockItemSummary.ts
rbaconcordium Sep 4, 2025
5e2e46f
Update packages/sdk/src/types.ts
rbaconcordium Sep 4, 2025
87ac9c8
fmt
soerenbf Sep 4, 2025
383ad91
Merge pull request #497 from Concordium/forward-com/COR-1834-Reject-R…
rbaconcordium Sep 5, 2025
3e9ef84
Wrap Upward around RewardStatus
Sep 5, 2025
a1ba8eb
Amended as per feedbacks
Sep 5, 2025
ab2ea43
Formating of file
Sep 5, 2025
a5ccd88
Add unknown variants to fields to `AccountInfo` (#498)
soerenbf Sep 5, 2025
ba903c4
Merge branch 'feature/forwards-compatibility' into forward-comp/COR-1…
rbaconcordium Sep 5, 2025
2fa7b5a
Merge pull request #503 from Concordium/forward-comp/COR-1837-Reward-…
rbaconcordium Sep 5, 2025
1ad179e
Forward comp/token cbor types (#492)
soerenbf Sep 8, 2025
d9f4718
Forward comp/contract types (#499)
soerenbf Sep 8, 2025
e0c5a9a
Forward comp/creds (#502)
soerenbf Sep 9, 2025
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
7 changes: 3 additions & 4 deletions examples/nodejs/client/getBlockItemStatus.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BlockItemStatus, CcdAmount, TransactionHash } from '@concordium/web-sdk';
import { BlockItemStatus, CcdAmount, TransactionHash, knownOrError } from '@concordium/web-sdk';
import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs';
import { credentials } from '@grpc/grpc-js';
import meow from 'meow';
Expand Down Expand Up @@ -77,8 +77,7 @@ const client = new ConcordiumGRPCNodeClient(
if (blockItemStatus.status === 'finalized') {
console.log('blockItemStatus is "finalized" and therefore there is exactly one outcome \n');

const { summary } = blockItemStatus.outcome;

const summary = knownOrError(blockItemStatus.outcome.summary, 'unknown outcome encountered');
if (summary.type === 'accountTransaction') {
console.log('The block item is an account transaction');

Expand All @@ -95,7 +94,7 @@ const client = new ConcordiumGRPCNodeClient(
const { failedTransactionType, rejectReason } = summary;
console.log(
'Transaction of type "' + failedTransactionType + '" failed because:',
rejectReason.tag
rejectReason?.tag ?? 'unknown'
);
break;
default:
Expand Down
10 changes: 7 additions & 3 deletions examples/nodejs/client/getBlockSpecialEvents.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BlockHash, BlockSpecialEvent } from '@concordium/web-sdk';
import { BlockHash, BlockSpecialEvent, Upward, isKnown } from '@concordium/web-sdk';
import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs';
import { credentials } from '@grpc/grpc-js';
import meow from 'meow';
Expand Down Expand Up @@ -50,10 +50,14 @@ const client = new ConcordiumGRPCNodeClient(address, Number(port), credentials.c
(async () => {
// #region documentation-snippet
const blockHash = cli.flags.block === undefined ? undefined : BlockHash.fromHexString(cli.flags.block);
const events: AsyncIterable<BlockSpecialEvent> = client.getBlockSpecialEvents(blockHash);
const events: AsyncIterable<Upward<BlockSpecialEvent>> = client.getBlockSpecialEvents(blockHash);
// #endregion documentation-snippet

for await (const event of events) {
console.dir(event, { depth: null, colors: true });
if (!isKnown(event)) {
console.warn('Unknown event encountered');
} else {
console.dir(event, { depth: null, colors: true });
}
}
})();
10 changes: 7 additions & 3 deletions examples/nodejs/client/getBlockTransactionEvents.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BlockHash, BlockItemSummary } from '@concordium/web-sdk';
import { BlockHash, BlockItemSummary, Upward, isKnown } from '@concordium/web-sdk';
import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs';
import { credentials } from '@grpc/grpc-js';
import meow from 'meow';
Expand Down Expand Up @@ -48,10 +48,14 @@ const client = new ConcordiumGRPCNodeClient(address, Number(port), credentials.c
(async () => {
// #region documentation-snippet
const blockHash = cli.flags.block === undefined ? undefined : BlockHash.fromHexString(cli.flags.block);
const events: AsyncIterable<BlockItemSummary> = client.getBlockTransactionEvents(blockHash);
const events: AsyncIterable<Upward<BlockItemSummary>> = client.getBlockTransactionEvents(blockHash);
// #endregion documentation-snippet

for await (const event of events) {
console.dir(event, { depth: null, colors: true });
if (isKnown(event)) {
console.dir(event, { depth: null, colors: true });
} else {
console.warn('Encountered unknown event');
}
}
})();
7 changes: 6 additions & 1 deletion examples/nodejs/client/getTokenomicsInfo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BlockHash } from '@concordium/web-sdk';
import { BlockHash, isKnown } from '@concordium/web-sdk';
import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs';
import { credentials } from '@grpc/grpc-js';
import meow from 'meow';
Expand Down Expand Up @@ -55,6 +55,11 @@ const client = new ConcordiumGRPCNodeClient(address, Number(port), credentials.c

// Protocol version 4 expanded the amount of information in the response, so one should check the type to access that.
// This information includes information about the payday and total amount of funds staked.
if (!isKnown(tokenomics)) {
console.warn('Unknown tokenomics version found');
return;
}

if (tokenomics.version === 1) {
console.log('Next payday time:', tokenomics.nextPaydayTime);
console.log('Total staked amount by bakers and delegators', tokenomics.totalStakedCapital);
Expand Down
3 changes: 2 additions & 1 deletion examples/nodejs/client/invokeContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
Parameter,
ReceiveName,
ReturnValue,
Upward,
} from '@concordium/web-sdk';
import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs';
import { credentials } from '@grpc/grpc-js';
Expand Down Expand Up @@ -124,7 +125,7 @@ const client = new ConcordiumGRPCNodeClient(address, Number(port), credentials.c
console.log('The return value of the invoked method:', ReturnValue.toHexString(returnValue));
}

const events: ContractTraceEvent[] = result.events;
const events: Upward<ContractTraceEvent>[] = result.events;
console.log('A list of effects that the update would have:');
console.dir(events, { depth: null, colors: true });
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AccountAddress, isRpcError } from '@concordium/web-sdk';
import { AccountAddress, isKnown, isRpcError } from '@concordium/web-sdk';
import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs';
import { credentials } from '@grpc/grpc-js';
import meow from 'meow';
Expand Down Expand Up @@ -75,6 +75,9 @@ const client = new ConcordiumGRPCNodeClient(address, Number(port), credentials.c

// If account is not a genesis account print account creation transaction hash
for await (const summary of summaries) {
if (!isKnown(summary)) {
continue;
}
if (summary.type === 'accountCreation' && AccountAddress.equals(summary.address, account)) {
console.log('Hash of transaction that created the account:', summary.hash);
}
Expand Down
11 changes: 10 additions & 1 deletion examples/nodejs/composed-examples/initAndUpdateContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {
affectedContracts,
buildAccountSigner,
deserializeReceiveReturnValue,
isKnown,
knownOrError,
parseWallet,
serializeInitContractParameters,
serializeUpdateContractParameters,
Expand Down Expand Up @@ -118,7 +120,14 @@ const client = new ConcordiumGRPCNodeClient(address, Number(port), credentials.c
const initStatus = await client.waitForTransactionFinalization(initTrxHash);
console.dir(initStatus, { depth: null, colors: true });

const contractAddress = affectedContracts(initStatus.summary)[0];
if (!isKnown(initStatus.summary)) {
throw new Error('Unexpected transaction outcome');
}

const contractAddress = knownOrError(
affectedContracts(initStatus.summary)[0],
'Expected contract init event to be known'
);

// #endregion documentation-snippet-init-contract

Expand Down
5 changes: 4 additions & 1 deletion examples/nodejs/composed-examples/listInitialAccounts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { unwrap } from '@concordium/web-sdk';
import { isKnown, unwrap } from '@concordium/web-sdk';
import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs';
import { credentials } from '@grpc/grpc-js';
import meow from 'meow';
Expand Down Expand Up @@ -71,6 +71,9 @@ const client = new ConcordiumGRPCNodeClient(address, Number(port), credentials.c
// Get transactions for block
const trxStream = client.getBlockTransactionEvents(block.hash);
for await (const trx of trxStream) {
if (!isKnown(trx)) {
continue;
}
if (trx.type === 'accountCreation' && trx.credentialType === 'initial') {
initAccounts.push(trx.address);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AccountAddress, isTransferLikeSummary, unwrap } from '@concordium/web-sdk';
import { AccountAddress, isKnown, isTransferLikeSummary, unwrap } from '@concordium/web-sdk';
import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs';
import { credentials } from '@grpc/grpc-js';
import meow from 'meow';
Expand Down Expand Up @@ -75,6 +75,9 @@ const client = new ConcordiumGRPCNodeClient(address, Number(port), credentials.c

// For each transaction in the block:
trxLoop: for await (const trx of trxStream) {
if (!isKnown(trx)) {
continue;
}
if (isTransferLikeSummary(trx)) {
const trxAcc = trx.sender;

Expand Down
14 changes: 10 additions & 4 deletions examples/nodejs/plt/modify-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
TransactionEventTag,
TransactionKindString,
TransactionSummaryType,
isKnown,
serializeAccountTransactionPayload,
} from '@concordium/web-sdk';
import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs';
Expand All @@ -17,6 +18,7 @@ import {
TokenOperation,
TokenOperationType,
createTokenUpdatePayload,
parseTokenModuleEvent,
} from '@concordium/web-sdk/plt';
import { credentials } from '@grpc/grpc-js';
import meow from 'meow';
Expand Down Expand Up @@ -137,22 +139,26 @@ const client = new ConcordiumGRPCNodeClient(
const result = await client.waitForTransactionFinalization(transaction);
console.log('Transaction finalized:', result);

if (!isKnown(result.summary)) {
throw new Error('Unexpected transaction outcome');
}

if (result.summary.type !== TransactionSummaryType.AccountTransaction) {
throw new Error('Unexpected transaction type: ' + result.summary.type);
}

switch (result.summary.transactionType) {
case TransactionKindString.TokenUpdate:
result.summary.events.forEach((e) => {
result.summary.events.filter(isKnown).forEach((e) => {
if (e.tag !== TransactionEventTag.TokenModuleEvent) {
throw new Error('Unexpected event type: ' + e.tag);
}
console.log('Token module event:', e, Cbor.decode(e.details, 'TokenListUpdateEventDetails'));
console.log('Token module event:', parseTokenModuleEvent(e));
});
break;
case TransactionKindString.Failed:
if (result.summary.rejectReason.tag !== RejectReasonTag.TokenUpdateTransactionFailed) {
throw new Error('Unexpected reject reason tag: ' + result.summary.rejectReason.tag);
if (result.summary.rejectReason?.tag !== RejectReasonTag.TokenUpdateTransactionFailed) {
throw new Error('Unexpected reject reason tag: ' + result.summary.rejectReason?.tag);
}
const details = Cbor.decode(result.summary.rejectReason.contents.details);
console.error(result.summary.rejectReason.contents, details);
Expand Down
22 changes: 17 additions & 5 deletions examples/nodejs/plt/pause.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@ import {
TransactionEventTag,
TransactionKindString,
TransactionSummaryType,
isKnown,
serializeAccountTransactionPayload,
} from '@concordium/web-sdk';
import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs';
import { Cbor, Token, TokenId, TokenOperation, createTokenUpdatePayload } from '@concordium/web-sdk/plt';
import {
Cbor,
Token,
TokenId,
TokenOperation,
createTokenUpdatePayload,
parseTokenModuleEvent,
} from '@concordium/web-sdk/plt';
import { credentials } from '@grpc/grpc-js';
import meow from 'meow';

Expand Down Expand Up @@ -102,22 +110,26 @@ const client = new ConcordiumGRPCNodeClient(
const result = await client.waitForTransactionFinalization(transaction);
console.log('Transaction finalized:', result);

if (!isKnown(result.summary)) {
throw new Error('Unexpected transaction outcome');
}

if (result.summary.type !== TransactionSummaryType.AccountTransaction) {
throw new Error('Unexpected transaction type: ' + result.summary.type);
}

switch (result.summary.transactionType) {
case TransactionKindString.TokenUpdate:
result.summary.events.forEach((e) => {
result.summary.events.filter(isKnown).forEach((e) => {
if (e.tag !== TransactionEventTag.TokenModuleEvent) {
throw new Error('Unexpected event type: ' + e.tag);
}
console.log('Token module event:', e, Cbor.decode(e.details, 'TokenPauseEventDetails'));
console.log('Token module event:', parseTokenModuleEvent(e));
});
break;
case TransactionKindString.Failed:
if (result.summary.rejectReason.tag !== RejectReasonTag.TokenUpdateTransactionFailed) {
throw new Error('Unexpected reject reason tag: ' + result.summary.rejectReason.tag);
if (result.summary.rejectReason?.tag !== RejectReasonTag.TokenUpdateTransactionFailed) {
throw new Error('Unexpected reject reason tag: ' + result.summary.rejectReason?.tag);
}
const details = Cbor.decode(result.summary.rejectReason.contents.details);
console.error(result.summary.rejectReason.contents, details);
Expand Down
8 changes: 6 additions & 2 deletions examples/nodejs/plt/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
RejectReasonTag,
TransactionKindString,
TransactionSummaryType,
isKnown,
serializeAccountTransactionPayload,
} from '@concordium/web-sdk';
import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs';
Expand Down Expand Up @@ -116,6 +117,9 @@ const client = new ConcordiumGRPCNodeClient(
const result = await client.waitForTransactionFinalization(transaction);
console.log('Transaction finalized:', result);

if (!isKnown(result.summary)) {
throw new Error('Unexpected transaction outcome');
}
if (result.summary.type !== TransactionSummaryType.AccountTransaction) {
throw new Error('Unexpected transaction type: ' + result.summary.type);
}
Expand All @@ -125,8 +129,8 @@ const client = new ConcordiumGRPCNodeClient(
result.summary.events.forEach((e) => console.log(e));
break;
case TransactionKindString.Failed:
if (result.summary.rejectReason.tag !== RejectReasonTag.TokenUpdateTransactionFailed) {
throw new Error('Unexpected reject reason tag: ' + result.summary.rejectReason.tag);
if (result.summary.rejectReason?.tag !== RejectReasonTag.TokenUpdateTransactionFailed) {
throw new Error('Unexpected reject reason tag: ' + result.summary.rejectReason?.tag);
}
const details = Cbor.decode(result.summary.rejectReason.contents.details);
console.error(result.summary.rejectReason.contents, details);
Expand Down
8 changes: 6 additions & 2 deletions examples/nodejs/plt/update-supply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
RejectReasonTag,
TransactionKindString,
TransactionSummaryType,
isKnown,
serializeAccountTransactionPayload,
} from '@concordium/web-sdk';
import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs';
Expand Down Expand Up @@ -110,6 +111,9 @@ const client = new ConcordiumGRPCNodeClient(addr, Number(port), credentials.crea
const result = await client.waitForTransactionFinalization(transaction);
console.log('Transaction finalized:', result);

if (!isKnown(result.summary)) {
throw new Error('Unexpected transaction outcome');
}
if (result.summary.type !== TransactionSummaryType.AccountTransaction) {
throw new Error('Unexpected transaction type: ' + result.summary.type);
}
Expand All @@ -119,8 +123,8 @@ const client = new ConcordiumGRPCNodeClient(addr, Number(port), credentials.crea
result.summary.events.forEach((e) => console.log(e));
break;
case TransactionKindString.Failed:
if (result.summary.rejectReason.tag !== RejectReasonTag.TokenUpdateTransactionFailed) {
throw new Error('Unexpected reject reason tag: ' + result.summary.rejectReason.tag);
if (result.summary.rejectReason?.tag !== RejectReasonTag.TokenUpdateTransactionFailed) {
throw new Error('Unexpected reject reason tag: ' + result.summary.rejectReason?.tag);
}
const details = Cbor.decode(result.summary.rejectReason.contents.details);
console.error(result.summary.rejectReason.contents, details);
Expand Down
4 changes: 2 additions & 2 deletions examples/wallet/src/CreateAccount.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
CredentialDeploymentTransaction,
CredentialDeploymentPayload,
CredentialInputNoSeed,
IdentityObjectV1,
getAccountAddress,
Expand Down Expand Up @@ -43,7 +43,7 @@ export function CreateAccount({ identity }: { identity: IdentityObjectV1 }) {
return;
}

const listener = (worker.onmessage = async (e: MessageEvent<CredentialDeploymentTransaction>) => {
const listener = (worker.onmessage = async (e: MessageEvent<CredentialDeploymentPayload>) => {
worker.removeEventListener('message', listener);
const credentialDeploymentTransaction = e.data;
const signingKey = getAccountSigningKey(seedPhrase, credentialDeploymentTransaction.unsignedCdi.ipIdentity);
Expand Down
4 changes: 2 additions & 2 deletions examples/wallet/src/account-worker.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createCredentialTransactionNoSeed } from '@concordium/web-sdk';
import { createCredentialPayloadNoSeed } from '@concordium/web-sdk';

import { AccountWorkerInput } from './types';

self.onmessage = (e: MessageEvent<AccountWorkerInput>) => {
const credentialTransaction = createCredentialTransactionNoSeed(e.data.credentialInput, e.data.expiry);
const credentialTransaction = createCredentialPayloadNoSeed(e.data.credentialInput, e.data.expiry);
self.postMessage(credentialTransaction);
};
Loading