Skip to content

Commit

Permalink
fix: verification fix (#133)
Browse files Browse the repository at this point in the history
* fix: handle new verification message name

* chore: bump relay version
  • Loading branch information
horsefacts authored Feb 2, 2024
1 parent 7b3a884 commit e5fa7ef
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
6 changes: 6 additions & 0 deletions apps/relay/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @farcaster/auth-relay

## 0.0.8

### Patch Changes

- fix: handle new verification message name

## 0.0.7

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion apps/relay/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
22 changes: 18 additions & 4 deletions apps/relay/src/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -70,7 +78,13 @@ export class AddressService {
return ResultAsync.fromPromise(this.http.get<VerificationsAPIResponse>(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
);
}),
);
});
}
}

0 comments on commit e5fa7ef

Please sign in to comment.