Skip to content

Commit

Permalink
Merge branch 'main' into feat(frontend)/add-sol-loader-components
Browse files Browse the repository at this point in the history
  • Loading branch information
loki344 authored Jan 7, 2025
2 parents 542e2bd + a3eda58 commit f2adea4
Show file tree
Hide file tree
Showing 37 changed files with 692 additions and 9 deletions.
13 changes: 12 additions & 1 deletion dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,18 @@
"rewards": {
"type": "custom",
"candid": "https://github.com/dfinity/oisy-wallet/releases/download/rc0.0.0/rewards.did",
"wasm": "https://github.com/dfinity/oisy-wallet/releases/download/rc0.0.0/rewards.wasm.gz"
"wasm": "https://github.com/dfinity/oisy-wallet/releases/download/rc0.0.0/rewards.wasm.gz",
"remote": {
"id": {
"ic": "nynz6-haaaa-aaaan-qzqda-cai",
"staging": "vi6cu-aiaaa-aaaad-aad7q-cai",
"test_be_1": "k2sla-fiaaa-aaaag-atvfa-cai",
"test_fe_1": "vi6cu-aiaaa-aaaad-aad7q-cai",
"test_fe_2": "vi6cu-aiaaa-aaaad-aad7q-cai",
"test_fe_3": "vi6cu-aiaaa-aaaad-aad7q-cai",
"test_fe_4": "vi6cu-aiaaa-aaaad-aad7q-cai"
}
}
}
},
"defaults": {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"prettier-plugin-organize-imports": "^4.1.0",
"prettier-plugin-svelte": "^3.3.2",
"prettier-plugin-tailwindcss": "^0.6.9",
"sass": "^1.83.0",
"sass": "^1.83.1",
"svelte": "^4.2.19",
"svelte-check": "^4.1.1",
"tailwindcss": "^3.4.17",
Expand Down
13 changes: 11 additions & 2 deletions scripts/deploy.backend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ II_CANISTER_ID="$(dfx canister id internet_identity --network "${ENV:-local}")"
BACKEND_CANISTER_ID="$(dfx canister id backend --network "${ENV:-local}")"
POUH_ISSUER_CANISTER_ID="$(dfx canister id pouh_issuer --network "${ENV:-local}")"
SIGNER_CANISTER_ID="$(dfx canister id signer --network "${ENV:-local}")"
# Rewards canister is optional for local deployments:
REWARDS_CANISTER_ID="$(dfx canister id rewards --network "${ENV:-local}" || [[ "${ENV:-local}" == "local" ]])"

case $ENV in
"staging")
Expand Down Expand Up @@ -41,6 +43,13 @@ case $ENV in
;;
esac

# If the rewards canister is known, it may perform priviliged actions such as find which users are eligible for rewards.
if [[ "${REWARDS_CANISTER_ID:-}" == "" ]]; then
ALLOWED_CALLERS="vec {}"
else
ALLOWED_CALLERS="vec{ principal \"$REWARDS_CANISTER_ID\" }"
fi

# URL used by II-issuer in the id_alias-verifiable credentials (hard-coded in II)
# Represents more an ID than a URL
II_VC_URL="https://identity.ic0.app"
Expand All @@ -51,7 +60,7 @@ if [ -n "${ENV+1}" ]; then
dfx deploy backend --argument "(variant {
Init = record {
ecdsa_key_name = \"$ECDSA_KEY_NAME\";
allowed_callers = vec {};
allowed_callers = $ALLOWED_CALLERS;
cfs_canister_id = opt principal \"$SIGNER_CANISTER_ID\";
derivation_origin = opt \"$DERIVATION_ORIGIN\";
supported_credentials = opt vec {
Expand All @@ -71,7 +80,7 @@ else
dfx deploy backend --argument "(variant {
Init = record {
ecdsa_key_name = \"$ECDSA_KEY_NAME\";
allowed_callers = vec {};
allowed_callers = $ALLOWED_CALLERS;
cfs_canister_id = opt principal \"$SIGNER_CANISTER_ID\";
derivation_origin = opt \"$DERIVATION_ORIGIN\";
supported_credentials = opt vec {
Expand Down
58 changes: 58 additions & 0 deletions src/frontend/src/lib/api/reward.api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import type {
ClaimVipRewardResponse,
NewVipRewardResponse,
UserData,
VipReward
} from '$declarations/rewards/rewards.did';
import { RewardCanister } from '$lib/canisters/reward.canister';
import { REWARDS_CANISTER_ID } from '$lib/constants/app.constants';
import type { CanisterApiFunctionParams } from '$lib/types/canister';
import { Principal } from '@dfinity/principal';
import { assertNonNullish, isNullish, type QueryParams } from '@dfinity/utils';

let canister: RewardCanister | undefined = undefined;

export const getUserInfo = async ({
identity,
certified
}: CanisterApiFunctionParams<QueryParams>): Promise<UserData> => {
const { getUserInfo } = await rewardCanister({ identity });

return getUserInfo({ certified });
};

export const getNewVipReward = async ({
identity
}: CanisterApiFunctionParams): Promise<NewVipRewardResponse> => {
const { getNewVipReward } = await rewardCanister({ identity });

return getNewVipReward();
};

export const claimVipReward = async ({
vipReward,
identity
}: CanisterApiFunctionParams<{
vipReward: VipReward;
}>): Promise<ClaimVipRewardResponse> => {
const { claimVipReward } = await rewardCanister({ identity });

return claimVipReward(vipReward);
};

const rewardCanister = async ({
identity,
nullishIdentityErrorMessage,
canisterId = REWARDS_CANISTER_ID
}: CanisterApiFunctionParams): Promise<RewardCanister> => {
assertNonNullish(identity, nullishIdentityErrorMessage);

if (isNullish(canister)) {
canister = await RewardCanister.create({
identity,
canisterId: Principal.fromText(canisterId)
});
}

return canister;
};
7 changes: 7 additions & 0 deletions src/frontend/src/lib/assets/failed-reward.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f2adea4

Please sign in to comment.