Skip to content

Commit

Permalink
Merge pull request #220 from Concordium/prepare-release
Browse files Browse the repository at this point in the history
Prepare new release + Fix transaction type enum
  • Loading branch information
shjortConcordium authored Jul 6, 2023
2 parents b1f33b5 + d505c71 commit 68ea0b6
Show file tree
Hide file tree
Showing 11 changed files with 141 additions and 14 deletions.
13 changes: 11 additions & 2 deletions packages/common/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
# Changelog

## 8.1.0
## 9.0.0

### Breaking changes

- Renamed `AccountTransactionType.TransferWithScheduleWithMemo` to `AccountTransactionType.TransferWithScheduleAndMemo`.

### Changed

- Bumped @concordium/rust-bindings to 1.1.0 (adds `display_type_schema_template` function)

### Added

- `display_type_schema_template` function
- `getTransactionKindString` function.
- `displayTypeSchemaTemplate` function.

## 8.0.0

Expand Down
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@concordium/common-sdk",
"version": "8.1.0",
"version": "9.0.0",
"license": "Apache-2.0",
"engines": {
"node": ">=14.16.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1492,7 +1492,7 @@ export enum AccountTransactionType {
RegisterData = 21,
TransferWithMemo = 22,
EncryptedAmountTransferWithMemo = 23,
TransferWithScheduleWithMemo = 24,
TransferWithScheduleAndMemo = 24,
ConfigureBaker = 25,
ConfigureDelegation = 26,
}
Expand Down
12 changes: 12 additions & 0 deletions packages/common/src/types/blockItemSummary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
TransactionStatusEnum,
ContractAddress,
Base58String,
AccountTransactionType,
} from '../types';
import { RejectReason } from './rejectReason';
import { isDefined } from '../util';
Expand Down Expand Up @@ -74,6 +75,17 @@ export enum TransactionKindString {
Failed = 'failed',
}

/**
* Given an AccountTransactionType number value, return the corresponding TransactionKindString value
*/
export function getTransactionKindString(
type: AccountTransactionType
): TransactionKindString {
return TransactionKindString[
AccountTransactionType[type] as keyof typeof AccountTransactionType
];
}

export interface TransferSummary {
transactionType: TransactionKindString.Transfer;
transfer: AccountTransferredEvent;
Expand Down
26 changes: 26 additions & 0 deletions packages/common/test/schemaHelpers.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import fs from 'fs';
import { Buffer } from 'buffer/';
import {
displayTypeSchemaTemplate,
getUpdateContractParameterSchema,
} from '../src/schemaHelpers';

test('schema template display', () => {
const fullSchema = Buffer.from(
fs.readFileSync('./test/resources/cis2-nft-schema.bin')
);
const schemaVersion = 1;
const contractName = 'CIS2-NFT';
const functionName = 'transfer';
const template = displayTypeSchemaTemplate(
getUpdateContractParameterSchema(
fullSchema,
contractName,
functionName,
schemaVersion
)
);
expect(template).toBe(
'[{"amount":["<UInt8>","<UInt8>"],"data":["<UInt8>"],"from":{"Enum":[{"Account":["<AccountAddress>"]},{"Contract":[{"index":"<UInt64>","subindex":"<UInt64>"}]}]},"to":{"Enum":[{"Account":["<AccountAddress>"]},{"Contract":[{"index":"<UInt64>","subindex":"<UInt64>"},{"contract":"<String>","func":"<String>"}]}]},"token_id":["<UInt8>"]}]'
);
});
74 changes: 74 additions & 0 deletions packages/common/test/types/blockItemSummary.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import {
ConfigureDelegationSummary,
DelegationTargetType,
getSummaryContractUpdateLogs,
getTransactionKindString,
AccountTransactionType,
} from '../../src';

const chainUpdate: UpdateSummary = {
Expand Down Expand Up @@ -348,3 +350,75 @@ describe('getSummaryContractUpdateLogs', () => {
]);
});
});

