@b3dotfun/sdk 0.0.7-alpha.4 → 0.0.7-alpha.5

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.
@@ -1,8 +1,5 @@
1
1
  export declare const useB3EnsName: () => {
2
- registerEns: (username: string, message: string, hash: string) => Promise<{
3
- success: boolean;
4
- error?: string;
5
- }>;
2
+ registerEns: (name: `${string}.b3.fun`, address: string, hash: string) => Promise<Response>;
6
3
  getEns: (address: string) => Promise<{
7
4
  name: string;
8
5
  }>;
@@ -1,39 +1,39 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.useB3EnsName = void 0;
7
- const bsmnt_1 = __importDefault(require("../../../global-account/bsmnt"));
8
4
  const constants_1 = require("../../../shared/constants");
9
- const js_cookie_1 = __importDefault(require("js-cookie"));
10
5
  const react_1 = require("react");
11
6
  const useB3EnsName = () => {
12
- const registerEns = (0, react_1.useCallback)(async (username, message, hash) => {
13
- if (!bsmnt_1.default.authentication.authenticated) {
14
- await bsmnt_1.default.authentication.authenticate({
15
- strategy: "b3-jwt",
16
- accessToken: js_cookie_1.default.get(constants_1.B3_AUTH_COOKIE_NAME) || ""
17
- });
18
- }
19
- const response = await bsmnt_1.default.service("profiles").registerUsername({
20
- username,
21
- message,
22
- hash
23
- }, {});
7
+ const registerEns = async (name, address, hash) => {
8
+ const message = `Register ${name}`;
9
+ const response = await fetch(constants_1.ENS_GATEWAY_URL + "set", {
10
+ method: "POST",
11
+ headers: {
12
+ "Content-Type": "application/json"
13
+ },
14
+ body: JSON.stringify({
15
+ name: name,
16
+ owner: address.toLowerCase(),
17
+ addresses: { "60": address.toLowerCase() },
18
+ signature: {
19
+ message: message,
20
+ hash: hash
21
+ }
22
+ })
23
+ });
24
24
  return response;
25
- }, [bsmnt_1.default.authentication.authenticated]);
26
- const getEns = (0, react_1.useCallback)(async (address) => {
27
- const response = await fetch(`https://ens-gateway.b3.fun/address/${address}`);
25
+ };
26
+ const getEns = async (address) => {
27
+ const response = await fetch(`${constants_1.ENS_GATEWAY_URL}address/${address}`);
28
28
  if (!response.ok) {
29
29
  throw new Error(`Failed to fetch ENS name: ${response.statusText}`);
30
30
  }
31
31
  const data = await response.json();
32
32
  return data;
33
- }, []);
33
+ };
34
34
  return (0, react_1.useMemo)(() => ({
35
35
  registerEns,
36
36
  getEns
37
- }), [registerEns, getEns]);
37
+ }), []);
38
38
  };
39
39
  exports.useB3EnsName = useB3EnsName;
@@ -13,3 +13,4 @@ export declare const THIRDWEB_SECRET_KEY: string;
13
13
  export declare const THIRDWEB_CLIENT_ID: string;
14
14
  export declare const CLIENT_APP_BUNDLE_ID: string;
15
15
  export declare const B3_AUTH_COOKIE_NAME = "b3-auth";
16
+ export declare const ENS_GATEWAY_URL = "https://ens-gateway.b3.fun/";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.B3_AUTH_COOKIE_NAME = exports.CLIENT_APP_BUNDLE_ID = exports.THIRDWEB_CLIENT_ID = exports.THIRDWEB_SECRET_KEY = exports.tokenIcons = exports.ecosystemWalletId = exports.b3CoinIcon = exports.siteURL = void 0;
3
+ exports.ENS_GATEWAY_URL = exports.B3_AUTH_COOKIE_NAME = exports.CLIENT_APP_BUNDLE_ID = exports.THIRDWEB_CLIENT_ID = exports.THIRDWEB_SECRET_KEY = exports.tokenIcons = exports.ecosystemWalletId = exports.b3CoinIcon = exports.siteURL = void 0;
4
4
  exports.siteURL = "https://basement.fun";
5
5
  exports.b3CoinIcon = "https://cdn.b3.fun/b3-coin-3d.png";
