Skip to content

Commit

Permalink
Merge pull request #358 from helium/fix/onboarding-type
Browse files Browse the repository at this point in the history
Use uppercase string for hotspot type.
  • Loading branch information
matthewcarlreetz authored Mar 6, 2023
2 parents 1b2c616 + 01a049c commit 2ccd673
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 20 deletions.
4 changes: 2 additions & 2 deletions integration_tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
"dependencies": {
"@helium/address": "^4.8.1",
"@helium/crypto": "^4.8.1",
"@helium/http": "^4.9.0",
"@helium/http": "^4.10.0",
"@helium/transactions": "^4.8.1"
},
"version": "4.9.0",
"version": "4.10.0",
"devDependencies": {
"nock": "^13.2.4"
}
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"integration_tests",
"packages/*"
],
"version": "4.9.0",
"version": "4.10.0",
"npmClient": "yarn"
}
2 changes: 1 addition & 1 deletion packages/currency/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@helium/currency",
"version": "4.9.0",
"version": "4.10.0",
"description": "Utilities for handling different currency types on the Helium blockchain",
"keywords": [
"helium",
Expand Down
4 changes: 2 additions & 2 deletions packages/http/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@helium/http",
"version": "4.9.0",
"version": "4.10.0",
"description": "HTTP library for interacting with the Helium blockchain API",
"keywords": [
"helium",
Expand All @@ -27,7 +27,7 @@
},
"dependencies": {
"@helium/address": "^4.8.1",
"@helium/currency": "^4.9.0",
"@helium/currency": "^4.10.0",
"axios": "^0.21.1",
"camelcase-keys": "^6.2.2",
"qs": "^6.9.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/onboarding/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@helium/onboarding",
"version": "4.9.0",
"version": "4.10.0",
"description": "HTTP library for interacting with an onboarding server",
"keywords": [
"helium",
Expand Down
31 changes: 20 additions & 11 deletions packages/onboarding/src/OnboardingClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ export default class OnboardingClient {
url: path,
data: params,
})
if (response.data.errorMessage) {
throw new Error(response.data.errorMessage)
}
if (response.data.success === false) {
throw new Error(`Failed with code ${response.data.code}}`)
}
return response.data
} catch (err) {
if (axios.isAxiosError(err)) {
Expand Down Expand Up @@ -90,20 +96,23 @@ export default class OnboardingClient {
type: HotspotType
} & Partial<Metadata>,
) {
return this.post<{ solanaTransactions: number[][] }>(`transactions/${opts.type}/onboard`, {
entityKey: opts.hotspotAddress,
location: opts.location,
elevation: opts.elevation,
gain: opts.gain,
})
return this.post<{ solanaTransactions: number[][] }>(
`transactions/${opts.type.toLowerCase()}/onboard`,
{
entityKey: opts.hotspotAddress,
location: opts.location,
elevation: opts.elevation,
gain: opts.gain,
},
)
}

async onboardIot(opts: { hotspotAddress: string } & Partial<Metadata>) {
return this.onboard({ ...opts, type: 'iot' })
return this.onboard({ ...opts, type: 'IOT' })
}

async onboardMobile(opts: { hotspotAddress: string } & Partial<Metadata>) {
return this.onboard({ ...opts, type: 'mobile' })
return this.onboard({ ...opts, type: 'MOBILE' })
}

async updateMetadata({
Expand All @@ -126,7 +135,7 @@ export default class OnboardingClient {
wallet: solanaAddress,
}
return this.post<{ solanaTransactions: number[][] }>(
`transactions/${type}/update-metadata`,
`transactions/${type.toLowerCase()}/update-metadata`,
body,
)
}
Expand All @@ -137,7 +146,7 @@ export default class OnboardingClient {
solanaAddress: string
},
) {
return this.updateMetadata({ ...opts, type: 'iot' })
return this.updateMetadata({ ...opts, type: 'IOT' })
}

async updateMobileMetadata(
Expand All @@ -146,6 +155,6 @@ export default class OnboardingClient {
solanaAddress: string
},
) {
return this.updateMetadata({ ...opts, type: 'mobile' })
return this.updateMetadata({ ...opts, type: 'MOBILE' })
}
}
2 changes: 1 addition & 1 deletion packages/onboarding/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ export type Metadata = {
elevation: number
gain: number
}
export type HotspotType = 'iot' | 'mobile'
export type HotspotType = 'IOT' | 'MOBILE'
2 changes: 1 addition & 1 deletion packages/wallet-link/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@helium/wallet-link",
"version": "4.9.0",
"version": "4.10.0",
"description": "Utilities for linking a 3rd party app to the helium wallet.",
"keywords": [
"helium",
Expand Down

0 comments on commit 2ccd673

Please sign in to comment.