Skip to content

confused why compiler doesn't work #485

@mugenosantyago

Description

@mugenosantyago

my contract is this:

contract UserProfile {
let owner: Address
let mut username: ByteVec
let mut bio: ByteVec
let mut profilePicHash: ByteVec
let mut followers: [Address]

// Constructor function
pub fn initialize(ownerAddress: Address) -> () {
    owner = ownerAddress
    username = ByteVec::empty()
    bio = ByteVec::empty()
    profilePicHash = ByteVec::empty()
    followers = [] // Initialize empty followers array
}

// Verify caller is profile owner
fn checkOwner() -> () {
    assert!(callerAddress!() == owner, 0)
}

// Event Definitions
event ProfileUpdated(newBio: ByteVec, newPic: ByteVec)
event NewFollower(follower: Address)

// Update Profile function
pub fn updateProfile(newBio: ByteVec, newPic: ByteVec) -> () {
    checkOwner()
    bio = newBio
    profilePicHash = newPic
    emit ProfileUpdated(newBio, newPic)
}

// Follow function
pub fn follow() -> () {
    let follower = callerAddress!()
    if followers.exists(f => f == follower) {
        // Handle case where follower is already in the list
        emit NewFollower(follower)
    } else {
        followers.push(follower)
        emit NewFollower(follower)
    }
}

// Get Profile function
pub fn getProfile() -> (ByteVec, ByteVec, ByteVec, U256) {
    return (username, bio, profilePicHash, followers.length())
}

}

I get this error every time:

✘ Failed to compile, error: user_profile.ral (1:1): Syntax error
1 |contract UserProfile {
|^^^^^^^^^^

Expected end-of-input
Trace log: Expected multiContract:1:1 / end-of-input:10:1, found "contract U"
otoyume@otoyumes-MacBook-Pro alephi v_4 %

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions