Skip to content

Safe integration for creating marketplace listings #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

pheuberger
Copy link
Member

This PR adds support to create marketplace listings using a Safe.

It introduces a new class SafeMessages that deals with constructing, signing and uploading Safe messages to the Safe Transaction Service.

On the exchange client it introduces a new function signMakerOrderSafe() that's supposed to be called by the users of this SDK.

In our frontend we're using Hypercerts as name and version number 1, so
we should do this in our SDK as well.
The TSDoc around bundleApprovalsForSafe() was missing a parameter and
not very descriptive what it did.
@pheuberger pheuberger requested a review from Jipperism March 26, 2025 18:51
@pheuberger pheuberger force-pushed the listing-safe-integration branch from 997b366 to eb41f3e Compare March 27, 2025 11:59
Without this patch users of this SDK have no way to create marketplace
listings from a Safe. This new function signs a maker order and uploads
it to the Safe transaction service. There it can be executed by the
other signers.
The function doesn't need these fields to compute validity. This only
complicates things at the call-site. We should apply the Law of Demeter
here.
Without this patch there's only the option to send both approval
transactions in a bundle. This can be a problem when the Safe has one of
the approvals but not both. Surely this is an edge case, but it did
happen during development. The problem, here, is that the approval of
the transfer manager will reject if it's already done. This could lead
to users being stuck.
This function builds the Safe-specific payload to the API that only
contains the chain id and message hash.
@pheuberger pheuberger force-pushed the listing-safe-integration branch from eb41f3e to 76fb5c3 Compare April 4, 2025 15:34
return this.createMakerAsk({
// Defaults
strategyId: StrategyType.standard,
collectionType: 2,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could use the CollectionType enum here

@@ -2,11 +2,11 @@
* EIP712 domain name.
* @see {@link https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator EIP712 doc}
*/
export const DOMAIN_NAME = "LooksRareProtocol";
export const DOMAIN_NAME = "Hypercerts";
Copy link
Collaborator

@Jipperism Jipperism Apr 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was changed last time as well, and it broke signatures as the API needs to be updated too, so I rolled it back. if we want to change it, it needs to be rolled out at the same time for the API and the marketplace sdk


/**
* EIP712 domain version.
* @see {@link https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator EIP712 doc}
*/
export const DOMAIN_VERSION = 2;
export const DOMAIN_VERSION = 1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idem

const domain = {
name: DOMAIN_NAME,
version: DOMAIN_VERSION.toString(),
chainId: Number(this.chainId),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parseInt

safeAddress: this.address,
});

const domain = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is getTypedDataDomain()

@@ -1,6 +1,6 @@
{
"name": "@hypercerts-org/marketplace-sdk",
"version": "0.5.3",
"version": "0.5.4",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i just merged the other PR so this needs updating

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants