Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

web SDK v8 #385

Merged
merged 29 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a2f852b
common: wasmToSchema: Base custom section resolution on module versio…
bisgardo Apr 26, 2024
f6ca2f0
Update concordium-base reference
soerenbf Aug 27, 2024
affcd78
Align `TransactionType` enum with the corresponding type from
soerenbf Aug 27, 2024
26c3517
Update `AccountInfo` with cooldown fields
soerenbf Aug 27, 2024
3174697
Translation of updated grpc types
soerenbf Aug 28, 2024
18a4bb9
Merge branch 'main' into release/web-sdk/8
soerenbf Aug 28, 2024
ca952cd
Revert "Align `TransactionType` enum with the corresponding type from"
soerenbf Aug 28, 2024
ececf67
Merge branch 'release/web-sdk/8' into pv7-conformance
soerenbf Aug 28, 2024
0073323
Fix changelog
soerenbf Aug 28, 2024
8c44117
Merge branch 'release/web-sdk/8' into pv7-conformance
soerenbf Aug 28, 2024
865b614
Update changelog with p7 conformance changes
soerenbf Aug 28, 2024
ea4d193
Bump version
soerenbf Aug 28, 2024
5e85ac5
Merge branch 'release/web-sdk/8' into pv7-conformance
soerenbf Aug 28, 2024
e75709b
Bump version
soerenbf Aug 28, 2024
45ccafc
Merge branch 'release/web-sdk/8' into pv7-conformance
soerenbf Aug 28, 2024
80f4bf9
Added new transaction events
soerenbf Aug 28, 2024
377c93e
Fix examples build
soerenbf Aug 28, 2024
3c5b92b
Fix build fail
soerenbf Aug 28, 2024
26b9fbe
Set available balance for client test data
soerenbf Aug 28, 2024
1e4bbb6
Remove credID equality tests
soerenbf Aug 28, 2024
508ec9f
Merge pull request #384 from Concordium/pv7-conformance
soerenbf Aug 29, 2024
ba63393
Bump versions of depending packages
soerenbf Aug 29, 2024
24fa230
Merge branch 'pv7-conformance' into release/web-sdk/8
soerenbf Aug 29, 2024
a76f5b9
Alpha version bump
soerenbf Sep 6, 2024
c4c54fe
Add fallback for available balance to be compatible with node version 6
soerenbf Sep 6, 2024
d2e5a42
Merge pull request #389 from Concordium/node-6-compat
soerenbf Sep 6, 2024
f762398
Version bump
soerenbf Sep 9, 2024
df090d5
Non-blocking wasm compilation
soerenbf Sep 10, 2024
b262717
Remove node version requirement from readme
soerenbf Sep 10, 2024
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
4 changes: 3 additions & 1 deletion examples/nodejs/client/getEmbeddedSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ const client = new ConcordiumGRPCNodeClient(address, Number(port), credentials.c
const schema = await client.getEmbeddedSchema(moduleRef);
// #endregion documentation-snippet

fs.writeFileSync(cli.flags.outPath, schema);
if (schema) {
fs.writeFileSync(cli.flags.outPath, new Uint8Array(schema.buffer));
}

console.log('Wrote schema to file: ', cli.flags.outPath);
})();
14 changes: 10 additions & 4 deletions examples/nodejs/client/getPoolInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,17 @@ const client = new ConcordiumGRPCNodeClient(address, Number(port), credentials.c
const blockHash = cli.flags.block === undefined ? undefined : BlockHash.fromHexString(cli.flags.block);
const bakerPool: BakerPoolStatus = await client.getPoolInfo(BigInt(cli.flags.poolOwner), blockHash);

console.log('Open status:', bakerPool.poolInfo.openStatus);
console.log('Open status:', bakerPool.poolInfo?.openStatus);
console.log('Baker address:', bakerPool.bakerAddress);
console.log('CCD provided by the baker to the pool:', CcdAmount.toCcd(bakerPool.bakerEquityCapital));
console.log('CCD provided by the delegators to the pool:', CcdAmount.toCcd(bakerPool.delegatedCapital));
console.log(
'CCD provided by the baker to the pool:',
bakerPool.bakerEquityCapital !== undefined ? CcdAmount.toCcd(bakerPool.bakerEquityCapital) : undefined
);
console.log(
'CCD provided by the delegators to the pool:',
bakerPool.delegatedCapital !== undefined ? CcdAmount.toCcd(bakerPool.delegatedCapital) : undefined
);
console.log('Total capital in CCD of ALL pools:', CcdAmount.toCcd(bakerPool.allPoolTotalCapital));
console.log('Pool commision rates:', bakerPool.poolInfo.commissionRates);
console.log('Pool commision rates:', bakerPool.poolInfo?.commissionRates);
// #endregion documentation-snippet
})();
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ const client = new ConcordiumGRPCNodeClient(address, Number(port), credentials.c
const schema = await client.getEmbeddedSchema(moduleRef);
// #endregion documentation-snippet

fs.writeFileSync(cli.flags.outPath, schema);
if (schema) {
fs.writeFileSync(cli.flags.outPath, new Uint8Array(schema.buffer));
}

console.log('Wrote schema to file: ', cli.flags.outPath);
})();
6 changes: 3 additions & 3 deletions examples/nodejs/composed-examples/initAndUpdateContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const client = new ConcordiumGRPCNodeClient(address, Number(port), credentials.c
sender,
};

