From 8f650f54d7714f38224886df7dc3eb769774e3b1 Mon Sep 17 00:00:00 2001 From: Odafe Aror Date: Thu, 7 Mar 2024 04:10:13 +0000 Subject: [PATCH] update --- .gitignore | 1 + contracts/scripts/deploy.ts | 10 +++++++--- contracts/src/chatroom/lib.rs | 12 +++++++++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 657428b..c379766 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,4 @@ coverage.json # VSCode .history/ +contracts/substrate-contracts-node diff --git a/contracts/scripts/deploy.ts b/contracts/scripts/deploy.ts index d503dae..3e2f8ab 100644 --- a/contracts/scripts/deploy.ts +++ b/contracts/scripts/deploy.ts @@ -19,12 +19,16 @@ const main = async () => { const { api, chain, account } = initParams // Deploy greeter contract - const { abi, wasm } = await getDeploymentData('greeter') - const greeter = await deployContract(api, account, abi, wasm, 'default', []) + // const { abi, wasm } = await getDeploymentData('greeter') + // const greeter = await deployContract(api, account, abi, wasm, 'default', []) + + // Deploy greeter contract + const { abi, wasm } = await getDeploymentData('chatroom') + const chatroom = await deployContract(api, account, abi, wasm, 'new', []) // Write contract addresses to `{contract}/{network}.ts` file(s) await writeContractAddresses(chain.network, { - greeter, + chatroom, }) } diff --git a/contracts/src/chatroom/lib.rs b/contracts/src/chatroom/lib.rs index b1871d5..46f59b7 100755 --- a/contracts/src/chatroom/lib.rs +++ b/contracts/src/chatroom/lib.rs @@ -3,6 +3,7 @@ #[ink::contract] mod chatroom { use ink::prelude::string::String; + use ink::prelude::vec::Vec; #[ink(event)] pub struct ChatroomCreated { @@ -24,11 +25,16 @@ mod chatroom { #[ink(constructor)] pub fn new() -> Self { let caller = Self::env().caller(); + let mut members: Vec = Vec::new(); members.push(caller.clone()); + + let mut messages: Vec = Vec::new(); + messages.push(String::from("Welcome to the chatroom")); + Self { - id: "1".to_string(), - messages: vec!["Welcome to the chatroom".to_string()], + id: String::from("1"), + messages: messages, owner: caller, members: members, } @@ -56,7 +62,7 @@ mod chatroom { #[ink::test] fn new_chatroom_works() { let mut chatroom = Chatroom::new(); - assert_eq!(chatroom.getId(), "1".to_string()); + assert_eq!(chatroom.getId(), String::from("1")); } }