on master help sign in
Fix incorrect sponsor displayed for L1 ships after escape

- Removed use of 'azimuth.getPoint()' and instead using roller data to fetch additional details regardless of dominion. This is because 'azimuth.getPoint()' will show stale sponsor data for any L1 ship that has been adopted using an L2 transaction.

commitc8cd811ed546742290497d923512b2984ce60324 authorShawn Tobin <shawn.david.tobin@gmail.com> dateWed 6 Sep 2023, 22:09 (3 years ago) parent0d7392b
2 files changed+27−32
src/lib/useRoller.ts+19−22 src/store/lib/useDetailsStore.ts+8−10
src/lib/useRoller.ts+19−22
@@ -139,9 +139,8 @@ export default function useRoller() {
139139 const initPoint = useCallback(
140140 async (point: string | number): Promise<Point> => {
141141 const _wallet = wallet.getOrElse(null);
142− const _contracts = contracts.getOrElse(null);
143142
144− if (!_wallet || !_contracts) {
143+ if (!_wallet) {
145144 return EMPTY_POINT;
146145 }
147146
@@ -152,9 +151,7 @@ export default function useRoller() {
152151 const l2Quota = isL2 ? await api.getRemainingQuota(pointNum) : 0;
153152 const l2Allowance = isL2 ? await api.getAllowance(pointNum) : 0;
154153
155− const details = isL2Spawn(rawDetails?.dominion)
156− ? toL1Details(rawDetails)
157− : await azimuth.azimuth.getPoint(_contracts, point);
154+ const details = toL1Details(rawDetails);
158155
159156 return new Point({
160157 value: pointNum,
@@ -309,14 +306,14 @@ export default function useRoller() {
309306 proxy === 'own'
310307 ? await api.getOwnedPoints(address)
311308 : proxy === 'manage'
312− ? await api.getManagerFor(address)
313− : proxy === 'vote'
314− ? await api.getVotingFor(address)
315− : proxy === 'transfer'
316− ? await api.getTransferringFor(address)
317− : proxy === 'spawn'
318− ? await api.getSpawningFor(address)
319− : [];
309+ ? await api.getManagerFor(address)
310+ : proxy === 'vote'
311+ ? await api.getVotingFor(address)
312+ : proxy === 'transfer'
313+ ? await api.getTransferringFor(address)
314+ : proxy === 'spawn'
315+ ? await api.getSpawningFor(address)
316+ : [];
320317
321318 return points;
322319 },
@@ -365,14 +362,14 @@ export default function useRoller() {
365362 const networkSeed = customNetworkSeed
366363 ? customNetworkSeed
367364 : await attemptNetworkSeedDerivation({
368− urbitWallet,
369− wallet,
370− authMnemonic,
371− details: point,
372− authToken,
373− point: point.value,
374− revision: nextRevision,
375− });
365+ urbitWallet,
366+ wallet,
367+ authMnemonic,
368+ details: point,
369+ authToken,
370+ point: point.value,
371+ revision: nextRevision,
372+ });
376373 const txHash = await submitL2Transaction({
377374 api,
378375 wallet: _wallet,
@@ -422,7 +419,7 @@ export default function useRoller() {
422419 let nonce = await api.getNonce({ ship: point, proxy });
423420 const progress = onUpdate
424421 ? (state: number) => onUpdate({ type: 'progress', state })
425− : () => { };
422+ : () => {};
426423
427424 let requests = [];
428425
src/store/lib/useDetailsStore.ts+8−10
@@ -33,18 +33,10 @@ export default function useDetailsStore() {
3333
3434 const syncDetails = useCallback(
3535 async point => {
36− const _contracts = contracts.getOrElse(null);
37− if (!_contracts) {
38− return;
39− }
40−
4136 // fetch point details
4237 try {
43− const l2Point = await api.getPoint(point);
44− const details =
45− l2Point && (l2Point.dominion === 'l2' || l2Point.dominion === 'spawn')
46− ? toL1Details(l2Point)
47− : await azimuth.azimuth.getPoint(_contracts, point);
38+ const _point = await api.getPoint(point);
39+ const details = toL1Details(_point);
4840 addToDetails({
4941 [point]: details,
5042 });
@@ -53,7 +45,13 @@ export default function useDetailsStore() {
5345 console.warn(error);
5446 }
5547
48+ // Try getting the details from L1
5649 try {
50+ const _contracts = contracts.getOrElse(null);
51+ if (!_contracts) {
52+ return;
53+ }
54+
5755 const details = await azimuth.azimuth.getPoint(_contracts, point);
5856 addToDetails({
5957 [point]: details,