重构(平台入口): 平台侧与 AGC 壳改用三池余额,退役 legacy 总额写入通道
- 平台入口与钱包 store 不再从充值中心响应读 walletBalance,合计改为按三池派生 - AGC 账户钱包同步:只透传 mudPointBalance,删掉 RechargeContent 的 walletBalance 排除项 - 删除已无生产调用方的 applyLegacyWalletBalanceSnapshot 与对应测试;明细读取失败不再伪造「只有总额」的中间态 - 图片编辑器与平台入口测试 fixture 改为三池形状,钱包面板断言改用「永久泥点 / 月度泥点」 Co-authored-by: Junie <junie@jetbrains.com>
This commit is contained in:
@@ -290,28 +290,15 @@ describe('createProfileWalletStore', () => {
|
||||
expect(store.getState().mudPointBalance?.permanentPoints).toBe(90);
|
||||
});
|
||||
|
||||
test('applies an owner-scoped legacy mutation snapshot atomically', () => {
|
||||
test('rejects a snapshot from another owner', () => {
|
||||
const store = createProfileWalletStore({ getRechargeCenter: vi.fn() });
|
||||
store.getState().setWalletOwner('user-a');
|
||||
const structuredSnapshot = store
|
||||
.getState()
|
||||
.captureWalletBalanceSnapshot('user-a');
|
||||
store
|
||||
.getState()
|
||||
.applyWalletBalanceSnapshot(structuredSnapshot!, balance(90));
|
||||
const legacySnapshot = store
|
||||
.getState()
|
||||
.captureWalletBalanceSnapshot('user-a');
|
||||
const snapshot = store.getState().captureWalletBalanceSnapshot('user-b');
|
||||
|
||||
expect(
|
||||
store.getState().applyLegacyWalletBalanceSnapshot(legacySnapshot!, 37),
|
||||
).toBe(true);
|
||||
expect(store.getState()).toMatchObject({
|
||||
legacyWalletBalance: 37,
|
||||
mudPointBalance: null,
|
||||
mudPointBalanceStatus: 'ready',
|
||||
mudPointBalanceError: '',
|
||||
});
|
||||
store.getState().applyWalletBalanceSnapshot(snapshot!, balance(37)),
|
||||
).toBe(false);
|
||||
expect(store.getState().mudPointBalance).toBeNull();
|
||||
});
|
||||
|
||||
test('rejects a snapshot after switching away from and back to the same owner', () => {
|
||||
|
||||
@@ -36,11 +36,7 @@ export type ProfileWalletStore = {
|
||||
) => ProfileWalletBalanceSnapshot | null;
|
||||
applyWalletBalanceSnapshot: (
|
||||
snapshot: ProfileWalletBalanceSnapshot,
|
||||
balance: ProfileMudPointBalance | ProfileMudPointBalanceView,
|
||||
) => boolean;
|
||||
applyLegacyWalletBalanceSnapshot: (
|
||||
snapshot: ProfileWalletBalanceSnapshot,
|
||||
balance: number,
|
||||
balance: ProfileMudPointBalance,
|
||||
) => boolean;
|
||||
onWalletBalanceMayHaveChanged: () => Promise<void>;
|
||||
resetWalletBalance: () => void;
|
||||
@@ -132,32 +128,6 @@ export function createProfileWalletStore(
|
||||
});
|
||||
return true;
|
||||
},
|
||||
applyLegacyWalletBalanceSnapshot: (snapshot, balance) => {
|
||||
if (
|
||||
!Number.isFinite(balance) ||
|
||||
get().ownerUserId !== snapshot.ownerUserId ||
|
||||
ownerVersion !== snapshot.ownerVersion ||
|
||||
snapshot.invalidationVersion < refreshVersion ||
|
||||
snapshot.invalidationVersion < settledRefreshVersion ||
|
||||
snapshot.operationSequence < latestAppliedOperationSequence
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
invalidateActiveRefresh();
|
||||
latestAppliedOperationSequence = Math.max(
|
||||
latestAppliedOperationSequence,
|
||||
snapshot.operationSequence,
|
||||
);
|
||||
settledRefreshVersion = snapshot.invalidationVersion;
|
||||
set({
|
||||
mudPointBalance: null,
|
||||
legacyWalletBalance: balance,
|
||||
mudPointBalanceStatus: 'ready',
|
||||
mudPointBalanceError: '',
|
||||
});
|
||||
return true;
|
||||
},
|
||||
onWalletBalanceMayHaveChanged: () => {
|
||||
refreshVersion += 1;
|
||||
if (activeRefresh) {
|
||||
|
||||
Reference in New Issue
Block a user