Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
od41 committed Mar 7, 2024
1 parent 5778474 commit 8f650f5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ coverage.json

# VSCode
.history/
contracts/substrate-contracts-node
10 changes: 7 additions & 3 deletions contracts/scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}

Expand Down
12 changes: 9 additions & 3 deletions contracts/src/chatroom/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#[ink::contract]
mod chatroom {
use ink::prelude::string::String;
use ink::prelude::vec::Vec;

#[ink(event)]
pub struct ChatroomCreated {
Expand All @@ -24,11 +25,16 @@ mod chatroom {
#[ink(constructor)]
pub fn new() -> Self {
let caller = Self::env().caller();

let mut members: Vec<AccountId> = Vec::new();
members.push(caller.clone());

let mut messages: Vec<String> = 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,
}
Expand Down Expand Up @@ -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"));
}
}

Expand Down

0 comments on commit 8f650f5

Please sign in to comment.