From cd0ddd6d24eeb2482214ddc800de83755f176002 Mon Sep 17 00:00:00 2001 From: Sanjay Date: Mon, 10 Jul 2023 23:40:50 -0700 Subject: [PATCH] feat: Support ENS names in the hub (#1101) * feat: Add ENS username proof support * Add UserNameProof store * ENS name ownership validations * Add remaining ens validations * Generate events correctly * Allow setting ens names on UserData and handle revoking it * Add changeset and cli flag --- .changeset/rotten-keys-smell.md | 8 + apps/hubble/README.md | 11 +- apps/hubble/docker-compose.yml | 2 +- apps/hubble/src/cli.ts | 2 + apps/hubble/src/defaultConfig.ts | 2 + apps/hubble/src/hubble.ts | 16 +- apps/hubble/src/rpc/server.ts | 14 + .../src/rpc/test/userDataService.test.ts | 80 +++- apps/hubble/src/storage/db/message.ts | 8 + .../src/storage/db/nameRegistryEvent.ts | 10 +- apps/hubble/src/storage/db/types.ts | 10 +- apps/hubble/src/storage/engine/index.test.ts | 275 +++++++++++++- apps/hubble/src/storage/engine/index.ts | 195 +++++++--- .../hubble/src/storage/stores/storageCache.ts | 8 + apps/hubble/src/storage/stores/store.ts | 45 ++- .../src/storage/stores/storeEventHandler.ts | 1 + .../src/storage/stores/userDataStore.ts | 2 + .../storage/stores/usernameProofStore.test.ts | 225 +++++++++++ .../src/storage/stores/usernameProofStore.ts | 216 +++++++++++ docker-compose-multinode.yml | 4 + packages/core/src/factories.ts | 39 +- .../core/src/protobufs/generated/hub_event.ts | 222 ++++++----- .../core/src/protobufs/generated/hub_state.ts | 30 +- .../protobufs/generated/id_registry_event.ts | 54 ++- packages/core/src/protobufs/generated/job.ts | 40 +- .../core/src/protobufs/generated/message.ts | 337 ++++++++-------- .../generated/name_registry_event.ts | 50 ++- .../protobufs/generated/request_response.ts | 210 ++++++---- .../core/src/protobufs/generated/sync_trie.ts | 32 +- .../src/protobufs/generated/username_proof.ts | 54 +-- packages/core/src/protobufs/typeguards.ts | 15 +- packages/core/src/protobufs/types.ts | 10 + packages/core/src/validations.test.ts | 121 ++++++ packages/core/src/validations.ts | 90 ++++- .../hub-nodejs/src/generated/hub_event.ts | 222 ++++++----- .../src/generated/id_registry_event.ts | 54 ++- packages/hub-nodejs/src/generated/message.ts | 337 ++++++++-------- .../src/generated/name_registry_event.ts | 50 ++- .../src/generated/request_response.ts | 210 ++++++---- packages/hub-nodejs/src/generated/rpc.ts | 359 ++++++++++-------- .../src/generated/username_proof.ts | 54 +-- packages/hub-web/src/generated/hub_event.ts | 222 ++++++----- .../src/generated/id_registry_event.ts | 54 ++- packages/hub-web/src/generated/message.ts | 337 ++++++++-------- .../src/generated/name_registry_event.ts | 50 ++- .../hub-web/src/generated/request_response.ts | 210 ++++++---- packages/hub-web/src/generated/rpc.ts | 333 +++++++--------- .../hub-web/src/generated/username_proof.ts | 54 +-- protobufs/schemas/hub_event.proto | 2 + protobufs/schemas/message.proto | 3 + protobufs/schemas/request_response.proto | 5 + protobufs/schemas/rpc.proto | 3 + protobufs/schemas/username_proof.proto | 1 + rome.json | 16 +- 54 files changed, 3258 insertions(+), 1756 deletions(-) create mode 100644 .changeset/rotten-keys-smell.md create mode 100644 apps/hubble/src/storage/stores/usernameProofStore.test.ts create mode 100644 apps/hubble/src/storage/stores/usernameProofStore.ts diff --git a/.changeset/rotten-keys-smell.md b/.changeset/rotten-keys-smell.md new file mode 100644 index 0000000000..24747cd1d1 --- /dev/null +++ b/.changeset/rotten-keys-smell.md @@ -0,0 +1,8 @@ +--- +"@farcaster/hub-nodejs": patch +"@farcaster/hub-web": patch +"@farcaster/core": patch +"@farcaster/hubble": patch +--- + +feat: Add support for ens names diff --git a/apps/hubble/README.md b/apps/hubble/README.md index a04b497426..65714075d1 100644 --- a/apps/hubble/README.md +++ b/apps/hubble/README.md @@ -24,7 +24,8 @@ Testnet is a sandboxed environment where you can read and write messages without 1. Create a `.env` file in your `apps/hubble` directory, substituting the relevant value for your `ETH_RPC_URL`: ``` - ETH_RPC_URL=your-ETH-RPC-URL + ETH_RPC_URL=your-ETH-goerli-RPC-URL + ETH_MAINNET_RPC_URL=your-ETH-mainnet-RPC-URL FC_NETWORK_ID=2 BOOTSTRAP_NODE=/dns/testnet1.farcaster.xyz/tcp/2282 ``` @@ -52,7 +53,8 @@ Mainnet is Farcaster's production environment apps use and writing a message her 1. Update the `.env` file in your `apps/hubble` directory, substituting the relevant value for your `ETH_RPC_URL`: ``` # Note: this should still point to goerli and not eth mainnet - ETH_RPC_URL=your-ETH-RPC-URL + ETH_RPC_URL=your-ETH-goerli-RPC-URL + ETH_MAINNET_RPC_URL=your-ETH-mainnet-RPC-URL FC_NETWORK_ID=1 BOOTSTRAP_NODE=/dns/nemes.farcaster.xyz/tcp/2282 ``` @@ -93,6 +95,7 @@ Create a `.env` file in your `apps/hubble` directory, substituting the relevant ``` ETH_RPC_URL=your-ETH-RPC-URL +ETH_MAINNET_RPC_URL=your-ETH-mainnet-RPC-URL FC_NETWORK_ID=2 BOOTSTRAP_NODE=/dns/testnet1.farcaster.xyz/tcp/2282 ``` @@ -122,6 +125,7 @@ Mainnet is Farcaster's production environment apps use and writing a message her ``` # Note: this should still point to goerli and not eth mainnet ETH_RPC_URL=your-ETH-RPC-URL + ETH_MAINNET_RPC_URL=your-ETH-mainnet-RPC-URL FC_NETWORK_ID=1 BOOTSTRAP_NODE=/dns/nemes.farcaster.xyz/tcp/2282 ``` @@ -150,7 +154,8 @@ Fetching data from Hubble requires communicating with its [gRPC](https://grpc.io 1. Go to `apps/hubble` in this repo 2. Pull the latest image: `docker pull farcasterxyz/hubble:latest` 3. Run `docker compose stop && docker compose up -d --force-recreate` -4. If you are upgrading from a non-docker deployment to docker, make sure the `.hub` and `.rocks` directories are writable for all users. +4. If you are upgrading from a non-docker deployment to docker, make sure the `.hub` and `.rocks` directories are writable for all users. +5. If you're upgrading from 1.3.3 or below, please set `ETH_MAINNET_RPC_URL=your-ETH-mainnet-RPC-URL` (if using docker) or provide the `--eth-mainnet-rpc-url` flag (if not using docker) Check the logs to ensure your hub is running successfully: ```sh diff --git a/apps/hubble/docker-compose.yml b/apps/hubble/docker-compose.yml index 35988238bb..8c7cc002c2 100644 --- a/apps/hubble/docker-compose.yml +++ b/apps/hubble/docker-compose.yml @@ -4,7 +4,7 @@ services: hubble: image: farcasterxyz/hubble:latest restart: unless-stopped - command: ["yarn", "start", "--ip", "0.0.0.0", "--gossip-port", "2282", "--rpc-port", "2283", "--eth-rpc-url", "$ETH_RPC_URL", "--network", "$FC_NETWORK_ID", "-b", "$BOOTSTRAP_NODE"] + command: ["yarn", "start", "--ip", "0.0.0.0", "--gossip-port", "2282", "--rpc-port", "2283", "--eth-rpc-url", "$ETH_RPC_URL", "--eth-mainnet-rpc-url", "$ETH_MAINNET_RPC_URL", "--network", "$FC_NETWORK_ID", "-b", "$BOOTSTRAP_NODE"] ports: - '2282:2282' # Gossip - '2283:2283' # RPC diff --git a/apps/hubble/src/cli.ts b/apps/hubble/src/cli.ts index 2cbc7a996d..b73095528c 100644 --- a/apps/hubble/src/cli.ts +++ b/apps/hubble/src/cli.ts @@ -53,6 +53,7 @@ app .command("start") .description("Start a Hub") .option("-e, --eth-rpc-url ", "RPC URL of a Goerli Ethereum Node") + .option("-m, --eth-mainnet-rpc-url ", "RPC URL of a mainnet Ethereum Node") .option("-c, --config ", "Path to a config file with options") .option("--fir-address
", "The address of the Farcaster ID Registry contract") .option("--fnr-address
", "The address of the Farcaster Name Registry contract") @@ -308,6 +309,7 @@ app gossipPort: hubAddressInfo.value.port, network, ethRpcUrl: cliOptions.ethRpcUrl ?? hubConfig.ethRpcUrl, + ethMainnetRpcUrl: cliOptions.ethMainnetRpcUrl ?? hubConfig.ethMainnetRpcUrl, fnameServerUrl: cliOptions.fnameServerUrl ?? hubConfig.fnameServerUrl ?? DEFAULT_FNAME_SERVER_URL, idRegistryAddress: cliOptions.firAddress ?? hubConfig.firAddress, nameRegistryAddress: cliOptions.fnrAddress ?? hubConfig.fnrAddress, diff --git a/apps/hubble/src/defaultConfig.ts b/apps/hubble/src/defaultConfig.ts index 8842f45dfa..62c2feb239 100644 --- a/apps/hubble/src/defaultConfig.ts +++ b/apps/hubble/src/defaultConfig.ts @@ -14,6 +14,8 @@ export const Config = { id: "./.hub/default_id.protobuf", /** Network URL of the IdRegistry Contract */ // ethRpcUrl: '', + /** ETH mainnet RPC URL */ + // ethMainnetRpcUrl: '', /** FName Registry Server URL */ // fnameServerUrl: ''; /** Address of the IdRegistry Contract */ diff --git a/apps/hubble/src/hubble.ts b/apps/hubble/src/hubble.ts index 75dce91d41..65e6a9c545 100644 --- a/apps/hubble/src/hubble.ts +++ b/apps/hubble/src/hubble.ts @@ -66,6 +66,8 @@ import StoreEventHandler from "./storage/stores/storeEventHandler.js"; import { FNameRegistryClient, FNameRegistryEventsProvider } from "./eth/fnameRegistryEventsProvider.js"; import { GOSSIP_PROTOCOL_VERSION } from "./network/p2p/protocol.js"; import packageJson from "./package.json" assert { type: "json" }; +import { createPublicClient, http } from "viem"; +import { mainnet } from "viem/chains"; export type HubSubmitSource = "gossip" | "rpc" | "eth-provider" | "sync" | "fname-registry"; @@ -131,6 +133,9 @@ export interface HubOptions { /** Network URL of the IdRegistry Contract */ ethRpcUrl?: string; + /** ETH mainnet RPC URL */ + ethMainnetRpcUrl?: string; + /** FName Registry Server URL */ fnameServerUrl?: string; @@ -247,6 +252,10 @@ export class Hub implements HubInterface { log.warn("No ETH RPC URL provided, not syncing with ETH contract events"); } + if (!options.ethMainnetRpcUrl || options.ethMainnetRpcUrl === "") { + log.warn("No ETH mainnet RPC URL provided, unable to validate ens names"); + } + if (options.fnameServerUrl && options.fnameServerUrl !== "") { this.fNameRegistryEventsProvider = new FNameRegistryEventsProvider( new FNameRegistryClient(options.fnameServerUrl), @@ -261,7 +270,12 @@ export class Hub implements HubInterface { lockMaxPending: options.commitLockMaxPending, lockTimeout: options.commitLockTimeout, }); - this.engine = new Engine(this.rocksDB, options.network, eventHandler); + const mainnetClient = createPublicClient({ + chain: mainnet, + transport: http(options.ethMainnetRpcUrl, { retryCount: 2 }), + }); + + this.engine = new Engine(this.rocksDB, options.network, eventHandler, mainnetClient); this.syncEngine = new SyncEngine(this, this.rocksDB, this.ethRegistryProvider); this.rpcServer = new Server( diff --git a/apps/hubble/src/rpc/server.ts b/apps/hubble/src/rpc/server.ts index f91f9d72ff..e987935fd3 100644 --- a/apps/hubble/src/rpc/server.ts +++ b/apps/hubble/src/rpc/server.ts @@ -36,6 +36,7 @@ import { SyncStatusResponse, SyncStatus, UserNameProof, + UsernameProofsResponse, } from "@farcaster/hub-nodejs"; import { err, ok, Result, ResultAsync } from "neverthrow"; import { APP_NICKNAME, APP_VERSION, HubInterface } from "../hubble.js"; @@ -655,6 +656,19 @@ export default class Server { }, ); }, + getUserNameProofsByFid: async (call, callback) => { + const request = call.request; + + const usernameProofResult = await this.engine?.getUserNameProofsByFid(request.fid); + usernameProofResult?.match( + (usernameProofs: UserNameProof[]) => { + callback(null, UsernameProofsResponse.create({ proofs: usernameProofs })); + }, + (err: HubError) => { + callback(toServiceError(err)); + }, + ); + }, getVerification: async (call, callback) => { const request = call.request; diff --git a/apps/hubble/src/rpc/test/userDataService.test.ts b/apps/hubble/src/rpc/test/userDataService.test.ts index ec2228c5d6..176a1c1d3a 100644 --- a/apps/hubble/src/rpc/test/userDataService.test.ts +++ b/apps/hubble/src/rpc/test/userDataService.test.ts @@ -1,19 +1,23 @@ import { - Message, + bytesToHexString, + bytesToUtf8String, + Factories, FarcasterNetwork, + FidRequest, + getInsecureHubRpcClient, + HubError, + HubRpcClient, IdRegistryEvent, + Message, SignerAddMessage, UserDataAddMessage, - UserDataType, UserDataRequest, - FidRequest, - bytesToUtf8String, - Factories, - HubError, - getInsecureHubRpcClient, - HubRpcClient, - UsernameProofRequest, + UserDataType, UserNameProof, + UsernameProofMessage, + UsernameProofRequest, + UsernameProofsResponse, + UserNameType, } from "@farcaster/hub-nodejs"; import { Ok } from "neverthrow"; import SyncEngine from "../../network/sync/syncEngine.js"; @@ -21,10 +25,12 @@ import Server from "../server.js"; import { jestRocksDB } from "../../storage/db/jestUtils.js"; import Engine from "../../storage/engine/index.js"; import { MockHub } from "../../test/mocks.js"; +import { jest } from "@jest/globals"; +import { publicClient } from "../../test/utils.js"; const db = jestRocksDB("protobufs.rpc.userdataservice.test"); const network = FarcasterNetwork.TESTNET; -const engine = new Engine(db, network); +const engine = new Engine(db, network, undefined, publicClient); const hub = new MockHub(db, engine); let server: Server; @@ -55,6 +61,9 @@ let pfpAdd: UserDataAddMessage; let displayAdd: UserDataAddMessage; let addFname: UserDataAddMessage; +let ensNameProof: UsernameProofMessage; +let addEnsName: UserDataAddMessage; + beforeAll(async () => { const signerKey = (await signer.getSignerKey())._unsafeUnwrap(); custodySignerKey = (await custodySigner.getSignerKey())._unsafeUnwrap(); @@ -88,6 +97,39 @@ beforeAll(async () => { }, { transient: { signer } }, ); + + const custodySignerAddress = bytesToHexString(custodySignerKey)._unsafeUnwrap(); + + jest.spyOn(publicClient, "getEnsAddress").mockImplementation(() => { + return Promise.resolve(custodySignerAddress); + }); + ensNameProof = await Factories.UsernameProofMessage.create( + { + data: { + fid, + usernameProofBody: Factories.UserNameProof.build({ + fid, + owner: custodySignerKey, + name: Factories.EnsName.build(), + type: UserNameType.USERNAME_TYPE_ENS_L1, + }), + }, + }, + { transient: { signer } }, + ); + addEnsName = await Factories.UserDataAddMessage.create( + { + data: { + fid, + userDataBody: { + type: UserDataType.FNAME, + value: bytesToUtf8String(ensNameProof.data.usernameProofBody.name)._unsafeUnwrap(), + }, + timestamp: addFname.data.timestamp + 2, + }, + }, + { transient: { signer } }, + ); }); describe("getUserData", () => { @@ -106,15 +148,25 @@ describe("getUserData", () => { const display = await client.getUserData(UserDataRequest.create({ fid, userDataType: UserDataType.DISPLAY })); expect(Message.toJSON(display._unsafeUnwrap())).toEqual(Message.toJSON(displayAdd)); - const nameProof = Factories.UserNameProof.build({ name: fname, owner: custodySignerKey }); - await engine.mergeUserNameProof(nameProof); + const fnameProof = Factories.UserNameProof.build({ name: fname, owner: custodySignerKey }); + await engine.mergeUserNameProof(fnameProof); expect(await engine.mergeMessage(addFname)).toBeInstanceOf(Ok); const fnameData = await client.getUserData(UserDataRequest.create({ fid, userDataType: UserDataType.FNAME })); expect(Message.toJSON(fnameData._unsafeUnwrap())).toEqual(Message.toJSON(addFname)); - const usernameProof = await client.getUsernameProof(UsernameProofRequest.create({ name: nameProof.name })); - expect(UserNameProof.toJSON(usernameProof._unsafeUnwrap())).toEqual(UserNameProof.toJSON(nameProof)); + const usernameProof = await client.getUsernameProof(UsernameProofRequest.create({ name: fnameProof.name })); + expect(UserNameProof.toJSON(usernameProof._unsafeUnwrap())).toEqual(UserNameProof.toJSON(fnameProof)); + + expect(await engine.mergeMessage(ensNameProof)).toBeInstanceOf(Ok); + const usernameProofs = await client.getUserNameProofsByFid(FidRequest.create({ fid })); + expect(UsernameProofsResponse.toJSON(usernameProofs._unsafeUnwrap())).toEqual( + UsernameProofsResponse.toJSON({ proofs: [ensNameProof.data.usernameProofBody] }), + ); + + expect(await engine.mergeMessage(addEnsName)).toBeInstanceOf(Ok); + const ensNameData = await client.getUserData(UserDataRequest.create({ fid, userDataType: UserDataType.FNAME })); + expect(Message.toJSON(ensNameData._unsafeUnwrap())).toEqual(Message.toJSON(addEnsName)); }); test("fails when user data is missing", async () => { diff --git a/apps/hubble/src/storage/db/message.ts b/apps/hubble/src/storage/db/message.ts index b85b5b43fd..4d602add52 100644 --- a/apps/hubble/src/storage/db/message.ts +++ b/apps/hubble/src/storage/db/message.ts @@ -12,6 +12,10 @@ export const makeFidKey = (fid: number): Buffer => { return buffer; }; +export const readFidKey = (buffer: Buffer): number => { + return buffer.readUInt32BE(0); +}; + /** */ export const makeUserKey = (fid: number): Buffer => { return Buffer.concat([Buffer.from([RootPrefix.User]), makeFidKey(fid)]); @@ -95,6 +99,10 @@ export const typeToSetPostfix = (type: MessageType): UserMessagePostfix => { return UserPostfix.LinkMessage; } + if (type === MessageType.USERNAME_PROOF) { + return UserPostfix.UsernameProofMessage; + } + throw new Error("invalid type"); }; diff --git a/apps/hubble/src/storage/db/nameRegistryEvent.ts b/apps/hubble/src/storage/db/nameRegistryEvent.ts index 194c07b213..57120a7be2 100644 --- a/apps/hubble/src/storage/db/nameRegistryEvent.ts +++ b/apps/hubble/src/storage/db/nameRegistryEvent.ts @@ -8,8 +8,8 @@ export const makeNameRegistryEventPrimaryKey = (fname: Uint8Array): Buffer => { return Buffer.concat([Buffer.from([RootPrefix.NameRegistryEvent]), Buffer.from(fname)]); }; -export const makeUserNameProofPrimaryKey = (name: Uint8Array): Buffer => { - return Buffer.concat([Buffer.from([RootPrefix.UserNameProof]), Buffer.from(name)]); +export const makeFNameUserNameProofKey = (name: Uint8Array): Buffer => { + return Buffer.concat([Buffer.from([RootPrefix.FNameUserNameProof]), Buffer.from(name)]); }; export const makeNameRegistryEventByExpiryKey = (expiry: number, fname?: Uint8Array): Buffer => { @@ -29,7 +29,7 @@ export const getNameRegistryEvent = async (db: RocksDB, fname: Uint8Array): Prom }; export const getUserNameProof = async (db: RocksDB, name: Uint8Array): Promise => { - const primaryKey = makeUserNameProofPrimaryKey(name); + const primaryKey = makeFNameUserNameProofKey(name); const buffer = await db.get(primaryKey); return UserNameProof.decode(new Uint8Array(buffer)); }; @@ -71,14 +71,14 @@ export const putNameRegistryEventTransaction = (txn: Transaction, event: NameReg export const putUserNameProofTransaction = (txn: Transaction, usernameProof: UserNameProof): Transaction => { const proofBuffer = Buffer.from(UserNameProof.encode(usernameProof).finish()); - const primaryKey = makeUserNameProofPrimaryKey(usernameProof.name); + const primaryKey = makeFNameUserNameProofKey(usernameProof.name); const putTxn = txn.put(primaryKey, proofBuffer); return putTxn; }; export const deleteUserNameProofTransaction = (txn: Transaction, usernameProof: UserNameProof): Transaction => { - const primaryKey = makeUserNameProofPrimaryKey(usernameProof.name); + const primaryKey = makeFNameUserNameProofKey(usernameProof.name); const deleteTxn = txn.del(primaryKey); return deleteTxn; diff --git a/apps/hubble/src/storage/db/types.ts b/apps/hubble/src/storage/db/types.ts index c558b24014..c2206f980c 100644 --- a/apps/hubble/src/storage/db/types.ts +++ b/apps/hubble/src/storage/db/types.ts @@ -53,10 +53,12 @@ export enum RootPrefix { HubEvents = 15, /* The network ID that the rocksDB was created with */ Network = 16, - /* Used to store name proofs */ - UserNameProof = 17, + /* Used to store fname server name proofs */ + FNameUserNameProof = 17, /* Used to store gossip network metrics */ GossipMetrics = 18, + /* Used to index user submited username proofs */ + UserNameProofByName = 19, } /** @@ -76,6 +78,7 @@ export enum UserPostfix { VerificationMessage = 4, SignerMessage = 5, UserDataMessage = 6, + UsernameProofMessage = 7, /** Index records (must be 86-255) */ @@ -117,4 +120,5 @@ export type UserMessagePostfix = | UserPostfix.VerificationMessage | UserPostfix.SignerMessage | UserPostfix.ReactionMessage - | UserPostfix.UserDataMessage; + | UserPostfix.UserDataMessage + | UserPostfix.UsernameProofMessage; diff --git a/apps/hubble/src/storage/engine/index.test.ts b/apps/hubble/src/storage/engine/index.test.ts index 8eebe7c789..0b04eb744c 100644 --- a/apps/hubble/src/storage/engine/index.test.ts +++ b/apps/hubble/src/storage/engine/index.test.ts @@ -1,10 +1,14 @@ import { + bytesToHexString, bytesToUtf8String, CastAddMessage, CastId, CastRemoveMessage, Factories, FarcasterNetwork, + fromFarcasterTime, + getFarcasterTime, + hexStringToBytes, HubError, HubEvent, HubEventType, @@ -12,8 +16,11 @@ import { IdRegistryEventType, LinkAddMessage, MergeMessageHubEvent, + MergeUserNameProofBody, + MergeUsernameProofHubEvent, Message, MessageData, + MessageType, NameRegistryEvent, NameRegistryEventType, PruneMessageHubEvent, @@ -25,6 +32,8 @@ import { UserDataAddMessage, UserDataType, UserNameProof, + UserNameType, + utf8StringToBytes, VerificationAddEthAddressMessage, } from "@farcaster/hub-nodejs"; import { err, Ok, ok } from "neverthrow"; @@ -37,10 +46,12 @@ import { StoreEvents } from "../stores/storeEventHandler.js"; import { makeVerificationEthAddressClaim } from "@farcaster/core"; import { setReferenceDateForTest } from "../../utils/versions.js"; import { getUserNameProof } from "../db/nameRegistryEvent.js"; +import { publicClient } from "../../test/utils.js"; +import { jest } from "@jest/globals"; const db = jestRocksDB("protobufs.engine.test"); const network = FarcasterNetwork.TESTNET; -const engine = new Engine(db, network); +const engine = new Engine(db, network, undefined, publicClient); // init signer store for checking state changes from engine const signerStore = new SignerStore(db, engine.eventHandler); @@ -442,6 +453,266 @@ describe("mergeMessage", () => { ); await mainnetEngine.stop(); }); + + describe("UsernameProof messages", () => { + const randomEthAddress = bytesToHexString(Factories.EthAddress.build())._unsafeUnwrap(); + let usernameProofEvents: MergeUserNameProofBody[] = []; + + const handleUsernameProofEvent = (event: MergeUsernameProofHubEvent) => { + usernameProofEvents.push(event.mergeUsernameProofBody); + }; + + beforeEach(async () => { + usernameProofEvents = []; + await engine.mergeIdRegistryEvent(custodyEvent); + await engine.mergeMessage(signerAdd); + await engine.eventHandler.syncCache(); + engine.eventHandler.on("mergeUsernameProofEvent", handleUsernameProofEvent); + }); + + afterEach(async () => { + jest.restoreAllMocks(); + engine.eventHandler.off("mergeUsernameProofEvent", handleUsernameProofEvent); + }); + + const createProof = async (name: string, timestamp?: number | null, owner?: string | null) => { + const ts = timestamp ?? getFarcasterTime()._unsafeUnwrap(); + const ownerAsBytes = owner ? hexStringToBytes(owner)._unsafeUnwrap() : Factories.EthAddress.build(); + return await Factories.UsernameProofMessage.create( + { + data: { + fid, + usernameProofBody: Factories.UserNameProof.build({ + name: utf8StringToBytes(name)._unsafeUnwrap(), + fid, + owner: ownerAsBytes, + timestamp: fromFarcasterTime(ts)._unsafeUnwrap(), + type: UserNameType.USERNAME_TYPE_ENS_L1, + }), + timestamp: ts, + type: MessageType.USERNAME_PROOF, + }, + }, + { transient: { signer } }, + ); + }; + + test("fails when not a valid ens name", async () => { + const result = await engine.mergeMessage(await createProof("no_dot_eth")); + expect(result).toMatchObject(err({ errCode: "bad_request.validation_failure" })); + expect(result._unsafeUnwrapErr().message).toMatch("invalid ens name"); + }); + test("fails gracefully when resolving throws an error", async () => { + const result = await engine.mergeMessage(await createProof("test.eth")); + expect(result).toMatchObject(err({ errCode: "unavailable.network_failure" })); + expect(result._unsafeUnwrapErr().message).toMatch("failed to resolve ens name"); + }); + test("fails gracefully when resolving an unregistered name", async () => { + jest.spyOn(publicClient, "getEnsAddress").mockImplementation(() => { + return Promise.resolve(null); + }); + const result = await engine.mergeMessage(await createProof("akjsdhkhaasd.eth")); + expect(result).toMatchObject(err({ errCode: "bad_request.validation_failure" })); + expect(result._unsafeUnwrapErr().message).toMatch("no valid address for akjsdhkhaasd.eth"); + }); + test("fails when resolved address does not match proof", async () => { + const message = await createProof("test.eth"); + jest.spyOn(publicClient, "getEnsAddress").mockImplementation(() => { + return Promise.resolve(randomEthAddress); + }); + const result = await engine.mergeMessage(message); + expect(result).toMatchObject(err({ errCode: "bad_request.validation_failure" })); + expect(result._unsafeUnwrapErr().message).toMatch(`resolved address ${randomEthAddress} does not match proof`); + }); + test("fails when resolved address does not match custody address or verification address", async () => { + await engine.mergeMessage(verificationAdd); + jest.spyOn(publicClient, "getEnsAddress").mockImplementation(() => { + return Promise.resolve(randomEthAddress); + }); + const message = await createProof("test.eth", null, randomEthAddress); + const result = await engine.mergeMessage(message); + expect(result).toMatchObject(err({ errCode: "bad_request.validation_failure" })); + expect(result._unsafeUnwrapErr().message).toMatch("ens name does not belong to fid"); + }); + test("succeeds for valid proof for custody address", async () => { + const custodyAddress = bytesToHexString(custodyEvent.to)._unsafeUnwrap(); + jest.spyOn(publicClient, "getEnsAddress").mockImplementation(() => { + return Promise.resolve(custodyAddress); + }); + const message = await createProof("test.eth", null, custodyAddress); + const result = await engine.mergeMessage(message); + expect(result.isOk()).toBeTruthy(); + + expect(usernameProofEvents.length).toBe(1); + expect(usernameProofEvents[0]?.usernameProof).toMatchObject(message.data.usernameProofBody); + expect(usernameProofEvents[0]?.deletedUsernameProof).toBeUndefined(); + }); + test("succeeds for valid proof for verified eth address", async () => { + await engine.mergeMessage(verificationAdd); + const verificationAddress = bytesToHexString( + verificationAdd.data.verificationAddEthAddressBody.address, + )._unsafeUnwrap(); + jest.spyOn(publicClient, "getEnsAddress").mockImplementation(() => { + return Promise.resolve(verificationAddress); + }); + const message = await createProof("test.eth", null, verificationAddress); + const result = await engine.mergeMessage(message); + expect(result.isOk()).toBeTruthy(); + + expect(usernameProofEvents.length).toBe(1); + expect(usernameProofEvents[0]?.usernameProof).toMatchObject(message.data.usernameProofBody); + expect(usernameProofEvents[0]?.deletedUsernameProof).toBeUndefined(); + }); + + describe("userDataAdd message with an ens name", () => { + let test1Message: Message; + let userDataAdd: Message; + let userDataAdd2: Message; + beforeEach(async () => { + const custodyAddress = bytesToHexString(custodyEvent.to)._unsafeUnwrap(); + const verificationAddress = bytesToHexString( + verificationAdd.data.verificationAddEthAddressBody.address, + )._unsafeUnwrap(); + + jest.spyOn(publicClient, "getEnsAddress").mockImplementation((opts) => { + if (opts.name === "test.eth") { + return Promise.resolve(custodyAddress); + } else if (opts.name === "test123.eth") { + return Promise.resolve(verificationAddress); + } + return Promise.resolve("0x"); + }); + test1Message = await createProof("test.eth", null, custodyAddress); + const testName = await engine.mergeMessage(test1Message); + expect(testName.isOk()).toBeTruthy(); + + await engine.mergeMessage(verificationAdd); + const test2Name = await engine.mergeMessage(await createProof("test123.eth", null, verificationAddress)); + expect(test2Name.isOk()).toBeTruthy(); + + userDataAdd = await Factories.UserDataAddMessage.create( + { + data: { + fid, + userDataBody: { + type: UserDataType.FNAME, + value: "test.eth", + }, + }, + }, + { transient: { signer } }, + ); + userDataAdd2 = await Factories.UserDataAddMessage.create( + { + data: { + fid, + userDataBody: { + type: UserDataType.FNAME, + value: "test123.eth", + }, + }, + }, + { transient: { signer } }, + ); + }); + + test("succeeds setting name when name is owned by custody address", async () => { + const result = await engine.mergeMessage(userDataAdd); + expect(result.isOk()).toBeTruthy(); + expect((await engine.getUserData(fid, UserDataType.FNAME))._unsafeUnwrap()).toMatchObject(userDataAdd); + }); + test("succeeds setting name when name is owned by verified address", async () => { + const result = await engine.mergeMessage(userDataAdd2); + expect(result.isOk()).toBeTruthy(); + expect((await engine.getUserData(fid, UserDataType.FNAME))._unsafeUnwrap()).toMatchObject(userDataAdd2); + }); + test("fails when custody address no longer owns the ens", async () => { + jest.spyOn(publicClient, "getEnsAddress").mockImplementation(() => { + return Promise.resolve(randomEthAddress); + }); + + const result = await engine.mergeMessage(userDataAdd); + expect(result).toMatchObject(err({ errCode: "bad_request.validation_failure" })); + expect(result._unsafeUnwrapErr().message).toMatch("does not match proof"); + }); + test("fails when verified address no longer owns the ens", async () => { + // Remove the verification + const verificationRemove = await Factories.VerificationRemoveMessage.create( + { + data: { + fid, + timestamp: verificationAdd.data.timestamp + 2, + verificationRemoveBody: { address: verificationAdd.data.verificationAddEthAddressBody.address }, + }, + }, + { transient: { signer } }, + ); + expect(await engine.mergeMessage(verificationRemove)).toMatchObject(ok({})); + const result = await engine.mergeMessage(userDataAdd2); + expect(result).toMatchObject(err({ errCode: "bad_request.validation_failure" })); + expect(result._unsafeUnwrapErr().message).toMatch("ens name does not belong to fid"); + }); + test("fails when unable to resolve ens name", async () => { + jest.spyOn(publicClient, "getEnsAddress").mockImplementation(() => { + throw new Error("Unable to resolve ens name"); + }); + + const result = await engine.mergeMessage(userDataAdd); + expect(result).toMatchObject(err({ errCode: "unavailable.network_failure" })); + expect(result._unsafeUnwrapErr().message).toMatch("failed to resolve ens"); + }); + + test("revokes the user data add when the username proof is revoked", async () => { + const result = await engine.mergeMessage(userDataAdd); + expect(result.isOk()).toBeTruthy(); + expect((await engine.getUserData(fid, UserDataType.FNAME))._unsafeUnwrap()).toMatchObject(userDataAdd); + + jest.spyOn(publicClient, "getEnsAddress").mockImplementation(() => { + return Promise.resolve(randomEthAddress); + }); + const revokeResult = await engine.validateOrRevokeMessage(test1Message); + expect(revokeResult.isOk()).toBeTruthy(); + + expect((await engine.getUserData(fid, UserDataType.FNAME))._unsafeUnwrap()).toMatchObject(userDataAdd); + }); + }); + + describe("validateOrRevokeMessage", () => { + let mergedMessage: Message; + beforeEach(async () => { + const custodyAddress = bytesToHexString(custodyEvent.to)._unsafeUnwrap(); + jest.spyOn(publicClient, "getEnsAddress").mockImplementation(() => { + return Promise.resolve(custodyAddress); + }); + mergedMessage = await createProof("test3.eth", null, custodyAddress); + const result = await engine.mergeMessage(mergedMessage); + expect(result.isOk()).toBeTruthy(); + usernameProofEvents = []; + }); + test("revokes an ens message when ens is no longer valid", async () => { + jest.spyOn(publicClient, "getEnsAddress").mockImplementation(() => { + return Promise.resolve(randomEthAddress); + }); + const result = await engine.validateOrRevokeMessage(mergedMessage); + expect(result.isOk()).toBeTruthy(); + + expect(usernameProofEvents.length).toBe(1); + expect(usernameProofEvents[0]?.deletedUsernameProof).toBeDefined(); + expect(usernameProofEvents[0]?.deletedUsernameProof).toEqual(mergedMessage.data?.usernameProofBody); + expect(usernameProofEvents[0]?.usernameProof).toBeUndefined(); + }); + test("does not revoke a message when address resolution temporarily fails", async () => { + jest.spyOn(publicClient, "getEnsAddress").mockImplementation(() => { + throw new Error("test"); + }); + const result = await engine.validateOrRevokeMessage(mergedMessage); + expect(result._unsafeUnwrapErr().errCode).toEqual("unavailable.network_failure"); + expect(result._unsafeUnwrapErr().message).toMatch("failed to resolve ens name"); + + expect(usernameProofEvents.length).toBe(0); + }); + }); + }); }); describe("mergeMessages", () => { @@ -629,6 +900,7 @@ describe("with listeners and workers", () => { const fname = Factories.Fname.build(); const nameProof = Factories.UserNameProof.build({ name: fname, + fid, owner: custodyEvent.to, }); await expect(liveEngine.mergeUserNameProof(nameProof)).resolves.toBeInstanceOf(Ok); @@ -644,6 +916,7 @@ describe("with listeners and workers", () => { await expect(liveEngine.mergeMessage(fnameAdd)).resolves.toBeInstanceOf(Ok); const nameTransfer = Factories.UserNameProof.build({ name: fname, + fid, owner: Factories.EthAddress.build(), timestamp: nameProof.timestamp + 1, }); diff --git a/apps/hubble/src/storage/engine/index.ts b/apps/hubble/src/storage/engine/index.ts index 634e182eb5..aecd9d5fc5 100644 --- a/apps/hubble/src/storage/engine/index.ts +++ b/apps/hubble/src/storage/engine/index.ts @@ -1,10 +1,12 @@ import { bytesCompare, bytesToHexString, + bytesToUtf8String, CastAddMessage, CastId, CastRemoveMessage, FarcasterNetwork, + hexStringToBytes, HubAsyncResult, HubError, HubEvent, @@ -14,13 +16,14 @@ import { isSignerAddMessage, isSignerRemoveMessage, isUserDataAddMessage, + isUsernameProofMessage, LinkAddMessage, LinkRemoveMessage, MergeIdRegistryEventHubEvent, MergeMessageHubEvent, + MergeUsernameProofHubEvent, Message, NameRegistryEvent, - UserNameProof, NameRegistryEventType, PruneMessageHubEvent, ReactionAddMessage, @@ -32,11 +35,12 @@ import { SignerRemoveMessage, UserDataAddMessage, UserDataType, + UserNameProof, + UserNameType, utf8StringToBytes, validations, VerificationAddEthAddressMessage, VerificationRemoveMessage, - MergeUsernameProofHubEvent, } from "@farcaster/hub-nodejs"; import { err, ok, Result, ResultAsync } from "neverthrow"; import fs from "fs"; @@ -54,8 +58,10 @@ import UserDataStore from "../stores/userDataStore.js"; import VerificationStore from "../stores/verificationStore.js"; import { logger } from "../../utils/logger.js"; import { RevokeMessagesBySignerJobQueue, RevokeMessagesBySignerJobWorker } from "../jobs/revokeMessagesBySignerJob.js"; -import { getIdRegistryEventByCustodyAddress } from "../db/idRegistryEvent.js"; import { ensureAboveTargetFarcasterVersion } from "../../utils/versions.js"; +import { PublicClient } from "viem"; +import { normalize } from "viem/ens"; +import UsernameProofStore from "../stores/usernameProofStore.js"; const log = logger.child({ component: "Engine", @@ -66,6 +72,7 @@ class Engine { private _db: RocksDB; private _network: FarcasterNetwork; + private _publicClient: PublicClient | undefined; private _linkStore: LinkStore; private _reactionStore: ReactionStore; @@ -73,6 +80,7 @@ class Engine { private _castStore: CastStore; private _userDataStore: UserDataStore; private _verificationStore: VerificationStore; + private _usernameProofStore: UsernameProofStore; private _validationWorker: Worker | undefined; private _validationWorkerJobId = 0; @@ -81,9 +89,10 @@ class Engine { private _revokeSignerQueue: RevokeMessagesBySignerJobQueue; private _revokeSignerWorker: RevokeMessagesBySignerJobWorker; - constructor(db: RocksDB, network: FarcasterNetwork, eventHandler?: StoreEventHandler) { + constructor(db: RocksDB, network: FarcasterNetwork, eventHandler?: StoreEventHandler, publicClient?: PublicClient) { this._db = db; this._network = network; + this._publicClient = publicClient; this.eventHandler = eventHandler ?? new StoreEventHandler(db); @@ -93,6 +102,7 @@ class Engine { this._castStore = new CastStore(db, this.eventHandler); this._userDataStore = new UserDataStore(db, this.eventHandler); this._verificationStore = new VerificationStore(db, this.eventHandler); + this._usernameProofStore = new UsernameProofStore(db, this.eventHandler); this._revokeSignerQueue = new RevokeMessagesBySignerJobQueue(db); this._revokeSignerWorker = new RevokeMessagesBySignerJobWorker(this._revokeSignerQueue, db, this); @@ -204,6 +214,9 @@ class Engine { case UserPostfix.VerificationMessage: { return ResultAsync.fromPromise(this._verificationStore.merge(message), (e) => e as HubError); } + case UserPostfix.UsernameProofMessage: { + return ResultAsync.fromPromise(this._usernameProofStore.merge(message), (e) => e as HubError); + } default: { return err(new HubError("bad_request.validation_failure", "invalid message type")); } @@ -273,6 +286,9 @@ class Engine { case UserPostfix.VerificationMessage: { return this._verificationStore.revoke(message.value); } + case UserPostfix.UsernameProofMessage: { + return this._usernameProofStore.revoke(message.value); + } default: { return err(new HubError("bad_request.invalid_param", "invalid message type")); } @@ -362,6 +378,13 @@ class Engine { case UserPostfix.VerificationMessage: { return this._verificationStore.revoke(message); } + case UserPostfix.UsernameProofMessage: { + if (isValid.error.errCode === "unavailable.network_failure") { + return err(isValid.error); + } else { + return this._usernameProofStore.revoke(message); + } + } default: { return err(new HubError("bad_request.invalid_param", "invalid message type")); } @@ -628,12 +651,38 @@ class Engine { } async getUserNameProof(name: Uint8Array): HubAsyncResult { - const validatedFname = validations.validateFname(name); - if (validatedFname.isErr()) { - return err(validatedFname.error); + const nameString = bytesToUtf8String(name); + if (nameString.isErr()) { + return err(nameString.error); } + if (nameString.value.endsWith(".eth")) { + const validatedEnsName = validations.validateEnsName(name); + if (validatedEnsName.isErr()) { + return err(validatedEnsName.error); + } + return ResultAsync.fromPromise( + this._usernameProofStore.getUsernameProof(name, UserNameType.USERNAME_TYPE_ENS_L1).then((proof) => { + return proof.data.usernameProofBody; + }), + (e) => e as HubError, + ); + } else { + const validatedFname = validations.validateFname(name); + if (validatedFname.isErr()) { + return err(validatedFname.error); + } - return ResultAsync.fromPromise(this._userDataStore.getUserNameProof(name), (e) => e as HubError); + return ResultAsync.fromPromise(this._userDataStore.getUserNameProof(name), (e) => e as HubError); + } + } + + async getUserNameProofsByFid(fid: number): HubAsyncResult { + const validatedFid = validations.validateFid(fid); + if (validatedFid.isErr()) { + return err(validatedFid.error); + } + + return ResultAsync.fromPromise(this._usernameProofStore.getUsernameProofsByFid(fid), (e) => e as HubError); } /* -------------------------------------------------------------------------- */ @@ -796,24 +845,41 @@ class Engine { return err(nameProof.error); } - // Check that the custody address for the fname and fid are the same - if (bytesCompare(custodyEvent.value.to, nameProof.value.owner) !== 0) { - const hex = Result.combine([ - bytesToHexString(custodyEvent.value.to), - bytesToHexString(nameProof.value.owner), - ]); - return hex.andThen(([custodySignerHex, fnameOwnerHex]) => { - return err( - new HubError( - "bad_request.validation_failure", - `fname custody address ${fnameOwnerHex} does not match custody address ${custodySignerHex} for fid ${message.data.fid}`, - ), - ); - }); + if (nameProof.value.type === UserNameType.USERNAME_TYPE_FNAME) { + // Check that the custody address for the fname and fid are the same + if (bytesCompare(custodyEvent.value.to, nameProof.value.owner) !== 0) { + const hex = Result.combine([ + bytesToHexString(custodyEvent.value.to), + bytesToHexString(nameProof.value.owner), + ]); + return hex.andThen(([custodySignerHex, fnameOwnerHex]) => { + return err( + new HubError( + "bad_request.validation_failure", + `fname custody address ${fnameOwnerHex} does not match custody address ${custodySignerHex} for fid ${message.data.fid}`, + ), + ); + }); + } + } else if (nameProof.value.type === UserNameType.USERNAME_TYPE_ENS_L1) { + const result = await this.validateEnsUsernameProof(nameProof.value, custodyEvent.value.to); + if (result.isErr()) { + return err(result.error); + } + } else { + return err(new HubError("bad_request.validation_failure", "invalid username type")); } } } + // For username proof messages, make sure the name resolves to the users custody address or a connected address actually owns the ens name + if (isUsernameProofMessage(message) && message.data.usernameProofBody.type === UserNameType.USERNAME_TYPE_ENS_L1) { + const result = await this.validateEnsUsernameProof(message.data.usernameProofBody, custodyEvent.value.to); + if (result.isErr()) { + return err(result.error); + } + } + // 6. Check message body and envelope if (this._validationWorker) { return new Promise>((resolve) => { @@ -827,6 +893,45 @@ class Engine { } } + private async validateEnsUsernameProof( + nameProof: UserNameProof, + custodyAddress: Uint8Array, + ): HubAsyncResult { + const nameResult = bytesToUtf8String(nameProof.name); + if (nameResult.isErr() || !nameResult.value.endsWith(".eth")) { + return err(new HubError("bad_request.validation_failure", `invalid ens name: ${nameProof.name}`)); + } + let resolvedAddress; + let resolvedAddressString; + try { + resolvedAddressString = await this._publicClient?.getEnsAddress({ name: normalize(nameResult.value) }); + const resolvedAddressBytes = hexStringToBytes(resolvedAddressString || ""); + if (resolvedAddressBytes.isErr() || resolvedAddressBytes.value.length === 0) { + return err(new HubError("bad_request.validation_failure", `no valid address for ${nameResult.value}`)); + } + resolvedAddress = resolvedAddressBytes.value; + } catch (e) { + return err(new HubError("unavailable.network_failure", `failed to resolve ens name ${nameResult.value}: ${e}`)); + } + + if (bytesCompare(resolvedAddress, nameProof.owner) !== 0) { + return err( + new HubError( + "bad_request.validation_failure", + `resolved address ${resolvedAddressString} does not match proof`, + ), + ); + } + // If resolved address does not match custody address then check if we have an eth verification for it + if (bytesCompare(resolvedAddress, custodyAddress) !== 0) { + const verificationResult = await this.getVerification(nameProof.fid, resolvedAddress); + if (verificationResult.isErr()) { + return err(new HubError("bad_request.validation_failure", `ens name does not belong to fid: ${nameProof.fid}`)); + } + } + return ok(undefined); + } + private async handleMergeIdRegistryEvent(event: MergeIdRegistryEventHubEvent): HubAsyncResult { const { idRegistryEvent } = event.mergeIdRegistryEventBody; const fromAddress = idRegistryEvent.from; @@ -879,37 +984,27 @@ class Engine { // When there is a UserNameProof, we need to check if we need to revoke UserDataAdd messages from the // previous owner of the name. if (deletedUsernameProof && deletedUsernameProof.owner.length > 0) { - // Check to see if the from address has an fid - const idRegistryEvent = await ResultAsync.fromPromise( - getIdRegistryEventByCustodyAddress(this._db, deletedUsernameProof.owner), + const fid = deletedUsernameProof.fid; + + // Check if this fid assigned the fname with a UserDataAdd message + const fnameAdd = await ResultAsync.fromPromise( + this._userDataStore.getUserDataAdd(fid, UserDataType.FNAME), () => undefined, ); - - if (idRegistryEvent.isOk()) { - const { fid } = idRegistryEvent.value; - - // Check if this fid assigned the fname with a UserDataAdd message - const fnameAdd = await ResultAsync.fromPromise( - this._userDataStore.getUserDataAdd(fid, UserDataType.FNAME), - () => undefined, + if (fnameAdd.isOk()) { + const revokeResult = await this._userDataStore.revoke(fnameAdd.value); + const fnameAddHex = bytesToHexString(fnameAdd.value.hash); + revokeResult.match( + () => + log.info(`revoked message ${fnameAddHex._unsafeUnwrap()} for fid ${fid} due to name proof invalidation`), + (e) => + log.error( + { errCode: e.errCode }, + `failed to revoke message ${fnameAddHex._unsafeUnwrap()} for fid ${fid} due to name proof invalidation: ${ + e.message + }`, + ), ); - if (fnameAdd.isOk()) { - const revokeResult = await this._userDataStore.revoke(fnameAdd.value); - const fnameAddHex = bytesToHexString(fnameAdd.value.hash); - revokeResult.match( - () => - log.info( - `revoked message ${fnameAddHex._unsafeUnwrap()} for fid ${fid} due to NameRegistryEvent transfer`, - ), - (e) => - log.error( - { errCode: e.errCode }, - `failed to revoke message ${fnameAddHex._unsafeUnwrap()} for fid ${fid} due to NameRegistryEvent transfer: ${ - e.message - }`, - ), - ); - } } } diff --git a/apps/hubble/src/storage/stores/storageCache.ts b/apps/hubble/src/storage/stores/storageCache.ts index 7ca899330b..306d156ec3 100644 --- a/apps/hubble/src/storage/stores/storageCache.ts +++ b/apps/hubble/src/storage/stores/storageCache.ts @@ -3,8 +3,10 @@ import { HubEvent, HubResult, isMergeMessageHubEvent, + isMergeUsernameProofHubEvent, isPruneMessageHubEvent, isRevokeMessageHubEvent, + isUsernameProofMessage, Message, } from "@farcaster/hub-nodejs"; import { err, ok } from "neverthrow"; @@ -117,6 +119,12 @@ export class StorageCache { this.removeMessage(event.pruneMessageBody.message); } else if (isRevokeMessageHubEvent(event)) { this.removeMessage(event.revokeMessageBody.message); + } else if (isMergeUsernameProofHubEvent(event)) { + if (event.mergeUsernameProofBody.usernameProofMessage) { + this.addMessage(event.mergeUsernameProofBody.usernameProofMessage); + } else if (event.mergeUsernameProofBody.deletedUsernameProofMessage) { + this.removeMessage(event.mergeUsernameProofBody.deletedUsernameProofMessage); + } } return ok(undefined); } diff --git a/apps/hubble/src/storage/stores/store.ts b/apps/hubble/src/storage/stores/store.ts index cbe3f4f291..d6cb390efb 100644 --- a/apps/hubble/src/storage/stores/store.ts +++ b/apps/hubble/src/storage/stores/store.ts @@ -237,10 +237,7 @@ export abstract class Store { return err(new HubError("bad_request.invalid_param", "invalid message type")); } - return this._eventHandler.commitTransaction(txn, { - type: HubEventType.REVOKE_MESSAGE, - revokeMessageBody: { message }, - }); + return this._eventHandler.commitTransaction(txn, this.revokeEventArgs(message)); } async pruneMessages(fid: number): HubAsyncResult { @@ -303,10 +300,7 @@ export abstract class Store { return err(new HubError("unknown", "invalid message type")); } - return this._eventHandler.commitTransaction(txn, { - type: HubEventType.PRUNE_MESSAGE, - pruneMessageBody: { message: nextMessage.value }, - }); + return this._eventHandler.commitTransaction(txn, this.pruneEventArgs(nextMessage.value)); }; let pruneResult = await pruneNextMessage(); @@ -346,6 +340,25 @@ export abstract class Store { return undefined; } + protected mergeEventArgs(mergedMessage: TAdd | TRemove, mergeConflicts: (TAdd | TRemove)[]): HubEventArgs { + return { + type: HubEventType.MERGE_MESSAGE, + mergeMessageBody: { message: mergedMessage, deletedMessages: mergeConflicts }, + }; + } + protected revokeEventArgs(message: TAdd | TRemove): HubEventArgs { + return { + type: HubEventType.REVOKE_MESSAGE, + revokeMessageBody: { message }, + }; + } + protected pruneEventArgs(prunedMessage: TAdd | TRemove): HubEventArgs { + return { + type: HubEventType.PRUNE_MESSAGE, + pruneMessageBody: { message: prunedMessage }, + }; + } + protected async getBySecondaryIndex(prefix: Buffer, pageOptions: PageOptions = {}): Promise> { const iterator = getPageIteratorByPrefix(this._db, prefix, pageOptions); @@ -407,13 +420,8 @@ export abstract class Store { txn = addTxn.value; - const hubEvent: HubEventArgs = { - type: HubEventType.MERGE_MESSAGE, - mergeMessageBody: { message, deletedMessages: mergeConflicts.value }, - }; - // Commit the RocksDB transaction - const result = await this._eventHandler.commitTransaction(txn, hubEvent); + const result = await this._eventHandler.commitTransaction(txn, this.mergeEventArgs(message, mergeConflicts.value)); if (result.isErr()) { throw result.error; } @@ -438,13 +446,8 @@ export abstract class Store { txn = txnRemove.value; - const hubEvent: HubEventArgs = { - type: HubEventType.MERGE_MESSAGE, - mergeMessageBody: { message, deletedMessages: mergeConflicts.value }, - }; - // Commit the RocksDB transaction - const result = await this._eventHandler.commitTransaction(txn, hubEvent); + const result = await this._eventHandler.commitTransaction(txn, this.mergeEventArgs(message, mergeConflicts.value)); if (result.isErr()) { throw result.error; } @@ -475,7 +478,7 @@ export abstract class Store { * * @returns a RocksDB transaction if keys must be added or removed, undefined otherwise */ - private async getMergeConflicts(message: TAdd | TRemove): HubAsyncResult<(TAdd | TRemove)[]> { + protected async getMergeConflicts(message: TAdd | TRemove): HubAsyncResult<(TAdd | TRemove)[]> { const validateResult = await (this._isAddType(message) ? this.validateAdd(message) : this.validateRemove(message)); if (validateResult.isErr()) { diff --git a/apps/hubble/src/storage/stores/storeEventHandler.ts b/apps/hubble/src/storage/stores/storeEventHandler.ts index e3898529e4..53176ba193 100644 --- a/apps/hubble/src/storage/stores/storeEventHandler.ts +++ b/apps/hubble/src/storage/stores/storeEventHandler.ts @@ -17,6 +17,7 @@ import { MergeUsernameProofHubEvent, PruneMessageHubEvent, RevokeMessageHubEvent, + MessageType, } from "@farcaster/hub-nodejs"; import AsyncLock from "async-lock"; import { err, ok, ResultAsync } from "neverthrow"; diff --git a/apps/hubble/src/storage/stores/userDataStore.ts b/apps/hubble/src/storage/stores/userDataStore.ts index df287fc963..7de2f16ebb 100644 --- a/apps/hubble/src/storage/stores/userDataStore.ts +++ b/apps/hubble/src/storage/stores/userDataStore.ts @@ -155,6 +155,8 @@ class UserDataStore extends Store { mergeUsernameProofBody: { usernameProof: usernameProof, deletedUsernameProof: existingProof.isOk() ? existingProof.value : undefined, + usernameProofMessage: undefined, + deletedUsernameProofMessage: undefined, }, }); diff --git a/apps/hubble/src/storage/stores/usernameProofStore.test.ts b/apps/hubble/src/storage/stores/usernameProofStore.test.ts new file mode 100644 index 0000000000..c0f552195f --- /dev/null +++ b/apps/hubble/src/storage/stores/usernameProofStore.test.ts @@ -0,0 +1,225 @@ +import { jestRocksDB } from "../db/jestUtils.js"; +import StoreEventHandler from "./storeEventHandler.js"; +import { + Factories, + getFarcasterTime, + HubError, + MergeUsernameProofHubEvent, + MessageType, + UserNameProof, + UsernameProofMessage, + UserNameType, +} from "@farcaster/hub-nodejs"; +import UsernameProofStore from "./usernameProofStore.js"; + +const db = jestRocksDB("protobufs.usernameProofSet.test"); +const eventHandler = new StoreEventHandler(db); +const set = new UsernameProofStore(db, eventHandler); +const fid = Factories.Fid.build(); + +describe("usernameProofStore", () => { + let ensProof: UsernameProofMessage; + let fname: Uint8Array; + let currentFarcasterTime: number; + + const buildProof = async ( + fid: number, + name: Uint8Array, + timestamp: number, + type: UserNameType, + ): Promise => { + return await Factories.UsernameProofMessage.create({ + data: { + fid, + usernameProofBody: Factories.UserNameProof.build({ + name, + fid, + timestamp, + type, + }), + timestamp: timestamp, + type: MessageType.USERNAME_PROOF, + }, + }); + }; + + beforeAll(async () => { + fname = Factories.Fname.build(); + currentFarcasterTime = getFarcasterTime()._unsafeUnwrap(); + ensProof = await buildProof(fid, fname, currentFarcasterTime, UserNameType.USERNAME_TYPE_ENS_L1); + }); + + beforeEach(async () => { + await eventHandler.syncCache(); + }); + + describe("merge", () => { + test("should merge valid proofs", async () => { + await set.merge(ensProof); + const proof = await set.getUsernameProof(fname, UserNameType.USERNAME_TYPE_ENS_L1); + expect(proof).toEqual(ensProof); + }); + + test("replaces existing proof for name if timestamp is newer", async () => { + await set.merge(ensProof); + + const newProof = await buildProof(fid, fname, currentFarcasterTime + 10, UserNameType.USERNAME_TYPE_ENS_L1); + expect(newProof).not.toEqual(ensProof); + await set.merge(newProof); + + const proof = await set.getUsernameProof(fname, UserNameType.USERNAME_TYPE_ENS_L1); + expect(proof).toEqual(newProof); + + const rawProof = await set.getAdd({ data: { fid, usernameProofBody: { name: fname } } }); + expect(rawProof).toEqual(newProof); + }); + + test("replaces existing proof for name even if fid is different if timestamp is newer", async () => { + await set.merge(ensProof); + + const newFid = Factories.Fid.build(); + const newProof = await buildProof(newFid, fname, currentFarcasterTime + 10, UserNameType.USERNAME_TYPE_ENS_L1); + expect(newProof).not.toEqual(ensProof); + await set.merge(newProof); + + const proof = await set.getUsernameProof(fname, UserNameType.USERNAME_TYPE_ENS_L1); + expect(proof).toEqual(newProof); + + await expect(set.getAdd({ data: { fid, usernameProofBody: { name: fname } } })).rejects.toThrowError("NotFound"); + }); + + test("does not replace existing proof for name if timestamp is older", async () => { + await set.merge(ensProof); + + const newFid = Factories.Fid.build(); + const newProof = await buildProof(newFid, fname, currentFarcasterTime - 10, UserNameType.USERNAME_TYPE_ENS_L1); + await expect(set.merge(newProof)).rejects.toThrowError("message conflicts with a more recent add"); + + const newProofOldFid = await buildProof(fid, fname, currentFarcasterTime - 10, UserNameType.USERNAME_TYPE_ENS_L1); + await expect(set.merge(newProofOldFid)).rejects.toThrowError("message conflicts with a more recent add"); + + const proof = await set.getUsernameProof(fname, UserNameType.USERNAME_TYPE_ENS_L1); + expect(proof).toEqual(ensProof); + }); + + test("does not merge duplicates", async () => { + await set.merge(ensProof); + await expect(set.merge(ensProof)).rejects.toThrowError("message has already been merged"); + }); + }); + + describe("getUsernameProof", () => { + test("fails if not found", async () => { + await expect(set.getUsernameProof(fname, UserNameType.USERNAME_TYPE_ENS_L1)).rejects.toThrowError("NotFound"); + }); + }); + + describe("getUsernameProofsByFid", () => { + test("should return empty array if no proofs", async () => { + expect(await set.getUsernameProofsByFid(fid)).toEqual([]); + }); + test("should return all proofs for fid", async () => { + const anotherFid = Factories.Fid.build(); + const proof1 = await Factories.UsernameProofMessage.create({ data: { fid } }); + const proof2 = await Factories.UsernameProofMessage.create({ data: { fid } }); + const proofAnotherFid = await Factories.UsernameProofMessage.create({ data: { fid: anotherFid } }); + await set.merge(proof1); + await set.merge(proof2); + await set.merge(proofAnotherFid); + + const proofsForFid = await set.getUsernameProofsByFid(fid); + expect(proofsForFid).toHaveLength(2); + expect(proofsForFid).toContainEqual(proof1.data.usernameProofBody); + expect(proofsForFid).toContainEqual(proof2.data.usernameProofBody); + expect(await set.getUsernameProofsByFid(anotherFid)).toEqual([proofAnotherFid.data.usernameProofBody]); + }); + }); + + describe("pruneMessages", () => { + let prunedMessages: UserNameProof[]; + let addedMessages: UserNameProof[]; + const pruneMessageListener = (event: MergeUsernameProofHubEvent) => { + if (event.mergeUsernameProofBody.deletedUsernameProof) { + prunedMessages.push(event.mergeUsernameProofBody.deletedUsernameProof); + } else if (event.mergeUsernameProofBody.usernameProof) { + addedMessages.push(event.mergeUsernameProofBody.usernameProof); + } + }; + + beforeAll(() => { + eventHandler.on("mergeUsernameProofEvent", pruneMessageListener); + }); + + beforeEach(() => { + prunedMessages = []; + addedMessages = []; + }); + + afterAll(() => { + eventHandler.off("mergeUsernameProofEvent", pruneMessageListener); + }); + + let add1: UsernameProofMessage; + let add2: UsernameProofMessage; + let add3: UsernameProofMessage; + let add4: UsernameProofMessage; + let addOld1: UsernameProofMessage; + + const generateAddWithTimestamp = async (fid: number, timestamp: number): Promise => { + return Factories.UsernameProofMessage.create({ data: { fid, timestamp } }); + }; + + beforeAll(async () => { + const time = getFarcasterTime()._unsafeUnwrap() - 10; + add1 = await generateAddWithTimestamp(fid, time + 1); + add2 = await generateAddWithTimestamp(fid, time + 2); + add3 = await generateAddWithTimestamp(fid, time + 3); + add4 = await generateAddWithTimestamp(fid, time + 5); + addOld1 = await generateAddWithTimestamp(fid, time - 60 * 60); + }); + + describe("with size limit", () => { + const sizePrunedStore = new UsernameProofStore(db, eventHandler, { pruneSizeLimit: 2 }); + + test("defaults size limit", async () => { + expect(set.pruneSizeLimit).toEqual(10); + expect(set.pruneTimeLimit).toBeUndefined(); + }); + + test("no-ops when no messages have been merged", async () => { + const result = await sizePrunedStore.pruneMessages(fid); + expect(result._unsafeUnwrap()).toEqual([]); + expect(prunedMessages).toEqual([]); + }); + + test("prunes earliest add messages", async () => { + const messages = [add1, add2, add3, add4]; + for (const message of messages) { + await sizePrunedStore.merge(message); + } + + const result = await sizePrunedStore.pruneMessages(fid); + expect(result.isOk()).toBeTruthy(); + + expect(prunedMessages).toEqual([add1.data.usernameProofBody, add2.data.usernameProofBody]); + + for (const message of prunedMessages) { + const getAdd = () => sizePrunedStore.getUsernameProof(message.name, message.type); + await expect(getAdd()).rejects.toThrow(HubError); + } + }); + + test("fails to add messages older than the earliest message", async () => { + const messages = [add1, add2, add3]; + for (const message of messages) { + await sizePrunedStore.merge(message); + } + + // Older messages are rejected + await expect(sizePrunedStore.merge(addOld1)).rejects.toEqual( + new HubError("bad_request.prunable", "message would be pruned"), + ); + }); + }); + }); +}); diff --git a/apps/hubble/src/storage/stores/usernameProofStore.ts b/apps/hubble/src/storage/stores/usernameProofStore.ts new file mode 100644 index 0000000000..ab9b1c59db --- /dev/null +++ b/apps/hubble/src/storage/stores/usernameProofStore.ts @@ -0,0 +1,216 @@ +import { + HubAsyncResult, + HubError, + HubEventType, + isUsernameProofMessage, + MessageType, + UserNameProof, + UsernameProofMessage, + UserNameType, +} from "@farcaster/hub-nodejs"; +import { err, ok, ResultAsync } from "neverthrow"; +import { RootPrefix, UserMessagePostfix, UserPostfix } from "../db/types.js"; +import { Store } from "./store.js"; +import { Transaction } from "../db/rocksdb.js"; +import { makeFidKey, makeTsHash, makeUserKey, readFidKey } from "../db/message.js"; +import { HubEventArgs } from "./storeEventHandler.js"; + +const PRUNE_SIZE_LIMIT_DEFAULT = 10; + +/** + * Generates a unique key used to store a UsernameProof Message + * + * @param fid the fid of the user who created the link + * @param name + * @returns RocksDB index key of the form :: + */ +const makeUserNameProofByFidKey = (fid: number, name: Uint8Array): Buffer => { + return Buffer.concat([makeUserKey(fid), Buffer.from([UserPostfix.UsernameProofMessage]), Buffer.from(name)]); +}; + +const makeUserNameProofByNameKey = (name: Uint8Array): Buffer => { + return Buffer.concat([Buffer.from([RootPrefix.UserNameProofByName]), Buffer.from(name)]); +}; + +class UsernameProofStore extends Store { + override _postfix: UserMessagePostfix = UserPostfix.UsernameProofMessage; + + override makeAddKey(msg: UsernameProofMessage) { + return makeUserNameProofByFidKey(msg.data.fid, msg.data.usernameProofBody.name) as Buffer; + } + + override makeRemoveKey(_: never): Buffer { + throw new Error("removes not supported"); + } + + override async findMergeAddConflicts(_message: UsernameProofMessage): HubAsyncResult { + return ok(undefined); + } + + override async findMergeRemoveConflicts(_message: never): HubAsyncResult { + throw new Error("removes not supported"); + } + + override _isAddType = isUsernameProofMessage; + override _isRemoveType = undefined; + override _addMessageType = MessageType.USERNAME_PROOF; + override _removeMessageType = undefined; + + protected override get PRUNE_SIZE_LIMIT_DEFAULT() { + return PRUNE_SIZE_LIMIT_DEFAULT; + } + + /** + * Finds a UserNameProof Message by checking the adds set index + * + * @returns the UsernameProof message if it exists, undefined otherwise + * @param name the name to find + * @param type the type of the name to find (fname or ens) + */ + async getUsernameProof(name: Uint8Array, type: UserNameType): Promise { + if (type === UserNameType.USERNAME_TYPE_ENS_L1) { + const byNameKey = makeUserNameProofByNameKey(name); + const fid = readFidKey(await this._db.get(byNameKey)); + if (fid === undefined) { + throw new HubError("not_found", `username proof not found for name: ${name.toString()}`); + } + return this.getAdd({ data: { fid, usernameProofBody: { name: name } } }); + } + throw new HubError("bad_request", `unsupported username type: ${type}`); + } + + /** Finds all UserNameProof messages for an fid */ + async getUsernameProofsByFid(fid: number): Promise { + const proofMessages = await this.getAddsByFid({ data: { fid } }, { pageSize: 25 }); + const result: UserNameProof[] = []; + for (const proofMessage of proofMessages.messages) { + result.push(proofMessage.data.usernameProofBody); + } + return result; + } + + override async buildSecondaryIndices(txn: Transaction, message: UsernameProofMessage): HubAsyncResult { + const tsHash = makeTsHash(message.data.timestamp, message.hash); + + if (tsHash.isErr()) { + return err(tsHash.error); + } + + const name = message.data.usernameProofBody.name; + + if (name.length === 0) { + return err(new HubError("bad_request.invalid_param", "name empty")); + } + + // Puts the fid into the byTarget index + const byNameKey = makeUserNameProofByNameKey(name); + txn.put(byNameKey, makeFidKey(message.data.fid)); + + return ok(undefined); + } + override async deleteSecondaryIndices(txn: Transaction, message: UsernameProofMessage): HubAsyncResult { + const name = message.data.usernameProofBody.name; + + if (name.length === 0) { + return err(new HubError("bad_request.invalid_param", "name empty")); + } + + // Delete the message key from byName index + const byNameKey = makeUserNameProofByNameKey(name); + txn.del(byNameKey); + + return ok(undefined); + } + + override async getMergeConflicts(message: UsernameProofMessage): HubAsyncResult { + const validateResult = await this.validateAdd(message); + + if (validateResult.isErr()) { + return err(validateResult.error); + } + + const checkResult = await this.findMergeAddConflicts(message); + + if (checkResult.isErr()) { + return err(checkResult.error); + } + + const conflicts: UsernameProofMessage[] = []; + + const byNameKey = makeUserNameProofByNameKey(message.data.usernameProofBody.name); + const fidResult = await ResultAsync.fromPromise(this._db.get(byNameKey), () => undefined); + if (fidResult.isOk()) { + const fid = readFidKey(fidResult.value); + if (fid !== undefined) { + const existingMessage = await this.getAdd({ + data: { + fid, + usernameProofBody: { name: message.data.usernameProofBody.name }, + }, + }); + const tsHash = makeTsHash(message.data.timestamp, message.hash); + const existingTsHash = makeTsHash(existingMessage.data.timestamp, existingMessage.hash); + + if (tsHash.isErr() || existingTsHash.isErr()) { + throw new HubError("bad_request", "failed to make tsHash"); + } + + const messageCompare = this.messageCompare( + this._addMessageType, + existingTsHash.value, + this._addMessageType, + tsHash.value, + ); + if (messageCompare > 0) { + return err(new HubError("bad_request.conflict", "message conflicts with a more recent add")); + } else if (messageCompare === 0) { + return err(new HubError("bad_request.duplicate", "message has already been merged")); + } else { + conflicts.push(existingMessage); + } + } + } + return ok(conflicts); + } + + protected override mergeEventArgs( + mergedMessage: UsernameProofMessage, + mergeConflicts: UsernameProofMessage[], + ): HubEventArgs { + return { + type: HubEventType.MERGE_USERNAME_PROOF, + mergeUsernameProofBody: { + usernameProof: mergedMessage.data.usernameProofBody, + deletedUsernameProof: mergeConflicts[0]?.data.usernameProofBody, + usernameProofMessage: mergedMessage, + deletedUsernameProofMessage: mergeConflicts[0], + }, + }; + } + + protected override pruneEventArgs(prunedMessage: UsernameProofMessage): HubEventArgs { + return { + type: HubEventType.MERGE_USERNAME_PROOF, + mergeUsernameProofBody: { + usernameProof: undefined, + deletedUsernameProof: prunedMessage.data.usernameProofBody, + usernameProofMessage: undefined, + deletedUsernameProofMessage: prunedMessage, + }, + }; + } + + protected override revokeEventArgs(message: UsernameProofMessage): HubEventArgs { + return { + type: HubEventType.MERGE_USERNAME_PROOF, + mergeUsernameProofBody: { + usernameProof: undefined, + deletedUsernameProof: message.data.usernameProofBody, + usernameProofMessage: undefined, + deletedUsernameProofMessage: message, + }, + }; + } +} + +export default UsernameProofStore; diff --git a/docker-compose-multinode.yml b/docker-compose-multinode.yml index 7a348c12bf..d2f2999d13 100644 --- a/docker-compose-multinode.yml +++ b/docker-compose-multinode.yml @@ -29,6 +29,8 @@ services: "2283", "--eth-rpc-url", "$ETH_RPC_URL", + "--eth-mainnet-rpc-url", + "$ETH_MAINNET_RPC_URL", "--network", "3", "--db-name", @@ -60,6 +62,8 @@ services: "2285", "--eth-rpc-url", "$ETH_RPC_URL", + "--eth-mainnet-rpc-url", + "$ETH_MAINNET_RPC_URL", "--network", "3", "-b", diff --git a/packages/core/src/factories.ts b/packages/core/src/factories.ts index 3eecbf4c95..03a9f73f0e 100644 --- a/packages/core/src/factories.ts +++ b/packages/core/src/factories.ts @@ -5,11 +5,12 @@ import { blake3 } from "@noble/hashes/blake3"; import { generatePrivateKey, privateKeyToAccount } from "viem/accounts"; import { randomBytes } from "@noble/hashes/utils"; import * as protobufs from "./protobufs"; -import { bytesToHexString } from "./bytes"; +import { bytesToHexString, utf8StringToBytes } from "./bytes"; import { Ed25519Signer, Eip712Signer, NobleEd25519Signer, ViemLocalEip712Signer, Signer } from "./signers"; -import { getFarcasterTime } from "./time"; +import { getFarcasterTime, toFarcasterTime } from "./time"; import { VerificationEthAddressClaim } from "./verifications"; import { LocalAccount } from "viem"; +import { UserNameType } from "./protobufs"; /** Scalars */ @@ -58,6 +59,11 @@ const FnameFactory = Factory.define(() => { return bytes; }); +const EnsNameFactory = Factory.define(() => { + const ensName = faker.random.alphaNumeric(faker.datatype.number({ min: 3, max: 16 })); + return utf8StringToBytes(ensName.concat(".eth"))._unsafeUnwrap(); +}); + /** Eth */ const BlockHashFactory = Factory.define(() => { @@ -546,6 +552,32 @@ const UserDataAddMessageFactory = Factory.define(() => { + const proofBody = UserNameProofFactory.build({ + type: UserNameType.USERNAME_TYPE_ENS_L1, + name: EnsNameFactory.build(), + }); + return MessageDataFactory.build({ + usernameProofBody: proofBody, + type: protobufs.MessageType.USERNAME_PROOF, + timestamp: toFarcasterTime(proofBody.timestamp)._unsafeUnwrap(), + fid: proofBody.fid, + }) as protobufs.UsernameProofData; +}); + +const UsernameProofMessageFactory = Factory.define( + ({ onCreate, transientParams }) => { + onCreate((message) => { + return MessageFactory.create(message, { transient: transientParams }) as Promise; + }); + + return MessageFactory.build( + { data: UsernameProofDataFactory.build(), signatureScheme: protobufs.SignatureScheme.ED25519 }, + { transient: transientParams }, + ) as protobufs.UsernameProofMessage; + }, +); + /** Contract event Protobufs */ const IdRegistryEventTypeFactory = Factory.define(() => { @@ -601,6 +633,7 @@ export const Factories = { MessageHash: MessageHashFactory, BlockHash: BlockHashFactory, EthAddress: EthAddressFactory, + EnsName: EnsNameFactory, TransactionHash: TransactionHashFactory, Ed25519PrivateKey: Ed25519PrivateKeyFactory, Ed25519PPublicKey: Ed25519PPublicKeyFactory, @@ -654,4 +687,6 @@ export const Factories = { NameRegistryEventType: NameRegistryEventTypeFactory, NameRegistryEvent: NameRegistryEventFactory, UserNameProof: UserNameProofFactory, + UsernameProofData: UsernameProofDataFactory, + UsernameProofMessage: UsernameProofMessageFactory, }; diff --git a/packages/core/src/protobufs/generated/hub_event.ts b/packages/core/src/protobufs/generated/hub_event.ts index 47a01a8f18..8e0c1d5dca 100644 --- a/packages/core/src/protobufs/generated/hub_event.ts +++ b/packages/core/src/protobufs/generated/hub_event.ts @@ -1,10 +1,10 @@ /* eslint-disable */ -import Long from 'long'; -import _m0 from 'protobufjs/minimal'; -import { IdRegistryEvent } from './id_registry_event'; -import { Message } from './message'; -import { NameRegistryEvent } from './name_registry_event'; -import { UserNameProof } from './username_proof'; +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { IdRegistryEvent } from "./id_registry_event"; +import { Message } from "./message"; +import { NameRegistryEvent } from "./name_registry_event"; +import { UserNameProof } from "./username_proof"; export enum HubEventType { NONE = 0, @@ -19,49 +19,49 @@ export enum HubEventType { export function hubEventTypeFromJSON(object: any): HubEventType { switch (object) { case 0: - case 'HUB_EVENT_TYPE_NONE': + case "HUB_EVENT_TYPE_NONE": return HubEventType.NONE; case 1: - case 'HUB_EVENT_TYPE_MERGE_MESSAGE': + case "HUB_EVENT_TYPE_MERGE_MESSAGE": return HubEventType.MERGE_MESSAGE; case 2: - case 'HUB_EVENT_TYPE_PRUNE_MESSAGE': + case "HUB_EVENT_TYPE_PRUNE_MESSAGE": return HubEventType.PRUNE_MESSAGE; case 3: - case 'HUB_EVENT_TYPE_REVOKE_MESSAGE': + case "HUB_EVENT_TYPE_REVOKE_MESSAGE": return HubEventType.REVOKE_MESSAGE; case 4: - case 'HUB_EVENT_TYPE_MERGE_ID_REGISTRY_EVENT': + case "HUB_EVENT_TYPE_MERGE_ID_REGISTRY_EVENT": return HubEventType.MERGE_ID_REGISTRY_EVENT; case 5: - case 'HUB_EVENT_TYPE_MERGE_NAME_REGISTRY_EVENT': + case "HUB_EVENT_TYPE_MERGE_NAME_REGISTRY_EVENT": return HubEventType.MERGE_NAME_REGISTRY_EVENT; case 6: - case 'HUB_EVENT_TYPE_MERGE_USERNAME_PROOF': + case "HUB_EVENT_TYPE_MERGE_USERNAME_PROOF": return HubEventType.MERGE_USERNAME_PROOF; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum HubEventType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum HubEventType"); } } export function hubEventTypeToJSON(object: HubEventType): string { switch (object) { case HubEventType.NONE: - return 'HUB_EVENT_TYPE_NONE'; + return "HUB_EVENT_TYPE_NONE"; case HubEventType.MERGE_MESSAGE: - return 'HUB_EVENT_TYPE_MERGE_MESSAGE'; + return "HUB_EVENT_TYPE_MERGE_MESSAGE"; case HubEventType.PRUNE_MESSAGE: - return 'HUB_EVENT_TYPE_PRUNE_MESSAGE'; + return "HUB_EVENT_TYPE_PRUNE_MESSAGE"; case HubEventType.REVOKE_MESSAGE: - return 'HUB_EVENT_TYPE_REVOKE_MESSAGE'; + return "HUB_EVENT_TYPE_REVOKE_MESSAGE"; case HubEventType.MERGE_ID_REGISTRY_EVENT: - return 'HUB_EVENT_TYPE_MERGE_ID_REGISTRY_EVENT'; + return "HUB_EVENT_TYPE_MERGE_ID_REGISTRY_EVENT"; case HubEventType.MERGE_NAME_REGISTRY_EVENT: - return 'HUB_EVENT_TYPE_MERGE_NAME_REGISTRY_EVENT'; + return "HUB_EVENT_TYPE_MERGE_NAME_REGISTRY_EVENT"; case HubEventType.MERGE_USERNAME_PROOF: - return 'HUB_EVENT_TYPE_MERGE_USERNAME_PROOF'; + return "HUB_EVENT_TYPE_MERGE_USERNAME_PROOF"; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum HubEventType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum HubEventType"); } } @@ -89,6 +89,8 @@ export interface MergeNameRegistryEventBody { export interface MergeUserNameProofBody { usernameProof: UserNameProof | undefined; deletedUsernameProof: UserNameProof | undefined; + usernameProofMessage: Message | undefined; + deletedUsernameProofMessage: Message | undefined; } export interface HubEvent { @@ -160,7 +162,7 @@ export const MergeMessageBody = { const obj: any = {}; message.message !== undefined && (obj.message = message.message ? Message.toJSON(message.message) : undefined); if (message.deletedMessages) { - obj.deletedMessages = message.deletedMessages.map((e) => (e ? Message.toJSON(e) : undefined)); + obj.deletedMessages = message.deletedMessages.map((e) => e ? Message.toJSON(e) : undefined); } else { obj.deletedMessages = []; } @@ -173,8 +175,9 @@ export const MergeMessageBody = { fromPartial, I>>(object: I): MergeMessageBody { const message = createBaseMergeMessageBody(); - message.message = - object.message !== undefined && object.message !== null ? Message.fromPartial(object.message) : undefined; + message.message = (object.message !== undefined && object.message !== null) + ? Message.fromPartial(object.message) + : undefined; message.deletedMessages = object.deletedMessages?.map((e) => Message.fromPartial(e)) || []; return message; }, @@ -231,8 +234,9 @@ export const PruneMessageBody = { fromPartial, I>>(object: I): PruneMessageBody { const message = createBasePruneMessageBody(); - message.message = - object.message !== undefined && object.message !== null ? Message.fromPartial(object.message) : undefined; + message.message = (object.message !== undefined && object.message !== null) + ? Message.fromPartial(object.message) + : undefined; return message; }, }; @@ -288,8 +292,9 @@ export const RevokeMessageBody = { fromPartial, I>>(object: I): RevokeMessageBody { const message = createBaseRevokeMessageBody(); - message.message = - object.message !== undefined && object.message !== null ? Message.fromPartial(object.message) : undefined; + message.message = (object.message !== undefined && object.message !== null) + ? Message.fromPartial(object.message) + : undefined; return message; }, }; @@ -348,10 +353,9 @@ export const MergeIdRegistryEventBody = { fromPartial, I>>(object: I): MergeIdRegistryEventBody { const message = createBaseMergeIdRegistryEventBody(); - message.idRegistryEvent = - object.idRegistryEvent !== undefined && object.idRegistryEvent !== null - ? IdRegistryEvent.fromPartial(object.idRegistryEvent) - : undefined; + message.idRegistryEvent = (object.idRegistryEvent !== undefined && object.idRegistryEvent !== null) + ? IdRegistryEvent.fromPartial(object.idRegistryEvent) + : undefined; return message; }, }; @@ -401,10 +405,9 @@ export const MergeNameRegistryEventBody = { toJSON(message: MergeNameRegistryEventBody): unknown { const obj: any = {}; - message.nameRegistryEvent !== undefined && - (obj.nameRegistryEvent = message.nameRegistryEvent - ? NameRegistryEvent.toJSON(message.nameRegistryEvent) - : undefined); + message.nameRegistryEvent !== undefined && (obj.nameRegistryEvent = message.nameRegistryEvent + ? NameRegistryEvent.toJSON(message.nameRegistryEvent) + : undefined); return obj; }, @@ -414,16 +417,20 @@ export const MergeNameRegistryEventBody = { fromPartial, I>>(object: I): MergeNameRegistryEventBody { const message = createBaseMergeNameRegistryEventBody(); - message.nameRegistryEvent = - object.nameRegistryEvent !== undefined && object.nameRegistryEvent !== null - ? NameRegistryEvent.fromPartial(object.nameRegistryEvent) - : undefined; + message.nameRegistryEvent = (object.nameRegistryEvent !== undefined && object.nameRegistryEvent !== null) + ? NameRegistryEvent.fromPartial(object.nameRegistryEvent) + : undefined; return message; }, }; function createBaseMergeUserNameProofBody(): MergeUserNameProofBody { - return { usernameProof: undefined, deletedUsernameProof: undefined }; + return { + usernameProof: undefined, + deletedUsernameProof: undefined, + usernameProofMessage: undefined, + deletedUsernameProofMessage: undefined, + }; } export const MergeUserNameProofBody = { @@ -434,6 +441,12 @@ export const MergeUserNameProofBody = { if (message.deletedUsernameProof !== undefined) { UserNameProof.encode(message.deletedUsernameProof, writer.uint32(18).fork()).ldelim(); } + if (message.usernameProofMessage !== undefined) { + Message.encode(message.usernameProofMessage, writer.uint32(26).fork()).ldelim(); + } + if (message.deletedUsernameProofMessage !== undefined) { + Message.encode(message.deletedUsernameProofMessage, writer.uint32(34).fork()).ldelim(); + } return writer; }, @@ -458,6 +471,20 @@ export const MergeUserNameProofBody = { message.deletedUsernameProof = UserNameProof.decode(reader, reader.uint32()); continue; + case 3: + if (tag != 26) { + break; + } + + message.usernameProofMessage = Message.decode(reader, reader.uint32()); + continue; + case 4: + if (tag != 34) { + break; + } + + message.deletedUsernameProofMessage = Message.decode(reader, reader.uint32()); + continue; } if ((tag & 7) == 4 || tag == 0) { break; @@ -473,6 +500,12 @@ export const MergeUserNameProofBody = { deletedUsernameProof: isSet(object.deletedUsernameProof) ? UserNameProof.fromJSON(object.deletedUsernameProof) : undefined, + usernameProofMessage: isSet(object.usernameProofMessage) + ? Message.fromJSON(object.usernameProofMessage) + : undefined, + deletedUsernameProofMessage: isSet(object.deletedUsernameProofMessage) + ? Message.fromJSON(object.deletedUsernameProofMessage) + : undefined, }; }, @@ -480,9 +513,15 @@ export const MergeUserNameProofBody = { const obj: any = {}; message.usernameProof !== undefined && (obj.usernameProof = message.usernameProof ? UserNameProof.toJSON(message.usernameProof) : undefined); - message.deletedUsernameProof !== undefined && - (obj.deletedUsernameProof = message.deletedUsernameProof - ? UserNameProof.toJSON(message.deletedUsernameProof) + message.deletedUsernameProof !== undefined && (obj.deletedUsernameProof = message.deletedUsernameProof + ? UserNameProof.toJSON(message.deletedUsernameProof) + : undefined); + message.usernameProofMessage !== undefined && (obj.usernameProofMessage = message.usernameProofMessage + ? Message.toJSON(message.usernameProofMessage) + : undefined); + message.deletedUsernameProofMessage !== undefined && + (obj.deletedUsernameProofMessage = message.deletedUsernameProofMessage + ? Message.toJSON(message.deletedUsernameProofMessage) : undefined); return obj; }, @@ -493,13 +532,18 @@ export const MergeUserNameProofBody = { fromPartial, I>>(object: I): MergeUserNameProofBody { const message = createBaseMergeUserNameProofBody(); - message.usernameProof = - object.usernameProof !== undefined && object.usernameProof !== null - ? UserNameProof.fromPartial(object.usernameProof) - : undefined; - message.deletedUsernameProof = - object.deletedUsernameProof !== undefined && object.deletedUsernameProof !== null - ? UserNameProof.fromPartial(object.deletedUsernameProof) + message.usernameProof = (object.usernameProof !== undefined && object.usernameProof !== null) + ? UserNameProof.fromPartial(object.usernameProof) + : undefined; + message.deletedUsernameProof = (object.deletedUsernameProof !== undefined && object.deletedUsernameProof !== null) + ? UserNameProof.fromPartial(object.deletedUsernameProof) + : undefined; + message.usernameProofMessage = (object.usernameProofMessage !== undefined && object.usernameProofMessage !== null) + ? Message.fromPartial(object.usernameProofMessage) + : undefined; + message.deletedUsernameProofMessage = + (object.deletedUsernameProofMessage !== undefined && object.deletedUsernameProofMessage !== null) + ? Message.fromPartial(object.deletedUsernameProofMessage) : undefined; return message; }, @@ -648,22 +692,19 @@ export const HubEvent = { (obj.mergeMessageBody = message.mergeMessageBody ? MergeMessageBody.toJSON(message.mergeMessageBody) : undefined); message.pruneMessageBody !== undefined && (obj.pruneMessageBody = message.pruneMessageBody ? PruneMessageBody.toJSON(message.pruneMessageBody) : undefined); - message.revokeMessageBody !== undefined && - (obj.revokeMessageBody = message.revokeMessageBody - ? RevokeMessageBody.toJSON(message.revokeMessageBody) - : undefined); - message.mergeIdRegistryEventBody !== undefined && - (obj.mergeIdRegistryEventBody = message.mergeIdRegistryEventBody - ? MergeIdRegistryEventBody.toJSON(message.mergeIdRegistryEventBody) - : undefined); + message.revokeMessageBody !== undefined && (obj.revokeMessageBody = message.revokeMessageBody + ? RevokeMessageBody.toJSON(message.revokeMessageBody) + : undefined); + message.mergeIdRegistryEventBody !== undefined && (obj.mergeIdRegistryEventBody = message.mergeIdRegistryEventBody + ? MergeIdRegistryEventBody.toJSON(message.mergeIdRegistryEventBody) + : undefined); message.mergeNameRegistryEventBody !== undefined && (obj.mergeNameRegistryEventBody = message.mergeNameRegistryEventBody ? MergeNameRegistryEventBody.toJSON(message.mergeNameRegistryEventBody) : undefined); - message.mergeUsernameProofBody !== undefined && - (obj.mergeUsernameProofBody = message.mergeUsernameProofBody - ? MergeUserNameProofBody.toJSON(message.mergeUsernameProofBody) - : undefined); + message.mergeUsernameProofBody !== undefined && (obj.mergeUsernameProofBody = message.mergeUsernameProofBody + ? MergeUserNameProofBody.toJSON(message.mergeUsernameProofBody) + : undefined); return obj; }, @@ -675,28 +716,25 @@ export const HubEvent = { const message = createBaseHubEvent(); message.type = object.type ?? 0; message.id = object.id ?? 0; - message.mergeMessageBody = - object.mergeMessageBody !== undefined && object.mergeMessageBody !== null - ? MergeMessageBody.fromPartial(object.mergeMessageBody) - : undefined; - message.pruneMessageBody = - object.pruneMessageBody !== undefined && object.pruneMessageBody !== null - ? PruneMessageBody.fromPartial(object.pruneMessageBody) - : undefined; - message.revokeMessageBody = - object.revokeMessageBody !== undefined && object.revokeMessageBody !== null - ? RevokeMessageBody.fromPartial(object.revokeMessageBody) - : undefined; + message.mergeMessageBody = (object.mergeMessageBody !== undefined && object.mergeMessageBody !== null) + ? MergeMessageBody.fromPartial(object.mergeMessageBody) + : undefined; + message.pruneMessageBody = (object.pruneMessageBody !== undefined && object.pruneMessageBody !== null) + ? PruneMessageBody.fromPartial(object.pruneMessageBody) + : undefined; + message.revokeMessageBody = (object.revokeMessageBody !== undefined && object.revokeMessageBody !== null) + ? RevokeMessageBody.fromPartial(object.revokeMessageBody) + : undefined; message.mergeIdRegistryEventBody = - object.mergeIdRegistryEventBody !== undefined && object.mergeIdRegistryEventBody !== null + (object.mergeIdRegistryEventBody !== undefined && object.mergeIdRegistryEventBody !== null) ? MergeIdRegistryEventBody.fromPartial(object.mergeIdRegistryEventBody) : undefined; message.mergeNameRegistryEventBody = - object.mergeNameRegistryEventBody !== undefined && object.mergeNameRegistryEventBody !== null + (object.mergeNameRegistryEventBody !== undefined && object.mergeNameRegistryEventBody !== null) ? MergeNameRegistryEventBody.fromPartial(object.mergeNameRegistryEventBody) : undefined; message.mergeUsernameProofBody = - object.mergeUsernameProofBody !== undefined && object.mergeUsernameProofBody !== null + (object.mergeUsernameProofBody !== undefined && object.mergeUsernameProofBody !== null) ? MergeUserNameProofBody.fromPartial(object.mergeUsernameProofBody) : undefined; return message; @@ -707,41 +745,35 @@ declare var self: any | undefined; declare var window: any | undefined; declare var global: any | undefined; var tsProtoGlobalThis: any = (() => { - if (typeof globalThis !== 'undefined') { + if (typeof globalThis !== "undefined") { return globalThis; } - if (typeof self !== 'undefined') { + if (typeof self !== "undefined") { return self; } - if (typeof window !== 'undefined') { + if (typeof window !== "undefined") { return window; } - if (typeof global !== 'undefined') { + if (typeof global !== "undefined") { return global; } - throw 'Unable to locate global object'; + throw "Unable to locate global object"; })(); type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; -type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } +type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; type KeysOfUnion = T extends T ? keyof T : never; -type Exact = P extends Builtin - ? P +type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function longToNumber(long: Long): number { if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new tsProtoGlobalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/packages/core/src/protobufs/generated/hub_state.ts b/packages/core/src/protobufs/generated/hub_state.ts index 970edbf90c..a1c0f20385 100644 --- a/packages/core/src/protobufs/generated/hub_state.ts +++ b/packages/core/src/protobufs/generated/hub_state.ts @@ -1,6 +1,6 @@ /* eslint-disable */ -import Long from 'long'; -import _m0 from 'protobufjs/minimal'; +import Long from "long"; +import _m0 from "protobufjs/minimal"; export interface HubState { lastEthBlock: number; @@ -82,41 +82,35 @@ declare var self: any | undefined; declare var window: any | undefined; declare var global: any | undefined; var tsProtoGlobalThis: any = (() => { - if (typeof globalThis !== 'undefined') { + if (typeof globalThis !== "undefined") { return globalThis; } - if (typeof self !== 'undefined') { + if (typeof self !== "undefined") { return self; } - if (typeof window !== 'undefined') { + if (typeof window !== "undefined") { return window; } - if (typeof global !== 'undefined') { + if (typeof global !== "undefined") { return global; } - throw 'Unable to locate global object'; + throw "Unable to locate global object"; })(); type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; -type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } +type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; type KeysOfUnion = T extends T ? keyof T : never; -type Exact = P extends Builtin - ? P +type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function longToNumber(long: Long): number { if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new tsProtoGlobalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/packages/core/src/protobufs/generated/id_registry_event.ts b/packages/core/src/protobufs/generated/id_registry_event.ts index 35d192b2cb..8f1a1a9610 100644 --- a/packages/core/src/protobufs/generated/id_registry_event.ts +++ b/packages/core/src/protobufs/generated/id_registry_event.ts @@ -1,6 +1,6 @@ /* eslint-disable */ -import Long from 'long'; -import _m0 from 'protobufjs/minimal'; +import Long from "long"; +import _m0 from "protobufjs/minimal"; export enum IdRegistryEventType { NONE = 0, @@ -11,29 +11,29 @@ export enum IdRegistryEventType { export function idRegistryEventTypeFromJSON(object: any): IdRegistryEventType { switch (object) { case 0: - case 'ID_REGISTRY_EVENT_TYPE_NONE': + case "ID_REGISTRY_EVENT_TYPE_NONE": return IdRegistryEventType.NONE; case 1: - case 'ID_REGISTRY_EVENT_TYPE_REGISTER': + case "ID_REGISTRY_EVENT_TYPE_REGISTER": return IdRegistryEventType.REGISTER; case 2: - case 'ID_REGISTRY_EVENT_TYPE_TRANSFER': + case "ID_REGISTRY_EVENT_TYPE_TRANSFER": return IdRegistryEventType.TRANSFER; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum IdRegistryEventType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum IdRegistryEventType"); } } export function idRegistryEventTypeToJSON(object: IdRegistryEventType): string { switch (object) { case IdRegistryEventType.NONE: - return 'ID_REGISTRY_EVENT_TYPE_NONE'; + return "ID_REGISTRY_EVENT_TYPE_NONE"; case IdRegistryEventType.REGISTER: - return 'ID_REGISTRY_EVENT_TYPE_REGISTER'; + return "ID_REGISTRY_EVENT_TYPE_REGISTER"; case IdRegistryEventType.TRANSFER: - return 'ID_REGISTRY_EVENT_TYPE_TRANSFER'; + return "ID_REGISTRY_EVENT_TYPE_TRANSFER"; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum IdRegistryEventType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum IdRegistryEventType"); } } @@ -182,7 +182,7 @@ export const IdRegistryEvent = { (obj.blockHash = base64FromBytes(message.blockHash !== undefined ? message.blockHash : new Uint8Array())); message.transactionHash !== undefined && (obj.transactionHash = base64FromBytes( - message.transactionHash !== undefined ? message.transactionHash : new Uint8Array() + message.transactionHash !== undefined ? message.transactionHash : new Uint8Array(), )); message.logIndex !== undefined && (obj.logIndex = Math.round(message.logIndex)); message.fid !== undefined && (obj.fid = Math.round(message.fid)); @@ -215,24 +215,24 @@ declare var self: any | undefined; declare var window: any | undefined; declare var global: any | undefined; var tsProtoGlobalThis: any = (() => { - if (typeof globalThis !== 'undefined') { + if (typeof globalThis !== "undefined") { return globalThis; } - if (typeof self !== 'undefined') { + if (typeof self !== "undefined") { return self; } - if (typeof window !== 'undefined') { + if (typeof window !== "undefined") { return window; } - if (typeof global !== 'undefined') { + if (typeof global !== "undefined") { return global; } - throw 'Unable to locate global object'; + throw "Unable to locate global object"; })(); function bytesFromBase64(b64: string): Uint8Array { if (tsProtoGlobalThis.Buffer) { - return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, 'base64')); + return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, "base64")); } else { const bin = tsProtoGlobalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -245,36 +245,30 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (tsProtoGlobalThis.Buffer) { - return tsProtoGlobalThis.Buffer.from(arr).toString('base64'); + return tsProtoGlobalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return tsProtoGlobalThis.btoa(bin.join('')); + return tsProtoGlobalThis.btoa(bin.join("")); } } type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; -type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } +type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; type KeysOfUnion = T extends T ? keyof T : never; -type Exact = P extends Builtin - ? P +type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function longToNumber(long: Long): number { if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new tsProtoGlobalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/packages/core/src/protobufs/generated/job.ts b/packages/core/src/protobufs/generated/job.ts index aac4724f8e..8100db8d7d 100644 --- a/packages/core/src/protobufs/generated/job.ts +++ b/packages/core/src/protobufs/generated/job.ts @@ -1,5 +1,5 @@ /* eslint-disable */ -import _m0 from 'protobufjs/minimal'; +import _m0 from "protobufjs/minimal"; export interface RevokeMessagesBySignerJobPayload { fid: number; @@ -71,13 +71,13 @@ export const RevokeMessagesBySignerJobPayload = { }, create, I>>( - base?: I + base?: I, ): RevokeMessagesBySignerJobPayload { return RevokeMessagesBySignerJobPayload.fromPartial(base ?? {}); }, fromPartial, I>>( - object: I + object: I, ): RevokeMessagesBySignerJobPayload { const message = createBaseRevokeMessagesBySignerJobPayload(); message.fid = object.fid ?? 0; @@ -133,13 +133,13 @@ export const UpdateNameRegistryEventExpiryJobPayload = { }, create, I>>( - base?: I + base?: I, ): UpdateNameRegistryEventExpiryJobPayload { return UpdateNameRegistryEventExpiryJobPayload.fromPartial(base ?? {}); }, fromPartial, I>>( - object: I + object: I, ): UpdateNameRegistryEventExpiryJobPayload { const message = createBaseUpdateNameRegistryEventExpiryJobPayload(); message.fname = object.fname ?? new Uint8Array(); @@ -151,24 +151,24 @@ declare var self: any | undefined; declare var window: any | undefined; declare var global: any | undefined; var tsProtoGlobalThis: any = (() => { - if (typeof globalThis !== 'undefined') { + if (typeof globalThis !== "undefined") { return globalThis; } - if (typeof self !== 'undefined') { + if (typeof self !== "undefined") { return self; } - if (typeof window !== 'undefined') { + if (typeof window !== "undefined") { return window; } - if (typeof global !== 'undefined') { + if (typeof global !== "undefined") { return global; } - throw 'Unable to locate global object'; + throw "Unable to locate global object"; })(); function bytesFromBase64(b64: string): Uint8Array { if (tsProtoGlobalThis.Buffer) { - return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, 'base64')); + return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, "base64")); } else { const bin = tsProtoGlobalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -181,31 +181,25 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (tsProtoGlobalThis.Buffer) { - return tsProtoGlobalThis.Buffer.from(arr).toString('base64'); + return tsProtoGlobalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return tsProtoGlobalThis.btoa(bin.join('')); + return tsProtoGlobalThis.btoa(bin.join("")); } } type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; -type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } +type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; type KeysOfUnion = T extends T ? keyof T : never; -type Exact = P extends Builtin - ? P +type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/packages/core/src/protobufs/generated/message.ts b/packages/core/src/protobufs/generated/message.ts index 3282b61a5f..32cdebeb7b 100644 --- a/packages/core/src/protobufs/generated/message.ts +++ b/packages/core/src/protobufs/generated/message.ts @@ -1,6 +1,7 @@ /* eslint-disable */ -import Long from 'long'; -import _m0 from 'protobufjs/minimal'; +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { UserNameProof } from "./username_proof"; /** Type of hashing scheme used to produce a digest of MessageData */ export enum HashScheme { @@ -12,24 +13,24 @@ export enum HashScheme { export function hashSchemeFromJSON(object: any): HashScheme { switch (object) { case 0: - case 'HASH_SCHEME_NONE': + case "HASH_SCHEME_NONE": return HashScheme.NONE; case 1: - case 'HASH_SCHEME_BLAKE3': + case "HASH_SCHEME_BLAKE3": return HashScheme.BLAKE3; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum HashScheme'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum HashScheme"); } } export function hashSchemeToJSON(object: HashScheme): string { switch (object) { case HashScheme.NONE: - return 'HASH_SCHEME_NONE'; + return "HASH_SCHEME_NONE"; case HashScheme.BLAKE3: - return 'HASH_SCHEME_BLAKE3'; + return "HASH_SCHEME_BLAKE3"; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum HashScheme'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum HashScheme"); } } @@ -45,29 +46,29 @@ export enum SignatureScheme { export function signatureSchemeFromJSON(object: any): SignatureScheme { switch (object) { case 0: - case 'SIGNATURE_SCHEME_NONE': + case "SIGNATURE_SCHEME_NONE": return SignatureScheme.NONE; case 1: - case 'SIGNATURE_SCHEME_ED25519': + case "SIGNATURE_SCHEME_ED25519": return SignatureScheme.ED25519; case 2: - case 'SIGNATURE_SCHEME_EIP712': + case "SIGNATURE_SCHEME_EIP712": return SignatureScheme.EIP712; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum SignatureScheme'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum SignatureScheme"); } } export function signatureSchemeToJSON(object: SignatureScheme): string { switch (object) { case SignatureScheme.NONE: - return 'SIGNATURE_SCHEME_NONE'; + return "SIGNATURE_SCHEME_NONE"; case SignatureScheme.ED25519: - return 'SIGNATURE_SCHEME_ED25519'; + return "SIGNATURE_SCHEME_ED25519"; case SignatureScheme.EIP712: - return 'SIGNATURE_SCHEME_EIP712'; + return "SIGNATURE_SCHEME_EIP712"; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum SignatureScheme'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum SignatureScheme"); } } @@ -96,79 +97,86 @@ export enum MessageType { SIGNER_REMOVE = 10, /** USER_DATA_ADD - Add metadata about a user */ USER_DATA_ADD = 11, + /** USERNAME_PROOF - Add or replace a username proof */ + USERNAME_PROOF = 12, } export function messageTypeFromJSON(object: any): MessageType { switch (object) { case 0: - case 'MESSAGE_TYPE_NONE': + case "MESSAGE_TYPE_NONE": return MessageType.NONE; case 1: - case 'MESSAGE_TYPE_CAST_ADD': + case "MESSAGE_TYPE_CAST_ADD": return MessageType.CAST_ADD; case 2: - case 'MESSAGE_TYPE_CAST_REMOVE': + case "MESSAGE_TYPE_CAST_REMOVE": return MessageType.CAST_REMOVE; case 3: - case 'MESSAGE_TYPE_REACTION_ADD': + case "MESSAGE_TYPE_REACTION_ADD": return MessageType.REACTION_ADD; case 4: - case 'MESSAGE_TYPE_REACTION_REMOVE': + case "MESSAGE_TYPE_REACTION_REMOVE": return MessageType.REACTION_REMOVE; case 5: - case 'MESSAGE_TYPE_LINK_ADD': + case "MESSAGE_TYPE_LINK_ADD": return MessageType.LINK_ADD; case 6: - case 'MESSAGE_TYPE_LINK_REMOVE': + case "MESSAGE_TYPE_LINK_REMOVE": return MessageType.LINK_REMOVE; case 7: - case 'MESSAGE_TYPE_VERIFICATION_ADD_ETH_ADDRESS': + case "MESSAGE_TYPE_VERIFICATION_ADD_ETH_ADDRESS": return MessageType.VERIFICATION_ADD_ETH_ADDRESS; case 8: - case 'MESSAGE_TYPE_VERIFICATION_REMOVE': + case "MESSAGE_TYPE_VERIFICATION_REMOVE": return MessageType.VERIFICATION_REMOVE; case 9: - case 'MESSAGE_TYPE_SIGNER_ADD': + case "MESSAGE_TYPE_SIGNER_ADD": return MessageType.SIGNER_ADD; case 10: - case 'MESSAGE_TYPE_SIGNER_REMOVE': + case "MESSAGE_TYPE_SIGNER_REMOVE": return MessageType.SIGNER_REMOVE; case 11: - case 'MESSAGE_TYPE_USER_DATA_ADD': + case "MESSAGE_TYPE_USER_DATA_ADD": return MessageType.USER_DATA_ADD; + case 12: + case "MESSAGE_TYPE_USERNAME_PROOF": + return MessageType.USERNAME_PROOF; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum MessageType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum MessageType"); } } export function messageTypeToJSON(object: MessageType): string { switch (object) { case MessageType.NONE: - return 'MESSAGE_TYPE_NONE'; + return "MESSAGE_TYPE_NONE"; case MessageType.CAST_ADD: - return 'MESSAGE_TYPE_CAST_ADD'; + return "MESSAGE_TYPE_CAST_ADD"; case MessageType.CAST_REMOVE: - return 'MESSAGE_TYPE_CAST_REMOVE'; + return "MESSAGE_TYPE_CAST_REMOVE"; case MessageType.REACTION_ADD: - return 'MESSAGE_TYPE_REACTION_ADD'; + return "MESSAGE_TYPE_REACTION_ADD"; case MessageType.REACTION_REMOVE: - return 'MESSAGE_TYPE_REACTION_REMOVE'; + return "MESSAGE_TYPE_REACTION_REMOVE"; case MessageType.LINK_ADD: - return 'MESSAGE_TYPE_LINK_ADD'; + return "MESSAGE_TYPE_LINK_ADD"; case MessageType.LINK_REMOVE: - return 'MESSAGE_TYPE_LINK_REMOVE'; + return "MESSAGE_TYPE_LINK_REMOVE"; case MessageType.VERIFICATION_ADD_ETH_ADDRESS: - return 'MESSAGE_TYPE_VERIFICATION_ADD_ETH_ADDRESS'; + return "MESSAGE_TYPE_VERIFICATION_ADD_ETH_ADDRESS"; case MessageType.VERIFICATION_REMOVE: - return 'MESSAGE_TYPE_VERIFICATION_REMOVE'; + return "MESSAGE_TYPE_VERIFICATION_REMOVE"; case MessageType.SIGNER_ADD: - return 'MESSAGE_TYPE_SIGNER_ADD'; + return "MESSAGE_TYPE_SIGNER_ADD"; case MessageType.SIGNER_REMOVE: - return 'MESSAGE_TYPE_SIGNER_REMOVE'; + return "MESSAGE_TYPE_SIGNER_REMOVE"; case MessageType.USER_DATA_ADD: - return 'MESSAGE_TYPE_USER_DATA_ADD'; + return "MESSAGE_TYPE_USER_DATA_ADD"; + case MessageType.USERNAME_PROOF: + return "MESSAGE_TYPE_USERNAME_PROOF"; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum MessageType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum MessageType"); } } @@ -186,34 +194,34 @@ export enum FarcasterNetwork { export function farcasterNetworkFromJSON(object: any): FarcasterNetwork { switch (object) { case 0: - case 'FARCASTER_NETWORK_NONE': + case "FARCASTER_NETWORK_NONE": return FarcasterNetwork.NONE; case 1: - case 'FARCASTER_NETWORK_MAINNET': + case "FARCASTER_NETWORK_MAINNET": return FarcasterNetwork.MAINNET; case 2: - case 'FARCASTER_NETWORK_TESTNET': + case "FARCASTER_NETWORK_TESTNET": return FarcasterNetwork.TESTNET; case 3: - case 'FARCASTER_NETWORK_DEVNET': + case "FARCASTER_NETWORK_DEVNET": return FarcasterNetwork.DEVNET; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum FarcasterNetwork'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum FarcasterNetwork"); } } export function farcasterNetworkToJSON(object: FarcasterNetwork): string { switch (object) { case FarcasterNetwork.NONE: - return 'FARCASTER_NETWORK_NONE'; + return "FARCASTER_NETWORK_NONE"; case FarcasterNetwork.MAINNET: - return 'FARCASTER_NETWORK_MAINNET'; + return "FARCASTER_NETWORK_MAINNET"; case FarcasterNetwork.TESTNET: - return 'FARCASTER_NETWORK_TESTNET'; + return "FARCASTER_NETWORK_TESTNET"; case FarcasterNetwork.DEVNET: - return 'FARCASTER_NETWORK_DEVNET'; + return "FARCASTER_NETWORK_DEVNET"; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum FarcasterNetwork'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum FarcasterNetwork"); } } @@ -235,44 +243,44 @@ export enum UserDataType { export function userDataTypeFromJSON(object: any): UserDataType { switch (object) { case 0: - case 'USER_DATA_TYPE_NONE': + case "USER_DATA_TYPE_NONE": return UserDataType.NONE; case 1: - case 'USER_DATA_TYPE_PFP': + case "USER_DATA_TYPE_PFP": return UserDataType.PFP; case 2: - case 'USER_DATA_TYPE_DISPLAY': + case "USER_DATA_TYPE_DISPLAY": return UserDataType.DISPLAY; case 3: - case 'USER_DATA_TYPE_BIO': + case "USER_DATA_TYPE_BIO": return UserDataType.BIO; case 5: - case 'USER_DATA_TYPE_URL': + case "USER_DATA_TYPE_URL": return UserDataType.URL; case 6: - case 'USER_DATA_TYPE_FNAME': + case "USER_DATA_TYPE_FNAME": return UserDataType.FNAME; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum UserDataType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum UserDataType"); } } export function userDataTypeToJSON(object: UserDataType): string { switch (object) { case UserDataType.NONE: - return 'USER_DATA_TYPE_NONE'; + return "USER_DATA_TYPE_NONE"; case UserDataType.PFP: - return 'USER_DATA_TYPE_PFP'; + return "USER_DATA_TYPE_PFP"; case UserDataType.DISPLAY: - return 'USER_DATA_TYPE_DISPLAY'; + return "USER_DATA_TYPE_DISPLAY"; case UserDataType.BIO: - return 'USER_DATA_TYPE_BIO'; + return "USER_DATA_TYPE_BIO"; case UserDataType.URL: - return 'USER_DATA_TYPE_URL'; + return "USER_DATA_TYPE_URL"; case UserDataType.FNAME: - return 'USER_DATA_TYPE_FNAME'; + return "USER_DATA_TYPE_FNAME"; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum UserDataType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum UserDataType"); } } @@ -288,29 +296,29 @@ export enum ReactionType { export function reactionTypeFromJSON(object: any): ReactionType { switch (object) { case 0: - case 'REACTION_TYPE_NONE': + case "REACTION_TYPE_NONE": return ReactionType.NONE; case 1: - case 'REACTION_TYPE_LIKE': + case "REACTION_TYPE_LIKE": return ReactionType.LIKE; case 2: - case 'REACTION_TYPE_RECAST': + case "REACTION_TYPE_RECAST": return ReactionType.RECAST; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum ReactionType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum ReactionType"); } } export function reactionTypeToJSON(object: ReactionType): string { switch (object) { case ReactionType.NONE: - return 'REACTION_TYPE_NONE'; + return "REACTION_TYPE_NONE"; case ReactionType.LIKE: - return 'REACTION_TYPE_LIKE'; + return "REACTION_TYPE_LIKE"; case ReactionType.RECAST: - return 'REACTION_TYPE_RECAST'; + return "REACTION_TYPE_RECAST"; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum ReactionType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum ReactionType"); } } @@ -320,7 +328,9 @@ export function reactionTypeToJSON(object: ReactionType): string { */ export interface Message { /** Contents of the message */ - data: MessageData | undefined; + data: + | MessageData + | undefined; /** Hash digest of data */ hash: Uint8Array; /** Hash scheme that produced the hash digest */ @@ -355,6 +365,7 @@ export interface MessageData { userDataBody?: UserDataBody | undefined; signerRemoveBody?: SignerRemoveBody | undefined; linkBody?: LinkBody | undefined; + usernameProofBody?: UserNameProof | undefined; } /** Adds an Ed25519 key pair that signs messages for a user */ @@ -391,9 +402,13 @@ export interface CastAddBody { /** Fids mentioned in the cast */ mentions: number[]; /** Parent cast of the cast */ - parentCastId?: CastId | undefined; + parentCastId?: + | CastId + | undefined; /** Parent URL */ - parentUrl?: string | undefined; + parentUrl?: + | string + | undefined; /** Text of the cast */ text: string; /** Positions of the mentions in the text */ @@ -421,7 +436,9 @@ export interface ReactionBody { /** Type of reaction */ type: ReactionType; /** CastId of the Cast to react to */ - targetCastId?: CastId | undefined; + targetCastId?: + | CastId + | undefined; /** URL to react to */ targetUrl?: string | undefined; } @@ -447,7 +464,9 @@ export interface LinkBody { /** Type of link, <= 8 characters */ type: string; /** User-defined timestamp that preserves original timestamp when message.data.timestamp needs to be updated for compaction */ - displayTimestamp?: number | undefined; + displayTimestamp?: + | number + | undefined; /** The fid the link relates to */ targetFid?: number | undefined; } @@ -575,7 +594,9 @@ export const Message = { fromPartial, I>>(object: I): Message { const message = createBaseMessage(); - message.data = object.data !== undefined && object.data !== null ? MessageData.fromPartial(object.data) : undefined; + message.data = (object.data !== undefined && object.data !== null) + ? MessageData.fromPartial(object.data) + : undefined; message.hash = object.hash ?? new Uint8Array(); message.hashScheme = object.hashScheme ?? 0; message.signature = object.signature ?? new Uint8Array(); @@ -600,6 +621,7 @@ function createBaseMessageData(): MessageData { userDataBody: undefined, signerRemoveBody: undefined, linkBody: undefined, + usernameProofBody: undefined, }; } @@ -644,6 +666,9 @@ export const MessageData = { if (message.linkBody !== undefined) { LinkBody.encode(message.linkBody, writer.uint32(114).fork()).ldelim(); } + if (message.usernameProofBody !== undefined) { + UserNameProof.encode(message.usernameProofBody, writer.uint32(122).fork()).ldelim(); + } return writer; }, @@ -745,6 +770,13 @@ export const MessageData = { message.linkBody = LinkBody.decode(reader, reader.uint32()); continue; + case 15: + if (tag != 122) { + break; + } + + message.usernameProofBody = UserNameProof.decode(reader, reader.uint32()); + continue; } if ((tag & 7) == 4 || tag == 0) { break; @@ -773,6 +805,7 @@ export const MessageData = { userDataBody: isSet(object.userDataBody) ? UserDataBody.fromJSON(object.userDataBody) : undefined, signerRemoveBody: isSet(object.signerRemoveBody) ? SignerRemoveBody.fromJSON(object.signerRemoveBody) : undefined, linkBody: isSet(object.linkBody) ? LinkBody.fromJSON(object.linkBody) : undefined, + usernameProofBody: isSet(object.usernameProofBody) ? UserNameProof.fromJSON(object.usernameProofBody) : undefined, }; }, @@ -792,10 +825,9 @@ export const MessageData = { (obj.verificationAddEthAddressBody = message.verificationAddEthAddressBody ? VerificationAddEthAddressBody.toJSON(message.verificationAddEthAddressBody) : undefined); - message.verificationRemoveBody !== undefined && - (obj.verificationRemoveBody = message.verificationRemoveBody - ? VerificationRemoveBody.toJSON(message.verificationRemoveBody) - : undefined); + message.verificationRemoveBody !== undefined && (obj.verificationRemoveBody = message.verificationRemoveBody + ? VerificationRemoveBody.toJSON(message.verificationRemoveBody) + : undefined); message.signerAddBody !== undefined && (obj.signerAddBody = message.signerAddBody ? SignerAddBody.toJSON(message.signerAddBody) : undefined); message.userDataBody !== undefined && @@ -803,6 +835,8 @@ export const MessageData = { message.signerRemoveBody !== undefined && (obj.signerRemoveBody = message.signerRemoveBody ? SignerRemoveBody.toJSON(message.signerRemoveBody) : undefined); message.linkBody !== undefined && (obj.linkBody = message.linkBody ? LinkBody.toJSON(message.linkBody) : undefined); + message.usernameProofBody !== undefined && + (obj.usernameProofBody = message.usernameProofBody ? UserNameProof.toJSON(message.usernameProofBody) : undefined); return obj; }, @@ -816,40 +850,38 @@ export const MessageData = { message.fid = object.fid ?? 0; message.timestamp = object.timestamp ?? 0; message.network = object.network ?? 0; - message.castAddBody = - object.castAddBody !== undefined && object.castAddBody !== null - ? CastAddBody.fromPartial(object.castAddBody) - : undefined; - message.castRemoveBody = - object.castRemoveBody !== undefined && object.castRemoveBody !== null - ? CastRemoveBody.fromPartial(object.castRemoveBody) - : undefined; - message.reactionBody = - object.reactionBody !== undefined && object.reactionBody !== null - ? ReactionBody.fromPartial(object.reactionBody) - : undefined; + message.castAddBody = (object.castAddBody !== undefined && object.castAddBody !== null) + ? CastAddBody.fromPartial(object.castAddBody) + : undefined; + message.castRemoveBody = (object.castRemoveBody !== undefined && object.castRemoveBody !== null) + ? CastRemoveBody.fromPartial(object.castRemoveBody) + : undefined; + message.reactionBody = (object.reactionBody !== undefined && object.reactionBody !== null) + ? ReactionBody.fromPartial(object.reactionBody) + : undefined; message.verificationAddEthAddressBody = - object.verificationAddEthAddressBody !== undefined && object.verificationAddEthAddressBody !== null + (object.verificationAddEthAddressBody !== undefined && object.verificationAddEthAddressBody !== null) ? VerificationAddEthAddressBody.fromPartial(object.verificationAddEthAddressBody) : undefined; message.verificationRemoveBody = - object.verificationRemoveBody !== undefined && object.verificationRemoveBody !== null + (object.verificationRemoveBody !== undefined && object.verificationRemoveBody !== null) ? VerificationRemoveBody.fromPartial(object.verificationRemoveBody) : undefined; - message.signerAddBody = - object.signerAddBody !== undefined && object.signerAddBody !== null - ? SignerAddBody.fromPartial(object.signerAddBody) - : undefined; - message.userDataBody = - object.userDataBody !== undefined && object.userDataBody !== null - ? UserDataBody.fromPartial(object.userDataBody) - : undefined; - message.signerRemoveBody = - object.signerRemoveBody !== undefined && object.signerRemoveBody !== null - ? SignerRemoveBody.fromPartial(object.signerRemoveBody) - : undefined; - message.linkBody = - object.linkBody !== undefined && object.linkBody !== null ? LinkBody.fromPartial(object.linkBody) : undefined; + message.signerAddBody = (object.signerAddBody !== undefined && object.signerAddBody !== null) + ? SignerAddBody.fromPartial(object.signerAddBody) + : undefined; + message.userDataBody = (object.userDataBody !== undefined && object.userDataBody !== null) + ? UserDataBody.fromPartial(object.userDataBody) + : undefined; + message.signerRemoveBody = (object.signerRemoveBody !== undefined && object.signerRemoveBody !== null) + ? SignerRemoveBody.fromPartial(object.signerRemoveBody) + : undefined; + message.linkBody = (object.linkBody !== undefined && object.linkBody !== null) + ? LinkBody.fromPartial(object.linkBody) + : undefined; + message.usernameProofBody = (object.usernameProofBody !== undefined && object.usernameProofBody !== null) + ? UserNameProof.fromPartial(object.usernameProofBody) + : undefined; return message; }, }; @@ -984,7 +1016,7 @@ export const SignerRemoveBody = { }; function createBaseUserDataBody(): UserDataBody { - return { type: 0, value: '' }; + return { type: 0, value: "" }; } export const UserDataBody = { @@ -992,7 +1024,7 @@ export const UserDataBody = { if (message.type !== 0) { writer.uint32(8).int32(message.type); } - if (message.value !== '') { + if (message.value !== "") { writer.uint32(18).string(message.value); } return writer; @@ -1031,7 +1063,7 @@ export const UserDataBody = { fromJSON(object: any): UserDataBody { return { type: isSet(object.type) ? userDataTypeFromJSON(object.type) : 0, - value: isSet(object.value) ? String(object.value) : '', + value: isSet(object.value) ? String(object.value) : "", }; }, @@ -1049,7 +1081,7 @@ export const UserDataBody = { fromPartial, I>>(object: I): UserDataBody { const message = createBaseUserDataBody(); message.type = object.type ?? 0; - message.value = object.value ?? ''; + message.value = object.value ?? ""; return message; }, }; @@ -1120,8 +1152,9 @@ export const Embed = { fromPartial, I>>(object: I): Embed { const message = createBaseEmbed(); message.url = object.url ?? undefined; - message.castId = - object.castId !== undefined && object.castId !== null ? CastId.fromPartial(object.castId) : undefined; + message.castId = (object.castId !== undefined && object.castId !== null) + ? CastId.fromPartial(object.castId) + : undefined; return message; }, }; @@ -1132,7 +1165,7 @@ function createBaseCastAddBody(): CastAddBody { mentions: [], parentCastId: undefined, parentUrl: undefined, - text: '', + text: "", mentionsPositions: [], embeds: [], }; @@ -1154,7 +1187,7 @@ export const CastAddBody = { if (message.parentUrl !== undefined) { writer.uint32(58).string(message.parentUrl); } - if (message.text !== '') { + if (message.text !== "") { writer.uint32(34).string(message.text); } writer.uint32(42).fork(); @@ -1259,7 +1292,7 @@ export const CastAddBody = { mentions: Array.isArray(object?.mentions) ? object.mentions.map((e: any) => Number(e)) : [], parentCastId: isSet(object.parentCastId) ? CastId.fromJSON(object.parentCastId) : undefined, parentUrl: isSet(object.parentUrl) ? String(object.parentUrl) : undefined, - text: isSet(object.text) ? String(object.text) : '', + text: isSet(object.text) ? String(object.text) : "", mentionsPositions: Array.isArray(object?.mentionsPositions) ? object.mentionsPositions.map((e: any) => Number(e)) : [], @@ -1289,7 +1322,7 @@ export const CastAddBody = { obj.mentionsPositions = []; } if (message.embeds) { - obj.embeds = message.embeds.map((e) => (e ? Embed.toJSON(e) : undefined)); + obj.embeds = message.embeds.map((e) => e ? Embed.toJSON(e) : undefined); } else { obj.embeds = []; } @@ -1304,12 +1337,11 @@ export const CastAddBody = { const message = createBaseCastAddBody(); message.embedsDeprecated = object.embedsDeprecated?.map((e) => e) || []; message.mentions = object.mentions?.map((e) => e) || []; - message.parentCastId = - object.parentCastId !== undefined && object.parentCastId !== null - ? CastId.fromPartial(object.parentCastId) - : undefined; + message.parentCastId = (object.parentCastId !== undefined && object.parentCastId !== null) + ? CastId.fromPartial(object.parentCastId) + : undefined; message.parentUrl = object.parentUrl ?? undefined; - message.text = object.text ?? ''; + message.text = object.text ?? ""; message.mentionsPositions = object.mentionsPositions?.map((e) => e) || []; message.embeds = object.embeds?.map((e) => Embed.fromPartial(e)) || []; return message; @@ -1524,10 +1556,9 @@ export const ReactionBody = { fromPartial, I>>(object: I): ReactionBody { const message = createBaseReactionBody(); message.type = object.type ?? 0; - message.targetCastId = - object.targetCastId !== undefined && object.targetCastId !== null - ? CastId.fromPartial(object.targetCastId) - : undefined; + message.targetCastId = (object.targetCastId !== undefined && object.targetCastId !== null) + ? CastId.fromPartial(object.targetCastId) + : undefined; message.targetUrl = object.targetUrl ?? undefined; return message; }, @@ -1602,7 +1633,7 @@ export const VerificationAddEthAddressBody = { (obj.address = base64FromBytes(message.address !== undefined ? message.address : new Uint8Array())); message.ethSignature !== undefined && (obj.ethSignature = base64FromBytes( - message.ethSignature !== undefined ? message.ethSignature : new Uint8Array() + message.ethSignature !== undefined ? message.ethSignature : new Uint8Array(), )); message.blockHash !== undefined && (obj.blockHash = base64FromBytes(message.blockHash !== undefined ? message.blockHash : new Uint8Array())); @@ -1614,7 +1645,7 @@ export const VerificationAddEthAddressBody = { }, fromPartial, I>>( - object: I + object: I, ): VerificationAddEthAddressBody { const message = createBaseVerificationAddEthAddressBody(); message.address = object.address ?? new Uint8Array(); @@ -1682,12 +1713,12 @@ export const VerificationRemoveBody = { }; function createBaseLinkBody(): LinkBody { - return { type: '', displayTimestamp: undefined, targetFid: undefined }; + return { type: "", displayTimestamp: undefined, targetFid: undefined }; } export const LinkBody = { encode(message: LinkBody, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.type !== '') { + if (message.type !== "") { writer.uint32(10).string(message.type); } if (message.displayTimestamp !== undefined) { @@ -1738,7 +1769,7 @@ export const LinkBody = { fromJSON(object: any): LinkBody { return { - type: isSet(object.type) ? String(object.type) : '', + type: isSet(object.type) ? String(object.type) : "", displayTimestamp: isSet(object.displayTimestamp) ? Number(object.displayTimestamp) : undefined, targetFid: isSet(object.targetFid) ? Number(object.targetFid) : undefined, }; @@ -1758,7 +1789,7 @@ export const LinkBody = { fromPartial, I>>(object: I): LinkBody { const message = createBaseLinkBody(); - message.type = object.type ?? ''; + message.type = object.type ?? ""; message.displayTimestamp = object.displayTimestamp ?? undefined; message.targetFid = object.targetFid ?? undefined; return message; @@ -1769,24 +1800,24 @@ declare var self: any | undefined; declare var window: any | undefined; declare var global: any | undefined; var tsProtoGlobalThis: any = (() => { - if (typeof globalThis !== 'undefined') { + if (typeof globalThis !== "undefined") { return globalThis; } - if (typeof self !== 'undefined') { + if (typeof self !== "undefined") { return self; } - if (typeof window !== 'undefined') { + if (typeof window !== "undefined") { return window; } - if (typeof global !== 'undefined') { + if (typeof global !== "undefined") { return global; } - throw 'Unable to locate global object'; + throw "Unable to locate global object"; })(); function bytesFromBase64(b64: string): Uint8Array { if (tsProtoGlobalThis.Buffer) { - return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, 'base64')); + return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, "base64")); } else { const bin = tsProtoGlobalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -1799,36 +1830,30 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (tsProtoGlobalThis.Buffer) { - return tsProtoGlobalThis.Buffer.from(arr).toString('base64'); + return tsProtoGlobalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return tsProtoGlobalThis.btoa(bin.join('')); + return tsProtoGlobalThis.btoa(bin.join("")); } } type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; -type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } +type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; type KeysOfUnion = T extends T ? keyof T : never; -type Exact = P extends Builtin - ? P +type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function longToNumber(long: Long): number { if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new tsProtoGlobalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/packages/core/src/protobufs/generated/name_registry_event.ts b/packages/core/src/protobufs/generated/name_registry_event.ts index b0a83e8ab3..c3da2d5215 100644 --- a/packages/core/src/protobufs/generated/name_registry_event.ts +++ b/packages/core/src/protobufs/generated/name_registry_event.ts @@ -1,5 +1,5 @@ /* eslint-disable */ -import _m0 from 'protobufjs/minimal'; +import _m0 from "protobufjs/minimal"; export enum NameRegistryEventType { NONE = 0, @@ -10,29 +10,29 @@ export enum NameRegistryEventType { export function nameRegistryEventTypeFromJSON(object: any): NameRegistryEventType { switch (object) { case 0: - case 'NAME_REGISTRY_EVENT_TYPE_NONE': + case "NAME_REGISTRY_EVENT_TYPE_NONE": return NameRegistryEventType.NONE; case 1: - case 'NAME_REGISTRY_EVENT_TYPE_TRANSFER': + case "NAME_REGISTRY_EVENT_TYPE_TRANSFER": return NameRegistryEventType.TRANSFER; case 2: - case 'NAME_REGISTRY_EVENT_TYPE_RENEW': + case "NAME_REGISTRY_EVENT_TYPE_RENEW": return NameRegistryEventType.RENEW; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum NameRegistryEventType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum NameRegistryEventType"); } } export function nameRegistryEventTypeToJSON(object: NameRegistryEventType): string { switch (object) { case NameRegistryEventType.NONE: - return 'NAME_REGISTRY_EVENT_TYPE_NONE'; + return "NAME_REGISTRY_EVENT_TYPE_NONE"; case NameRegistryEventType.TRANSFER: - return 'NAME_REGISTRY_EVENT_TYPE_TRANSFER'; + return "NAME_REGISTRY_EVENT_TYPE_TRANSFER"; case NameRegistryEventType.RENEW: - return 'NAME_REGISTRY_EVENT_TYPE_RENEW'; + return "NAME_REGISTRY_EVENT_TYPE_RENEW"; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum NameRegistryEventType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum NameRegistryEventType"); } } @@ -194,7 +194,7 @@ export const NameRegistryEvent = { (obj.blockHash = base64FromBytes(message.blockHash !== undefined ? message.blockHash : new Uint8Array())); message.transactionHash !== undefined && (obj.transactionHash = base64FromBytes( - message.transactionHash !== undefined ? message.transactionHash : new Uint8Array() + message.transactionHash !== undefined ? message.transactionHash : new Uint8Array(), )); message.logIndex !== undefined && (obj.logIndex = Math.round(message.logIndex)); message.fname !== undefined && @@ -230,24 +230,24 @@ declare var self: any | undefined; declare var window: any | undefined; declare var global: any | undefined; var tsProtoGlobalThis: any = (() => { - if (typeof globalThis !== 'undefined') { + if (typeof globalThis !== "undefined") { return globalThis; } - if (typeof self !== 'undefined') { + if (typeof self !== "undefined") { return self; } - if (typeof window !== 'undefined') { + if (typeof window !== "undefined") { return window; } - if (typeof global !== 'undefined') { + if (typeof global !== "undefined") { return global; } - throw 'Unable to locate global object'; + throw "Unable to locate global object"; })(); function bytesFromBase64(b64: string): Uint8Array { if (tsProtoGlobalThis.Buffer) { - return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, 'base64')); + return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, "base64")); } else { const bin = tsProtoGlobalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -260,31 +260,25 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (tsProtoGlobalThis.Buffer) { - return tsProtoGlobalThis.Buffer.from(arr).toString('base64'); + return tsProtoGlobalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return tsProtoGlobalThis.btoa(bin.join('')); + return tsProtoGlobalThis.btoa(bin.join("")); } } type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; -type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } +type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; type KeysOfUnion = T extends T ? keyof T : never; -type Exact = P extends Builtin - ? P +type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/packages/core/src/protobufs/generated/request_response.ts b/packages/core/src/protobufs/generated/request_response.ts index 02843b438f..5d346edb0a 100644 --- a/packages/core/src/protobufs/generated/request_response.ts +++ b/packages/core/src/protobufs/generated/request_response.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import Long from 'long'; -import _m0 from 'protobufjs/minimal'; -import { HubEventType, hubEventTypeFromJSON, hubEventTypeToJSON } from './hub_event'; +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { HubEventType, hubEventTypeFromJSON, hubEventTypeToJSON } from "./hub_event"; import { CastId, Message, @@ -11,9 +11,11 @@ import { UserDataType, userDataTypeFromJSON, userDataTypeToJSON, -} from './message'; +} from "./message"; +import { UserNameProof } from "./username_proof"; -export interface Empty {} +export interface Empty { +} export interface SubscribeRequest { eventTypes: HubEventType[]; @@ -153,6 +155,10 @@ export interface UsernameProofRequest { name: Uint8Array; } +export interface UsernameProofsResponse { + proofs: UserNameProof[]; +} + export interface VerificationRequest { fid: number; address: Uint8Array; @@ -436,21 +442,21 @@ export const HubInfoRequest = { }; function createBaseHubInfoResponse(): HubInfoResponse { - return { version: '', isSyncing: false, nickname: '', rootHash: '', dbStats: undefined }; + return { version: "", isSyncing: false, nickname: "", rootHash: "", dbStats: undefined }; } export const HubInfoResponse = { encode(message: HubInfoResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.version !== '') { + if (message.version !== "") { writer.uint32(10).string(message.version); } if (message.isSyncing === true) { writer.uint32(16).bool(message.isSyncing); } - if (message.nickname !== '') { + if (message.nickname !== "") { writer.uint32(26).string(message.nickname); } - if (message.rootHash !== '') { + if (message.rootHash !== "") { writer.uint32(34).string(message.rootHash); } if (message.dbStats !== undefined) { @@ -512,10 +518,10 @@ export const HubInfoResponse = { fromJSON(object: any): HubInfoResponse { return { - version: isSet(object.version) ? String(object.version) : '', + version: isSet(object.version) ? String(object.version) : "", isSyncing: isSet(object.isSyncing) ? Boolean(object.isSyncing) : false, - nickname: isSet(object.nickname) ? String(object.nickname) : '', - rootHash: isSet(object.rootHash) ? String(object.rootHash) : '', + nickname: isSet(object.nickname) ? String(object.nickname) : "", + rootHash: isSet(object.rootHash) ? String(object.rootHash) : "", dbStats: isSet(object.dbStats) ? DbStats.fromJSON(object.dbStats) : undefined, }; }, @@ -536,12 +542,13 @@ export const HubInfoResponse = { fromPartial, I>>(object: I): HubInfoResponse { const message = createBaseHubInfoResponse(); - message.version = object.version ?? ''; + message.version = object.version ?? ""; message.isSyncing = object.isSyncing ?? false; - message.nickname = object.nickname ?? ''; - message.rootHash = object.rootHash ?? ''; - message.dbStats = - object.dbStats !== undefined && object.dbStats !== null ? DbStats.fromPartial(object.dbStats) : undefined; + message.nickname = object.nickname ?? ""; + message.rootHash = object.rootHash ?? ""; + message.dbStats = (object.dbStats !== undefined && object.dbStats !== null) + ? DbStats.fromPartial(object.dbStats) + : undefined; return message; }, }; @@ -742,7 +749,7 @@ export const SyncStatusResponse = { const obj: any = {}; message.isSyncing !== undefined && (obj.isSyncing = message.isSyncing); if (message.syncStatus) { - obj.syncStatus = message.syncStatus.map((e) => (e ? SyncStatus.toJSON(e) : undefined)); + obj.syncStatus = message.syncStatus.map((e) => e ? SyncStatus.toJSON(e) : undefined); } else { obj.syncStatus = []; } @@ -763,10 +770,10 @@ export const SyncStatusResponse = { function createBaseSyncStatus(): SyncStatus { return { - peerId: '', - inSync: '', + peerId: "", + inSync: "", shouldSync: false, - divergencePrefix: '', + divergencePrefix: "", divergenceSecondsAgo: 0, theirMessages: 0, ourMessages: 0, @@ -776,16 +783,16 @@ function createBaseSyncStatus(): SyncStatus { export const SyncStatus = { encode(message: SyncStatus, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.peerId !== '') { + if (message.peerId !== "") { writer.uint32(10).string(message.peerId); } - if (message.inSync !== '') { + if (message.inSync !== "") { writer.uint32(18).string(message.inSync); } if (message.shouldSync === true) { writer.uint32(24).bool(message.shouldSync); } - if (message.divergencePrefix !== '') { + if (message.divergencePrefix !== "") { writer.uint32(34).string(message.divergencePrefix); } if (message.divergenceSecondsAgo !== 0) { @@ -877,10 +884,10 @@ export const SyncStatus = { fromJSON(object: any): SyncStatus { return { - peerId: isSet(object.peerId) ? String(object.peerId) : '', - inSync: isSet(object.inSync) ? String(object.inSync) : '', + peerId: isSet(object.peerId) ? String(object.peerId) : "", + inSync: isSet(object.inSync) ? String(object.inSync) : "", shouldSync: isSet(object.shouldSync) ? Boolean(object.shouldSync) : false, - divergencePrefix: isSet(object.divergencePrefix) ? String(object.divergencePrefix) : '', + divergencePrefix: isSet(object.divergencePrefix) ? String(object.divergencePrefix) : "", divergenceSecondsAgo: isSet(object.divergenceSecondsAgo) ? Number(object.divergenceSecondsAgo) : 0, theirMessages: isSet(object.theirMessages) ? Number(object.theirMessages) : 0, ourMessages: isSet(object.ourMessages) ? Number(object.ourMessages) : 0, @@ -907,10 +914,10 @@ export const SyncStatus = { fromPartial, I>>(object: I): SyncStatus { const message = createBaseSyncStatus(); - message.peerId = object.peerId ?? ''; - message.inSync = object.inSync ?? ''; + message.peerId = object.peerId ?? ""; + message.inSync = object.inSync ?? ""; message.shouldSync = object.shouldSync ?? false; - message.divergencePrefix = object.divergencePrefix ?? ''; + message.divergencePrefix = object.divergencePrefix ?? ""; message.divergenceSecondsAgo = object.divergenceSecondsAgo ?? 0; message.theirMessages = object.theirMessages ?? 0; message.ourMessages = object.ourMessages ?? 0; @@ -920,7 +927,7 @@ export const SyncStatus = { }; function createBaseTrieNodeMetadataResponse(): TrieNodeMetadataResponse { - return { prefix: new Uint8Array(), numMessages: 0, hash: '', children: [] }; + return { prefix: new Uint8Array(), numMessages: 0, hash: "", children: [] }; } export const TrieNodeMetadataResponse = { @@ -931,7 +938,7 @@ export const TrieNodeMetadataResponse = { if (message.numMessages !== 0) { writer.uint32(16).uint64(message.numMessages); } - if (message.hash !== '') { + if (message.hash !== "") { writer.uint32(26).string(message.hash); } for (const v of message.children) { @@ -988,7 +995,7 @@ export const TrieNodeMetadataResponse = { return { prefix: isSet(object.prefix) ? bytesFromBase64(object.prefix) : new Uint8Array(), numMessages: isSet(object.numMessages) ? Number(object.numMessages) : 0, - hash: isSet(object.hash) ? String(object.hash) : '', + hash: isSet(object.hash) ? String(object.hash) : "", children: Array.isArray(object?.children) ? object.children.map((e: any) => TrieNodeMetadataResponse.fromJSON(e)) : [], @@ -1002,7 +1009,7 @@ export const TrieNodeMetadataResponse = { message.numMessages !== undefined && (obj.numMessages = Math.round(message.numMessages)); message.hash !== undefined && (obj.hash = message.hash); if (message.children) { - obj.children = message.children.map((e) => (e ? TrieNodeMetadataResponse.toJSON(e) : undefined)); + obj.children = message.children.map((e) => e ? TrieNodeMetadataResponse.toJSON(e) : undefined); } else { obj.children = []; } @@ -1017,14 +1024,14 @@ export const TrieNodeMetadataResponse = { const message = createBaseTrieNodeMetadataResponse(); message.prefix = object.prefix ?? new Uint8Array(); message.numMessages = object.numMessages ?? 0; - message.hash = object.hash ?? ''; + message.hash = object.hash ?? ""; message.children = object.children?.map((e) => TrieNodeMetadataResponse.fromPartial(e)) || []; return message; }, }; function createBaseTrieNodeSnapshotResponse(): TrieNodeSnapshotResponse { - return { prefix: new Uint8Array(), excludedHashes: [], numMessages: 0, rootHash: '' }; + return { prefix: new Uint8Array(), excludedHashes: [], numMessages: 0, rootHash: "" }; } export const TrieNodeSnapshotResponse = { @@ -1038,7 +1045,7 @@ export const TrieNodeSnapshotResponse = { if (message.numMessages !== 0) { writer.uint32(24).uint64(message.numMessages); } - if (message.rootHash !== '') { + if (message.rootHash !== "") { writer.uint32(34).string(message.rootHash); } return writer; @@ -1093,7 +1100,7 @@ export const TrieNodeSnapshotResponse = { prefix: isSet(object.prefix) ? bytesFromBase64(object.prefix) : new Uint8Array(), excludedHashes: Array.isArray(object?.excludedHashes) ? object.excludedHashes.map((e: any) => String(e)) : [], numMessages: isSet(object.numMessages) ? Number(object.numMessages) : 0, - rootHash: isSet(object.rootHash) ? String(object.rootHash) : '', + rootHash: isSet(object.rootHash) ? String(object.rootHash) : "", }; }, @@ -1120,7 +1127,7 @@ export const TrieNodeSnapshotResponse = { message.prefix = object.prefix ?? new Uint8Array(); message.excludedHashes = object.excludedHashes?.map((e) => e) || []; message.numMessages = object.numMessages ?? 0; - message.rootHash = object.rootHash ?? ''; + message.rootHash = object.rootHash ?? ""; return message; }, }; @@ -1567,7 +1574,7 @@ export const MessagesResponse = { toJSON(message: MessagesResponse): unknown { const obj: any = {}; if (message.messages) { - obj.messages = message.messages.map((e) => (e ? Message.toJSON(e) : undefined)); + obj.messages = message.messages.map((e) => e ? Message.toJSON(e) : undefined); } else { obj.messages = []; } @@ -1697,10 +1704,9 @@ export const CastsByParentRequest = { fromPartial, I>>(object: I): CastsByParentRequest { const message = createBaseCastsByParentRequest(); - message.parentCastId = - object.parentCastId !== undefined && object.parentCastId !== null - ? CastId.fromPartial(object.parentCastId) - : undefined; + message.parentCastId = (object.parentCastId !== undefined && object.parentCastId !== null) + ? CastId.fromPartial(object.parentCastId) + : undefined; message.parentUrl = object.parentUrl ?? undefined; message.pageSize = object.pageSize ?? undefined; message.pageToken = object.pageToken ?? undefined; @@ -1801,10 +1807,9 @@ export const ReactionRequest = { const message = createBaseReactionRequest(); message.fid = object.fid ?? 0; message.reactionType = object.reactionType ?? 0; - message.targetCastId = - object.targetCastId !== undefined && object.targetCastId !== null - ? CastId.fromPartial(object.targetCastId) - : undefined; + message.targetCastId = (object.targetCastId !== undefined && object.targetCastId !== null) + ? CastId.fromPartial(object.targetCastId) + : undefined; message.targetUrl = object.targetUrl ?? undefined; return message; }, @@ -2045,10 +2050,9 @@ export const ReactionsByTargetRequest = { fromPartial, I>>(object: I): ReactionsByTargetRequest { const message = createBaseReactionsByTargetRequest(); - message.targetCastId = - object.targetCastId !== undefined && object.targetCastId !== null - ? CastId.fromPartial(object.targetCastId) - : undefined; + message.targetCastId = (object.targetCastId !== undefined && object.targetCastId !== null) + ? CastId.fromPartial(object.targetCastId) + : undefined; message.targetUrl = object.targetUrl ?? undefined; message.reactionType = object.reactionType ?? undefined; message.pageSize = object.pageSize ?? undefined; @@ -2243,6 +2247,66 @@ export const UsernameProofRequest = { }, }; +function createBaseUsernameProofsResponse(): UsernameProofsResponse { + return { proofs: [] }; +} + +export const UsernameProofsResponse = { + encode(message: UsernameProofsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.proofs) { + UserNameProof.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): UsernameProofsResponse { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUsernameProofsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag != 10) { + break; + } + + message.proofs.push(UserNameProof.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) == 4 || tag == 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): UsernameProofsResponse { + return { proofs: Array.isArray(object?.proofs) ? object.proofs.map((e: any) => UserNameProof.fromJSON(e)) : [] }; + }, + + toJSON(message: UsernameProofsResponse): unknown { + const obj: any = {}; + if (message.proofs) { + obj.proofs = message.proofs.map((e) => e ? UserNameProof.toJSON(e) : undefined); + } else { + obj.proofs = []; + } + return obj; + }, + + create, I>>(base?: I): UsernameProofsResponse { + return UsernameProofsResponse.fromPartial(base ?? {}); + }, + + fromPartial, I>>(object: I): UsernameProofsResponse { + const message = createBaseUsernameProofsResponse(); + message.proofs = object.proofs?.map((e) => UserNameProof.fromPartial(e)) || []; + return message; + }, +}; + function createBaseVerificationRequest(): VerificationRequest { return { fid: 0, address: new Uint8Array() }; } @@ -2388,7 +2452,7 @@ export const SignerRequest = { }; function createBaseLinkRequest(): LinkRequest { - return { fid: 0, linkType: '', targetFid: undefined }; + return { fid: 0, linkType: "", targetFid: undefined }; } export const LinkRequest = { @@ -2396,7 +2460,7 @@ export const LinkRequest = { if (message.fid !== 0) { writer.uint32(8).uint64(message.fid); } - if (message.linkType !== '') { + if (message.linkType !== "") { writer.uint32(18).string(message.linkType); } if (message.targetFid !== undefined) { @@ -2445,7 +2509,7 @@ export const LinkRequest = { fromJSON(object: any): LinkRequest { return { fid: isSet(object.fid) ? Number(object.fid) : 0, - linkType: isSet(object.linkType) ? String(object.linkType) : '', + linkType: isSet(object.linkType) ? String(object.linkType) : "", targetFid: isSet(object.targetFid) ? Number(object.targetFid) : undefined, }; }, @@ -2465,7 +2529,7 @@ export const LinkRequest = { fromPartial, I>>(object: I): LinkRequest { const message = createBaseLinkRequest(); message.fid = object.fid ?? 0; - message.linkType = object.linkType ?? ''; + message.linkType = object.linkType ?? ""; message.targetFid = object.targetFid ?? undefined; return message; }, @@ -2800,7 +2864,7 @@ export const IdRegistryEventByAddressRequest = { }, fromPartial, I>>( - object: I + object: I, ): IdRegistryEventByAddressRequest { const message = createBaseIdRegistryEventByAddressRequest(); message.address = object.address ?? new Uint8Array(); @@ -2812,24 +2876,24 @@ declare var self: any | undefined; declare var window: any | undefined; declare var global: any | undefined; var tsProtoGlobalThis: any = (() => { - if (typeof globalThis !== 'undefined') { + if (typeof globalThis !== "undefined") { return globalThis; } - if (typeof self !== 'undefined') { + if (typeof self !== "undefined") { return self; } - if (typeof window !== 'undefined') { + if (typeof window !== "undefined") { return window; } - if (typeof global !== 'undefined') { + if (typeof global !== "undefined") { return global; } - throw 'Unable to locate global object'; + throw "Unable to locate global object"; })(); function bytesFromBase64(b64: string): Uint8Array { if (tsProtoGlobalThis.Buffer) { - return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, 'base64')); + return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, "base64")); } else { const bin = tsProtoGlobalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -2842,36 +2906,30 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (tsProtoGlobalThis.Buffer) { - return tsProtoGlobalThis.Buffer.from(arr).toString('base64'); + return tsProtoGlobalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return tsProtoGlobalThis.btoa(bin.join('')); + return tsProtoGlobalThis.btoa(bin.join("")); } } type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; -type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } +type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; type KeysOfUnion = T extends T ? keyof T : never; -type Exact = P extends Builtin - ? P +type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function longToNumber(long: Long): number { if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new tsProtoGlobalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/packages/core/src/protobufs/generated/sync_trie.ts b/packages/core/src/protobufs/generated/sync_trie.ts index 1ed4bb284e..7750a9bf38 100644 --- a/packages/core/src/protobufs/generated/sync_trie.ts +++ b/packages/core/src/protobufs/generated/sync_trie.ts @@ -1,5 +1,5 @@ /* eslint-disable */ -import _m0 from 'protobufjs/minimal'; +import _m0 from "protobufjs/minimal"; export interface DbTrieNode { key: Uint8Array; @@ -126,24 +126,24 @@ declare var self: any | undefined; declare var window: any | undefined; declare var global: any | undefined; var tsProtoGlobalThis: any = (() => { - if (typeof globalThis !== 'undefined') { + if (typeof globalThis !== "undefined") { return globalThis; } - if (typeof self !== 'undefined') { + if (typeof self !== "undefined") { return self; } - if (typeof window !== 'undefined') { + if (typeof window !== "undefined") { return window; } - if (typeof global !== 'undefined') { + if (typeof global !== "undefined") { return global; } - throw 'Unable to locate global object'; + throw "Unable to locate global object"; })(); function bytesFromBase64(b64: string): Uint8Array { if (tsProtoGlobalThis.Buffer) { - return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, 'base64')); + return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, "base64")); } else { const bin = tsProtoGlobalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -156,31 +156,25 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (tsProtoGlobalThis.Buffer) { - return tsProtoGlobalThis.Buffer.from(arr).toString('base64'); + return tsProtoGlobalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return tsProtoGlobalThis.btoa(bin.join('')); + return tsProtoGlobalThis.btoa(bin.join("")); } } type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; -type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } +type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; type KeysOfUnion = T extends T ? keyof T : never; -type Exact = P extends Builtin - ? P +type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/packages/core/src/protobufs/generated/username_proof.ts b/packages/core/src/protobufs/generated/username_proof.ts index 96f1c7464f..d25ba3f8f9 100644 --- a/packages/core/src/protobufs/generated/username_proof.ts +++ b/packages/core/src/protobufs/generated/username_proof.ts @@ -1,33 +1,39 @@ /* eslint-disable */ -import Long from 'long'; -import _m0 from 'protobufjs/minimal'; +import Long from "long"; +import _m0 from "protobufjs/minimal"; export enum UserNameType { USERNAME_TYPE_NONE = 0, USERNAME_TYPE_FNAME = 1, + USERNAME_TYPE_ENS_L1 = 2, } export function userNameTypeFromJSON(object: any): UserNameType { switch (object) { case 0: - case 'USERNAME_TYPE_NONE': + case "USERNAME_TYPE_NONE": return UserNameType.USERNAME_TYPE_NONE; case 1: - case 'USERNAME_TYPE_FNAME': + case "USERNAME_TYPE_FNAME": return UserNameType.USERNAME_TYPE_FNAME; + case 2: + case "USERNAME_TYPE_ENS_L1": + return UserNameType.USERNAME_TYPE_ENS_L1; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum UserNameType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum UserNameType"); } } export function userNameTypeToJSON(object: UserNameType): string { switch (object) { case UserNameType.USERNAME_TYPE_NONE: - return 'USERNAME_TYPE_NONE'; + return "USERNAME_TYPE_NONE"; case UserNameType.USERNAME_TYPE_FNAME: - return 'USERNAME_TYPE_FNAME'; + return "USERNAME_TYPE_FNAME"; + case UserNameType.USERNAME_TYPE_ENS_L1: + return "USERNAME_TYPE_ENS_L1"; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum UserNameType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum UserNameType"); } } @@ -177,24 +183,24 @@ declare var self: any | undefined; declare var window: any | undefined; declare var global: any | undefined; var tsProtoGlobalThis: any = (() => { - if (typeof globalThis !== 'undefined') { + if (typeof globalThis !== "undefined") { return globalThis; } - if (typeof self !== 'undefined') { + if (typeof self !== "undefined") { return self; } - if (typeof window !== 'undefined') { + if (typeof window !== "undefined") { return window; } - if (typeof global !== 'undefined') { + if (typeof global !== "undefined") { return global; } - throw 'Unable to locate global object'; + throw "Unable to locate global object"; })(); function bytesFromBase64(b64: string): Uint8Array { if (tsProtoGlobalThis.Buffer) { - return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, 'base64')); + return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, "base64")); } else { const bin = tsProtoGlobalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -207,36 +213,30 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (tsProtoGlobalThis.Buffer) { - return tsProtoGlobalThis.Buffer.from(arr).toString('base64'); + return tsProtoGlobalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return tsProtoGlobalThis.btoa(bin.join('')); + return tsProtoGlobalThis.btoa(bin.join("")); } } type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; -type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } +type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; type KeysOfUnion = T extends T ? keyof T : never; -type Exact = P extends Builtin - ? P +type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function longToNumber(long: Long): number { if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new tsProtoGlobalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/packages/core/src/protobufs/typeguards.ts b/packages/core/src/protobufs/typeguards.ts index 32b7b80631..1a4f7c8294 100644 --- a/packages/core/src/protobufs/typeguards.ts +++ b/packages/core/src/protobufs/typeguards.ts @@ -143,6 +143,18 @@ export const isUserDataAddMessage = (message: protobufs.Message): message is typ ); }; +export const isUsernameProofData = (data: protobufs.MessageData): data is types.UsernameProofData => { + return data.type === protobufs.MessageType.USERNAME_PROOF && typeof data.usernameProofBody !== "undefined"; +}; + +export const isUsernameProofMessage = (message: protobufs.Message): message is types.UsernameProofMessage => { + return ( + message.signatureScheme === protobufs.SignatureScheme.ED25519 && + typeof message.data !== "undefined" && + isUsernameProofData(message.data) + ); +}; + /** Hub event typeguards */ export const isMergeMessageHubEvent = (event: hubEventProtobufs.HubEvent): event is types.MergeMessageHubEvent => { @@ -195,6 +207,7 @@ export const isMergeUsernameProofHubEvent = ( return ( event.type === hubEventProtobufs.HubEventType.MERGE_USERNAME_PROOF && typeof event.mergeUsernameProofBody !== "undefined" && - typeof event.mergeUsernameProofBody.usernameProof !== "undefined" + (typeof event.mergeUsernameProofBody.usernameProof !== "undefined" || + typeof event.mergeUsernameProofBody.deletedUsernameProof !== "undefined") ); }; diff --git a/packages/core/src/protobufs/types.ts b/packages/core/src/protobufs/types.ts index f19b34072a..e09a945642 100644 --- a/packages/core/src/protobufs/types.ts +++ b/packages/core/src/protobufs/types.ts @@ -116,6 +116,16 @@ export type UserDataAddMessage = protobufs.Message & { signatureScheme: protobufs.SignatureScheme.ED25519; }; +export type UsernameProofData = protobufs.MessageData & { + type: protobufs.MessageType.USERNAME_PROOF; + usernameProofBody: UserNameProof; +}; + +export type UsernameProofMessage = protobufs.Message & { + data: UsernameProofData; + signatureScheme: protobufs.SignatureScheme.ED25519; +}; + /** Hub event types */ export type MergeMessageHubEvent = hubEventProtobufs.HubEvent & { diff --git a/packages/core/src/validations.test.ts b/packages/core/src/validations.test.ts index ac034878b9..c000ff3142 100644 --- a/packages/core/src/validations.test.ts +++ b/packages/core/src/validations.test.ts @@ -7,6 +7,7 @@ import { Factories } from "./factories"; import { fromFarcasterTime, getFarcasterTime } from "./time"; import * as validations from "./validations"; import { makeVerificationEthAddressClaim } from "./verifications"; +import { UserDataType, UserNameType } from "@farcaster/hub-nodejs"; const signer = Factories.Ed25519Signer.build(); const ethSigner = Factories.Eip712Signer.build(); @@ -82,6 +83,75 @@ describe("validateFname", () => { err(new HubError("bad_request.validation_failure", `fname "${fname}" doesn't match ${validations.FNAME_REGEX}`)), ); }); + + test("does not allow names ending with .eth", () => { + const fname = "fname.eth"; + expect(validations.validateFname(fname)).toEqual( + err(new HubError("bad_request.validation_failure", `fname "${fname}" doesn't match ${validations.FNAME_REGEX}`)), + ); + }); +}); + +describe("validateENSname", () => { + test("succeeds with valid byte array input", () => { + const ensName = Factories.EnsName.build(); + expect(validations.validateEnsName(ensName)).toEqual(ok(ensName)); + }); + + test("succeeds with valid string input", () => { + const ensName = bytesToUtf8String(Factories.EnsName.build())._unsafeUnwrap(); + expect(validations.validateEnsName(ensName)).toEqual(ok(ensName)); + }); + + test("fails when greater than 20 characters", () => { + const ensName = faker.random.alpha(17).concat(".eth"); + expect(validations.validateEnsName(ensName)).toEqual( + err(new HubError("bad_request.validation_failure", `ensName "${ensName}" > 20 characters`)), + ); + }); + + test("fails with an empty string", () => { + const ensName = ""; + expect(validations.validateEnsName(ensName)).toEqual( + err(new HubError("bad_request.validation_failure", "ensName is missing")), + ); + }); + + test("fails when undefined", () => { + expect(validations.validateEnsName(undefined)).toEqual( + err(new HubError("bad_request.validation_failure", "ensName is missing")), + ); + }); + + test("fails with invalid characters", () => { + const ensName = "-fname.eth"; + expect(validations.validateEnsName(ensName)).toEqual( + err( + new HubError("bad_request.validation_failure", `ensName "${ensName}" doesn't match ${validations.FNAME_REGEX}`), + ), + ); + }); + + test("fails when name does not end with .eth", () => { + const ensName = "ensname"; + expect(validations.validateEnsName(ensName)).toEqual( + err(new HubError("bad_request.validation_failure", `ensName "${ensName}" doesn't end with .eth`)), + ); + }); + + test("fails with subdomains", () => { + const ensName = "abc.def.eth"; + expect(validations.validateEnsName(ensName)).toEqual( + err(new HubError("bad_request.validation_failure", `ensName "${ensName}" unsupported subdomain`)), + ); + }); + + test("fails when unable to normalize ens names", () => { + const ensName = "2l--3-6b-mi-d-b.eth"; + expect(validations.validateEnsName(ensName)).toEqual( + err(new HubError("bad_request.validation_failure", `ensName "${ensName}" is not a valid ENS name`)), + ); + }); }); describe("validateCastId", () => { @@ -725,6 +795,11 @@ describe("validateUserDataAddBody", () => { expect(validations.validateUserDataAddBody(body)).toEqual(ok(body)); }); + test("succeeds for ens names", async () => { + const body = Factories.UserDataBody.build({ type: UserDataType.FNAME, value: "averylongensname.eth" }); + expect(validations.validateUserDataAddBody(body)).toEqual(ok(body)); + }); + describe("fails", () => { let body: protobufs.UserDataBody; let hubErrorMessage: string; @@ -769,6 +844,52 @@ describe("validateUserDataAddBody", () => { }); }); +describe("validateUsernameProof", () => { + test("when timestamp does not match message timestamp", async () => { + const proof = await Factories.UsernameProofMessage.create(); + proof.data.timestamp = proof.data.timestamp + 10; + const result = await validations.validateUsernameProofBody(proof.data.usernameProofBody, proof.data); + expect(result._unsafeUnwrapErr()).toEqual( + new HubError( + "bad_request.validation_failure", + "timestamp in username proof does not match timestamp in message data", + ), + ); + }); + test("when name does not end with .eth", async () => { + const proof = await Factories.UsernameProofMessage.create({ + data: { usernameProofBody: { name: Factories.Fname.build() } }, + }); + const result = await validations.validateUsernameProofBody(proof.data.usernameProofBody, proof.data); + const hubError = result._unsafeUnwrapErr(); + expect(hubError.errCode).toEqual("bad_request.validation_failure"); + expect(hubError.message).toMatch("doesn't end with .eth"); + }); + test("when type is unsupported", async () => { + const proof = await Factories.UsernameProofMessage.create({ + data: { usernameProofBody: { type: UserNameType.USERNAME_TYPE_NONE } }, + }); + const result = await validations.validateUsernameProofBody(proof.data.usernameProofBody, proof.data); + expect(result._unsafeUnwrapErr()).toEqual( + new HubError("bad_request.validation_failure", "invalid username type: 0"), + ); + }); + test("when type is fname", async () => { + const proof = await Factories.UsernameProofMessage.create({ + data: { usernameProofBody: { type: UserNameType.USERNAME_TYPE_FNAME } }, + }); + const result = await validations.validateUsernameProofBody(proof.data.usernameProofBody, proof.data); + expect(result._unsafeUnwrapErr()).toEqual( + new HubError("bad_request.validation_failure", "invalid username type: 1"), + ); + }); + test("succeeds for a valid message", async () => { + const proof = await Factories.UsernameProofMessage.create(); + const result = await validations.validateUsernameProofBody(proof.data.usernameProofBody, proof.data); + expect(result.isOk()).toBeTruthy(); + }); +}); + describe("validateMessage", () => { test("succeeds with Ed25519 signer", async () => { const message = await Factories.Message.create({}, { transient: { signer } }); diff --git a/packages/core/src/validations.ts b/packages/core/src/validations.ts index 27ea389533..09275cdc71 100644 --- a/packages/core/src/validations.ts +++ b/packages/core/src/validations.ts @@ -5,8 +5,10 @@ import { err, ok, Result } from "neverthrow"; import { bytesCompare, bytesToUtf8String, utf8StringToBytes } from "./bytes"; import { eip712 } from "./crypto"; import { HubAsyncResult, HubError, HubResult } from "./errors"; -import { getFarcasterTime } from "./time"; +import { getFarcasterTime, toFarcasterTime } from "./time"; import { makeVerificationEthAddressClaim } from "./verifications"; +import { UserNameType } from "./protobufs"; +import { normalize } from "viem/ens"; /** Number of seconds (10 minutes) that is appropriate for clock skew */ export const ALLOWED_CLOCK_SKEW_SECONDS = 10 * 60; @@ -221,6 +223,8 @@ export const validateMessageData = async (data: ); } else if (validType.value === protobufs.MessageType.VERIFICATION_REMOVE && !!data.verificationRemoveBody) { bodyResult = validateVerificationRemoveBody(data.verificationRemoveBody); + } else if (validType.value === protobufs.MessageType.USERNAME_PROOF && !!data.usernameProofBody) { + bodyResult = validateUsernameProofBody(data.usernameProofBody, data); } else { return err(new HubError("bad_request.invalid_param", "bodyType is invalid")); } @@ -516,6 +520,39 @@ export const validateVerificationRemoveBody = ( return validateEthAddress(body.address).map(() => body); }; +export const validateUsernameProofBody = ( + body: protobufs.UserNameProof, + data: protobufs.MessageData, +): HubResult => { + // Gossiped username proofs must only have an ENS type + if (body.type !== UserNameType.USERNAME_TYPE_ENS_L1) { + return err(new HubError("bad_request.validation_failure", `invalid username type: ${body.type}`)); + } + const validateName = validateEnsName(body.name); + if (validateName.isErr()) { + return err(validateName.error); + } + if (body.fid !== data.fid) { + return err( + new HubError("bad_request.validation_failure", "fid in username proof does not match fid in message data"), + ); + } + + const proofFarcasterTimestamp = toFarcasterTime(body.timestamp); + if (proofFarcasterTimestamp.isErr()) { + return err(proofFarcasterTimestamp.error); + } + if (proofFarcasterTimestamp.value !== data.timestamp) { + return err( + new HubError( + "bad_request.validation_failure", + "timestamp in username proof does not match timestamp in message data", + ), + ); + } + return ok(body); +}; + export const validateSignerAddBody = (body: protobufs.SignerAddBody): HubResult => { if (body.name !== undefined) { const textUtf8BytesResult = utf8StringToBytes(body.name); @@ -586,7 +623,9 @@ export const validateUserDataAddBody = (body: protobufs.UserDataBody): HubResult // Users are allowed to set fname = '' to remove their fname, otherwise we need a valid fname to add if (value !== "") { const validatedFname = validateFname(value); - if (validatedFname.isErr()) { + const validatedEnsName = validateEnsName(value); + // At least one of fname or ensName must be valid + if (validatedFname.isErr() && validatedEnsName.isErr()) { return err(validatedFname.error); } } @@ -630,3 +669,50 @@ export const validateFname = (fnameP?: T | null): return ok(fnameP); }; + +export const validateEnsName = (ensNameP?: T | null): HubResult => { + if (ensNameP === undefined || ensNameP === null || ensNameP === "") { + return err(new HubError("bad_request.validation_failure", "ensName is missing")); + } + + let ensName; + if (ensNameP instanceof Uint8Array) { + const fromBytes = bytesToUtf8String(ensNameP); + if (fromBytes.isErr()) { + return err(fromBytes.error); + } + ensName = fromBytes.value; + } else { + ensName = ensNameP; + } + + if (ensName === undefined || ensName === null || ensName === "") { + return err(new HubError("bad_request.validation_failure", "ensName is missing")); + } + + try { + normalize(ensName); + } catch (e) { + return err(new HubError("bad_request.validation_failure", `ensName "${ensName}" is not a valid ENS name`)); + } + + if (!ensName.endsWith(".eth")) { + return err(new HubError("bad_request.validation_failure", `ensName "${ensName}" doesn't end with .eth`)); + } + + const nameParts = ensName.split("."); + if (nameParts[0] === undefined || nameParts.length !== 2) { + return err(new HubError("bad_request.validation_failure", `ensName "${ensName}" unsupported subdomain`)); + } + + if (ensName.length > 20) { + return err(new HubError("bad_request.validation_failure", `ensName "${ensName}" > 20 characters`)); + } + + const hasValidChars = FNAME_REGEX.test(nameParts[0]); + if (!hasValidChars) { + return err(new HubError("bad_request.validation_failure", `ensName "${ensName}" doesn't match ${FNAME_REGEX}`)); + } + + return ok(ensNameP); +}; diff --git a/packages/hub-nodejs/src/generated/hub_event.ts b/packages/hub-nodejs/src/generated/hub_event.ts index 47a01a8f18..8e0c1d5dca 100644 --- a/packages/hub-nodejs/src/generated/hub_event.ts +++ b/packages/hub-nodejs/src/generated/hub_event.ts @@ -1,10 +1,10 @@ /* eslint-disable */ -import Long from 'long'; -import _m0 from 'protobufjs/minimal'; -import { IdRegistryEvent } from './id_registry_event'; -import { Message } from './message'; -import { NameRegistryEvent } from './name_registry_event'; -import { UserNameProof } from './username_proof'; +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { IdRegistryEvent } from "./id_registry_event"; +import { Message } from "./message"; +import { NameRegistryEvent } from "./name_registry_event"; +import { UserNameProof } from "./username_proof"; export enum HubEventType { NONE = 0, @@ -19,49 +19,49 @@ export enum HubEventType { export function hubEventTypeFromJSON(object: any): HubEventType { switch (object) { case 0: - case 'HUB_EVENT_TYPE_NONE': + case "HUB_EVENT_TYPE_NONE": return HubEventType.NONE; case 1: - case 'HUB_EVENT_TYPE_MERGE_MESSAGE': + case "HUB_EVENT_TYPE_MERGE_MESSAGE": return HubEventType.MERGE_MESSAGE; case 2: - case 'HUB_EVENT_TYPE_PRUNE_MESSAGE': + case "HUB_EVENT_TYPE_PRUNE_MESSAGE": return HubEventType.PRUNE_MESSAGE; case 3: - case 'HUB_EVENT_TYPE_REVOKE_MESSAGE': + case "HUB_EVENT_TYPE_REVOKE_MESSAGE": return HubEventType.REVOKE_MESSAGE; case 4: - case 'HUB_EVENT_TYPE_MERGE_ID_REGISTRY_EVENT': + case "HUB_EVENT_TYPE_MERGE_ID_REGISTRY_EVENT": return HubEventType.MERGE_ID_REGISTRY_EVENT; case 5: - case 'HUB_EVENT_TYPE_MERGE_NAME_REGISTRY_EVENT': + case "HUB_EVENT_TYPE_MERGE_NAME_REGISTRY_EVENT": return HubEventType.MERGE_NAME_REGISTRY_EVENT; case 6: - case 'HUB_EVENT_TYPE_MERGE_USERNAME_PROOF': + case "HUB_EVENT_TYPE_MERGE_USERNAME_PROOF": return HubEventType.MERGE_USERNAME_PROOF; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum HubEventType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum HubEventType"); } } export function hubEventTypeToJSON(object: HubEventType): string { switch (object) { case HubEventType.NONE: - return 'HUB_EVENT_TYPE_NONE'; + return "HUB_EVENT_TYPE_NONE"; case HubEventType.MERGE_MESSAGE: - return 'HUB_EVENT_TYPE_MERGE_MESSAGE'; + return "HUB_EVENT_TYPE_MERGE_MESSAGE"; case HubEventType.PRUNE_MESSAGE: - return 'HUB_EVENT_TYPE_PRUNE_MESSAGE'; + return "HUB_EVENT_TYPE_PRUNE_MESSAGE"; case HubEventType.REVOKE_MESSAGE: - return 'HUB_EVENT_TYPE_REVOKE_MESSAGE'; + return "HUB_EVENT_TYPE_REVOKE_MESSAGE"; case HubEventType.MERGE_ID_REGISTRY_EVENT: - return 'HUB_EVENT_TYPE_MERGE_ID_REGISTRY_EVENT'; + return "HUB_EVENT_TYPE_MERGE_ID_REGISTRY_EVENT"; case HubEventType.MERGE_NAME_REGISTRY_EVENT: - return 'HUB_EVENT_TYPE_MERGE_NAME_REGISTRY_EVENT'; + return "HUB_EVENT_TYPE_MERGE_NAME_REGISTRY_EVENT"; case HubEventType.MERGE_USERNAME_PROOF: - return 'HUB_EVENT_TYPE_MERGE_USERNAME_PROOF'; + return "HUB_EVENT_TYPE_MERGE_USERNAME_PROOF"; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum HubEventType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum HubEventType"); } } @@ -89,6 +89,8 @@ export interface MergeNameRegistryEventBody { export interface MergeUserNameProofBody { usernameProof: UserNameProof | undefined; deletedUsernameProof: UserNameProof | undefined; + usernameProofMessage: Message | undefined; + deletedUsernameProofMessage: Message | undefined; } export interface HubEvent { @@ -160,7 +162,7 @@ export const MergeMessageBody = { const obj: any = {}; message.message !== undefined && (obj.message = message.message ? Message.toJSON(message.message) : undefined); if (message.deletedMessages) { - obj.deletedMessages = message.deletedMessages.map((e) => (e ? Message.toJSON(e) : undefined)); + obj.deletedMessages = message.deletedMessages.map((e) => e ? Message.toJSON(e) : undefined); } else { obj.deletedMessages = []; } @@ -173,8 +175,9 @@ export const MergeMessageBody = { fromPartial, I>>(object: I): MergeMessageBody { const message = createBaseMergeMessageBody(); - message.message = - object.message !== undefined && object.message !== null ? Message.fromPartial(object.message) : undefined; + message.message = (object.message !== undefined && object.message !== null) + ? Message.fromPartial(object.message) + : undefined; message.deletedMessages = object.deletedMessages?.map((e) => Message.fromPartial(e)) || []; return message; }, @@ -231,8 +234,9 @@ export const PruneMessageBody = { fromPartial, I>>(object: I): PruneMessageBody { const message = createBasePruneMessageBody(); - message.message = - object.message !== undefined && object.message !== null ? Message.fromPartial(object.message) : undefined; + message.message = (object.message !== undefined && object.message !== null) + ? Message.fromPartial(object.message) + : undefined; return message; }, }; @@ -288,8 +292,9 @@ export const RevokeMessageBody = { fromPartial, I>>(object: I): RevokeMessageBody { const message = createBaseRevokeMessageBody(); - message.message = - object.message !== undefined && object.message !== null ? Message.fromPartial(object.message) : undefined; + message.message = (object.message !== undefined && object.message !== null) + ? Message.fromPartial(object.message) + : undefined; return message; }, }; @@ -348,10 +353,9 @@ export const MergeIdRegistryEventBody = { fromPartial, I>>(object: I): MergeIdRegistryEventBody { const message = createBaseMergeIdRegistryEventBody(); - message.idRegistryEvent = - object.idRegistryEvent !== undefined && object.idRegistryEvent !== null - ? IdRegistryEvent.fromPartial(object.idRegistryEvent) - : undefined; + message.idRegistryEvent = (object.idRegistryEvent !== undefined && object.idRegistryEvent !== null) + ? IdRegistryEvent.fromPartial(object.idRegistryEvent) + : undefined; return message; }, }; @@ -401,10 +405,9 @@ export const MergeNameRegistryEventBody = { toJSON(message: MergeNameRegistryEventBody): unknown { const obj: any = {}; - message.nameRegistryEvent !== undefined && - (obj.nameRegistryEvent = message.nameRegistryEvent - ? NameRegistryEvent.toJSON(message.nameRegistryEvent) - : undefined); + message.nameRegistryEvent !== undefined && (obj.nameRegistryEvent = message.nameRegistryEvent + ? NameRegistryEvent.toJSON(message.nameRegistryEvent) + : undefined); return obj; }, @@ -414,16 +417,20 @@ export const MergeNameRegistryEventBody = { fromPartial, I>>(object: I): MergeNameRegistryEventBody { const message = createBaseMergeNameRegistryEventBody(); - message.nameRegistryEvent = - object.nameRegistryEvent !== undefined && object.nameRegistryEvent !== null - ? NameRegistryEvent.fromPartial(object.nameRegistryEvent) - : undefined; + message.nameRegistryEvent = (object.nameRegistryEvent !== undefined && object.nameRegistryEvent !== null) + ? NameRegistryEvent.fromPartial(object.nameRegistryEvent) + : undefined; return message; }, }; function createBaseMergeUserNameProofBody(): MergeUserNameProofBody { - return { usernameProof: undefined, deletedUsernameProof: undefined }; + return { + usernameProof: undefined, + deletedUsernameProof: undefined, + usernameProofMessage: undefined, + deletedUsernameProofMessage: undefined, + }; } export const MergeUserNameProofBody = { @@ -434,6 +441,12 @@ export const MergeUserNameProofBody = { if (message.deletedUsernameProof !== undefined) { UserNameProof.encode(message.deletedUsernameProof, writer.uint32(18).fork()).ldelim(); } + if (message.usernameProofMessage !== undefined) { + Message.encode(message.usernameProofMessage, writer.uint32(26).fork()).ldelim(); + } + if (message.deletedUsernameProofMessage !== undefined) { + Message.encode(message.deletedUsernameProofMessage, writer.uint32(34).fork()).ldelim(); + } return writer; }, @@ -458,6 +471,20 @@ export const MergeUserNameProofBody = { message.deletedUsernameProof = UserNameProof.decode(reader, reader.uint32()); continue; + case 3: + if (tag != 26) { + break; + } + + message.usernameProofMessage = Message.decode(reader, reader.uint32()); + continue; + case 4: + if (tag != 34) { + break; + } + + message.deletedUsernameProofMessage = Message.decode(reader, reader.uint32()); + continue; } if ((tag & 7) == 4 || tag == 0) { break; @@ -473,6 +500,12 @@ export const MergeUserNameProofBody = { deletedUsernameProof: isSet(object.deletedUsernameProof) ? UserNameProof.fromJSON(object.deletedUsernameProof) : undefined, + usernameProofMessage: isSet(object.usernameProofMessage) + ? Message.fromJSON(object.usernameProofMessage) + : undefined, + deletedUsernameProofMessage: isSet(object.deletedUsernameProofMessage) + ? Message.fromJSON(object.deletedUsernameProofMessage) + : undefined, }; }, @@ -480,9 +513,15 @@ export const MergeUserNameProofBody = { const obj: any = {}; message.usernameProof !== undefined && (obj.usernameProof = message.usernameProof ? UserNameProof.toJSON(message.usernameProof) : undefined); - message.deletedUsernameProof !== undefined && - (obj.deletedUsernameProof = message.deletedUsernameProof - ? UserNameProof.toJSON(message.deletedUsernameProof) + message.deletedUsernameProof !== undefined && (obj.deletedUsernameProof = message.deletedUsernameProof + ? UserNameProof.toJSON(message.deletedUsernameProof) + : undefined); + message.usernameProofMessage !== undefined && (obj.usernameProofMessage = message.usernameProofMessage + ? Message.toJSON(message.usernameProofMessage) + : undefined); + message.deletedUsernameProofMessage !== undefined && + (obj.deletedUsernameProofMessage = message.deletedUsernameProofMessage + ? Message.toJSON(message.deletedUsernameProofMessage) : undefined); return obj; }, @@ -493,13 +532,18 @@ export const MergeUserNameProofBody = { fromPartial, I>>(object: I): MergeUserNameProofBody { const message = createBaseMergeUserNameProofBody(); - message.usernameProof = - object.usernameProof !== undefined && object.usernameProof !== null - ? UserNameProof.fromPartial(object.usernameProof) - : undefined; - message.deletedUsernameProof = - object.deletedUsernameProof !== undefined && object.deletedUsernameProof !== null - ? UserNameProof.fromPartial(object.deletedUsernameProof) + message.usernameProof = (object.usernameProof !== undefined && object.usernameProof !== null) + ? UserNameProof.fromPartial(object.usernameProof) + : undefined; + message.deletedUsernameProof = (object.deletedUsernameProof !== undefined && object.deletedUsernameProof !== null) + ? UserNameProof.fromPartial(object.deletedUsernameProof) + : undefined; + message.usernameProofMessage = (object.usernameProofMessage !== undefined && object.usernameProofMessage !== null) + ? Message.fromPartial(object.usernameProofMessage) + : undefined; + message.deletedUsernameProofMessage = + (object.deletedUsernameProofMessage !== undefined && object.deletedUsernameProofMessage !== null) + ? Message.fromPartial(object.deletedUsernameProofMessage) : undefined; return message; }, @@ -648,22 +692,19 @@ export const HubEvent = { (obj.mergeMessageBody = message.mergeMessageBody ? MergeMessageBody.toJSON(message.mergeMessageBody) : undefined); message.pruneMessageBody !== undefined && (obj.pruneMessageBody = message.pruneMessageBody ? PruneMessageBody.toJSON(message.pruneMessageBody) : undefined); - message.revokeMessageBody !== undefined && - (obj.revokeMessageBody = message.revokeMessageBody - ? RevokeMessageBody.toJSON(message.revokeMessageBody) - : undefined); - message.mergeIdRegistryEventBody !== undefined && - (obj.mergeIdRegistryEventBody = message.mergeIdRegistryEventBody - ? MergeIdRegistryEventBody.toJSON(message.mergeIdRegistryEventBody) - : undefined); + message.revokeMessageBody !== undefined && (obj.revokeMessageBody = message.revokeMessageBody + ? RevokeMessageBody.toJSON(message.revokeMessageBody) + : undefined); + message.mergeIdRegistryEventBody !== undefined && (obj.mergeIdRegistryEventBody = message.mergeIdRegistryEventBody + ? MergeIdRegistryEventBody.toJSON(message.mergeIdRegistryEventBody) + : undefined); message.mergeNameRegistryEventBody !== undefined && (obj.mergeNameRegistryEventBody = message.mergeNameRegistryEventBody ? MergeNameRegistryEventBody.toJSON(message.mergeNameRegistryEventBody) : undefined); - message.mergeUsernameProofBody !== undefined && - (obj.mergeUsernameProofBody = message.mergeUsernameProofBody - ? MergeUserNameProofBody.toJSON(message.mergeUsernameProofBody) - : undefined); + message.mergeUsernameProofBody !== undefined && (obj.mergeUsernameProofBody = message.mergeUsernameProofBody + ? MergeUserNameProofBody.toJSON(message.mergeUsernameProofBody) + : undefined); return obj; }, @@ -675,28 +716,25 @@ export const HubEvent = { const message = createBaseHubEvent(); message.type = object.type ?? 0; message.id = object.id ?? 0; - message.mergeMessageBody = - object.mergeMessageBody !== undefined && object.mergeMessageBody !== null - ? MergeMessageBody.fromPartial(object.mergeMessageBody) - : undefined; - message.pruneMessageBody = - object.pruneMessageBody !== undefined && object.pruneMessageBody !== null - ? PruneMessageBody.fromPartial(object.pruneMessageBody) - : undefined; - message.revokeMessageBody = - object.revokeMessageBody !== undefined && object.revokeMessageBody !== null - ? RevokeMessageBody.fromPartial(object.revokeMessageBody) - : undefined; + message.mergeMessageBody = (object.mergeMessageBody !== undefined && object.mergeMessageBody !== null) + ? MergeMessageBody.fromPartial(object.mergeMessageBody) + : undefined; + message.pruneMessageBody = (object.pruneMessageBody !== undefined && object.pruneMessageBody !== null) + ? PruneMessageBody.fromPartial(object.pruneMessageBody) + : undefined; + message.revokeMessageBody = (object.revokeMessageBody !== undefined && object.revokeMessageBody !== null) + ? RevokeMessageBody.fromPartial(object.revokeMessageBody) + : undefined; message.mergeIdRegistryEventBody = - object.mergeIdRegistryEventBody !== undefined && object.mergeIdRegistryEventBody !== null + (object.mergeIdRegistryEventBody !== undefined && object.mergeIdRegistryEventBody !== null) ? MergeIdRegistryEventBody.fromPartial(object.mergeIdRegistryEventBody) : undefined; message.mergeNameRegistryEventBody = - object.mergeNameRegistryEventBody !== undefined && object.mergeNameRegistryEventBody !== null + (object.mergeNameRegistryEventBody !== undefined && object.mergeNameRegistryEventBody !== null) ? MergeNameRegistryEventBody.fromPartial(object.mergeNameRegistryEventBody) : undefined; message.mergeUsernameProofBody = - object.mergeUsernameProofBody !== undefined && object.mergeUsernameProofBody !== null + (object.mergeUsernameProofBody !== undefined && object.mergeUsernameProofBody !== null) ? MergeUserNameProofBody.fromPartial(object.mergeUsernameProofBody) : undefined; return message; @@ -707,41 +745,35 @@ declare var self: any | undefined; declare var window: any | undefined; declare var global: any | undefined; var tsProtoGlobalThis: any = (() => { - if (typeof globalThis !== 'undefined') { + if (typeof globalThis !== "undefined") { return globalThis; } - if (typeof self !== 'undefined') { + if (typeof self !== "undefined") { return self; } - if (typeof window !== 'undefined') { + if (typeof window !== "undefined") { return window; } - if (typeof global !== 'undefined') { + if (typeof global !== "undefined") { return global; } - throw 'Unable to locate global object'; + throw "Unable to locate global object"; })(); type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; -type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } +type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; type KeysOfUnion = T extends T ? keyof T : never; -type Exact = P extends Builtin - ? P +type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function longToNumber(long: Long): number { if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new tsProtoGlobalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/packages/hub-nodejs/src/generated/id_registry_event.ts b/packages/hub-nodejs/src/generated/id_registry_event.ts index 35d192b2cb..8f1a1a9610 100644 --- a/packages/hub-nodejs/src/generated/id_registry_event.ts +++ b/packages/hub-nodejs/src/generated/id_registry_event.ts @@ -1,6 +1,6 @@ /* eslint-disable */ -import Long from 'long'; -import _m0 from 'protobufjs/minimal'; +import Long from "long"; +import _m0 from "protobufjs/minimal"; export enum IdRegistryEventType { NONE = 0, @@ -11,29 +11,29 @@ export enum IdRegistryEventType { export function idRegistryEventTypeFromJSON(object: any): IdRegistryEventType { switch (object) { case 0: - case 'ID_REGISTRY_EVENT_TYPE_NONE': + case "ID_REGISTRY_EVENT_TYPE_NONE": return IdRegistryEventType.NONE; case 1: - case 'ID_REGISTRY_EVENT_TYPE_REGISTER': + case "ID_REGISTRY_EVENT_TYPE_REGISTER": return IdRegistryEventType.REGISTER; case 2: - case 'ID_REGISTRY_EVENT_TYPE_TRANSFER': + case "ID_REGISTRY_EVENT_TYPE_TRANSFER": return IdRegistryEventType.TRANSFER; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum IdRegistryEventType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum IdRegistryEventType"); } } export function idRegistryEventTypeToJSON(object: IdRegistryEventType): string { switch (object) { case IdRegistryEventType.NONE: - return 'ID_REGISTRY_EVENT_TYPE_NONE'; + return "ID_REGISTRY_EVENT_TYPE_NONE"; case IdRegistryEventType.REGISTER: - return 'ID_REGISTRY_EVENT_TYPE_REGISTER'; + return "ID_REGISTRY_EVENT_TYPE_REGISTER"; case IdRegistryEventType.TRANSFER: - return 'ID_REGISTRY_EVENT_TYPE_TRANSFER'; + return "ID_REGISTRY_EVENT_TYPE_TRANSFER"; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum IdRegistryEventType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum IdRegistryEventType"); } } @@ -182,7 +182,7 @@ export const IdRegistryEvent = { (obj.blockHash = base64FromBytes(message.blockHash !== undefined ? message.blockHash : new Uint8Array())); message.transactionHash !== undefined && (obj.transactionHash = base64FromBytes( - message.transactionHash !== undefined ? message.transactionHash : new Uint8Array() + message.transactionHash !== undefined ? message.transactionHash : new Uint8Array(), )); message.logIndex !== undefined && (obj.logIndex = Math.round(message.logIndex)); message.fid !== undefined && (obj.fid = Math.round(message.fid)); @@ -215,24 +215,24 @@ declare var self: any | undefined; declare var window: any | undefined; declare var global: any | undefined; var tsProtoGlobalThis: any = (() => { - if (typeof globalThis !== 'undefined') { + if (typeof globalThis !== "undefined") { return globalThis; } - if (typeof self !== 'undefined') { + if (typeof self !== "undefined") { return self; } - if (typeof window !== 'undefined') { + if (typeof window !== "undefined") { return window; } - if (typeof global !== 'undefined') { + if (typeof global !== "undefined") { return global; } - throw 'Unable to locate global object'; + throw "Unable to locate global object"; })(); function bytesFromBase64(b64: string): Uint8Array { if (tsProtoGlobalThis.Buffer) { - return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, 'base64')); + return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, "base64")); } else { const bin = tsProtoGlobalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -245,36 +245,30 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (tsProtoGlobalThis.Buffer) { - return tsProtoGlobalThis.Buffer.from(arr).toString('base64'); + return tsProtoGlobalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return tsProtoGlobalThis.btoa(bin.join('')); + return tsProtoGlobalThis.btoa(bin.join("")); } } type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; -type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } +type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; type KeysOfUnion = T extends T ? keyof T : never; -type Exact = P extends Builtin - ? P +type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function longToNumber(long: Long): number { if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new tsProtoGlobalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/packages/hub-nodejs/src/generated/message.ts b/packages/hub-nodejs/src/generated/message.ts index 3282b61a5f..32cdebeb7b 100644 --- a/packages/hub-nodejs/src/generated/message.ts +++ b/packages/hub-nodejs/src/generated/message.ts @@ -1,6 +1,7 @@ /* eslint-disable */ -import Long from 'long'; -import _m0 from 'protobufjs/minimal'; +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { UserNameProof } from "./username_proof"; /** Type of hashing scheme used to produce a digest of MessageData */ export enum HashScheme { @@ -12,24 +13,24 @@ export enum HashScheme { export function hashSchemeFromJSON(object: any): HashScheme { switch (object) { case 0: - case 'HASH_SCHEME_NONE': + case "HASH_SCHEME_NONE": return HashScheme.NONE; case 1: - case 'HASH_SCHEME_BLAKE3': + case "HASH_SCHEME_BLAKE3": return HashScheme.BLAKE3; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum HashScheme'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum HashScheme"); } } export function hashSchemeToJSON(object: HashScheme): string { switch (object) { case HashScheme.NONE: - return 'HASH_SCHEME_NONE'; + return "HASH_SCHEME_NONE"; case HashScheme.BLAKE3: - return 'HASH_SCHEME_BLAKE3'; + return "HASH_SCHEME_BLAKE3"; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum HashScheme'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum HashScheme"); } } @@ -45,29 +46,29 @@ export enum SignatureScheme { export function signatureSchemeFromJSON(object: any): SignatureScheme { switch (object) { case 0: - case 'SIGNATURE_SCHEME_NONE': + case "SIGNATURE_SCHEME_NONE": return SignatureScheme.NONE; case 1: - case 'SIGNATURE_SCHEME_ED25519': + case "SIGNATURE_SCHEME_ED25519": return SignatureScheme.ED25519; case 2: - case 'SIGNATURE_SCHEME_EIP712': + case "SIGNATURE_SCHEME_EIP712": return SignatureScheme.EIP712; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum SignatureScheme'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum SignatureScheme"); } } export function signatureSchemeToJSON(object: SignatureScheme): string { switch (object) { case SignatureScheme.NONE: - return 'SIGNATURE_SCHEME_NONE'; + return "SIGNATURE_SCHEME_NONE"; case SignatureScheme.ED25519: - return 'SIGNATURE_SCHEME_ED25519'; + return "SIGNATURE_SCHEME_ED25519"; case SignatureScheme.EIP712: - return 'SIGNATURE_SCHEME_EIP712'; + return "SIGNATURE_SCHEME_EIP712"; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum SignatureScheme'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum SignatureScheme"); } } @@ -96,79 +97,86 @@ export enum MessageType { SIGNER_REMOVE = 10, /** USER_DATA_ADD - Add metadata about a user */ USER_DATA_ADD = 11, + /** USERNAME_PROOF - Add or replace a username proof */ + USERNAME_PROOF = 12, } export function messageTypeFromJSON(object: any): MessageType { switch (object) { case 0: - case 'MESSAGE_TYPE_NONE': + case "MESSAGE_TYPE_NONE": return MessageType.NONE; case 1: - case 'MESSAGE_TYPE_CAST_ADD': + case "MESSAGE_TYPE_CAST_ADD": return MessageType.CAST_ADD; case 2: - case 'MESSAGE_TYPE_CAST_REMOVE': + case "MESSAGE_TYPE_CAST_REMOVE": return MessageType.CAST_REMOVE; case 3: - case 'MESSAGE_TYPE_REACTION_ADD': + case "MESSAGE_TYPE_REACTION_ADD": return MessageType.REACTION_ADD; case 4: - case 'MESSAGE_TYPE_REACTION_REMOVE': + case "MESSAGE_TYPE_REACTION_REMOVE": return MessageType.REACTION_REMOVE; case 5: - case 'MESSAGE_TYPE_LINK_ADD': + case "MESSAGE_TYPE_LINK_ADD": return MessageType.LINK_ADD; case 6: - case 'MESSAGE_TYPE_LINK_REMOVE': + case "MESSAGE_TYPE_LINK_REMOVE": return MessageType.LINK_REMOVE; case 7: - case 'MESSAGE_TYPE_VERIFICATION_ADD_ETH_ADDRESS': + case "MESSAGE_TYPE_VERIFICATION_ADD_ETH_ADDRESS": return MessageType.VERIFICATION_ADD_ETH_ADDRESS; case 8: - case 'MESSAGE_TYPE_VERIFICATION_REMOVE': + case "MESSAGE_TYPE_VERIFICATION_REMOVE": return MessageType.VERIFICATION_REMOVE; case 9: - case 'MESSAGE_TYPE_SIGNER_ADD': + case "MESSAGE_TYPE_SIGNER_ADD": return MessageType.SIGNER_ADD; case 10: - case 'MESSAGE_TYPE_SIGNER_REMOVE': + case "MESSAGE_TYPE_SIGNER_REMOVE": return MessageType.SIGNER_REMOVE; case 11: - case 'MESSAGE_TYPE_USER_DATA_ADD': + case "MESSAGE_TYPE_USER_DATA_ADD": return MessageType.USER_DATA_ADD; + case 12: + case "MESSAGE_TYPE_USERNAME_PROOF": + return MessageType.USERNAME_PROOF; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum MessageType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum MessageType"); } } export function messageTypeToJSON(object: MessageType): string { switch (object) { case MessageType.NONE: - return 'MESSAGE_TYPE_NONE'; + return "MESSAGE_TYPE_NONE"; case MessageType.CAST_ADD: - return 'MESSAGE_TYPE_CAST_ADD'; + return "MESSAGE_TYPE_CAST_ADD"; case MessageType.CAST_REMOVE: - return 'MESSAGE_TYPE_CAST_REMOVE'; + return "MESSAGE_TYPE_CAST_REMOVE"; case MessageType.REACTION_ADD: - return 'MESSAGE_TYPE_REACTION_ADD'; + return "MESSAGE_TYPE_REACTION_ADD"; case MessageType.REACTION_REMOVE: - return 'MESSAGE_TYPE_REACTION_REMOVE'; + return "MESSAGE_TYPE_REACTION_REMOVE"; case MessageType.LINK_ADD: - return 'MESSAGE_TYPE_LINK_ADD'; + return "MESSAGE_TYPE_LINK_ADD"; case MessageType.LINK_REMOVE: - return 'MESSAGE_TYPE_LINK_REMOVE'; + return "MESSAGE_TYPE_LINK_REMOVE"; case MessageType.VERIFICATION_ADD_ETH_ADDRESS: - return 'MESSAGE_TYPE_VERIFICATION_ADD_ETH_ADDRESS'; + return "MESSAGE_TYPE_VERIFICATION_ADD_ETH_ADDRESS"; case MessageType.VERIFICATION_REMOVE: - return 'MESSAGE_TYPE_VERIFICATION_REMOVE'; + return "MESSAGE_TYPE_VERIFICATION_REMOVE"; case MessageType.SIGNER_ADD: - return 'MESSAGE_TYPE_SIGNER_ADD'; + return "MESSAGE_TYPE_SIGNER_ADD"; case MessageType.SIGNER_REMOVE: - return 'MESSAGE_TYPE_SIGNER_REMOVE'; + return "MESSAGE_TYPE_SIGNER_REMOVE"; case MessageType.USER_DATA_ADD: - return 'MESSAGE_TYPE_USER_DATA_ADD'; + return "MESSAGE_TYPE_USER_DATA_ADD"; + case MessageType.USERNAME_PROOF: + return "MESSAGE_TYPE_USERNAME_PROOF"; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum MessageType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum MessageType"); } } @@ -186,34 +194,34 @@ export enum FarcasterNetwork { export function farcasterNetworkFromJSON(object: any): FarcasterNetwork { switch (object) { case 0: - case 'FARCASTER_NETWORK_NONE': + case "FARCASTER_NETWORK_NONE": return FarcasterNetwork.NONE; case 1: - case 'FARCASTER_NETWORK_MAINNET': + case "FARCASTER_NETWORK_MAINNET": return FarcasterNetwork.MAINNET; case 2: - case 'FARCASTER_NETWORK_TESTNET': + case "FARCASTER_NETWORK_TESTNET": return FarcasterNetwork.TESTNET; case 3: - case 'FARCASTER_NETWORK_DEVNET': + case "FARCASTER_NETWORK_DEVNET": return FarcasterNetwork.DEVNET; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum FarcasterNetwork'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum FarcasterNetwork"); } } export function farcasterNetworkToJSON(object: FarcasterNetwork): string { switch (object) { case FarcasterNetwork.NONE: - return 'FARCASTER_NETWORK_NONE'; + return "FARCASTER_NETWORK_NONE"; case FarcasterNetwork.MAINNET: - return 'FARCASTER_NETWORK_MAINNET'; + return "FARCASTER_NETWORK_MAINNET"; case FarcasterNetwork.TESTNET: - return 'FARCASTER_NETWORK_TESTNET'; + return "FARCASTER_NETWORK_TESTNET"; case FarcasterNetwork.DEVNET: - return 'FARCASTER_NETWORK_DEVNET'; + return "FARCASTER_NETWORK_DEVNET"; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum FarcasterNetwork'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum FarcasterNetwork"); } } @@ -235,44 +243,44 @@ export enum UserDataType { export function userDataTypeFromJSON(object: any): UserDataType { switch (object) { case 0: - case 'USER_DATA_TYPE_NONE': + case "USER_DATA_TYPE_NONE": return UserDataType.NONE; case 1: - case 'USER_DATA_TYPE_PFP': + case "USER_DATA_TYPE_PFP": return UserDataType.PFP; case 2: - case 'USER_DATA_TYPE_DISPLAY': + case "USER_DATA_TYPE_DISPLAY": return UserDataType.DISPLAY; case 3: - case 'USER_DATA_TYPE_BIO': + case "USER_DATA_TYPE_BIO": return UserDataType.BIO; case 5: - case 'USER_DATA_TYPE_URL': + case "USER_DATA_TYPE_URL": return UserDataType.URL; case 6: - case 'USER_DATA_TYPE_FNAME': + case "USER_DATA_TYPE_FNAME": return UserDataType.FNAME; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum UserDataType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum UserDataType"); } } export function userDataTypeToJSON(object: UserDataType): string { switch (object) { case UserDataType.NONE: - return 'USER_DATA_TYPE_NONE'; + return "USER_DATA_TYPE_NONE"; case UserDataType.PFP: - return 'USER_DATA_TYPE_PFP'; + return "USER_DATA_TYPE_PFP"; case UserDataType.DISPLAY: - return 'USER_DATA_TYPE_DISPLAY'; + return "USER_DATA_TYPE_DISPLAY"; case UserDataType.BIO: - return 'USER_DATA_TYPE_BIO'; + return "USER_DATA_TYPE_BIO"; case UserDataType.URL: - return 'USER_DATA_TYPE_URL'; + return "USER_DATA_TYPE_URL"; case UserDataType.FNAME: - return 'USER_DATA_TYPE_FNAME'; + return "USER_DATA_TYPE_FNAME"; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum UserDataType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum UserDataType"); } } @@ -288,29 +296,29 @@ export enum ReactionType { export function reactionTypeFromJSON(object: any): ReactionType { switch (object) { case 0: - case 'REACTION_TYPE_NONE': + case "REACTION_TYPE_NONE": return ReactionType.NONE; case 1: - case 'REACTION_TYPE_LIKE': + case "REACTION_TYPE_LIKE": return ReactionType.LIKE; case 2: - case 'REACTION_TYPE_RECAST': + case "REACTION_TYPE_RECAST": return ReactionType.RECAST; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum ReactionType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum ReactionType"); } } export function reactionTypeToJSON(object: ReactionType): string { switch (object) { case ReactionType.NONE: - return 'REACTION_TYPE_NONE'; + return "REACTION_TYPE_NONE"; case ReactionType.LIKE: - return 'REACTION_TYPE_LIKE'; + return "REACTION_TYPE_LIKE"; case ReactionType.RECAST: - return 'REACTION_TYPE_RECAST'; + return "REACTION_TYPE_RECAST"; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum ReactionType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum ReactionType"); } } @@ -320,7 +328,9 @@ export function reactionTypeToJSON(object: ReactionType): string { */ export interface Message { /** Contents of the message */ - data: MessageData | undefined; + data: + | MessageData + | undefined; /** Hash digest of data */ hash: Uint8Array; /** Hash scheme that produced the hash digest */ @@ -355,6 +365,7 @@ export interface MessageData { userDataBody?: UserDataBody | undefined; signerRemoveBody?: SignerRemoveBody | undefined; linkBody?: LinkBody | undefined; + usernameProofBody?: UserNameProof | undefined; } /** Adds an Ed25519 key pair that signs messages for a user */ @@ -391,9 +402,13 @@ export interface CastAddBody { /** Fids mentioned in the cast */ mentions: number[]; /** Parent cast of the cast */ - parentCastId?: CastId | undefined; + parentCastId?: + | CastId + | undefined; /** Parent URL */ - parentUrl?: string | undefined; + parentUrl?: + | string + | undefined; /** Text of the cast */ text: string; /** Positions of the mentions in the text */ @@ -421,7 +436,9 @@ export interface ReactionBody { /** Type of reaction */ type: ReactionType; /** CastId of the Cast to react to */ - targetCastId?: CastId | undefined; + targetCastId?: + | CastId + | undefined; /** URL to react to */ targetUrl?: string | undefined; } @@ -447,7 +464,9 @@ export interface LinkBody { /** Type of link, <= 8 characters */ type: string; /** User-defined timestamp that preserves original timestamp when message.data.timestamp needs to be updated for compaction */ - displayTimestamp?: number | undefined; + displayTimestamp?: + | number + | undefined; /** The fid the link relates to */ targetFid?: number | undefined; } @@ -575,7 +594,9 @@ export const Message = { fromPartial, I>>(object: I): Message { const message = createBaseMessage(); - message.data = object.data !== undefined && object.data !== null ? MessageData.fromPartial(object.data) : undefined; + message.data = (object.data !== undefined && object.data !== null) + ? MessageData.fromPartial(object.data) + : undefined; message.hash = object.hash ?? new Uint8Array(); message.hashScheme = object.hashScheme ?? 0; message.signature = object.signature ?? new Uint8Array(); @@ -600,6 +621,7 @@ function createBaseMessageData(): MessageData { userDataBody: undefined, signerRemoveBody: undefined, linkBody: undefined, + usernameProofBody: undefined, }; } @@ -644,6 +666,9 @@ export const MessageData = { if (message.linkBody !== undefined) { LinkBody.encode(message.linkBody, writer.uint32(114).fork()).ldelim(); } + if (message.usernameProofBody !== undefined) { + UserNameProof.encode(message.usernameProofBody, writer.uint32(122).fork()).ldelim(); + } return writer; }, @@ -745,6 +770,13 @@ export const MessageData = { message.linkBody = LinkBody.decode(reader, reader.uint32()); continue; + case 15: + if (tag != 122) { + break; + } + + message.usernameProofBody = UserNameProof.decode(reader, reader.uint32()); + continue; } if ((tag & 7) == 4 || tag == 0) { break; @@ -773,6 +805,7 @@ export const MessageData = { userDataBody: isSet(object.userDataBody) ? UserDataBody.fromJSON(object.userDataBody) : undefined, signerRemoveBody: isSet(object.signerRemoveBody) ? SignerRemoveBody.fromJSON(object.signerRemoveBody) : undefined, linkBody: isSet(object.linkBody) ? LinkBody.fromJSON(object.linkBody) : undefined, + usernameProofBody: isSet(object.usernameProofBody) ? UserNameProof.fromJSON(object.usernameProofBody) : undefined, }; }, @@ -792,10 +825,9 @@ export const MessageData = { (obj.verificationAddEthAddressBody = message.verificationAddEthAddressBody ? VerificationAddEthAddressBody.toJSON(message.verificationAddEthAddressBody) : undefined); - message.verificationRemoveBody !== undefined && - (obj.verificationRemoveBody = message.verificationRemoveBody - ? VerificationRemoveBody.toJSON(message.verificationRemoveBody) - : undefined); + message.verificationRemoveBody !== undefined && (obj.verificationRemoveBody = message.verificationRemoveBody + ? VerificationRemoveBody.toJSON(message.verificationRemoveBody) + : undefined); message.signerAddBody !== undefined && (obj.signerAddBody = message.signerAddBody ? SignerAddBody.toJSON(message.signerAddBody) : undefined); message.userDataBody !== undefined && @@ -803,6 +835,8 @@ export const MessageData = { message.signerRemoveBody !== undefined && (obj.signerRemoveBody = message.signerRemoveBody ? SignerRemoveBody.toJSON(message.signerRemoveBody) : undefined); message.linkBody !== undefined && (obj.linkBody = message.linkBody ? LinkBody.toJSON(message.linkBody) : undefined); + message.usernameProofBody !== undefined && + (obj.usernameProofBody = message.usernameProofBody ? UserNameProof.toJSON(message.usernameProofBody) : undefined); return obj; }, @@ -816,40 +850,38 @@ export const MessageData = { message.fid = object.fid ?? 0; message.timestamp = object.timestamp ?? 0; message.network = object.network ?? 0; - message.castAddBody = - object.castAddBody !== undefined && object.castAddBody !== null - ? CastAddBody.fromPartial(object.castAddBody) - : undefined; - message.castRemoveBody = - object.castRemoveBody !== undefined && object.castRemoveBody !== null - ? CastRemoveBody.fromPartial(object.castRemoveBody) - : undefined; - message.reactionBody = - object.reactionBody !== undefined && object.reactionBody !== null - ? ReactionBody.fromPartial(object.reactionBody) - : undefined; + message.castAddBody = (object.castAddBody !== undefined && object.castAddBody !== null) + ? CastAddBody.fromPartial(object.castAddBody) + : undefined; + message.castRemoveBody = (object.castRemoveBody !== undefined && object.castRemoveBody !== null) + ? CastRemoveBody.fromPartial(object.castRemoveBody) + : undefined; + message.reactionBody = (object.reactionBody !== undefined && object.reactionBody !== null) + ? ReactionBody.fromPartial(object.reactionBody) + : undefined; message.verificationAddEthAddressBody = - object.verificationAddEthAddressBody !== undefined && object.verificationAddEthAddressBody !== null + (object.verificationAddEthAddressBody !== undefined && object.verificationAddEthAddressBody !== null) ? VerificationAddEthAddressBody.fromPartial(object.verificationAddEthAddressBody) : undefined; message.verificationRemoveBody = - object.verificationRemoveBody !== undefined && object.verificationRemoveBody !== null + (object.verificationRemoveBody !== undefined && object.verificationRemoveBody !== null) ? VerificationRemoveBody.fromPartial(object.verificationRemoveBody) : undefined; - message.signerAddBody = - object.signerAddBody !== undefined && object.signerAddBody !== null - ? SignerAddBody.fromPartial(object.signerAddBody) - : undefined; - message.userDataBody = - object.userDataBody !== undefined && object.userDataBody !== null - ? UserDataBody.fromPartial(object.userDataBody) - : undefined; - message.signerRemoveBody = - object.signerRemoveBody !== undefined && object.signerRemoveBody !== null - ? SignerRemoveBody.fromPartial(object.signerRemoveBody) - : undefined; - message.linkBody = - object.linkBody !== undefined && object.linkBody !== null ? LinkBody.fromPartial(object.linkBody) : undefined; + message.signerAddBody = (object.signerAddBody !== undefined && object.signerAddBody !== null) + ? SignerAddBody.fromPartial(object.signerAddBody) + : undefined; + message.userDataBody = (object.userDataBody !== undefined && object.userDataBody !== null) + ? UserDataBody.fromPartial(object.userDataBody) + : undefined; + message.signerRemoveBody = (object.signerRemoveBody !== undefined && object.signerRemoveBody !== null) + ? SignerRemoveBody.fromPartial(object.signerRemoveBody) + : undefined; + message.linkBody = (object.linkBody !== undefined && object.linkBody !== null) + ? LinkBody.fromPartial(object.linkBody) + : undefined; + message.usernameProofBody = (object.usernameProofBody !== undefined && object.usernameProofBody !== null) + ? UserNameProof.fromPartial(object.usernameProofBody) + : undefined; return message; }, }; @@ -984,7 +1016,7 @@ export const SignerRemoveBody = { }; function createBaseUserDataBody(): UserDataBody { - return { type: 0, value: '' }; + return { type: 0, value: "" }; } export const UserDataBody = { @@ -992,7 +1024,7 @@ export const UserDataBody = { if (message.type !== 0) { writer.uint32(8).int32(message.type); } - if (message.value !== '') { + if (message.value !== "") { writer.uint32(18).string(message.value); } return writer; @@ -1031,7 +1063,7 @@ export const UserDataBody = { fromJSON(object: any): UserDataBody { return { type: isSet(object.type) ? userDataTypeFromJSON(object.type) : 0, - value: isSet(object.value) ? String(object.value) : '', + value: isSet(object.value) ? String(object.value) : "", }; }, @@ -1049,7 +1081,7 @@ export const UserDataBody = { fromPartial, I>>(object: I): UserDataBody { const message = createBaseUserDataBody(); message.type = object.type ?? 0; - message.value = object.value ?? ''; + message.value = object.value ?? ""; return message; }, }; @@ -1120,8 +1152,9 @@ export const Embed = { fromPartial, I>>(object: I): Embed { const message = createBaseEmbed(); message.url = object.url ?? undefined; - message.castId = - object.castId !== undefined && object.castId !== null ? CastId.fromPartial(object.castId) : undefined; + message.castId = (object.castId !== undefined && object.castId !== null) + ? CastId.fromPartial(object.castId) + : undefined; return message; }, }; @@ -1132,7 +1165,7 @@ function createBaseCastAddBody(): CastAddBody { mentions: [], parentCastId: undefined, parentUrl: undefined, - text: '', + text: "", mentionsPositions: [], embeds: [], }; @@ -1154,7 +1187,7 @@ export const CastAddBody = { if (message.parentUrl !== undefined) { writer.uint32(58).string(message.parentUrl); } - if (message.text !== '') { + if (message.text !== "") { writer.uint32(34).string(message.text); } writer.uint32(42).fork(); @@ -1259,7 +1292,7 @@ export const CastAddBody = { mentions: Array.isArray(object?.mentions) ? object.mentions.map((e: any) => Number(e)) : [], parentCastId: isSet(object.parentCastId) ? CastId.fromJSON(object.parentCastId) : undefined, parentUrl: isSet(object.parentUrl) ? String(object.parentUrl) : undefined, - text: isSet(object.text) ? String(object.text) : '', + text: isSet(object.text) ? String(object.text) : "", mentionsPositions: Array.isArray(object?.mentionsPositions) ? object.mentionsPositions.map((e: any) => Number(e)) : [], @@ -1289,7 +1322,7 @@ export const CastAddBody = { obj.mentionsPositions = []; } if (message.embeds) { - obj.embeds = message.embeds.map((e) => (e ? Embed.toJSON(e) : undefined)); + obj.embeds = message.embeds.map((e) => e ? Embed.toJSON(e) : undefined); } else { obj.embeds = []; } @@ -1304,12 +1337,11 @@ export const CastAddBody = { const message = createBaseCastAddBody(); message.embedsDeprecated = object.embedsDeprecated?.map((e) => e) || []; message.mentions = object.mentions?.map((e) => e) || []; - message.parentCastId = - object.parentCastId !== undefined && object.parentCastId !== null - ? CastId.fromPartial(object.parentCastId) - : undefined; + message.parentCastId = (object.parentCastId !== undefined && object.parentCastId !== null) + ? CastId.fromPartial(object.parentCastId) + : undefined; message.parentUrl = object.parentUrl ?? undefined; - message.text = object.text ?? ''; + message.text = object.text ?? ""; message.mentionsPositions = object.mentionsPositions?.map((e) => e) || []; message.embeds = object.embeds?.map((e) => Embed.fromPartial(e)) || []; return message; @@ -1524,10 +1556,9 @@ export const ReactionBody = { fromPartial, I>>(object: I): ReactionBody { const message = createBaseReactionBody(); message.type = object.type ?? 0; - message.targetCastId = - object.targetCastId !== undefined && object.targetCastId !== null - ? CastId.fromPartial(object.targetCastId) - : undefined; + message.targetCastId = (object.targetCastId !== undefined && object.targetCastId !== null) + ? CastId.fromPartial(object.targetCastId) + : undefined; message.targetUrl = object.targetUrl ?? undefined; return message; }, @@ -1602,7 +1633,7 @@ export const VerificationAddEthAddressBody = { (obj.address = base64FromBytes(message.address !== undefined ? message.address : new Uint8Array())); message.ethSignature !== undefined && (obj.ethSignature = base64FromBytes( - message.ethSignature !== undefined ? message.ethSignature : new Uint8Array() + message.ethSignature !== undefined ? message.ethSignature : new Uint8Array(), )); message.blockHash !== undefined && (obj.blockHash = base64FromBytes(message.blockHash !== undefined ? message.blockHash : new Uint8Array())); @@ -1614,7 +1645,7 @@ export const VerificationAddEthAddressBody = { }, fromPartial, I>>( - object: I + object: I, ): VerificationAddEthAddressBody { const message = createBaseVerificationAddEthAddressBody(); message.address = object.address ?? new Uint8Array(); @@ -1682,12 +1713,12 @@ export const VerificationRemoveBody = { }; function createBaseLinkBody(): LinkBody { - return { type: '', displayTimestamp: undefined, targetFid: undefined }; + return { type: "", displayTimestamp: undefined, targetFid: undefined }; } export const LinkBody = { encode(message: LinkBody, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.type !== '') { + if (message.type !== "") { writer.uint32(10).string(message.type); } if (message.displayTimestamp !== undefined) { @@ -1738,7 +1769,7 @@ export const LinkBody = { fromJSON(object: any): LinkBody { return { - type: isSet(object.type) ? String(object.type) : '', + type: isSet(object.type) ? String(object.type) : "", displayTimestamp: isSet(object.displayTimestamp) ? Number(object.displayTimestamp) : undefined, targetFid: isSet(object.targetFid) ? Number(object.targetFid) : undefined, }; @@ -1758,7 +1789,7 @@ export const LinkBody = { fromPartial, I>>(object: I): LinkBody { const message = createBaseLinkBody(); - message.type = object.type ?? ''; + message.type = object.type ?? ""; message.displayTimestamp = object.displayTimestamp ?? undefined; message.targetFid = object.targetFid ?? undefined; return message; @@ -1769,24 +1800,24 @@ declare var self: any | undefined; declare var window: any | undefined; declare var global: any | undefined; var tsProtoGlobalThis: any = (() => { - if (typeof globalThis !== 'undefined') { + if (typeof globalThis !== "undefined") { return globalThis; } - if (typeof self !== 'undefined') { + if (typeof self !== "undefined") { return self; } - if (typeof window !== 'undefined') { + if (typeof window !== "undefined") { return window; } - if (typeof global !== 'undefined') { + if (typeof global !== "undefined") { return global; } - throw 'Unable to locate global object'; + throw "Unable to locate global object"; })(); function bytesFromBase64(b64: string): Uint8Array { if (tsProtoGlobalThis.Buffer) { - return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, 'base64')); + return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, "base64")); } else { const bin = tsProtoGlobalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -1799,36 +1830,30 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (tsProtoGlobalThis.Buffer) { - return tsProtoGlobalThis.Buffer.from(arr).toString('base64'); + return tsProtoGlobalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return tsProtoGlobalThis.btoa(bin.join('')); + return tsProtoGlobalThis.btoa(bin.join("")); } } type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; -type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } +type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; type KeysOfUnion = T extends T ? keyof T : never; -type Exact = P extends Builtin - ? P +type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function longToNumber(long: Long): number { if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new tsProtoGlobalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/packages/hub-nodejs/src/generated/name_registry_event.ts b/packages/hub-nodejs/src/generated/name_registry_event.ts index b0a83e8ab3..c3da2d5215 100644 --- a/packages/hub-nodejs/src/generated/name_registry_event.ts +++ b/packages/hub-nodejs/src/generated/name_registry_event.ts @@ -1,5 +1,5 @@ /* eslint-disable */ -import _m0 from 'protobufjs/minimal'; +import _m0 from "protobufjs/minimal"; export enum NameRegistryEventType { NONE = 0, @@ -10,29 +10,29 @@ export enum NameRegistryEventType { export function nameRegistryEventTypeFromJSON(object: any): NameRegistryEventType { switch (object) { case 0: - case 'NAME_REGISTRY_EVENT_TYPE_NONE': + case "NAME_REGISTRY_EVENT_TYPE_NONE": return NameRegistryEventType.NONE; case 1: - case 'NAME_REGISTRY_EVENT_TYPE_TRANSFER': + case "NAME_REGISTRY_EVENT_TYPE_TRANSFER": return NameRegistryEventType.TRANSFER; case 2: - case 'NAME_REGISTRY_EVENT_TYPE_RENEW': + case "NAME_REGISTRY_EVENT_TYPE_RENEW": return NameRegistryEventType.RENEW; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum NameRegistryEventType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum NameRegistryEventType"); } } export function nameRegistryEventTypeToJSON(object: NameRegistryEventType): string { switch (object) { case NameRegistryEventType.NONE: - return 'NAME_REGISTRY_EVENT_TYPE_NONE'; + return "NAME_REGISTRY_EVENT_TYPE_NONE"; case NameRegistryEventType.TRANSFER: - return 'NAME_REGISTRY_EVENT_TYPE_TRANSFER'; + return "NAME_REGISTRY_EVENT_TYPE_TRANSFER"; case NameRegistryEventType.RENEW: - return 'NAME_REGISTRY_EVENT_TYPE_RENEW'; + return "NAME_REGISTRY_EVENT_TYPE_RENEW"; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum NameRegistryEventType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum NameRegistryEventType"); } } @@ -194,7 +194,7 @@ export const NameRegistryEvent = { (obj.blockHash = base64FromBytes(message.blockHash !== undefined ? message.blockHash : new Uint8Array())); message.transactionHash !== undefined && (obj.transactionHash = base64FromBytes( - message.transactionHash !== undefined ? message.transactionHash : new Uint8Array() + message.transactionHash !== undefined ? message.transactionHash : new Uint8Array(), )); message.logIndex !== undefined && (obj.logIndex = Math.round(message.logIndex)); message.fname !== undefined && @@ -230,24 +230,24 @@ declare var self: any | undefined; declare var window: any | undefined; declare var global: any | undefined; var tsProtoGlobalThis: any = (() => { - if (typeof globalThis !== 'undefined') { + if (typeof globalThis !== "undefined") { return globalThis; } - if (typeof self !== 'undefined') { + if (typeof self !== "undefined") { return self; } - if (typeof window !== 'undefined') { + if (typeof window !== "undefined") { return window; } - if (typeof global !== 'undefined') { + if (typeof global !== "undefined") { return global; } - throw 'Unable to locate global object'; + throw "Unable to locate global object"; })(); function bytesFromBase64(b64: string): Uint8Array { if (tsProtoGlobalThis.Buffer) { - return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, 'base64')); + return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, "base64")); } else { const bin = tsProtoGlobalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -260,31 +260,25 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (tsProtoGlobalThis.Buffer) { - return tsProtoGlobalThis.Buffer.from(arr).toString('base64'); + return tsProtoGlobalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return tsProtoGlobalThis.btoa(bin.join('')); + return tsProtoGlobalThis.btoa(bin.join("")); } } type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; -type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } +type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; type KeysOfUnion = T extends T ? keyof T : never; -type Exact = P extends Builtin - ? P +type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/packages/hub-nodejs/src/generated/request_response.ts b/packages/hub-nodejs/src/generated/request_response.ts index 02843b438f..5d346edb0a 100644 --- a/packages/hub-nodejs/src/generated/request_response.ts +++ b/packages/hub-nodejs/src/generated/request_response.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import Long from 'long'; -import _m0 from 'protobufjs/minimal'; -import { HubEventType, hubEventTypeFromJSON, hubEventTypeToJSON } from './hub_event'; +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { HubEventType, hubEventTypeFromJSON, hubEventTypeToJSON } from "./hub_event"; import { CastId, Message, @@ -11,9 +11,11 @@ import { UserDataType, userDataTypeFromJSON, userDataTypeToJSON, -} from './message'; +} from "./message"; +import { UserNameProof } from "./username_proof"; -export interface Empty {} +export interface Empty { +} export interface SubscribeRequest { eventTypes: HubEventType[]; @@ -153,6 +155,10 @@ export interface UsernameProofRequest { name: Uint8Array; } +export interface UsernameProofsResponse { + proofs: UserNameProof[]; +} + export interface VerificationRequest { fid: number; address: Uint8Array; @@ -436,21 +442,21 @@ export const HubInfoRequest = { }; function createBaseHubInfoResponse(): HubInfoResponse { - return { version: '', isSyncing: false, nickname: '', rootHash: '', dbStats: undefined }; + return { version: "", isSyncing: false, nickname: "", rootHash: "", dbStats: undefined }; } export const HubInfoResponse = { encode(message: HubInfoResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.version !== '') { + if (message.version !== "") { writer.uint32(10).string(message.version); } if (message.isSyncing === true) { writer.uint32(16).bool(message.isSyncing); } - if (message.nickname !== '') { + if (message.nickname !== "") { writer.uint32(26).string(message.nickname); } - if (message.rootHash !== '') { + if (message.rootHash !== "") { writer.uint32(34).string(message.rootHash); } if (message.dbStats !== undefined) { @@ -512,10 +518,10 @@ export const HubInfoResponse = { fromJSON(object: any): HubInfoResponse { return { - version: isSet(object.version) ? String(object.version) : '', + version: isSet(object.version) ? String(object.version) : "", isSyncing: isSet(object.isSyncing) ? Boolean(object.isSyncing) : false, - nickname: isSet(object.nickname) ? String(object.nickname) : '', - rootHash: isSet(object.rootHash) ? String(object.rootHash) : '', + nickname: isSet(object.nickname) ? String(object.nickname) : "", + rootHash: isSet(object.rootHash) ? String(object.rootHash) : "", dbStats: isSet(object.dbStats) ? DbStats.fromJSON(object.dbStats) : undefined, }; }, @@ -536,12 +542,13 @@ export const HubInfoResponse = { fromPartial, I>>(object: I): HubInfoResponse { const message = createBaseHubInfoResponse(); - message.version = object.version ?? ''; + message.version = object.version ?? ""; message.isSyncing = object.isSyncing ?? false; - message.nickname = object.nickname ?? ''; - message.rootHash = object.rootHash ?? ''; - message.dbStats = - object.dbStats !== undefined && object.dbStats !== null ? DbStats.fromPartial(object.dbStats) : undefined; + message.nickname = object.nickname ?? ""; + message.rootHash = object.rootHash ?? ""; + message.dbStats = (object.dbStats !== undefined && object.dbStats !== null) + ? DbStats.fromPartial(object.dbStats) + : undefined; return message; }, }; @@ -742,7 +749,7 @@ export const SyncStatusResponse = { const obj: any = {}; message.isSyncing !== undefined && (obj.isSyncing = message.isSyncing); if (message.syncStatus) { - obj.syncStatus = message.syncStatus.map((e) => (e ? SyncStatus.toJSON(e) : undefined)); + obj.syncStatus = message.syncStatus.map((e) => e ? SyncStatus.toJSON(e) : undefined); } else { obj.syncStatus = []; } @@ -763,10 +770,10 @@ export const SyncStatusResponse = { function createBaseSyncStatus(): SyncStatus { return { - peerId: '', - inSync: '', + peerId: "", + inSync: "", shouldSync: false, - divergencePrefix: '', + divergencePrefix: "", divergenceSecondsAgo: 0, theirMessages: 0, ourMessages: 0, @@ -776,16 +783,16 @@ function createBaseSyncStatus(): SyncStatus { export const SyncStatus = { encode(message: SyncStatus, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.peerId !== '') { + if (message.peerId !== "") { writer.uint32(10).string(message.peerId); } - if (message.inSync !== '') { + if (message.inSync !== "") { writer.uint32(18).string(message.inSync); } if (message.shouldSync === true) { writer.uint32(24).bool(message.shouldSync); } - if (message.divergencePrefix !== '') { + if (message.divergencePrefix !== "") { writer.uint32(34).string(message.divergencePrefix); } if (message.divergenceSecondsAgo !== 0) { @@ -877,10 +884,10 @@ export const SyncStatus = { fromJSON(object: any): SyncStatus { return { - peerId: isSet(object.peerId) ? String(object.peerId) : '', - inSync: isSet(object.inSync) ? String(object.inSync) : '', + peerId: isSet(object.peerId) ? String(object.peerId) : "", + inSync: isSet(object.inSync) ? String(object.inSync) : "", shouldSync: isSet(object.shouldSync) ? Boolean(object.shouldSync) : false, - divergencePrefix: isSet(object.divergencePrefix) ? String(object.divergencePrefix) : '', + divergencePrefix: isSet(object.divergencePrefix) ? String(object.divergencePrefix) : "", divergenceSecondsAgo: isSet(object.divergenceSecondsAgo) ? Number(object.divergenceSecondsAgo) : 0, theirMessages: isSet(object.theirMessages) ? Number(object.theirMessages) : 0, ourMessages: isSet(object.ourMessages) ? Number(object.ourMessages) : 0, @@ -907,10 +914,10 @@ export const SyncStatus = { fromPartial, I>>(object: I): SyncStatus { const message = createBaseSyncStatus(); - message.peerId = object.peerId ?? ''; - message.inSync = object.inSync ?? ''; + message.peerId = object.peerId ?? ""; + message.inSync = object.inSync ?? ""; message.shouldSync = object.shouldSync ?? false; - message.divergencePrefix = object.divergencePrefix ?? ''; + message.divergencePrefix = object.divergencePrefix ?? ""; message.divergenceSecondsAgo = object.divergenceSecondsAgo ?? 0; message.theirMessages = object.theirMessages ?? 0; message.ourMessages = object.ourMessages ?? 0; @@ -920,7 +927,7 @@ export const SyncStatus = { }; function createBaseTrieNodeMetadataResponse(): TrieNodeMetadataResponse { - return { prefix: new Uint8Array(), numMessages: 0, hash: '', children: [] }; + return { prefix: new Uint8Array(), numMessages: 0, hash: "", children: [] }; } export const TrieNodeMetadataResponse = { @@ -931,7 +938,7 @@ export const TrieNodeMetadataResponse = { if (message.numMessages !== 0) { writer.uint32(16).uint64(message.numMessages); } - if (message.hash !== '') { + if (message.hash !== "") { writer.uint32(26).string(message.hash); } for (const v of message.children) { @@ -988,7 +995,7 @@ export const TrieNodeMetadataResponse = { return { prefix: isSet(object.prefix) ? bytesFromBase64(object.prefix) : new Uint8Array(), numMessages: isSet(object.numMessages) ? Number(object.numMessages) : 0, - hash: isSet(object.hash) ? String(object.hash) : '', + hash: isSet(object.hash) ? String(object.hash) : "", children: Array.isArray(object?.children) ? object.children.map((e: any) => TrieNodeMetadataResponse.fromJSON(e)) : [], @@ -1002,7 +1009,7 @@ export const TrieNodeMetadataResponse = { message.numMessages !== undefined && (obj.numMessages = Math.round(message.numMessages)); message.hash !== undefined && (obj.hash = message.hash); if (message.children) { - obj.children = message.children.map((e) => (e ? TrieNodeMetadataResponse.toJSON(e) : undefined)); + obj.children = message.children.map((e) => e ? TrieNodeMetadataResponse.toJSON(e) : undefined); } else { obj.children = []; } @@ -1017,14 +1024,14 @@ export const TrieNodeMetadataResponse = { const message = createBaseTrieNodeMetadataResponse(); message.prefix = object.prefix ?? new Uint8Array(); message.numMessages = object.numMessages ?? 0; - message.hash = object.hash ?? ''; + message.hash = object.hash ?? ""; message.children = object.children?.map((e) => TrieNodeMetadataResponse.fromPartial(e)) || []; return message; }, }; function createBaseTrieNodeSnapshotResponse(): TrieNodeSnapshotResponse { - return { prefix: new Uint8Array(), excludedHashes: [], numMessages: 0, rootHash: '' }; + return { prefix: new Uint8Array(), excludedHashes: [], numMessages: 0, rootHash: "" }; } export const TrieNodeSnapshotResponse = { @@ -1038,7 +1045,7 @@ export const TrieNodeSnapshotResponse = { if (message.numMessages !== 0) { writer.uint32(24).uint64(message.numMessages); } - if (message.rootHash !== '') { + if (message.rootHash !== "") { writer.uint32(34).string(message.rootHash); } return writer; @@ -1093,7 +1100,7 @@ export const TrieNodeSnapshotResponse = { prefix: isSet(object.prefix) ? bytesFromBase64(object.prefix) : new Uint8Array(), excludedHashes: Array.isArray(object?.excludedHashes) ? object.excludedHashes.map((e: any) => String(e)) : [], numMessages: isSet(object.numMessages) ? Number(object.numMessages) : 0, - rootHash: isSet(object.rootHash) ? String(object.rootHash) : '', + rootHash: isSet(object.rootHash) ? String(object.rootHash) : "", }; }, @@ -1120,7 +1127,7 @@ export const TrieNodeSnapshotResponse = { message.prefix = object.prefix ?? new Uint8Array(); message.excludedHashes = object.excludedHashes?.map((e) => e) || []; message.numMessages = object.numMessages ?? 0; - message.rootHash = object.rootHash ?? ''; + message.rootHash = object.rootHash ?? ""; return message; }, }; @@ -1567,7 +1574,7 @@ export const MessagesResponse = { toJSON(message: MessagesResponse): unknown { const obj: any = {}; if (message.messages) { - obj.messages = message.messages.map((e) => (e ? Message.toJSON(e) : undefined)); + obj.messages = message.messages.map((e) => e ? Message.toJSON(e) : undefined); } else { obj.messages = []; } @@ -1697,10 +1704,9 @@ export const CastsByParentRequest = { fromPartial, I>>(object: I): CastsByParentRequest { const message = createBaseCastsByParentRequest(); - message.parentCastId = - object.parentCastId !== undefined && object.parentCastId !== null - ? CastId.fromPartial(object.parentCastId) - : undefined; + message.parentCastId = (object.parentCastId !== undefined && object.parentCastId !== null) + ? CastId.fromPartial(object.parentCastId) + : undefined; message.parentUrl = object.parentUrl ?? undefined; message.pageSize = object.pageSize ?? undefined; message.pageToken = object.pageToken ?? undefined; @@ -1801,10 +1807,9 @@ export const ReactionRequest = { const message = createBaseReactionRequest(); message.fid = object.fid ?? 0; message.reactionType = object.reactionType ?? 0; - message.targetCastId = - object.targetCastId !== undefined && object.targetCastId !== null - ? CastId.fromPartial(object.targetCastId) - : undefined; + message.targetCastId = (object.targetCastId !== undefined && object.targetCastId !== null) + ? CastId.fromPartial(object.targetCastId) + : undefined; message.targetUrl = object.targetUrl ?? undefined; return message; }, @@ -2045,10 +2050,9 @@ export const ReactionsByTargetRequest = { fromPartial, I>>(object: I): ReactionsByTargetRequest { const message = createBaseReactionsByTargetRequest(); - message.targetCastId = - object.targetCastId !== undefined && object.targetCastId !== null - ? CastId.fromPartial(object.targetCastId) - : undefined; + message.targetCastId = (object.targetCastId !== undefined && object.targetCastId !== null) + ? CastId.fromPartial(object.targetCastId) + : undefined; message.targetUrl = object.targetUrl ?? undefined; message.reactionType = object.reactionType ?? undefined; message.pageSize = object.pageSize ?? undefined; @@ -2243,6 +2247,66 @@ export const UsernameProofRequest = { }, }; +function createBaseUsernameProofsResponse(): UsernameProofsResponse { + return { proofs: [] }; +} + +export const UsernameProofsResponse = { + encode(message: UsernameProofsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.proofs) { + UserNameProof.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): UsernameProofsResponse { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUsernameProofsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag != 10) { + break; + } + + message.proofs.push(UserNameProof.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) == 4 || tag == 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): UsernameProofsResponse { + return { proofs: Array.isArray(object?.proofs) ? object.proofs.map((e: any) => UserNameProof.fromJSON(e)) : [] }; + }, + + toJSON(message: UsernameProofsResponse): unknown { + const obj: any = {}; + if (message.proofs) { + obj.proofs = message.proofs.map((e) => e ? UserNameProof.toJSON(e) : undefined); + } else { + obj.proofs = []; + } + return obj; + }, + + create, I>>(base?: I): UsernameProofsResponse { + return UsernameProofsResponse.fromPartial(base ?? {}); + }, + + fromPartial, I>>(object: I): UsernameProofsResponse { + const message = createBaseUsernameProofsResponse(); + message.proofs = object.proofs?.map((e) => UserNameProof.fromPartial(e)) || []; + return message; + }, +}; + function createBaseVerificationRequest(): VerificationRequest { return { fid: 0, address: new Uint8Array() }; } @@ -2388,7 +2452,7 @@ export const SignerRequest = { }; function createBaseLinkRequest(): LinkRequest { - return { fid: 0, linkType: '', targetFid: undefined }; + return { fid: 0, linkType: "", targetFid: undefined }; } export const LinkRequest = { @@ -2396,7 +2460,7 @@ export const LinkRequest = { if (message.fid !== 0) { writer.uint32(8).uint64(message.fid); } - if (message.linkType !== '') { + if (message.linkType !== "") { writer.uint32(18).string(message.linkType); } if (message.targetFid !== undefined) { @@ -2445,7 +2509,7 @@ export const LinkRequest = { fromJSON(object: any): LinkRequest { return { fid: isSet(object.fid) ? Number(object.fid) : 0, - linkType: isSet(object.linkType) ? String(object.linkType) : '', + linkType: isSet(object.linkType) ? String(object.linkType) : "", targetFid: isSet(object.targetFid) ? Number(object.targetFid) : undefined, }; }, @@ -2465,7 +2529,7 @@ export const LinkRequest = { fromPartial, I>>(object: I): LinkRequest { const message = createBaseLinkRequest(); message.fid = object.fid ?? 0; - message.linkType = object.linkType ?? ''; + message.linkType = object.linkType ?? ""; message.targetFid = object.targetFid ?? undefined; return message; }, @@ -2800,7 +2864,7 @@ export const IdRegistryEventByAddressRequest = { }, fromPartial, I>>( - object: I + object: I, ): IdRegistryEventByAddressRequest { const message = createBaseIdRegistryEventByAddressRequest(); message.address = object.address ?? new Uint8Array(); @@ -2812,24 +2876,24 @@ declare var self: any | undefined; declare var window: any | undefined; declare var global: any | undefined; var tsProtoGlobalThis: any = (() => { - if (typeof globalThis !== 'undefined') { + if (typeof globalThis !== "undefined") { return globalThis; } - if (typeof self !== 'undefined') { + if (typeof self !== "undefined") { return self; } - if (typeof window !== 'undefined') { + if (typeof window !== "undefined") { return window; } - if (typeof global !== 'undefined') { + if (typeof global !== "undefined") { return global; } - throw 'Unable to locate global object'; + throw "Unable to locate global object"; })(); function bytesFromBase64(b64: string): Uint8Array { if (tsProtoGlobalThis.Buffer) { - return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, 'base64')); + return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, "base64")); } else { const bin = tsProtoGlobalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -2842,36 +2906,30 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (tsProtoGlobalThis.Buffer) { - return tsProtoGlobalThis.Buffer.from(arr).toString('base64'); + return tsProtoGlobalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return tsProtoGlobalThis.btoa(bin.join('')); + return tsProtoGlobalThis.btoa(bin.join("")); } } type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; -type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } +type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; type KeysOfUnion = T extends T ? keyof T : never; -type Exact = P extends Builtin - ? P +type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function longToNumber(long: Long): number { if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new tsProtoGlobalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/packages/hub-nodejs/src/generated/rpc.ts b/packages/hub-nodejs/src/generated/rpc.ts index e26e3f56a0..461321b397 100644 --- a/packages/hub-nodejs/src/generated/rpc.ts +++ b/packages/hub-nodejs/src/generated/rpc.ts @@ -12,11 +12,11 @@ import { Metadata, ServiceError, UntypedServiceImplementation, -} from '@grpc/grpc-js'; -import { HubEvent } from './hub_event'; -import { IdRegistryEvent } from './id_registry_event'; -import { CastId, Message } from './message'; -import { NameRegistryEvent } from './name_registry_event'; +} from "@grpc/grpc-js"; +import { HubEvent } from "./hub_event"; +import { IdRegistryEvent } from "./id_registry_event"; +import { CastId, Message } from "./message"; +import { NameRegistryEvent } from "./name_registry_event"; import { CastsByParentRequest, Empty, @@ -46,15 +46,16 @@ import { TrieNodeSnapshotResponse, UserDataRequest, UsernameProofRequest, + UsernameProofsResponse, VerificationRequest, -} from './request_response'; -import { UserNameProof } from './username_proof'; +} from "./request_response"; +import { UserNameProof } from "./username_proof"; export type HubServiceService = typeof HubServiceService; export const HubServiceService = { /** Submit Methods */ submitMessage: { - path: '/HubService/SubmitMessage', + path: "/HubService/SubmitMessage", requestStream: false, responseStream: false, requestSerialize: (value: Message) => Buffer.from(Message.encode(value).finish()), @@ -64,7 +65,7 @@ export const HubServiceService = { }, /** Event Methods */ subscribe: { - path: '/HubService/Subscribe', + path: "/HubService/Subscribe", requestStream: false, responseStream: true, requestSerialize: (value: SubscribeRequest) => Buffer.from(SubscribeRequest.encode(value).finish()), @@ -73,7 +74,7 @@ export const HubServiceService = { responseDeserialize: (value: Buffer) => HubEvent.decode(value), }, getEvent: { - path: '/HubService/GetEvent', + path: "/HubService/GetEvent", requestStream: false, responseStream: false, requestSerialize: (value: EventRequest) => Buffer.from(EventRequest.encode(value).finish()), @@ -83,7 +84,7 @@ export const HubServiceService = { }, /** Casts */ getCast: { - path: '/HubService/GetCast', + path: "/HubService/GetCast", requestStream: false, responseStream: false, requestSerialize: (value: CastId) => Buffer.from(CastId.encode(value).finish()), @@ -92,7 +93,7 @@ export const HubServiceService = { responseDeserialize: (value: Buffer) => Message.decode(value), }, getCastsByFid: { - path: '/HubService/GetCastsByFid', + path: "/HubService/GetCastsByFid", requestStream: false, responseStream: false, requestSerialize: (value: FidRequest) => Buffer.from(FidRequest.encode(value).finish()), @@ -101,7 +102,7 @@ export const HubServiceService = { responseDeserialize: (value: Buffer) => MessagesResponse.decode(value), }, getCastsByParent: { - path: '/HubService/GetCastsByParent', + path: "/HubService/GetCastsByParent", requestStream: false, responseStream: false, requestSerialize: (value: CastsByParentRequest) => Buffer.from(CastsByParentRequest.encode(value).finish()), @@ -110,7 +111,7 @@ export const HubServiceService = { responseDeserialize: (value: Buffer) => MessagesResponse.decode(value), }, getCastsByMention: { - path: '/HubService/GetCastsByMention', + path: "/HubService/GetCastsByMention", requestStream: false, responseStream: false, requestSerialize: (value: FidRequest) => Buffer.from(FidRequest.encode(value).finish()), @@ -120,7 +121,7 @@ export const HubServiceService = { }, /** Reactions */ getReaction: { - path: '/HubService/GetReaction', + path: "/HubService/GetReaction", requestStream: false, responseStream: false, requestSerialize: (value: ReactionRequest) => Buffer.from(ReactionRequest.encode(value).finish()), @@ -129,7 +130,7 @@ export const HubServiceService = { responseDeserialize: (value: Buffer) => Message.decode(value), }, getReactionsByFid: { - path: '/HubService/GetReactionsByFid', + path: "/HubService/GetReactionsByFid", requestStream: false, responseStream: false, requestSerialize: (value: ReactionsByFidRequest) => Buffer.from(ReactionsByFidRequest.encode(value).finish()), @@ -139,7 +140,7 @@ export const HubServiceService = { }, /** To be deprecated */ getReactionsByCast: { - path: '/HubService/GetReactionsByCast', + path: "/HubService/GetReactionsByCast", requestStream: false, responseStream: false, requestSerialize: (value: ReactionsByTargetRequest) => Buffer.from(ReactionsByTargetRequest.encode(value).finish()), @@ -148,7 +149,7 @@ export const HubServiceService = { responseDeserialize: (value: Buffer) => MessagesResponse.decode(value), }, getReactionsByTarget: { - path: '/HubService/GetReactionsByTarget', + path: "/HubService/GetReactionsByTarget", requestStream: false, responseStream: false, requestSerialize: (value: ReactionsByTargetRequest) => Buffer.from(ReactionsByTargetRequest.encode(value).finish()), @@ -158,7 +159,7 @@ export const HubServiceService = { }, /** User Data */ getUserData: { - path: '/HubService/GetUserData', + path: "/HubService/GetUserData", requestStream: false, responseStream: false, requestSerialize: (value: UserDataRequest) => Buffer.from(UserDataRequest.encode(value).finish()), @@ -167,7 +168,7 @@ export const HubServiceService = { responseDeserialize: (value: Buffer) => Message.decode(value), }, getUserDataByFid: { - path: '/HubService/GetUserDataByFid', + path: "/HubService/GetUserDataByFid", requestStream: false, responseStream: false, requestSerialize: (value: FidRequest) => Buffer.from(FidRequest.encode(value).finish()), @@ -176,7 +177,7 @@ export const HubServiceService = { responseDeserialize: (value: Buffer) => MessagesResponse.decode(value), }, getNameRegistryEvent: { - path: '/HubService/GetNameRegistryEvent', + path: "/HubService/GetNameRegistryEvent", requestStream: false, responseStream: false, requestSerialize: (value: NameRegistryEventRequest) => Buffer.from(NameRegistryEventRequest.encode(value).finish()), @@ -184,8 +185,9 @@ export const HubServiceService = { responseSerialize: (value: NameRegistryEvent) => Buffer.from(NameRegistryEvent.encode(value).finish()), responseDeserialize: (value: Buffer) => NameRegistryEvent.decode(value), }, + /** Username Proof */ getUsernameProof: { - path: '/HubService/GetUsernameProof', + path: "/HubService/GetUsernameProof", requestStream: false, responseStream: false, requestSerialize: (value: UsernameProofRequest) => Buffer.from(UsernameProofRequest.encode(value).finish()), @@ -193,9 +195,18 @@ export const HubServiceService = { responseSerialize: (value: UserNameProof) => Buffer.from(UserNameProof.encode(value).finish()), responseDeserialize: (value: Buffer) => UserNameProof.decode(value), }, + getUserNameProofsByFid: { + path: "/HubService/GetUserNameProofsByFid", + requestStream: false, + responseStream: false, + requestSerialize: (value: FidRequest) => Buffer.from(FidRequest.encode(value).finish()), + requestDeserialize: (value: Buffer) => FidRequest.decode(value), + responseSerialize: (value: UsernameProofsResponse) => Buffer.from(UsernameProofsResponse.encode(value).finish()), + responseDeserialize: (value: Buffer) => UsernameProofsResponse.decode(value), + }, /** Verifications */ getVerification: { - path: '/HubService/GetVerification', + path: "/HubService/GetVerification", requestStream: false, responseStream: false, requestSerialize: (value: VerificationRequest) => Buffer.from(VerificationRequest.encode(value).finish()), @@ -204,7 +215,7 @@ export const HubServiceService = { responseDeserialize: (value: Buffer) => Message.decode(value), }, getVerificationsByFid: { - path: '/HubService/GetVerificationsByFid', + path: "/HubService/GetVerificationsByFid", requestStream: false, responseStream: false, requestSerialize: (value: FidRequest) => Buffer.from(FidRequest.encode(value).finish()), @@ -214,7 +225,7 @@ export const HubServiceService = { }, /** Signer */ getSigner: { - path: '/HubService/GetSigner', + path: "/HubService/GetSigner", requestStream: false, responseStream: false, requestSerialize: (value: SignerRequest) => Buffer.from(SignerRequest.encode(value).finish()), @@ -223,7 +234,7 @@ export const HubServiceService = { responseDeserialize: (value: Buffer) => Message.decode(value), }, getSignersByFid: { - path: '/HubService/GetSignersByFid', + path: "/HubService/GetSignersByFid", requestStream: false, responseStream: false, requestSerialize: (value: FidRequest) => Buffer.from(FidRequest.encode(value).finish()), @@ -232,7 +243,7 @@ export const HubServiceService = { responseDeserialize: (value: Buffer) => MessagesResponse.decode(value), }, getIdRegistryEvent: { - path: '/HubService/GetIdRegistryEvent', + path: "/HubService/GetIdRegistryEvent", requestStream: false, responseStream: false, requestSerialize: (value: IdRegistryEventRequest) => Buffer.from(IdRegistryEventRequest.encode(value).finish()), @@ -241,7 +252,7 @@ export const HubServiceService = { responseDeserialize: (value: Buffer) => IdRegistryEvent.decode(value), }, getIdRegistryEventByAddress: { - path: '/HubService/GetIdRegistryEventByAddress', + path: "/HubService/GetIdRegistryEventByAddress", requestStream: false, responseStream: false, requestSerialize: (value: IdRegistryEventByAddressRequest) => @@ -251,7 +262,7 @@ export const HubServiceService = { responseDeserialize: (value: Buffer) => IdRegistryEvent.decode(value), }, getFids: { - path: '/HubService/GetFids', + path: "/HubService/GetFids", requestStream: false, responseStream: false, requestSerialize: (value: FidsRequest) => Buffer.from(FidsRequest.encode(value).finish()), @@ -261,7 +272,7 @@ export const HubServiceService = { }, /** Links */ getLink: { - path: '/HubService/GetLink', + path: "/HubService/GetLink", requestStream: false, responseStream: false, requestSerialize: (value: LinkRequest) => Buffer.from(LinkRequest.encode(value).finish()), @@ -270,7 +281,7 @@ export const HubServiceService = { responseDeserialize: (value: Buffer) => Message.decode(value), }, getLinksByFid: { - path: '/HubService/GetLinksByFid', + path: "/HubService/GetLinksByFid", requestStream: false, responseStream: false, requestSerialize: (value: LinksByFidRequest) => Buffer.from(LinksByFidRequest.encode(value).finish()), @@ -279,7 +290,7 @@ export const HubServiceService = { responseDeserialize: (value: Buffer) => MessagesResponse.decode(value), }, getLinksByTarget: { - path: '/HubService/GetLinksByTarget', + path: "/HubService/GetLinksByTarget", requestStream: false, responseStream: false, requestSerialize: (value: LinksByTargetRequest) => Buffer.from(LinksByTargetRequest.encode(value).finish()), @@ -289,7 +300,7 @@ export const HubServiceService = { }, /** Bulk Methods */ getAllCastMessagesByFid: { - path: '/HubService/GetAllCastMessagesByFid', + path: "/HubService/GetAllCastMessagesByFid", requestStream: false, responseStream: false, requestSerialize: (value: FidRequest) => Buffer.from(FidRequest.encode(value).finish()), @@ -298,7 +309,7 @@ export const HubServiceService = { responseDeserialize: (value: Buffer) => MessagesResponse.decode(value), }, getAllReactionMessagesByFid: { - path: '/HubService/GetAllReactionMessagesByFid', + path: "/HubService/GetAllReactionMessagesByFid", requestStream: false, responseStream: false, requestSerialize: (value: FidRequest) => Buffer.from(FidRequest.encode(value).finish()), @@ -307,7 +318,7 @@ export const HubServiceService = { responseDeserialize: (value: Buffer) => MessagesResponse.decode(value), }, getAllVerificationMessagesByFid: { - path: '/HubService/GetAllVerificationMessagesByFid', + path: "/HubService/GetAllVerificationMessagesByFid", requestStream: false, responseStream: false, requestSerialize: (value: FidRequest) => Buffer.from(FidRequest.encode(value).finish()), @@ -316,7 +327,7 @@ export const HubServiceService = { responseDeserialize: (value: Buffer) => MessagesResponse.decode(value), }, getAllSignerMessagesByFid: { - path: '/HubService/GetAllSignerMessagesByFid', + path: "/HubService/GetAllSignerMessagesByFid", requestStream: false, responseStream: false, requestSerialize: (value: FidRequest) => Buffer.from(FidRequest.encode(value).finish()), @@ -325,7 +336,7 @@ export const HubServiceService = { responseDeserialize: (value: Buffer) => MessagesResponse.decode(value), }, getAllUserDataMessagesByFid: { - path: '/HubService/GetAllUserDataMessagesByFid', + path: "/HubService/GetAllUserDataMessagesByFid", requestStream: false, responseStream: false, requestSerialize: (value: FidRequest) => Buffer.from(FidRequest.encode(value).finish()), @@ -334,7 +345,7 @@ export const HubServiceService = { responseDeserialize: (value: Buffer) => MessagesResponse.decode(value), }, getAllLinkMessagesByFid: { - path: '/HubService/GetAllLinkMessagesByFid', + path: "/HubService/GetAllLinkMessagesByFid", requestStream: false, responseStream: false, requestSerialize: (value: FidRequest) => Buffer.from(FidRequest.encode(value).finish()), @@ -344,7 +355,7 @@ export const HubServiceService = { }, /** Sync Methods */ getInfo: { - path: '/HubService/GetInfo', + path: "/HubService/GetInfo", requestStream: false, responseStream: false, requestSerialize: (value: HubInfoRequest) => Buffer.from(HubInfoRequest.encode(value).finish()), @@ -353,7 +364,7 @@ export const HubServiceService = { responseDeserialize: (value: Buffer) => HubInfoResponse.decode(value), }, getSyncStatus: { - path: '/HubService/GetSyncStatus', + path: "/HubService/GetSyncStatus", requestStream: false, responseStream: false, requestSerialize: (value: SyncStatusRequest) => Buffer.from(SyncStatusRequest.encode(value).finish()), @@ -362,7 +373,7 @@ export const HubServiceService = { responseDeserialize: (value: Buffer) => SyncStatusResponse.decode(value), }, getAllSyncIdsByPrefix: { - path: '/HubService/GetAllSyncIdsByPrefix', + path: "/HubService/GetAllSyncIdsByPrefix", requestStream: false, responseStream: false, requestSerialize: (value: TrieNodePrefix) => Buffer.from(TrieNodePrefix.encode(value).finish()), @@ -371,7 +382,7 @@ export const HubServiceService = { responseDeserialize: (value: Buffer) => SyncIds.decode(value), }, getAllMessagesBySyncIds: { - path: '/HubService/GetAllMessagesBySyncIds', + path: "/HubService/GetAllMessagesBySyncIds", requestStream: false, responseStream: false, requestSerialize: (value: SyncIds) => Buffer.from(SyncIds.encode(value).finish()), @@ -380,7 +391,7 @@ export const HubServiceService = { responseDeserialize: (value: Buffer) => MessagesResponse.decode(value), }, getSyncMetadataByPrefix: { - path: '/HubService/GetSyncMetadataByPrefix', + path: "/HubService/GetSyncMetadataByPrefix", requestStream: false, responseStream: false, requestSerialize: (value: TrieNodePrefix) => Buffer.from(TrieNodePrefix.encode(value).finish()), @@ -390,7 +401,7 @@ export const HubServiceService = { responseDeserialize: (value: Buffer) => TrieNodeMetadataResponse.decode(value), }, getSyncSnapshotByPrefix: { - path: '/HubService/GetSyncSnapshotByPrefix', + path: "/HubService/GetSyncSnapshotByPrefix", requestStream: false, responseStream: false, requestSerialize: (value: TrieNodePrefix) => Buffer.from(TrieNodePrefix.encode(value).finish()), @@ -422,7 +433,9 @@ export interface HubServiceServer extends UntypedServiceImplementation { getUserData: handleUnaryCall; getUserDataByFid: handleUnaryCall; getNameRegistryEvent: handleUnaryCall; + /** Username Proof */ getUsernameProof: handleUnaryCall; + getUserNameProofsByFid: handleUnaryCall; /** Verifications */ getVerification: handleUnaryCall; getVerificationsByFid: handleUnaryCall; @@ -458,546 +471,562 @@ export interface HubServiceClient extends Client { submitMessage( request: Message, metadata: Metadata, - callback: (error: ServiceError | null, response: Message) => void + callback: (error: ServiceError | null, response: Message) => void, ): ClientUnaryCall; submitMessage( request: Message, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: Message) => void + callback: (error: ServiceError | null, response: Message) => void, ): ClientUnaryCall; /** Event Methods */ subscribe(request: SubscribeRequest, options?: Partial): ClientReadableStream; subscribe( request: SubscribeRequest, metadata?: Metadata, - options?: Partial + options?: Partial, ): ClientReadableStream; getEvent(request: EventRequest, callback: (error: ServiceError | null, response: HubEvent) => void): ClientUnaryCall; getEvent( request: EventRequest, metadata: Metadata, - callback: (error: ServiceError | null, response: HubEvent) => void + callback: (error: ServiceError | null, response: HubEvent) => void, ): ClientUnaryCall; getEvent( request: EventRequest, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: HubEvent) => void + callback: (error: ServiceError | null, response: HubEvent) => void, ): ClientUnaryCall; /** Casts */ getCast(request: CastId, callback: (error: ServiceError | null, response: Message) => void): ClientUnaryCall; getCast( request: CastId, metadata: Metadata, - callback: (error: ServiceError | null, response: Message) => void + callback: (error: ServiceError | null, response: Message) => void, ): ClientUnaryCall; getCast( request: CastId, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: Message) => void + callback: (error: ServiceError | null, response: Message) => void, ): ClientUnaryCall; getCastsByFid( request: FidRequest, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getCastsByFid( request: FidRequest, metadata: Metadata, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getCastsByFid( request: FidRequest, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getCastsByParent( request: CastsByParentRequest, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getCastsByParent( request: CastsByParentRequest, metadata: Metadata, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getCastsByParent( request: CastsByParentRequest, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getCastsByMention( request: FidRequest, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getCastsByMention( request: FidRequest, metadata: Metadata, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getCastsByMention( request: FidRequest, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; /** Reactions */ getReaction( request: ReactionRequest, - callback: (error: ServiceError | null, response: Message) => void + callback: (error: ServiceError | null, response: Message) => void, ): ClientUnaryCall; getReaction( request: ReactionRequest, metadata: Metadata, - callback: (error: ServiceError | null, response: Message) => void + callback: (error: ServiceError | null, response: Message) => void, ): ClientUnaryCall; getReaction( request: ReactionRequest, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: Message) => void + callback: (error: ServiceError | null, response: Message) => void, ): ClientUnaryCall; getReactionsByFid( request: ReactionsByFidRequest, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getReactionsByFid( request: ReactionsByFidRequest, metadata: Metadata, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getReactionsByFid( request: ReactionsByFidRequest, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; /** To be deprecated */ getReactionsByCast( request: ReactionsByTargetRequest, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getReactionsByCast( request: ReactionsByTargetRequest, metadata: Metadata, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getReactionsByCast( request: ReactionsByTargetRequest, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getReactionsByTarget( request: ReactionsByTargetRequest, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getReactionsByTarget( request: ReactionsByTargetRequest, metadata: Metadata, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getReactionsByTarget( request: ReactionsByTargetRequest, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; /** User Data */ getUserData( request: UserDataRequest, - callback: (error: ServiceError | null, response: Message) => void + callback: (error: ServiceError | null, response: Message) => void, ): ClientUnaryCall; getUserData( request: UserDataRequest, metadata: Metadata, - callback: (error: ServiceError | null, response: Message) => void + callback: (error: ServiceError | null, response: Message) => void, ): ClientUnaryCall; getUserData( request: UserDataRequest, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: Message) => void + callback: (error: ServiceError | null, response: Message) => void, ): ClientUnaryCall; getUserDataByFid( request: FidRequest, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getUserDataByFid( request: FidRequest, metadata: Metadata, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getUserDataByFid( request: FidRequest, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getNameRegistryEvent( request: NameRegistryEventRequest, - callback: (error: ServiceError | null, response: NameRegistryEvent) => void + callback: (error: ServiceError | null, response: NameRegistryEvent) => void, ): ClientUnaryCall; getNameRegistryEvent( request: NameRegistryEventRequest, metadata: Metadata, - callback: (error: ServiceError | null, response: NameRegistryEvent) => void + callback: (error: ServiceError | null, response: NameRegistryEvent) => void, ): ClientUnaryCall; getNameRegistryEvent( request: NameRegistryEventRequest, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: NameRegistryEvent) => void + callback: (error: ServiceError | null, response: NameRegistryEvent) => void, ): ClientUnaryCall; + /** Username Proof */ getUsernameProof( request: UsernameProofRequest, - callback: (error: ServiceError | null, response: UserNameProof) => void + callback: (error: ServiceError | null, response: UserNameProof) => void, ): ClientUnaryCall; getUsernameProof( request: UsernameProofRequest, metadata: Metadata, - callback: (error: ServiceError | null, response: UserNameProof) => void + callback: (error: ServiceError | null, response: UserNameProof) => void, ): ClientUnaryCall; getUsernameProof( request: UsernameProofRequest, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: UserNameProof) => void + callback: (error: ServiceError | null, response: UserNameProof) => void, + ): ClientUnaryCall; + getUserNameProofsByFid( + request: FidRequest, + callback: (error: ServiceError | null, response: UsernameProofsResponse) => void, + ): ClientUnaryCall; + getUserNameProofsByFid( + request: FidRequest, + metadata: Metadata, + callback: (error: ServiceError | null, response: UsernameProofsResponse) => void, + ): ClientUnaryCall; + getUserNameProofsByFid( + request: FidRequest, + metadata: Metadata, + options: Partial, + callback: (error: ServiceError | null, response: UsernameProofsResponse) => void, ): ClientUnaryCall; /** Verifications */ getVerification( request: VerificationRequest, - callback: (error: ServiceError | null, response: Message) => void + callback: (error: ServiceError | null, response: Message) => void, ): ClientUnaryCall; getVerification( request: VerificationRequest, metadata: Metadata, - callback: (error: ServiceError | null, response: Message) => void + callback: (error: ServiceError | null, response: Message) => void, ): ClientUnaryCall; getVerification( request: VerificationRequest, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: Message) => void + callback: (error: ServiceError | null, response: Message) => void, ): ClientUnaryCall; getVerificationsByFid( request: FidRequest, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getVerificationsByFid( request: FidRequest, metadata: Metadata, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getVerificationsByFid( request: FidRequest, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; /** Signer */ getSigner(request: SignerRequest, callback: (error: ServiceError | null, response: Message) => void): ClientUnaryCall; getSigner( request: SignerRequest, metadata: Metadata, - callback: (error: ServiceError | null, response: Message) => void + callback: (error: ServiceError | null, response: Message) => void, ): ClientUnaryCall; getSigner( request: SignerRequest, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: Message) => void + callback: (error: ServiceError | null, response: Message) => void, ): ClientUnaryCall; getSignersByFid( request: FidRequest, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getSignersByFid( request: FidRequest, metadata: Metadata, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getSignersByFid( request: FidRequest, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getIdRegistryEvent( request: IdRegistryEventRequest, - callback: (error: ServiceError | null, response: IdRegistryEvent) => void + callback: (error: ServiceError | null, response: IdRegistryEvent) => void, ): ClientUnaryCall; getIdRegistryEvent( request: IdRegistryEventRequest, metadata: Metadata, - callback: (error: ServiceError | null, response: IdRegistryEvent) => void + callback: (error: ServiceError | null, response: IdRegistryEvent) => void, ): ClientUnaryCall; getIdRegistryEvent( request: IdRegistryEventRequest, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: IdRegistryEvent) => void + callback: (error: ServiceError | null, response: IdRegistryEvent) => void, ): ClientUnaryCall; getIdRegistryEventByAddress( request: IdRegistryEventByAddressRequest, - callback: (error: ServiceError | null, response: IdRegistryEvent) => void + callback: (error: ServiceError | null, response: IdRegistryEvent) => void, ): ClientUnaryCall; getIdRegistryEventByAddress( request: IdRegistryEventByAddressRequest, metadata: Metadata, - callback: (error: ServiceError | null, response: IdRegistryEvent) => void + callback: (error: ServiceError | null, response: IdRegistryEvent) => void, ): ClientUnaryCall; getIdRegistryEventByAddress( request: IdRegistryEventByAddressRequest, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: IdRegistryEvent) => void + callback: (error: ServiceError | null, response: IdRegistryEvent) => void, ): ClientUnaryCall; getFids( request: FidsRequest, - callback: (error: ServiceError | null, response: FidsResponse) => void + callback: (error: ServiceError | null, response: FidsResponse) => void, ): ClientUnaryCall; getFids( request: FidsRequest, metadata: Metadata, - callback: (error: ServiceError | null, response: FidsResponse) => void + callback: (error: ServiceError | null, response: FidsResponse) => void, ): ClientUnaryCall; getFids( request: FidsRequest, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: FidsResponse) => void + callback: (error: ServiceError | null, response: FidsResponse) => void, ): ClientUnaryCall; /** Links */ getLink(request: LinkRequest, callback: (error: ServiceError | null, response: Message) => void): ClientUnaryCall; getLink( request: LinkRequest, metadata: Metadata, - callback: (error: ServiceError | null, response: Message) => void + callback: (error: ServiceError | null, response: Message) => void, ): ClientUnaryCall; getLink( request: LinkRequest, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: Message) => void + callback: (error: ServiceError | null, response: Message) => void, ): ClientUnaryCall; getLinksByFid( request: LinksByFidRequest, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getLinksByFid( request: LinksByFidRequest, metadata: Metadata, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getLinksByFid( request: LinksByFidRequest, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getLinksByTarget( request: LinksByTargetRequest, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getLinksByTarget( request: LinksByTargetRequest, metadata: Metadata, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getLinksByTarget( request: LinksByTargetRequest, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; /** Bulk Methods */ getAllCastMessagesByFid( request: FidRequest, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getAllCastMessagesByFid( request: FidRequest, metadata: Metadata, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getAllCastMessagesByFid( request: FidRequest, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getAllReactionMessagesByFid( request: FidRequest, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getAllReactionMessagesByFid( request: FidRequest, metadata: Metadata, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getAllReactionMessagesByFid( request: FidRequest, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getAllVerificationMessagesByFid( request: FidRequest, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getAllVerificationMessagesByFid( request: FidRequest, metadata: Metadata, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getAllVerificationMessagesByFid( request: FidRequest, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getAllSignerMessagesByFid( request: FidRequest, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getAllSignerMessagesByFid( request: FidRequest, metadata: Metadata, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getAllSignerMessagesByFid( request: FidRequest, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getAllUserDataMessagesByFid( request: FidRequest, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getAllUserDataMessagesByFid( request: FidRequest, metadata: Metadata, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getAllUserDataMessagesByFid( request: FidRequest, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getAllLinkMessagesByFid( request: FidRequest, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getAllLinkMessagesByFid( request: FidRequest, metadata: Metadata, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getAllLinkMessagesByFid( request: FidRequest, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; /** Sync Methods */ getInfo( request: HubInfoRequest, - callback: (error: ServiceError | null, response: HubInfoResponse) => void + callback: (error: ServiceError | null, response: HubInfoResponse) => void, ): ClientUnaryCall; getInfo( request: HubInfoRequest, metadata: Metadata, - callback: (error: ServiceError | null, response: HubInfoResponse) => void + callback: (error: ServiceError | null, response: HubInfoResponse) => void, ): ClientUnaryCall; getInfo( request: HubInfoRequest, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: HubInfoResponse) => void + callback: (error: ServiceError | null, response: HubInfoResponse) => void, ): ClientUnaryCall; getSyncStatus( request: SyncStatusRequest, - callback: (error: ServiceError | null, response: SyncStatusResponse) => void + callback: (error: ServiceError | null, response: SyncStatusResponse) => void, ): ClientUnaryCall; getSyncStatus( request: SyncStatusRequest, metadata: Metadata, - callback: (error: ServiceError | null, response: SyncStatusResponse) => void + callback: (error: ServiceError | null, response: SyncStatusResponse) => void, ): ClientUnaryCall; getSyncStatus( request: SyncStatusRequest, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: SyncStatusResponse) => void + callback: (error: ServiceError | null, response: SyncStatusResponse) => void, ): ClientUnaryCall; getAllSyncIdsByPrefix( request: TrieNodePrefix, - callback: (error: ServiceError | null, response: SyncIds) => void + callback: (error: ServiceError | null, response: SyncIds) => void, ): ClientUnaryCall; getAllSyncIdsByPrefix( request: TrieNodePrefix, metadata: Metadata, - callback: (error: ServiceError | null, response: SyncIds) => void + callback: (error: ServiceError | null, response: SyncIds) => void, ): ClientUnaryCall; getAllSyncIdsByPrefix( request: TrieNodePrefix, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: SyncIds) => void + callback: (error: ServiceError | null, response: SyncIds) => void, ): ClientUnaryCall; getAllMessagesBySyncIds( request: SyncIds, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getAllMessagesBySyncIds( request: SyncIds, metadata: Metadata, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getAllMessagesBySyncIds( request: SyncIds, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: MessagesResponse) => void + callback: (error: ServiceError | null, response: MessagesResponse) => void, ): ClientUnaryCall; getSyncMetadataByPrefix( request: TrieNodePrefix, - callback: (error: ServiceError | null, response: TrieNodeMetadataResponse) => void + callback: (error: ServiceError | null, response: TrieNodeMetadataResponse) => void, ): ClientUnaryCall; getSyncMetadataByPrefix( request: TrieNodePrefix, metadata: Metadata, - callback: (error: ServiceError | null, response: TrieNodeMetadataResponse) => void + callback: (error: ServiceError | null, response: TrieNodeMetadataResponse) => void, ): ClientUnaryCall; getSyncMetadataByPrefix( request: TrieNodePrefix, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: TrieNodeMetadataResponse) => void + callback: (error: ServiceError | null, response: TrieNodeMetadataResponse) => void, ): ClientUnaryCall; getSyncSnapshotByPrefix( request: TrieNodePrefix, - callback: (error: ServiceError | null, response: TrieNodeSnapshotResponse) => void + callback: (error: ServiceError | null, response: TrieNodeSnapshotResponse) => void, ): ClientUnaryCall; getSyncSnapshotByPrefix( request: TrieNodePrefix, metadata: Metadata, - callback: (error: ServiceError | null, response: TrieNodeSnapshotResponse) => void + callback: (error: ServiceError | null, response: TrieNodeSnapshotResponse) => void, ): ClientUnaryCall; getSyncSnapshotByPrefix( request: TrieNodePrefix, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: TrieNodeSnapshotResponse) => void + callback: (error: ServiceError | null, response: TrieNodeSnapshotResponse) => void, ): ClientUnaryCall; } -export const HubServiceClient = makeGenericClientConstructor(HubServiceService, 'HubService') as unknown as { +export const HubServiceClient = makeGenericClientConstructor(HubServiceService, "HubService") as unknown as { new (address: string, credentials: ChannelCredentials, options?: Partial): HubServiceClient; service: typeof HubServiceService; }; @@ -1005,7 +1034,7 @@ export const HubServiceClient = makeGenericClientConstructor(HubServiceService, export type AdminServiceService = typeof AdminServiceService; export const AdminServiceService = { rebuildSyncTrie: { - path: '/AdminService/RebuildSyncTrie', + path: "/AdminService/RebuildSyncTrie", requestStream: false, responseStream: false, requestSerialize: (value: Empty) => Buffer.from(Empty.encode(value).finish()), @@ -1014,7 +1043,7 @@ export const AdminServiceService = { responseDeserialize: (value: Buffer) => Empty.decode(value), }, deleteAllMessagesFromDb: { - path: '/AdminService/DeleteAllMessagesFromDb', + path: "/AdminService/DeleteAllMessagesFromDb", requestStream: false, responseStream: false, requestSerialize: (value: Empty) => Buffer.from(Empty.encode(value).finish()), @@ -1023,7 +1052,7 @@ export const AdminServiceService = { responseDeserialize: (value: Buffer) => Empty.decode(value), }, submitIdRegistryEvent: { - path: '/AdminService/SubmitIdRegistryEvent', + path: "/AdminService/SubmitIdRegistryEvent", requestStream: false, responseStream: false, requestSerialize: (value: IdRegistryEvent) => Buffer.from(IdRegistryEvent.encode(value).finish()), @@ -1032,7 +1061,7 @@ export const AdminServiceService = { responseDeserialize: (value: Buffer) => IdRegistryEvent.decode(value), }, submitNameRegistryEvent: { - path: '/AdminService/SubmitNameRegistryEvent', + path: "/AdminService/SubmitNameRegistryEvent", requestStream: false, responseStream: false, requestSerialize: (value: NameRegistryEvent) => Buffer.from(NameRegistryEvent.encode(value).finish()), @@ -1054,62 +1083,62 @@ export interface AdminServiceClient extends Client { rebuildSyncTrie( request: Empty, metadata: Metadata, - callback: (error: ServiceError | null, response: Empty) => void + callback: (error: ServiceError | null, response: Empty) => void, ): ClientUnaryCall; rebuildSyncTrie( request: Empty, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: Empty) => void + callback: (error: ServiceError | null, response: Empty) => void, ): ClientUnaryCall; deleteAllMessagesFromDb( request: Empty, - callback: (error: ServiceError | null, response: Empty) => void + callback: (error: ServiceError | null, response: Empty) => void, ): ClientUnaryCall; deleteAllMessagesFromDb( request: Empty, metadata: Metadata, - callback: (error: ServiceError | null, response: Empty) => void + callback: (error: ServiceError | null, response: Empty) => void, ): ClientUnaryCall; deleteAllMessagesFromDb( request: Empty, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: Empty) => void + callback: (error: ServiceError | null, response: Empty) => void, ): ClientUnaryCall; submitIdRegistryEvent( request: IdRegistryEvent, - callback: (error: ServiceError | null, response: IdRegistryEvent) => void + callback: (error: ServiceError | null, response: IdRegistryEvent) => void, ): ClientUnaryCall; submitIdRegistryEvent( request: IdRegistryEvent, metadata: Metadata, - callback: (error: ServiceError | null, response: IdRegistryEvent) => void + callback: (error: ServiceError | null, response: IdRegistryEvent) => void, ): ClientUnaryCall; submitIdRegistryEvent( request: IdRegistryEvent, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: IdRegistryEvent) => void + callback: (error: ServiceError | null, response: IdRegistryEvent) => void, ): ClientUnaryCall; submitNameRegistryEvent( request: NameRegistryEvent, - callback: (error: ServiceError | null, response: NameRegistryEvent) => void + callback: (error: ServiceError | null, response: NameRegistryEvent) => void, ): ClientUnaryCall; submitNameRegistryEvent( request: NameRegistryEvent, metadata: Metadata, - callback: (error: ServiceError | null, response: NameRegistryEvent) => void + callback: (error: ServiceError | null, response: NameRegistryEvent) => void, ): ClientUnaryCall; submitNameRegistryEvent( request: NameRegistryEvent, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: NameRegistryEvent) => void + callback: (error: ServiceError | null, response: NameRegistryEvent) => void, ): ClientUnaryCall; } -export const AdminServiceClient = makeGenericClientConstructor(AdminServiceService, 'AdminService') as unknown as { +export const AdminServiceClient = makeGenericClientConstructor(AdminServiceService, "AdminService") as unknown as { new (address: string, credentials: ChannelCredentials, options?: Partial): AdminServiceClient; service: typeof AdminServiceService; }; diff --git a/packages/hub-nodejs/src/generated/username_proof.ts b/packages/hub-nodejs/src/generated/username_proof.ts index 96f1c7464f..d25ba3f8f9 100644 --- a/packages/hub-nodejs/src/generated/username_proof.ts +++ b/packages/hub-nodejs/src/generated/username_proof.ts @@ -1,33 +1,39 @@ /* eslint-disable */ -import Long from 'long'; -import _m0 from 'protobufjs/minimal'; +import Long from "long"; +import _m0 from "protobufjs/minimal"; export enum UserNameType { USERNAME_TYPE_NONE = 0, USERNAME_TYPE_FNAME = 1, + USERNAME_TYPE_ENS_L1 = 2, } export function userNameTypeFromJSON(object: any): UserNameType { switch (object) { case 0: - case 'USERNAME_TYPE_NONE': + case "USERNAME_TYPE_NONE": return UserNameType.USERNAME_TYPE_NONE; case 1: - case 'USERNAME_TYPE_FNAME': + case "USERNAME_TYPE_FNAME": return UserNameType.USERNAME_TYPE_FNAME; + case 2: + case "USERNAME_TYPE_ENS_L1": + return UserNameType.USERNAME_TYPE_ENS_L1; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum UserNameType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum UserNameType"); } } export function userNameTypeToJSON(object: UserNameType): string { switch (object) { case UserNameType.USERNAME_TYPE_NONE: - return 'USERNAME_TYPE_NONE'; + return "USERNAME_TYPE_NONE"; case UserNameType.USERNAME_TYPE_FNAME: - return 'USERNAME_TYPE_FNAME'; + return "USERNAME_TYPE_FNAME"; + case UserNameType.USERNAME_TYPE_ENS_L1: + return "USERNAME_TYPE_ENS_L1"; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum UserNameType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum UserNameType"); } } @@ -177,24 +183,24 @@ declare var self: any | undefined; declare var window: any | undefined; declare var global: any | undefined; var tsProtoGlobalThis: any = (() => { - if (typeof globalThis !== 'undefined') { + if (typeof globalThis !== "undefined") { return globalThis; } - if (typeof self !== 'undefined') { + if (typeof self !== "undefined") { return self; } - if (typeof window !== 'undefined') { + if (typeof window !== "undefined") { return window; } - if (typeof global !== 'undefined') { + if (typeof global !== "undefined") { return global; } - throw 'Unable to locate global object'; + throw "Unable to locate global object"; })(); function bytesFromBase64(b64: string): Uint8Array { if (tsProtoGlobalThis.Buffer) { - return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, 'base64')); + return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, "base64")); } else { const bin = tsProtoGlobalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -207,36 +213,30 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (tsProtoGlobalThis.Buffer) { - return tsProtoGlobalThis.Buffer.from(arr).toString('base64'); + return tsProtoGlobalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return tsProtoGlobalThis.btoa(bin.join('')); + return tsProtoGlobalThis.btoa(bin.join("")); } } type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; -type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } +type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; type KeysOfUnion = T extends T ? keyof T : never; -type Exact = P extends Builtin - ? P +type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function longToNumber(long: Long): number { if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new tsProtoGlobalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/packages/hub-web/src/generated/hub_event.ts b/packages/hub-web/src/generated/hub_event.ts index 47a01a8f18..8e0c1d5dca 100644 --- a/packages/hub-web/src/generated/hub_event.ts +++ b/packages/hub-web/src/generated/hub_event.ts @@ -1,10 +1,10 @@ /* eslint-disable */ -import Long from 'long'; -import _m0 from 'protobufjs/minimal'; -import { IdRegistryEvent } from './id_registry_event'; -import { Message } from './message'; -import { NameRegistryEvent } from './name_registry_event'; -import { UserNameProof } from './username_proof'; +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { IdRegistryEvent } from "./id_registry_event"; +import { Message } from "./message"; +import { NameRegistryEvent } from "./name_registry_event"; +import { UserNameProof } from "./username_proof"; export enum HubEventType { NONE = 0, @@ -19,49 +19,49 @@ export enum HubEventType { export function hubEventTypeFromJSON(object: any): HubEventType { switch (object) { case 0: - case 'HUB_EVENT_TYPE_NONE': + case "HUB_EVENT_TYPE_NONE": return HubEventType.NONE; case 1: - case 'HUB_EVENT_TYPE_MERGE_MESSAGE': + case "HUB_EVENT_TYPE_MERGE_MESSAGE": return HubEventType.MERGE_MESSAGE; case 2: - case 'HUB_EVENT_TYPE_PRUNE_MESSAGE': + case "HUB_EVENT_TYPE_PRUNE_MESSAGE": return HubEventType.PRUNE_MESSAGE; case 3: - case 'HUB_EVENT_TYPE_REVOKE_MESSAGE': + case "HUB_EVENT_TYPE_REVOKE_MESSAGE": return HubEventType.REVOKE_MESSAGE; case 4: - case 'HUB_EVENT_TYPE_MERGE_ID_REGISTRY_EVENT': + case "HUB_EVENT_TYPE_MERGE_ID_REGISTRY_EVENT": return HubEventType.MERGE_ID_REGISTRY_EVENT; case 5: - case 'HUB_EVENT_TYPE_MERGE_NAME_REGISTRY_EVENT': + case "HUB_EVENT_TYPE_MERGE_NAME_REGISTRY_EVENT": return HubEventType.MERGE_NAME_REGISTRY_EVENT; case 6: - case 'HUB_EVENT_TYPE_MERGE_USERNAME_PROOF': + case "HUB_EVENT_TYPE_MERGE_USERNAME_PROOF": return HubEventType.MERGE_USERNAME_PROOF; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum HubEventType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum HubEventType"); } } export function hubEventTypeToJSON(object: HubEventType): string { switch (object) { case HubEventType.NONE: - return 'HUB_EVENT_TYPE_NONE'; + return "HUB_EVENT_TYPE_NONE"; case HubEventType.MERGE_MESSAGE: - return 'HUB_EVENT_TYPE_MERGE_MESSAGE'; + return "HUB_EVENT_TYPE_MERGE_MESSAGE"; case HubEventType.PRUNE_MESSAGE: - return 'HUB_EVENT_TYPE_PRUNE_MESSAGE'; + return "HUB_EVENT_TYPE_PRUNE_MESSAGE"; case HubEventType.REVOKE_MESSAGE: - return 'HUB_EVENT_TYPE_REVOKE_MESSAGE'; + return "HUB_EVENT_TYPE_REVOKE_MESSAGE"; case HubEventType.MERGE_ID_REGISTRY_EVENT: - return 'HUB_EVENT_TYPE_MERGE_ID_REGISTRY_EVENT'; + return "HUB_EVENT_TYPE_MERGE_ID_REGISTRY_EVENT"; case HubEventType.MERGE_NAME_REGISTRY_EVENT: - return 'HUB_EVENT_TYPE_MERGE_NAME_REGISTRY_EVENT'; + return "HUB_EVENT_TYPE_MERGE_NAME_REGISTRY_EVENT"; case HubEventType.MERGE_USERNAME_PROOF: - return 'HUB_EVENT_TYPE_MERGE_USERNAME_PROOF'; + return "HUB_EVENT_TYPE_MERGE_USERNAME_PROOF"; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum HubEventType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum HubEventType"); } } @@ -89,6 +89,8 @@ export interface MergeNameRegistryEventBody { export interface MergeUserNameProofBody { usernameProof: UserNameProof | undefined; deletedUsernameProof: UserNameProof | undefined; + usernameProofMessage: Message | undefined; + deletedUsernameProofMessage: Message | undefined; } export interface HubEvent { @@ -160,7 +162,7 @@ export const MergeMessageBody = { const obj: any = {}; message.message !== undefined && (obj.message = message.message ? Message.toJSON(message.message) : undefined); if (message.deletedMessages) { - obj.deletedMessages = message.deletedMessages.map((e) => (e ? Message.toJSON(e) : undefined)); + obj.deletedMessages = message.deletedMessages.map((e) => e ? Message.toJSON(e) : undefined); } else { obj.deletedMessages = []; } @@ -173,8 +175,9 @@ export const MergeMessageBody = { fromPartial, I>>(object: I): MergeMessageBody { const message = createBaseMergeMessageBody(); - message.message = - object.message !== undefined && object.message !== null ? Message.fromPartial(object.message) : undefined; + message.message = (object.message !== undefined && object.message !== null) + ? Message.fromPartial(object.message) + : undefined; message.deletedMessages = object.deletedMessages?.map((e) => Message.fromPartial(e)) || []; return message; }, @@ -231,8 +234,9 @@ export const PruneMessageBody = { fromPartial, I>>(object: I): PruneMessageBody { const message = createBasePruneMessageBody(); - message.message = - object.message !== undefined && object.message !== null ? Message.fromPartial(object.message) : undefined; + message.message = (object.message !== undefined && object.message !== null) + ? Message.fromPartial(object.message) + : undefined; return message; }, }; @@ -288,8 +292,9 @@ export const RevokeMessageBody = { fromPartial, I>>(object: I): RevokeMessageBody { const message = createBaseRevokeMessageBody(); - message.message = - object.message !== undefined && object.message !== null ? Message.fromPartial(object.message) : undefined; + message.message = (object.message !== undefined && object.message !== null) + ? Message.fromPartial(object.message) + : undefined; return message; }, }; @@ -348,10 +353,9 @@ export const MergeIdRegistryEventBody = { fromPartial, I>>(object: I): MergeIdRegistryEventBody { const message = createBaseMergeIdRegistryEventBody(); - message.idRegistryEvent = - object.idRegistryEvent !== undefined && object.idRegistryEvent !== null - ? IdRegistryEvent.fromPartial(object.idRegistryEvent) - : undefined; + message.idRegistryEvent = (object.idRegistryEvent !== undefined && object.idRegistryEvent !== null) + ? IdRegistryEvent.fromPartial(object.idRegistryEvent) + : undefined; return message; }, }; @@ -401,10 +405,9 @@ export const MergeNameRegistryEventBody = { toJSON(message: MergeNameRegistryEventBody): unknown { const obj: any = {}; - message.nameRegistryEvent !== undefined && - (obj.nameRegistryEvent = message.nameRegistryEvent - ? NameRegistryEvent.toJSON(message.nameRegistryEvent) - : undefined); + message.nameRegistryEvent !== undefined && (obj.nameRegistryEvent = message.nameRegistryEvent + ? NameRegistryEvent.toJSON(message.nameRegistryEvent) + : undefined); return obj; }, @@ -414,16 +417,20 @@ export const MergeNameRegistryEventBody = { fromPartial, I>>(object: I): MergeNameRegistryEventBody { const message = createBaseMergeNameRegistryEventBody(); - message.nameRegistryEvent = - object.nameRegistryEvent !== undefined && object.nameRegistryEvent !== null - ? NameRegistryEvent.fromPartial(object.nameRegistryEvent) - : undefined; + message.nameRegistryEvent = (object.nameRegistryEvent !== undefined && object.nameRegistryEvent !== null) + ? NameRegistryEvent.fromPartial(object.nameRegistryEvent) + : undefined; return message; }, }; function createBaseMergeUserNameProofBody(): MergeUserNameProofBody { - return { usernameProof: undefined, deletedUsernameProof: undefined }; + return { + usernameProof: undefined, + deletedUsernameProof: undefined, + usernameProofMessage: undefined, + deletedUsernameProofMessage: undefined, + }; } export const MergeUserNameProofBody = { @@ -434,6 +441,12 @@ export const MergeUserNameProofBody = { if (message.deletedUsernameProof !== undefined) { UserNameProof.encode(message.deletedUsernameProof, writer.uint32(18).fork()).ldelim(); } + if (message.usernameProofMessage !== undefined) { + Message.encode(message.usernameProofMessage, writer.uint32(26).fork()).ldelim(); + } + if (message.deletedUsernameProofMessage !== undefined) { + Message.encode(message.deletedUsernameProofMessage, writer.uint32(34).fork()).ldelim(); + } return writer; }, @@ -458,6 +471,20 @@ export const MergeUserNameProofBody = { message.deletedUsernameProof = UserNameProof.decode(reader, reader.uint32()); continue; + case 3: + if (tag != 26) { + break; + } + + message.usernameProofMessage = Message.decode(reader, reader.uint32()); + continue; + case 4: + if (tag != 34) { + break; + } + + message.deletedUsernameProofMessage = Message.decode(reader, reader.uint32()); + continue; } if ((tag & 7) == 4 || tag == 0) { break; @@ -473,6 +500,12 @@ export const MergeUserNameProofBody = { deletedUsernameProof: isSet(object.deletedUsernameProof) ? UserNameProof.fromJSON(object.deletedUsernameProof) : undefined, + usernameProofMessage: isSet(object.usernameProofMessage) + ? Message.fromJSON(object.usernameProofMessage) + : undefined, + deletedUsernameProofMessage: isSet(object.deletedUsernameProofMessage) + ? Message.fromJSON(object.deletedUsernameProofMessage) + : undefined, }; }, @@ -480,9 +513,15 @@ export const MergeUserNameProofBody = { const obj: any = {}; message.usernameProof !== undefined && (obj.usernameProof = message.usernameProof ? UserNameProof.toJSON(message.usernameProof) : undefined); - message.deletedUsernameProof !== undefined && - (obj.deletedUsernameProof = message.deletedUsernameProof - ? UserNameProof.toJSON(message.deletedUsernameProof) + message.deletedUsernameProof !== undefined && (obj.deletedUsernameProof = message.deletedUsernameProof + ? UserNameProof.toJSON(message.deletedUsernameProof) + : undefined); + message.usernameProofMessage !== undefined && (obj.usernameProofMessage = message.usernameProofMessage + ? Message.toJSON(message.usernameProofMessage) + : undefined); + message.deletedUsernameProofMessage !== undefined && + (obj.deletedUsernameProofMessage = message.deletedUsernameProofMessage + ? Message.toJSON(message.deletedUsernameProofMessage) : undefined); return obj; }, @@ -493,13 +532,18 @@ export const MergeUserNameProofBody = { fromPartial, I>>(object: I): MergeUserNameProofBody { const message = createBaseMergeUserNameProofBody(); - message.usernameProof = - object.usernameProof !== undefined && object.usernameProof !== null - ? UserNameProof.fromPartial(object.usernameProof) - : undefined; - message.deletedUsernameProof = - object.deletedUsernameProof !== undefined && object.deletedUsernameProof !== null - ? UserNameProof.fromPartial(object.deletedUsernameProof) + message.usernameProof = (object.usernameProof !== undefined && object.usernameProof !== null) + ? UserNameProof.fromPartial(object.usernameProof) + : undefined; + message.deletedUsernameProof = (object.deletedUsernameProof !== undefined && object.deletedUsernameProof !== null) + ? UserNameProof.fromPartial(object.deletedUsernameProof) + : undefined; + message.usernameProofMessage = (object.usernameProofMessage !== undefined && object.usernameProofMessage !== null) + ? Message.fromPartial(object.usernameProofMessage) + : undefined; + message.deletedUsernameProofMessage = + (object.deletedUsernameProofMessage !== undefined && object.deletedUsernameProofMessage !== null) + ? Message.fromPartial(object.deletedUsernameProofMessage) : undefined; return message; }, @@ -648,22 +692,19 @@ export const HubEvent = { (obj.mergeMessageBody = message.mergeMessageBody ? MergeMessageBody.toJSON(message.mergeMessageBody) : undefined); message.pruneMessageBody !== undefined && (obj.pruneMessageBody = message.pruneMessageBody ? PruneMessageBody.toJSON(message.pruneMessageBody) : undefined); - message.revokeMessageBody !== undefined && - (obj.revokeMessageBody = message.revokeMessageBody - ? RevokeMessageBody.toJSON(message.revokeMessageBody) - : undefined); - message.mergeIdRegistryEventBody !== undefined && - (obj.mergeIdRegistryEventBody = message.mergeIdRegistryEventBody - ? MergeIdRegistryEventBody.toJSON(message.mergeIdRegistryEventBody) - : undefined); + message.revokeMessageBody !== undefined && (obj.revokeMessageBody = message.revokeMessageBody + ? RevokeMessageBody.toJSON(message.revokeMessageBody) + : undefined); + message.mergeIdRegistryEventBody !== undefined && (obj.mergeIdRegistryEventBody = message.mergeIdRegistryEventBody + ? MergeIdRegistryEventBody.toJSON(message.mergeIdRegistryEventBody) + : undefined); message.mergeNameRegistryEventBody !== undefined && (obj.mergeNameRegistryEventBody = message.mergeNameRegistryEventBody ? MergeNameRegistryEventBody.toJSON(message.mergeNameRegistryEventBody) : undefined); - message.mergeUsernameProofBody !== undefined && - (obj.mergeUsernameProofBody = message.mergeUsernameProofBody - ? MergeUserNameProofBody.toJSON(message.mergeUsernameProofBody) - : undefined); + message.mergeUsernameProofBody !== undefined && (obj.mergeUsernameProofBody = message.mergeUsernameProofBody + ? MergeUserNameProofBody.toJSON(message.mergeUsernameProofBody) + : undefined); return obj; }, @@ -675,28 +716,25 @@ export const HubEvent = { const message = createBaseHubEvent(); message.type = object.type ?? 0; message.id = object.id ?? 0; - message.mergeMessageBody = - object.mergeMessageBody !== undefined && object.mergeMessageBody !== null - ? MergeMessageBody.fromPartial(object.mergeMessageBody) - : undefined; - message.pruneMessageBody = - object.pruneMessageBody !== undefined && object.pruneMessageBody !== null - ? PruneMessageBody.fromPartial(object.pruneMessageBody) - : undefined; - message.revokeMessageBody = - object.revokeMessageBody !== undefined && object.revokeMessageBody !== null - ? RevokeMessageBody.fromPartial(object.revokeMessageBody) - : undefined; + message.mergeMessageBody = (object.mergeMessageBody !== undefined && object.mergeMessageBody !== null) + ? MergeMessageBody.fromPartial(object.mergeMessageBody) + : undefined; + message.pruneMessageBody = (object.pruneMessageBody !== undefined && object.pruneMessageBody !== null) + ? PruneMessageBody.fromPartial(object.pruneMessageBody) + : undefined; + message.revokeMessageBody = (object.revokeMessageBody !== undefined && object.revokeMessageBody !== null) + ? RevokeMessageBody.fromPartial(object.revokeMessageBody) + : undefined; message.mergeIdRegistryEventBody = - object.mergeIdRegistryEventBody !== undefined && object.mergeIdRegistryEventBody !== null + (object.mergeIdRegistryEventBody !== undefined && object.mergeIdRegistryEventBody !== null) ? MergeIdRegistryEventBody.fromPartial(object.mergeIdRegistryEventBody) : undefined; message.mergeNameRegistryEventBody = - object.mergeNameRegistryEventBody !== undefined && object.mergeNameRegistryEventBody !== null + (object.mergeNameRegistryEventBody !== undefined && object.mergeNameRegistryEventBody !== null) ? MergeNameRegistryEventBody.fromPartial(object.mergeNameRegistryEventBody) : undefined; message.mergeUsernameProofBody = - object.mergeUsernameProofBody !== undefined && object.mergeUsernameProofBody !== null + (object.mergeUsernameProofBody !== undefined && object.mergeUsernameProofBody !== null) ? MergeUserNameProofBody.fromPartial(object.mergeUsernameProofBody) : undefined; return message; @@ -707,41 +745,35 @@ declare var self: any | undefined; declare var window: any | undefined; declare var global: any | undefined; var tsProtoGlobalThis: any = (() => { - if (typeof globalThis !== 'undefined') { + if (typeof globalThis !== "undefined") { return globalThis; } - if (typeof self !== 'undefined') { + if (typeof self !== "undefined") { return self; } - if (typeof window !== 'undefined') { + if (typeof window !== "undefined") { return window; } - if (typeof global !== 'undefined') { + if (typeof global !== "undefined") { return global; } - throw 'Unable to locate global object'; + throw "Unable to locate global object"; })(); type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; -type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } +type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; type KeysOfUnion = T extends T ? keyof T : never; -type Exact = P extends Builtin - ? P +type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function longToNumber(long: Long): number { if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new tsProtoGlobalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/packages/hub-web/src/generated/id_registry_event.ts b/packages/hub-web/src/generated/id_registry_event.ts index 35d192b2cb..8f1a1a9610 100644 --- a/packages/hub-web/src/generated/id_registry_event.ts +++ b/packages/hub-web/src/generated/id_registry_event.ts @@ -1,6 +1,6 @@ /* eslint-disable */ -import Long from 'long'; -import _m0 from 'protobufjs/minimal'; +import Long from "long"; +import _m0 from "protobufjs/minimal"; export enum IdRegistryEventType { NONE = 0, @@ -11,29 +11,29 @@ export enum IdRegistryEventType { export function idRegistryEventTypeFromJSON(object: any): IdRegistryEventType { switch (object) { case 0: - case 'ID_REGISTRY_EVENT_TYPE_NONE': + case "ID_REGISTRY_EVENT_TYPE_NONE": return IdRegistryEventType.NONE; case 1: - case 'ID_REGISTRY_EVENT_TYPE_REGISTER': + case "ID_REGISTRY_EVENT_TYPE_REGISTER": return IdRegistryEventType.REGISTER; case 2: - case 'ID_REGISTRY_EVENT_TYPE_TRANSFER': + case "ID_REGISTRY_EVENT_TYPE_TRANSFER": return IdRegistryEventType.TRANSFER; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum IdRegistryEventType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum IdRegistryEventType"); } } export function idRegistryEventTypeToJSON(object: IdRegistryEventType): string { switch (object) { case IdRegistryEventType.NONE: - return 'ID_REGISTRY_EVENT_TYPE_NONE'; + return "ID_REGISTRY_EVENT_TYPE_NONE"; case IdRegistryEventType.REGISTER: - return 'ID_REGISTRY_EVENT_TYPE_REGISTER'; + return "ID_REGISTRY_EVENT_TYPE_REGISTER"; case IdRegistryEventType.TRANSFER: - return 'ID_REGISTRY_EVENT_TYPE_TRANSFER'; + return "ID_REGISTRY_EVENT_TYPE_TRANSFER"; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum IdRegistryEventType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum IdRegistryEventType"); } } @@ -182,7 +182,7 @@ export const IdRegistryEvent = { (obj.blockHash = base64FromBytes(message.blockHash !== undefined ? message.blockHash : new Uint8Array())); message.transactionHash !== undefined && (obj.transactionHash = base64FromBytes( - message.transactionHash !== undefined ? message.transactionHash : new Uint8Array() + message.transactionHash !== undefined ? message.transactionHash : new Uint8Array(), )); message.logIndex !== undefined && (obj.logIndex = Math.round(message.logIndex)); message.fid !== undefined && (obj.fid = Math.round(message.fid)); @@ -215,24 +215,24 @@ declare var self: any | undefined; declare var window: any | undefined; declare var global: any | undefined; var tsProtoGlobalThis: any = (() => { - if (typeof globalThis !== 'undefined') { + if (typeof globalThis !== "undefined") { return globalThis; } - if (typeof self !== 'undefined') { + if (typeof self !== "undefined") { return self; } - if (typeof window !== 'undefined') { + if (typeof window !== "undefined") { return window; } - if (typeof global !== 'undefined') { + if (typeof global !== "undefined") { return global; } - throw 'Unable to locate global object'; + throw "Unable to locate global object"; })(); function bytesFromBase64(b64: string): Uint8Array { if (tsProtoGlobalThis.Buffer) { - return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, 'base64')); + return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, "base64")); } else { const bin = tsProtoGlobalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -245,36 +245,30 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (tsProtoGlobalThis.Buffer) { - return tsProtoGlobalThis.Buffer.from(arr).toString('base64'); + return tsProtoGlobalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return tsProtoGlobalThis.btoa(bin.join('')); + return tsProtoGlobalThis.btoa(bin.join("")); } } type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; -type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } +type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; type KeysOfUnion = T extends T ? keyof T : never; -type Exact = P extends Builtin - ? P +type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function longToNumber(long: Long): number { if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new tsProtoGlobalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/packages/hub-web/src/generated/message.ts b/packages/hub-web/src/generated/message.ts index 3282b61a5f..32cdebeb7b 100644 --- a/packages/hub-web/src/generated/message.ts +++ b/packages/hub-web/src/generated/message.ts @@ -1,6 +1,7 @@ /* eslint-disable */ -import Long from 'long'; -import _m0 from 'protobufjs/minimal'; +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { UserNameProof } from "./username_proof"; /** Type of hashing scheme used to produce a digest of MessageData */ export enum HashScheme { @@ -12,24 +13,24 @@ export enum HashScheme { export function hashSchemeFromJSON(object: any): HashScheme { switch (object) { case 0: - case 'HASH_SCHEME_NONE': + case "HASH_SCHEME_NONE": return HashScheme.NONE; case 1: - case 'HASH_SCHEME_BLAKE3': + case "HASH_SCHEME_BLAKE3": return HashScheme.BLAKE3; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum HashScheme'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum HashScheme"); } } export function hashSchemeToJSON(object: HashScheme): string { switch (object) { case HashScheme.NONE: - return 'HASH_SCHEME_NONE'; + return "HASH_SCHEME_NONE"; case HashScheme.BLAKE3: - return 'HASH_SCHEME_BLAKE3'; + return "HASH_SCHEME_BLAKE3"; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum HashScheme'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum HashScheme"); } } @@ -45,29 +46,29 @@ export enum SignatureScheme { export function signatureSchemeFromJSON(object: any): SignatureScheme { switch (object) { case 0: - case 'SIGNATURE_SCHEME_NONE': + case "SIGNATURE_SCHEME_NONE": return SignatureScheme.NONE; case 1: - case 'SIGNATURE_SCHEME_ED25519': + case "SIGNATURE_SCHEME_ED25519": return SignatureScheme.ED25519; case 2: - case 'SIGNATURE_SCHEME_EIP712': + case "SIGNATURE_SCHEME_EIP712": return SignatureScheme.EIP712; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum SignatureScheme'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum SignatureScheme"); } } export function signatureSchemeToJSON(object: SignatureScheme): string { switch (object) { case SignatureScheme.NONE: - return 'SIGNATURE_SCHEME_NONE'; + return "SIGNATURE_SCHEME_NONE"; case SignatureScheme.ED25519: - return 'SIGNATURE_SCHEME_ED25519'; + return "SIGNATURE_SCHEME_ED25519"; case SignatureScheme.EIP712: - return 'SIGNATURE_SCHEME_EIP712'; + return "SIGNATURE_SCHEME_EIP712"; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum SignatureScheme'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum SignatureScheme"); } } @@ -96,79 +97,86 @@ export enum MessageType { SIGNER_REMOVE = 10, /** USER_DATA_ADD - Add metadata about a user */ USER_DATA_ADD = 11, + /** USERNAME_PROOF - Add or replace a username proof */ + USERNAME_PROOF = 12, } export function messageTypeFromJSON(object: any): MessageType { switch (object) { case 0: - case 'MESSAGE_TYPE_NONE': + case "MESSAGE_TYPE_NONE": return MessageType.NONE; case 1: - case 'MESSAGE_TYPE_CAST_ADD': + case "MESSAGE_TYPE_CAST_ADD": return MessageType.CAST_ADD; case 2: - case 'MESSAGE_TYPE_CAST_REMOVE': + case "MESSAGE_TYPE_CAST_REMOVE": return MessageType.CAST_REMOVE; case 3: - case 'MESSAGE_TYPE_REACTION_ADD': + case "MESSAGE_TYPE_REACTION_ADD": return MessageType.REACTION_ADD; case 4: - case 'MESSAGE_TYPE_REACTION_REMOVE': + case "MESSAGE_TYPE_REACTION_REMOVE": return MessageType.REACTION_REMOVE; case 5: - case 'MESSAGE_TYPE_LINK_ADD': + case "MESSAGE_TYPE_LINK_ADD": return MessageType.LINK_ADD; case 6: - case 'MESSAGE_TYPE_LINK_REMOVE': + case "MESSAGE_TYPE_LINK_REMOVE": return MessageType.LINK_REMOVE; case 7: - case 'MESSAGE_TYPE_VERIFICATION_ADD_ETH_ADDRESS': + case "MESSAGE_TYPE_VERIFICATION_ADD_ETH_ADDRESS": return MessageType.VERIFICATION_ADD_ETH_ADDRESS; case 8: - case 'MESSAGE_TYPE_VERIFICATION_REMOVE': + case "MESSAGE_TYPE_VERIFICATION_REMOVE": return MessageType.VERIFICATION_REMOVE; case 9: - case 'MESSAGE_TYPE_SIGNER_ADD': + case "MESSAGE_TYPE_SIGNER_ADD": return MessageType.SIGNER_ADD; case 10: - case 'MESSAGE_TYPE_SIGNER_REMOVE': + case "MESSAGE_TYPE_SIGNER_REMOVE": return MessageType.SIGNER_REMOVE; case 11: - case 'MESSAGE_TYPE_USER_DATA_ADD': + case "MESSAGE_TYPE_USER_DATA_ADD": return MessageType.USER_DATA_ADD; + case 12: + case "MESSAGE_TYPE_USERNAME_PROOF": + return MessageType.USERNAME_PROOF; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum MessageType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum MessageType"); } } export function messageTypeToJSON(object: MessageType): string { switch (object) { case MessageType.NONE: - return 'MESSAGE_TYPE_NONE'; + return "MESSAGE_TYPE_NONE"; case MessageType.CAST_ADD: - return 'MESSAGE_TYPE_CAST_ADD'; + return "MESSAGE_TYPE_CAST_ADD"; case MessageType.CAST_REMOVE: - return 'MESSAGE_TYPE_CAST_REMOVE'; + return "MESSAGE_TYPE_CAST_REMOVE"; case MessageType.REACTION_ADD: - return 'MESSAGE_TYPE_REACTION_ADD'; + return "MESSAGE_TYPE_REACTION_ADD"; case MessageType.REACTION_REMOVE: - return 'MESSAGE_TYPE_REACTION_REMOVE'; + return "MESSAGE_TYPE_REACTION_REMOVE"; case MessageType.LINK_ADD: - return 'MESSAGE_TYPE_LINK_ADD'; + return "MESSAGE_TYPE_LINK_ADD"; case MessageType.LINK_REMOVE: - return 'MESSAGE_TYPE_LINK_REMOVE'; + return "MESSAGE_TYPE_LINK_REMOVE"; case MessageType.VERIFICATION_ADD_ETH_ADDRESS: - return 'MESSAGE_TYPE_VERIFICATION_ADD_ETH_ADDRESS'; + return "MESSAGE_TYPE_VERIFICATION_ADD_ETH_ADDRESS"; case MessageType.VERIFICATION_REMOVE: - return 'MESSAGE_TYPE_VERIFICATION_REMOVE'; + return "MESSAGE_TYPE_VERIFICATION_REMOVE"; case MessageType.SIGNER_ADD: - return 'MESSAGE_TYPE_SIGNER_ADD'; + return "MESSAGE_TYPE_SIGNER_ADD"; case MessageType.SIGNER_REMOVE: - return 'MESSAGE_TYPE_SIGNER_REMOVE'; + return "MESSAGE_TYPE_SIGNER_REMOVE"; case MessageType.USER_DATA_ADD: - return 'MESSAGE_TYPE_USER_DATA_ADD'; + return "MESSAGE_TYPE_USER_DATA_ADD"; + case MessageType.USERNAME_PROOF: + return "MESSAGE_TYPE_USERNAME_PROOF"; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum MessageType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum MessageType"); } } @@ -186,34 +194,34 @@ export enum FarcasterNetwork { export function farcasterNetworkFromJSON(object: any): FarcasterNetwork { switch (object) { case 0: - case 'FARCASTER_NETWORK_NONE': + case "FARCASTER_NETWORK_NONE": return FarcasterNetwork.NONE; case 1: - case 'FARCASTER_NETWORK_MAINNET': + case "FARCASTER_NETWORK_MAINNET": return FarcasterNetwork.MAINNET; case 2: - case 'FARCASTER_NETWORK_TESTNET': + case "FARCASTER_NETWORK_TESTNET": return FarcasterNetwork.TESTNET; case 3: - case 'FARCASTER_NETWORK_DEVNET': + case "FARCASTER_NETWORK_DEVNET": return FarcasterNetwork.DEVNET; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum FarcasterNetwork'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum FarcasterNetwork"); } } export function farcasterNetworkToJSON(object: FarcasterNetwork): string { switch (object) { case FarcasterNetwork.NONE: - return 'FARCASTER_NETWORK_NONE'; + return "FARCASTER_NETWORK_NONE"; case FarcasterNetwork.MAINNET: - return 'FARCASTER_NETWORK_MAINNET'; + return "FARCASTER_NETWORK_MAINNET"; case FarcasterNetwork.TESTNET: - return 'FARCASTER_NETWORK_TESTNET'; + return "FARCASTER_NETWORK_TESTNET"; case FarcasterNetwork.DEVNET: - return 'FARCASTER_NETWORK_DEVNET'; + return "FARCASTER_NETWORK_DEVNET"; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum FarcasterNetwork'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum FarcasterNetwork"); } } @@ -235,44 +243,44 @@ export enum UserDataType { export function userDataTypeFromJSON(object: any): UserDataType { switch (object) { case 0: - case 'USER_DATA_TYPE_NONE': + case "USER_DATA_TYPE_NONE": return UserDataType.NONE; case 1: - case 'USER_DATA_TYPE_PFP': + case "USER_DATA_TYPE_PFP": return UserDataType.PFP; case 2: - case 'USER_DATA_TYPE_DISPLAY': + case "USER_DATA_TYPE_DISPLAY": return UserDataType.DISPLAY; case 3: - case 'USER_DATA_TYPE_BIO': + case "USER_DATA_TYPE_BIO": return UserDataType.BIO; case 5: - case 'USER_DATA_TYPE_URL': + case "USER_DATA_TYPE_URL": return UserDataType.URL; case 6: - case 'USER_DATA_TYPE_FNAME': + case "USER_DATA_TYPE_FNAME": return UserDataType.FNAME; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum UserDataType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum UserDataType"); } } export function userDataTypeToJSON(object: UserDataType): string { switch (object) { case UserDataType.NONE: - return 'USER_DATA_TYPE_NONE'; + return "USER_DATA_TYPE_NONE"; case UserDataType.PFP: - return 'USER_DATA_TYPE_PFP'; + return "USER_DATA_TYPE_PFP"; case UserDataType.DISPLAY: - return 'USER_DATA_TYPE_DISPLAY'; + return "USER_DATA_TYPE_DISPLAY"; case UserDataType.BIO: - return 'USER_DATA_TYPE_BIO'; + return "USER_DATA_TYPE_BIO"; case UserDataType.URL: - return 'USER_DATA_TYPE_URL'; + return "USER_DATA_TYPE_URL"; case UserDataType.FNAME: - return 'USER_DATA_TYPE_FNAME'; + return "USER_DATA_TYPE_FNAME"; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum UserDataType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum UserDataType"); } } @@ -288,29 +296,29 @@ export enum ReactionType { export function reactionTypeFromJSON(object: any): ReactionType { switch (object) { case 0: - case 'REACTION_TYPE_NONE': + case "REACTION_TYPE_NONE": return ReactionType.NONE; case 1: - case 'REACTION_TYPE_LIKE': + case "REACTION_TYPE_LIKE": return ReactionType.LIKE; case 2: - case 'REACTION_TYPE_RECAST': + case "REACTION_TYPE_RECAST": return ReactionType.RECAST; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum ReactionType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum ReactionType"); } } export function reactionTypeToJSON(object: ReactionType): string { switch (object) { case ReactionType.NONE: - return 'REACTION_TYPE_NONE'; + return "REACTION_TYPE_NONE"; case ReactionType.LIKE: - return 'REACTION_TYPE_LIKE'; + return "REACTION_TYPE_LIKE"; case ReactionType.RECAST: - return 'REACTION_TYPE_RECAST'; + return "REACTION_TYPE_RECAST"; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum ReactionType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum ReactionType"); } } @@ -320,7 +328,9 @@ export function reactionTypeToJSON(object: ReactionType): string { */ export interface Message { /** Contents of the message */ - data: MessageData | undefined; + data: + | MessageData + | undefined; /** Hash digest of data */ hash: Uint8Array; /** Hash scheme that produced the hash digest */ @@ -355,6 +365,7 @@ export interface MessageData { userDataBody?: UserDataBody | undefined; signerRemoveBody?: SignerRemoveBody | undefined; linkBody?: LinkBody | undefined; + usernameProofBody?: UserNameProof | undefined; } /** Adds an Ed25519 key pair that signs messages for a user */ @@ -391,9 +402,13 @@ export interface CastAddBody { /** Fids mentioned in the cast */ mentions: number[]; /** Parent cast of the cast */ - parentCastId?: CastId | undefined; + parentCastId?: + | CastId + | undefined; /** Parent URL */ - parentUrl?: string | undefined; + parentUrl?: + | string + | undefined; /** Text of the cast */ text: string; /** Positions of the mentions in the text */ @@ -421,7 +436,9 @@ export interface ReactionBody { /** Type of reaction */ type: ReactionType; /** CastId of the Cast to react to */ - targetCastId?: CastId | undefined; + targetCastId?: + | CastId + | undefined; /** URL to react to */ targetUrl?: string | undefined; } @@ -447,7 +464,9 @@ export interface LinkBody { /** Type of link, <= 8 characters */ type: string; /** User-defined timestamp that preserves original timestamp when message.data.timestamp needs to be updated for compaction */ - displayTimestamp?: number | undefined; + displayTimestamp?: + | number + | undefined; /** The fid the link relates to */ targetFid?: number | undefined; } @@ -575,7 +594,9 @@ export const Message = { fromPartial, I>>(object: I): Message { const message = createBaseMessage(); - message.data = object.data !== undefined && object.data !== null ? MessageData.fromPartial(object.data) : undefined; + message.data = (object.data !== undefined && object.data !== null) + ? MessageData.fromPartial(object.data) + : undefined; message.hash = object.hash ?? new Uint8Array(); message.hashScheme = object.hashScheme ?? 0; message.signature = object.signature ?? new Uint8Array(); @@ -600,6 +621,7 @@ function createBaseMessageData(): MessageData { userDataBody: undefined, signerRemoveBody: undefined, linkBody: undefined, + usernameProofBody: undefined, }; } @@ -644,6 +666,9 @@ export const MessageData = { if (message.linkBody !== undefined) { LinkBody.encode(message.linkBody, writer.uint32(114).fork()).ldelim(); } + if (message.usernameProofBody !== undefined) { + UserNameProof.encode(message.usernameProofBody, writer.uint32(122).fork()).ldelim(); + } return writer; }, @@ -745,6 +770,13 @@ export const MessageData = { message.linkBody = LinkBody.decode(reader, reader.uint32()); continue; + case 15: + if (tag != 122) { + break; + } + + message.usernameProofBody = UserNameProof.decode(reader, reader.uint32()); + continue; } if ((tag & 7) == 4 || tag == 0) { break; @@ -773,6 +805,7 @@ export const MessageData = { userDataBody: isSet(object.userDataBody) ? UserDataBody.fromJSON(object.userDataBody) : undefined, signerRemoveBody: isSet(object.signerRemoveBody) ? SignerRemoveBody.fromJSON(object.signerRemoveBody) : undefined, linkBody: isSet(object.linkBody) ? LinkBody.fromJSON(object.linkBody) : undefined, + usernameProofBody: isSet(object.usernameProofBody) ? UserNameProof.fromJSON(object.usernameProofBody) : undefined, }; }, @@ -792,10 +825,9 @@ export const MessageData = { (obj.verificationAddEthAddressBody = message.verificationAddEthAddressBody ? VerificationAddEthAddressBody.toJSON(message.verificationAddEthAddressBody) : undefined); - message.verificationRemoveBody !== undefined && - (obj.verificationRemoveBody = message.verificationRemoveBody - ? VerificationRemoveBody.toJSON(message.verificationRemoveBody) - : undefined); + message.verificationRemoveBody !== undefined && (obj.verificationRemoveBody = message.verificationRemoveBody + ? VerificationRemoveBody.toJSON(message.verificationRemoveBody) + : undefined); message.signerAddBody !== undefined && (obj.signerAddBody = message.signerAddBody ? SignerAddBody.toJSON(message.signerAddBody) : undefined); message.userDataBody !== undefined && @@ -803,6 +835,8 @@ export const MessageData = { message.signerRemoveBody !== undefined && (obj.signerRemoveBody = message.signerRemoveBody ? SignerRemoveBody.toJSON(message.signerRemoveBody) : undefined); message.linkBody !== undefined && (obj.linkBody = message.linkBody ? LinkBody.toJSON(message.linkBody) : undefined); + message.usernameProofBody !== undefined && + (obj.usernameProofBody = message.usernameProofBody ? UserNameProof.toJSON(message.usernameProofBody) : undefined); return obj; }, @@ -816,40 +850,38 @@ export const MessageData = { message.fid = object.fid ?? 0; message.timestamp = object.timestamp ?? 0; message.network = object.network ?? 0; - message.castAddBody = - object.castAddBody !== undefined && object.castAddBody !== null - ? CastAddBody.fromPartial(object.castAddBody) - : undefined; - message.castRemoveBody = - object.castRemoveBody !== undefined && object.castRemoveBody !== null - ? CastRemoveBody.fromPartial(object.castRemoveBody) - : undefined; - message.reactionBody = - object.reactionBody !== undefined && object.reactionBody !== null - ? ReactionBody.fromPartial(object.reactionBody) - : undefined; + message.castAddBody = (object.castAddBody !== undefined && object.castAddBody !== null) + ? CastAddBody.fromPartial(object.castAddBody) + : undefined; + message.castRemoveBody = (object.castRemoveBody !== undefined && object.castRemoveBody !== null) + ? CastRemoveBody.fromPartial(object.castRemoveBody) + : undefined; + message.reactionBody = (object.reactionBody !== undefined && object.reactionBody !== null) + ? ReactionBody.fromPartial(object.reactionBody) + : undefined; message.verificationAddEthAddressBody = - object.verificationAddEthAddressBody !== undefined && object.verificationAddEthAddressBody !== null + (object.verificationAddEthAddressBody !== undefined && object.verificationAddEthAddressBody !== null) ? VerificationAddEthAddressBody.fromPartial(object.verificationAddEthAddressBody) : undefined; message.verificationRemoveBody = - object.verificationRemoveBody !== undefined && object.verificationRemoveBody !== null + (object.verificationRemoveBody !== undefined && object.verificationRemoveBody !== null) ? VerificationRemoveBody.fromPartial(object.verificationRemoveBody) : undefined; - message.signerAddBody = - object.signerAddBody !== undefined && object.signerAddBody !== null - ? SignerAddBody.fromPartial(object.signerAddBody) - : undefined; - message.userDataBody = - object.userDataBody !== undefined && object.userDataBody !== null - ? UserDataBody.fromPartial(object.userDataBody) - : undefined; - message.signerRemoveBody = - object.signerRemoveBody !== undefined && object.signerRemoveBody !== null - ? SignerRemoveBody.fromPartial(object.signerRemoveBody) - : undefined; - message.linkBody = - object.linkBody !== undefined && object.linkBody !== null ? LinkBody.fromPartial(object.linkBody) : undefined; + message.signerAddBody = (object.signerAddBody !== undefined && object.signerAddBody !== null) + ? SignerAddBody.fromPartial(object.signerAddBody) + : undefined; + message.userDataBody = (object.userDataBody !== undefined && object.userDataBody !== null) + ? UserDataBody.fromPartial(object.userDataBody) + : undefined; + message.signerRemoveBody = (object.signerRemoveBody !== undefined && object.signerRemoveBody !== null) + ? SignerRemoveBody.fromPartial(object.signerRemoveBody) + : undefined; + message.linkBody = (object.linkBody !== undefined && object.linkBody !== null) + ? LinkBody.fromPartial(object.linkBody) + : undefined; + message.usernameProofBody = (object.usernameProofBody !== undefined && object.usernameProofBody !== null) + ? UserNameProof.fromPartial(object.usernameProofBody) + : undefined; return message; }, }; @@ -984,7 +1016,7 @@ export const SignerRemoveBody = { }; function createBaseUserDataBody(): UserDataBody { - return { type: 0, value: '' }; + return { type: 0, value: "" }; } export const UserDataBody = { @@ -992,7 +1024,7 @@ export const UserDataBody = { if (message.type !== 0) { writer.uint32(8).int32(message.type); } - if (message.value !== '') { + if (message.value !== "") { writer.uint32(18).string(message.value); } return writer; @@ -1031,7 +1063,7 @@ export const UserDataBody = { fromJSON(object: any): UserDataBody { return { type: isSet(object.type) ? userDataTypeFromJSON(object.type) : 0, - value: isSet(object.value) ? String(object.value) : '', + value: isSet(object.value) ? String(object.value) : "", }; }, @@ -1049,7 +1081,7 @@ export const UserDataBody = { fromPartial, I>>(object: I): UserDataBody { const message = createBaseUserDataBody(); message.type = object.type ?? 0; - message.value = object.value ?? ''; + message.value = object.value ?? ""; return message; }, }; @@ -1120,8 +1152,9 @@ export const Embed = { fromPartial, I>>(object: I): Embed { const message = createBaseEmbed(); message.url = object.url ?? undefined; - message.castId = - object.castId !== undefined && object.castId !== null ? CastId.fromPartial(object.castId) : undefined; + message.castId = (object.castId !== undefined && object.castId !== null) + ? CastId.fromPartial(object.castId) + : undefined; return message; }, }; @@ -1132,7 +1165,7 @@ function createBaseCastAddBody(): CastAddBody { mentions: [], parentCastId: undefined, parentUrl: undefined, - text: '', + text: "", mentionsPositions: [], embeds: [], }; @@ -1154,7 +1187,7 @@ export const CastAddBody = { if (message.parentUrl !== undefined) { writer.uint32(58).string(message.parentUrl); } - if (message.text !== '') { + if (message.text !== "") { writer.uint32(34).string(message.text); } writer.uint32(42).fork(); @@ -1259,7 +1292,7 @@ export const CastAddBody = { mentions: Array.isArray(object?.mentions) ? object.mentions.map((e: any) => Number(e)) : [], parentCastId: isSet(object.parentCastId) ? CastId.fromJSON(object.parentCastId) : undefined, parentUrl: isSet(object.parentUrl) ? String(object.parentUrl) : undefined, - text: isSet(object.text) ? String(object.text) : '', + text: isSet(object.text) ? String(object.text) : "", mentionsPositions: Array.isArray(object?.mentionsPositions) ? object.mentionsPositions.map((e: any) => Number(e)) : [], @@ -1289,7 +1322,7 @@ export const CastAddBody = { obj.mentionsPositions = []; } if (message.embeds) { - obj.embeds = message.embeds.map((e) => (e ? Embed.toJSON(e) : undefined)); + obj.embeds = message.embeds.map((e) => e ? Embed.toJSON(e) : undefined); } else { obj.embeds = []; } @@ -1304,12 +1337,11 @@ export const CastAddBody = { const message = createBaseCastAddBody(); message.embedsDeprecated = object.embedsDeprecated?.map((e) => e) || []; message.mentions = object.mentions?.map((e) => e) || []; - message.parentCastId = - object.parentCastId !== undefined && object.parentCastId !== null - ? CastId.fromPartial(object.parentCastId) - : undefined; + message.parentCastId = (object.parentCastId !== undefined && object.parentCastId !== null) + ? CastId.fromPartial(object.parentCastId) + : undefined; message.parentUrl = object.parentUrl ?? undefined; - message.text = object.text ?? ''; + message.text = object.text ?? ""; message.mentionsPositions = object.mentionsPositions?.map((e) => e) || []; message.embeds = object.embeds?.map((e) => Embed.fromPartial(e)) || []; return message; @@ -1524,10 +1556,9 @@ export const ReactionBody = { fromPartial, I>>(object: I): ReactionBody { const message = createBaseReactionBody(); message.type = object.type ?? 0; - message.targetCastId = - object.targetCastId !== undefined && object.targetCastId !== null - ? CastId.fromPartial(object.targetCastId) - : undefined; + message.targetCastId = (object.targetCastId !== undefined && object.targetCastId !== null) + ? CastId.fromPartial(object.targetCastId) + : undefined; message.targetUrl = object.targetUrl ?? undefined; return message; }, @@ -1602,7 +1633,7 @@ export const VerificationAddEthAddressBody = { (obj.address = base64FromBytes(message.address !== undefined ? message.address : new Uint8Array())); message.ethSignature !== undefined && (obj.ethSignature = base64FromBytes( - message.ethSignature !== undefined ? message.ethSignature : new Uint8Array() + message.ethSignature !== undefined ? message.ethSignature : new Uint8Array(), )); message.blockHash !== undefined && (obj.blockHash = base64FromBytes(message.blockHash !== undefined ? message.blockHash : new Uint8Array())); @@ -1614,7 +1645,7 @@ export const VerificationAddEthAddressBody = { }, fromPartial, I>>( - object: I + object: I, ): VerificationAddEthAddressBody { const message = createBaseVerificationAddEthAddressBody(); message.address = object.address ?? new Uint8Array(); @@ -1682,12 +1713,12 @@ export const VerificationRemoveBody = { }; function createBaseLinkBody(): LinkBody { - return { type: '', displayTimestamp: undefined, targetFid: undefined }; + return { type: "", displayTimestamp: undefined, targetFid: undefined }; } export const LinkBody = { encode(message: LinkBody, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.type !== '') { + if (message.type !== "") { writer.uint32(10).string(message.type); } if (message.displayTimestamp !== undefined) { @@ -1738,7 +1769,7 @@ export const LinkBody = { fromJSON(object: any): LinkBody { return { - type: isSet(object.type) ? String(object.type) : '', + type: isSet(object.type) ? String(object.type) : "", displayTimestamp: isSet(object.displayTimestamp) ? Number(object.displayTimestamp) : undefined, targetFid: isSet(object.targetFid) ? Number(object.targetFid) : undefined, }; @@ -1758,7 +1789,7 @@ export const LinkBody = { fromPartial, I>>(object: I): LinkBody { const message = createBaseLinkBody(); - message.type = object.type ?? ''; + message.type = object.type ?? ""; message.displayTimestamp = object.displayTimestamp ?? undefined; message.targetFid = object.targetFid ?? undefined; return message; @@ -1769,24 +1800,24 @@ declare var self: any | undefined; declare var window: any | undefined; declare var global: any | undefined; var tsProtoGlobalThis: any = (() => { - if (typeof globalThis !== 'undefined') { + if (typeof globalThis !== "undefined") { return globalThis; } - if (typeof self !== 'undefined') { + if (typeof self !== "undefined") { return self; } - if (typeof window !== 'undefined') { + if (typeof window !== "undefined") { return window; } - if (typeof global !== 'undefined') { + if (typeof global !== "undefined") { return global; } - throw 'Unable to locate global object'; + throw "Unable to locate global object"; })(); function bytesFromBase64(b64: string): Uint8Array { if (tsProtoGlobalThis.Buffer) { - return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, 'base64')); + return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, "base64")); } else { const bin = tsProtoGlobalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -1799,36 +1830,30 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (tsProtoGlobalThis.Buffer) { - return tsProtoGlobalThis.Buffer.from(arr).toString('base64'); + return tsProtoGlobalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return tsProtoGlobalThis.btoa(bin.join('')); + return tsProtoGlobalThis.btoa(bin.join("")); } } type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; -type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } +type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; type KeysOfUnion = T extends T ? keyof T : never; -type Exact = P extends Builtin - ? P +type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function longToNumber(long: Long): number { if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new tsProtoGlobalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/packages/hub-web/src/generated/name_registry_event.ts b/packages/hub-web/src/generated/name_registry_event.ts index b0a83e8ab3..c3da2d5215 100644 --- a/packages/hub-web/src/generated/name_registry_event.ts +++ b/packages/hub-web/src/generated/name_registry_event.ts @@ -1,5 +1,5 @@ /* eslint-disable */ -import _m0 from 'protobufjs/minimal'; +import _m0 from "protobufjs/minimal"; export enum NameRegistryEventType { NONE = 0, @@ -10,29 +10,29 @@ export enum NameRegistryEventType { export function nameRegistryEventTypeFromJSON(object: any): NameRegistryEventType { switch (object) { case 0: - case 'NAME_REGISTRY_EVENT_TYPE_NONE': + case "NAME_REGISTRY_EVENT_TYPE_NONE": return NameRegistryEventType.NONE; case 1: - case 'NAME_REGISTRY_EVENT_TYPE_TRANSFER': + case "NAME_REGISTRY_EVENT_TYPE_TRANSFER": return NameRegistryEventType.TRANSFER; case 2: - case 'NAME_REGISTRY_EVENT_TYPE_RENEW': + case "NAME_REGISTRY_EVENT_TYPE_RENEW": return NameRegistryEventType.RENEW; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum NameRegistryEventType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum NameRegistryEventType"); } } export function nameRegistryEventTypeToJSON(object: NameRegistryEventType): string { switch (object) { case NameRegistryEventType.NONE: - return 'NAME_REGISTRY_EVENT_TYPE_NONE'; + return "NAME_REGISTRY_EVENT_TYPE_NONE"; case NameRegistryEventType.TRANSFER: - return 'NAME_REGISTRY_EVENT_TYPE_TRANSFER'; + return "NAME_REGISTRY_EVENT_TYPE_TRANSFER"; case NameRegistryEventType.RENEW: - return 'NAME_REGISTRY_EVENT_TYPE_RENEW'; + return "NAME_REGISTRY_EVENT_TYPE_RENEW"; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum NameRegistryEventType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum NameRegistryEventType"); } } @@ -194,7 +194,7 @@ export const NameRegistryEvent = { (obj.blockHash = base64FromBytes(message.blockHash !== undefined ? message.blockHash : new Uint8Array())); message.transactionHash !== undefined && (obj.transactionHash = base64FromBytes( - message.transactionHash !== undefined ? message.transactionHash : new Uint8Array() + message.transactionHash !== undefined ? message.transactionHash : new Uint8Array(), )); message.logIndex !== undefined && (obj.logIndex = Math.round(message.logIndex)); message.fname !== undefined && @@ -230,24 +230,24 @@ declare var self: any | undefined; declare var window: any | undefined; declare var global: any | undefined; var tsProtoGlobalThis: any = (() => { - if (typeof globalThis !== 'undefined') { + if (typeof globalThis !== "undefined") { return globalThis; } - if (typeof self !== 'undefined') { + if (typeof self !== "undefined") { return self; } - if (typeof window !== 'undefined') { + if (typeof window !== "undefined") { return window; } - if (typeof global !== 'undefined') { + if (typeof global !== "undefined") { return global; } - throw 'Unable to locate global object'; + throw "Unable to locate global object"; })(); function bytesFromBase64(b64: string): Uint8Array { if (tsProtoGlobalThis.Buffer) { - return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, 'base64')); + return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, "base64")); } else { const bin = tsProtoGlobalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -260,31 +260,25 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (tsProtoGlobalThis.Buffer) { - return tsProtoGlobalThis.Buffer.from(arr).toString('base64'); + return tsProtoGlobalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return tsProtoGlobalThis.btoa(bin.join('')); + return tsProtoGlobalThis.btoa(bin.join("")); } } type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; -type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } +type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; type KeysOfUnion = T extends T ? keyof T : never; -type Exact = P extends Builtin - ? P +type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/packages/hub-web/src/generated/request_response.ts b/packages/hub-web/src/generated/request_response.ts index 02843b438f..5d346edb0a 100644 --- a/packages/hub-web/src/generated/request_response.ts +++ b/packages/hub-web/src/generated/request_response.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import Long from 'long'; -import _m0 from 'protobufjs/minimal'; -import { HubEventType, hubEventTypeFromJSON, hubEventTypeToJSON } from './hub_event'; +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { HubEventType, hubEventTypeFromJSON, hubEventTypeToJSON } from "./hub_event"; import { CastId, Message, @@ -11,9 +11,11 @@ import { UserDataType, userDataTypeFromJSON, userDataTypeToJSON, -} from './message'; +} from "./message"; +import { UserNameProof } from "./username_proof"; -export interface Empty {} +export interface Empty { +} export interface SubscribeRequest { eventTypes: HubEventType[]; @@ -153,6 +155,10 @@ export interface UsernameProofRequest { name: Uint8Array; } +export interface UsernameProofsResponse { + proofs: UserNameProof[]; +} + export interface VerificationRequest { fid: number; address: Uint8Array; @@ -436,21 +442,21 @@ export const HubInfoRequest = { }; function createBaseHubInfoResponse(): HubInfoResponse { - return { version: '', isSyncing: false, nickname: '', rootHash: '', dbStats: undefined }; + return { version: "", isSyncing: false, nickname: "", rootHash: "", dbStats: undefined }; } export const HubInfoResponse = { encode(message: HubInfoResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.version !== '') { + if (message.version !== "") { writer.uint32(10).string(message.version); } if (message.isSyncing === true) { writer.uint32(16).bool(message.isSyncing); } - if (message.nickname !== '') { + if (message.nickname !== "") { writer.uint32(26).string(message.nickname); } - if (message.rootHash !== '') { + if (message.rootHash !== "") { writer.uint32(34).string(message.rootHash); } if (message.dbStats !== undefined) { @@ -512,10 +518,10 @@ export const HubInfoResponse = { fromJSON(object: any): HubInfoResponse { return { - version: isSet(object.version) ? String(object.version) : '', + version: isSet(object.version) ? String(object.version) : "", isSyncing: isSet(object.isSyncing) ? Boolean(object.isSyncing) : false, - nickname: isSet(object.nickname) ? String(object.nickname) : '', - rootHash: isSet(object.rootHash) ? String(object.rootHash) : '', + nickname: isSet(object.nickname) ? String(object.nickname) : "", + rootHash: isSet(object.rootHash) ? String(object.rootHash) : "", dbStats: isSet(object.dbStats) ? DbStats.fromJSON(object.dbStats) : undefined, }; }, @@ -536,12 +542,13 @@ export const HubInfoResponse = { fromPartial, I>>(object: I): HubInfoResponse { const message = createBaseHubInfoResponse(); - message.version = object.version ?? ''; + message.version = object.version ?? ""; message.isSyncing = object.isSyncing ?? false; - message.nickname = object.nickname ?? ''; - message.rootHash = object.rootHash ?? ''; - message.dbStats = - object.dbStats !== undefined && object.dbStats !== null ? DbStats.fromPartial(object.dbStats) : undefined; + message.nickname = object.nickname ?? ""; + message.rootHash = object.rootHash ?? ""; + message.dbStats = (object.dbStats !== undefined && object.dbStats !== null) + ? DbStats.fromPartial(object.dbStats) + : undefined; return message; }, }; @@ -742,7 +749,7 @@ export const SyncStatusResponse = { const obj: any = {}; message.isSyncing !== undefined && (obj.isSyncing = message.isSyncing); if (message.syncStatus) { - obj.syncStatus = message.syncStatus.map((e) => (e ? SyncStatus.toJSON(e) : undefined)); + obj.syncStatus = message.syncStatus.map((e) => e ? SyncStatus.toJSON(e) : undefined); } else { obj.syncStatus = []; } @@ -763,10 +770,10 @@ export const SyncStatusResponse = { function createBaseSyncStatus(): SyncStatus { return { - peerId: '', - inSync: '', + peerId: "", + inSync: "", shouldSync: false, - divergencePrefix: '', + divergencePrefix: "", divergenceSecondsAgo: 0, theirMessages: 0, ourMessages: 0, @@ -776,16 +783,16 @@ function createBaseSyncStatus(): SyncStatus { export const SyncStatus = { encode(message: SyncStatus, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.peerId !== '') { + if (message.peerId !== "") { writer.uint32(10).string(message.peerId); } - if (message.inSync !== '') { + if (message.inSync !== "") { writer.uint32(18).string(message.inSync); } if (message.shouldSync === true) { writer.uint32(24).bool(message.shouldSync); } - if (message.divergencePrefix !== '') { + if (message.divergencePrefix !== "") { writer.uint32(34).string(message.divergencePrefix); } if (message.divergenceSecondsAgo !== 0) { @@ -877,10 +884,10 @@ export const SyncStatus = { fromJSON(object: any): SyncStatus { return { - peerId: isSet(object.peerId) ? String(object.peerId) : '', - inSync: isSet(object.inSync) ? String(object.inSync) : '', + peerId: isSet(object.peerId) ? String(object.peerId) : "", + inSync: isSet(object.inSync) ? String(object.inSync) : "", shouldSync: isSet(object.shouldSync) ? Boolean(object.shouldSync) : false, - divergencePrefix: isSet(object.divergencePrefix) ? String(object.divergencePrefix) : '', + divergencePrefix: isSet(object.divergencePrefix) ? String(object.divergencePrefix) : "", divergenceSecondsAgo: isSet(object.divergenceSecondsAgo) ? Number(object.divergenceSecondsAgo) : 0, theirMessages: isSet(object.theirMessages) ? Number(object.theirMessages) : 0, ourMessages: isSet(object.ourMessages) ? Number(object.ourMessages) : 0, @@ -907,10 +914,10 @@ export const SyncStatus = { fromPartial, I>>(object: I): SyncStatus { const message = createBaseSyncStatus(); - message.peerId = object.peerId ?? ''; - message.inSync = object.inSync ?? ''; + message.peerId = object.peerId ?? ""; + message.inSync = object.inSync ?? ""; message.shouldSync = object.shouldSync ?? false; - message.divergencePrefix = object.divergencePrefix ?? ''; + message.divergencePrefix = object.divergencePrefix ?? ""; message.divergenceSecondsAgo = object.divergenceSecondsAgo ?? 0; message.theirMessages = object.theirMessages ?? 0; message.ourMessages = object.ourMessages ?? 0; @@ -920,7 +927,7 @@ export const SyncStatus = { }; function createBaseTrieNodeMetadataResponse(): TrieNodeMetadataResponse { - return { prefix: new Uint8Array(), numMessages: 0, hash: '', children: [] }; + return { prefix: new Uint8Array(), numMessages: 0, hash: "", children: [] }; } export const TrieNodeMetadataResponse = { @@ -931,7 +938,7 @@ export const TrieNodeMetadataResponse = { if (message.numMessages !== 0) { writer.uint32(16).uint64(message.numMessages); } - if (message.hash !== '') { + if (message.hash !== "") { writer.uint32(26).string(message.hash); } for (const v of message.children) { @@ -988,7 +995,7 @@ export const TrieNodeMetadataResponse = { return { prefix: isSet(object.prefix) ? bytesFromBase64(object.prefix) : new Uint8Array(), numMessages: isSet(object.numMessages) ? Number(object.numMessages) : 0, - hash: isSet(object.hash) ? String(object.hash) : '', + hash: isSet(object.hash) ? String(object.hash) : "", children: Array.isArray(object?.children) ? object.children.map((e: any) => TrieNodeMetadataResponse.fromJSON(e)) : [], @@ -1002,7 +1009,7 @@ export const TrieNodeMetadataResponse = { message.numMessages !== undefined && (obj.numMessages = Math.round(message.numMessages)); message.hash !== undefined && (obj.hash = message.hash); if (message.children) { - obj.children = message.children.map((e) => (e ? TrieNodeMetadataResponse.toJSON(e) : undefined)); + obj.children = message.children.map((e) => e ? TrieNodeMetadataResponse.toJSON(e) : undefined); } else { obj.children = []; } @@ -1017,14 +1024,14 @@ export const TrieNodeMetadataResponse = { const message = createBaseTrieNodeMetadataResponse(); message.prefix = object.prefix ?? new Uint8Array(); message.numMessages = object.numMessages ?? 0; - message.hash = object.hash ?? ''; + message.hash = object.hash ?? ""; message.children = object.children?.map((e) => TrieNodeMetadataResponse.fromPartial(e)) || []; return message; }, }; function createBaseTrieNodeSnapshotResponse(): TrieNodeSnapshotResponse { - return { prefix: new Uint8Array(), excludedHashes: [], numMessages: 0, rootHash: '' }; + return { prefix: new Uint8Array(), excludedHashes: [], numMessages: 0, rootHash: "" }; } export const TrieNodeSnapshotResponse = { @@ -1038,7 +1045,7 @@ export const TrieNodeSnapshotResponse = { if (message.numMessages !== 0) { writer.uint32(24).uint64(message.numMessages); } - if (message.rootHash !== '') { + if (message.rootHash !== "") { writer.uint32(34).string(message.rootHash); } return writer; @@ -1093,7 +1100,7 @@ export const TrieNodeSnapshotResponse = { prefix: isSet(object.prefix) ? bytesFromBase64(object.prefix) : new Uint8Array(), excludedHashes: Array.isArray(object?.excludedHashes) ? object.excludedHashes.map((e: any) => String(e)) : [], numMessages: isSet(object.numMessages) ? Number(object.numMessages) : 0, - rootHash: isSet(object.rootHash) ? String(object.rootHash) : '', + rootHash: isSet(object.rootHash) ? String(object.rootHash) : "", }; }, @@ -1120,7 +1127,7 @@ export const TrieNodeSnapshotResponse = { message.prefix = object.prefix ?? new Uint8Array(); message.excludedHashes = object.excludedHashes?.map((e) => e) || []; message.numMessages = object.numMessages ?? 0; - message.rootHash = object.rootHash ?? ''; + message.rootHash = object.rootHash ?? ""; return message; }, }; @@ -1567,7 +1574,7 @@ export const MessagesResponse = { toJSON(message: MessagesResponse): unknown { const obj: any = {}; if (message.messages) { - obj.messages = message.messages.map((e) => (e ? Message.toJSON(e) : undefined)); + obj.messages = message.messages.map((e) => e ? Message.toJSON(e) : undefined); } else { obj.messages = []; } @@ -1697,10 +1704,9 @@ export const CastsByParentRequest = { fromPartial, I>>(object: I): CastsByParentRequest { const message = createBaseCastsByParentRequest(); - message.parentCastId = - object.parentCastId !== undefined && object.parentCastId !== null - ? CastId.fromPartial(object.parentCastId) - : undefined; + message.parentCastId = (object.parentCastId !== undefined && object.parentCastId !== null) + ? CastId.fromPartial(object.parentCastId) + : undefined; message.parentUrl = object.parentUrl ?? undefined; message.pageSize = object.pageSize ?? undefined; message.pageToken = object.pageToken ?? undefined; @@ -1801,10 +1807,9 @@ export const ReactionRequest = { const message = createBaseReactionRequest(); message.fid = object.fid ?? 0; message.reactionType = object.reactionType ?? 0; - message.targetCastId = - object.targetCastId !== undefined && object.targetCastId !== null - ? CastId.fromPartial(object.targetCastId) - : undefined; + message.targetCastId = (object.targetCastId !== undefined && object.targetCastId !== null) + ? CastId.fromPartial(object.targetCastId) + : undefined; message.targetUrl = object.targetUrl ?? undefined; return message; }, @@ -2045,10 +2050,9 @@ export const ReactionsByTargetRequest = { fromPartial, I>>(object: I): ReactionsByTargetRequest { const message = createBaseReactionsByTargetRequest(); - message.targetCastId = - object.targetCastId !== undefined && object.targetCastId !== null - ? CastId.fromPartial(object.targetCastId) - : undefined; + message.targetCastId = (object.targetCastId !== undefined && object.targetCastId !== null) + ? CastId.fromPartial(object.targetCastId) + : undefined; message.targetUrl = object.targetUrl ?? undefined; message.reactionType = object.reactionType ?? undefined; message.pageSize = object.pageSize ?? undefined; @@ -2243,6 +2247,66 @@ export const UsernameProofRequest = { }, }; +function createBaseUsernameProofsResponse(): UsernameProofsResponse { + return { proofs: [] }; +} + +export const UsernameProofsResponse = { + encode(message: UsernameProofsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.proofs) { + UserNameProof.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): UsernameProofsResponse { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUsernameProofsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag != 10) { + break; + } + + message.proofs.push(UserNameProof.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) == 4 || tag == 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): UsernameProofsResponse { + return { proofs: Array.isArray(object?.proofs) ? object.proofs.map((e: any) => UserNameProof.fromJSON(e)) : [] }; + }, + + toJSON(message: UsernameProofsResponse): unknown { + const obj: any = {}; + if (message.proofs) { + obj.proofs = message.proofs.map((e) => e ? UserNameProof.toJSON(e) : undefined); + } else { + obj.proofs = []; + } + return obj; + }, + + create, I>>(base?: I): UsernameProofsResponse { + return UsernameProofsResponse.fromPartial(base ?? {}); + }, + + fromPartial, I>>(object: I): UsernameProofsResponse { + const message = createBaseUsernameProofsResponse(); + message.proofs = object.proofs?.map((e) => UserNameProof.fromPartial(e)) || []; + return message; + }, +}; + function createBaseVerificationRequest(): VerificationRequest { return { fid: 0, address: new Uint8Array() }; } @@ -2388,7 +2452,7 @@ export const SignerRequest = { }; function createBaseLinkRequest(): LinkRequest { - return { fid: 0, linkType: '', targetFid: undefined }; + return { fid: 0, linkType: "", targetFid: undefined }; } export const LinkRequest = { @@ -2396,7 +2460,7 @@ export const LinkRequest = { if (message.fid !== 0) { writer.uint32(8).uint64(message.fid); } - if (message.linkType !== '') { + if (message.linkType !== "") { writer.uint32(18).string(message.linkType); } if (message.targetFid !== undefined) { @@ -2445,7 +2509,7 @@ export const LinkRequest = { fromJSON(object: any): LinkRequest { return { fid: isSet(object.fid) ? Number(object.fid) : 0, - linkType: isSet(object.linkType) ? String(object.linkType) : '', + linkType: isSet(object.linkType) ? String(object.linkType) : "", targetFid: isSet(object.targetFid) ? Number(object.targetFid) : undefined, }; }, @@ -2465,7 +2529,7 @@ export const LinkRequest = { fromPartial, I>>(object: I): LinkRequest { const message = createBaseLinkRequest(); message.fid = object.fid ?? 0; - message.linkType = object.linkType ?? ''; + message.linkType = object.linkType ?? ""; message.targetFid = object.targetFid ?? undefined; return message; }, @@ -2800,7 +2864,7 @@ export const IdRegistryEventByAddressRequest = { }, fromPartial, I>>( - object: I + object: I, ): IdRegistryEventByAddressRequest { const message = createBaseIdRegistryEventByAddressRequest(); message.address = object.address ?? new Uint8Array(); @@ -2812,24 +2876,24 @@ declare var self: any | undefined; declare var window: any | undefined; declare var global: any | undefined; var tsProtoGlobalThis: any = (() => { - if (typeof globalThis !== 'undefined') { + if (typeof globalThis !== "undefined") { return globalThis; } - if (typeof self !== 'undefined') { + if (typeof self !== "undefined") { return self; } - if (typeof window !== 'undefined') { + if (typeof window !== "undefined") { return window; } - if (typeof global !== 'undefined') { + if (typeof global !== "undefined") { return global; } - throw 'Unable to locate global object'; + throw "Unable to locate global object"; })(); function bytesFromBase64(b64: string): Uint8Array { if (tsProtoGlobalThis.Buffer) { - return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, 'base64')); + return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, "base64")); } else { const bin = tsProtoGlobalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -2842,36 +2906,30 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (tsProtoGlobalThis.Buffer) { - return tsProtoGlobalThis.Buffer.from(arr).toString('base64'); + return tsProtoGlobalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return tsProtoGlobalThis.btoa(bin.join('')); + return tsProtoGlobalThis.btoa(bin.join("")); } } type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; -type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } +type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; type KeysOfUnion = T extends T ? keyof T : never; -type Exact = P extends Builtin - ? P +type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function longToNumber(long: Long): number { if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new tsProtoGlobalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/packages/hub-web/src/generated/rpc.ts b/packages/hub-web/src/generated/rpc.ts index 4f584b94c1..59af604672 100644 --- a/packages/hub-web/src/generated/rpc.ts +++ b/packages/hub-web/src/generated/rpc.ts @@ -1,13 +1,13 @@ /* eslint-disable */ // This must be manually change to a default import right now import grpcWeb from '@improbable-eng/grpc-web'; -import { BrowserHeaders } from 'browser-headers'; -import { Observable } from 'rxjs'; -import { share } from 'rxjs/operators'; -import { HubEvent } from './hub_event'; -import { IdRegistryEvent } from './id_registry_event'; -import { CastId, Message } from './message'; -import { NameRegistryEvent } from './name_registry_event'; +import { BrowserHeaders } from "browser-headers"; +import { Observable } from "rxjs"; +import { share } from "rxjs/operators"; +import { HubEvent } from "./hub_event"; +import { IdRegistryEvent } from "./id_registry_event"; +import { CastId, Message } from "./message"; +import { NameRegistryEvent } from "./name_registry_event"; import { CastsByParentRequest, Empty, @@ -37,9 +37,10 @@ import { TrieNodeSnapshotResponse, UserDataRequest, UsernameProofRequest, + UsernameProofsResponse, VerificationRequest, -} from './request_response'; -import { UserNameProof } from './username_proof'; +} from "./request_response"; +import { UserNameProof } from "./username_proof"; export interface HubService { /** Submit Methods */ @@ -50,84 +51,56 @@ export interface HubService { /** Casts */ getCast(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise; getCastsByFid(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise; - getCastsByParent( - request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata - ): Promise; + getCastsByParent(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise; getCastsByMention(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise; /** Reactions */ getReaction(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise; - getReactionsByFid( - request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata - ): Promise; + getReactionsByFid(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise; /** To be deprecated */ getReactionsByCast( request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata + metadata?: grpcWeb.grpc.Metadata, ): Promise; getReactionsByTarget( request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata + metadata?: grpcWeb.grpc.Metadata, ): Promise; /** User Data */ getUserData(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise; getUserDataByFid(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise; getNameRegistryEvent( request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata + metadata?: grpcWeb.grpc.Metadata, ): Promise; - getUsernameProof( - request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata - ): Promise; + /** Username Proof */ + getUsernameProof(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise; + getUserNameProofsByFid(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise; /** Verifications */ getVerification(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise; getVerificationsByFid(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise; /** Signer */ getSigner(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise; getSignersByFid(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise; - getIdRegistryEvent( - request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata - ): Promise; + getIdRegistryEvent(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise; getIdRegistryEventByAddress( request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata + metadata?: grpcWeb.grpc.Metadata, ): Promise; getFids(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise; /** Links */ getLink(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise; getLinksByFid(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise; - getLinksByTarget( - request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata - ): Promise; + getLinksByTarget(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise; /** Bulk Methods */ - getAllCastMessagesByFid( - request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata - ): Promise; - getAllReactionMessagesByFid( - request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata - ): Promise; + getAllCastMessagesByFid(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise; + getAllReactionMessagesByFid(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise; getAllVerificationMessagesByFid( request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata - ): Promise; - getAllSignerMessagesByFid( - request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata - ): Promise; - getAllUserDataMessagesByFid( - request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata - ): Promise; - getAllLinkMessagesByFid( - request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata + metadata?: grpcWeb.grpc.Metadata, ): Promise; + getAllSignerMessagesByFid(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise; + getAllUserDataMessagesByFid(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise; + getAllLinkMessagesByFid(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise; /** Sync Methods */ getInfo(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise; getSyncStatus(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise; @@ -135,11 +108,11 @@ export interface HubService { getAllMessagesBySyncIds(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise; getSyncMetadataByPrefix( request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata + metadata?: grpcWeb.grpc.Metadata, ): Promise; getSyncSnapshotByPrefix( request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata + metadata?: grpcWeb.grpc.Metadata, ): Promise; } @@ -163,6 +136,7 @@ export class HubServiceClientImpl implements HubService { this.getUserDataByFid = this.getUserDataByFid.bind(this); this.getNameRegistryEvent = this.getNameRegistryEvent.bind(this); this.getUsernameProof = this.getUsernameProof.bind(this); + this.getUserNameProofsByFid = this.getUserNameProofsByFid.bind(this); this.getVerification = this.getVerification.bind(this); this.getVerificationsByFid = this.getVerificationsByFid.bind(this); this.getSigner = this.getSigner.bind(this); @@ -207,10 +181,7 @@ export class HubServiceClientImpl implements HubService { return this.rpc.unary(HubServiceGetCastsByFidDesc, FidRequest.fromPartial(request), metadata); } - getCastsByParent( - request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata - ): Promise { + getCastsByParent(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise { return this.rpc.unary(HubServiceGetCastsByParentDesc, CastsByParentRequest.fromPartial(request), metadata); } @@ -222,23 +193,20 @@ export class HubServiceClientImpl implements HubService { return this.rpc.unary(HubServiceGetReactionDesc, ReactionRequest.fromPartial(request), metadata); } - getReactionsByFid( - request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata - ): Promise { + getReactionsByFid(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise { return this.rpc.unary(HubServiceGetReactionsByFidDesc, ReactionsByFidRequest.fromPartial(request), metadata); } getReactionsByCast( request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata + metadata?: grpcWeb.grpc.Metadata, ): Promise { return this.rpc.unary(HubServiceGetReactionsByCastDesc, ReactionsByTargetRequest.fromPartial(request), metadata); } getReactionsByTarget( request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata + metadata?: grpcWeb.grpc.Metadata, ): Promise { return this.rpc.unary(HubServiceGetReactionsByTargetDesc, ReactionsByTargetRequest.fromPartial(request), metadata); } @@ -253,18 +221,19 @@ export class HubServiceClientImpl implements HubService { getNameRegistryEvent( request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata + metadata?: grpcWeb.grpc.Metadata, ): Promise { return this.rpc.unary(HubServiceGetNameRegistryEventDesc, NameRegistryEventRequest.fromPartial(request), metadata); } - getUsernameProof( - request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata - ): Promise { + getUsernameProof(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise { return this.rpc.unary(HubServiceGetUsernameProofDesc, UsernameProofRequest.fromPartial(request), metadata); } + getUserNameProofsByFid(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise { + return this.rpc.unary(HubServiceGetUserNameProofsByFidDesc, FidRequest.fromPartial(request), metadata); + } + getVerification(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise { return this.rpc.unary(HubServiceGetVerificationDesc, VerificationRequest.fromPartial(request), metadata); } @@ -281,21 +250,18 @@ export class HubServiceClientImpl implements HubService { return this.rpc.unary(HubServiceGetSignersByFidDesc, FidRequest.fromPartial(request), metadata); } - getIdRegistryEvent( - request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata - ): Promise { + getIdRegistryEvent(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise { return this.rpc.unary(HubServiceGetIdRegistryEventDesc, IdRegistryEventRequest.fromPartial(request), metadata); } getIdRegistryEventByAddress( request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata + metadata?: grpcWeb.grpc.Metadata, ): Promise { return this.rpc.unary( HubServiceGetIdRegistryEventByAddressDesc, IdRegistryEventByAddressRequest.fromPartial(request), - metadata + metadata, ); } @@ -311,52 +277,34 @@ export class HubServiceClientImpl implements HubService { return this.rpc.unary(HubServiceGetLinksByFidDesc, LinksByFidRequest.fromPartial(request), metadata); } - getLinksByTarget( - request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata - ): Promise { + getLinksByTarget(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise { return this.rpc.unary(HubServiceGetLinksByTargetDesc, LinksByTargetRequest.fromPartial(request), metadata); } - getAllCastMessagesByFid( - request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata - ): Promise { + getAllCastMessagesByFid(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise { return this.rpc.unary(HubServiceGetAllCastMessagesByFidDesc, FidRequest.fromPartial(request), metadata); } - getAllReactionMessagesByFid( - request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata - ): Promise { + getAllReactionMessagesByFid(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise { return this.rpc.unary(HubServiceGetAllReactionMessagesByFidDesc, FidRequest.fromPartial(request), metadata); } getAllVerificationMessagesByFid( request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata + metadata?: grpcWeb.grpc.Metadata, ): Promise { return this.rpc.unary(HubServiceGetAllVerificationMessagesByFidDesc, FidRequest.fromPartial(request), metadata); } - getAllSignerMessagesByFid( - request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata - ): Promise { + getAllSignerMessagesByFid(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise { return this.rpc.unary(HubServiceGetAllSignerMessagesByFidDesc, FidRequest.fromPartial(request), metadata); } - getAllUserDataMessagesByFid( - request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata - ): Promise { + getAllUserDataMessagesByFid(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise { return this.rpc.unary(HubServiceGetAllUserDataMessagesByFidDesc, FidRequest.fromPartial(request), metadata); } - getAllLinkMessagesByFid( - request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata - ): Promise { + getAllLinkMessagesByFid(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise { return this.rpc.unary(HubServiceGetAllLinkMessagesByFidDesc, FidRequest.fromPartial(request), metadata); } @@ -364,10 +312,7 @@ export class HubServiceClientImpl implements HubService { return this.rpc.unary(HubServiceGetInfoDesc, HubInfoRequest.fromPartial(request), metadata); } - getSyncStatus( - request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata - ): Promise { + getSyncStatus(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise { return this.rpc.unary(HubServiceGetSyncStatusDesc, SyncStatusRequest.fromPartial(request), metadata); } @@ -381,23 +326,23 @@ export class HubServiceClientImpl implements HubService { getSyncMetadataByPrefix( request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata + metadata?: grpcWeb.grpc.Metadata, ): Promise { return this.rpc.unary(HubServiceGetSyncMetadataByPrefixDesc, TrieNodePrefix.fromPartial(request), metadata); } getSyncSnapshotByPrefix( request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata + metadata?: grpcWeb.grpc.Metadata, ): Promise { return this.rpc.unary(HubServiceGetSyncSnapshotByPrefixDesc, TrieNodePrefix.fromPartial(request), metadata); } } -export const HubServiceDesc = { serviceName: 'HubService' }; +export const HubServiceDesc = { serviceName: "HubService" }; export const HubServiceSubmitMessageDesc: UnaryMethodDefinitionish = { - methodName: 'SubmitMessage', + methodName: "SubmitMessage", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -420,7 +365,7 @@ export const HubServiceSubmitMessageDesc: UnaryMethodDefinitionish = { }; export const HubServiceSubscribeDesc: UnaryMethodDefinitionish = { - methodName: 'Subscribe', + methodName: "Subscribe", service: HubServiceDesc, requestStream: false, responseStream: true, @@ -443,7 +388,7 @@ export const HubServiceSubscribeDesc: UnaryMethodDefinitionish = { }; export const HubServiceGetEventDesc: UnaryMethodDefinitionish = { - methodName: 'GetEvent', + methodName: "GetEvent", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -466,7 +411,7 @@ export const HubServiceGetEventDesc: UnaryMethodDefinitionish = { }; export const HubServiceGetCastDesc: UnaryMethodDefinitionish = { - methodName: 'GetCast', + methodName: "GetCast", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -489,7 +434,7 @@ export const HubServiceGetCastDesc: UnaryMethodDefinitionish = { }; export const HubServiceGetCastsByFidDesc: UnaryMethodDefinitionish = { - methodName: 'GetCastsByFid', + methodName: "GetCastsByFid", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -512,7 +457,7 @@ export const HubServiceGetCastsByFidDesc: UnaryMethodDefinitionish = { }; export const HubServiceGetCastsByParentDesc: UnaryMethodDefinitionish = { - methodName: 'GetCastsByParent', + methodName: "GetCastsByParent", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -535,7 +480,7 @@ export const HubServiceGetCastsByParentDesc: UnaryMethodDefinitionish = { }; export const HubServiceGetCastsByMentionDesc: UnaryMethodDefinitionish = { - methodName: 'GetCastsByMention', + methodName: "GetCastsByMention", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -558,7 +503,7 @@ export const HubServiceGetCastsByMentionDesc: UnaryMethodDefinitionish = { }; export const HubServiceGetReactionDesc: UnaryMethodDefinitionish = { - methodName: 'GetReaction', + methodName: "GetReaction", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -581,7 +526,7 @@ export const HubServiceGetReactionDesc: UnaryMethodDefinitionish = { }; export const HubServiceGetReactionsByFidDesc: UnaryMethodDefinitionish = { - methodName: 'GetReactionsByFid', + methodName: "GetReactionsByFid", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -604,7 +549,7 @@ export const HubServiceGetReactionsByFidDesc: UnaryMethodDefinitionish = { }; export const HubServiceGetReactionsByCastDesc: UnaryMethodDefinitionish = { - methodName: 'GetReactionsByCast', + methodName: "GetReactionsByCast", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -627,7 +572,7 @@ export const HubServiceGetReactionsByCastDesc: UnaryMethodDefinitionish = { }; export const HubServiceGetReactionsByTargetDesc: UnaryMethodDefinitionish = { - methodName: 'GetReactionsByTarget', + methodName: "GetReactionsByTarget", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -650,7 +595,7 @@ export const HubServiceGetReactionsByTargetDesc: UnaryMethodDefinitionish = { }; export const HubServiceGetUserDataDesc: UnaryMethodDefinitionish = { - methodName: 'GetUserData', + methodName: "GetUserData", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -673,7 +618,7 @@ export const HubServiceGetUserDataDesc: UnaryMethodDefinitionish = { }; export const HubServiceGetUserDataByFidDesc: UnaryMethodDefinitionish = { - methodName: 'GetUserDataByFid', + methodName: "GetUserDataByFid", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -696,7 +641,7 @@ export const HubServiceGetUserDataByFidDesc: UnaryMethodDefinitionish = { }; export const HubServiceGetNameRegistryEventDesc: UnaryMethodDefinitionish = { - methodName: 'GetNameRegistryEvent', + methodName: "GetNameRegistryEvent", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -719,7 +664,7 @@ export const HubServiceGetNameRegistryEventDesc: UnaryMethodDefinitionish = { }; export const HubServiceGetUsernameProofDesc: UnaryMethodDefinitionish = { - methodName: 'GetUsernameProof', + methodName: "GetUsernameProof", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -741,8 +686,31 @@ export const HubServiceGetUsernameProofDesc: UnaryMethodDefinitionish = { } as any, }; +export const HubServiceGetUserNameProofsByFidDesc: UnaryMethodDefinitionish = { + methodName: "GetUserNameProofsByFid", + service: HubServiceDesc, + requestStream: false, + responseStream: false, + requestType: { + serializeBinary() { + return FidRequest.encode(this).finish(); + }, + } as any, + responseType: { + deserializeBinary(data: Uint8Array) { + const value = UsernameProofsResponse.decode(data); + return { + ...value, + toObject() { + return value; + }, + }; + }, + } as any, +}; + export const HubServiceGetVerificationDesc: UnaryMethodDefinitionish = { - methodName: 'GetVerification', + methodName: "GetVerification", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -765,7 +733,7 @@ export const HubServiceGetVerificationDesc: UnaryMethodDefinitionish = { }; export const HubServiceGetVerificationsByFidDesc: UnaryMethodDefinitionish = { - methodName: 'GetVerificationsByFid', + methodName: "GetVerificationsByFid", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -788,7 +756,7 @@ export const HubServiceGetVerificationsByFidDesc: UnaryMethodDefinitionish = { }; export const HubServiceGetSignerDesc: UnaryMethodDefinitionish = { - methodName: 'GetSigner', + methodName: "GetSigner", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -811,7 +779,7 @@ export const HubServiceGetSignerDesc: UnaryMethodDefinitionish = { }; export const HubServiceGetSignersByFidDesc: UnaryMethodDefinitionish = { - methodName: 'GetSignersByFid', + methodName: "GetSignersByFid", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -834,7 +802,7 @@ export const HubServiceGetSignersByFidDesc: UnaryMethodDefinitionish = { }; export const HubServiceGetIdRegistryEventDesc: UnaryMethodDefinitionish = { - methodName: 'GetIdRegistryEvent', + methodName: "GetIdRegistryEvent", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -857,7 +825,7 @@ export const HubServiceGetIdRegistryEventDesc: UnaryMethodDefinitionish = { }; export const HubServiceGetIdRegistryEventByAddressDesc: UnaryMethodDefinitionish = { - methodName: 'GetIdRegistryEventByAddress', + methodName: "GetIdRegistryEventByAddress", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -880,7 +848,7 @@ export const HubServiceGetIdRegistryEventByAddressDesc: UnaryMethodDefinitionish }; export const HubServiceGetFidsDesc: UnaryMethodDefinitionish = { - methodName: 'GetFids', + methodName: "GetFids", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -903,7 +871,7 @@ export const HubServiceGetFidsDesc: UnaryMethodDefinitionish = { }; export const HubServiceGetLinkDesc: UnaryMethodDefinitionish = { - methodName: 'GetLink', + methodName: "GetLink", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -926,7 +894,7 @@ export const HubServiceGetLinkDesc: UnaryMethodDefinitionish = { }; export const HubServiceGetLinksByFidDesc: UnaryMethodDefinitionish = { - methodName: 'GetLinksByFid', + methodName: "GetLinksByFid", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -949,7 +917,7 @@ export const HubServiceGetLinksByFidDesc: UnaryMethodDefinitionish = { }; export const HubServiceGetLinksByTargetDesc: UnaryMethodDefinitionish = { - methodName: 'GetLinksByTarget', + methodName: "GetLinksByTarget", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -972,7 +940,7 @@ export const HubServiceGetLinksByTargetDesc: UnaryMethodDefinitionish = { }; export const HubServiceGetAllCastMessagesByFidDesc: UnaryMethodDefinitionish = { - methodName: 'GetAllCastMessagesByFid', + methodName: "GetAllCastMessagesByFid", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -995,7 +963,7 @@ export const HubServiceGetAllCastMessagesByFidDesc: UnaryMethodDefinitionish = { }; export const HubServiceGetAllReactionMessagesByFidDesc: UnaryMethodDefinitionish = { - methodName: 'GetAllReactionMessagesByFid', + methodName: "GetAllReactionMessagesByFid", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -1018,7 +986,7 @@ export const HubServiceGetAllReactionMessagesByFidDesc: UnaryMethodDefinitionish }; export const HubServiceGetAllVerificationMessagesByFidDesc: UnaryMethodDefinitionish = { - methodName: 'GetAllVerificationMessagesByFid', + methodName: "GetAllVerificationMessagesByFid", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -1041,7 +1009,7 @@ export const HubServiceGetAllVerificationMessagesByFidDesc: UnaryMethodDefinitio }; export const HubServiceGetAllSignerMessagesByFidDesc: UnaryMethodDefinitionish = { - methodName: 'GetAllSignerMessagesByFid', + methodName: "GetAllSignerMessagesByFid", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -1064,7 +1032,7 @@ export const HubServiceGetAllSignerMessagesByFidDesc: UnaryMethodDefinitionish = }; export const HubServiceGetAllUserDataMessagesByFidDesc: UnaryMethodDefinitionish = { - methodName: 'GetAllUserDataMessagesByFid', + methodName: "GetAllUserDataMessagesByFid", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -1087,7 +1055,7 @@ export const HubServiceGetAllUserDataMessagesByFidDesc: UnaryMethodDefinitionish }; export const HubServiceGetAllLinkMessagesByFidDesc: UnaryMethodDefinitionish = { - methodName: 'GetAllLinkMessagesByFid', + methodName: "GetAllLinkMessagesByFid", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -1110,7 +1078,7 @@ export const HubServiceGetAllLinkMessagesByFidDesc: UnaryMethodDefinitionish = { }; export const HubServiceGetInfoDesc: UnaryMethodDefinitionish = { - methodName: 'GetInfo', + methodName: "GetInfo", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -1133,7 +1101,7 @@ export const HubServiceGetInfoDesc: UnaryMethodDefinitionish = { }; export const HubServiceGetSyncStatusDesc: UnaryMethodDefinitionish = { - methodName: 'GetSyncStatus', + methodName: "GetSyncStatus", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -1156,7 +1124,7 @@ export const HubServiceGetSyncStatusDesc: UnaryMethodDefinitionish = { }; export const HubServiceGetAllSyncIdsByPrefixDesc: UnaryMethodDefinitionish = { - methodName: 'GetAllSyncIdsByPrefix', + methodName: "GetAllSyncIdsByPrefix", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -1179,7 +1147,7 @@ export const HubServiceGetAllSyncIdsByPrefixDesc: UnaryMethodDefinitionish = { }; export const HubServiceGetAllMessagesBySyncIdsDesc: UnaryMethodDefinitionish = { - methodName: 'GetAllMessagesBySyncIds', + methodName: "GetAllMessagesBySyncIds", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -1202,7 +1170,7 @@ export const HubServiceGetAllMessagesBySyncIdsDesc: UnaryMethodDefinitionish = { }; export const HubServiceGetSyncMetadataByPrefixDesc: UnaryMethodDefinitionish = { - methodName: 'GetSyncMetadataByPrefix', + methodName: "GetSyncMetadataByPrefix", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -1225,7 +1193,7 @@ export const HubServiceGetSyncMetadataByPrefixDesc: UnaryMethodDefinitionish = { }; export const HubServiceGetSyncSnapshotByPrefixDesc: UnaryMethodDefinitionish = { - methodName: 'GetSyncSnapshotByPrefix', + methodName: "GetSyncSnapshotByPrefix", service: HubServiceDesc, requestStream: false, responseStream: false, @@ -1250,13 +1218,10 @@ export const HubServiceGetSyncSnapshotByPrefixDesc: UnaryMethodDefinitionish = { export interface AdminService { rebuildSyncTrie(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise; deleteAllMessagesFromDb(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise; - submitIdRegistryEvent( - request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata - ): Promise; + submitIdRegistryEvent(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise; submitNameRegistryEvent( request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata + metadata?: grpcWeb.grpc.Metadata, ): Promise; } @@ -1279,25 +1244,22 @@ export class AdminServiceClientImpl implements AdminService { return this.rpc.unary(AdminServiceDeleteAllMessagesFromDbDesc, Empty.fromPartial(request), metadata); } - submitIdRegistryEvent( - request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata - ): Promise { + submitIdRegistryEvent(request: DeepPartial, metadata?: grpcWeb.grpc.Metadata): Promise { return this.rpc.unary(AdminServiceSubmitIdRegistryEventDesc, IdRegistryEvent.fromPartial(request), metadata); } submitNameRegistryEvent( request: DeepPartial, - metadata?: grpcWeb.grpc.Metadata + metadata?: grpcWeb.grpc.Metadata, ): Promise { return this.rpc.unary(AdminServiceSubmitNameRegistryEventDesc, NameRegistryEvent.fromPartial(request), metadata); } } -export const AdminServiceDesc = { serviceName: 'AdminService' }; +export const AdminServiceDesc = { serviceName: "AdminService" }; export const AdminServiceRebuildSyncTrieDesc: UnaryMethodDefinitionish = { - methodName: 'RebuildSyncTrie', + methodName: "RebuildSyncTrie", service: AdminServiceDesc, requestStream: false, responseStream: false, @@ -1320,7 +1282,7 @@ export const AdminServiceRebuildSyncTrieDesc: UnaryMethodDefinitionish = { }; export const AdminServiceDeleteAllMessagesFromDbDesc: UnaryMethodDefinitionish = { - methodName: 'DeleteAllMessagesFromDb', + methodName: "DeleteAllMessagesFromDb", service: AdminServiceDesc, requestStream: false, responseStream: false, @@ -1343,7 +1305,7 @@ export const AdminServiceDeleteAllMessagesFromDbDesc: UnaryMethodDefinitionish = }; export const AdminServiceSubmitIdRegistryEventDesc: UnaryMethodDefinitionish = { - methodName: 'SubmitIdRegistryEvent', + methodName: "SubmitIdRegistryEvent", service: AdminServiceDesc, requestStream: false, responseStream: false, @@ -1366,7 +1328,7 @@ export const AdminServiceSubmitIdRegistryEventDesc: UnaryMethodDefinitionish = { }; export const AdminServiceSubmitNameRegistryEventDesc: UnaryMethodDefinitionish = { - methodName: 'SubmitNameRegistryEvent', + methodName: "SubmitNameRegistryEvent", service: AdminServiceDesc, requestStream: false, responseStream: false, @@ -1399,12 +1361,12 @@ interface Rpc { unary( methodDesc: T, request: any, - metadata: grpcWeb.grpc.Metadata | undefined + metadata: grpcWeb.grpc.Metadata | undefined, ): Promise; invoke( methodDesc: T, request: any, - metadata: grpcWeb.grpc.Metadata | undefined + metadata: grpcWeb.grpc.Metadata | undefined, ): Observable; } @@ -1426,7 +1388,7 @@ export class GrpcWebImpl { debug?: boolean; metadata?: grpcWeb.grpc.Metadata; upStreamRetryCodes?: number[]; - } + }, ) { this.host = host; this.options = options; @@ -1435,13 +1397,12 @@ export class GrpcWebImpl { unary( methodDesc: T, _request: any, - metadata: grpcWeb.grpc.Metadata | undefined + metadata: grpcWeb.grpc.Metadata | undefined, ): Promise { const request = { ..._request, ...methodDesc.requestType }; - const maybeCombinedMetadata = - metadata && this.options.metadata - ? new BrowserHeaders({ ...this.options?.metadata.headersMap, ...metadata?.headersMap }) - : metadata || this.options.metadata; + const maybeCombinedMetadata = metadata && this.options.metadata + ? new BrowserHeaders({ ...this.options?.metadata.headersMap, ...metadata?.headersMap }) + : metadata || this.options.metadata; return new Promise((resolve, reject) => { grpcWeb.grpc.unary(methodDesc, { request, @@ -1464,17 +1425,16 @@ export class GrpcWebImpl { invoke( methodDesc: T, _request: any, - metadata: grpcWeb.grpc.Metadata | undefined + metadata: grpcWeb.grpc.Metadata | undefined, ): Observable { const upStreamCodes = this.options.upStreamRetryCodes || []; const DEFAULT_TIMEOUT_TIME: number = 3_000; const request = { ..._request, ...methodDesc.requestType }; - const maybeCombinedMetadata = - metadata && this.options.metadata - ? new BrowserHeaders({ ...this.options?.metadata.headersMap, ...metadata?.headersMap }) - : metadata || this.options.metadata; + const maybeCombinedMetadata = metadata && this.options.metadata + ? new BrowserHeaders({ ...this.options?.metadata.headersMap, ...metadata?.headersMap }) + : metadata || this.options.metadata; return new Observable((observer) => { - const upStream = () => { + const upStream = (() => { const client = grpcWeb.grpc.invoke(methodDesc, { host: this.host, request, @@ -1500,7 +1460,7 @@ export class GrpcWebImpl { return client.close(); } }); - }; + }); upStream(); }).pipe(share()); } @@ -1510,31 +1470,26 @@ declare var self: any | undefined; declare var window: any | undefined; declare var global: any | undefined; var tsProtoGlobalThis: any = (() => { - if (typeof globalThis !== 'undefined') { + if (typeof globalThis !== "undefined") { return globalThis; } - if (typeof self !== 'undefined') { + if (typeof self !== "undefined") { return self; } - if (typeof window !== 'undefined') { + if (typeof window !== "undefined") { return window; } - if (typeof global !== 'undefined') { + if (typeof global !== "undefined") { return global; } - throw 'Unable to locate global object'; + throw "Unable to locate global object"; })(); type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; -type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } +type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; export class GrpcWebError extends tsProtoGlobalThis.Error { diff --git a/packages/hub-web/src/generated/username_proof.ts b/packages/hub-web/src/generated/username_proof.ts index 96f1c7464f..d25ba3f8f9 100644 --- a/packages/hub-web/src/generated/username_proof.ts +++ b/packages/hub-web/src/generated/username_proof.ts @@ -1,33 +1,39 @@ /* eslint-disable */ -import Long from 'long'; -import _m0 from 'protobufjs/minimal'; +import Long from "long"; +import _m0 from "protobufjs/minimal"; export enum UserNameType { USERNAME_TYPE_NONE = 0, USERNAME_TYPE_FNAME = 1, + USERNAME_TYPE_ENS_L1 = 2, } export function userNameTypeFromJSON(object: any): UserNameType { switch (object) { case 0: - case 'USERNAME_TYPE_NONE': + case "USERNAME_TYPE_NONE": return UserNameType.USERNAME_TYPE_NONE; case 1: - case 'USERNAME_TYPE_FNAME': + case "USERNAME_TYPE_FNAME": return UserNameType.USERNAME_TYPE_FNAME; + case 2: + case "USERNAME_TYPE_ENS_L1": + return UserNameType.USERNAME_TYPE_ENS_L1; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum UserNameType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum UserNameType"); } } export function userNameTypeToJSON(object: UserNameType): string { switch (object) { case UserNameType.USERNAME_TYPE_NONE: - return 'USERNAME_TYPE_NONE'; + return "USERNAME_TYPE_NONE"; case UserNameType.USERNAME_TYPE_FNAME: - return 'USERNAME_TYPE_FNAME'; + return "USERNAME_TYPE_FNAME"; + case UserNameType.USERNAME_TYPE_ENS_L1: + return "USERNAME_TYPE_ENS_L1"; default: - throw new tsProtoGlobalThis.Error('Unrecognized enum value ' + object + ' for enum UserNameType'); + throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum UserNameType"); } } @@ -177,24 +183,24 @@ declare var self: any | undefined; declare var window: any | undefined; declare var global: any | undefined; var tsProtoGlobalThis: any = (() => { - if (typeof globalThis !== 'undefined') { + if (typeof globalThis !== "undefined") { return globalThis; } - if (typeof self !== 'undefined') { + if (typeof self !== "undefined") { return self; } - if (typeof window !== 'undefined') { + if (typeof window !== "undefined") { return window; } - if (typeof global !== 'undefined') { + if (typeof global !== "undefined") { return global; } - throw 'Unable to locate global object'; + throw "Unable to locate global object"; })(); function bytesFromBase64(b64: string): Uint8Array { if (tsProtoGlobalThis.Buffer) { - return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, 'base64')); + return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, "base64")); } else { const bin = tsProtoGlobalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -207,36 +213,30 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (tsProtoGlobalThis.Buffer) { - return tsProtoGlobalThis.Buffer.from(arr).toString('base64'); + return tsProtoGlobalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return tsProtoGlobalThis.btoa(bin.join('')); + return tsProtoGlobalThis.btoa(bin.join("")); } } type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; -type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } +type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; type KeysOfUnion = T extends T ? keyof T : never; -type Exact = P extends Builtin - ? P +type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function longToNumber(long: Long): number { if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new tsProtoGlobalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/protobufs/schemas/hub_event.proto b/protobufs/schemas/hub_event.proto index 3f91ccf326..8262f3ba1f 100644 --- a/protobufs/schemas/hub_event.proto +++ b/protobufs/schemas/hub_event.proto @@ -39,6 +39,8 @@ message MergeNameRegistryEventBody { message MergeUserNameProofBody { UserNameProof username_proof = 1; UserNameProof deleted_username_proof = 2; + Message username_proof_message = 3; + Message deleted_username_proof_message = 4; } message HubEvent { diff --git a/protobufs/schemas/message.proto b/protobufs/schemas/message.proto index 9192b4ce5d..3de2c73ac8 100644 --- a/protobufs/schemas/message.proto +++ b/protobufs/schemas/message.proto @@ -1,4 +1,5 @@ syntax = "proto3"; +import "username_proof.proto"; /** * A Message is a delta operation on the Farcaster network. The message protobuf is an envelope @@ -32,6 +33,7 @@ message MessageData { UserDataBody user_data_body = 12; SignerRemoveBody signer_remove_body = 13; LinkBody link_body = 14; + UserNameProof username_proof_body = 15; } // Properties specific to the MessageType } @@ -62,6 +64,7 @@ enum MessageType { MESSAGE_TYPE_SIGNER_ADD = 9; // Add a new Ed25519 key pair that signs messages for a user MESSAGE_TYPE_SIGNER_REMOVE = 10; // Remove an Ed25519 key pair that signs messages for a user MESSAGE_TYPE_USER_DATA_ADD = 11; // Add metadata about a user + MESSAGE_TYPE_USERNAME_PROOF = 12; // Add or replace a username proof } /** Farcaster network the message is intended for */ diff --git a/protobufs/schemas/request_response.proto b/protobufs/schemas/request_response.proto index d358ce8419..c5f2784a7c 100644 --- a/protobufs/schemas/request_response.proto +++ b/protobufs/schemas/request_response.proto @@ -2,6 +2,7 @@ syntax = "proto3"; import "message.proto"; import "hub_event.proto"; +import "username_proof.proto"; message Empty {} @@ -149,6 +150,10 @@ message UsernameProofRequest { bytes name = 1; } +message UsernameProofsResponse { + repeated UserNameProof proofs = 1; +} + message VerificationRequest { uint64 fid = 1; bytes address = 2; diff --git a/protobufs/schemas/rpc.proto b/protobufs/schemas/rpc.proto index 06a1ebc884..2a5fbf4127 100644 --- a/protobufs/schemas/rpc.proto +++ b/protobufs/schemas/rpc.proto @@ -31,7 +31,10 @@ service HubService { rpc GetUserData(UserDataRequest) returns (Message); rpc GetUserDataByFid(FidRequest) returns (MessagesResponse); rpc GetNameRegistryEvent(NameRegistryEventRequest) returns (NameRegistryEvent); + + // Username Proof rpc GetUsernameProof(UsernameProofRequest) returns (UserNameProof); + rpc GetUserNameProofsByFid(FidRequest) returns (UsernameProofsResponse); // Verifications rpc GetVerification(VerificationRequest) returns (Message); diff --git a/protobufs/schemas/username_proof.proto b/protobufs/schemas/username_proof.proto index 4dfbc18ace..3a888f0ed9 100644 --- a/protobufs/schemas/username_proof.proto +++ b/protobufs/schemas/username_proof.proto @@ -3,6 +3,7 @@ syntax = "proto3"; enum UserNameType { USERNAME_TYPE_NONE = 0; USERNAME_TYPE_FNAME = 1; + USERNAME_TYPE_ENS_L1 = 2; } message UserNameProof { diff --git a/rome.json b/rome.json index b41e2afceb..c99e1797ef 100644 --- a/rome.json +++ b/rome.json @@ -8,13 +8,25 @@ "indentSize": 2, "indentStyle": "space", "lineWidth": 120, - "ignore": ["src/abstract-leveldown.d.ts", "src/rocksdb.d.ts"] + "ignore": [ + "src/abstract-leveldown.d.ts", + "src/rocksdb.d.ts", + "packages/core/src/protobufs/generated/*", + "packages/hub-nodejs/src/generated/*", + "packages/hub-web/src/generated/*" + ] }, "linter": { "enabled": true, "rules": { "recommended": true }, - "ignore": ["src/abstract-leveldown.d.ts", "src/rocksdb.d.ts"] + "ignore": [ + "src/abstract-leveldown.d.ts", + "src/rocksdb.d.ts", + "packages/core/src/protobufs/generated/*", + "packages/hub-nodejs/src/generated/*", + "packages/hub-web/src/generated/*" + ] } }