Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Commit

Permalink
make clear currently using grpc in that code
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelLHuber committed Mar 7, 2024
1 parent e8b2b6f commit 1acb667
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
30 changes: 16 additions & 14 deletions src/functions/getConnectedAddresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import { ConnectedAddresses } from "../types";
export default function getConnectedAddresses(provider: Provider, fid: number, ethereum?: boolean, solana?: boolean): ConnectedAddresses {
let addresses: ConnectedAddresses;

if(provider instanceof HubProvider) {
if(provider.psqlUrl)
if (provider instanceof HubProvider) {
if (provider.psqlUrl)
addresses = getConnectedAddressesFromReplicator(provider.psqlUrl, fid, ethereum, solana);
else
addresses = getConnectedAddressesFromHub(provider.hubUrl, fid, ethereum, solana);
}
else if( provider instanceof NeynarProvider) {
else if (provider instanceof NeynarProvider) {
addresses = getConnectedAddressesFromNeynar(provider, fid, ethereum, solana);
}
else {
Expand Down Expand Up @@ -50,30 +50,30 @@ function getConnectedAddressesFromHub(hubUrl: string, fid: number, ethereum?: bo
const client = getSSLHubRpcClient(hubUrl);

try {
const verificationResponse = client.getVerificationsByFid({fid: fid});
const verificationResponse = client.getVerificationsByFid({ fid: fid });

if (verificationResponse.isOk() && verificationResponse.value) {
verificationResponse.value.messages.forEach((verification) => {

if(verification.data?.verificationAddAddressBody?.protocol === 0){ // protocol === 0 guarantees only ETH addresses
const addressBytes = verification.data?.verificationAddAddressBody.address;
const address = `0x${Buffer.from(addressBytes).toString('hex')}`;
addresses.all.push(address);
addresses.ethereum.push(address);
if (verification.data?.verificationAddAddressBody?.protocol === 0) { // protocol === 0 guarantees only ETH addresses
const addressBytes = verification.data?.verificationAddAddressBody.address;
const address = `0x${Buffer.from(addressBytes).toString('hex')}`;
addresses.all.push(address);
addresses.ethereum.push(address);
}

if(verification.data?.verificationAddAddressBody?.protocol === 1){ // protocol === 1 guarantees only SOL addresses
if (verification.data?.verificationAddAddressBody?.protocol === 1) { // protocol === 1 guarantees only SOL addresses
const addressBytes = verification.data?.verificationAddAddressBody.address;
const address = `${Buffer.from(addressBytes).toString('hex')}`;
addresses.all.push(address);
addresses.solana.push(address);
const address = `${Buffer.from(addressBytes).toString('hex')}`;
addresses.all.push(address);
addresses.solana.push(address);
}

});
}
} catch (e) {
console.error(e);
throw new Error("Error getting verifications from hub", e);
throw new Error("Error getting verifications from hub");
}
return addresses;
}
Expand All @@ -85,5 +85,7 @@ function getConnectedAddressesFromNeynar(provider: NeynarProvider, fid: number,
solana: [],
};
// ...


throw new Error("Not implemented");
}
2 changes: 1 addition & 1 deletion src/providers/class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class HubProvider extends Provider {
/**
* HubProvider for getting Data with Farcaster Hubs and optional PostgreSQL Replicator
* @param name the custom name of the provider. useful for debugging output
* @param hubUrl the Farcaster Hub URL to use
* @param hubUrl the Farcaster Hub gRPC endpoint to use !use gRPC!
* @param psqlUrl optional: the PostgreSQL Replicator URL to use. Defaults to undefined
*/
constructor(name: string, hubUrl: string, psqlUrl?: string) {
Expand Down
2 changes: 1 addition & 1 deletion src/providers/public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class PublicProvider extends HubProvider {
let name: string;

if (providerType === 'pinata') {
hubUrl = 'hub.pinata.cloud/v1/';
hubUrl = 'hub-grpc.pinata.cloud';
name = 'publicPinataHub';
} else {
hubUrl = 'nemes.farcaster.xyz:2283';
Expand Down

0 comments on commit 1acb667

Please sign in to comment.