From 1b5748934f051ed1a5207165c9ad81c243f034af Mon Sep 17 00:00:00 2001 From: Wasif Iqbal Date: Tue, 30 Jan 2024 22:34:54 -0600 Subject: [PATCH] remove solana related changes --- apps/hubble/src/storage/engine/index.test.ts | 4 +- apps/replicator/src/db.ts | 7 -- apps/replicator/src/processors/index.ts | 7 -- apps/replicator/src/util.ts | 12 --- packages/core/src/builders.test.ts | 10 +-- packages/core/src/builders.ts | 14 ---- packages/core/src/crypto/eip712.test.ts | 4 +- packages/core/src/crypto/eip712.ts | 8 +- packages/core/src/factories.ts | 4 +- .../core/src/protobufs/generated/message.ts | 7 -- packages/core/src/protobufs/typeguards.ts | 19 ----- packages/core/src/protobufs/types.ts | 10 --- packages/core/src/signers/eip712Signer.ts | 4 +- .../core/src/signers/ethersEip712Signer.ts | 4 +- .../core/src/signers/ethersV5Eip712Signer.ts | 4 +- packages/core/src/signers/testUtils.ts | 8 +- .../core/src/signers/viemLocalEip712Signer.ts | 4 +- .../src/signers/viemWalletEip712Signer.ts | 4 +- packages/core/src/validations.test.ts | 4 +- packages/core/src/validations.ts | 76 +------------------ packages/core/src/verifications.test.ts | 15 +--- packages/core/src/verifications.ts | 43 +---------- packages/hub-nodejs/src/generated/message.ts | 7 -- packages/hub-web/src/generated/message.ts | 7 -- protobufs/schemas/message.proto | 1 - 25 files changed, 38 insertions(+), 249 deletions(-) diff --git a/apps/hubble/src/storage/engine/index.test.ts b/apps/hubble/src/storage/engine/index.test.ts index bdfdf0d21b..b4df18c9d8 100644 --- a/apps/hubble/src/storage/engine/index.test.ts +++ b/apps/hubble/src/storage/engine/index.test.ts @@ -35,7 +35,7 @@ import Engine from "../engine/index.js"; import { sleep } from "../../utils/crypto.js"; import { getMessage, makeTsHash, typeToSetPostfix } from "../db/message.js"; import { StoreEvents } from "../stores/storeEventHandler.js"; -import { IdRegisterOnChainEvent, makeVerificationEthAddressClaim } from "@farcaster/core"; +import { IdRegisterOnChainEvent, makeVerificationAddressClaim } from "@farcaster/core"; import { setReferenceDateForTest } from "../../utils/versions.js"; import { getUserNameProof } from "../db/nameRegistryEvent.js"; import { publicClient } from "../../test/utils.js"; @@ -185,7 +185,7 @@ describe("mergeMessage", () => { test("fails when network does not match claim network", async () => { const address = custodySignerKey; const blockHash = Factories.BlockHash.build(); - const mainnetClaim = await makeVerificationEthAddressClaim( + const mainnetClaim = await makeVerificationAddressClaim( fid, address, FarcasterNetwork.MAINNET, diff --git a/apps/replicator/src/db.ts b/apps/replicator/src/db.ts index 1f83faf88a..e1095d064c 100644 --- a/apps/replicator/src/db.ts +++ b/apps/replicator/src/db.ts @@ -208,12 +208,6 @@ export type VerificationAddEthAddressBodyJson = { blockHash: Hex; }; -export type VerificationAddSolAddressBodyJson = { - address: Hex; - protocolSignature: Hex; - blockHash: Hex; -}; - export type VerificationRemoveBodyJson = { address: Hex; protocol: Protocol; @@ -246,7 +240,6 @@ export type MessageBodyJson = | ReactionBodyJson | LinkBodyJson | VerificationAddEthAddressBodyJson - | VerificationAddSolAddressBodyJson | VerificationRemoveBodyJson | UserDataBodyJson | UsernameProofBodyJson; diff --git a/apps/replicator/src/processors/index.ts b/apps/replicator/src/processors/index.ts index 6d86251446..11e62ff06c 100644 --- a/apps/replicator/src/processors/index.ts +++ b/apps/replicator/src/processors/index.ts @@ -26,7 +26,6 @@ import { isUserDataAddMessage, isUsernameProofMessage, isVerificationAddAddressMessage, - isVerificationAddSolAddressMessage, isVerificationRemoveMessage, } from "@farcaster/hub-nodejs"; import { Redis } from "ioredis"; @@ -180,12 +179,6 @@ export async function processMessage( break; case MessageType.FRAME_ACTION: throw new AssertionError("Unexpected FRAME_ACTION message type"); - case MessageType.VERIFICATION_ADD_SOL_ADDRESS: - if (!isVerificationAddSolAddressMessage(message)) - throw new AssertionError(`Invalid VerificationAddSolAddressMessage: ${message}`); - log.debug(`Processing VerificationAddSolAddressMessage ${hash} (fid ${fid})`, { fid, hash }); - // await processVerificationAddSolAddress(message, operation, trx); - break; case MessageType.NONE: throw new AssertionError("Message contained no type"); default: diff --git a/apps/replicator/src/util.ts b/apps/replicator/src/util.ts index 6b58de5600..6f3a97a546 100644 --- a/apps/replicator/src/util.ts +++ b/apps/replicator/src/util.ts @@ -29,7 +29,6 @@ import { UserDataBodyJson, VerificationRemoveBodyJson, VerificationAddEthAddressBodyJson, - VerificationAddSolAddressBodyJson, LinkBodyJson, ReactionBodyJson, CastRemoveBodyJson, @@ -201,17 +200,6 @@ export function convertProtobufMessageBodyToJson(message: Message): MessageBodyJ blockHash: bytesToHex(blockHash), } satisfies VerificationAddEthAddressBodyJson; } - case MessageType.VERIFICATION_ADD_SOL_ADDRESS: { - if (!message.data.verificationAddAddressBody) { - throw new Error("Missing verificationAddSolAddressBody"); - } - const { address, protocolSignature, blockHash } = message.data.verificationAddAddressBody; - return { - address: bytesToHex(address), - protocolSignature: bytesToHex(protocolSignature), - blockHash: bytesToHex(blockHash), - } satisfies VerificationAddSolAddressBodyJson; - } case MessageType.VERIFICATION_REMOVE: { if (!message.data.verificationRemoveBody) throw new Error("Missing verificationRemoveBody"); const { address, protocol } = message.data.verificationRemoveBody; diff --git a/packages/core/src/builders.test.ts b/packages/core/src/builders.test.ts index 469e5867f7..354662e7ef 100644 --- a/packages/core/src/builders.test.ts +++ b/packages/core/src/builders.test.ts @@ -7,7 +7,7 @@ import { bytesToHexString, hexStringToBytes, utf8StringToBytes } from "./bytes"; import { HubError } from "./errors"; import { Factories } from "./factories"; import * as validations from "./validations"; -import { makeVerificationEthAddressClaim, VerificationEthAddressClaim } from "./verifications"; +import { makeVerificationAddressClaim, VerificationAddressClaim } from "./verifications"; import { getFarcasterTime, toFarcasterTime } from "./time"; import { makeUserNameProofClaim } from "./userNameProof"; @@ -140,10 +140,10 @@ describe("makeReactionRemove", () => { describe("makeVerificationAddEthAddressData", () => { const blockHash = Factories.BlockHash.build(); let ethSignature: Uint8Array; - let claim: VerificationEthAddressClaim; + let claim: VerificationAddressClaim; beforeAll(async () => { - claim = makeVerificationEthAddressClaim(fid, ethSignerKey, network, blockHash)._unsafeUnwrap(); + claim = makeVerificationAddressClaim(fid, ethSignerKey, network, blockHash)._unsafeUnwrap(); const signature = (await eip712Signer.signVerificationEthAddressClaim(claim))._unsafeUnwrap(); expect(signature).toBeTruthy(); ethSignature = signature; @@ -178,10 +178,10 @@ describe("makeVerificationRemoveData", () => { describe("makeVerificationAddEthAddress", () => { const blockHash = Factories.BlockHash.build(); let ethSignature: Uint8Array; - let claim: VerificationEthAddressClaim; + let claim: VerificationAddressClaim; beforeAll(async () => { - claim = makeVerificationEthAddressClaim(fid, ethSignerKey, network, blockHash)._unsafeUnwrap(); + claim = makeVerificationAddressClaim(fid, ethSignerKey, network, blockHash)._unsafeUnwrap(); const signatureHex = (await eip712Signer.signVerificationEthAddressClaim(claim))._unsafeUnwrap(); expect(signatureHex).toBeTruthy(); ethSignature = signatureHex; diff --git a/packages/core/src/builders.ts b/packages/core/src/builders.ts index 5d6414a155..9795a23ef5 100644 --- a/packages/core/src/builders.ts +++ b/packages/core/src/builders.ts @@ -268,20 +268,6 @@ export const makeVerificationAddEthAddressData = ( ); }; -// TODO: Add Solana public clients -export const makeVerificationAddSolAddressData = ( - body: protobufs.VerificationAddAddressBody, - dataOptions: MessageDataOptions, - publicClients: PublicClients = defaultPublicClients, -): HubAsyncResult => { - return makeMessageData( - { verificationAddAddressBody: body }, - protobufs.MessageType.VERIFICATION_ADD_SOL_ADDRESS, - dataOptions, - publicClients, - ); -}; - export const makeVerificationRemoveData = ( body: protobufs.VerificationRemoveBody, dataOptions: MessageDataOptions, diff --git a/packages/core/src/crypto/eip712.test.ts b/packages/core/src/crypto/eip712.test.ts index 8e9f3c5fd0..fe6cb79ef7 100644 --- a/packages/core/src/crypto/eip712.test.ts +++ b/packages/core/src/crypto/eip712.test.ts @@ -5,7 +5,7 @@ import { hexStringToBytes } from "../bytes"; import * as eip712 from "./eip712"; import { ViemLocalEip712Signer } from "../signers"; import { makeUserNameProofClaim } from "../userNameProof"; -import { makeVerificationEthAddressClaim } from "../verifications"; +import { makeVerificationAddressClaim } from "../verifications"; const privateKey = generatePrivateKey(); const account = privateKeyToAccount(privateKey); @@ -49,7 +49,7 @@ describe("verifyUserNameProofClaim", () => { describe("verifyVerificationEthAddressClaimSignature", () => { test("succeeds with a generated claim", async () => { - const claimRes = makeVerificationEthAddressClaim( + const claimRes = makeVerificationAddressClaim( Factories.Fid.build(), (await signer.getSignerKey())._unsafeUnwrap(), Factories.FarcasterNetwork.build(), diff --git a/packages/core/src/crypto/eip712.ts b/packages/core/src/crypto/eip712.ts index b183c8b482..3187b90d3c 100644 --- a/packages/core/src/crypto/eip712.ts +++ b/packages/core/src/crypto/eip712.ts @@ -1,7 +1,7 @@ import { bytesToHex, verifyTypedData } from "viem"; import { ResultAsync } from "neverthrow"; import { HubAsyncResult, HubError } from "../errors"; -import { VerificationEthAddressClaim } from "../verifications"; +import { VerificationAddressClaim } from "../verifications"; import { UserNameProofClaim } from "../userNameProof"; import { PublicClients, defaultPublicClients } from "../eth/clients"; import { CHAIN_IDS } from "../eth/chains"; @@ -65,7 +65,7 @@ export const MESSAGE_DATA_EIP_712_TYPES = { } as const; export const verifyVerificationClaimEOASignature = async ( - claim: VerificationEthAddressClaim, + claim: VerificationAddressClaim, signature: Uint8Array, address: Uint8Array, chainId: number, @@ -91,7 +91,7 @@ export const verifyVerificationClaimEOASignature = async ( }; export const verifyVerificationClaimContractSignature = async ( - claim: VerificationEthAddressClaim, + claim: VerificationAddressClaim, signature: Uint8Array, address: Uint8Array, chainId: number, @@ -119,7 +119,7 @@ export const verifyVerificationClaimContractSignature = async ( }; export const verifyVerificationEthAddressClaimSignature = async ( - claim: VerificationEthAddressClaim, + claim: VerificationAddressClaim, signature: Uint8Array, address: Uint8Array, verificationType = 0, diff --git a/packages/core/src/factories.ts b/packages/core/src/factories.ts index 239f40b80a..028303fbb4 100644 --- a/packages/core/src/factories.ts +++ b/packages/core/src/factories.ts @@ -22,7 +22,7 @@ import { import { bytesToHexString, utf8StringToBytes } from "./bytes"; import { Ed25519Signer, Eip712Signer, NobleEd25519Signer, Signer, ViemLocalEip712Signer } from "./signers"; import { FARCASTER_EPOCH, getFarcasterTime, toFarcasterTime } from "./time"; -import { VerificationEthAddressClaim } from "./verifications"; +import { VerificationAddressClaim } from "./verifications"; import { LocalAccount } from "viem"; /** Scalars */ @@ -372,7 +372,7 @@ const ReactionRemoveMessageFactory = Factory.define(() => { +const VerificationEthAddressClaimFactory = Factory.define(() => { const address = bytesToHexString(EthAddressFactory.build())._unsafeUnwrap(); const blockHash = bytesToHexString(BlockHashFactory.build())._unsafeUnwrap(); diff --git a/packages/core/src/protobufs/generated/message.ts b/packages/core/src/protobufs/generated/message.ts index 51459da53f..bfa5ec5710 100644 --- a/packages/core/src/protobufs/generated/message.ts +++ b/packages/core/src/protobufs/generated/message.ts @@ -101,8 +101,6 @@ export enum MessageType { USERNAME_PROOF = 12, /** FRAME_ACTION - A Farcaster Frame action */ FRAME_ACTION = 13, - /** VERIFICATION_ADD_SOL_ADDRESS - Add a Verification of a Solana Address */ - VERIFICATION_ADD_SOL_ADDRESS = 14, } export function messageTypeFromJSON(object: any): MessageType { @@ -143,9 +141,6 @@ export function messageTypeFromJSON(object: any): MessageType { case 13: case "MESSAGE_TYPE_FRAME_ACTION": return MessageType.FRAME_ACTION; - case 14: - case "MESSAGE_TYPE_VERIFICATION_ADD_SOL_ADDRESS": - return MessageType.VERIFICATION_ADD_SOL_ADDRESS; default: throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum MessageType"); } @@ -177,8 +172,6 @@ export function messageTypeToJSON(object: MessageType): string { return "MESSAGE_TYPE_USERNAME_PROOF"; case MessageType.FRAME_ACTION: return "MESSAGE_TYPE_FRAME_ACTION"; - case MessageType.VERIFICATION_ADD_SOL_ADDRESS: - return "MESSAGE_TYPE_VERIFICATION_ADD_SOL_ADDRESS"; default: throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum MessageType"); } diff --git a/packages/core/src/protobufs/typeguards.ts b/packages/core/src/protobufs/typeguards.ts index 9b03f59a19..d57f6a7e38 100644 --- a/packages/core/src/protobufs/typeguards.ts +++ b/packages/core/src/protobufs/typeguards.ts @@ -95,25 +95,6 @@ export const isVerificationAddAddressMessage = ( isVerificationAddEthAddressData(message.data) ); }; -export const isVerificationAddSolAddressData = ( - data: protobufs.MessageData, -): data is types.VerificationAddSolAddressData => { - return ( - data.type === protobufs.MessageType.VERIFICATION_ADD_SOL_ADDRESS && - typeof data.verificationAddAddressBody !== "undefined" - ); -}; - -export const isVerificationAddSolAddressMessage = ( - message: protobufs.Message, -): message is types.VerificationAddSolAddressMessage => { - return ( - message.signatureScheme === protobufs.SignatureScheme.ED25519 && - typeof message.data !== "undefined" && - isVerificationAddSolAddressData(message.data) - ); -}; - export const isVerificationRemoveData = (data: protobufs.MessageData): data is types.VerificationRemoveData => { return data.type === protobufs.MessageType.VERIFICATION_REMOVE && typeof data.verificationRemoveBody !== "undefined"; }; diff --git a/packages/core/src/protobufs/types.ts b/packages/core/src/protobufs/types.ts index 5dc8bb6ed9..6774a692f9 100644 --- a/packages/core/src/protobufs/types.ts +++ b/packages/core/src/protobufs/types.ts @@ -76,16 +76,6 @@ export type VerificationAddAddressMessage = protobufs.Message & { signatureScheme: protobufs.SignatureScheme.ED25519; }; -export type VerificationAddSolAddressData = protobufs.MessageData & { - type: protobufs.MessageType.VERIFICATION_ADD_SOL_ADDRESS; - verificationAddSolAddressBody: protobufs.VerificationAddAddressBody; -}; - -export type VerificationAddSolAddressMessage = protobufs.Message & { - data: VerificationAddSolAddressData; - signatureScheme: protobufs.SignatureScheme.ED25519; -}; - export type VerificationRemoveData = protobufs.MessageData & { type: protobufs.MessageType.VERIFICATION_REMOVE; verificationRemoveBody: protobufs.VerificationRemoveBody; diff --git a/packages/core/src/signers/eip712Signer.ts b/packages/core/src/signers/eip712Signer.ts index 79fc832b54..98525989be 100644 --- a/packages/core/src/signers/eip712Signer.ts +++ b/packages/core/src/signers/eip712Signer.ts @@ -1,6 +1,6 @@ import { SignatureScheme } from "../protobufs"; import { HubAsyncResult } from "../errors"; -import { VerificationEthAddressClaim } from "../verifications"; +import { VerificationAddressClaim } from "../verifications"; import { UserNameProofClaim } from "../userNameProof"; import { Signer } from "./signer"; import { KeyGatewayAddMessage } from "../eth/contracts/keyGateway"; @@ -26,7 +26,7 @@ export abstract class Eip712Signer implements Signer { public abstract getSignerKey(): HubAsyncResult; public abstract signMessageHash(hash: Uint8Array): HubAsyncResult; public abstract signVerificationEthAddressClaim( - claim: VerificationEthAddressClaim, + claim: VerificationAddressClaim, chainId?: number, ): HubAsyncResult; public abstract signUserNameProofClaim(claim: UserNameProofClaim): HubAsyncResult; diff --git a/packages/core/src/signers/ethersEip712Signer.ts b/packages/core/src/signers/ethersEip712Signer.ts index 9122b2da6b..623523d5c3 100644 --- a/packages/core/src/signers/ethersEip712Signer.ts +++ b/packages/core/src/signers/ethersEip712Signer.ts @@ -1,7 +1,7 @@ import { ResultAsync, err } from "neverthrow"; import type { Signer } from "ethers"; import { HubAsyncResult, HubError } from "../errors"; -import { VerificationEthAddressClaim } from "../verifications"; +import { VerificationAddressClaim } from "../verifications"; import { UserNameProofClaim } from "../userNameProof"; import { Eip712Signer } from "./eip712Signer"; import { bytesToHexString, hexStringToBytes } from "../bytes"; @@ -70,7 +70,7 @@ export class EthersEip712Signer extends Eip712Signer { } public async signVerificationEthAddressClaim( - claim: VerificationEthAddressClaim, + claim: VerificationAddressClaim, chainId = 0, ): HubAsyncResult { const domain = chainId === 0 ? EIP_712_FARCASTER_DOMAIN : { ...EIP_712_FARCASTER_DOMAIN, chainId }; diff --git a/packages/core/src/signers/ethersV5Eip712Signer.ts b/packages/core/src/signers/ethersV5Eip712Signer.ts index 093a9768eb..3cd2119f12 100644 --- a/packages/core/src/signers/ethersV5Eip712Signer.ts +++ b/packages/core/src/signers/ethersV5Eip712Signer.ts @@ -7,7 +7,7 @@ import type { import { HubAsyncResult, HubError } from "../errors"; import { eip712 } from "../crypto"; import { bytesToHexString, hexStringToBytes } from "../bytes"; -import { VerificationEthAddressClaim } from "../verifications"; +import { VerificationAddressClaim } from "../verifications"; import { UserNameProofClaim } from "../userNameProof"; import { ID_GATEWAY_EIP_712_DOMAIN, @@ -66,7 +66,7 @@ export class EthersV5Eip712Signer extends Eip712Signer { } public async signVerificationEthAddressClaim( - claim: VerificationEthAddressClaim, + claim: VerificationAddressClaim, chainId = 0, ): HubAsyncResult { const domain = chainId === 0 ? eip712.EIP_712_FARCASTER_DOMAIN : { ...eip712.EIP_712_FARCASTER_DOMAIN, chainId }; diff --git a/packages/core/src/signers/testUtils.ts b/packages/core/src/signers/testUtils.ts index 998451470d..c4d233b459 100644 --- a/packages/core/src/signers/testUtils.ts +++ b/packages/core/src/signers/testUtils.ts @@ -4,7 +4,7 @@ import { bytesToHexString, hexStringToBytes } from "../bytes"; import { eip712 } from "../crypto"; import { Factories } from "../factories"; import { FarcasterNetwork } from "../protobufs"; -import { makeVerificationEthAddressClaim, VerificationEthAddressClaim } from "../verifications"; +import { makeVerificationAddressClaim, VerificationAddressClaim } from "../verifications"; import { makeUserNameProofClaim, UserNameProofClaim } from "../userNameProof"; import { Eip712Signer } from "./eip712Signer"; import { bytesToHex, decodeAbiParameters } from "viem"; @@ -39,11 +39,11 @@ export const testEip712Signer = async (signer: Eip712Signer) => { }); describe("signVerificationEthAddressClaim", () => { - let claim: VerificationEthAddressClaim; + let claim: VerificationAddressClaim; let signature: Uint8Array; beforeAll(async () => { - claim = makeVerificationEthAddressClaim( + claim = makeVerificationAddressClaim( Factories.Fid.build(), signerKey, FarcasterNetwork.TESTNET, @@ -60,7 +60,7 @@ export const testEip712Signer = async (signer: Eip712Signer) => { }); test("succeeds when encoding twice", async () => { - const claim2: VerificationEthAddressClaim = { ...claim }; + const claim2: VerificationAddressClaim = { ...claim }; const signature2 = await signer.signVerificationEthAddressClaim(claim2); expect(signature2).toEqual(ok(signature)); expect(bytesToHexString(signature2._unsafeUnwrap())).toEqual(bytesToHexString(signature)); diff --git a/packages/core/src/signers/viemLocalEip712Signer.ts b/packages/core/src/signers/viemLocalEip712Signer.ts index 9748c92bf0..14819c3c04 100644 --- a/packages/core/src/signers/viemLocalEip712Signer.ts +++ b/packages/core/src/signers/viemLocalEip712Signer.ts @@ -9,7 +9,7 @@ import { MESSAGE_DATA_EIP_712_TYPES, } from "../crypto/eip712"; import { HubAsyncResult, HubError } from "../errors"; -import { VerificationEthAddressClaim } from "../verifications"; +import { VerificationAddressClaim } from "../verifications"; import { UserNameProofClaim } from "../userNameProof"; import { Eip712Signer } from "./eip712Signer"; import { ID_GATEWAY_EIP_712_TYPES, IdGatewayRegisterMessage } from "../eth/contracts/idGateway"; @@ -53,7 +53,7 @@ export class ViemLocalEip712Signer extends Eip712Signer { } public async signVerificationEthAddressClaim( - claim: VerificationEthAddressClaim, + claim: VerificationAddressClaim, chainId = 0, ): HubAsyncResult { const domain = chainId === 0 ? EIP_712_FARCASTER_DOMAIN : { ...EIP_712_FARCASTER_DOMAIN, chainId }; diff --git a/packages/core/src/signers/viemWalletEip712Signer.ts b/packages/core/src/signers/viemWalletEip712Signer.ts index 7eb00ebd65..1b83a01ae2 100644 --- a/packages/core/src/signers/viemWalletEip712Signer.ts +++ b/packages/core/src/signers/viemWalletEip712Signer.ts @@ -8,7 +8,7 @@ import { USERNAME_PROOF_EIP_712_TYPES, } from "../crypto/eip712"; import { HubAsyncResult, HubError } from "../errors"; -import { VerificationEthAddressClaim } from "../verifications"; +import { VerificationAddressClaim } from "../verifications"; import { UserNameProofClaim } from "../userNameProof"; import { Eip712Signer } from "./eip712Signer"; import { ID_GATEWAY_EIP_712_TYPES, IdGatewayRegisterMessage } from "../eth/contracts/idGateway"; @@ -55,7 +55,7 @@ export class ViemWalletEip712Signer extends Eip712Signer { } public async signVerificationEthAddressClaim( - claim: VerificationEthAddressClaim, + claim: VerificationAddressClaim, chainId = 0, ): HubAsyncResult { const domain = chainId === 0 ? EIP_712_FARCASTER_DOMAIN : { ...EIP_712_FARCASTER_DOMAIN, chainId }; diff --git a/packages/core/src/validations.test.ts b/packages/core/src/validations.test.ts index 83859d0075..eb0410a3bc 100644 --- a/packages/core/src/validations.test.ts +++ b/packages/core/src/validations.test.ts @@ -6,7 +6,7 @@ import { HubError } from "./errors"; import { Factories } from "./factories"; import { fromFarcasterTime, getFarcasterTime } from "./time"; import * as validations from "./validations"; -import { makeVerificationEthAddressClaim } from "./verifications"; +import { makeVerificationAddressClaim } from "./verifications"; import { UserDataType, UserNameType } from "@farcaster/hub-nodejs"; import { defaultL1PublicClient } from "./eth/clients"; import { optimism } from "viem/chains"; @@ -755,7 +755,7 @@ describe("validateVerificationAddEthAddressSignature", () => { test("fails with eth signature from different address", async () => { const blockHash = Factories.BlockHash.build(); - const claim = makeVerificationEthAddressClaim(fid, ethSignerKey, network, blockHash)._unsafeUnwrap(); + const claim = makeVerificationAddressClaim(fid, ethSignerKey, network, blockHash)._unsafeUnwrap(); const ethSignature = (await ethSigner.signVerificationEthAddressClaim(claim))._unsafeUnwrap(); expect(ethSignature).toBeTruthy(); const body = await Factories.VerificationAddEthAddressBody.create({ diff --git a/packages/core/src/validations.ts b/packages/core/src/validations.ts index 80cd9c349f..eb0b41b34f 100644 --- a/packages/core/src/validations.ts +++ b/packages/core/src/validations.ts @@ -5,11 +5,10 @@ import { bytesCompare, bytesToUtf8String, utf8StringToBytes } from "./bytes"; import { ed25519, eip712 } from "./crypto"; import { HubAsyncResult, HubError, HubResult } from "./errors"; import { getFarcasterTime, toFarcasterTime } from "./time"; -import { makeVerificationEthAddressClaim, makeVerificationSolAddressClaim } from "./verifications"; +import { makeVerificationAddressClaim } from "./verifications"; import { UserNameType } from "./protobufs"; import { normalize } from "viem/ens"; import { defaultPublicClients, PublicClients } from "./eth/clients"; -import bs58 from "bs58"; /** Number of seconds (10 minutes) that is appropriate for clock skew */ export const ALLOWED_CLOCK_SKEW_SECONDS = 10 * 60; @@ -146,18 +145,6 @@ export const validateEthAddress = (address?: Uint8Array | null): HubResult => { - if (!address || address.length === 0) { - return err(new HubError("bad_request.validation_failure", "Solana address is missing")); - } - - if (address.length !== 32) { - return err(new HubError("bad_request.validation_failure", "Solana address must be 32 bytes")); - } - - return ok(address); -}; - export const validateEthBlockHash = (blockHash?: Uint8Array | null): HubResult => { if (!blockHash || blockHash.length === 0) { return err(new HubError("bad_request.validation_failure", "blockHash is missing")); @@ -170,21 +157,6 @@ export const validateEthBlockHash = (blockHash?: Uint8Array | null): HubResult { - try { - const inputString = new TextDecoder().decode(input); - const decoded = bs58.decode(inputString); - // Solana block hashes are 32 bytes - if (decoded.length === 32) { - return ok(input); - } else { - return err(new HubError("bad_request.validation_failure", "Solana block hash must be 32 bytes")); - } - } catch (error) { - return err(new HubError("bad_request.validation_failure", "Solana block hash must be a valid base58 string")); - } -} - export const validateEd25519PublicKey = (publicKey?: Uint8Array | null): HubResult => { if (!publicKey || publicKey.length === 0) { return err(new HubError("bad_request.validation_failure", "publicKey is missing")); @@ -359,7 +331,7 @@ export const validateVerificationAddEthAddressSignature = async ( return err(new HubError("bad_request.validation_failure", "protocolSignature > 256 bytes")); } - const reconstructedClaim = makeVerificationEthAddressClaim(fid, body.address, network, body.blockHash); + const reconstructedClaim = makeVerificationAddressClaim(fid, body.address, network, body.blockHash); if (reconstructedClaim.isErr()) { return err(reconstructedClaim.error); } @@ -384,24 +356,6 @@ export const validateVerificationAddEthAddressSignature = async ( return ok(body.protocolSignature); }; -export const validateVerificationAddSolAddressSignature = async ( - body: protobufs.VerificationAddAddressBody, - fid: number, - network: protobufs.FarcasterNetwork, - publicClients: PublicClients = defaultPublicClients, -): HubAsyncResult => { - if (body.protocolSignature.length > 256) { - return err(new HubError("bad_request.validation_failure", "protocolSignature > 256 bytes")); - } - - const reconstructedClaim = makeVerificationSolAddressClaim(fid, body.address, network, body.blockHash); - if (reconstructedClaim.isErr()) { - return err(reconstructedClaim.error); - } - - return ok(body.protocolSignature); -}; - export const validateUrl = (url: string): HubResult => { if (typeof url !== "string") { return err(new HubError("bad_request.validation_failure", "url must be a string")); @@ -663,38 +617,12 @@ export const validateVerificationAddEthAddressBody = async ( return ok(body); }; -export const validateVerificationAddSolAddressBody = async ( - body: protobufs.VerificationAddAddressBody, - fid: number, - network: protobufs.FarcasterNetwork, - publicClients: PublicClients, -): HubAsyncResult => { - const validAddress = validateSolAddress(body.address); - if (validAddress.isErr()) { - return err(validAddress.error); - } - - // Solana block hash uses SHA-256 algorithm - const validBlockHash = validateSolBlockHash(body.blockHash); - if (validBlockHash.isErr()) { - return err(validBlockHash.error); - } - - const validSignature = await validateVerificationAddSolAddressSignature(body, fid, network, publicClients); - - // TODO: add validation to reconstruct user claim and validate signature against claim using input FID - - return ok(body); -}; - export const validateVerificationRemoveBody = ( body: protobufs.VerificationRemoveBody, ): HubResult => { switch (body.protocol) { case protobufs.Protocol.ETHEREUM: return validateEthAddress(body.address).map(() => body); - case protobufs.Protocol.SOLANA: - return validateSolAddress(body.address).map(() => body); default: return err(new HubError("bad_request.validation_failure", "invalid verification protocol")); } diff --git a/packages/core/src/verifications.test.ts b/packages/core/src/verifications.test.ts index acd2c14242..8309749a3a 100644 --- a/packages/core/src/verifications.test.ts +++ b/packages/core/src/verifications.test.ts @@ -1,5 +1,5 @@ import { Factories } from "./factories"; -import { makeVerificationEthAddressClaim, makeVerificationSolAddressClaim } from "./verifications"; +import { makeVerificationAddressClaim } from "./verifications"; describe("makeVerificationEthAddressClaim", () => { test("succeeds", () => { @@ -7,18 +7,7 @@ describe("makeVerificationEthAddressClaim", () => { const ethAddress = Factories.EthAddress.build(); const network = Factories.FarcasterNetwork.build(); const blockHash = Factories.BlockHash.build(); - const claim = makeVerificationEthAddressClaim(fid, ethAddress, network, blockHash); - expect(claim.isOk()).toBeTruthy(); - }); -}); - -describe("makeVerificationSolAddressClaim", () => { - test("succeeds", () => { - const fid = Factories.Fid.build(); - const solAddress = Factories.EthAddress.build(); - const network = Factories.FarcasterNetwork.build(); - const blockHash = Factories.BlockHash.build(); - const claim = makeVerificationSolAddressClaim(fid, solAddress, network, blockHash); + const claim = makeVerificationAddressClaim(fid, ethAddress, network, blockHash); expect(claim.isOk()).toBeTruthy(); }); }); diff --git a/packages/core/src/verifications.ts b/packages/core/src/verifications.ts index b68bf946af..2d1256c95a 100644 --- a/packages/core/src/verifications.ts +++ b/packages/core/src/verifications.ts @@ -4,28 +4,19 @@ import { bytesToHexString } from "./bytes"; import { HubResult } from "./errors"; import { validateEthAddress, validateEthBlockHash } from "./validations"; -export type VerificationEthAddressClaim = { +export type VerificationAddressClaim = { fid: bigint; address: `0x${string}`; network: FarcasterNetwork; blockHash: `0x${string}`; }; -export type VerificationSolAddressClaim = { - fid: bigint; - // Solana addresses use base58 encoding and do not have a 0x prefix - address: string; - network: FarcasterNetwork; - // Solana block hash is base58 encoded and does not have a 0x prefix - blockHash: string; -}; - -export const makeVerificationEthAddressClaim = ( +export const makeVerificationAddressClaim = ( fid: number, ethAddress: Uint8Array, network: FarcasterNetwork, blockHash: Uint8Array, -): HubResult => { +): HubResult => { const ethAddressHex = validateEthAddress(ethAddress).andThen((validatedEthAddress) => bytesToHexString(validatedEthAddress), ); @@ -47,31 +38,3 @@ export const makeVerificationEthAddressClaim = ( blockHash: blockHashHex.value, }); }; - -export const makeVerificationSolAddressClaim = ( - fid: number, - solAddress: Uint8Array, - network: FarcasterNetwork, - blockHash: Uint8Array, -): HubResult => { - const solAddressHex = validateEthAddress(solAddress).andThen((validatedEthAddress) => - bytesToHexString(validatedEthAddress), - ); - if (solAddressHex.isErr()) { - return err(solAddressHex.error); - } - - const blockHashHex = validateEthBlockHash(blockHash).andThen((validatedBlockHash) => - bytesToHexString(validatedBlockHash), - ); - if (blockHashHex.isErr()) { - return err(blockHashHex.error); - } - - return ok({ - fid: BigInt(fid), - address: solAddressHex.value, - network: network, - blockHash: blockHashHex.value, - }); -}; diff --git a/packages/hub-nodejs/src/generated/message.ts b/packages/hub-nodejs/src/generated/message.ts index 51459da53f..bfa5ec5710 100644 --- a/packages/hub-nodejs/src/generated/message.ts +++ b/packages/hub-nodejs/src/generated/message.ts @@ -101,8 +101,6 @@ export enum MessageType { USERNAME_PROOF = 12, /** FRAME_ACTION - A Farcaster Frame action */ FRAME_ACTION = 13, - /** VERIFICATION_ADD_SOL_ADDRESS - Add a Verification of a Solana Address */ - VERIFICATION_ADD_SOL_ADDRESS = 14, } export function messageTypeFromJSON(object: any): MessageType { @@ -143,9 +141,6 @@ export function messageTypeFromJSON(object: any): MessageType { case 13: case "MESSAGE_TYPE_FRAME_ACTION": return MessageType.FRAME_ACTION; - case 14: - case "MESSAGE_TYPE_VERIFICATION_ADD_SOL_ADDRESS": - return MessageType.VERIFICATION_ADD_SOL_ADDRESS; default: throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum MessageType"); } @@ -177,8 +172,6 @@ export function messageTypeToJSON(object: MessageType): string { return "MESSAGE_TYPE_USERNAME_PROOF"; case MessageType.FRAME_ACTION: return "MESSAGE_TYPE_FRAME_ACTION"; - case MessageType.VERIFICATION_ADD_SOL_ADDRESS: - return "MESSAGE_TYPE_VERIFICATION_ADD_SOL_ADDRESS"; default: throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum MessageType"); } diff --git a/packages/hub-web/src/generated/message.ts b/packages/hub-web/src/generated/message.ts index 51459da53f..bfa5ec5710 100644 --- a/packages/hub-web/src/generated/message.ts +++ b/packages/hub-web/src/generated/message.ts @@ -101,8 +101,6 @@ export enum MessageType { USERNAME_PROOF = 12, /** FRAME_ACTION - A Farcaster Frame action */ FRAME_ACTION = 13, - /** VERIFICATION_ADD_SOL_ADDRESS - Add a Verification of a Solana Address */ - VERIFICATION_ADD_SOL_ADDRESS = 14, } export function messageTypeFromJSON(object: any): MessageType { @@ -143,9 +141,6 @@ export function messageTypeFromJSON(object: any): MessageType { case 13: case "MESSAGE_TYPE_FRAME_ACTION": return MessageType.FRAME_ACTION; - case 14: - case "MESSAGE_TYPE_VERIFICATION_ADD_SOL_ADDRESS": - return MessageType.VERIFICATION_ADD_SOL_ADDRESS; default: throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum MessageType"); } @@ -177,8 +172,6 @@ export function messageTypeToJSON(object: MessageType): string { return "MESSAGE_TYPE_USERNAME_PROOF"; case MessageType.FRAME_ACTION: return "MESSAGE_TYPE_FRAME_ACTION"; - case MessageType.VERIFICATION_ADD_SOL_ADDRESS: - return "MESSAGE_TYPE_VERIFICATION_ADD_SOL_ADDRESS"; default: throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum MessageType"); } diff --git a/protobufs/schemas/message.proto b/protobufs/schemas/message.proto index eb95cc2bba..d90662912e 100644 --- a/protobufs/schemas/message.proto +++ b/protobufs/schemas/message.proto @@ -69,7 +69,6 @@ enum MessageType { MESSAGE_TYPE_USER_DATA_ADD = 11; // Add metadata about a user MESSAGE_TYPE_USERNAME_PROOF = 12; // Add or replace a username proof MESSAGE_TYPE_FRAME_ACTION = 13; // A Farcaster Frame action - MESSAGE_TYPE_VERIFICATION_ADD_SOL_ADDRESS = 14; // Add a Verification of a Solana Address } /** Farcaster network the message is intended for */