Skip to content

Commit

Permalink
feat: can not free text flow (#326)
Browse files Browse the repository at this point in the history
* feat: same flow in mumbai and polygon to create lens profile

* fix: index

* feat: profile metadata and image with gasfull versions too

* fix: eslint
  • Loading branch information
albertfolch-redeemeum authored Oct 14, 2022
1 parent 11917f5 commit 63184ab
Show file tree
Hide file tree
Showing 10 changed files with 370 additions and 100 deletions.
66 changes: 33 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"dependencies": {
"@bosonprotocol/chat-sdk": "^1.1.0",
"@bosonprotocol/react-kit": "^0.9.2",
"@bosonprotocol/react-kit": "^0.9.3-alpha.2",
"@davatar/react": "^1.10.4",
"@ethersproject/address": "^5.6.1",
"@ethersproject/units": "^5.6.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { CONFIG } from "../../../../../lib/config";
import { colors } from "../../../../../lib/styles/colors";
import { loadAndSetImage } from "../../../../../lib/utils/base64";
import { Profile } from "../../../../../lib/utils/hooks/lens/graphql/generated";
import useCustomCreateLensProfileMumbai from "../../../../../lib/utils/hooks/lens/profile/useCustomCreateLensProfileMumbai";
import useCustomCreateLensProfilePolygon from "../../../../../lib/utils/hooks/lens/profile/useCustomCreateLensProfilePolygon";
import useCreateSeller from "../../../../../lib/utils/hooks/offer/useCreateSeller";
import useUpdateSeller from "../../../../../lib/utils/hooks/offer/useUpdateSeller";
Expand Down Expand Up @@ -119,18 +118,14 @@ export default function CreateBosonLensAccountSummary({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const useCreateFunc =
CONFIG.chainId === 137
? useCustomCreateLensProfilePolygon
: useCustomCreateLensProfileMumbai;
const {
create: createLensProfile,
isLoading: isCreatingLensProfile,
isError: isCreateLensError,

isHandleTakenError,
isSetLensProfileMetadataError
} = useCreateFunc({
} = useCustomCreateLensProfilePolygon({
values: values,
onCreatedProfile: (profile: Profile) => {
setLensProfileToSubmit(profile);
Expand Down
3 changes: 3 additions & 0 deletions src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,11 @@ export const CONFIG = {
apiLink: config.lens.apiLink,
LENS_HUB_CONTRACT: config.lens.LENS_HUB_CONTRACT,
LENS_PERIPHERY_CONTRACT: config.lens.LENS_PERIPHERY_CONTRACT,
LENS_PROFILES_CONTRACT_ADDRESS: config.lens.LENS_PROFILES_CONTRACT_ADDRESS,
LENS_HUB_ABI: lensHubContractAbi,
LENS_PERIPHERY_ABI: lensPeripheryDataProvider,
LENS_PROFILES_CONTRACT_PARTIAL_ABI:
config.lens.LENS_PROFILES_CONTRACT_PARTIAL_ABI,
LENS_FOLLOW_NFT_ABI: lensFollowNftContractAbi
}
};
Expand Down
33 changes: 32 additions & 1 deletion src/lib/utils/hooks/lens/fetchLens.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import request, { RequestDocument } from "graphql-request";
import { GraphQLError } from "graphql";
import request, { rawRequest, RequestDocument } from "graphql-request";
import { Headers } from "graphql-request/dist/types.dom";

import { CONFIG } from "../../../config";

Expand All @@ -24,3 +26,32 @@ export async function fetchLens<T, V = Record<string, unknown>>(
throw err;
}
}

export async function fetchRawLens<T, V = Record<string, unknown>>(
query: string,
variables?: V,
headers?: Record<string, unknown>
): Promise<{
data: T;
extensions?: unknown;
headers: Headers;
errors?: GraphQLError[];
status: number;
}> {
try {
const response = await rawRequest<T, V>(
CONFIG.lens.apiLink || "",
query,
variables,
{
...headers,
Accept: "application/json",
"Content-Type": "application/json"
}
);
return response;
} catch (err) {
console.error(err);
throw err;
}
}
2 changes: 2 additions & 0 deletions src/lib/utils/hooks/lens/lens-hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import { CONFIG } from "../../../config";
// contract address on polygon.
export const getLensHub = (signer: ethers.Signer) =>
new ethers.Contract(
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
CONFIG.lens.LENS_HUB_CONTRACT!,
CONFIG.lens.LENS_HUB_ABI,
signer
);
export const getLensPeriphery = (signer: ethers.Signer) =>
new ethers.Contract(
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
CONFIG.lens.LENS_PERIPHERY_CONTRACT!,
CONFIG.lens.LENS_PERIPHERY_ABI,
signer
Expand Down
Loading

0 comments on commit 63184ab

Please sign in to comment.