Skip to content

Commit

Permalink
Wire up BotApiGateway in setup scripts (#6828)
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles authored Nov 15, 2024
1 parent 692fa00 commit 6eca4f2
Show file tree
Hide file tree
Showing 17 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions backend/canisters/local_user_index/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

- Top up canisters which have fewer than `MIN_CYCLES_BALANCE` cycles ([#6819](https://github.com/open-chat-labs/open-chat/pull/6819))
- Reduce top up amount to 0.02T ([#6821](https://github.com/open-chat-labs/open-chat/pull/6821))
- Add `BotApiCanister` to the canister state ([#6828](https://github.com/open-chat-labs/open-chat/pull/6828))

## [[2.0.1447](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1447-local_user_index)] - 2024-11-13

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub struct Args {
pub group_index_canister_id: CanisterId,
pub identity_canister_id: CanisterId,
pub notifications_canister_id: CanisterId,
pub bot_api_gateway_canister_id: CanisterId,
pub proposals_bot_canister_id: CanisterId,
pub cycles_dispenser_canister_id: CanisterId,
pub escrow_canister_id: CanisterId,
Expand Down
19 changes: 19 additions & 0 deletions backend/canisters/local_user_index/impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ impl RuntimeState {
group_index: self.data.group_index_canister_id,
identity: self.data.identity_canister_id,
notifications: self.data.notifications_canister_id,
bot_api_gateway: self.data.bot_api_gateway_canister_id,
proposals_bot: self.data.proposals_bot_canister_id,
cycles_dispenser: self.data.cycles_dispenser_canister_id,
escrow: self.data.escrow_canister_id,
Expand Down Expand Up @@ -292,6 +293,8 @@ struct Data {
pub group_index_canister_id: CanisterId,
pub identity_canister_id: CanisterId,
pub notifications_canister_id: CanisterId,
#[serde(default = "bot_api_gateway_canister_id")]
pub bot_api_gateway_canister_id: CanisterId,
pub proposals_bot_canister_id: CanisterId,
pub cycles_dispenser_canister_id: CanisterId,
pub escrow_canister_id: CanisterId,
Expand Down Expand Up @@ -319,6 +322,19 @@ struct Data {
pub cycles_balance_check_queue: VecDeque<UserId>,
}

fn bot_api_gateway_canister_id() -> CanisterId {
let canister_id = ic_cdk::id();
if canister_id == CanisterId::from_text("nq4qv-wqaaa-aaaaf-bhdgq-cai").unwrap() {
CanisterId::from_text("xdh4a-myaaa-aaaaf-bscya-cai").unwrap()
} else if canister_id == CanisterId::from_text("aboy3-giaaa-aaaar-aaaaq-cai").unwrap() {
CanisterId::from_text("lvpeh-caaaa-aaaar-boaha-cai").unwrap()
} else if canister_id == CanisterId::from_text("pecvb-tqaaa-aaaaf-bhdiq-cai").unwrap() {
CanisterId::from_text("xeg2u-baaaa-aaaaf-bscyq-cai").unwrap()
} else {
Principal::anonymous()
}
}

#[derive(Serialize, Deserialize)]
pub struct FailedMessageUsers {
pub sender: UserId,
Expand All @@ -340,6 +356,7 @@ impl Data {
group_index_canister_id: CanisterId,
identity_canister_id: CanisterId,
notifications_canister_id: CanisterId,
bot_api_gateway_canister_id: CanisterId,
proposals_bot_canister_id: CanisterId,
cycles_dispenser_canister_id: CanisterId,
escrow_canister_id: CanisterId,
Expand All @@ -359,6 +376,7 @@ impl Data {
group_index_canister_id,
identity_canister_id,
notifications_canister_id,
bot_api_gateway_canister_id,
proposals_bot_canister_id,
cycles_dispenser_canister_id,
escrow_canister_id,
Expand Down Expand Up @@ -430,6 +448,7 @@ pub struct CanisterIds {
pub group_index: CanisterId,
pub identity: CanisterId,
pub notifications: CanisterId,
pub bot_api_gateway: CanisterId,
pub proposals_bot: CanisterId,
pub cycles_dispenser: CanisterId,
pub escrow: CanisterId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ fn init(args: Args) {
args.group_index_canister_id,
args.identity_canister_id,
args.notifications_canister_id,
args.bot_api_gateway_canister_id,
args.proposals_bot_canister_id,
args.cycles_dispenser_canister_id,
args.escrow_canister_id,
Expand Down
4 changes: 4 additions & 0 deletions backend/canisters/user_index/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [unreleased]

### Changed

- Pass in `BotApiCanister` when installing a new LocalUserIndex ([#6828](https://github.com/open-chat-labs/open-chat/pull/6828))

## [[2.0.1450](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1450-user_index)] - 2024-11-14

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use types::CanisterId;
pub struct Args {
pub canister_id: CanisterId,
pub notifications_canister_id: CanisterId,
pub bot_api_gateway_canister_id: CanisterId,
}

#[derive(CandidType, Serialize, Deserialize, Debug)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ fn prepare(args: &Args, state: &RuntimeState) -> Result<PrepareResult, Response>
group_index_canister_id: state.data.group_index_canister_id,
identity_canister_id: state.data.identity_canister_id,
notifications_canister_id: args.notifications_canister_id,
bot_api_gateway_canister_id: args.bot_api_gateway_canister_id,
proposals_bot_canister_id: state.data.proposals_bot_canister_id,
cycles_dispenser_canister_id: state.data.cycles_dispenser_canister_id,
escrow_canister_id: state.data.escrow_canister_id,
Expand Down
2 changes: 2 additions & 0 deletions backend/integration_tests/src/client/user_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ pub mod happy_path {
user_index_canister_id: CanisterId,
local_user_index_canister_id: CanisterId,
notifications_canister_id: CanisterId,
bot_api_gateway_canister_id: CanisterId,
) {
let response = super::add_local_user_index_canister(
env,
Expand All @@ -215,6 +216,7 @@ pub mod happy_path {
&user_index_canister::add_local_user_index_canister::Args {
canister_id: local_user_index_canister_id,
notifications_canister_id,
bot_api_gateway_canister_id,
},
);

Expand Down
2 changes: 2 additions & 0 deletions backend/integration_tests/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ fn install_canisters(env: &mut PocketIc, controller: Principal) -> CanisterIds {
let local_user_index_canister_id = create_canister(env, user_index_canister_id);
let local_group_index_canister_id = create_canister(env, group_index_canister_id);
let notifications_canister_id = create_canister(env, notifications_index_canister_id);
let bot_api_gateway_canister_id = create_canister(env, user_index_canister_id);

let community_canister_wasm = wasms::COMMUNITY.clone();
let cycles_dispenser_canister_wasm = wasms::CYCLES_DISPENSER.clone();
Expand Down Expand Up @@ -410,6 +411,7 @@ fn install_canisters(env: &mut PocketIc, controller: Principal) -> CanisterIds {
user_index_canister_id,
local_user_index_canister_id,
notifications_canister_id,
bot_api_gateway_canister_id,
);

client::group_index::happy_path::upgrade_group_canister_wasm(env, controller, group_index_canister_id, group_canister_wasm);
Expand Down
1 change: 1 addition & 0 deletions backend/libraries/canister_agent_utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ pub struct CanisterIds {
pub local_user_index: CanisterId,
pub local_group_index: CanisterId,
pub notifications: CanisterId,
pub bot_api_gateway: CanisterId,
pub identity: CanisterId,
pub online_users: CanisterId,
pub proposals_bot: CanisterId,
Expand Down
1 change: 1 addition & 0 deletions backend/tools/canister_installer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ async fn install_service_canisters_impl(
&user_index_canister::add_local_user_index_canister::Args {
canister_id: canister_ids.local_user_index,
notifications_canister_id: canister_ids.notifications,
bot_api_gateway_canister_id: canister_ids.bot_api_gateway,
},
)
.await
Expand Down
4 changes: 4 additions & 0 deletions backend/tools/canister_installer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ async fn main() {
local_user_index: opts.local_user_index,
local_group_index: opts.local_group_index,
notifications: opts.notifications,
bot_api_gateway: opts.bot_api_gateway,
identity: opts.identity,
online_users: opts.online_users,
proposals_bot: opts.proposals_bot,
Expand Down Expand Up @@ -73,6 +74,9 @@ struct Opts {
#[arg(long)]
notifications: CanisterId,

#[arg(long)]
bot_api_gateway: CanisterId,

#[arg(long)]
identity: CanisterId,

Expand Down
1 change: 1 addition & 0 deletions scripts/deploy-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ dfx --identity $IDENTITY canister create --no-wallet --with-cycles 1000000000000
dfx --identity $IDENTITY canister create --no-wallet --with-cycles 100000000000000 local_user_index
dfx --identity $IDENTITY canister create --no-wallet --with-cycles 100000000000000 local_group_index
dfx --identity $IDENTITY canister create --no-wallet --with-cycles 100000000000000 notifications
dfx --identity $IDENTITY canister create --no-wallet --with-cycles 100000000000000 bot_api_gateway
dfx --identity $IDENTITY canister create --no-wallet --with-cycles 100000000000000 identity
dfx --identity $IDENTITY canister create --no-wallet --with-cycles 100000000000000 online_users
dfx --identity $IDENTITY canister create --no-wallet --with-cycles 100000000000000 proposals_bot
Expand Down
1 change: 1 addition & 0 deletions scripts/deploy-testnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dfx --identity $IDENTITY canister create --provisional-create-canister-effective
dfx --identity $IDENTITY canister create --provisional-create-canister-effective-canister-id jrlun-jiaaa-aaaab-aaaaa-cai --network $NETWORK --no-wallet --with-cycles 100000000000000 local_user_index
dfx --identity $IDENTITY canister create --provisional-create-canister-effective-canister-id jrlun-jiaaa-aaaab-aaaaa-cai --network $NETWORK --no-wallet --with-cycles 100000000000000 local_group_index
dfx --identity $IDENTITY canister create --provisional-create-canister-effective-canister-id jrlun-jiaaa-aaaab-aaaaa-cai --network $NETWORK --no-wallet --with-cycles 100000000000000 notifications
dfx --identity $IDENTITY canister create --provisional-create-canister-effective-canister-id jrlun-jiaaa-aaaab-aaaaa-cai --network $NETWORK --no-wallet --with-cycles 100000000000000 bot_api_gateway
dfx --identity $IDENTITY canister create --provisional-create-canister-effective-canister-id jrlun-jiaaa-aaaab-aaaaa-cai --network $NETWORK --no-wallet --with-cycles 100000000000000 identity
dfx --identity $IDENTITY canister create --provisional-create-canister-effective-canister-id jrlun-jiaaa-aaaab-aaaaa-cai --network $NETWORK --no-wallet --with-cycles 100000000000000 online_users
dfx --identity $IDENTITY canister create --provisional-create-canister-effective-canister-id jrlun-jiaaa-aaaab-aaaaa-cai --network $NETWORK --no-wallet --with-cycles 100000000000000 airdrop_bot
Expand Down
2 changes: 2 additions & 0 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ NOTIFICATIONS_INDEX_CANISTER_ID=$(dfx canister --network $NETWORK id notificatio
LOCAL_USER_INDEX_CANISTER_ID=$(dfx canister --network $NETWORK id local_user_index)
LOCAL_GROUP_INDEX_CANISTER_ID=$(dfx canister --network $NETWORK id local_group_index)
NOTIFICATIONS_CANISTER_ID=$(dfx canister --network $NETWORK id notifications)
BOT_API_GATEWAY_CANISTER_ID=$(dfx canister --network $NETWORK id bot_api_gateway)
IDENTITY_CANISTER_ID=$(dfx canister --network $NETWORK id identity)
ONLINE_USERS_CANISTER_ID=$(dfx canister --network $NETWORK id online_users)
PROPOSALS_BOT_CANISTER_ID=$(dfx canister --network $NETWORK id proposals_bot)
Expand Down Expand Up @@ -67,6 +68,7 @@ cargo run \
--local-user-index $LOCAL_USER_INDEX_CANISTER_ID \
--local-group-index $LOCAL_GROUP_INDEX_CANISTER_ID \
--notifications $NOTIFICATIONS_CANISTER_ID \
--bot-api-gateway $BOT_API_GATEWAY_CANISTER_ID \
--identity $IDENTITY_CANISTER_ID \
--online-users $ONLINE_USERS_CANISTER_ID \
--proposals-bot $PROPOSALS_BOT_CANISTER_ID \
Expand Down
1 change: 1 addition & 0 deletions scripts/download-all-canister-wasms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ fi
echo "Downloading wasms"

./download-canister-wasm.sh airdrop_bot $WASM_SRC || exit 1
./download-canister-wasm.sh bot_api_gateway $WASM_SRC || exit 1
./download-canister-wasm.sh community $WASM_SRC || exit 1
./download-canister-wasm.sh cycles_dispenser $WASM_SRC || exit 1
./download-canister-wasm.sh escrow $WASM_SRC || exit 1
Expand Down
3 changes: 3 additions & 0 deletions scripts/generate-all-canister-wasms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ done

cargo build --locked --target wasm32-unknown-unknown --release \
--package airdrop_bot_canister_impl \
--package bot_api_gateway_canister_impl \
--package community_canister_impl \
--package cycles_dispenser_canister_impl \
--package escrow_canister_impl \
Expand Down Expand Up @@ -53,6 +54,7 @@ then
fi

ic-wasm ./target/wasm32-unknown-unknown/release/airdrop_bot_canister_impl.wasm -o ./target/wasm32-unknown-unknown/release/airdrop_bot_canister_impl-opt.wasm shrink
ic-wasm ./target/wasm32-unknown-unknown/release/bot_api_gateway_canister_impl.wasm -o ./target/wasm32-unknown-unknown/release/bot_api_gateway_canister_impl-opt.wasm shrink
ic-wasm ./target/wasm32-unknown-unknown/release/community_canister_impl.wasm -o ./target/wasm32-unknown-unknown/release/community_canister_impl-opt.wasm shrink
ic-wasm ./target/wasm32-unknown-unknown/release/cycles_dispenser_canister_impl.wasm -o ./target/wasm32-unknown-unknown/release/cycles_dispenser_canister_impl-opt.wasm shrink
ic-wasm ./target/wasm32-unknown-unknown/release/escrow_canister_impl.wasm -o ./target/wasm32-unknown-unknown/release/escrow_canister_impl-opt.wasm shrink
Expand All @@ -79,6 +81,7 @@ ic-wasm ./target/wasm32-unknown-unknown/release/user_index_canister_impl.wasm -o
echo Compressing wasms
mkdir -p wasms
gzip -fckn9 target/wasm32-unknown-unknown/release/airdrop_bot_canister_impl-opt.wasm > ./wasms/airdrop_bot.wasm.gz
gzip -fckn9 target/wasm32-unknown-unknown/release/bot_api_gateway_canister_impl-opt.wasm > ./wasms/bot_api_gateway.wasm.gz
gzip -fckn9 target/wasm32-unknown-unknown/release/community_canister_impl-opt.wasm > ./wasms/community.wasm.gz
gzip -fckn9 target/wasm32-unknown-unknown/release/cycles_dispenser_canister_impl-opt.wasm > ./wasms/cycles_dispenser.wasm.gz
gzip -fckn9 target/wasm32-unknown-unknown/release/escrow_canister_impl-opt.wasm > ./wasms/escrow.wasm.gz
Expand Down

0 comments on commit 6eca4f2

Please sign in to comment.