Skip to content

Commit

Permalink
Merge pull request #1261 from hypercerts-org/feat/defender_allowlist_…
Browse files Browse the repository at this point in the history
…parsing

Bump contract and SDK package to use marketplace deployments
  • Loading branch information
bitbeckers authored Jan 16, 2024
2 parents 801da52 + 2a8e11e commit e97f101
Show file tree
Hide file tree
Showing 19 changed files with 155 additions and 93 deletions.
5 changes: 5 additions & 0 deletions contracts/RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# 1.1.0

- Added Sepolia marketplace deployment
- Added marketplace abis
- Added marketplace addresses
2 changes: 1 addition & 1 deletion contracts/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@hypercerts-org/contracts",
"description": "EVM compatible protocol for managing impact claims",
"version": "1.0.0",
"version": "1.1.0",
"author": {
"name": "Hypercerts Foundation",
"url": "https://github.com/hypercerts-org/hypercerts"
Expand Down
12 changes: 1 addition & 11 deletions contracts/src/deployments/deployments-protocol.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
{
"5": {
"HypercertMinterUUPS": "0x822F17A9A5EeCFd66dBAFf7946a8071C265D1d07",
"HypercertMinterImplementation": "0x0a00a2f09cd37b24e7429c5238323bfebcff3ed9",
"TransferManager": "0xeec4DFb4A230e92c854a643130BA7F89617CD8e6",
"HypercertExchange": "0x54E196903c7E71182025aBa9DBE5Dd136755D05a",
"OrderValidatorV2A": "0x9626265537c50528a6579e23d44f4d877d27af0b"
},
"11155111": {
"HypercertMinterUUPS": "0xa16DFb32Eb140a6f3F2AC68f41dAd8c7e83C4941",
"HypercertMinterImplementation": "0x0a0df97bddb36eef95fef089a4aeb7aceabf2101",
"TransferManager": "0x7AAC4C1407f5F83256581eCc913dC8b20F7bdab1",
"HypercertExchange": "0x4072ABD45a95c56372eAA00059B101C95191ea2A",
"OrderValidatorV2A": "0x11cf91a633b292e90afc1dd063db9ce0b94a89ae"
"HypercertMinterImplementation": "0x0a0df97bddb36eef95fef089a4aeb7aceabf2101"
},
"10": {
"HypercertMinterUUPS": "0x822F17A9A5EeCFd66dBAFf7946a8071C265D1d07",
Expand Down
13 changes: 12 additions & 1 deletion contracts/src/deployments/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,18 @@ import deployments_marketplace_sepolia from "./deployment-marketplace-sepolia.js
import deployments_protocol from "./deployments-protocol.json";

const deployments_marketplace = {
"11155111": deployments_marketplace_sepolia,
"11155111": {
TransferManager: deployments_marketplace_sepolia.TransferManager.address,
HypercertExchange: deployments_marketplace_sepolia.HypercertExchange.address,
OrderValidatorV2A: deployments_marketplace_sepolia.OrderValidator.address,
RoyaltyFeeRegistry: deployments_marketplace_sepolia.RoyaltyFeeRegistry.address,
StrategyCollectionOffer: deployments_marketplace_sepolia.StrategyCollectionOffer.address,
StrategyDutchAuction: deployments_marketplace_sepolia.StrategyDutchAuction.address,
StrategyItemIdsRange: deployments_marketplace_sepolia.StrategyItemIdsRange.address,
StrategyHypercertCollectionOffer: deployments_marketplace_sepolia.StrategyHypercertCollectionOffer.address,
StrategyHypercertDutchAuction: deployments_marketplace_sepolia.StrategyHypercertDutchAuction.address,
StrategyHypercertFractionOffer: deployments_marketplace_sepolia.StrategyHypercertFractionOffer.address,
},
};

export default { marketplace: deployments_marketplace, protocol: deployments_protocol };
34 changes: 28 additions & 6 deletions contracts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ import OrderValidatorV2AAbi from "../abi/src/marketplace/helpers/OrderValidatorV
import StrategyManagerAbi from "../abi/src/marketplace/StrategyManager.sol/StrategyManager.json";
import TransferManagerAbi from "../abi/src/marketplace/TransferManager.sol/TransferManager.json";
import StrategyCollectionOfferAbi from "../abi/src/marketplace/executionStrategies/StrategyCollectionOffer.sol/StrategyCollectionOffer.json";
import StrategyDutchAuctionAbi from "../abi/src/marketplace/executionStrategies/StrategyDutchAuction.sol/StrategyDutchAuction.json";
import StrategyHypercertFractionOfferAbi from "../abi/src/marketplace/executionStrategies/StrategyHypercertFractionOffer.sol/StrategyHypercertFractionOffer.json";
import CreatorFeeManagerWithRoyaltiesAbi from "../abi/src/marketplace/CreatorFeeManagerWithRoyalties.sol/CreatorFeeManagerWithRoyalties.json";
import StrategyHypercertCollectionOfferAbi from "../abi/src/marketplace/executionStrategies/StrategyHypercertCollectionOffer.sol/StrategyHypercertCollectionOffer.json";
import StrategyHypercertDutchAuctionAbi from "../abi/src/marketplace/executionStrategies/StrategyHypercertDutchAuction.sol/StrategyHypercertDutchAuction.json";
import StrategyItemIdsRangeAbi from "../abi/src/marketplace/executionStrategies/StrategyItemIdsRange.sol/StrategyItemIdsRange.json";
import ExecutionManagerAbi from "../abi/src/marketplace/ExecutionManager.sol/ExecutionManager.json";

import {
Expand All @@ -16,11 +20,15 @@ import {
IHypercertToken,
LooksRareProtocol as HypercertExchange,
ILooksRareProtocol as IHypercertExchange,
CreatorFeeManagerWithRoyalties,
OrderValidatorV2A,
TransferManager,
StrategyCollectionOffer,
StrategyDutchAuction,
StrategyItemIdsRange,
StrategyHypercertFractionOffer,
CreatorFeeManagerWithRoyalties,
OrderValidatorV2A,
StrategyHypercertCollectionOffer,
StrategyHypercertDutchAuction,
} from "types";

/*
Expand All @@ -34,14 +42,19 @@ import {
export type DeploymentProtocol = {
HypercertMinterUUPS: `0x${string}`;
HypercertMinterImplementation: `0x${string}`;
TransferManager?: `0x${string}`;
HypercertExchange?: `0x${string}`;
};

export type DeploymentMarketplace = {
HypercertExchange: `0x${string}`;
TransferManager: `0x${string}`;
HypercertExchange: `0x${string}`;
OrderValidatorV2A: `0x${string}`;
RoyaltyFeeRegistry: `0x${string}`;
StrategyCollectionOffer: `0x${string}`;
StrategyDutchAuction: `0x${string}`;
StrategyItemIdsRange: `0x${string}`;
StrategyHypercertCollectionOffer: `0x${string}`;
StrategyHypercertDutchAuction: `0x${string}`;
StrategyHypercertFractionOffer: `0x${string}`;
};

export type Deployment = DeploymentProtocol & Partial<DeploymentMarketplace>;
Expand All @@ -57,6 +70,7 @@ const deployments = {
},
11155111: {
...DEPLOYMENTS.protocol["11155111"],
...DEPLOYMENTS.marketplace["11155111"],
},
} as Record<DeployedChains, Deployment>;

Expand All @@ -74,10 +88,14 @@ export {
HypercertMinterAbi,
HypercertExchangeAbi,
OrderValidatorV2AAbi,
TransferManagerAbi,
StrategyManagerAbi,
StrategyCollectionOfferAbi,
StrategyDutchAuctionAbi,
StrategyItemIdsRangeAbi,
StrategyHypercertFractionOfferAbi,
TransferManagerAbi,
StrategyHypercertCollectionOfferAbi,
StrategyHypercertDutchAuctionAbi,
};

// Interfaces
Expand All @@ -91,5 +109,9 @@ export type {
OrderValidatorV2A,
TransferManager,
StrategyCollectionOffer,
StrategyDutchAuction,
StrategyItemIdsRange,
StrategyHypercertFractionOffer,
StrategyHypercertCollectionOffer,
StrategyHypercertDutchAuction,
};
2 changes: 1 addition & 1 deletion graph/tests/.latest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "0.6.0",
"timestamp": 1703510468280
"timestamp": 1705410292091
}
14 changes: 7 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions sdk/RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Release notes

## 1.4.0

- Added all deployments from `@hypercerts-org/contracts` to the SDK under deploments.
- Deprecated `getContract` because we no longer have one contract address per network.
- Added `getDeployments` to retrieve all deployments for a network.

## 1.3.0

- Added `txParser` util to parse transaction hashes and return the required data
- Added `getClaimStoredDataFromTxHash` to retrieve the claim data from a transaction hash

## 1.1.1

- Deprecate goerli chain
Expand Down
4 changes: 2 additions & 2 deletions sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hypercerts-org/sdk",
"version": "1.3.0",
"version": "1.4.1",
"description": "SDK for hypercerts protocol",
"repository": "git@github.com:hypercerts-org/hypercerts.git",
"author": "Hypercerts team",
Expand All @@ -24,7 +24,7 @@
"@ethereum-attestation-service/eas-sdk": "1.3.7",
"@ethersproject/abstract-signer": "^5.7.0",
"@graphql-typed-document-node/core": "^3.2.0",
"@hypercerts-org/contracts": "1.0.0",
"@hypercerts-org/contracts": "1.1.0",
"@openzeppelin/merkle-tree": "^1.0.5",
"@urql/core": "^4.2.0",
"@whatwg-node/fetch": "^0.9.13",
Expand Down
21 changes: 16 additions & 5 deletions sdk/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
HypercertClientInterface,
HypercertMetadata,
InvalidOrMissingError,
SupportedChainIds,
SupportedOverrides,
TransferRestrictions,
} from "./types";
Expand All @@ -18,6 +19,7 @@ import { verifyMerkleProof, verifyMerkleProofs } from "./validator";
import { handleSimulatedContractError } from "./utils/errors";
import { logger } from "./utils";
import { parseAllowListEntriesToMerkleTree } from "./utils/allowlist";
import { DEPLOYMENTS } from "./constants";
import { getClaimStoredDataFromTxHash } from "./utils";
import { ParserReturnType } from "./utils/txParser";

Expand Down Expand Up @@ -100,15 +102,25 @@ export class HypercertClient implements HypercertClientInterface {
/**
* Gets the HypercertMinter contract used by the client.
* @returns The contract.
* @deprecated Use getDeployments instead.
*/
get contract(): GetContractReturnType<typeof HypercertMinterAbi> {
return getContract({
address: this._config.contractAddress as `0x${string}`,
address: this._config.addresses?.HypercertMinterUUPS as `0x${string}`,
abi: HypercertMinterAbi,
publicClient: this._publicClient,
});
}

/**
* Gets the contract addresses and graph urls for the provided `chainId`
* @returns The addresses, graph name and graph url.
* @deprecated Use getDeployments instead.
*/
getDeployment = (chainId: SupportedChainIds) => {
return DEPLOYMENTS[chainId];
};

/**
* Mints a new claim.
*
Expand Down Expand Up @@ -347,8 +359,6 @@ export class HypercertClient implements HypercertClientInterface {

const request = await this.simulateRequest(account, "mergeFractions", [account?.address, fractionIds], overrides);

console.log(request);

return this.submitRequest(request);
};

Expand Down Expand Up @@ -479,10 +489,11 @@ export class HypercertClient implements HypercertClientInterface {
};

private getContractConfig = () => {
if (!this.config?.contractAddress) throw new ClientError("No contract address found", { config: this.config });
if (!this.config?.addresses?.HypercertMinterUUPS)
throw new ClientError("No contract address found", { config: this.config });

return getContract({
address: this.config.contractAddress as `0x${string}`,
address: this.config.addresses.HypercertMinterUUPS as `0x${string}`,
abi: HypercertMinterAbi,
publicClient: this._publicClient,
});
Expand Down
7 changes: 4 additions & 3 deletions sdk/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/

import { Deployment, SupportedChainIds } from "./types";
import { deployments } from "@hypercerts-org/contracts";

const DEFAULT_GRAPH_BASE_URL = "https://api.thegraph.com/subgraphs/name/hypercerts-admin";

Expand All @@ -16,17 +17,17 @@ const APIS: { [key: string]: string } = {
// These are the deployments we manage
const DEPLOYMENTS: { [key in SupportedChainIds]: Partial<Deployment> } = {
10: {
contractAddress: "0x822F17A9A5EeCFd66dBAFf7946a8071C265D1d07",
addresses: deployments[10],
graphName: "hypercerts-optimism-mainnet",
graphUrl: `${DEFAULT_GRAPH_BASE_URL}/hypercerts-optimism-mainnet`,
} as const,
42220: {
contractAddress: "0x16ba53b74c234c870c61efc04cd418b8f2865959",
addresses: deployments[42220],
graphName: "hypercerts-celo",
graphUrl: `${DEFAULT_GRAPH_BASE_URL}/hypercerts-celo`,
},
11155111: {
contractAddress: "0xa16DFb32Eb140a6f3F2AC68f41dAd8c7e83C4941",
addresses: deployments[11155111],
graphName: "hypercerts-sepolia",
graphUrl: `${DEFAULT_GRAPH_BASE_URL}/hypercerts-sepolia`,
} as const,
Expand Down
32 changes: 30 additions & 2 deletions sdk/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
import { HypercertMinterAbi, HypercertExchangeAbi } from "@hypercerts-org/contracts";
import {
HypercertMinterAbi,
HypercertExchangeAbi,
OrderValidatorV2AAbi,
StrategyCollectionOfferAbi,
StrategyManagerAbi,
TransferManagerAbi,
StrategyDutchAuctionAbi,
StrategyItemIdsRangeAbi,
StrategyHypercertFractionOfferAbi,
StrategyHypercertCollectionOfferAbi,
StrategyHypercertDutchAuctionAbi,
CreatorFeeManagerWithRoyaltiesAbi,
ExecutionManagerAbi,
} from "@hypercerts-org/contracts";

import { HypercertClient } from "./client";
import { HypercertsStorage } from "./storage";
Expand All @@ -7,7 +21,21 @@ import { APIS, DEPLOYMENTS } from "./constants";
/**
* Protocol
*/
export { HypercertMinterAbi, HypercertExchangeAbi };
export {
HypercertMinterAbi,
HypercertExchangeAbi,
OrderValidatorV2AAbi,
StrategyCollectionOfferAbi,
StrategyManagerAbi,
TransferManagerAbi,
StrategyDutchAuctionAbi,
StrategyItemIdsRangeAbi,
StrategyHypercertFractionOfferAbi,
StrategyHypercertCollectionOfferAbi,
StrategyHypercertDutchAuctionAbi,
CreatorFeeManagerWithRoyaltiesAbi,
ExecutionManagerAbi,
};
export { DEPLOYMENTS as deployments };
export { APIS as apis };

Expand Down
8 changes: 6 additions & 2 deletions sdk/src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ export class HypercertsStorage implements HypercertStorageInterface {

logger.debug("Allowlist tree: ", "storage", [tree]);

const { cid: allowlistCID, errors: uploadAllowlistErrors } = await uploadAllowlist({
const { data: resData, errors: uploadAllowlistErrors } = await uploadAllowlist({
allowList: JSON.stringify(tree.dump()),
totalUnits: totalUnits.toString(),
});

const allowlistCID = resData?.cid;

if ((uploadAllowlistErrors && Object.keys(uploadAllowlistErrors).length > 0) || !allowlistCID) {
throw new StorageError(`Allowlist upload failed.`, { errors: uploadAllowlistErrors, allowlistCID });
}
Expand Down Expand Up @@ -77,7 +79,9 @@ export class HypercertsStorage implements HypercertStorageInterface {

logger.debug("Storing HypercertMetaData: ", "storage", [data]);

const { errors, cid } = await uploadMetadata(metadata);
const { errors, data: resData } = await uploadMetadata(metadata);

const cid = resData?.cid;

if (!cid || (errors && Object.keys(errors).length > 0)) {
throw new StorageError("Failed to store metadata", { errors, cid });
Expand Down
Loading

0 comments on commit e97f101

Please sign in to comment.