Skip to content

Commit

Permalink
Merge pull request #2 from SweetmanTech/sweets/hotfix/subparticles
Browse files Browse the repository at this point in the history
I update version and changelog.
  • Loading branch information
sweetmantech authored Dec 20, 2023
2 parents 5a3d287 + c14f84c commit b4e42f0
Show file tree
Hide file tree
Showing 6 changed files with 408 additions and 1,243 deletions.
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
# onchain-magic

## 0.1.26

### Patch Changes

- I update README to include instructions for installation with npm."

## 0.1.25

### Patch Changes

- merge conflicts.

## 0.1.24

### Patch Changes

- I try another attempt to return tx receipt.

## 0.1.23

### Patch Changes

- I return the tx receipt from create 1155 contract hook.

## 0.1.22

### Patch Changes

- I init zora lib to handle cases when zora factory is not at deterministic crosschain address.

## 0.1.21

### Patch Changes

- I init dependencies with nft.storage to ensure applications will automatically download required packages. Originally, this package was a peerDependency. peerDependencies are not automatically installed in npm versions 3 and later.

## 0.1.20

### Patch Changes
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

## Getting started

```
```bash
npm install onchain-magic
# or
yarn add onchain-magic
```

```
import { useCreate1155Contract } from 'onchain-magic';
const MyComponent = () => {
const { createContract } = useCreate1155Contract
const { createContract } = useCreate1155Contract()
const handleClick = () => {
createContract()
Expand Down
22 changes: 12 additions & 10 deletions hooks/useCreate1155Contract.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import abi from "../lib/abi/Zora1155CreatorProxy.json";
import { getZoraBlob, store } from "../lib/ipfs";
import { Contract } from "ethers";
import { useAccount } from "wagmi";
import { useAccount, useNetwork } from "wagmi";
import { useEthersSigner } from "./useEthersSigner";
import type { Create1155ContractArgs } from "../lib/types/Create1155ContractArgs";
import getFactoryAddress from "../lib/zora/getFactoryAddress";
import { useMemo } from "react";

const useCreate1155Contract = () => {
const signer = useEthersSigner();
const { address } = useAccount() as any;
const factoryAddress = "0x777777C338d93e2C7adf08D102d45CA7CC4Ed021";
const { chain } = useNetwork();
const factoryAddress = getFactoryAddress(chain?.id as number);
const defaultContractName = "ONCHAINMAGIC🪄";

const signTransaction = async (args: any[]) => {
const factory = new Contract(factoryAddress, abi, signer);
const tx = await factory.createContract(...args);
const response = await tx.wait();
return response;
};
const factory = useMemo(
() => new Contract(factoryAddress, abi, signer),
[signer, factoryAddress]
);

const createContract = async (contractArgs?: Create1155ContractArgs) => {
if (!signer)
Expand Down Expand Up @@ -46,7 +46,9 @@ const useCreate1155Contract = () => {
contractArgs?.defaultAdmin || address,
setupActions,
];
await signTransaction(args);
const tx = await factory.createContract(...args);
const receipt = await tx.wait();
return receipt;
} catch (error) {
return { error };
}
Expand Down
12 changes: 12 additions & 0 deletions lib/zora/getFactoryAddress.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { sepolia } from "wagmi";

const getFactoryAddress = (chainId: number) => {
switch (chainId) {
case sepolia.id:
return "0x13dAA8E9e3f68deDE7b1386ACdc12eA98F2FB688";
default:
return "0x777777C338d93e2C7adf08D102d45CA7CC4Ed021";
}
};

export default getFactoryAddress;
Loading

0 comments on commit b4e42f0

Please sign in to comment.