6
6
  exports.ecosystemWalletId = (process.env.EXPO_PUBLIC_THIRDWEB_ECOSYSTEM_ID ||
@@ -19,3 +19,4 @@ exports.THIRDWEB_SECRET_KEY = process.env.THIRDWEB_SECRET_KEY || "";
19
19
  exports.THIRDWEB_CLIENT_ID = process.env.NEXT_PUBLIC_THIRDWEB_CLIENT_ID || process.env.EXPO_PUBLIC_THIRDWEB_CLIENT_ID || "";
20
20
  exports.CLIENT_APP_BUNDLE_ID = process.env.EXPO_PUBLIC_B3_BUNDLE_ID || "";
21
21
  exports.B3_AUTH_COOKIE_NAME = "b3-auth";
22
+ exports.ENS_GATEWAY_URL = "https://ens-gateway.b3.fun/";
@@ -1,8 +1,5 @@
1
1
  export declare const useB3EnsName: () => {
2
- registerEns: (username: string, message: string, hash: string) => Promise<{
3
- success: boolean;
4
- error?: string;
5
- }>;
2
+ registerEns: (name: `${string}.b3.fun`, address: string, hash: string) => Promise<Response>;
6
3
  getEns: (address: string) => Promise<{
7
4
  name: string;
8
5
  }>;
@@ -1,32 +1,35 @@
1
- import bsmntApp from "../../../global-account/bsmnt.js";
2
- import { B3_AUTH_COOKIE_NAME } from "../../../shared/constants/index.js";
3
- import Cookies from "js-cookie";
4
- import { useCallback, useMemo } from "react";
1
+ import { ENS_GATEWAY_URL } from "../../../shared/constants/index.js";
2
+ import { useMemo } from "react";
5
3
  export const useB3EnsName = () => {
6
- const registerEns = useCallback(async (username, message, hash) => {
7
- if (!bsmntApp.authentication.authenticated) {
8
- await bsmntApp.authentication.authenticate({
9
- strategy: "b3-jwt",
10
- accessToken: Cookies.get(B3_AUTH_COOKIE_NAME) || ""
11
- });
12
- }
13
- const response = await bsmntApp.service("profiles").registerUsername({
14
- username,
15
- message,
16
- hash
17
- }, {});
4
+ const registerEns = async (name, address, hash) => {
5
+ const message = `Register ${name}`;
6
+ const response = await fetch(ENS_GATEWAY_URL + "set", {
7
+ method: "POST",
8
+ headers: {
9
+ "Content-Type": "application/json"
10
+ },
11
+ body: JSON.stringify({
12
+ name: name,
13
+ owner: address.toLowerCase(),
14
+ addresses: { "60": address.toLowerCase() },
15
+ signature: {
16
+ message: message,
17
+ hash: hash
18
+ }
19
+ })
20
+ });
18
21
  return response;
19
- }, [bsmntApp.authentication.authenticated]);
20
- const getEns = useCallback(async (address) => {
21
- const response = await fetch(`https://ens-gateway.b3.fun/address/${address}`);
22
+ };
23
+ const getEns = async (address) => {
24
+ const response = await fetch(`${ENS_GATEWAY_URL}address/${address}`);
22
25
  if (!response.ok) {
23
26
  throw new Error(`Failed to fetch ENS name: ${response.statusText}`);
24
27
  }
25
28
  const data = await response.json();
26
29
  return data;
27
- }, []);
30
+ };
28
31
  return useMemo(() => ({
29
32
  registerEns,
30
33
  getEns
31
- }), [registerEns, getEns]);
34
+ }), []);
32
35
  };
@@ -13,3 +13,4 @@ export declare const THIRDWEB_SECRET_KEY: string;
13
13
  export declare const THIRDWEB_CLIENT_ID: string;
14
14
  export declare const CLIENT_APP_BUNDLE_ID: string;
15
15
  export declare const B3_AUTH_COOKIE_NAME = "b3-auth";
16
+ export declare const ENS_GATEWAY_URL = "https://ens-gateway.b3.fun/";
@@ -16,3 +16,4 @@ export const THIRDWEB_SECRET_KEY = process.env.THIRDWEB_SECRET_KEY || "";
16
16
  export const THIRDWEB_CLIENT_ID = process.env.NEXT_PUBLIC_THIRDWEB_CLIENT_ID || process.env.EXPO_PUBLIC_THIRDWEB_CLIENT_ID || "";
17
17
  export const CLIENT_APP_BUNDLE_ID = process.env.EXPO_PUBLIC_B3_BUNDLE_ID || "";
