Skip to content

Commit

Permalink
Merge branch 'NNS1-3348-add-feature-flag' of https://github.com/dfini…
Browse files Browse the repository at this point in the history
…ty/nns-dapp into NNS1-3348-add-feature-flag
  • Loading branch information
coskucinkilic committed Sep 24, 2024
2 parents de49d41 + e9a61ed commit 63cf156
Show file tree
Hide file tree
Showing 13 changed files with 237 additions and 215 deletions.
265 changes: 137 additions & 128 deletions Cargo.lock

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ ic-cdk = "0.16.0"
ic-cdk-macros = "0.16.0"
ic-cdk-timers = "0.10.0"

cycles-minting-canister = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-12_01-30-base" }
dfn_candid = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-12_01-30-base" }
dfn_core = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-12_01-30-base" }
dfn_protobuf = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-12_01-30-base" }
ic-base-types = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-12_01-30-base" }
ic-crypto-sha2 = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-12_01-30-base" }
ic-management-canister-types = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-12_01-30-base" }
ic-ledger-core = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-12_01-30-base" }
ic-nervous-system-common = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-12_01-30-base" }
ic-nervous-system-root = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-12_01-30-base" }
ic-nns-common = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-12_01-30-base" }
ic-nns-constants = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-12_01-30-base" }
ic-nns-governance = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-12_01-30-base" }
ic-protobuf = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-12_01-30-base" }
ic-sns-swap = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-12_01-30-base" }
icp-ledger = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-12_01-30-base" }
on_wire = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-12_01-30-base" }
cycles-minting-canister = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-19_01-31-base" }
dfn_candid = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-19_01-31-base" }
dfn_core = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-19_01-31-base" }
dfn_protobuf = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-19_01-31-base" }
ic-base-types = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-19_01-31-base" }
ic-crypto-sha2 = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-19_01-31-base" }
ic-management-canister-types = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-19_01-31-base" }
ic-ledger-core = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-19_01-31-base" }
ic-nervous-system-common = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-19_01-31-base" }
ic-nervous-system-root = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-19_01-31-base" }
ic-nns-common = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-19_01-31-base" }
ic-nns-constants = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-19_01-31-base" }
ic-nns-governance = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-19_01-31-base" }
ic-protobuf = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-19_01-31-base" }
ic-sns-swap = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-19_01-31-base" }
icp-ledger = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-19_01-31-base" }
on_wire = { git = "https://github.com/dfinity/ic", rev = "release-2024-09-19_01-31-base" }

