I have created MessageList.tsx and MessageEdit.tsx, copy and pasted the code from the tutorial, however it shows me errors:
MessageList.tsx:
Property ‘Message’ does not exist on type ‘typeof import(“c:/Users/myuser/myapp/ui/node_modules/@daml.js/myapp/lib/User/index”)’.ts(2339)
Property ‘sender’ does not exist on type ‘{}’.ts(2339)
Property ‘receiver’ does not exist on type ‘{}’.
Property ‘content’ does not exist on type ‘{}’.ts(2339)
MessageEdit.tsx:
Property ‘SendMessage’ does not exist on type ‘Template<User, string, “3e79e02f8c408a0506afcd6348344977294486816a781d905515ecc0c131377b:User:User”> & ToInterface<User, never> & UserInterface’.ts(2339)
User.daml:
-- Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module User where
-- MAIN_TEMPLATE_BEGIN
template User with
username: Party
following: [Party]
where
signatory username
observer following
-- MAIN_TEMPLATE_END
key username: Party
maintainer key
-- FOLLOW_BEGIN
nonconsuming choice Follow: ContractId User with
userToFollow: Party
controller username
do
assertMsg "You cannot follow yourself" (userToFollow /= username)
assertMsg "You cannot follow the same user twice" (notElem userToFollow following)
archive self
create this with following = userToFollow :: following
-- FOLLOW_END
nonconsuming choice SendMessage: ContractId Message with
sender: Party
content: Text
controller sender
do
assertMsg "Designated user must follow you back to send a message" (elem sender following)
create Message with sender, receiver = username, content
-- ALIAS_BEGIN
template Alias with
username: Party
alias: Text
public: Party
where
signatory username
observer public
key (username, public) : (Party, Party)
maintainer key._1
nonconsuming choice Change: ContractId Alias with
newAlias: Text
controller username
do
archive self
create this with alias = newAlias
-- ALIAS_END
--
template Message with
sender: Party
receiver: Party
content: Text
where
signatory sender, receiver
My environment: SDK: 2.4.0 NodeJS version: v14.21.1 Yarn version: v1.22.19 OS: Windows
Could you please help me to fix the issues? Where can I find the complete example? I could not find it on Github. I thought, I could “cheat” with that
Have you re-run the codegen after modifying the User.daml file? If you have daml start running it should watch for file changes and run it automatically, but otherwise you can run it manually with daml codegen js from the project root (the folder that has the daml.yaml file).
daml start does not watch for file changes automatically. You need to press r followed by Return in the terminal you started it for it to pick up the changes you made. Based on the error you get it seems like that’s the missing step.
Do you know, where can I find the source code for the tutorial related to SDK 2.4.0 presented on Getting Started with Daml — Daml SDK 2.4.0 documentation? I did not find it on Github. It would be great to have working solutions, which can be reviewed and tried out.
No success, still the same. I will try to do tomorrow everything from scratch, maybe I missed something.
Do you know, where can I find the source code for the tutorial related to SDK 2.4.0 presented on Getting Started with Daml — Daml SDK 2.4.0 documentation? I did not find it on Github. It would be great to have working solutions, which can be reviewed and tried out. I think it would be beneficial for newbies like me.
I’ve found in some other discuss post that nodeJS 14 or 16 is recommended for DAML.
I’ve installed NPM version to 6.14.17 which is the default version for NodeJS 14.21.1 based on Previous Releases | Node.js. It seems to be fine, however it still does not work:
If I check the source code, I got new errors in MessageEdit.tsx:
JSX element type ‘Form’ does not have any construct or call signatures.ts(2604)
JSX element class does not support attributes because it does not have a ‘props’ property.ts(2607)
‘Button’ cannot be used as a JSX component.
Its instance type ‘Button’ is not a valid JSX element.
Type ‘Button’ is missing the following properties from type ‘ElementClass’: render, context, setState, forceUpdate, and 3 more.ts(2786)
MessageList.tsx:
JSX element type ‘List’ does not have any construct or call signatures.ts(2604)
Could you please tell me the exact version (nodeJS, NPM) you’re using and this example works?