Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't build wrappers for aborted SNSes (#5742)
# Motivation We were seeing errors in NNS dapp because it tried to call `get_buyer_state` on the swap canister of an aborted swap while that canister was out of cycles. But we should not be trying to call anything on aborted swaps because we don't care about aborted swaps. Multiple things were happening. 1. We load aggregator data into `snsAggregatorIncludingAbortedProjectsStore`, [here](https://github.com/dfinity/nns-dapp/blob/94df88c1e01a9677ccbd760f6483edde53c6c11f/frontend/src/lib/services/public/sns.services.ts#L51C5-L51C47). From that store, we derive [snsAggregatorStore](https://github.com/dfinity/nns-dapp/blob/94df88c1e01a9677ccbd760f6483edde53c6c11f/frontend/src/lib/stores/sns-aggregator.store.ts#L34), which has aborted SNS filtered out. 2. But on the Launchpad, when we try to load the swap commitments of the user, we don't use the list of SNSes from the aggregator. We call [loadSnsWrappers](https://github.com/dfinity/nns-dapp/blob/94df88c1e01a9677ccbd760f6483edde53c6c11f/frontend/src/lib/api/sns-wrapper.api.ts#L157), which gets the list from SNSes from the SNS-W and then from rootCanisterId, it gets the other canister IDs. This will fail for 8 of the root canisters because they no longer exist. We detect these failures and ignore those SNSes. The successful SNSes are then cached. 3. But when the aggregator data is loaded, we [populate this same cache](https://github.com/dfinity/nns-dapp/blob/94df88c1e01a9677ccbd760f6483edde53c6c11f/frontend/src/lib/services/public/sns.services.ts#L33-L42) with wrappers, without having to get canister IDs from the root canisters, but before filtering out the aborted SNSes. 4. So if after this, we again try to get swap commitments, the aborted SNSes are now included in the wrappers cache and then we try to call `get_buyer_state` on them. In this PR we just skip the aborted SNSes when populating the wrappers cache from aggregator data. This makes the error go away. But ideally we only construct wrappers from aggregator data and stop calling SNS-W and root canisters altogether. That's for future PRs. # Changes 1. Skip aborted SNSes when creating SNS wrappers from aggregator data. # Tests 1. Unit test added. 2. Tested against mainnet before the offending canister was topped up, which also made the error go away. # Todos - [x] Add entry to changelog (if necessary).
- Loading branch information