test('getTransactionKindString', () => {
expect(getTransactionKindString(AccountTransactionType.DeployModule)).toBe(
TransactionKindString.DeployModule
);
expect(getTransactionKindString(AccountTransactionType.InitContract)).toBe(
TransactionKindString.InitContract
);
expect(getTransactionKindString(AccountTransactionType.Update)).toBe(
TransactionKindString.Update
);
expect(getTransactionKindString(AccountTransactionType.Transfer)).toBe(
TransactionKindString.Transfer
);
expect(getTransactionKindString(AccountTransactionType.AddBaker)).toBe(
TransactionKindString.AddBaker
);
expect(getTransactionKindString(AccountTransactionType.RemoveBaker)).toBe(
TransactionKindString.RemoveBaker
);
expect(
getTransactionKindString(AccountTransactionType.UpdateBakerStake)
).toBe(TransactionKindString.UpdateBakerStake);
expect(
getTransactionKindString(
AccountTransactionType.UpdateBakerRestakeEarnings
)
).toBe(TransactionKindString.UpdateBakerRestakeEarnings);
expect(
getTransactionKindString(AccountTransactionType.UpdateBakerKeys)
).toBe(TransactionKindString.UpdateBakerKeys);
expect(
getTransactionKindString(AccountTransactionType.UpdateCredentialKeys)
).toBe(TransactionKindString.UpdateCredentialKeys);
expect(
getTransactionKindString(AccountTransactionType.EncryptedAmountTransfer)
).toBe(TransactionKindString.EncryptedAmountTransfer);
expect(
getTransactionKindString(AccountTransactionType.TransferToEncrypted)
).toBe(TransactionKindString.TransferToEncrypted);
expect(
getTransactionKindString(AccountTransactionType.TransferToPublic)
).toBe(TransactionKindString.TransferToPublic);
expect(
getTransactionKindString(AccountTransactionType.TransferWithSchedule)
).toBe(TransactionKindString.TransferWithSchedule);
expect(
getTransactionKindString(AccountTransactionType.UpdateCredentials)
).toBe(TransactionKindString.UpdateCredentials);
expect(getTransactionKindString(AccountTransactionType.RegisterData)).toBe(
TransactionKindString.RegisterData
);
expect(
getTransactionKindString(AccountTransactionType.TransferWithMemo)
).toBe(TransactionKindString.TransferWithMemo);
expect(
getTransactionKindString(
AccountTransactionType.EncryptedAmountTransferWithMemo
)
).toBe(TransactionKindString.EncryptedAmountTransferWithMemo);
expect(
getTransactionKindString(
AccountTransactionType.TransferWithScheduleAndMemo
)
).toBe(TransactionKindString.TransferWithScheduleAndMemo);
expect(
getTransactionKindString(AccountTransactionType.ConfigureBaker)
).toBe(TransactionKindString.ConfigureBaker);
expect(
getTransactionKindString(AccountTransactionType.ConfigureDelegation)
).toBe(TransactionKindString.ConfigureDelegation);
});
6 changes: 6 additions & 0 deletions packages/nodejs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 9.0.0

### Breaking changes

- Bumped @concordium/common-sdk to 9.0.0. (adds `displayTypeSchemaTemplate/getTransactionKindString` and renames `AccountTransactionType.TransferWithScheduleWithMemo`)

## 8.0.0

### Breaking changes
Expand Down
4 changes: 2 additions & 2 deletions packages/nodejs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@concordium/node-sdk",
"version": "8.0.0",
"version": "9.0.0",
"description": "Helpers for interacting with the Concordium node",
"repository": {
"type": "git",
Expand Down Expand Up @@ -60,7 +60,7 @@
"build-dev": "tsc"
},
"dependencies": {
"@concordium/common-sdk": "8.1.0",
"@concordium/common-sdk": "9.0.0",
"@grpc/grpc-js": "^1.3.4",
"@protobuf-ts/grpc-transport": "^2.8.2",
"buffer": "^6.0.3",
Expand Down
6 changes: 3 additions & 3 deletions packages/web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Changelog

## 5.1.0
## 6.0.0

### Added
### Breaking changes

- `display_type_schema_template` function
- Bumped @concordium/rust-bindings to 1.1.0 and @concordium/common-sdk to 9.0.0. (adds `displayTypeSchemaTemplate/getTransactionKindString` and renames `AccountTransactionType.TransferWithScheduleWithMemo`)

## 5.0.0

Expand Down
4 changes: 2 additions & 2 deletions packages/web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@concordium/web-sdk",
"version": "5.1.0",
"version": "6.0.0",
"license": "Apache-2.0",
"browser": "lib/concordium.min.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -48,7 +48,7 @@
"webpack-cli": "^4.9.2"
},
"dependencies": {
"@concordium/common-sdk": "8.1.0",
"@concordium/common-sdk": "9.0.0",
"@concordium/rust-bindings": "1.1.0",
"@grpc/grpc-js": "^1.3.4",
"@protobuf-ts/grpcweb-transport": "^2.8.2",
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,7 @@ __metadata:
languageName: node
linkType: hard

"@concordium/common-sdk@8.1.0, @concordium/common-sdk@workspace:packages/common":
"@concordium/common-sdk@9.0.0, @concordium/common-sdk@workspace:packages/common":
version: 0.0.0-use.local
resolution: "@concordium/common-sdk@workspace:packages/common"
dependencies:
Expand Down Expand Up @@ -1375,7 +1375,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@concordium/node-sdk@workspace:packages/nodejs"
dependencies:
"@concordium/common-sdk": 8.1.0
"@concordium/common-sdk": 9.0.0
"@grpc/grpc-js": ^1.3.4
"@noble/ed25519": ^1.7.1
"@protobuf-ts/grpc-transport": ^2.8.2
Expand Down Expand Up @@ -1414,7 +1414,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@concordium/web-sdk@workspace:packages/web"
dependencies:
"@concordium/common-sdk": 8.1.0
"@concordium/common-sdk": 9.0.0
"@concordium/rust-bindings": 1.1.0
"@grpc/grpc-js": ^1.3.4
"@protobuf-ts/grpcweb-transport": ^2.8.2
Expand Down

0 comments on commit 68ea0b6

Please sign in to comment.