@farcaster/hub-web 0.9.4 → 0.9.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.grpcweb.md CHANGED
@@ -53,7 +53,7 @@ import { getHubRpcClient } from '@farcaster/hub-web';
53
53
  (async () => {
54
54
  const client = getHubRpcClient('https://testnet1.farcaster.xyz:2285');
55
55
 
56
- // If you're using gRPC-Web from a Nodejs environment, add a second false parameter
56
+ // If you're using gRPC-Web from a Node.js environment, add a second false parameter
57
57
  // const nodeClient = getHubRpcClient('https://testnet1.farcaster.xyz:2285', false);
58
58
  })();
59
59
  ```
@@ -69,7 +69,7 @@ import { getHubRpcClient } from '@farcaster/hub-web';
69
69
  | Name | Type | Description |
70
70
  | :---------- | :-------- | :------------------------------------------------------------------------- |
71
71
  | `url` | `string` | Address and RPC port string (e.g. `https://testnet1.farcaster.xyz:2285`) |
72
- | `isBrowser` | `boolean` | Optional parameter indicating whether to use the gRPC-Web Nodejs transport |
72
+ | `isBrowser` | `boolean` | Optional parameter indicating whether to use the gRPC-Web Node.js transport |
73
73
 
74
74
  ### Streaming hub events
75
75
 
package/README.md CHANGED
@@ -33,13 +33,34 @@ try {
33
33
  const response = await axios.get(`${server}/v1/castsByFid?fid=${fid}`);
34
34
 
35
35
  console.log(`API Returned HTTP status ${response.status}`);
36
- console.log(`First Cast's text is ${response.messages[0].data.castAddBody.text}`);
36
+ console.log(`The first cast's text is ${response.messages[0].data.castAddBody.text}`);
37
37
  } catch (e) {
38
38
  // Handle errors
39
39
  console.log(response);
40
40
  }
41
41
  ```
42
42
 
43
+ ### Get the username by FID
44
+
45
+ ```typescript
46
+ const getFnameFromFid = async (
47
+ fid: number,
48
+ client: HubRpcClient
49
+ ): HubAsyncResult<string> => {
50
+ const result = await client.getUserData({
51
+ fid: fid,
52
+ userDataType: UserDataType.FNAME,
53
+ });
54
+ return result.map((message) => {
55
+ if (isUserDataAddMessage(message)) {
56
+ return message.data.userDataBody.value;
57
+ } else {
58
+ return '';
59
+ }
60
+ });
61
+ };
62
+ ```
63
+
43
64
  ### Running the examples
44
65
 
45
66
  There are several examples in the `examples/` folder. To run the examples, please look at the individual README files in the examples directory. Most examples can be run by
package/dist/index.d.ts CHANGED
@@ -453,7 +453,11 @@ declare enum UserDataType {
453
453
  /** USERNAME - Preferred Name for the user */
454
454
  USERNAME = 6,
455
455
  /** LOCATION - Current location for the user */
456
- LOCATION = 7
456
+ LOCATION = 7,
457
+ /** TWITTER - Username of user on twitter */
458
+ TWITTER = 8,
459
+ /** GITHUB - Username of user on github */
460
+ GITHUB = 9
457
461
  }
458
462
  /** Type of cast */
459
463
  declare enum CastType {
package/dist/index.js CHANGED
@@ -3138,6 +3138,12 @@ function userDataTypeFromJSON(object) {
3138
3138
  case 7:
3139
3139
  case "USER_DATA_TYPE_LOCATION":
3140
3140
  return 7 /* LOCATION */;
3141
+ case 8:
3142
+ case "USER_DATA_TYPE_TWITTER":
3143
+ return 8 /* TWITTER */;
3144
+ case 9:
3145
+ case "USER_DATA_TYPE_GITHUB":
3146
+ return 9 /* GITHUB */;
3141
3147
  default:
3142
3148
  throw new tsProtoGlobalThis2.Error("Unrecognized enum value " + object + " for enum UserDataType");
3143
3149
  }
@@ -3158,6 +3164,10 @@ function userDataTypeToJSON(object) {
3158
3164
  return "USER_DATA_TYPE_USERNAME";
3159
3165
  case 7 /* LOCATION */:
3160
3166
  return "USER_DATA_TYPE_LOCATION";
3167
+ case 8 /* TWITTER */:
3168
+ return "USER_DATA_TYPE_TWITTER";
3169
+ case 9 /* GITHUB */:
3170
+ return "USER_DATA_TYPE_GITHUB";
3161
3171
  default:
3162
3172
  throw new tsProtoGlobalThis2.Error("Unrecognized enum value " + object + " for enum UserDataType");
3163
3173
  }
package/dist/index.mjs CHANGED
@@ -3070,6 +3070,12 @@ function userDataTypeFromJSON(object) {
3070
3070
  case 7:
3071
3071
  case "USER_DATA_TYPE_LOCATION":
3072
3072
  return 7 /* LOCATION */;
3073
+ case 8:
3074
+ case "USER_DATA_TYPE_TWITTER":
3075
+ return 8 /* TWITTER */;
3076
+ case 9:
3077
+ case "USER_DATA_TYPE_GITHUB":
3078
+ return 9 /* GITHUB */;
3073
3079
  default:
3074
3080
  throw new tsProtoGlobalThis2.Error("Unrecognized enum value " + object + " for enum UserDataType");
3075
3081
  }
@@ -3090,6 +3096,10 @@ function userDataTypeToJSON(object) {
3090
3096
  return "USER_DATA_TYPE_USERNAME";
3091
3097
  case 7 /* LOCATION */:
3092
3098
  return "USER_DATA_TYPE_LOCATION";
3099
+ case 8 /* TWITTER */:
3100
+ return "USER_DATA_TYPE_TWITTER";
3101
+ case 9 /* GITHUB */:
3102
+ return "USER_DATA_TYPE_GITHUB";
3093
3103
  default:
3094
3104
  throw new tsProtoGlobalThis2.Error("Unrecognized enum value " + object + " for enum UserDataType");
3095
3105
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farcaster/hub-web",
3
- "version": "0.9.4",
3
+ "version": "0.9.6",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -32,7 +32,7 @@
32
32
  "ts-proto": "^1.146.0"
33
33
  },
34
34
  "dependencies": {
35
- "@farcaster/core": "^0.15.5",
35
+ "@farcaster/core": "^0.16.0",
36
36
  "@improbable-eng/grpc-web": "^0.15.0",
37
37
  "rxjs": "^7.8.0"
38
38
  }