From 56cbeaea6324a85b29c28948a3f2a000e4be5e1c Mon Sep 17 00:00:00 2001 From: Chewing Glass Date: Wed, 27 Dec 2023 12:13:26 -0500 Subject: [PATCH] bug(#86): Location asserts sending decimals instead of hex --- package.json | 2 +- src/Onboarding/useOnboarding.tsx | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index b3979e3..3f10e5d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@helium/react-native-sdk", - "version": "3.0.2", + "version": "3.0.3", "description": "Helium React Native SDK", "main": "lib/commonjs/index.js", "module": "lib/module/index.js", diff --git a/src/Onboarding/useOnboarding.tsx b/src/Onboarding/useOnboarding.tsx index 0c0af9b..aefaee1 100644 --- a/src/Onboarding/useOnboarding.tsx +++ b/src/Onboarding/useOnboarding.tsx @@ -238,7 +238,7 @@ const useOnboarding = ({ baseUrl }: { baseUrl: string }) => { let location: string | undefined if (lat && lng && lat !== 0 && lng !== 0) { - location = new BN(getH3Location(lat, lng), 'hex').toString() + location = getH3Location(lat, lng) } const details = await solana.getHotspotDetails({ address: hotspotAddress, @@ -390,12 +390,11 @@ const useOnboarding = ({ baseUrl }: { baseUrl: string }) => { const solResponses = await Promise.all( networkDetails.map(({ elevation, gain, nextLocation, hotspotType }) => { - const location = new BN(nextLocation, 'hex').toString() return onboardingClient.updateMetadata({ type: hotspotType, solanaAddress, hotspotAddress: gateway, - location, + location: nextLocation, elevation, gain, payer, @@ -403,6 +402,15 @@ const useOnboarding = ({ baseUrl }: { baseUrl: string }) => { }) ) + const fails = solResponses.filter((s) => !s.success) + if (fails.length > 0) { + throw new Error( + `Update metadata requests failed: ${fails + .map((f) => f.errorMessage) + .join(', ')}` + ) + } + solanaTransactions = solResponses .flatMap((r) => r.data?.solanaTransactions || []) .map((txn) => Buffer.from(txn))