@b3dotfun/sdk 0.0.69-alpha.0 → 0.0.69-alpha.1

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.
@@ -6,6 +6,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.ProfileEditor = ProfileEditor;
8
8
  const jsx_runtime_1 = require("react/jsx-runtime");
9
+ const ens_normalize_1 = require("@adraffy/ens-normalize");
9
10
  const app_1 = __importDefault(require("../../../../global-account/app"));
10
11
  const react_1 = require("../../../../global-account/react");
11
12
  const profileDisplay_1 = require("../../../../global-account/react/utils/profileDisplay");
@@ -102,10 +103,19 @@ function ProfileEditor({ onSuccess, className }) {
102
103
  }
103
104
  // Update username if changed (this will use the updated user from avatar change if both were updated)
104
105
  if (hasUsernameChange && user?._id) {
105
- // @ts-expect-error this resolved fine, look into why expect-error needed
106
- updatedUser = await app_1.default.service("users").registerUsername({ username: username },
107
- // @ts-expect-error - our typed client is expecting context even though it's set elsewhere
108
- {});
106
+ const sanitizedUsername = (0, ens_normalize_1.ens_normalize)(username);
107
+ const b3Username = `${sanitizedUsername}.b3.fun`;
108
+ const usernameSignMessage = `Register "${b3Username}"`;
109
+ const usernameSignature = await account?.signMessage({ message: usernameSignMessage });
110
+ if (!usernameSignature) {
111
+ throw new Error("Failed to sign username registration message");
112
+ }
113
+ console.log("@@usernameSignature", usernameSignature);
114
+ // Register username with ENS
115
+ // Note: Type assertion needed until @b3dotfun/b3-api package is updated with RegisterUsername type
116
+ updatedUser = (await app_1.default
117
+ .service("users")
118
+ .registerUsername({ username, message: usernameSignMessage, hash: usernameSignature }, {}));
109
119
  }
110
120
  // Update user state
111
121
  setUser(updatedUser);
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { ens_normalize } from "@adraffy/ens-normalize";
3
4
  import app from "../../../../global-account/app.js";
4
5
  import { Button, useB3, useProfile } from "../../../../global-account/react/index.js";
5
6
  import { validateImageUrl } from "../../../../global-account/react/utils/profileDisplay.js";
@@ -96,10 +97,19 @@ export function ProfileEditor({ onSuccess, className }) {
96
97
  }
97
98
  // Update username if changed (this will use the updated user from avatar change if both were updated)
98
99
  if (hasUsernameChange && user?._id) {
99
- // @ts-expect-error this resolved fine, look into why expect-error needed
100
- updatedUser = await app.service("users").registerUsername({ username: username },
101
- // @ts-expect-error - our typed client is expecting context even though it's set elsewhere
102
- {});
100
+ const sanitizedUsername = ens_normalize(username);
101
+ const b3Username = `${sanitizedUsername}.b3.fun`;
102
+ const usernameSignMessage = `Register "${b3Username}"`;
103
+ const usernameSignature = await account?.signMessage({ message: usernameSignMessage });
104
+ if (!usernameSignature) {
105
+ throw new Error("Failed to sign username registration message");
106
+ }
107
+ console.log("@@usernameSignature", usernameSignature);
108
+ // Register username with ENS
109
+ // Note: Type assertion needed until @b3dotfun/b3-api package is updated with RegisterUsername type
110
+ updatedUser = (await app
111
+ .service("users")
112
+ .registerUsername({ username, message: usernameSignMessage, hash: usernameSignature }, {}));
103
113
  }
104
114
  // Update user state
105
115
  setUser(updatedUser);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b3dotfun/sdk",
3
- "version": "0.0.69-alpha.0",
3
+ "version": "0.0.69-alpha.1",
4
4
  "source": "src/index.ts",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "react-native": "./dist/cjs/index.native.js",
@@ -282,7 +282,8 @@
282
282
  "constants"
283
283
  ],
284
284
  "dependencies": {
285
- "@b3dotfun/b3-api": "0.0.84",
285
+ "@adraffy/ens-normalize": "1.11.1",
286
+ "@b3dotfun/b3-api": "0.0.87",
286
287
  "@b3dotfun/basement-api": "0.0.11",
287
288
  "@feathersjs/authentication-client": "5.0.33",
288
289
  "@feathersjs/feathers": "5.0.33",
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
 
3
+ import { ens_normalize } from "@adraffy/ens-normalize";
3
4
  import { Users } from "@b3dotfun/b3-api";
4
5
  import app from "@b3dotfun/sdk/global-account/app";
5
6
  import { Button, useB3, useProfile } from "@b3dotfun/sdk/global-account/react";
@@ -122,12 +123,25 @@ export function ProfileEditor({ onSuccess, className }: ProfileEditorProps) {
122
123
 
123
124
  // Update username if changed (this will use the updated user from avatar change if both were updated)
124
125
  if (hasUsernameChange && user?._id) {
125
- // @ts-expect-error this resolved fine, look into why expect-error needed
126
- updatedUser = await app.service("users").registerUsername(
127
- { username: username },
128
- // @ts-expect-error - our typed client is expecting context even though it's set elsewhere
129
- {},
130
- );
126
+ const sanitizedUsername = ens_normalize(username);
127
+ const b3Username = `${sanitizedUsername}.b3.fun`;
128
+ const usernameSignMessage = `Register "${b3Username}"`;
129
+ const usernameSignature = await account?.signMessage({ message: usernameSignMessage });
130
+
131
+ if (!usernameSignature) {
132
+ throw new Error("Failed to sign username registration message");
133
+ }
134
+
135
+ console.log("@@usernameSignature", usernameSignature);
136
+
137
+ // Register username with ENS
138
+ // Note: Type assertion needed until @b3dotfun/b3-api package is updated with RegisterUsername type
139
+ updatedUser = (await app
140
+ .service("users")
141
+ .registerUsername(
142
+ { username, message: usernameSignMessage, hash: usernameSignature },
143
+ {} as any,
144
+ )) as unknown as Users;
131
145
  }
132
146
 
133
147
  // Update user state