Skip to content

Commit 4f4c307

Browse files
committed
corrected minor bug
1 parent 9121584 commit 4f4c307

File tree

6 files changed

+48
-129
lines changed

6 files changed

+48
-129
lines changed

apps/box/android/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ android {
8282
applicationId "land.fx.blox"
8383
minSdkVersion rootProject.ext.minSdkVersion
8484
targetSdkVersion rootProject.ext.targetSdkVersion
85-
versionCode 246
86-
versionName "2.2.1"
85+
versionCode 247
86+
versionName "2.2.2"
8787
// buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
8888

8989
testBuildType System.getProperty('testBuildType', 'debug')

apps/box/ios/Box.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@
665665
"$(inherited)",
666666
"@executable_path/Frameworks",
667667
);
668-
MARKETING_VERSION = 2.2.1;
668+
MARKETING_VERSION = 2.2.2;
669669
OTHER_LDFLAGS = (
670670
"$(inherited)",
671671
"-ObjC",
@@ -702,7 +702,7 @@
702702
"$(inherited)",
703703
"@executable_path/Frameworks",
704704
);
705-
MARKETING_VERSION = 2.2.1;
705+
MARKETING_VERSION = 2.2.2;
706706
OTHER_LDFLAGS = (
707707
"$(inherited)",
708708
"-ObjC",

apps/box/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "box",
3-
"version": "2.2.1",
3+
"version": "2.2.2",
44
"private": true,
55
"dependencies": {
66
"@functionland/fula-sec": "*",

apps/box/src/hooks/usePoolsWithFallback.ts

Lines changed: 41 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -57,28 +57,23 @@ export const usePoolsWithFallback = () => {
5757
userActiveRequests: [],
5858
});
5959

60-
// Determine which account to use and which service to use
60+
// Determine which account to use - always use RPC service for read operations
6161
const effectiveAccount = metamaskAccount || manualSignatureWalletAddress;
62-
// Use read-only service when MetaMask account is not available but manual signature wallet is
63-
const useReadOnlyService = !metamaskAccount && !!manualSignatureWalletAddress;
6462

6563
console.log('usePoolsWithFallback state:', {
6664
hasHydrated,
6765
metamaskAccount,
6866
manualSignatureWalletAddress,
6967
connected,
7068
effectiveAccount,
71-
useReadOnlyService,
7269
});
7370

7471
/**
75-
* Check user membership using either contractService or poolReadService
72+
* Check user membership using direct RPC calls via poolReadService
7673
*/
7774
const checkUserMembership = useCallback(async () => {
7875
console.log('checkUserMembership', {
79-
useReadOnlyService,
8076
effectiveAccount,
81-
contractService: !!contractService,
8277
});
8378

8479
if (!effectiveAccount) {
@@ -90,37 +85,17 @@ export const usePoolsWithFallback = () => {
9085
}
9186

9287
try {
93-
if (useReadOnlyService) {
94-
// Use read-only service when MetaMask is not connected
95-
const poolReadService = getPoolReadService(selectedChain);
96-
const userPoolInfo = await poolReadService.getUserPoolInfo(
97-
effectiveAccount,
98-
currentBloxPeerId
99-
);
100-
101-
return {
102-
isMemberOfAnyPool: userPoolInfo.poolId !== '0' && userPoolInfo.poolId !== '',
103-
memberPools: userPoolInfo.poolId !== '0' && userPoolInfo.poolId !== '' ? [userPoolInfo.poolId] : [],
104-
activeRequests: userPoolInfo.requestPoolId !== '0' && userPoolInfo.requestPoolId !== '' ? [userPoolInfo.requestPoolId] : [],
105-
};
106-
} else if (isReady && contractService && connected) {
107-
// Use contract service when MetaMask is connected
108-
const { poolId, requestPoolId } = await contractService.getUserPool(
109-
effectiveAccount,
110-
currentBloxPeerId
111-
);
112-
113-
return {
114-
isMemberOfAnyPool: poolId !== '0' && poolId !== '',
115-
memberPools: poolId !== '0' && poolId !== '' ? [poolId] : [],
116-
activeRequests: requestPoolId !== '0' && requestPoolId !== '' ? [requestPoolId] : [],
117-
};
118-
}
88+
// Always use read-only service for reliable direct RPC calls
89+
const poolReadService = getPoolReadService(selectedChain);
90+
const userPoolInfo = await poolReadService.getUserPoolInfo(
91+
effectiveAccount,
92+
currentBloxPeerId
93+
);
11994

12095
return {
121-
isMemberOfAnyPool: false,
122-
memberPools: [],
123-
activeRequests: [],
96+
isMemberOfAnyPool: userPoolInfo.poolId !== '0' && userPoolInfo.poolId !== '',
97+
memberPools: userPoolInfo.poolId !== '0' && userPoolInfo.poolId !== '' ? [userPoolInfo.poolId] : [],
98+
activeRequests: userPoolInfo.requestPoolId !== '0' && userPoolInfo.requestPoolId !== '' ? [userPoolInfo.requestPoolId] : [],
12499
};
125100
} catch (error) {
126101
console.error('Error checking user membership:', error);
@@ -130,43 +105,25 @@ export const usePoolsWithFallback = () => {
130105
activeRequests: [],
131106
};
132107
}
133-
}, [useReadOnlyService, effectiveAccount, contractService, isReady, connected, selectedChain, currentBloxPeerId]);
108+
}, [effectiveAccount, selectedChain, currentBloxPeerId]);
134109