const initParams = serializeInitContractParameters(contractName, sunnyWeather, schema);
const initParams = serializeInitContractParameters(contractName, sunnyWeather, schema!.buffer);

const initPayload: InitContractPayload = {
amount: CcdAmount.zero(),
Expand Down Expand Up @@ -142,7 +142,7 @@ const client = new ConcordiumGRPCNodeClient(address, Number(port), credentials.c
contractName,
EntrypointName.fromString('set'),
rainyWeather,
schema
schema!.buffer
);

const updatePayload: UpdateContractPayload = {
Expand Down Expand Up @@ -187,7 +187,7 @@ const client = new ConcordiumGRPCNodeClient(address, Number(port), credentials.c
const rawReturnValue = unwrap(invokedPostInit.returnValue);
const returnValue = deserializeReceiveReturnValue(
ReturnValue.toBuffer(rawReturnValue),
schema,
schema!.buffer,
contractName,
EntrypointName.fromString('get')
);
Expand Down
2 changes: 1 addition & 1 deletion examples/reactnative/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -716,4 +716,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: c70448f9d8b13c40c47391af88ee9f69ffe85d63

COCOAPODS: 1.14.3
COCOAPODS: 1.15.2
6 changes: 5 additions & 1 deletion packages/ccd-js-gen/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog - ccd-js-gen

## Unreleased
## 1.2.1

### Changed

- Update peer depedency for `@concordium/web-sdk` to support any version above `7`

## 1.2.0

Expand Down
4 changes: 2 additions & 2 deletions packages/ccd-js-gen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
},
"license": "Apache-2.0",
"peerDependencies": {
"@concordium/web-sdk": "7.x"
"@concordium/web-sdk": ">= 7"
},
"dependencies": {
"@concordium/web-sdk": "workspace:^7.0.0",
"@concordium/web-sdk": "workspace:^",
"buffer": "^6.0.3",
"commander": "^11.0.0",
"sanitize-filename": "^1.6.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/ccd-js-gen/src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ async function generateCode(
}
notifier.done('Parse smart contract module.');

const moduleSchema = rawModuleSchema === null ? null : SDK.parseRawModuleSchema(rawModuleSchema);
const moduleSchema = rawModuleSchema && SDK.parseRawModuleSchema(rawModuleSchema);

const outputFilePath = path.format({
dir: outDirPath,
Expand Down
6 changes: 6 additions & 0 deletions packages/react-components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.6.1]

### Changed

- Update peer depedency for `@concordium/web-sdk` to support any version above `7`

## [0.6.0] - 2024-06-12

### Changed
Expand Down
4 changes: 2 additions & 2 deletions packages/react-components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@concordium/react-components",
"version": "0.6.0",
"version": "0.6.1",
"description": "Utility library of React components for building dApps that interact with the Concordium blockchain.",
"author": "Concordium Software",
"license": "Apache-2.0",
Expand Down Expand Up @@ -42,7 +42,7 @@
"typescript": "^5.2.2"
},
"peerDependencies": {
"@concordium/web-sdk": "7.x",
"@concordium/web-sdk": ">= 7",
"react": "^18"
}
}
6 changes: 3 additions & 3 deletions packages/rust-bindings/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions packages/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## 8.0.1

### Breaking changes
soerenbf marked this conversation as resolved.
Show resolved Hide resolved

- `getEmbeddedModuleSchema` now uses the module version to determine in which custom wasm sections to look for the schema.
- `ConcordiumGRPCClient.getEmbeddedSchema` now delegates to `getEmbeddedModuleSchema` instead of `wasmToSchema`
(which was removed as it was just a less capable version of `getEmbeddedModuleSchema`).
This means that it returns the complete `RawModuleSchema` instead of only the schema bytes.
It also means that it returns `null` instead of an error when no embedded schema was found.
- Update `AccountInfo` and `BakerPoolStatus` according to the changes introduced in the GRPC types introduced with node version 7

## 7.5.1

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@concordium/web-sdk",
"version": "7.5.1",
"version": "8.0.1",
"license": "Apache-2.0",
"engines": {
"node": ">=16"
Expand Down
9 changes: 5 additions & 4 deletions packages/sdk/src/GenericContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -521,10 +521,11 @@ export class Contract<E extends string = string, V extends string = string> exte
if (!schema) {
try {
const raw = await grpcClient.getEmbeddedSchema(instanceInfo.sourceModule);
const encoded = Buffer.from(raw).toString('base64');

if (encoded) {
mSchema = encoded;
if (raw) {
const encoded = Buffer.from(raw.buffer).toString('base64');
if (encoded) {
mSchema = encoded;
}
}
} catch {
// Do nothing.
Expand Down
19 changes: 12 additions & 7 deletions packages/sdk/src/grpc/GRPCClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { calculateEnergyCost } from '../energyCost.js';
import { HealthClient } from '../grpc-api/v2/concordium/health.client.js';
import { QueriesClient } from '../grpc-api/v2/concordium/service.client.js';
import * as v2 from '../grpc-api/v2/concordium/types.js';
import { RawModuleSchema } from '../schemaTypes.js';
import { serializeAccountTransactionPayload } from '../serialization.js';
import * as v1 from '../types.js';
import { HexString, isRpcError } from '../types.js';
Expand All @@ -29,8 +30,9 @@ import * as SequenceNumber from '../types/SequenceNumber.js';
import * as Timestamp from '../types/Timestamp.js';
import * as TransactionExpiry from '../types/TransactionExpiry.js';
import * as TransactionHash from '../types/TransactionHash.js';
import { getEmbeddedModuleSchema } from '../types/VersionedModuleSource.js';
import type { BlockItemStatus, BlockItemSummary } from '../types/blockItemSummary.js';
import { countSignatures, isHex, isValidIp, mapRecord, mapStream, unwrap, wasmToSchema } from '../util.js';
import { countSignatures, isHex, isValidIp, mapRecord, mapStream, unwrap } from '../util.js';
import * as translate from './translation.js';

/**
Expand Down Expand Up @@ -199,13 +201,16 @@ export class ConcordiumGRPCClient {
* @param moduleRef the module's reference, represented by the ModuleReference class.
* @param blockHash optional block hash to get the module embedded schema at, otherwise retrieves from last finalized block
*
* @returns the module schema as a buffer.
* @throws An error of type `RpcError` if not found in the block.
* @throws If the module or schema cannot be parsed
* @returns the module schema as a {@link RawModuleSchema} or `null` if not found in the block.
* @throws An error of type `RpcError` if the module was not found in the block.
* @throws If the module source cannot be parsed or contains duplicate schema sections.
*/
async getEmbeddedSchema(moduleRef: ModuleReference.Type, blockHash?: BlockHash.Type): Promise<Uint8Array> {
const versionedSource = await this.getModuleSource(moduleRef, blockHash);
return wasmToSchema(versionedSource.source);
async getEmbeddedSchema(
moduleRef: ModuleReference.Type,
blockHash?: BlockHash.Type
): Promise<RawModuleSchema | undefined> {
const source = await this.getModuleSource(moduleRef, blockHash);
return getEmbeddedModuleSchema(source);
}

/**
Expand Down
Loading
Loading