18
18
  export const B3_AUTH_COOKIE_NAME = "b3-auth";
19
+ export const ENS_GATEWAY_URL = "https://ens-gateway.b3.fun/";
@@ -1,8 +1,5 @@
1
1
  export declare const useB3EnsName: () => {
2
- registerEns: (username: string, message: string, hash: string) => Promise<{
3
- success: boolean;
4
- error?: string;
5
- }>;
2
+ registerEns: (name: `${string}.b3.fun`, address: string, hash: string) => Promise<Response>;
6
3
  getEns: (address: string) => Promise<{
7
4
  name: string;
8
5
  }>;
@@ -13,3 +13,4 @@ export declare const THIRDWEB_SECRET_KEY: string;
13
13
  export declare const THIRDWEB_CLIENT_ID: string;
14
14
  export declare const CLIENT_APP_BUNDLE_ID: string;
15
15
  export declare const B3_AUTH_COOKIE_NAME = "b3-auth";
16
+ export declare const ENS_GATEWAY_URL = "https://ens-gateway.b3.fun/";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b3dotfun/sdk",
3
- "version": "0.0.7-alpha.4",
3
+ "version": "0.0.7-alpha.5",
4
4
  "source": "src/index.ts",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "react-native": "./dist/cjs/index.native.js",
@@ -1,35 +1,29 @@
1
- import bsmntApp from "@b3dotfun/sdk/global-account/bsmnt";
2
- import { B3_AUTH_COOKIE_NAME } from "@b3dotfun/sdk/shared/constants";
3
- import Cookies from "js-cookie";
4
-
5
- import { useCallback, useMemo } from "react";
1
+ import { ENS_GATEWAY_URL } from "@b3dotfun/sdk/shared/constants";
2
+ import { useMemo } from "react";
6
3
 
7
4
  export const useB3EnsName = () => {
8
- const registerEns = useCallback(
9
- async (username: string, message: string, hash: string) => {
10
- if (!bsmntApp.authentication.authenticated) {
11
- await bsmntApp.authentication.authenticate({
12
- strategy: "b3-jwt",
13
- accessToken: Cookies.get(B3_AUTH_COOKIE_NAME) || ""
14
- });
15
- }
16
-
17
- const response = await bsmntApp.service("profiles").registerUsername(
18
- {
19
- username,
20
- message,
21
- hash
22
- },
23
- {}
24
- );
25
-
26
- return response;
27
- },
28
- [bsmntApp.authentication.authenticated]
29
- );
30
-
31
- const getEns = useCallback(async (address: string) => {
32
- const response = await fetch(`https://ens-gateway.b3.fun/address/${address}`);
5
+ const registerEns = async (name: `${string}.b3.fun`, address: string, hash: string): Promise<Response> => {
6
+ const message = `Register ${name}`;
7
+ const response = await fetch(ENS_GATEWAY_URL + "set", {
8
+ method: "POST",
9
+ headers: {
10
+ "Content-Type": "application/json"
11
+ },
12
+ body: JSON.stringify({
13
+ name: name,
14
+ owner: address.toLowerCase(),
15
+ addresses: { "60": address.toLowerCase() },
16
+ signature: {
17
+ message: message,
18
+ hash: hash
19
+ }
20
+ })
21
+ });
22
+ return response;
23
+ };
24
+
25
+ const getEns = async (address: string) => {
26
+ const response = await fetch(`${ENS_GATEWAY_URL}address/${address}`);
33
27
 
34
28
  if (!response.ok) {
35
29
  throw new Error(`Failed to fetch ENS name: ${response.statusText}`);
@@ -37,13 +31,13 @@ export const useB3EnsName = () => {
37
31
 
38
32
  const data = await response.json();
39
33
  return data as { name: string };
40
- }, []);
34
+ };
41
35
 
42
36
  return useMemo(
43
37
  () => ({
44
38
  registerEns,
45
39
  getEns
46
40
  }),
47
- [registerEns, getEns]
41
+ []
48
42
  );
49
43
  };
@@ -24,3 +24,5 @@ export const THIRDWEB_CLIENT_ID =
24
24
  export const CLIENT_APP_BUNDLE_ID = process.env.EXPO_PUBLIC_B3_BUNDLE_ID || "";
25
25
 
26
26
  export const B3_AUTH_COOKIE_NAME = "b3-auth";
27
+
28
+ export const ENS_GATEWAY_URL = "https://ens-gateway.b3.fun/";