[profile.release]
lto = false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Candid for canister `nns_governance` obtained by `scripts/update_ic_commit` from: <https://raw.githubusercontent.com/dfinity/ic/release-2024-09-12_01-30-base/rs/nns/governance/canister/governance.did>
//! Candid for canister `nns_governance` obtained by `scripts/update_ic_commit` from: <https://raw.githubusercontent.com/dfinity/ic/release-2024-09-19_01-31-base/rs/nns/governance/canister/governance.did>
type AccountIdentifier = record {
hash : blob;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Candid for canister `nns_registry` obtained by `scripts/update_ic_commit` from: <https://raw.githubusercontent.com/dfinity/ic/release-2024-09-12_01-30-base/rs/registry/canister/canister/registry.did>
//! Candid for canister `nns_registry` obtained by `scripts/update_ic_commit` from: <https://raw.githubusercontent.com/dfinity/ic/release-2024-09-19_01-31-base/rs/registry/canister/canister/registry.did>
// A brief note about the history of this file: This file used to be
// automatically generated, but now, it is hand-crafted, because the
// auto-generator has some some pretty degenerate behaviors. The worst of those
Expand Down
2 changes: 1 addition & 1 deletion declarations/used_by_proposals/sns_wasm/sns_wasm.did
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Candid for canister `sns_wasm` obtained by `scripts/update_ic_commit` from: <https://raw.githubusercontent.com/dfinity/ic/release-2024-09-12_01-30-base/rs/nns/sns-wasm/canister/sns-wasm.did>
//! Candid for canister `sns_wasm` obtained by `scripts/update_ic_commit` from: <https://raw.githubusercontent.com/dfinity/ic/release-2024-09-19_01-31-base/rs/nns/sns-wasm/canister/sns-wasm.did>
type AddWasmRequest = record {
hash : blob;
wasm : opt SnsWasm;
Expand Down
2 changes: 1 addition & 1 deletion dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@
"POCKETIC_VERSION": "3.0.1",
"CARGO_SORT_VERSION": "1.0.9",
"SNSDEMO_RELEASE": "release-2024-09-18",
"IC_COMMIT_FOR_PROPOSALS": "release-2024-09-12_01-30-base",
"IC_COMMIT_FOR_PROPOSALS": "release-2024-09-19_01-31-base",
"IC_COMMIT_FOR_SNS_AGGREGATOR": "release-2024-09-12_01-30-base"
},
"packtool": ""
Expand Down
109 changes: 60 additions & 49 deletions frontend/package-lock.json

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

18 changes: 10 additions & 8 deletions frontend/src/lib/utils/neuron.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,12 @@ export const votingPower = ({
const dissolveDelayMultiplier = bonusMultiplier({
amount: dissolveDelay,
maxBonus: maxDissolveDelayBonus,
maxAmount: maxDissolveDelaySeconds,
amountForMaxBonus: maxDissolveDelaySeconds,
});
const ageMultiplier = bonusMultiplier({
amount: ageSeconds,
maxBonus: maxAgeBonus,
maxAmount: maxAgeSeconds,
amountForMaxBonus: maxAgeSeconds,
});
// We don't use dissolveDelayMultiplier and ageMultiplier directly because those are specific to NNS.
// This function is generic and could be used for SNS.
Expand All @@ -187,37 +187,39 @@ export const dissolveDelayMultiplier = (delayInSeconds: bigint): number =>
bonusMultiplier({
amount: delayInSeconds,
maxBonus: MAX_DISSOLVE_DELAY_BONUS,
maxAmount: SECONDS_IN_EIGHT_YEARS,
amountForMaxBonus: SECONDS_IN_EIGHT_YEARS,
});

export const ageMultiplier = (ageSeconds: bigint): number =>
bonusMultiplier({
amount: ageSeconds,
maxBonus: MAX_AGE_BONUS,
maxAmount: SECONDS_IN_FOUR_YEARS,
amountForMaxBonus: SECONDS_IN_FOUR_YEARS,
});

// Calculates the bonus multiplier for an amount (such as dissolve delay or age)
// which results in bonus eligibility which scales linearly from 1 to
// `maxBonus`. For example for dissolve delay, the values
// amount: 4 years
// maxBonusAmount: 8 years
// amountForMaxBonus: 8 years
// maxBonus: 1
// Would mean that there is a maximum bonus of 1 = 100% (which means a
// multiplier of 2) but with a dissolve delay of 4 years out of a maximum of
// 8 years, the bonus would be 50%, which means a multiplier of 1.5.
// So in this case the return value would be 1.5.
export const bonusMultiplier = ({
amount,
maxAmount,
amountForMaxBonus,
maxBonus,
}: {
amount: bigint;
maxAmount: number;
amountForMaxBonus: number;
maxBonus: number;
}): number => {
const bonusProportion =
maxAmount === 0 ? 0 : Math.min(Number(amount), maxAmount) / maxAmount;
amountForMaxBonus === 0
? 0
: Math.min(Number(amount), amountForMaxBonus) / amountForMaxBonus;
return 1 + maxBonus * bonusProportion;
};

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/lib/utils/sns-neuron.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ export const dissolveDelayMultiplier = ({
return bonusMultiplier({
amount: dissolveDelay,
maxBonus: Number(maxDissolveDelayBonusPercentage) / 100,
maxAmount: Number(maxDissolveDelaySeconds),
amountForMaxBonus: Number(maxDissolveDelaySeconds),
});
};

Expand All @@ -814,7 +814,7 @@ export const ageMultiplier = ({
return bonusMultiplier({
amount: neuronAge(neuron),
maxBonus: Number(maxAgeBonusPercentage) / 100,
maxAmount: Number(maxNeuronAgeForAgeBonus),
amountForMaxBonus: Number(maxNeuronAgeForAgeBonus),
});
};

Expand Down
Loading

0 comments on commit 63cf156

Please sign in to comment.