135110
/**
136-
* Load pools using either contractService or poolReadService
111+
* Load pools using direct RPC calls via poolReadService
137112
*/
138113
const loadPools = useCallback(async () => {
139114
console.log('loadPools called', {
140-
useReadOnlyService,
141115
effectiveAccount,
142-
isReady,
143-
contractService: !!contractService,
144-
isOnCorrectNetwork,
145116
});
146117

147-
// If using read-only service, we don't need to check network or contract readiness
148-
if (!useReadOnlyService) {
149-
// For MetaMask-connected flow, require all prerequisites
150-
if (!isReady || !contractService || !effectiveAccount || !isOnCorrectNetwork) {
151-
console.log('loadPools: Prerequisites not met for contract service');
152-
setState((prev) => ({
153-
...prev,
154-
enableInteraction: false,
155-
loading: false,
156-
}));
157-
return;
158-
}
159-
} else {
160-
// For read-only service, only need effective account
161-
if (!effectiveAccount) {
162-
console.log('loadPools: No effective account available');
163-
setState((prev) => ({
164-
...prev,
165-
enableInteraction: false,
166-
loading: false,
167-
}));
168-
return;
169-
}
118+
// For read-only RPC service, only need effective account
119+
if (!effectiveAccount) {
120+
console.log('loadPools: No effective account available');
121+
setState((prev) => ({
122+
...prev,
123+
enableInteraction: false,
124+
loading: false,
125+
}));
126+
return;
170127
}
171128

172129
setState((prev) => ({ ...prev, loading: true, error: null }));
@@ -175,18 +132,10 @@ export const usePoolsWithFallback = () => {
175132
console.log('🔍 loadPools: Starting...');
176133
console.log('🔍 effectiveAccount:', effectiveAccount);
177134
console.log('🔍 currentBloxPeerId:', currentBloxPeerId);
178-
console.log('🔍 useReadOnlyService:', useReadOnlyService);
179-
180-
let poolList: PoolInfo[];
181135

182-
if (useReadOnlyService) {
183-
// Use read-only service
184-
const poolReadService = getPoolReadService(selectedChain);
185-
poolList = await poolReadService.listPools(0, 25);
186-
} else {
187-
// Use contract service
188-
poolList = await contractService!.listPools(0, 25);
189-
}
136+
// Always use read-only service for reliable direct RPC calls
137+
const poolReadService = getPoolReadService(selectedChain);
138+
const poolList: PoolInfo[] = await poolReadService.listPools(0, 25);
190139

191140
console.log('🔍 Pools received:', poolList?.length);
192141

@@ -213,18 +162,12 @@ export const usePoolsWithFallback = () => {
213162

214163
try {
215164
console.log('🔍 Getting user pool info...');
216-
if (useReadOnlyService) {
217-
const poolReadService = getPoolReadService(selectedChain);
218-
userPool = await poolReadService.getUserPoolInfo(
219-
effectiveAccount,
220-
currentBloxPeerId
221-
);
222-
} else {
223-
userPool = await contractService!.getUserPool(
224-
effectiveAccount,
225-
currentBloxPeerId
226-
);
227-
}
165+
// Always use read-only service for reliable direct RPC calls
166+
const poolReadService = getPoolReadService(selectedChain);
167+
userPool = await poolReadService.getUserPoolInfo(
168+
effectiveAccount,
169+
currentBloxPeerId
170+
);
228171

229172
console.log('🔍 User pool result:', userPool);
230173

@@ -235,19 +178,12 @@ export const usePoolsWithFallback = () => {
235178
} else if (userPool && userPool.requestPoolId !== '0') {
236179
poolIdOfInterest = userPool.requestPoolId;
237180
try {
238-
let joinRequestInfo;
239-
if (useReadOnlyService) {
240-
const poolReadService = getPoolReadService(selectedChain);
241-
joinRequestInfo = await poolReadService.getJoinRequest(
242-
userPool.requestPoolId,
243-
effectiveAccount
244-
);
245-
} else {
246-
joinRequestInfo = await contractService!.getJoinRequest(
247-
userPool.requestPoolId,
248-
effectiveAccount
249-
);
250-
}
181+
// Always use read-only service for reliable direct RPC calls
182+
const poolReadService = getPoolReadService(selectedChain);
183+
const joinRequestInfo = await poolReadService.getJoinRequest(
184+
userPool.requestPoolId,
185+
effectiveAccount
186+
);
251187
console.log('Join request info:', joinRequestInfo);
252188
numVotes = joinRequestInfo.positive_votes + joinRequestInfo.negative_votes;
253189
requested = true;
@@ -314,7 +250,7 @@ export const usePoolsWithFallback = () => {
314250
enableInteraction: false,
315251
}));
316252
}
317-
}, [useReadOnlyService, effectiveAccount, isReady, contractService, isOnCorrectNetwork, selectedChain, currentBloxPeerId, checkUserMembership]);
253+
}, [effectiveAccount, selectedChain, currentBloxPeerId, checkUserMembership]);
318254

319255
/**
320256
* Join pool via API - works with both MetaMask and manual signature
@@ -460,29 +396,12 @@ export const usePoolsWithFallback = () => {
460396
[effectiveAccount, currentBloxPeerId, selectedChain, loadPools]
461397
);
462398

463-
// Load pools when conditions are met
464-
useEffect(() => {
465-
if (useReadOnlyService) {
466-
// For read-only service, load when we have effective account
467-
if (effectiveAccount) {
468-
loadPools();
469-
}
470-
} else {
471-
// For contract service, load when contract is ready and on correct network
472-
if (isReady && isOnCorrectNetwork) {
473-
loadPools();
474-
}
475-
}
476-
}, [useReadOnlyService, effectiveAccount, isReady, isOnCorrectNetwork, loadPools]);
477-
478-
// Refresh pools when account changes
399+
// Load pools when we have an effective account
479400
useEffect(() => {
480401
if (effectiveAccount) {
481-
if (useReadOnlyService || (isReady && isOnCorrectNetwork)) {
482-
loadPools();
483-
}
402+
loadPools();
484403
}
485-
}, [effectiveAccount, useReadOnlyService, isReady, isOnCorrectNetwork, loadPools]);
404+
}, [effectiveAccount, loadPools]);
486405

487406
return {
488407
...state,

apps/box/src/i18n/locales/en/translation.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"reconnectExisting": "Reconnect to existing blox",
3434
"bluetoothCommands": "Bluetooth commands",
3535
"skipManualSetup": "Skip to manual setup",
36-
"existingIdentity": "Existing Identity Found",
36+
"existingIdentity": "Generated Identity",
3737
"continueWithExisting": "Continue",
3838
"clearCachedData": "Reset Identity",
3939
"cachedDataCleared": "Identity has been reset successfully"

apps/box/src/i18n/locales/zh/translation.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"reconnectExisting": "重新连接到现有 blox",
3434
"bluetoothCommands": "蓝牙命令",
3535
"skipManualSetup": "跳到手动设置",
36-
"existingIdentity": "发现现有身份",
36+
"existingIdentity": "生成的身份",
3737
"continueWithExisting": "继续",
3838
"clearCachedData": "重置身份",
3939
"cachedDataCleared": "身份已成功重置"

0 commit comments

Comments
 (0)