From e5fa7ef56bf56098a8b04653c5ddd159ecd0ba8c Mon Sep 17 00:00:00 2001 From: horsefacts <109845214+horsefacts@users.noreply.github.com> Date: Fri, 2 Feb 2024 09:23:09 -0700 Subject: [PATCH] fix: verification fix (#133) * fix: handle new verification message name * chore: bump relay version --- apps/relay/CHANGELOG.md | 6 ++++++ apps/relay/package.json | 2 +- apps/relay/src/addresses.ts | 22 ++++++++++++++++++---- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/apps/relay/CHANGELOG.md b/apps/relay/CHANGELOG.md index ec30b27..3d94ce4 100644 --- a/apps/relay/CHANGELOG.md +++ b/apps/relay/CHANGELOG.md @@ -1,5 +1,11 @@ # @farcaster/auth-relay +## 0.0.8 + +### Patch Changes + +- fix: handle new verification message name + ## 0.0.7 ### Patch Changes diff --git a/apps/relay/package.json b/apps/relay/package.json index feeb0ba..2572b9f 100644 --- a/apps/relay/package.json +++ b/apps/relay/package.json @@ -1,6 +1,6 @@ { "name": "@farcaster/auth-relay", - "version": "0.0.7", + "version": "0.0.8", "description": "Farcaster Auth relay server", "private": true, "type": "commonjs", diff --git a/apps/relay/src/addresses.ts b/apps/relay/src/addresses.ts index 03ad09f..12cd1c2 100644 --- a/apps/relay/src/addresses.ts +++ b/apps/relay/src/addresses.ts @@ -8,14 +8,22 @@ import { ID_REGISTRY_ADDRESS, idRegistryABI } from "@farcaster/core"; import { RelayAsyncResult, RelayError } from "./errors"; import { HUB_URL, OPTIMISM_RPC_URL } from "./env"; -interface VerificationAddEthAddressBody { +interface VerificationAddAddressBody { address: Hex; } -interface VerificationMessageData { - verificationAddEthAddressBody: VerificationAddEthAddressBody; +interface ArbitraryVerificationMessageData { + verificationAddEthAddressBody: never; + verificationAddAddressBody: VerificationAddAddressBody; } +interface EthVerificationMessageData { + verificationAddEthAddressBody: VerificationAddAddressBody; + verificationAddAddressBody: never; +} + +type VerificationMessageData = ArbitraryVerificationMessageData | EthVerificationMessageData; + interface VerificationMessage { data: VerificationMessageData; } @@ -70,7 +78,13 @@ export class AddressService { return ResultAsync.fromPromise(this.http.get(url), (error) => { return new RelayError("unknown", error as Error); }).andThen((res) => { - return ok(res.data.messages.map((message) => message.data.verificationAddEthAddressBody.address)); + return ok( + res.data.messages.map((message) => { + return ( + message.data?.verificationAddAddressBody?.address || message.data?.verificationAddEthAddressBody?.address + ); + }), + ); }); } }