Skip to content
This repository has been archived by the owner on Feb 5, 2025. It is now read-only.

Release to production #1254

Merged
merged 77 commits into from
Jan 8, 2024
Merged
Changes from 1 commit
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
7b32b0f
Fix/package build (#1124)
bitbeckers Oct 22, 2023
6d75f0a
Feat/deploy to celo (#1135)
bitbeckers Oct 23, 2023
c60e8f7
fix(gha): use pnpm cache in graph gha (#1138)
bitbeckers Oct 23, 2023
a99e85e
Merge branch 'main' into develop
bitbeckers Oct 23, 2023
fe9b359
chore: add wrapper components for split and merge functionality
Jipperism Oct 31, 2023
b033d77
Fix/handle batch transfers graph (#1149)
bitbeckers Nov 3, 2023
859366a
SDK remove default chainID dependency (#1146)
bitbeckers Nov 6, 2023
462abfd
Fix/gha graph (#1165)
bitbeckers Nov 6, 2023
6d8a7d4
feat(event): add event to merge
bitbeckers Nov 6, 2023
5cf30b3
chore(deploy): deployed to goerli and sepolia
bitbeckers Nov 7, 2023
a8beee5
Merge branch 'develop' into feat/splitmerged-event-to-splitmerge-func…
bitbeckers Nov 7, 2023
ee250ee
Feat/allowlist proof util (#1168)
bitbeckers Nov 7, 2023
44baf47
Add hypercerts to marketplace functionality (#1170)
bitbeckers Nov 8, 2023
a827b5e
feat(restriction): add transfer restriction to fe (#1173)
bitbeckers Nov 8, 2023
34436b9
feat(metadata): add application name (#1174)
bitbeckers Nov 9, 2023
fc0161d
feat(deployments): typed deployment contracts
bitbeckers Nov 9, 2023
55c1f57
fix(props): props from plas to form (#1176)
bitbeckers Nov 9, 2023
c93f391
format external url in case it is a direct ipfs link (#1182)
Jipperism Nov 13, 2023
dbdb083
fix(fix formatting of ipfs urls on hypercert page) (#1183)
Jipperism Nov 15, 2023
a6c3b8f
Feat/split and merge (#1185)
Jipperism Nov 21, 2023
84a623c
Feat/hardhat deploy script (#1177)
bitbeckers Nov 22, 2023
9657f17
feat(merkle): account allowlist strategy (#1186)
bitbeckers Nov 22, 2023
5623583
Added strategy and tests for hypercert functionality (#1188)
bitbeckers Nov 24, 2023
582af93
Feat/partial fraction sale (#1190)
bitbeckers Nov 24, 2023
3bc340a
Feat/sdk common js (#1191)
bitbeckers Nov 26, 2023
ccdf65b
feat(abis): updated SDK abis and restored tests (#1193)
bitbeckers Nov 29, 2023
c7dbb36
Merge branch 'develop' into feat/splitmerged-event-to-splitmerge-func…
bitbeckers Nov 29, 2023
1acbaa0
fix(test): add currency admin to test (#1197)
bitbeckers Nov 30, 2023
de5e0d0
fix build error - set output:export in next config (#1199)
Jipperism Dec 1, 2023
31ac54c
add placeholder for transfer fraction button (#1201)
Jipperism Dec 1, 2023
5c94088
change next build back to next export (#1202)
Jipperism Dec 1, 2023
6ef5b40
Feature/transfer fraction button (#1203)
Jipperism Dec 1, 2023
6488e79
add override chain id functionality for plasmic editing (#1204)
Jipperism Dec 1, 2023
a602567
Bugfix/add override chain id for plasmit editing (#1205)
Jipperism Dec 1, 2023
2406b96
remove transfer fraction button from split fraction button (#1206)
Jipperism Dec 1, 2023
6a93ec8
Bugfix/only show transfer button for fraction owned (#1207)
Jipperism Dec 1, 2023
f36b963
Feat/more robust split transfer logic with hc strategy (#1208)
bitbeckers Dec 2, 2023
4b86911
Feat/docs tests cleanup (#1210)
bitbeckers Dec 4, 2023
b253cd6
Feat/docs tests cleanup (#1211)
bitbeckers Dec 4, 2023
2637ed0
Feat/docs tests cleanup (#1212)
bitbeckers Dec 4, 2023
1cc481f
Feat/add batch transfer method to client methods (#1215)
bitbeckers Dec 6, 2023
0c249aa
Chore/lets merge together (#1220)
Jipperism Dec 7, 2023
435db09
feat(urql): refactored to urql and own codegen (#1223)
bitbeckers Dec 8, 2023
73b06f3
Feat/docs updates docusaurs v3 search release (#1226)
bitbeckers Dec 8, 2023
f1de3d6
Feat/sdk npm docs release 1 (#1228)
bitbeckers Dec 8, 2023
210c167
Feat/sdk npm docs release 1 (#1231)
bitbeckers Dec 8, 2023
c96bb1f
Faet/docs search function in documentation (#1236)
bitbeckers Dec 14, 2023
ad5d0c3
(feat): add initial version of delete on order fulfilled script
Jipperism Dec 14, 2023
0ea6ded
Merge branch 'develop' into feat/splitmerged-event-to-splitmerge-func…
bitbeckers Dec 14, 2023
7535f4e
Merge pull request #1167 from hypercerts-org/feat/splitmerged-event-t…
bitbeckers Dec 14, 2023
6dc0592
chore(bump): web3 connectors fe
bitbeckers Dec 14, 2023
dc04f74
Merge pull request #1239 from hypercerts-org/chore/dev_update_wagmi
bitbeckers Dec 14, 2023
0182b2e
Merge branch 'develop' into chore/main-to-develop
Jipperism Dec 15, 2023
1a3b8d8
Merge pull request #1243 from hypercerts-org/chore/main-to-develop
Jipperism Dec 15, 2023
1cb40c6
Merge branch 'develop' into feature/marketplace-defender-autotasks
Jipperism Dec 18, 2023
f7f0805
(feature): Delete order on execute taker bid autotask
Jipperism Dec 20, 2023
0619383
(feat): fix setup and rollouts, update scripts
Jipperism Dec 20, 2023
13a4852
(feat): remove redundancy from create-sentinel.ts config
Jipperism Dec 20, 2023
0f3e7d8
Merge pull request #1250 from hypercerts-org/feature/marketplace-defe…
Jipperism Dec 22, 2023
38ed2bf
(chore): delete goerli from SDK
Jipperism Dec 25, 2023
4386d02
(chore): delete goerli from defender config
Jipperism Dec 25, 2023
f4409b3
(chore): delete goerli from graph
Jipperism Dec 25, 2023
1635b01
(chore): delete goerli from frontend
Jipperism Dec 25, 2023
f172a19
(chore): update tests for goerli deprecation
Jipperism Dec 25, 2023
6d6e4f2
feat(apis): refactor to use hypercerts APIs
bitbeckers Jan 8, 2024
0f59f97
fix(api): migrate to railway
bitbeckers Jan 8, 2024
808e655
fix(build): update viem and fe client config
bitbeckers Jan 8, 2024
fd70875
chore(bump): sdk 1.1.0 release and bump fe
bitbeckers Jan 8, 2024
aa6d33a
Merge branch 'develop' into chore/deprecate-goerli
Jipperism Jan 8, 2024
0df2168
(chore): update changelog
Jipperism Jan 8, 2024
1cc289e
Merge pull request #1252 from hypercerts-org/chore/deprecate-goerli
Jipperism Jan 8, 2024
8a19334
Merge branch 'develop' into feat/sdk-use-w3up-in-sdk
Jipperism Jan 8, 2024
d87fa08
fix(ci): linting
bitbeckers Jan 8, 2024
cf8baf2
Merge branch 'feat/sdk-use-w3up-in-sdk' of github.com:hypercerts-org/…
bitbeckers Jan 8, 2024
a9d54f9
Merge pull request #1253 from hypercerts-org/feat/sdk-use-w3up-in-sdk
bitbeckers Jan 8, 2024
3a64188
chore(bump): fe sdk dep
bitbeckers Jan 8, 2024
547443b
Merge pull request #1255 from hypercerts-org/chore/bump_sdk_1_2_0
bitbeckers Jan 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Feat/split and merge (#1185)
* Add split and merge functionality to plasmic and add component logic.
Jipperism authored Nov 21, 2023
commit a6c3b8f40c4189e450015896d965e755ccf60250
4 changes: 2 additions & 2 deletions contracts/test/mock/MockERC1155.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.7;

import { ERC1155 } from "solmate/src/tokens/ERC1155.sol";
import {ERC1155} from "solmate/src/tokens/ERC1155.sol";

// LooksRare unopinionated libraries
import { IERC2981 } from "@looksrare/contracts-libs/contracts/interfaces/generic/IERC2981.sol";
import {IERC2981} from "@looksrare/contracts-libs/contracts/interfaces/generic/IERC2981.sol";

contract MockERC1155 is ERC1155 {
function batchMint(address to, uint256[] memory tokenIds, uint256[] memory amounts) public {
2 changes: 1 addition & 1 deletion contracts/test/mock/MockERC1155SupportsNoInterface.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.7;

import { MockERC1155 } from "./MockERC1155.sol";
import {MockERC1155} from "./MockERC1155.sol";

contract MockERC1155SupportsNoInterface is MockERC1155 {
function supportsInterface(bytes4) public view virtual override returns (bool) {
2 changes: 1 addition & 1 deletion contracts/test/mock/MockERC1155WithoutAnyBalanceOf.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.7;

import { ERC1155 } from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import {ERC1155} from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";

/**
* @dev This contract has to inherit from OZ instead of Solmate because
2 changes: 1 addition & 1 deletion contracts/test/mock/MockERC1155WithoutBalanceOfBatch.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.7;

import { MockERC1155 } from "./MockERC1155.sol";
import {MockERC1155} from "./MockERC1155.sol";

contract MockERC1155WithoutBalanceOfBatch is MockERC1155 {
function balanceOfBatch(address[] calldata, uint256[] calldata) public pure override returns (uint256[] memory) {
2 changes: 1 addition & 1 deletion contracts/test/mock/MockERC1155WithoutIsApprovedForAll.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.7;

import { ERC1155 } from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import {ERC1155} from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";

/**
* @dev This contract has to inherit from OZ instead of Solmate because
2 changes: 1 addition & 1 deletion contracts/test/mock/MockERC20.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.7;

import { ERC20 } from "solmate/src/tokens/ERC20.sol";
import {ERC20} from "solmate/src/tokens/ERC20.sol";

contract MockERC20 is ERC20("MockERC20", "MockERC20", 18) {
function mint(address to, uint256 amount) public {
4 changes: 2 additions & 2 deletions contracts/test/mock/MockERC721.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.7;

import { ERC721 } from "solmate/src/tokens/ERC721.sol";
import { IERC165 } from "@looksrare/contracts-libs/contracts/interfaces/generic/IERC165.sol";
import {ERC721} from "solmate/src/tokens/ERC721.sol";
import {IERC165} from "@looksrare/contracts-libs/contracts/interfaces/generic/IERC165.sol";

contract MockERC721 is ERC721("MockERC721", "MockERC721") {
function mint(address to, uint256 tokenId) public {
2 changes: 1 addition & 1 deletion contracts/test/mock/MockERC721SupportsNoInterface.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.7;

import { MockERC721 } from "./MockERC721.sol";
import {MockERC721} from "./MockERC721.sol";

contract MockERC721SupportsNoInterface is MockERC721 {
function supportsInterface(bytes4) public view virtual override returns (bool) {
24 changes: 12 additions & 12 deletions contracts/test/mock/MockERC721WithRoyalties.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import { IERC165, IERC2981 } from "@looksrare/contracts-libs/contracts/interfaces/generic/IERC2981.sol";
import { MockERC721 } from "./MockERC721.sol";
import {IERC165, IERC2981} from "@looksrare/contracts-libs/contracts/interfaces/generic/IERC2981.sol";
import {MockERC721} from "./MockERC721.sol";

// Constants
import { ONE_HUNDRED_PERCENT_IN_BP } from "@hypercerts/marketplace/constants/NumericConstants.sol";
import {ONE_HUNDRED_PERCENT_IN_BP} from "@hypercerts/marketplace/constants/NumericConstants.sol";

/**
* @dev This contract allows adding a royalty basis points higher than 10,000, which
@@ -25,19 +25,19 @@ contract MockERC721WithRoyalties is MockERC721, IERC2981 {
DEFAULT_ROYALTY_FEE = _royaltyFee;
}

function addCustomRoyaltyInformationForTokenId(
uint256 tokenId,
address royaltyRecipient,
uint256 royaltyFee
) external {
function addCustomRoyaltyInformationForTokenId(uint256 tokenId, address royaltyRecipient, uint256 royaltyFee)
external
{
_royaltyRecipientForTokenId[tokenId] = royaltyRecipient;
_royaltyFeeForTokenId[tokenId] = royaltyFee;
}

function royaltyInfo(
uint256 tokenId,
uint256 salePrice
) external view override returns (address royaltyRecipient, uint256 royaltyAmount) {
function royaltyInfo(uint256 tokenId, uint256 salePrice)
external
view
override
returns (address royaltyRecipient, uint256 royaltyAmount)
{
royaltyRecipient = _royaltyRecipientForTokenId[tokenId] == address(0)
? DEFAULT_ROYALTY_RECIPIENT
: _royaltyRecipientForTokenId[tokenId];
22 changes: 10 additions & 12 deletions contracts/test/mock/MockRoyaltyFeeRegistry.sol
Original file line number Diff line number Diff line change
@@ -2,13 +2,13 @@
pragma solidity 0.8.17;

// LooksRare unopinionated libraries
import { OwnableTwoSteps } from "@looksrare/contracts-libs/contracts/OwnableTwoSteps.sol";
import {OwnableTwoSteps} from "@looksrare/contracts-libs/contracts/OwnableTwoSteps.sol";

// Royalty Fee Registry interface
import { IRoyaltyFeeRegistry } from "@hypercerts/marketplace/interfaces/IRoyaltyFeeRegistry.sol";
import {IRoyaltyFeeRegistry} from "@hypercerts/marketplace/interfaces/IRoyaltyFeeRegistry.sol";

// Constants
import { ONE_HUNDRED_PERCENT_IN_BP } from "@hypercerts/marketplace/constants/NumericConstants.sol";
import {ONE_HUNDRED_PERCENT_IN_BP} from "@hypercerts/marketplace/constants/NumericConstants.sol";

/**
* @title MockRoyaltyFeeRegistry
@@ -36,7 +36,7 @@ contract MockRoyaltyFeeRegistry is IRoyaltyFeeRegistry, OwnableTwoSteps {
* @param _royaltyFeeLimit new royalty fee limit (500 = 5%, 1,000 = 10%)
*/
constructor(address _owner, uint256 _royaltyFeeLimit) OwnableTwoSteps(_owner) {
require(_royaltyFeeLimit <= 9_500, "Owner: Royalty fee limit too high");
require(_royaltyFeeLimit <= 9500, "Owner: Royalty fee limit too high");
royaltyFeeLimit = _royaltyFeeLimit;
}

@@ -45,7 +45,7 @@ contract MockRoyaltyFeeRegistry is IRoyaltyFeeRegistry, OwnableTwoSteps {
* @param _royaltyFeeLimit new royalty fee limit (500 = 5%, 1,000 = 10%)
*/
function updateRoyaltyFeeLimit(uint256 _royaltyFeeLimit) external onlyOwner {
require(_royaltyFeeLimit <= 9_500, "Owner: Royalty fee limit too high");
require(_royaltyFeeLimit <= 9500, "Owner: Royalty fee limit too high");
royaltyFeeLimit = _royaltyFeeLimit;

emit NewRoyaltyFeeLimit(_royaltyFeeLimit);
@@ -58,14 +58,12 @@ contract MockRoyaltyFeeRegistry is IRoyaltyFeeRegistry, OwnableTwoSteps {
* @param receiver receiver for the royalty fee
* @param fee fee (500 = 5%, 1,000 = 10%)
*/
function updateRoyaltyInfoForCollection(
address collection,
address setter,
address receiver,
uint256 fee
) external onlyOwner {
function updateRoyaltyInfoForCollection(address collection, address setter, address receiver, uint256 fee)
external
onlyOwner
{
require(fee <= royaltyFeeLimit, "Registry: Royalty fee too high");
_royaltyFeeInfoCollection[collection] = FeeInfo({ setter: setter, receiver: receiver, fee: fee });
_royaltyFeeInfoCollection[collection] = FeeInfo({setter: setter, receiver: receiver, fee: fee});

emit RoyaltyFeeUpdate(collection, setter, receiver, fee);
}
2 changes: 1 addition & 1 deletion contracts/test/mock/MockSmartWallet.sol
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ contract MockSmartWallet {
}

function execute(address dest, uint256 value, bytes calldata calldata_) public onlyOwner {
(bool success, bytes memory result) = dest.call{ value: value }(calldata_);
(bool success, bytes memory result) = dest.call{value: value}(calldata_);

if (!success) {
assembly {
90 changes: 86 additions & 4 deletions frontend/components/merge-all-claim-fractions-button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import React from "react";
import { Button } from "@mui/material";
import {
Button,
Dialog,
DialogActions,
DialogContent,
DialogContentText,
DialogTitle,
} from "@mui/material";
import { useMergeFractionUnits } from "../hooks/mergeFractionUnits";
import { toast } from "react-toastify";
import { useHypercertClient } from "../hooks/hypercerts-client";
import { useAccountLowerCase } from "../hooks/account";

interface Props {
claimId: string;
@@ -14,13 +25,84 @@ export function MergeAllClaimFractionsButton({
className,
disabled,
}: Props) {
const [open, setOpen] = React.useState(false);
const { write, readOnly, txPending } = useMergeFractionUnits({});
const { client, isLoading } = useHypercertClient();
const { address } = useAccountLowerCase();

const onClick = async () => {
console.log("Merging all claim fractions", claimId);
setOpen(false);
if (readOnly) {
toast("Please connect your wallet to merge all claim fractions");
return;
}

if (isLoading) {
toast("Please wait for the client to be ready");
return;
}

if (!client) {
toast("Please connect your wallet to merge all claim fractions");
return;
}

if (!address) {
toast("Please connect your wallet to merge all claim fractions");
return;
}

const fractionUnits = await client.indexer.fractionsByClaim(claimId);
console.log("Fraction units", fractionUnits);

const myFractions = fractionUnits.claimTokens.filter(
(fraction) => fraction.owner === address,
);

console.log("address", address);
console.log("My fractions", myFractions);

if (!myFractions.length) {
toast("No fractions to merge");
return;
}

await write(myFractions.map((fraction) => fraction.tokenID));
};

const isDisabled = disabled || txPending || readOnly || isLoading;

return (
<Button disabled={disabled} className={className} onClick={onClick}>
{text}
</Button>
<>
<Button
disabled={isDisabled}
className={className}
onClick={() => setOpen(true)}
>
{text}
</Button>
<Dialog
open={open}
onClose={() => setOpen(false)}
aria-labelledby="alert-dialog-title"
aria-describedby="alert-dialog-description"
>
<DialogTitle id="alert-dialog-title">
{"Merge all your fractions for this hypercert?"}
</DialogTitle>
<DialogContent>
<DialogContentText id="alert-dialog-description">
This action cannot be reversed
</DialogContentText>
</DialogContent>
<DialogActions>
<Button onClick={() => setOpen(false)}>Disagree</Button>
<Button onClick={onClick} autoFocus>
Agree
</Button>
</DialogActions>
</Dialog>
</>
);
}
178 changes: 171 additions & 7 deletions frontend/components/split-fraction-button.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
import { Button } from "@mui/material";
import { Box, Button, Input, Modal, Typography } from "@mui/material";
import React, { useState } from "react";
import { FieldArray, Form, Formik } from "formik";
import { useFractionById } from "../hooks/fractions";
import { PlusIcon } from "primereact/icons/plus";
import { Delete } from "@mui/icons-material";
import { useSplitFractionUnits } from "../hooks/splitClaimUnits";
import { toast } from "react-toastify";

const style = {
position: "absolute",
top: "50%",
left: "50%",
transform: "translate(-50%, -50%)",
width: 400,
bgcolor: "background.paper",
boxShadow: 24,
pt: 2,
px: 4,
pb: 3,
};

interface Props {
fractionId: string;
@@ -12,13 +32,157 @@ export function SplitFractionButton({
className,
disabled,
}: Props) {
const onClick = async () => {
console.log("Splitting fraction", fractionId);
};
const [open, setOpen] = useState(false);
const handleOpen = () => setOpen(true);
const handleClose = () => setOpen(false);

const { write, readOnly, txPending } = useSplitFractionUnits({
onComplete: () => {
toast("Splitting fraction completed");
handleClose();
},
});

const { data, isLoading } = useFractionById(fractionId);

console.log(data, isLoading);

if (isLoading || !data?.claimToken) {
return null;
}

const totalValue = parseInt(data.claimToken.units, 10);

const _disabled = txPending || readOnly || isLoading || disabled;

return (
<Button className={className} disabled={disabled} onClick={onClick}>
{text}
</Button>
<>
<Button className={className} disabled={disabled} onClick={handleOpen}>
{text}
</Button>
<Modal
open={open}
onClose={handleClose}
aria-labelledby="modal-modal-title"
aria-describedby="modal-modal-description"
>
<Box sx={{ ...style, width: 400 }}>
<Typography id="modal-modal-title" variant="h6" component="h2">
Split up your fraction
</Typography>
<Typography id="modal-modal-description" sx={{ mt: 2, mb: 2 }}>
Make sure the total value of the fractions is equal to the original
</Typography>
<Formik
initialValues={{ units: [totalValue] }}
validate={(values) => {
if (!values.units.length) {
return { units: "Required" };
}
const totalValueInForm = values.units.reduce(
(sum, value) => sum + value,
0,
);

if (totalValueInForm !== totalValue) {
return {
units: "Total value must be equal to the original value",
};
}
}}
onSubmit={async (values) => {
const tokenId = data.claimToken?.tokenID;
if (!tokenId) {
return;
}
await write(
BigInt(tokenId),
values.units.map((x) => BigInt(x)),
);
}}
>
{({ values, errors, setFieldValue, isValid, isSubmitting }) => {
const isDisabled = _disabled || isSubmitting;
return (
<Form>
<FieldArray
name="units"
render={(arrayHelpers) => (
<div>
{values.units && values.units.length > 0 ? (
values.units.map((unit, index) => (
<div
key={index}
style={{
display: "flex",
marginBottom: "1rem",
}}
>
{/*<Field name={} />*/}
<Input
sx={{ mr: 1 }}
value={unit}
name={`units.${index}`}
disabled={isDisabled}
onChange={(e) =>
setFieldValue(
`units.${index}`,
isNaN(parseInt(e.target.value))
? 0
: parseInt(e.target.value),
)
}
/>

<Button
sx={{ mr: 1 }}
variant="contained"
disabled={isDisabled}
startIcon={<Delete />}
onClick={() => arrayHelpers.remove(index)} // remove a friend from the list
>
Delete
</Button>

<Button
variant="contained"
disabled={isDisabled}
onClick={() =>
arrayHelpers.insert(index + 1, 0)
} // remove a friend from the list
startIcon={<PlusIcon />}
>
Add
</Button>
</div>
))
) : (
<Button
disabled={isDisabled}
type="button"
onClick={() => arrayHelpers.push("")}
>
Add a fraction
</Button>
)}
{errors.units && (
<div className="error">{errors.units as string}</div>
)}

<div>
<Button disabled={!isValid} type="submit">
Submit
</Button>
</div>
</div>
)}
/>
</Form>
);
}}
</Formik>
</Box>
</Modal>
</>
);
}
11 changes: 5 additions & 6 deletions frontend/hooks/fractions.ts
Original file line number Diff line number Diff line change
@@ -18,11 +18,10 @@ export const useFractionsByClaim = (claimId: string) => {
client: { indexer },
} = useHypercertClient();

return (
useQuery(["graph", "fractions", "claim", claimId], () =>
indexer.fractionsByClaim(claimId),
),
{ enabled: !!claimId, refetchInterval: 5000 }
return useQuery(
["graph", "fractions", "claim", claimId],
() => indexer.fractionsByClaim(claimId),
{ enabled: !!claimId, refetchInterval: 5000 },
);
};

@@ -34,6 +33,6 @@ export const useFractionById = (fractionId: string) => {
return useQuery(
["graph", "fractions", fractionId],
() => indexer.fractionById(fractionId),
{ enabled: !!fractionId, refetchInterval: 5000 },
{ enabled: !!fractionId },
);
};
3 changes: 2 additions & 1 deletion frontend/hooks/mergeFractionUnits.ts
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ export const useMergeFractionUnits = ({
console.error(receipt);
}
if (receipt?.status === "success") {
toast(mintInteractionLabels.toastSuccess, { type: "success" });
toast("Fractions successfully merged", { type: "success" });

setStep("complete");
onComplete?.();
@@ -66,6 +66,7 @@ export const useMergeFractionUnits = ({
showModal({ stepDescriptions });
setStep("preparing");
await initializeWrite(ids);
window.location.reload();
},
txPending,
readOnly: isLoading || !client || client.readonly,
14 changes: 6 additions & 8 deletions frontend/hooks/splitClaimUnits.ts
Original file line number Diff line number Diff line change
@@ -15,8 +15,7 @@ export const useSplitFractionUnits = ({
const { client, isLoading } = useHypercertClient();

const stepDescriptions = {
preparing: "Preparing to merge fraction values",
merging: "Splitting fraction units on-chain",
splitting: "Splitting fraction units on-chain",
waiting: "Awaiting confirmation",
complete: "Done splitting",
};
@@ -26,20 +25,20 @@ export const useSplitFractionUnits = ({

const publicClient = client.config.publicClient;

const initializeWrite = async (id: bigint, fractions: bigint[]) => {
const initializeWrite = async (fractionId: bigint, fractions: bigint[]) => {
showModal({ stepDescriptions });
setStep("splitting");
try {
setTxPending(true);

const hash = await client.splitFractionUnits(id, fractions);
const hash = await client.splitFractionUnits(fractionId, fractions);

setStep("waiting");
const receipt = await publicClient?.waitForTransactionReceipt({
confirmations: 3,
hash: hash,
});

setStep("waiting");

if (receipt?.status === "reverted") {
toast("Splitting failed", {
type: "error",
@@ -65,9 +64,8 @@ export const useSplitFractionUnits = ({

return {
write: async (id: bigint, fractions: bigint[]) => {
showModal({ stepDescriptions });
setStep("preparing");
await initializeWrite(id, fractions);
window.location.reload();
},
txPending,
readOnly: isLoading || !client || client.readonly,
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@
"@graphprotocol/client-cli": "^2.2.16",
"@hypercerts-org/contracts": "0.9.0",
"@hypercerts-org/observabletreemap": "workspace: *",
"@hypercerts-org/sdk": "1.0.0-alpha.8",
"@hypercerts-org/sdk": "1.0.0-alpha.9",
"@mui/icons-material": "^5.11.9",
"@mui/material": "^5.11.2",
"@mui/x-date-pickers": "^5.0.12",
2 changes: 1 addition & 1 deletion frontend/plasmic-init.ts
Original file line number Diff line number Diff line change
@@ -683,7 +683,7 @@ PLASMIC.registerComponent(MergeAllClaimFractionsButton, {
disabled: "boolean",
text: {
type: "string",
defaultValue: "Split",
defaultValue: "Merge",
helpText: "Text to display on button",
},
},
133 changes: 71 additions & 62 deletions pnpm-lock.yaml

Large diffs are not rendered by default.