Skip to content

Commit a9310c0

Browse files
committed
Refactor equippable
1 parent 6474e46 commit a9310c0

File tree

4 files changed

+166
-222
lines changed

4 files changed

+166
-222
lines changed

lib/transactions/deploy-contract.ts

+5-15
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
import { NewTransaction } from '@rainbow-me/rainbowkit/dist/transactions/transactionStore';
2-
import { BigNumber, Contract, ethers, Signer } from 'ethers';
2+
import { BigNumber, Contract, ContractTransaction, ethers, Signer } from 'ethers';
33
import { RMRKMultiResourceFactoryContractAddress } from '../../constants';
44

55
interface IProps {
66
signer?: ethers.Signer | null;
77
registryContract: Contract;
88
tokenContract: Contract;
9-
factoryContract: Contract;
9+
callFactory: () => Promise<ContractTransaction>;
1010
addRecentTransaction: (transaction: NewTransaction) => void;
11-
data: { [key: string]: string | number };
1211
}
1312

1413
export async function deployContract({
1514
signer,
1615
registryContract,
1716
tokenContract,
18-
factoryContract,
17+
callFactory,
1918
addRecentTransaction,
20-
data,
2119
}: IProps) {
22-
const { nameInput, symbolInput, maxSupplyInput, priceInput, collectionMetadataInput } = data;
2320
if (signer instanceof Signer) {
2421
const caller = await signer.getAddress();
2522
const deposit: BigNumber = await registryContract.getCollectionListingFee();
@@ -34,15 +31,8 @@ export async function deployContract({
3431
);
3532
await approveTransactionResponse.wait();
3633
}
37-
const tx = await factoryContract
38-
.connect(signer)
39-
.deployRMRKMultiResource(
40-
nameInput,
41-
symbolInput,
42-
maxSupplyInput,
43-
priceInput,
44-
collectionMetadataInput,
45-
);
34+
35+
const tx = await callFactory();
4636

4737
addRecentTransaction({
4838
hash: tx.hash,

lib/transactions/get-owned-nfts.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
import { Contract, ethers, Signer } from 'ethers';
22
import abis from '../../abis/abis';
3+
import { AbiItem } from '../types';
34

45
interface IProps {
56
signer?: ethers.Signer | null;
67
contractAddress: string;
8+
abi: ethers.ContractInterface;
79
}
810

9-
export async function getOwnedNfts({ signer, contractAddress }: IProps) {
11+
export async function getOwnedNfts({ signer, contractAddress, abi }: IProps) {
1012
const nfts = [];
1113

1214
if (signer instanceof Signer && ethers.utils.isAddress(contractAddress)) {
13-
const multiResourceContract = new Contract(contractAddress, abis.multiResourceAbi, signer);
15+
const multiResourceContract = new Contract(contractAddress, abi, signer);
1416

1517
const nftSupply = await multiResourceContract.totalSupply();
1618
for (let i = 1; i <= nftSupply.toNumber(); i++) {

0 commit comments

Comments
 (0)