Skip to content

Commit

Permalink
Feature/mobile wifi onboarding (#363)
Browse files Browse the repository at this point in the history
Add support for wifi hotspot onboarding
  • Loading branch information
matthewcarlreetz authored Dec 19, 2023
1 parent 43bc934 commit c592dbc
Show file tree
Hide file tree
Showing 49 changed files with 5,660 additions and 939 deletions.
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.10.2",
"version": "4.11.0",
"npmClient": "yarn"
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
},
"devDependencies": {
"@types/jest": "^28.1.6",
"@types/node": "^20.5.9",
"@typescript-eslint/eslint-plugin": "4.7.0",
"coveralls": "^3.1.1",
"eslint-config-airbnb-typescript": "^17.0.0",
Expand All @@ -43,6 +44,6 @@
"standard": "^17.0.0",
"ts-jest": "^28.0.7",
"typedoc": "~0.22.0",
"typescript": "4.1.2"
"typescript": "^5.2.2"
}
}
2 changes: 1 addition & 1 deletion packages/address/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@helium/address",
"version": "4.10.2",
"version": "4.11.0",
"description": "Helium public key utilities",
"keywords": [
"helium",
Expand Down
4 changes: 2 additions & 2 deletions packages/crypto-react-native/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@helium/crypto-react-native",
"version": "4.10.2",
"version": "4.11.0",
"description": "Cryptography utilities including mnemonics, keypairs and base58-check encoding for React Native",
"keywords": [
"helium",
Expand All @@ -27,7 +27,7 @@
"build": "yarn run clean && tsc"
},
"dependencies": {
"@helium/address": "^4.10.2",
"@helium/address": "^4.11.0",
"js-sha256": "^0.9.0",
"react-native-sodium": "^0.4.0",
"safe-buffer": "^5.2.1"
Expand Down
4 changes: 2 additions & 2 deletions packages/crypto/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@helium/crypto",
"version": "4.10.2",
"version": "4.11.0",
"description": "Cryptography utilities including mnemonics, keypairs and base58-check encoding",
"keywords": [
"helium",
Expand All @@ -26,7 +26,7 @@
"build": "yarn run clean && tsc"
},
"dependencies": {
"@helium/address": "^4.10.2",
"@helium/address": "^4.11.0",
"create-hash": "^1.2.0",
"libsodium-wrappers": "^0.7.6"
},
Expand Down
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.10.2",
"version": "4.11.0",
"description": "Utilities for handling different currency types on the Helium blockchain",
"keywords": [
"helium",
Expand Down
8 changes: 4 additions & 4 deletions packages/http/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@helium/http",
"version": "4.10.2",
"version": "4.11.0",
"description": "HTTP library for interacting with the Helium blockchain API",
"keywords": [
"helium",
Expand All @@ -26,13 +26,13 @@
"build": "yarn run clean && tsc"
},
"dependencies": {
"@helium/address": "^4.10.2",
"@helium/currency": "^4.10.2",
"@helium/address": "^4.11.0",
"@helium/currency": "^4.11.0",
"axios": "^0.21.1",
"camelcase-keys": "^6.2.2",
"qs": "^6.9.3",
"retry-axios": "^2.1.2",
"snakecase-keys": "^5.1.0"
"snakecase-keys": "^5.4.6"
},
"devDependencies": {
"@types/qs": "6.9.5",
Expand Down
6 changes: 3 additions & 3 deletions packages/http/src/models/Account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,8 @@ export default class Account extends DataModel {
super()
this.client = client
this.netType = Address.fromB58(account.address).netType
const currencyType = this.netType === NetTypes.TESTNET
? CurrencyType.testNetworkToken
: CurrencyType.default
const currencyType =
this.netType === NetTypes.TESTNET ? CurrencyType.testNetworkToken : CurrencyType.default
this.speculativeNonce = account.speculative_nonce
this.stakedBalance = toBalance(account.staked_balance, currencyType)
this.secNonce = account.sec_nonce
Expand Down Expand Up @@ -176,6 +175,7 @@ export default class Account extends DataModel {
get data(): AccountData {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { client, ...rest } = this
// @ts-ignore
return { ...rest }
}
}
1 change: 1 addition & 0 deletions packages/http/src/models/Block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default class Block extends DataModel {
get data(): BlockData {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { client, ...rest } = this
// @ts-ignore
return { ...rest }
}
}
1 change: 1 addition & 0 deletions packages/http/src/models/City.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export default class City extends DataModel {
get data(): CityData {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { client, ...rest } = this
// @ts-ignore
return { ...rest }
}
}
1 change: 1 addition & 0 deletions packages/http/src/models/Hotspot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ export default class Hotspot extends DataModel {
get data(): HotspotData {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { client, ...rest } = this
// @ts-ignore
return { ...rest }
}
}
1 change: 1 addition & 0 deletions packages/http/src/models/Location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default class Location extends DataModel {
get data(): LocationData {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { client, ...rest } = this
// @ts-ignore
return { ...rest }
}
}
1 change: 1 addition & 0 deletions packages/http/src/models/OraclePrice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default class OraclePrice extends DataModel {
get data(): OraclePriceData {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { client, ...rest } = this
// @ts-ignore
return { ...rest }
}
}
1 change: 1 addition & 0 deletions packages/http/src/models/OraclePricePrediction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default class OraclePricePrediction extends DataModel {
get data(): OraclePriceData {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { client, ...rest } = this
// @ts-ignore
return { ...rest }
}
}
1 change: 1 addition & 0 deletions packages/http/src/models/Reward.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default class Reward extends DataModel {
get data(): RewardData {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { client, ...rest } = this
// @ts-ignore
return { ...rest }
}
}
1 change: 1 addition & 0 deletions packages/http/src/models/Sum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export default class Sum extends DataModel {
get data(): SumData {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { client, ...rest } = this
// @ts-ignore
return { ...rest }
}
}
1 change: 1 addition & 0 deletions packages/http/src/models/Validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export default class Validator extends DataModel {
get data(): ValidatorData {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { client, ...rest } = this
// @ts-ignore
return { ...rest }
}
}
1 change: 1 addition & 0 deletions packages/http/src/models/Witness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export default class Witness extends DataModel {
get data(): WitnessData {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { client, ...rest } = this
// @ts-ignore
return { ...rest }
}
}
68 changes: 32 additions & 36 deletions packages/http/src/resources/__tests__/Accounts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,15 @@ describe('list', () => {
nock('https://api.helium.io')
.get('/v1/accounts')
.reply(200, {
data: [
accountFixture({ address: 'address-1' }),
accountFixture({ address: 'address-2' }),
],
data: [accountFixture({ address: 'address-1' }), accountFixture({ address: 'address-2' })],
cursor: 'cursor-1',
})

nock('https://api.helium.io')
.get('/v1/accounts')
.query({ cursor: 'cursor-1' })
.reply(200, {
data: [
accountFixture({ address: 'address-3' }),
accountFixture({ address: 'address-4' }),
],
data: [accountFixture({ address: 'address-3' }), accountFixture({ address: 'address-4' })],
})

it('lists a page of accounts and exposes pagination functions', async () => {
Expand All @@ -120,21 +114,15 @@ describe('list', () => {
nock('https://api.helium.io')
.get('/v1/accounts')
.reply(200, {
data: [
accountFixture({ address: 'address-1' }),
accountFixture({ address: 'address-2' }),
],
data: [accountFixture({ address: 'address-1' }), accountFixture({ address: 'address-2' })],
cursor: 'cursor-1',
})

nock('https://api.helium.io')
.get('/v1/accounts')
.query({ cursor: 'cursor-1' })
.reply(200, {
data: [
accountFixture({ address: 'address-3' }),
accountFixture({ address: 'address-4' }),
],
data: [accountFixture({ address: 'address-3' }), accountFixture({ address: 'address-4' })],
})

it('lists accounts as an auto-paginating iterator', async () => {
Expand All @@ -147,12 +135,7 @@ describe('list', () => {
for await (const account of accounts) {
addresses.push(account.address)
}
expect(addresses).toEqual([
'address-1',
'address-2',
'address-3',
'address-4',
])
expect(addresses).toEqual(['address-1', 'address-2', 'address-3', 'address-4'])
})
})

Expand Down Expand Up @@ -202,15 +185,17 @@ export const rewardSumListFixture = () => ({
min_time: '2020-12-17T00:00:00Z',
max_time: '2020-12-18T00:00:00Z',
},
data: [{
total: 13.17717245,
sum: 1317717245,
stddev: 1.10445133,
min: 0,
median: 1.98726309,
max: 2,
avg: 1.4641302722222223,
}],
data: [
{
total: 13.17717245,
sum: 1317717245,
stddev: 1.10445133,
min: 0,
median: 1.98726309,
max: 2,
avg: 1.4641302722222223,
},
],
})

export const rewardsFixture = () => ({
Expand Down Expand Up @@ -244,15 +229,21 @@ export const rewardsFixture = () => ({

describe('get rewards', () => {
nock('https://api.helium.io')
.get('/v1/accounts/fake-address/rewards/sum?min_time=2020-12-17T00%3A00%3A00.000Z&max_time=2020-12-18T00%3A00%3A00.000Z')
.get(
'/v1/accounts/fake-address/rewards/sum?min_time=2020-12-17T00%3A00%3A00.000Z&max_time=2020-12-18T00%3A00%3A00.000Z',
)
.reply(200, rewardSumFixture())

nock('https://api.helium.io')
.get('/v1/accounts/fake-address/rewards?min_time=2020-12-17T00%3A00%3A00.000Z&max_time=2020-12-18T00%3A00%3A00.000Z')
.get(
'/v1/accounts/fake-address/rewards?min_time=2020-12-17T00%3A00%3A00.000Z&max_time=2020-12-18T00%3A00%3A00.000Z',
)
.reply(200, rewardsFixture())

nock('https://api.helium.io')
.get('/v1/accounts/fake-address/rewards/sum?min_time=2020-12-17T00%3A00%3A00.000Z&max_time=2020-12-18T00%3A00%3A00.000Z&bucket=day')
.get(
'/v1/accounts/fake-address/rewards/sum?min_time=2020-12-17T00%3A00%3A00.000Z&max_time=2020-12-18T00%3A00%3A00.000Z&bucket=day',
)
.reply(200, rewardSumListFixture())

nock('https://api.helium.io')
Expand Down Expand Up @@ -289,6 +280,7 @@ describe('get rewards', () => {
try {
await client.account('fake-address').rewards.sum.list({ minTime, maxTime })
} catch (error) {
//@ts-ignore
expect(error.message).toBe('missing bucket param')
}
})
Expand All @@ -297,7 +289,9 @@ describe('get rewards', () => {
const minTime = new Date('2020-12-17T00:00:00Z')
const maxTime = new Date('2020-12-18T00:00:00Z')
const client = new Client()
const rewardsList = await client.account('fake-address').rewards.sum.list({ minTime, maxTime, bucket: 'day' })
const rewardsList = await client
.account('fake-address')
.rewards.sum.list({ minTime, maxTime, bucket: 'day' })
const rewards = await rewardsList.take(5)
expect(rewards.length).toBe(1)
expect(rewards[0].balanceTotal.floatBalance).toBe(13.17717245)
Expand All @@ -306,7 +300,9 @@ describe('get rewards', () => {
it('list account reward sums by bucket', async () => {
const minTime = '-1 day'
const client = new Client()
const rewardsList = await client.account('fake-address').rewards.sum.list({ minTime, bucket: 'day' })
const rewardsList = await client
.account('fake-address')
.rewards.sum.list({ minTime, bucket: 'day' })
const rewards = await rewardsList.take(5)
expect(rewards.length).toBe(1)
expect(rewards[0].balanceTotal.floatBalance).toBe(13.17717245)
Expand Down
1 change: 1 addition & 0 deletions packages/http/src/resources/__tests__/Hotspots.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ describe('get rewards', () => {
try {
await client.hotspot('fake-address').rewards.sum.list({ minTime, maxTime })
} catch (error) {
// @ts-ignore
expect(error.message).toBe('missing bucket param')
}
})
Expand Down
1 change: 1 addition & 0 deletions packages/http/src/resources/__tests__/Validators.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ describe('get rewards', () => {
try {
await client.validator('fake-address').rewards.sum.list({ minTime, maxTime })
} catch (error) {
// @ts-ignore
expect(error.message).toBe('missing bucket param')
}
})
Expand Down
Loading

0 comments on commit c592dbc

Please sign in to comment.