Skip to content

Commit

Permalink
feat: Package bundled via ESM method , and Tested
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhruv-2003 committed Mar 4, 2023
1 parent cd66fb4 commit c4acde9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
16 changes: 4 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,16 @@
"name": "token-gating-sdk",
"version": "1.0.6",
"description": "A token gating SDK to restrict access to Next and React Application for NFT and Token Holders",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"main": "dist/esm/index.js",
"types": "./dist/index.d.ts",
"import": "dist/esm/index.js",
"type": "module",
"files": [
"dist"
],
"exports": {
"node": {
"types": "./dist/index.d.ts",
"require": "./dist/cjs/index.js",
"import": "./dist/cjs/index.js"
},
"package.json": "./package.json",
"default": "./dist/esm/index.js"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"rollup": "rollup -c --bundleConfigAsCjs",
"rollup": "rm -rf dist/ && rollup -c --bundleConfigAsCjs",
"build": "rm -rf dist/ && npm run build:esm && npm run build:cjs",
"build:esm": "tsc",
"build:cjs": "tsc --moudle CommonJS --outDir dist/cjs"
Expand Down
6 changes: 0 additions & 6 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ export default [
output: [
{
file: packageJson.main,
format: "cjs",
sourcemap: true,
// dir: "dist/cjs",
},
{
file: packageJson.module,
format: "esm",
sourcemap: true,
// dir: "dist/esm",
Expand Down
26 changes: 20 additions & 6 deletions src/components/nextWrapper/nextWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { publicProvider } from "wagmi/providers/public";
import { useState, useEffect } from "react";
import { useRouter } from "next/router";
import { Network, Alchemy } from "alchemy-sdk";
import { configDataType, configType, methods } from "../config/index";
import { configDataType, configType, methods, networks } from "../config/index";

const API_KEY: any = process.env.ALCHEMY_ID;

Expand Down Expand Up @@ -56,13 +56,27 @@ export const TokenGatingWrapper: React.FunctionComponent<
const [showConnectModel, setShowConnectModel] = useState(false);
const { chain, chains } = useNetwork();

const getChainName = (chainType: networks) => {
if (chainType == networks.Ethereum) {
return "Ethereum";
} else if (chainType == networks.Polygon) {
return "Polygon";
} else if (chainType == networks.Optimism) {
return "Optimism";
} else if (chainType == networks["Arbitrum One"]) {
return "Arbitrum One";
} else {
return "Ethereum";
}
};

const getNetwork = (chainName: string) => {
// console.log(chainName);
console.log(chainName);
if (!chainName) {
return;
}
const currentChainName = chain?.name;
// console.log(currentChainName);
console.log(currentChainName);
// console.log(chains);
if (currentChainName != chainName) {
const chainId = chains?.find((v) => {
Expand Down Expand Up @@ -235,10 +249,10 @@ export const TokenGatingWrapper: React.FunctionComponent<
return;
}

const finalNetwork = getNetwork(configData.network.toString());
if (!finalNetwork) return;

// console.log(configData);
const chainName: string = getChainName(configData.network);
const finalNetwork = getNetwork(chainName);
if (!finalNetwork) return;

// // checking the conditions of the method Applied and
if (configData.methodName == methods.NFTWithTokenID) {
Expand Down

0 comments on commit c4acde9

Please sign in to comment.