diff --git a/README.md b/README.md index cc3558b..be9b8cd 100644 --- a/README.md +++ b/README.md @@ -37,8 +37,8 @@ REACT_APP_DIMO_IDENTITY_URL=https://identity-api.dev.dimo.zone/query REACT_APP_DEVICES_API_URL=http://0.0.0.0:8080/https://devices-api.dev.dimo.zone/v1 REACT_APP_DEVICE_DEFINITIONS_URL=https://device-definitions-api.dev.dimo.zone REACT_APP_POLYGON_RPC_URL=https://polygon-amoy.g.alchemy.com/v2/-0PsUljNtSdA31-XWj-kL_L1Mx2ArYfS -REACT_APP_ZERODEV_BUNDLER_URL=https://rpc.zerodev.app/api/v2/bundler/f4d1596a-edfd-4063-8f99-2d8835e07739 -REACT_APP_ZERODEV_PAYMASTER_URL=https://rpc.zerodev.app/api/v2/paymaster/f4d1596a-edfd-4063-8f99-2d8835e07739 +REACT_APP_ZERODEV_BUNDLER_URL=https://rpc.zerodev.app/api/v2/bundler/ +REACT_APP_ZERODEV_PAYMASTER_URL=https://rpc.zerodev.app/api/v2/paymaster/ REACT_APP_ENVIRONMENT=dev REACT_APP_SMARTCAR_CLIENT_ID=f0378698-ab62-40ca-ae37-5e7fd9cab711 REACT_APP_TESLA_CLIENT_ID=194119ca43c7-4528-9415-3116fb5868cd diff --git a/src/hooks/useParamsHandler.ts b/src/hooks/useParamsHandler.ts index 447e754..b1e4719 100644 --- a/src/hooks/useParamsHandler.ts +++ b/src/hooks/useParamsHandler.ts @@ -7,6 +7,9 @@ import { UiStates } from '../enums'; import { setForceEmail } from '../stores/AuthStateStore'; import { parseExpirationDate, getDefaultExpirationDate } from '../utils/dateUtils'; +// Params that are handles empty values +const DEFAULTED_PARAMS = ['expirationDate']; + export const useParamsHandler = (DEFAULT_CONTEXT: AllParams) => { const [devCredentialsState, setDevCredentialsState] = useState(DEFAULT_CONTEXT); @@ -74,12 +77,15 @@ export const useParamsHandler = (DEFAULT_CONTEXT: AllParams) => { })), }; + const hasValidValue = (key: string, value: unknown) => + DEFAULTED_PARAMS.includes(key) || value !== undefined; + const applyDevCredentialsConfig = (config: Record) => { Object.entries(config).forEach(([key, value]) => { if ( key in specialSetters && specialSetters[key as keyof typeof specialSetters] && - value !== undefined + hasValidValue(key, value) ) { specialSetters[key as keyof typeof specialSetters](value); } else { diff --git a/src/models/__tests__/vehicle.test.ts b/src/models/__tests__/vehicle.test.ts index 37dd9b2..5d2417e 100644 --- a/src/models/__tests__/vehicle.test.ts +++ b/src/models/__tests__/vehicle.test.ts @@ -9,6 +9,7 @@ jest.mock('@dimo-network/transactions', () => ({ describe('LocalVehicle', () => { const mockVehicleNode = { tokenId: 123, + tokenDID: 'did:erc721:0xbA5738a18d83D41847dfFbDC6101d37C69c9B0cF:123', imageURI: 'http://image.url', definition: { id: 'mock_def_id', @@ -49,6 +50,7 @@ describe('LocalVehicle', () => { it('normalizes vehicle data', () => { expect(localVehicle.normalize()).toEqual({ tokenId: 123, + tokenDID: 'did:erc721:0xbA5738a18d83D41847dfFbDC6101d37C69c9B0cF:123', imageURI: 'http://image.url', make: 'Tesla', model: 'Model S', diff --git a/src/models/vehicle.ts b/src/models/vehicle.ts index 3f0f5d2..8deda0f 100644 --- a/src/models/vehicle.ts +++ b/src/models/vehicle.ts @@ -4,6 +4,7 @@ import { fetchDeviceDefinition, VehicleNode } from '../services'; export interface Vehicle { tokenId: number; + tokenDID: string; imageURI: string; make: string; model: string; @@ -67,6 +68,7 @@ export class LocalVehicle { normalize() { return { tokenId: this.tokenId, + tokenDID: this.vehicleNode.tokenDID, imageURI: this.vehicleNode.imageURI, make: this.make, model: this.model, diff --git a/src/services/__tests__/vehicleService.test.ts b/src/services/__tests__/vehicleService.test.ts index c6a6e01..e015ae8 100644 --- a/src/services/__tests__/vehicleService.test.ts +++ b/src/services/__tests__/vehicleService.test.ts @@ -21,6 +21,7 @@ beforeEach(() => { nodes: [ { tokenId: 1, + tokenDID: 'did:erc721:0xbA5738a18d83D41847dfFbDC6101d37C69c9B0cF:1', imageURI: 'http://image.url', definition: { id: 'tesla_model_3_2019', @@ -34,6 +35,7 @@ beforeEach(() => { }, { tokenId: 2, + tokenDID: 'did:erc721:0xbA5738a18d83D41847dfFbDC6101d37C69c9B0cF:2', imageURI: 'http://image.url', definition: { id: 'ford_bronco_2023', @@ -177,6 +179,7 @@ it('Returns vehicles with the correct shape in compatible and incompatible array expect(vehicle).toEqual( expect.objectContaining({ tokenId: expect.any(Number), + tokenDID: expect.any(String), imageURI: expect.anything(), shared: expect.any(Boolean), expiresAt: expect.any(String), @@ -201,6 +204,7 @@ it('Returns incompatible vehicles with the correct shape when no compatible vehi expect(vehicle).toEqual( expect.objectContaining({ tokenId: expect.any(Number), + tokenDID: expect.any(String), imageURI: expect.anything(), shared: expect.any(Boolean), expiresAt: expect.any(String), diff --git a/src/services/identityService.ts b/src/services/identityService.ts index 718d0d1..3f57e69 100644 --- a/src/services/identityService.ts +++ b/src/services/identityService.ts @@ -35,6 +35,7 @@ const GET_VEHICLES = gql` ) { nodes { tokenId + tokenDID imageURI definition { id @@ -62,6 +63,7 @@ const GET_VEHICLES = gql` export type VehicleNode = { tokenId: number; + tokenDID: string; imageURI: string; definition: { id: string;