From 7c351ca3d384e5290430a58df1851284b3b68e55 Mon Sep 17 00:00:00 2001 From: Nadeem Date: Tue, 2 Apr 2024 22:34:12 +0530 Subject: [PATCH 1/2] update README --- packages/heartbit-core/README.md | 4 ++-- packages/heartbit-react/README.md | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/heartbit-core/README.md b/packages/heartbit-core/README.md index ff08a0d..939388d 100644 --- a/packages/heartbit-core/README.md +++ b/packages/heartbit-core/README.md @@ -44,7 +44,7 @@ async function main() { const signature = "0x...signed message"; const startTime = 1706898250; const endTime = 1706898251; - const hash = "ipfs://somecid"; // unique identifier for token. eg ipfs://somecid in that case + const hash = "ipfs://somecid"; // unique identifier for token. eg ipfs://somecid // Mint HeartBit @@ -79,7 +79,7 @@ This minimal example demonstrates how to use `HeartBitCore` for minting heartbit async function main() { const startTime = 1706898250; const endTime = 1706898251; - const hash = "ipfs://cid"; // unique identifier for token. eg ipfs://somecid that case + const hash = "ipfs://cid"; // unique identifier for token. eg ipfs://somecid const apiKey = "hello"; const address = "0x...ethaddress"; diff --git a/packages/heartbit-react/README.md b/packages/heartbit-react/README.md index a9a7c2f..8921f35 100644 --- a/packages/heartbit-react/README.md +++ b/packages/heartbit-react/README.md @@ -28,7 +28,7 @@ import { HeartBit } from "@fileverse/heartbit-react"; ### Integrate HeartBit Functionality -First of all, you want to set up your wallet providers. For this example, we will be using the `BrowserProvider` from `ethers` as our provider. We will create a React component that will render `HeartBit`, and we are going to configure the network by passing the `coreOption` as props to it. It requires the `getSignatureArgsHook` as props as well, which it calls internally to get the `message`, `signature`, and optionally an `onMintCallback`, a function that will be called after mint is completed. We would also define `hash` which is a keccak256 hash that will be used for generating the tokenId on the smart contract, and we will use `SIWE` for generating the `message` and `signature`. The code below should do the trick: +First of all, you want to set up your wallet providers. For this example, we will be using the `BrowserProvider` from `ethers` as our provider. We will create a React component that will render `HeartBit`, and we are going to configure the network by passing the `coreOption` as props to it. It requires the `getSignatureArgsHook` as props as well, which it calls internally to get the `message`, `signature`, and optionally an `onMintCallback`, a function that will be called after mint is completed. We would also define `hash` that will be used for generating the tokenId on the smart contract generally use `ipfs hash` here for `eg: ipfs://cid`, and we will use `SIWE` for generating the `message` and `signature`. The code below should do the trick: ```javascript const MyApp = () => { @@ -61,7 +61,7 @@ const MyApp = () => { }; }; - const hash = keccak256(toUtf8Bytes("window.location.href")); // This is an identifier for the token, if this hash changes you mint a new token in that case + const hash = "ipfs//cid"; // This is an identifier for the token, if this hash changes you mint a new token in that case return { const [startTime, setStartTime] = useState(null) // should be in seconds const address = '0x...someaddress' - const hash = '0x....somehash' // This is an identifier for the token, if this hash changes you mint a new token in that case + const hash = 'ipfs://cid' // This is an identifier for the token, if this hash changes you mint a new token eg: ipfs://cid useEffect(() => { const fetchBalances = async () => { const totalMintsByHash = await getTotalHeartBitByHash({ hash }); // Total Supply for a hash @@ -119,7 +119,7 @@ const CustomHearBit = () => { await mintHeartBit({ startTime, endTime, - hash, // This is an identifier for the token, if this hash changes you mint a new token in that case + hash, // This is an identifier for the token, if this hash changes you mint a new token. eg: ipfs://cid message, // raw message that was signed signature, // signed message }) @@ -128,10 +128,11 @@ const CustomHearBit = () => { return } ``` -[Here](https://codesandbox.io/p/devbox/custom-heartbit-example-p6f7gr) is a working example using the `HeartBitProvider` and `useHeartBit`. +[Here](https://codesandbox.io/p/devbox/custom-heartbit-example-p6f7gr) is a working example using the `HeartBitProvider` and `useHeartBit`. ### Interface + ```javascript interface SignatureArgs { message: string; @@ -142,13 +143,12 @@ interface HeartBitProps extends Omit { coreOptions: HeartBitCoreOptions; getSignatureArgsHook: () => Promise; // this is a required hook, this allows to call sign message operation on the user wallet, must return SignatureArgs - hash: string; // This is an identifier for the token, if this hash changes you mint a new token in that case + hash: string; // This is an identifier for the token, if this hash changes you mint a new token. eg: ipfs://cid address?: string; // user wallet address showTotalMintsByHash?: boolean; // Default to false, if true will show total mints for a hash to the right of component showTotalMintsByUser?: boolean; // Defaults to false, if true will show total mints by a user on a hash to right of the component } - type SupportedChain = "0xaa36a7" | "0x2105" | "0x64"; interface HeartBitCoreOptions { chain: SupportedChain; @@ -159,10 +159,10 @@ interface HeartBitProviderProps { coreOptions: HeartBitCoreOptions; } interface TotalHeartBitCountArgs { - hash: string; // This is an identifier for the token, if this hash changes you mint a new token in that case + hash: string; // This is an identifier for the token, if this hash changes you mint a new token. eg: ipfs://cid } interface HeartBitCountByUserArgs { - hash: string; // This is an identifier for the token, if this hash changes you mint a new token in that case + hash: string; // This is an identifier for the token, if this hash changes you mint a new token. eg: ipfs://cid address: string; // ethereum wallet address } interface MintHeartBitArgs { @@ -170,7 +170,7 @@ interface MintHeartBitArgs { signature: string; startTime: number; // in seconds endTime: number; // in seconds - hash: string; // This is an identifier for the token, if this hash changes you mint a new token in that case + hash: string; // This is an identifier for the token, if this hash changes you mint a new token. eg: ipfs://cid } interface IHeartBitContext { getTotalHeartMintsByUser: (opts: HeartBitCountByUserArgs) => Promise; From fa270e270714bd6d99699ad634b402a035faaf17 Mon Sep 17 00:00:00 2001 From: Nadeem Date: Tue, 2 Apr 2024 22:37:35 +0530 Subject: [PATCH 2/2] run changeset --- .changeset/loud-zoos-decide.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/loud-zoos-decide.md diff --git a/.changeset/loud-zoos-decide.md b/.changeset/loud-zoos-decide.md new file mode 100644 index 0000000..411af7a --- /dev/null +++ b/.changeset/loud-zoos-decide.md @@ -0,0 +1,6 @@ +--- +"@fileverse/heartbit-react": minor +"@fileverse/heartbit-core": minor +--- + +Update README hash def