Skip to content

Commit

Permalink
camel case it (#469)
Browse files Browse the repository at this point in the history
  • Loading branch information
bryzettler authored Nov 1, 2023
1 parent 478afe7 commit 86c3a98
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
31 changes: 15 additions & 16 deletions packages/metadata-service/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { provider } from "./solana";
import { daoKey } from "@helium/helium-sub-daos-sdk";
import {
AccountLayout,
getAccount,
getAssociatedTokenAddressSync,
} from "@solana/spl-token";
import { PublicKey } from "@solana/web3.js";
Expand Down Expand Up @@ -78,7 +77,7 @@ server.get<{ Params: { wallet: string } }>(
});

const assetJsons = keyToAssets.map((record) => {
const keyStr = decodeEntityKey(record.entity_key, {
const keyStr = decodeEntityKey(record.entityKey, {
[record.keySerialization]: {},
});
return generateAssetJson(record, keyStr!);
Expand Down Expand Up @@ -128,7 +127,7 @@ server.get<{ Querystring: { subnetwork: string } }>(
return ktas.map((kta) => {
return {
key_to_asset_key: kta.address,
is_active: kta.iot_hotspot_info!.is_active,
is_active: kta.iotHotspotInfo!.isActive,
};
});
} else if (subnetwork === "mobile") {
Expand All @@ -143,8 +142,8 @@ server.get<{ Querystring: { subnetwork: string } }>(
return ktas.map((kta) => {
return {
key_to_asset_key: kta.address,
is_active: kta.mobile_hotspot_info!.is_active,
device_type: kta.mobile_hotspot_info!.device_type,
is_active: kta.mobileHotspotInfo!.isActive,
device_type: kta.mobileHotspotInfo!.deviceType,
};
});
}
Expand All @@ -160,10 +159,10 @@ function generateAssetJson(record: KeyToAsset, keyStr: string) {
const hotspotType = keyStr.length > 100 ? "MOBILE" : "IOT";
const image = `${SHDW_DRIVE_URL}/${
hotspotType === "MOBILE"
? record?.mobile_hotspot_info?.is_active
? record?.mobileHotspotInfo?.isActive
? "mobile-hotspot-active.png"
: "mobile-hotspot.png"
: record?.iot_hotspot_info?.is_active
: record?.iotHotspotInfo?.isActive
? "hotspot-active.png"
: "hotspot.png"
}`;
Expand All @@ -177,10 +176,10 @@ function generateAssetJson(record: KeyToAsset, keyStr: string) {
key_to_asset_key: record.address,
image,
hotspot_infos: {
iot: record?.iot_hotspot_info,
mobile: record?.mobile_hotspot_info,
iot: record?.iotHotspotInfo,
mobile: record?.mobileHotspotInfo,
},
entity_key_b64: record?.entity_key.toString("base64"),
entity_key_b64: record?.entityKey.toString("base64"),
key_serialization: record?.keySerialization,
entity_key_str: keyStr,
attributes: [
Expand All @@ -190,18 +189,18 @@ function generateAssetJson(record: KeyToAsset, keyStr: string) {
{ trait_type: "entity_key_string", value: keyStr },
{
trait_type: "entity_key",
value: record?.entity_key?.toString("base64"),
value: record?.entityKey?.toString("base64"),
},
{ trait_type: "rewardable", value: true },
{
trait_type: "networks",
value: [
record?.iot_hotspot_info && "iot",
record?.mobile_hotspot_info && "mobile",
record?.iotHotspotInfo && "iot",
record?.mobileHotspotInfo && "mobile",
].filter(truthy),
},
...locationAttributes("iot", record?.iot_hotspot_info),
...locationAttributes("mobile", record?.mobile_hotspot_info),
...locationAttributes("iot", record?.iotHotspotInfo),
...locationAttributes("mobile", record?.mobileHotspotInfo),
],
};
}
Expand All @@ -219,7 +218,7 @@ const getHotspotByKeyToAsset = async (request, reply) => {
return reply.code(404);
}

const { entity_key: entityKey, keySerialization } = record;
const { entityKey, keySerialization } = record;
const keyStr = decodeEntityKey(entityKey, { [keySerialization]: {} });

const assetJson = generateAssetJson(record, keyStr!);
Expand Down
14 changes: 7 additions & 7 deletions packages/metadata-service/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ export class MobileHotspotInfo extends Model {
declare city: string;
declare state: string;
declare country: string;
declare is_active: boolean;
declare device_type: string;
declare isActive: boolean;
declare deviceType: string;
}
MobileHotspotInfo.init(
{
Expand Down Expand Up @@ -90,7 +90,7 @@ export class IotHotspotInfo extends Model {
declare city: string;
declare state: string;
declare country: string;
declare is_active: boolean;
declare isActive: boolean;
}
IotHotspotInfo.init(
{
Expand All @@ -106,7 +106,7 @@ IotHotspotInfo.init(
location: DataTypes.DECIMAL.UNSIGNED,
dcOnboardingFeePaid: DataTypes.DECIMAL.UNSIGNED,
elevation: DataTypes.NUMBER,
gain: DataTypes.NUMBER
gain: DataTypes.NUMBER,
},
{
sequelize,
Expand All @@ -120,9 +120,9 @@ IotHotspotInfo.init(
export class KeyToAsset extends Model {
declare address: string;
declare asset: string;
declare entity_key: Buffer;
declare mobile_hotspot_info?: MobileHotspotInfo;
declare iot_hotspot_info?: IotHotspotInfo;
declare entityKey: Buffer;
declare mobileHotspotInfo?: MobileHotspotInfo;
declare iotHotspotInfo?: IotHotspotInfo;
declare keySerialization: string;
}
KeyToAsset.init(
Expand Down

0 comments on commit 86c3a98

Please sign in to comment.