@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.
- package/dist/cjs/global-account/react/hooks/useB3EnsName.d.ts +1 -4
- package/dist/cjs/global-account/react/hooks/useB3EnsName.js +22 -22
- package/dist/cjs/shared/constants/index.d.ts +1 -0
- package/dist/cjs/shared/constants/index.js +2 -1
- package/dist/esm/global-account/react/hooks/useB3EnsName.d.ts +1 -4
- package/dist/esm/global-account/react/hooks/useB3EnsName.js +24 -21
- package/dist/esm/shared/constants/index.d.ts +1 -0
- package/dist/esm/shared/constants/index.js +1 -0
- package/dist/types/global-account/react/hooks/useB3EnsName.d.ts +1 -4
- package/dist/types/shared/constants/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/global-account/react/hooks/useB3EnsName.ts +26 -32
- package/src/shared/constants/index.ts +2 -0
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
export declare const useB3EnsName: () => {
|
|
2
|
-
registerEns: (
|
|
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 =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
}
|
|
26
|
-
const getEns =
|
|
27
|
-
const response = await fetch(
|
|
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
|
-
}), [
|
|
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: (
|
|
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
|
|
2
|
-
import {
|
|
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 =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
}
|
|
20
|
-
const getEns =
|
|
21
|
-
const response = await fetch(
|
|
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
|
-
}), [
|
|
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: (
|
|
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,35 +1,29 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
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 =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
{
|
|
19
|
-
|
|
20
|
-
message,
|
|
21
|
-
hash
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
[
|
|
41
|
+
[]
|
|
48
42
|
);
|
|
49
43
|
};
|