Skip to content

Commit b20ea1c

Browse files
author
Victor Nordam Suadicani
authored
Fix voting example (#482)
* Fix voting example * Changelog * Fix broken swc version * Fix broken swc version in other package.jsons too * Fix workaround * Update lock file
1 parent 4b545a0 commit b20ea1c

File tree

9 files changed

+177
-13
lines changed

9 files changed

+177
-13
lines changed

examples/eSealing/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"typescript": "^5.2.2",
2727
"vite": "^4.5.0",
2828
"vite-plugin-svgr": "^4.1.0",
29-
"vite-plugin-top-level-await": "^1.3.1",
29+
"vite-plugin-top-level-await": "^1.4.2",
3030
"vite-plugin-wasm": "^3.2.2"
3131
},
3232
"scripts": {

examples/voting/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 1.1.3
4+
5+
- Fixed problems on the result page due to breaking changes in the web SDK.
6+
37
## 1.1.2
48

59
- Bumped version of @concordium/web-sdk and @concordium/browser-wallet-api-helpers

examples/voting/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"typescript": "^5.2.2",
2727
"vite": "^4.5.0",
2828
"vite-plugin-svgr": "^4.1.0",
29-
"vite-plugin-top-level-await": "^1.3.1",
29+
"vite-plugin-top-level-await": "^1.4.2",
3030
"vite-plugin-wasm": "^3.2.2"
3131
},
3232
"scripts": {
File renamed without changes.
File renamed without changes.

examples/voting/src/Wallet.jsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ import { Alert, Button } from 'react-bootstrap';
1111
import {
1212
AccountTransactionType,
1313
CcdAmount,
14+
ConcordiumGRPCClient,
15+
ContractAddress,
16+
ContractName,
17+
EntrypointName,
1418
ModuleReference,
19+
ReceiveName,
1520
serializeUpdateContractParameters,
1621
toBuffer,
1722
} from '@concordium/web-sdk';
@@ -105,19 +110,20 @@ export async function getView(client, contractIndex) {
105110
export async function getVotes(client, contractIndex, numOptions) {
106111
const promises = [];
107112

113+
const grpcClient = new ConcordiumGRPCClient(client.grpcTransport);
108114
for (let i = 0; i < numOptions; i++) {
109115
const param = serializeUpdateContractParameters(
110-
'voting',
111-
'getNumberOfVotes',
116+
ContractName.fromString('voting'),
117+
EntrypointName.fromString('getNumberOfVotes'),
112118
{
113119
vote_index: i,
114120
},
115121
toBuffer(RAW_SCHEMA_BASE64, 'base64')
116122
);
117123

118-
const promise = client.getGrpcClient().invokeContract({
119-
contract: { index: BigInt(contractIndex), subindex: BigInt(0) },
120-
method: 'voting.getNumberOfVotes',
124+
const promise = grpcClient.invokeContract({
125+
contract: ContractAddress.create(contractIndex, 0),
126+
method: ReceiveName.fromString('voting.getNumberOfVotes'),
121127
parameter: param,
122128
});
123129

examples/voting/src/buffer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function decodeVotes(votesResult) {
4242
const votes = new Array(0);
4343
votesResult.forEach((element) => {
4444
const offset0 = 0;
45-
const buffer = toBuffer(element.returnValue, 'hex');
45+
const buffer = toBuffer(element.returnValue.buffer, 'hex');
4646
const [voteCount] = [buffer.readUInt32LE(offset0), offset0 + 4];
4747
votes.push(voteCount);
4848
});

examples/wCCD/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"typescript": "^5.2.2",
2424
"vite": "^4.5.0",
2525
"vite-plugin-svgr": "^4.1.0",
26-
"vite-plugin-top-level-await": "^1.3.1",
26+
"vite-plugin-top-level-await": "^1.4.2",
2727
"vite-plugin-wasm": "^3.2.2"
2828
},
2929
"scripts": {

yarn.lock

Lines changed: 158 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3839,7 +3839,7 @@ __metadata:
38393839
languageName: node
38403840
linkType: hard
38413841

3842-
"@rollup/plugin-virtual@npm:^3.0.1":
3842+
"@rollup/plugin-virtual@npm:^3.0.1, @rollup/plugin-virtual@npm:^3.0.2":
38433843
version: 3.0.2
38443844
resolution: "@rollup/plugin-virtual@npm:3.0.2"
38453845
peerDependencies:
@@ -5758,69 +5758,139 @@ __metadata:
57585758
languageName: node
57595759
linkType: hard
57605760

5761+
"@swc/core-darwin-arm64@npm:1.7.0":
5762+
version: 1.7.0
5763+
resolution: "@swc/core-darwin-arm64@npm:1.7.0"
5764+
conditions: os=darwin & cpu=arm64
5765+
languageName: node
5766+
linkType: hard
5767+
57615768
"@swc/core-darwin-x64@npm:1.3.93":
57625769
version: 1.3.93
57635770
resolution: "@swc/core-darwin-x64@npm:1.3.93"
57645771
conditions: os=darwin & cpu=x64
57655772
languageName: node
57665773
linkType: hard
57675774

5775+
"@swc/core-darwin-x64@npm:1.7.0":
5776+
version: 1.7.0
5777+
resolution: "@swc/core-darwin-x64@npm:1.7.0"
5778+
conditions: os=darwin & cpu=x64
5779+
languageName: node
5780+
linkType: hard
5781+
57685782
"@swc/core-linux-arm-gnueabihf@npm:1.3.93":
57695783
version: 1.3.93
57705784
resolution: "@swc/core-linux-arm-gnueabihf@npm:1.3.93"
57715785
conditions: os=linux & cpu=arm
57725786
languageName: node
57735787
linkType: hard
57745788

5789+
"@swc/core-linux-arm-gnueabihf@npm:1.7.0":
5790+
version: 1.7.0
5791+
resolution: "@swc/core-linux-arm-gnueabihf@npm:1.7.0"
5792+
conditions: os=linux & cpu=arm
5793+
languageName: node
5794+
linkType: hard
5795+
57755796
"@swc/core-linux-arm64-gnu@npm:1.3.93":
57765797
version: 1.3.93
57775798
resolution: "@swc/core-linux-arm64-gnu@npm:1.3.93"
57785799
conditions: os=linux & cpu=arm64 & libc=glibc
57795800
languageName: node
57805801
linkType: hard
57815802

5803+
"@swc/core-linux-arm64-gnu@npm:1.7.0":
5804+
version: 1.7.0
5805+
resolution: "@swc/core-linux-arm64-gnu@npm:1.7.0"
5806+
conditions: os=linux & cpu=arm64 & libc=glibc
5807+
languageName: node
5808+
linkType: hard
5809+
57825810
"@swc/core-linux-arm64-musl@npm:1.3.93":
57835811
version: 1.3.93
57845812
resolution: "@swc/core-linux-arm64-musl@npm:1.3.93"
57855813
conditions: os=linux & cpu=arm64 & libc=musl
57865814
languageName: node
57875815
linkType: hard
57885816

5817+
"@swc/core-linux-arm64-musl@npm:1.7.0":
5818+
version: 1.7.0
5819+
resolution: "@swc/core-linux-arm64-musl@npm:1.7.0"
5820+
conditions: os=linux & cpu=arm64 & libc=musl
5821+
languageName: node
5822+
linkType: hard
5823+
57895824
"@swc/core-linux-x64-gnu@npm:1.3.93":
57905825
version: 1.3.93
57915826
resolution: "@swc/core-linux-x64-gnu@npm:1.3.93"
57925827
conditions: os=linux & cpu=x64 & libc=glibc
57935828
languageName: node
57945829
linkType: hard
57955830

5831+
"@swc/core-linux-x64-gnu@npm:1.7.0":
5832+
version: 1.7.0
5833+
resolution: "@swc/core-linux-x64-gnu@npm:1.7.0"
5834+
conditions: os=linux & cpu=x64 & libc=glibc
5835+
languageName: node
5836+
linkType: hard
5837+
57965838
"@swc/core-linux-x64-musl@npm:1.3.93":
57975839
version: 1.3.93
57985840
resolution: "@swc/core-linux-x64-musl@npm:1.3.93"
57995841
conditions: os=linux & cpu=x64 & libc=musl
58005842
languageName: node
58015843
linkType: hard
58025844

5845+
"@swc/core-linux-x64-musl@npm:1.7.0":
5846+
version: 1.7.0
5847+
resolution: "@swc/core-linux-x64-musl@npm:1.7.0"
5848+
conditions: os=linux & cpu=x64 & libc=musl
5849+
languageName: node
5850+
linkType: hard
5851+
58035852
"@swc/core-win32-arm64-msvc@npm:1.3.93":
58045853
version: 1.3.93
58055854
resolution: "@swc/core-win32-arm64-msvc@npm:1.3.93"
58065855
conditions: os=win32 & cpu=arm64
58075856
languageName: node
58085857
linkType: hard
58095858

5859+
"@swc/core-win32-arm64-msvc@npm:1.7.0":
5860+
version: 1.7.0
5861+
resolution: "@swc/core-win32-arm64-msvc@npm:1.7.0"
5862+
conditions: os=win32 & cpu=arm64
5863+
languageName: node
5864+
linkType: hard
5865+
58105866
"@swc/core-win32-ia32-msvc@npm:1.3.93":
58115867
version: 1.3.93
58125868
resolution: "@swc/core-win32-ia32-msvc@npm:1.3.93"
58135869
conditions: os=win32 & cpu=ia32
58145870
languageName: node
58155871
linkType: hard
58165872

5873+
"@swc/core-win32-ia32-msvc@npm:1.7.0":
5874+
version: 1.7.0
5875+
resolution: "@swc/core-win32-ia32-msvc@npm:1.7.0"
5876+
conditions: os=win32 & cpu=ia32
5877+
languageName: node
5878+
linkType: hard
5879+
58175880
"@swc/core-win32-x64-msvc@npm:1.3.93":
58185881
version: 1.3.93
58195882
resolution: "@swc/core-win32-x64-msvc@npm:1.3.93"
58205883
conditions: os=win32 & cpu=x64
58215884
languageName: node
58225885
linkType: hard
58235886

5887+
"@swc/core-win32-x64-msvc@npm:1.7.0":
5888+
version: 1.7.0
5889+
resolution: "@swc/core-win32-x64-msvc@npm:1.7.0"
5890+
conditions: os=win32 & cpu=x64
5891+
languageName: node
5892+
linkType: hard
5893+
58245894
"@swc/core@npm:^1.3.10, @swc/core@npm:^1.3.85":
58255895
version: 1.3.93
58265896
resolution: "@swc/core@npm:1.3.93"
@@ -5867,20 +5937,82 @@ __metadata:
58675937
languageName: node
58685938
linkType: hard
58695939

5940+
"@swc/core@npm:^1.7.0":
5941+
version: 1.7.0
5942+
resolution: "@swc/core@npm:1.7.0"
5943+
dependencies:
5944+
"@swc/core-darwin-arm64": 1.7.0
5945+
"@swc/core-darwin-x64": 1.7.0
5946+
"@swc/core-linux-arm-gnueabihf": 1.7.0
5947+
"@swc/core-linux-arm64-gnu": 1.7.0
5948+
"@swc/core-linux-arm64-musl": 1.7.0
5949+
"@swc/core-linux-x64-gnu": 1.7.0
5950+
"@swc/core-linux-x64-musl": 1.7.0
5951+
"@swc/core-win32-arm64-msvc": 1.7.0
5952+
"@swc/core-win32-ia32-msvc": 1.7.0
5953+
"@swc/core-win32-x64-msvc": 1.7.0
5954+
"@swc/counter": ^0.1.3
5955+
"@swc/types": ^0.1.9
5956+
peerDependencies:
5957+
"@swc/helpers": "*"
5958+
dependenciesMeta:
5959+
"@swc/core-darwin-arm64":
5960+
optional: true
5961+
"@swc/core-darwin-x64":
5962+
optional: true
5963+
"@swc/core-linux-arm-gnueabihf":
5964+
optional: true
5965+
"@swc/core-linux-arm64-gnu":
5966+
optional: true
5967+
"@swc/core-linux-arm64-musl":
5968+
optional: true
5969+
"@swc/core-linux-x64-gnu":
5970+
optional: true
5971+
"@swc/core-linux-x64-musl":
5972+
optional: true
5973+
"@swc/core-win32-arm64-msvc":
5974+
optional: true
5975+
"@swc/core-win32-ia32-msvc":
5976+
optional: true
5977+
"@swc/core-win32-x64-msvc":
5978+
optional: true
5979+
peerDependenciesMeta:
5980+
"@swc/helpers":
5981+
optional: true
5982+
checksum: 5ede35e27f1f51a0133722ecf3943c8a3922087b1a53eefc7b9d11ae2a97fcb69821dc2793e57e01d0f5d7d01ce72150a333e5b944c37210b4e3118df6215984
5983+
languageName: node
5984+
linkType: hard
5985+
58705986
"@swc/counter@npm:^0.1.1":
58715987
version: 0.1.2
58725988
resolution: "@swc/counter@npm:0.1.2"
58735989
checksum: 8427c594f1f0cf44b83885e9c8fe1e370c9db44ae96e07a37c117a6260ee97797d0709483efbcc244e77bac578690215f45b23254c4cd8a70fb25ddbb50bf33e
58745990
languageName: node
58755991
linkType: hard
58765992

5993+
"@swc/counter@npm:^0.1.3":
5994+
version: 0.1.3
5995+
resolution: "@swc/counter@npm:0.1.3"
5996+
checksum: df8f9cfba9904d3d60f511664c70d23bb323b3a0803ec9890f60133954173047ba9bdeabce28cd70ba89ccd3fd6c71c7b0bd58be85f611e1ffbe5d5c18616598
5997+
languageName: node
5998+
linkType: hard
5999+
58776000
"@swc/types@npm:^0.1.5":
58786001
version: 0.1.5
58796002
resolution: "@swc/types@npm:0.1.5"
58806003
checksum: 6aee11f62d3d805a64848e0bd5f0e0e615f958e327a9e1260056c368d7d28764d89e38bd8005a536c9bf18afbcd303edd84099d60df34a2975d62540f61df13b
58816004
languageName: node
58826005
linkType: hard
58836006

6007+
"@swc/types@npm:^0.1.9":
6008+
version: 0.1.12
6009+
resolution: "@swc/types@npm:0.1.12"
6010+
dependencies:
6011+
"@swc/counter": ^0.1.3
6012+
checksum: cf7f89e46f859864075d7965582baea9c5f98830f45b1046251568c9bdf1ca484b1bf37f6d3c32b7c82ecf8cd5df89d22f05268c391819c44e49911bb1a8e71a
6013+
languageName: node
6014+
linkType: hard
6015+
58846016
"@szmarczak/http-timer@npm:^1.1.2":
58856017
version: 1.1.2
58866018
resolution: "@szmarczak/http-timer@npm:1.1.2"
@@ -11218,7 +11350,7 @@ __metadata:
1121811350
vite: ^4.5.0
1121911351
vite-plugin-node-polyfills: ^0.21.0
1122011352
vite-plugin-svgr: ^4.1.0
11221-
vite-plugin-top-level-await: ^1.3.1
11353+
vite-plugin-top-level-await: ^1.4.2
1122211354
vite-plugin-wasm: ^3.2.2
1122311355
languageName: unknown
1122411356
linkType: soft
@@ -23532,6 +23664,15 @@ __metadata:
2353223664
languageName: node
2353323665
linkType: hard
2353423666

23667+
"uuid@npm:^10.0.0":
23668+
version: 10.0.0
23669+
resolution: "uuid@npm:10.0.0"
23670+
bin:
23671+
uuid: dist/bin/uuid
23672+
checksum: 4b81611ade2885d2313ddd8dc865d93d8dccc13ddf901745edca8f86d99bc46d7a330d678e7532e7ebf93ce616679fb19b2e3568873ac0c14c999032acb25869
23673+
languageName: node
23674+
linkType: hard
23675+
2353523676
"uuid@npm:^3.0.0, uuid@npm:^3.3.2":
2353623677
version: 3.4.0
2353723678
resolution: "uuid@npm:3.4.0"
@@ -23668,6 +23809,19 @@ __metadata:
2366823809
languageName: node
2366923810
linkType: hard
2367023811

23812+
"vite-plugin-top-level-await@npm:^1.4.2":
23813+
version: 1.4.2
23814+
resolution: "vite-plugin-top-level-await@npm:1.4.2"
23815+
dependencies:
23816+
"@rollup/plugin-virtual": ^3.0.2
23817+
"@swc/core": ^1.7.0
23818+
uuid: ^10.0.0
23819+
peerDependencies:
23820+
vite: ">=2.8"
23821+
checksum: c2174eb63c33ffb26705f629d6f43f02f1d5e224828bc9b83cdb4f400d7bcdc88e8545880822557e7655e3e602b2ec1aac9cbbae86c0afa93850ae72660546c3
23822+
languageName: node
23823+
linkType: hard
23824+
2367123825
"vite-plugin-wasm@npm:^3.2.2":
2367223826
version: 3.2.2
2367323827
resolution: "vite-plugin-wasm@npm:3.2.2"
@@ -23754,7 +23908,7 @@ __metadata:
2375423908
vite: ^4.5.0
2375523909
vite-plugin-node-polyfills: ^0.21.0
2375623910
vite-plugin-svgr: ^4.1.0
23757-
vite-plugin-top-level-await: ^1.3.1
23911+
vite-plugin-top-level-await: ^1.4.2
2375823912
vite-plugin-wasm: ^3.2.2
2375923913
web-vitals: ^2.1.4
2376023914
languageName: unknown
@@ -23862,7 +24016,7 @@ __metadata:
2386224016
vite: ^4.5.0
2386324017
vite-plugin-node-polyfills: ^0.21.0
2386424018
vite-plugin-svgr: ^4.1.0
23865-
vite-plugin-top-level-await: ^1.3.1
24019+
vite-plugin-top-level-await: ^1.4.2
2386624020
vite-plugin-wasm: ^3.2.2
2386724021
languageName: unknown
2386824022
linkType: soft

0 commit comments

Comments
 (0)