Skip to content

Commit

Permalink
remove solana related changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Wazzymandias committed Jan 31, 2024
1 parent 1afc542 commit 1b57489
Show file tree
Hide file tree
Showing 25 changed files with 38 additions and 249 deletions.
4 changes: 2 additions & 2 deletions apps/hubble/src/storage/engine/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 0 additions & 7 deletions apps/replicator/src/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -246,7 +240,6 @@ export type MessageBodyJson =
| ReactionBodyJson
| LinkBodyJson
| VerificationAddEthAddressBodyJson
| VerificationAddSolAddressBodyJson
| VerificationRemoveBodyJson
| UserDataBodyJson
| UsernameProofBodyJson;
Expand Down
7 changes: 0 additions & 7 deletions apps/replicator/src/processors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
isUserDataAddMessage,
isUsernameProofMessage,
isVerificationAddAddressMessage,
isVerificationAddSolAddressMessage,
isVerificationRemoveMessage,
} from "@farcaster/hub-nodejs";
import { Redis } from "ioredis";
Expand Down Expand Up @@ -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:
Expand Down
12 changes: 0 additions & 12 deletions apps/replicator/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {
UserDataBodyJson,
VerificationRemoveBodyJson,
VerificationAddEthAddressBodyJson,
VerificationAddSolAddressBodyJson,
LinkBodyJson,
ReactionBodyJson,
CastRemoveBodyJson,
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/builders.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 0 additions & 14 deletions packages/core/src/builders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,20 +268,6 @@ export const makeVerificationAddEthAddressData = (
);
};

// TODO: Add Solana public clients
export const makeVerificationAddSolAddressData = (
body: protobufs.VerificationAddAddressBody,
dataOptions: MessageDataOptions,
publicClients: PublicClients = defaultPublicClients,
): HubAsyncResult<protobufs.VerificationAddSolAddressData> => {
return makeMessageData(
{ verificationAddAddressBody: body },
protobufs.MessageType.VERIFICATION_ADD_SOL_ADDRESS,
dataOptions,
publicClients,
);
};

export const makeVerificationRemoveData = (
body: protobufs.VerificationRemoveBody,
dataOptions: MessageDataOptions,
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/crypto/eip712.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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(),
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/crypto/eip712.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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,
Expand All @@ -91,7 +91,7 @@ export const verifyVerificationClaimEOASignature = async (
};

export const verifyVerificationClaimContractSignature = async (
claim: VerificationEthAddressClaim,
claim: VerificationAddressClaim,
signature: Uint8Array,
address: Uint8Array,
chainId: number,
Expand Down Expand Up @@ -119,7 +119,7 @@ export const verifyVerificationClaimContractSignature = async (
};

export const verifyVerificationEthAddressClaimSignature = async (
claim: VerificationEthAddressClaim,
claim: VerificationAddressClaim,
signature: Uint8Array,
address: Uint8Array,
verificationType = 0,
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/factories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -372,7 +372,7 @@ const ReactionRemoveMessageFactory = Factory.define<protobufs.ReactionRemoveMess
},
);

const VerificationEthAddressClaimFactory = Factory.define<VerificationEthAddressClaim>(() => {
const VerificationEthAddressClaimFactory = Factory.define<VerificationAddressClaim>(() => {
const address = bytesToHexString(EthAddressFactory.build())._unsafeUnwrap();
const blockHash = bytesToHexString(BlockHashFactory.build())._unsafeUnwrap();

Expand Down
7 changes: 0 additions & 7 deletions packages/core/src/protobufs/generated/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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");
}
Expand Down
19 changes: 0 additions & 19 deletions packages/core/src/protobufs/typeguards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
};
Expand Down
10 changes: 0 additions & 10 deletions packages/core/src/protobufs/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/signers/eip712Signer.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -26,7 +26,7 @@ export abstract class Eip712Signer implements Signer {
public abstract getSignerKey(): HubAsyncResult<Uint8Array>;
public abstract signMessageHash(hash: Uint8Array): HubAsyncResult<Uint8Array>;
public abstract signVerificationEthAddressClaim(
claim: VerificationEthAddressClaim,
claim: VerificationAddressClaim,
chainId?: number,
): HubAsyncResult<Uint8Array>;
public abstract signUserNameProofClaim(claim: UserNameProofClaim): HubAsyncResult<Uint8Array>;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/signers/ethersEip712Signer.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -70,7 +70,7 @@ export class EthersEip712Signer extends Eip712Signer {
}

public async signVerificationEthAddressClaim(
claim: VerificationEthAddressClaim,
claim: VerificationAddressClaim,
chainId = 0,
): HubAsyncResult<Uint8Array> {
const domain = chainId === 0 ? EIP_712_FARCASTER_DOMAIN : { ...EIP_712_FARCASTER_DOMAIN, chainId };
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/signers/ethersV5Eip712Signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -66,7 +66,7 @@ export class EthersV5Eip712Signer extends Eip712Signer {
}

public async signVerificationEthAddressClaim(
claim: VerificationEthAddressClaim,
claim: VerificationAddressClaim,
chainId = 0,
): HubAsyncResult<Uint8Array> {
const domain = chainId === 0 ? eip712.EIP_712_FARCASTER_DOMAIN : { ...eip712.EIP_712_FARCASTER_DOMAIN, chainId };
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/signers/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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,
Expand All @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/signers/viemLocalEip712Signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -53,7 +53,7 @@ export class ViemLocalEip712Signer extends Eip712Signer {
}

public async signVerificationEthAddressClaim(
claim: VerificationEthAddressClaim,
claim: VerificationAddressClaim,
chainId = 0,
): HubAsyncResult<Uint8Array> {
const domain = chainId === 0 ? EIP_712_FARCASTER_DOMAIN : { ...EIP_712_FARCASTER_DOMAIN, chainId };
Expand Down
Loading

0 comments on commit 1b57489

Please sign in to comment.