@hypercerts-org/marketplace-sdk 0.0.16 → 0.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{LooksRare.d.ts → HypercertExchangeClient.d.ts} +31 -6
- package/dist/index.cjs.js +208 -65
- package/dist/index.d.ts +1 -3
- package/dist/index.esm.js +209 -66
- package/dist/types.d.ts +12 -2
- package/dist/utils/api.d.ts +19 -1
- package/package.json +2 -2
@@ -1,14 +1,16 @@
|
|
1
1
|
import { BigNumberish, ContractTransactionResponse, Overrides, TypedDataDomain, Provider, Signer } from "ethers";
|
2
|
+
import * as api from "./utils/api";
|
2
3
|
import { Addresses, Maker, Taker, ChainId, CreateMakerInput, CreateMakerAskOutput, CreateMakerBidOutput, CreateMakerCollectionOfferInput, CreateMakerCollectionOfferWithProofInput, MerkleTree, ContractMethods, OrderValidatorCode, BatchTransferItem, SignMerkleTreeOrdersOutput, StrategyType, StrategyInfo } from "./types";
|
3
4
|
/**
|
4
5
|
* LooksRare
|
5
6
|
* This class provides helpers to interact with the LooksRare V2 contracts
|
6
7
|
*/
|
7
|
-
export declare class
|
8
|
+
export declare class HypercertExchangeClient {
|
8
9
|
/** Current app chain ID */
|
9
10
|
readonly chainId: ChainId;
|
10
11
|
/** Mapping of LooksRare protocol addresses for the current chain */
|
11
12
|
readonly addresses: Addresses;
|
13
|
+
readonly api: typeof api;
|
12
14
|
/**
|
13
15
|
* Ethers signer
|
14
16
|
* @see {@link https://docs.ethers.org/v6/api/providers/#Signer Ethers signer doc}
|
@@ -136,11 +138,6 @@ export declare class LooksRare {
|
|
136
138
|
merkleTree?: MerkleTree;
|
137
139
|
}[], isAtomic: boolean, overrides?: Overrides): {
|
138
140
|
call: (additionalOverrides?: import("./typechain/common").PayableOverrides | undefined) => any;
|
139
|
-
/**
|
140
|
-
* Validate a timestamp format (seconds)
|
141
|
-
* @param timestamp
|
142
|
-
* @returns boolean
|
143
|
-
*/
|
144
141
|
estimateGas: (additionalOverrides?: import("./typechain/common").PayableOverrides | undefined) => any;
|
145
142
|
callStatic: (additionalOverrides?: import("./typechain/common").PayableOverrides | undefined) => any;
|
146
143
|
};
|
@@ -220,4 +217,32 @@ export declare class LooksRare {
|
|
220
217
|
* @returns StrategyInfo
|
221
218
|
*/
|
222
219
|
strategyInfo(strategyId: StrategyType, overrides?: Overrides): Promise<StrategyInfo>;
|
220
|
+
/**
|
221
|
+
* Create a maker ask for a collection or singular offer of fractions
|
222
|
+
* @param itemIds Token IDs of the fractions to be sold
|
223
|
+
* @param price Price of the fractions in wei
|
224
|
+
* @param startTime Timestamp in seconds when the order becomes valid
|
225
|
+
* @param endTime Timestamp in seconds when the order becomes invalid
|
226
|
+
* @param additionalParameters Additional parameters used to support complex orders
|
227
|
+
*/
|
228
|
+
createDirectFractionsSaleMakerAsk({ itemIds, price, startTime, endTime, additionalParameters, }: Omit<CreateMakerInput, "strategyId" | "collectionType" | "collection" | "subsetNonce" | "orderNonce" | "amounts" | "currency">): Promise<CreateMakerAskOutput>;
|
229
|
+
createFractionalSaleMakerAsk({ itemIds, price, startTime, endTime, maxUnitAmount, minUnitAmount, minUnitsToKeep, sellLeftoverFraction, root, }: Omit<CreateMakerInput, "strategyId" | "collectionType" | "collection" | "subsetNonce" | "orderNonce" | "amounts" | "currency" | "additionalParameters"> & {
|
230
|
+
minUnitAmount: BigNumberish;
|
231
|
+
maxUnitAmount: BigNumberish;
|
232
|
+
minUnitsToKeep: BigNumberish;
|
233
|
+
sellLeftoverFraction: boolean;
|
234
|
+
root?: string;
|
235
|
+
}): Promise<CreateMakerAskOutput>;
|
236
|
+
createFractionalSaleTakerBid(maker: Maker, recipient: string | undefined, unitAmount: BigNumberish, pricePerUnit: BigNumberish): Taker;
|
237
|
+
/**
|
238
|
+
* Register the order with hypercerts marketplace API.
|
239
|
+
* @param order Maker order
|
240
|
+
* @param signature Signature of the maker order
|
241
|
+
*/
|
242
|
+
registerOrder({ order, signature }: {
|
243
|
+
order: Maker;
|
244
|
+
signature: string;
|
245
|
+
}): Promise<{
|
246
|
+
success: boolean;
|
247
|
+
}>;
|
223
248
|
}
|
package/dist/index.cjs.js
CHANGED
@@ -3,9 +3,9 @@
|
|
3
3
|
var ethers = require('ethers');
|
4
4
|
var contracts = require('@hypercerts-org/contracts');
|
5
5
|
var merkletreejs = require('merkletreejs');
|
6
|
-
var supabaseJs = require('@supabase/supabase-js');
|
7
6
|
var sdk = require('@hypercerts-org/sdk');
|
8
7
|
var jsSha3 = require('js-sha3');
|
8
|
+
var supabaseJs = require('@supabase/supabase-js');
|
9
9
|
|
10
10
|
var abiIERC721 = [
|
11
11
|
{
|
@@ -688,6 +688,7 @@ var strategies = /*#__PURE__*/Object.freeze({
|
|
688
688
|
exports.ChainId = void 0;
|
689
689
|
(function (ChainId) {
|
690
690
|
ChainId[ChainId["SEPOLIA"] = 11155111] = "SEPOLIA";
|
691
|
+
ChainId[ChainId["HARDHAT"] = 31337] = "HARDHAT";
|
691
692
|
})(exports.ChainId || (exports.ChainId = {}));
|
692
693
|
/** List of collection types supported by the protocol */
|
693
694
|
exports.CollectionType = void 0;
|
@@ -703,6 +704,14 @@ exports.StrategyType = void 0;
|
|
703
704
|
StrategyType[StrategyType["standard"] = 0] = "standard";
|
704
705
|
StrategyType[StrategyType["collection"] = 1] = "collection";
|
705
706
|
StrategyType[StrategyType["collectionWithMerkleTree"] = 2] = "collectionWithMerkleTree";
|
707
|
+
StrategyType[StrategyType["dutchAuction"] = 4] = "dutchAuction";
|
708
|
+
StrategyType[StrategyType["itemIdsRange"] = 5] = "itemIdsRange";
|
709
|
+
StrategyType[StrategyType["hypercertCollectionOffer"] = 6] = "hypercertCollectionOffer";
|
710
|
+
StrategyType[StrategyType["hypercertCollectionOfferWithProof"] = 7] = "hypercertCollectionOfferWithProof";
|
711
|
+
StrategyType[StrategyType["hypercertCollectionOfferWithAllowlist"] = 8] = "hypercertCollectionOfferWithAllowlist";
|
712
|
+
StrategyType[StrategyType["hypercertDutchAuction"] = 9] = "hypercertDutchAuction";
|
713
|
+
StrategyType[StrategyType["hypercertFractionOffer"] = 10] = "hypercertFractionOffer";
|
714
|
+
StrategyType[StrategyType["hypercertFractionOfferWithAllowlist"] = 11] = "hypercertFractionOfferWithAllowlist";
|
706
715
|
})(exports.StrategyType || (exports.StrategyType = {}));
|
707
716
|
/** Type for maker order */
|
708
717
|
exports.QuoteType = void 0;
|
@@ -785,6 +794,12 @@ const getMakerParamsTypes = (strategy) => {
|
|
785
794
|
if (strategy === exports.StrategyType.collectionWithMerkleTree) {
|
786
795
|
return ["bytes32"]; // Merkle tree root
|
787
796
|
}
|
797
|
+
if (strategy === exports.StrategyType.hypercertFractionOffer) {
|
798
|
+
return ["uint256", "uint256", "uint256", "bool"]; // minUnitAmount, maxUnitAmount, minUnitsToKeep, sellLeftoverFraction
|
799
|
+
}
|
800
|
+
if (strategy === exports.StrategyType.hypercertFractionOfferWithAllowlist) {
|
801
|
+
return ["uint256", "uint256", "uint256", "bool", "bytes32"]; // minUnitAmount, maxUnitAmount, minUnitsToKeep, sellLeftoverFraction, root
|
802
|
+
}
|
788
803
|
return [];
|
789
804
|
};
|
790
805
|
/**
|
@@ -802,6 +817,12 @@ const getTakerParamsTypes = (strategy) => {
|
|
802
817
|
if (strategy === exports.StrategyType.collectionWithMerkleTree) {
|
803
818
|
return ["uint256", "bytes32[]"]; // Item id, merkle proof
|
804
819
|
}
|
820
|
+
if (strategy === exports.StrategyType.hypercertFractionOffer) {
|
821
|
+
return ["uint256", "uint256"]; // unitAmount, pricePerUnit
|
822
|
+
}
|
823
|
+
if (strategy === exports.StrategyType.hypercertFractionOfferWithAllowlist) {
|
824
|
+
return ["uint256", "uint256", "bytes32[]"]; // unitAmount, pricePerUnit, proof
|
825
|
+
}
|
805
826
|
return [];
|
806
827
|
};
|
807
828
|
/**
|
@@ -1072,81 +1093,30 @@ var asDeployedChain$1 = /*#__PURE__*/Object.freeze({
|
|
1072
1093
|
asDeployedChain: asDeployedChain
|
1073
1094
|
});
|
1074
1095
|
|
1075
|
-
const HYPERCERTS_MARKETPLACE_API_URL = "https://staging.hyperboards.org/api";
|
1076
|
-
const SUPABASE_HYPERCERTS_URL = "https://clagjjfinooizoqdkvqc.supabase.co";
|
1077
|
-
const SUPABASE_HYPERCERTS_ANON_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNsYWdqamZpbm9vaXpvcWRrdnFjIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NzY5NTAxNDAsImV4cCI6MTk5MjUyNjE0MH0.LOIW3NcYEfF7w893PS3Ne1VrntACE3OPeSRFkspvyqw";
|
1078
|
-
const supabaseHypercerts = supabaseJs.createClient(SUPABASE_HYPERCERTS_URL, SUPABASE_HYPERCERTS_ANON_KEY);
|
1079
|
-
const fetchOrderNonce = async ({ address, chainId }) => {
|
1080
|
-
return fetch(`${HYPERCERTS_MARKETPLACE_API_URL}/marketplace/order-nonce/`, {
|
1081
|
-
method: "POST",
|
1082
|
-
headers: {
|
1083
|
-
"Content-Type": "application/json",
|
1084
|
-
},
|
1085
|
-
body: JSON.stringify({
|
1086
|
-
address,
|
1087
|
-
chainId,
|
1088
|
-
}),
|
1089
|
-
})
|
1090
|
-
.then((res) => res.json())
|
1091
|
-
.then((res) => res.data);
|
1092
|
-
};
|
1093
|
-
const createOrder = async ({ order, signer, signature, quoteType, chainId, }) => {
|
1094
|
-
const { globalNonce, ...orderWithoutGlobalNonce } = order;
|
1095
|
-
return fetch(`${HYPERCERTS_MARKETPLACE_API_URL}/marketplace/order/`, {
|
1096
|
-
method: "POST",
|
1097
|
-
headers: {
|
1098
|
-
"Content-Type": "application/json",
|
1099
|
-
},
|
1100
|
-
body: JSON.stringify({
|
1101
|
-
...orderWithoutGlobalNonce,
|
1102
|
-
globalNonce: globalNonce.toString(10),
|
1103
|
-
price: order.price.toString(10),
|
1104
|
-
quoteType,
|
1105
|
-
signer,
|
1106
|
-
signature,
|
1107
|
-
chainId,
|
1108
|
-
}),
|
1109
|
-
}).then((res) => res.json());
|
1110
|
-
};
|
1111
|
-
const fetchOrdersByHypercertId = async ({ hypercertId, chainId }) => {
|
1112
|
-
const hypercertsClient = new sdk.HypercertClient({
|
1113
|
-
chain: { id: chainId },
|
1114
|
-
});
|
1115
|
-
const fractions = await hypercertsClient.indexer.fractionsByClaim(hypercertId);
|
1116
|
-
const tokenIds = fractions.claimTokens.map((fraction) => fraction.tokenID);
|
1117
|
-
return supabaseHypercerts.from("marketplace-orders").select("*").containedBy("itemIds", tokenIds).throwOnError();
|
1118
|
-
};
|
1119
|
-
|
1120
|
-
var api = /*#__PURE__*/Object.freeze({
|
1121
|
-
__proto__: null,
|
1122
|
-
createOrder: createOrder,
|
1123
|
-
fetchOrderNonce: fetchOrderNonce,
|
1124
|
-
fetchOrdersByHypercertId: fetchOrdersByHypercertId,
|
1125
|
-
supabaseHypercerts: supabaseHypercerts
|
1126
|
-
});
|
1127
|
-
|
1128
1096
|
const sepoliaAddresses = {
|
1129
1097
|
EXCHANGE_V2: sdk.deployments[11155111].addresses?.HypercertExchange,
|
1130
1098
|
TRANSFER_MANAGER_V2: sdk.deployments[11155111].addresses?.TransferManager,
|
1131
1099
|
ORDER_VALIDATOR_V2: sdk.deployments[11155111].addresses?.OrderValidator,
|
1132
1100
|
WETH: "0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9",
|
1101
|
+
MINTER: sdk.deployments[11155111].addresses?.HypercertMinterUUPS,
|
1133
1102
|
};
|
1134
1103
|
/**
|
1135
1104
|
* List of useful contract addresses
|
1136
1105
|
*/
|
1137
1106
|
const addressesByNetwork = {
|
1138
1107
|
[exports.ChainId.SEPOLIA]: sepoliaAddresses,
|
1108
|
+
[exports.ChainId.HARDHAT]: sepoliaAddresses,
|
1139
1109
|
};
|
1140
1110
|
|
1141
1111
|
const chainInfo = {
|
1142
|
-
[
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
},
|
1112
|
+
// [ChainId.GOERLI]: {
|
1113
|
+
// label: "Goerli",
|
1114
|
+
// appUrl: "https://goerli.looksrare.org",
|
1115
|
+
// explorer: "https://goerli.etherscan.io",
|
1116
|
+
// rpcUrl: "https://eth-goerli.g.alchemy.com/v2",
|
1117
|
+
// baseApiUrl: "https://graphql-goerli.looksrare.org",
|
1118
|
+
// osApiUrl: "https://testnets-api.opensea.io",
|
1119
|
+
// },
|
1150
1120
|
[exports.ChainId.SEPOLIA]: {
|
1151
1121
|
label: "Sepolia",
|
1152
1122
|
appUrl: "https://sepolia.looksrare.org",
|
@@ -4834,11 +4804,82 @@ const contractName = "LooksRareProtocol";
|
|
4834
4804
|
*/
|
4835
4805
|
const version = 2;
|
4836
4806
|
|
4807
|
+
const HYPERCERTS_MARKETPLACE_API_URL = "http://localhost:3000/api";
|
4808
|
+
const SUPABASE_HYPERCERTS_URL = "https://clagjjfinooizoqdkvqc.supabase.co";
|
4809
|
+
const SUPABASE_HYPERCERTS_ANON_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNsYWdqamZpbm9vaXpvcWRrdnFjIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NzY5NTAxNDAsImV4cCI6MTk5MjUyNjE0MH0.LOIW3NcYEfF7w893PS3Ne1VrntACE3OPeSRFkspvyqw";
|
4810
|
+
const supabaseHypercerts = supabaseJs.createClient(SUPABASE_HYPERCERTS_URL, SUPABASE_HYPERCERTS_ANON_KEY);
|
4811
|
+
/**
|
4812
|
+
* Fetches order nonce from api
|
4813
|
+
* @param address Address
|
4814
|
+
* @param chainId Chain ID
|
4815
|
+
*/
|
4816
|
+
const fetchOrderNonce = async ({ address, chainId }) => {
|
4817
|
+
return fetch(`${HYPERCERTS_MARKETPLACE_API_URL}/marketplace/order-nonce/`, {
|
4818
|
+
method: "POST",
|
4819
|
+
headers: {
|
4820
|
+
"Content-Type": "application/json",
|
4821
|
+
},
|
4822
|
+
body: JSON.stringify({
|
4823
|
+
address,
|
4824
|
+
chainId,
|
4825
|
+
}),
|
4826
|
+
})
|
4827
|
+
.then((res) => res.json())
|
4828
|
+
.then((res) => res.data);
|
4829
|
+
};
|
4830
|
+
/**
|
4831
|
+
* Registers order in api
|
4832
|
+
* @param order Order
|
4833
|
+
* @param signer Signer
|
4834
|
+
* @param signature Signature
|
4835
|
+
* @param quoteType Quote type
|
4836
|
+
* @param chainId Chain ID
|
4837
|
+
*/
|
4838
|
+
const registerOrder = async ({ order, signer, signature, quoteType, chainId, }) => {
|
4839
|
+
const { globalNonce, ...orderWithoutGlobalNonce } = order;
|
4840
|
+
return fetch(`${HYPERCERTS_MARKETPLACE_API_URL}/marketplace/order/`, {
|
4841
|
+
method: "POST",
|
4842
|
+
headers: {
|
4843
|
+
"Content-Type": "application/json",
|
4844
|
+
},
|
4845
|
+
body: JSON.stringify({
|
4846
|
+
...orderWithoutGlobalNonce,
|
4847
|
+
globalNonce: globalNonce.toString(10),
|
4848
|
+
price: order.price.toString(10),
|
4849
|
+
quoteType,
|
4850
|
+
signer,
|
4851
|
+
signature,
|
4852
|
+
chainId,
|
4853
|
+
}),
|
4854
|
+
}).then((res) => res.json());
|
4855
|
+
};
|
4856
|
+
/**
|
4857
|
+
* Fetches orders from api by hypercert ID
|
4858
|
+
* @param hypercertId Hypercert ID
|
4859
|
+
* @param chainId Chain ID
|
4860
|
+
*/
|
4861
|
+
const fetchOrdersByHypercertId = async ({ hypercertId, chainId }) => {
|
4862
|
+
const hypercertsClient = new sdk.HypercertClient({
|
4863
|
+
chain: { id: chainId },
|
4864
|
+
});
|
4865
|
+
const fractions = await hypercertsClient.indexer.fractionsByClaim(hypercertId);
|
4866
|
+
const tokenIds = fractions.claimTokens.map((fraction) => fraction.tokenID);
|
4867
|
+
return supabaseHypercerts.from("marketplace-orders").select("*").containedBy("itemIds", tokenIds).throwOnError();
|
4868
|
+
};
|
4869
|
+
|
4870
|
+
var api = /*#__PURE__*/Object.freeze({
|
4871
|
+
__proto__: null,
|
4872
|
+
fetchOrderNonce: fetchOrderNonce,
|
4873
|
+
fetchOrdersByHypercertId: fetchOrdersByHypercertId,
|
4874
|
+
registerOrder: registerOrder,
|
4875
|
+
supabaseHypercerts: supabaseHypercerts
|
4876
|
+
});
|
4877
|
+
|
4837
4878
|
/**
|
4838
4879
|
* LooksRare
|
4839
4880
|
* This class provides helpers to interact with the LooksRare V2 contracts
|
4840
4881
|
*/
|
4841
|
-
class
|
4882
|
+
class HypercertExchangeClient {
|
4842
4883
|
/**
|
4843
4884
|
* LooksRare protocol main class
|
4844
4885
|
* @param chainId Current app chain id
|
@@ -4849,8 +4890,10 @@ class LooksRare {
|
|
4849
4890
|
constructor(chainId, provider, signer, override) {
|
4850
4891
|
this.chainId = chainId;
|
4851
4892
|
this.addresses = override ?? addressesByNetwork[this.chainId];
|
4893
|
+
console.log("Addresses", this.addresses);
|
4852
4894
|
this.signer = signer;
|
4853
4895
|
this.provider = provider;
|
4896
|
+
this.api = api;
|
4854
4897
|
}
|
4855
4898
|
/**
|
4856
4899
|
* Return the signer it it's set, throw an exception otherwise
|
@@ -5062,6 +5105,7 @@ class LooksRare {
|
|
5062
5105
|
*/
|
5063
5106
|
async signMakerOrder(maker) {
|
5064
5107
|
const signer = this.getSigner();
|
5108
|
+
console.log("signing against", this.getTypedDataDomain(), maker);
|
5065
5109
|
return await signMakerOrder(signer, this.getTypedDataDomain(), maker);
|
5066
5110
|
}
|
5067
5111
|
/**
|
@@ -5228,6 +5272,106 @@ class LooksRare {
|
|
5228
5272
|
async strategyInfo(strategyId, overrides) {
|
5229
5273
|
return strategyInfo(this.provider, this.addresses.EXCHANGE_V2, strategyId, overrides);
|
5230
5274
|
}
|
5275
|
+
/**
|
5276
|
+
* Create a maker ask for a collection or singular offer of fractions
|
5277
|
+
* @param itemIds Token IDs of the fractions to be sold
|
5278
|
+
* @param price Price of the fractions in wei
|
5279
|
+
* @param startTime Timestamp in seconds when the order becomes valid
|
5280
|
+
* @param endTime Timestamp in seconds when the order becomes invalid
|
5281
|
+
* @param additionalParameters Additional parameters used to support complex orders
|
5282
|
+
*/
|
5283
|
+
async createDirectFractionsSaleMakerAsk({ itemIds, price, startTime, endTime, additionalParameters = [], }) {
|
5284
|
+
const address = await this.signer?.getAddress();
|
5285
|
+
if (!address) {
|
5286
|
+
throw new Error("No signer address could be determined");
|
5287
|
+
}
|
5288
|
+
const chainId = this.chainId;
|
5289
|
+
const { nonce_counter } = await fetchOrderNonce({
|
5290
|
+
address,
|
5291
|
+
chainId,
|
5292
|
+
});
|
5293
|
+
const amounts = Array.from({ length: itemIds.length }, () => 1);
|
5294
|
+
return this.createMakerAsk({
|
5295
|
+
// Defaults
|
5296
|
+
strategyId: exports.StrategyType.standard,
|
5297
|
+
collectionType: 2,
|
5298
|
+
collection: this.addresses.MINTER,
|
5299
|
+
subsetNonce: 0,
|
5300
|
+
currency: this.addresses.WETH,
|
5301
|
+
amounts,
|
5302
|
+
orderNonce: nonce_counter.toString(),
|
5303
|
+
// User specified
|
5304
|
+
itemIds,
|
5305
|
+
price,
|
5306
|
+
startTime,
|
5307
|
+
endTime,
|
5308
|
+
additionalParameters,
|
5309
|
+
});
|
5310
|
+
}
|
5311
|
+
async createFractionalSaleMakerAsk({ itemIds, price, startTime, endTime, maxUnitAmount, minUnitAmount, minUnitsToKeep, sellLeftoverFraction, root, }) {
|
5312
|
+
const address = await this.signer?.getAddress();
|
5313
|
+
if (!address) {
|
5314
|
+
throw new Error("No signer address could be determined");
|
5315
|
+
}
|
5316
|
+
const chainId = this.chainId;
|
5317
|
+
const { nonce_counter } = await fetchOrderNonce({
|
5318
|
+
address,
|
5319
|
+
chainId,
|
5320
|
+
});
|
5321
|
+
const amounts = Array.from({ length: itemIds.length }, () => 1);
|
5322
|
+
const sharedArgs = {
|
5323
|
+
// Defaults
|
5324
|
+
collectionType: 2,
|
5325
|
+
collection: this.addresses.MINTER,
|
5326
|
+
subsetNonce: 0,
|
5327
|
+
currency: this.addresses.WETH,
|
5328
|
+
amounts,
|
5329
|
+
orderNonce: nonce_counter.toString(),
|
5330
|
+
// User specified
|
5331
|
+
itemIds,
|
5332
|
+
price,
|
5333
|
+
startTime,
|
5334
|
+
endTime,
|
5335
|
+
};
|
5336
|
+
if (root) {
|
5337
|
+
return this.createMakerAsk({
|
5338
|
+
...sharedArgs,
|
5339
|
+
strategyId: exports.StrategyType.hypercertFractionOfferWithAllowlist,
|
5340
|
+
additionalParameters: [minUnitAmount, maxUnitAmount, minUnitsToKeep, sellLeftoverFraction, root],
|
5341
|
+
});
|
5342
|
+
}
|
5343
|
+
return this.createMakerAsk({
|
5344
|
+
...sharedArgs,
|
5345
|
+
strategyId: exports.StrategyType.hypercertFractionOffer,
|
5346
|
+
additionalParameters: [minUnitAmount, maxUnitAmount, minUnitsToKeep, sellLeftoverFraction],
|
5347
|
+
});
|
5348
|
+
}
|
5349
|
+
createFractionalSaleTakerBid(maker, recipient = ethers.ZeroAddress, unitAmount, pricePerUnit) {
|
5350
|
+
const order = {
|
5351
|
+
recipient: recipient,
|
5352
|
+
additionalParameters: encodeParams([unitAmount, pricePerUnit], getTakerParamsTypes(maker.strategyId)),
|
5353
|
+
};
|
5354
|
+
return order;
|
5355
|
+
}
|
5356
|
+
/**
|
5357
|
+
* Register the order with hypercerts marketplace API.
|
5358
|
+
* @param order Maker order
|
5359
|
+
* @param signature Signature of the maker order
|
5360
|
+
*/
|
5361
|
+
async registerOrder({ order, signature }) {
|
5362
|
+
const address = await this.signer?.getAddress();
|
5363
|
+
if (!address) {
|
5364
|
+
throw new Error("No signer address could be determined");
|
5365
|
+
}
|
5366
|
+
const chainId = this.chainId;
|
5367
|
+
return registerOrder({
|
5368
|
+
order,
|
5369
|
+
signer: address,
|
5370
|
+
signature,
|
5371
|
+
quoteType: order.quoteType,
|
5372
|
+
chainId,
|
5373
|
+
});
|
5374
|
+
}
|
5231
5375
|
}
|
5232
5376
|
|
5233
5377
|
const utils = {
|
@@ -5241,7 +5385,6 @@ const utils = {
|
|
5241
5385
|
...signMakerOrders,
|
5242
5386
|
...eip712,
|
5243
5387
|
...asDeployedChain$1,
|
5244
|
-
api,
|
5245
5388
|
};
|
5246
5389
|
|
5247
5390
|
exports.Eip712MakerMerkleTree = Eip712MakerMerkleTree;
|
@@ -5252,10 +5395,10 @@ exports.ErrorQuoteType = ErrorQuoteType;
|
|
5252
5395
|
exports.ErrorSigner = ErrorSigner;
|
5253
5396
|
exports.ErrorStrategyType = ErrorStrategyType;
|
5254
5397
|
exports.ErrorTimestamp = ErrorTimestamp;
|
5398
|
+
exports.HypercertExchangeClient = HypercertExchangeClient;
|
5255
5399
|
exports.IERC1155Abi = IERC1155;
|
5256
5400
|
exports.IERC20Abi = abiIERC20;
|
5257
5401
|
exports.IERC721Abi = abiIERC721;
|
5258
|
-
exports.LooksRare = LooksRare;
|
5259
5402
|
exports.LooksRareProtocolAbi = LooksRareProtocol;
|
5260
5403
|
exports.MAX_ORDERS_PER_TREE = MAX_ORDERS_PER_TREE;
|
5261
5404
|
exports.OrderValidatorV2AAbi = OrderValidatorV2A;
|
package/dist/index.d.ts
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
import * as api from "./utils/api";
|
2
1
|
declare const utils: {
|
3
|
-
api: typeof api;
|
4
2
|
asDeployedChain: (chainId: number) => import("./types").ChainId;
|
5
3
|
MAKER_HASH: "0x003c1bce41a2de73dfe64d6eeb2b3d7f15f1c0c382d9d963c2c6daeb75f0e539";
|
6
4
|
hashingMakerTypes: string[];
|
@@ -45,4 +43,4 @@ export * from "./types";
|
|
45
43
|
export * from "./abis";
|
46
44
|
export { Eip712MakerMerkleTree } from "./utils/Eip712MakerMerkleTree";
|
47
45
|
export { Eip712MerkleTree } from "./utils/Eip712MerkleTree";
|
48
|
-
export {
|
46
|
+
export { HypercertExchangeClient } from "./HypercertExchangeClient";
|
package/dist/index.esm.js
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
import { Contract, ZeroAddress, AbiCoder, TypedDataEncoder, keccak256, solidityPackedKeccak256, ethers, ZeroHash, MaxUint256 } from 'ethers';
|
2
2
|
import { HypercertExchangeAbi, TransferManagerAbi, OrderValidatorV2A as OrderValidatorV2A$1 } from '@hypercerts-org/contracts';
|
3
3
|
import { MerkleTree } from 'merkletreejs';
|
4
|
-
import {
|
5
|
-
import { HypercertClient, deployments } from '@hypercerts-org/sdk';
|
4
|
+
import { deployments, HypercertClient } from '@hypercerts-org/sdk';
|
6
5
|
import { keccak256 as keccak256$1 } from 'js-sha3';
|
6
|
+
import { createClient } from '@supabase/supabase-js';
|
7
7
|
|
8
8
|
var abiIERC721 = [
|
9
9
|
{
|
@@ -686,6 +686,7 @@ var strategies = /*#__PURE__*/Object.freeze({
|
|
686
686
|
var ChainId;
|
687
687
|
(function (ChainId) {
|
688
688
|
ChainId[ChainId["SEPOLIA"] = 11155111] = "SEPOLIA";
|
689
|
+
ChainId[ChainId["HARDHAT"] = 31337] = "HARDHAT";
|
689
690
|
})(ChainId || (ChainId = {}));
|
690
691
|
/** List of collection types supported by the protocol */
|
691
692
|
var CollectionType;
|
@@ -701,6 +702,14 @@ var StrategyType;
|
|
701
702
|
StrategyType[StrategyType["standard"] = 0] = "standard";
|
702
703
|
StrategyType[StrategyType["collection"] = 1] = "collection";
|
703
704
|
StrategyType[StrategyType["collectionWithMerkleTree"] = 2] = "collectionWithMerkleTree";
|
705
|
+
StrategyType[StrategyType["dutchAuction"] = 4] = "dutchAuction";
|
706
|
+
StrategyType[StrategyType["itemIdsRange"] = 5] = "itemIdsRange";
|
707
|
+
StrategyType[StrategyType["hypercertCollectionOffer"] = 6] = "hypercertCollectionOffer";
|
708
|
+
StrategyType[StrategyType["hypercertCollectionOfferWithProof"] = 7] = "hypercertCollectionOfferWithProof";
|
709
|
+
StrategyType[StrategyType["hypercertCollectionOfferWithAllowlist"] = 8] = "hypercertCollectionOfferWithAllowlist";
|
710
|
+
StrategyType[StrategyType["hypercertDutchAuction"] = 9] = "hypercertDutchAuction";
|
711
|
+
StrategyType[StrategyType["hypercertFractionOffer"] = 10] = "hypercertFractionOffer";
|
712
|
+
StrategyType[StrategyType["hypercertFractionOfferWithAllowlist"] = 11] = "hypercertFractionOfferWithAllowlist";
|
704
713
|
})(StrategyType || (StrategyType = {}));
|
705
714
|
/** Type for maker order */
|
706
715
|
var QuoteType;
|
@@ -783,6 +792,12 @@ const getMakerParamsTypes = (strategy) => {
|
|
783
792
|
if (strategy === StrategyType.collectionWithMerkleTree) {
|
784
793
|
return ["bytes32"]; // Merkle tree root
|
785
794
|
}
|
795
|
+
if (strategy === StrategyType.hypercertFractionOffer) {
|
796
|
+
return ["uint256", "uint256", "uint256", "bool"]; // minUnitAmount, maxUnitAmount, minUnitsToKeep, sellLeftoverFraction
|
797
|
+
}
|
798
|
+
if (strategy === StrategyType.hypercertFractionOfferWithAllowlist) {
|
799
|
+
return ["uint256", "uint256", "uint256", "bool", "bytes32"]; // minUnitAmount, maxUnitAmount, minUnitsToKeep, sellLeftoverFraction, root
|
800
|
+
}
|
786
801
|
return [];
|
787
802
|
};
|
788
803
|
/**
|
@@ -800,6 +815,12 @@ const getTakerParamsTypes = (strategy) => {
|
|
800
815
|
if (strategy === StrategyType.collectionWithMerkleTree) {
|
801
816
|
return ["uint256", "bytes32[]"]; // Item id, merkle proof
|
802
817
|
}
|
818
|
+
if (strategy === StrategyType.hypercertFractionOffer) {
|
819
|
+
return ["uint256", "uint256"]; // unitAmount, pricePerUnit
|
820
|
+
}
|
821
|
+
if (strategy === StrategyType.hypercertFractionOfferWithAllowlist) {
|
822
|
+
return ["uint256", "uint256", "bytes32[]"]; // unitAmount, pricePerUnit, proof
|
823
|
+
}
|
803
824
|
return [];
|
804
825
|
};
|
805
826
|
/**
|
@@ -1070,81 +1091,30 @@ var asDeployedChain$1 = /*#__PURE__*/Object.freeze({
|
|
1070
1091
|
asDeployedChain: asDeployedChain
|
1071
1092
|
});
|
1072
1093
|
|
1073
|
-
const HYPERCERTS_MARKETPLACE_API_URL = "https://staging.hyperboards.org/api";
|
1074
|
-
const SUPABASE_HYPERCERTS_URL = "https://clagjjfinooizoqdkvqc.supabase.co";
|
1075
|
-
const SUPABASE_HYPERCERTS_ANON_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNsYWdqamZpbm9vaXpvcWRrdnFjIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NzY5NTAxNDAsImV4cCI6MTk5MjUyNjE0MH0.LOIW3NcYEfF7w893PS3Ne1VrntACE3OPeSRFkspvyqw";
|
1076
|
-
const supabaseHypercerts = createClient(SUPABASE_HYPERCERTS_URL, SUPABASE_HYPERCERTS_ANON_KEY);
|
1077
|
-
const fetchOrderNonce = async ({ address, chainId }) => {
|
1078
|
-
return fetch(`${HYPERCERTS_MARKETPLACE_API_URL}/marketplace/order-nonce/`, {
|
1079
|
-
method: "POST",
|
1080
|
-
headers: {
|
1081
|
-
"Content-Type": "application/json",
|
1082
|
-
},
|
1083
|
-
body: JSON.stringify({
|
1084
|
-
address,
|
1085
|
-
chainId,
|
1086
|
-
}),
|
1087
|
-
})
|
1088
|
-
.then((res) => res.json())
|
1089
|
-
.then((res) => res.data);
|
1090
|
-
};
|
1091
|
-
const createOrder = async ({ order, signer, signature, quoteType, chainId, }) => {
|
1092
|
-
const { globalNonce, ...orderWithoutGlobalNonce } = order;
|
1093
|
-
return fetch(`${HYPERCERTS_MARKETPLACE_API_URL}/marketplace/order/`, {
|
1094
|
-
method: "POST",
|
1095
|
-
headers: {
|
1096
|
-
"Content-Type": "application/json",
|
1097
|
-
},
|
1098
|
-
body: JSON.stringify({
|
1099
|
-
...orderWithoutGlobalNonce,
|
1100
|
-
globalNonce: globalNonce.toString(10),
|
1101
|
-
price: order.price.toString(10),
|
1102
|
-
quoteType,
|
1103
|
-
signer,
|
1104
|
-
signature,
|
1105
|
-
chainId,
|
1106
|
-
}),
|
1107
|
-
}).then((res) => res.json());
|
1108
|
-
};
|
1109
|
-
const fetchOrdersByHypercertId = async ({ hypercertId, chainId }) => {
|
1110
|
-
const hypercertsClient = new HypercertClient({
|
1111
|
-
chain: { id: chainId },
|
1112
|
-
});
|
1113
|
-
const fractions = await hypercertsClient.indexer.fractionsByClaim(hypercertId);
|
1114
|
-
const tokenIds = fractions.claimTokens.map((fraction) => fraction.tokenID);
|
1115
|
-
return supabaseHypercerts.from("marketplace-orders").select("*").containedBy("itemIds", tokenIds).throwOnError();
|
1116
|
-
};
|
1117
|
-
|
1118
|
-
var api = /*#__PURE__*/Object.freeze({
|
1119
|
-
__proto__: null,
|
1120
|
-
createOrder: createOrder,
|
1121
|
-
fetchOrderNonce: fetchOrderNonce,
|
1122
|
-
fetchOrdersByHypercertId: fetchOrdersByHypercertId,
|
1123
|
-
supabaseHypercerts: supabaseHypercerts
|
1124
|
-
});
|
1125
|
-
|
1126
1094
|
const sepoliaAddresses = {
|
1127
1095
|
EXCHANGE_V2: deployments[11155111].addresses?.HypercertExchange,
|
1128
1096
|
TRANSFER_MANAGER_V2: deployments[11155111].addresses?.TransferManager,
|
1129
1097
|
ORDER_VALIDATOR_V2: deployments[11155111].addresses?.OrderValidator,
|
1130
1098
|
WETH: "0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9",
|
1099
|
+
MINTER: deployments[11155111].addresses?.HypercertMinterUUPS,
|
1131
1100
|
};
|
1132
1101
|
/**
|
1133
1102
|
* List of useful contract addresses
|
1134
1103
|
*/
|
1135
1104
|
const addressesByNetwork = {
|
1136
1105
|
[ChainId.SEPOLIA]: sepoliaAddresses,
|
1106
|
+
[ChainId.HARDHAT]: sepoliaAddresses,
|
1137
1107
|
};
|
1138
1108
|
|
1139
1109
|
const chainInfo = {
|
1140
|
-
[ChainId.GOERLI]: {
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
},
|
1110
|
+
// [ChainId.GOERLI]: {
|
1111
|
+
// label: "Goerli",
|
1112
|
+
// appUrl: "https://goerli.looksrare.org",
|
1113
|
+
// explorer: "https://goerli.etherscan.io",
|
1114
|
+
// rpcUrl: "https://eth-goerli.g.alchemy.com/v2",
|
1115
|
+
// baseApiUrl: "https://graphql-goerli.looksrare.org",
|
1116
|
+
// osApiUrl: "https://testnets-api.opensea.io",
|
1117
|
+
// },
|
1148
1118
|
[ChainId.SEPOLIA]: {
|
1149
1119
|
label: "Sepolia",
|
1150
1120
|
appUrl: "https://sepolia.looksrare.org",
|
@@ -4832,11 +4802,82 @@ const contractName = "LooksRareProtocol";
|
|
4832
4802
|
*/
|
4833
4803
|
const version = 2;
|
4834
4804
|
|
4805
|
+
const HYPERCERTS_MARKETPLACE_API_URL = "http://localhost:3000/api";
|
4806
|
+
const SUPABASE_HYPERCERTS_URL = "https://clagjjfinooizoqdkvqc.supabase.co";
|
4807
|
+
const SUPABASE_HYPERCERTS_ANON_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNsYWdqamZpbm9vaXpvcWRrdnFjIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NzY5NTAxNDAsImV4cCI6MTk5MjUyNjE0MH0.LOIW3NcYEfF7w893PS3Ne1VrntACE3OPeSRFkspvyqw";
|
4808
|
+
const supabaseHypercerts = createClient(SUPABASE_HYPERCERTS_URL, SUPABASE_HYPERCERTS_ANON_KEY);
|
4809
|
+
/**
|
4810
|
+
* Fetches order nonce from api
|
4811
|
+
* @param address Address
|
4812
|
+
* @param chainId Chain ID
|
4813
|
+
*/
|
4814
|
+
const fetchOrderNonce = async ({ address, chainId }) => {
|
4815
|
+
return fetch(`${HYPERCERTS_MARKETPLACE_API_URL}/marketplace/order-nonce/`, {
|
4816
|
+
method: "POST",
|
4817
|
+
headers: {
|
4818
|
+
"Content-Type": "application/json",
|
4819
|
+
},
|
4820
|
+
body: JSON.stringify({
|
4821
|
+
address,
|
4822
|
+
chainId,
|
4823
|
+
}),
|
4824
|
+
})
|
4825
|
+
.then((res) => res.json())
|
4826
|
+
.then((res) => res.data);
|
4827
|
+
};
|
4828
|
+
/**
|
4829
|
+
* Registers order in api
|
4830
|
+
* @param order Order
|
4831
|
+
* @param signer Signer
|
4832
|
+
* @param signature Signature
|
4833
|
+
* @param quoteType Quote type
|
4834
|
+
* @param chainId Chain ID
|
4835
|
+
*/
|
4836
|
+
const registerOrder = async ({ order, signer, signature, quoteType, chainId, }) => {
|
4837
|
+
const { globalNonce, ...orderWithoutGlobalNonce } = order;
|
4838
|
+
return fetch(`${HYPERCERTS_MARKETPLACE_API_URL}/marketplace/order/`, {
|
4839
|
+
method: "POST",
|
4840
|
+
headers: {
|
4841
|
+
"Content-Type": "application/json",
|
4842
|
+
},
|
4843
|
+
body: JSON.stringify({
|
4844
|
+
...orderWithoutGlobalNonce,
|
4845
|
+
globalNonce: globalNonce.toString(10),
|
4846
|
+
price: order.price.toString(10),
|
4847
|
+
quoteType,
|
4848
|
+
signer,
|
4849
|
+
signature,
|
4850
|
+
chainId,
|
4851
|
+
}),
|
4852
|
+
}).then((res) => res.json());
|
4853
|
+
};
|
4854
|
+
/**
|
4855
|
+
* Fetches orders from api by hypercert ID
|
4856
|
+
* @param hypercertId Hypercert ID
|
4857
|
+
* @param chainId Chain ID
|
4858
|
+
*/
|
4859
|
+
const fetchOrdersByHypercertId = async ({ hypercertId, chainId }) => {
|
4860
|
+
const hypercertsClient = new HypercertClient({
|
4861
|
+
chain: { id: chainId },
|
4862
|
+
});
|
4863
|
+
const fractions = await hypercertsClient.indexer.fractionsByClaim(hypercertId);
|
4864
|
+
const tokenIds = fractions.claimTokens.map((fraction) => fraction.tokenID);
|
4865
|
+
return supabaseHypercerts.from("marketplace-orders").select("*").containedBy("itemIds", tokenIds).throwOnError();
|
4866
|
+
};
|
4867
|
+
|
4868
|
+
var api = /*#__PURE__*/Object.freeze({
|
4869
|
+
__proto__: null,
|
4870
|
+
fetchOrderNonce: fetchOrderNonce,
|
4871
|
+
fetchOrdersByHypercertId: fetchOrdersByHypercertId,
|
4872
|
+
registerOrder: registerOrder,
|
4873
|
+
supabaseHypercerts: supabaseHypercerts
|
4874
|
+
});
|
4875
|
+
|
4835
4876
|
/**
|
4836
4877
|
* LooksRare
|
4837
4878
|
* This class provides helpers to interact with the LooksRare V2 contracts
|
4838
4879
|
*/
|
4839
|
-
class
|
4880
|
+
class HypercertExchangeClient {
|
4840
4881
|
/**
|
4841
4882
|
* LooksRare protocol main class
|
4842
4883
|
* @param chainId Current app chain id
|
@@ -4847,8 +4888,10 @@ class LooksRare {
|
|
4847
4888
|
constructor(chainId, provider, signer, override) {
|
4848
4889
|
this.chainId = chainId;
|
4849
4890
|
this.addresses = override ?? addressesByNetwork[this.chainId];
|
4891
|
+
console.log("Addresses", this.addresses);
|
4850
4892
|
this.signer = signer;
|
4851
4893
|
this.provider = provider;
|
4894
|
+
this.api = api;
|
4852
4895
|
}
|
4853
4896
|
/**
|
4854
4897
|
* Return the signer it it's set, throw an exception otherwise
|
@@ -5060,6 +5103,7 @@ class LooksRare {
|
|
5060
5103
|
*/
|
5061
5104
|
async signMakerOrder(maker) {
|
5062
5105
|
const signer = this.getSigner();
|
5106
|
+
console.log("signing against", this.getTypedDataDomain(), maker);
|
5063
5107
|
return await signMakerOrder(signer, this.getTypedDataDomain(), maker);
|
5064
5108
|
}
|
5065
5109
|
/**
|
@@ -5226,6 +5270,106 @@ class LooksRare {
|
|
5226
5270
|
async strategyInfo(strategyId, overrides) {
|
5227
5271
|
return strategyInfo(this.provider, this.addresses.EXCHANGE_V2, strategyId, overrides);
|
5228
5272
|
}
|
5273
|
+
/**
|
5274
|
+
* Create a maker ask for a collection or singular offer of fractions
|
5275
|
+
* @param itemIds Token IDs of the fractions to be sold
|
5276
|
+
* @param price Price of the fractions in wei
|
5277
|
+
* @param startTime Timestamp in seconds when the order becomes valid
|
5278
|
+
* @param endTime Timestamp in seconds when the order becomes invalid
|
5279
|
+
* @param additionalParameters Additional parameters used to support complex orders
|
5280
|
+
*/
|
5281
|
+
async createDirectFractionsSaleMakerAsk({ itemIds, price, startTime, endTime, additionalParameters = [], }) {
|
5282
|
+
const address = await this.signer?.getAddress();
|
5283
|
+
if (!address) {
|
5284
|
+
throw new Error("No signer address could be determined");
|
5285
|
+
}
|
5286
|
+
const chainId = this.chainId;
|
5287
|
+
const { nonce_counter } = await fetchOrderNonce({
|
5288
|
+
address,
|
5289
|
+
chainId,
|
5290
|
+
});
|
5291
|
+
const amounts = Array.from({ length: itemIds.length }, () => 1);
|
5292
|
+
return this.createMakerAsk({
|
5293
|
+
// Defaults
|
5294
|
+
strategyId: StrategyType.standard,
|
5295
|
+
collectionType: 2,
|
5296
|
+
collection: this.addresses.MINTER,
|
5297
|
+
subsetNonce: 0,
|
5298
|
+
currency: this.addresses.WETH,
|
5299
|
+
amounts,
|
5300
|
+
orderNonce: nonce_counter.toString(),
|
5301
|
+
// User specified
|
5302
|
+
itemIds,
|
5303
|
+
price,
|
5304
|
+
startTime,
|
5305
|
+
endTime,
|
5306
|
+
additionalParameters,
|
5307
|
+
});
|
5308
|
+
}
|
5309
|
+
async createFractionalSaleMakerAsk({ itemIds, price, startTime, endTime, maxUnitAmount, minUnitAmount, minUnitsToKeep, sellLeftoverFraction, root, }) {
|
5310
|
+
const address = await this.signer?.getAddress();
|
5311
|
+
if (!address) {
|
5312
|
+
throw new Error("No signer address could be determined");
|
5313
|
+
}
|
5314
|
+
const chainId = this.chainId;
|
5315
|
+
const { nonce_counter } = await fetchOrderNonce({
|
5316
|
+
address,
|
5317
|
+
chainId,
|
5318
|
+
});
|
5319
|
+
const amounts = Array.from({ length: itemIds.length }, () => 1);
|
5320
|
+
const sharedArgs = {
|
5321
|
+
// Defaults
|
5322
|
+
collectionType: 2,
|
5323
|
+
collection: this.addresses.MINTER,
|
5324
|
+
subsetNonce: 0,
|
5325
|
+
currency: this.addresses.WETH,
|
5326
|
+
amounts,
|
5327
|
+
orderNonce: nonce_counter.toString(),
|
5328
|
+
// User specified
|
5329
|
+
itemIds,
|
5330
|
+
price,
|
5331
|
+
startTime,
|
5332
|
+
endTime,
|
5333
|
+
};
|
5334
|
+
if (root) {
|
5335
|
+
return this.createMakerAsk({
|
5336
|
+
...sharedArgs,
|
5337
|
+
strategyId: StrategyType.hypercertFractionOfferWithAllowlist,
|
5338
|
+
additionalParameters: [minUnitAmount, maxUnitAmount, minUnitsToKeep, sellLeftoverFraction, root],
|
5339
|
+
});
|
5340
|
+
}
|
5341
|
+
return this.createMakerAsk({
|
5342
|
+
...sharedArgs,
|
5343
|
+
strategyId: StrategyType.hypercertFractionOffer,
|
5344
|
+
additionalParameters: [minUnitAmount, maxUnitAmount, minUnitsToKeep, sellLeftoverFraction],
|
5345
|
+
});
|
5346
|
+
}
|
5347
|
+
createFractionalSaleTakerBid(maker, recipient = ZeroAddress, unitAmount, pricePerUnit) {
|
5348
|
+
const order = {
|
5349
|
+
recipient: recipient,
|
5350
|
+
additionalParameters: encodeParams([unitAmount, pricePerUnit], getTakerParamsTypes(maker.strategyId)),
|
5351
|
+
};
|
5352
|
+
return order;
|
5353
|
+
}
|
5354
|
+
/**
|
5355
|
+
* Register the order with hypercerts marketplace API.
|
5356
|
+
* @param order Maker order
|
5357
|
+
* @param signature Signature of the maker order
|
5358
|
+
*/
|
5359
|
+
async registerOrder({ order, signature }) {
|
5360
|
+
const address = await this.signer?.getAddress();
|
5361
|
+
if (!address) {
|
5362
|
+
throw new Error("No signer address could be determined");
|
5363
|
+
}
|
5364
|
+
const chainId = this.chainId;
|
5365
|
+
return registerOrder({
|
5366
|
+
order,
|
5367
|
+
signer: address,
|
5368
|
+
signature,
|
5369
|
+
quoteType: order.quoteType,
|
5370
|
+
chainId,
|
5371
|
+
});
|
5372
|
+
}
|
5229
5373
|
}
|
5230
5374
|
|
5231
5375
|
const utils = {
|
@@ -5239,7 +5383,6 @@ const utils = {
|
|
5239
5383
|
...signMakerOrders,
|
5240
5384
|
...eip712,
|
5241
5385
|
...asDeployedChain$1,
|
5242
|
-
api,
|
5243
5386
|
};
|
5244
5387
|
|
5245
|
-
export { ChainId, CollectionType, Eip712MakerMerkleTree, Eip712MerkleTree, ErrorItemId, ErrorMerkleTreeDepth, ErrorQuoteType, ErrorSigner, ErrorStrategyType, ErrorTimestamp, IERC1155 as IERC1155Abi, abiIERC20 as IERC20Abi, abiIERC721 as IERC721Abi,
|
5388
|
+
export { ChainId, CollectionType, Eip712MakerMerkleTree, Eip712MerkleTree, ErrorItemId, ErrorMerkleTreeDepth, ErrorQuoteType, ErrorSigner, ErrorStrategyType, ErrorTimestamp, HypercertExchangeClient, IERC1155 as IERC1155Abi, abiIERC20 as IERC20Abi, abiIERC721 as IERC721Abi, LooksRareProtocol as LooksRareProtocolAbi, MAX_ORDERS_PER_TREE, MerkleTreeNodePosition, OrderValidatorCode, OrderValidatorV2A as OrderValidatorV2AAbi, QuoteType, StrategyType, TransferManager as TransferManagerAbi, WETH as WETHAbi, addressesByNetwork, chainInfo, defaultMerkleTree, utils };
|
package/dist/types.d.ts
CHANGED
@@ -6,10 +6,12 @@ export interface Addresses {
|
|
6
6
|
TRANSFER_MANAGER_V2: `0x${string}`;
|
7
7
|
WETH: `0x${string}`;
|
8
8
|
ORDER_VALIDATOR_V2: `0x${string}`;
|
9
|
+
MINTER: `0x${string}`;
|
9
10
|
}
|
10
11
|
/** List of supported chains */
|
11
12
|
export declare enum ChainId {
|
12
|
-
SEPOLIA = 11155111
|
13
|
+
SEPOLIA = 11155111,
|
14
|
+
HARDHAT = 31337
|
13
15
|
}
|
14
16
|
/** ChainInfo data used to interact with LooksRare ecosystem */
|
15
17
|
export interface ChainInfo {
|
@@ -31,7 +33,15 @@ export declare enum CollectionType {
|
|
31
33
|
export declare enum StrategyType {
|
32
34
|
standard = 0,
|
33
35
|
collection = 1,
|
34
|
-
collectionWithMerkleTree = 2
|
36
|
+
collectionWithMerkleTree = 2,
|
37
|
+
dutchAuction = 4,
|
38
|
+
itemIdsRange = 5,
|
39
|
+
hypercertCollectionOffer = 6,
|
40
|
+
hypercertCollectionOfferWithProof = 7,
|
41
|
+
hypercertCollectionOfferWithAllowlist = 8,
|
42
|
+
hypercertDutchAuction = 9,
|
43
|
+
hypercertFractionOffer = 10,
|
44
|
+
hypercertFractionOfferWithAllowlist = 11
|
35
45
|
}
|
36
46
|
/** Type for maker order */
|
37
47
|
export declare enum QuoteType {
|
package/dist/utils/api.d.ts
CHANGED
@@ -724,6 +724,11 @@ export declare const supabaseHypercerts: import("@supabase/supabase-js").Supabas
|
|
724
724
|
Enums: {};
|
725
725
|
CompositeTypes: {};
|
726
726
|
}>;
|
727
|
+
/**
|
728
|
+
* Fetches order nonce from api
|
729
|
+
* @param address Address
|
730
|
+
* @param chainId Chain ID
|
731
|
+
*/
|
727
732
|
export declare const fetchOrderNonce: ({ address, chainId }: {
|
728
733
|
address: string;
|
729
734
|
chainId: number;
|
@@ -732,7 +737,15 @@ export declare const fetchOrderNonce: ({ address, chainId }: {
|
|
732
737
|
address: string;
|
733
738
|
chain_id: number;
|
734
739
|
}>;
|
735
|
-
|
740
|
+
/**
|
741
|
+
* Registers order in api
|
742
|
+
* @param order Order
|
743
|
+
* @param signer Signer
|
744
|
+
* @param signature Signature
|
745
|
+
* @param quoteType Quote type
|
746
|
+
* @param chainId Chain ID
|
747
|
+
*/
|
748
|
+
export declare const registerOrder: ({ order, signer, signature, quoteType, chainId, }: {
|
736
749
|
order: Maker;
|
737
750
|
signer: string;
|
738
751
|
signature: string;
|
@@ -741,6 +754,11 @@ export declare const createOrder: ({ order, signer, signature, quoteType, chainI
|
|
741
754
|
}) => Promise<{
|
742
755
|
success: boolean;
|
743
756
|
}>;
|
757
|
+
/**
|
758
|
+
* Fetches orders from api by hypercert ID
|
759
|
+
* @param hypercertId Hypercert ID
|
760
|
+
* @param chainId Chain ID
|
761
|
+
*/
|
744
762
|
export declare const fetchOrdersByHypercertId: ({ hypercertId, chainId }: {
|
745
763
|
hypercertId: string;
|
746
764
|
chainId: number;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@hypercerts-org/marketplace-sdk",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.18",
|
4
4
|
"license": "MIT",
|
5
5
|
"main": "dist/index.cjs.js",
|
6
6
|
"module": "dist/index.esm.js",
|
@@ -91,7 +91,7 @@
|
|
91
91
|
"typescript": "^5.3.3"
|
92
92
|
},
|
93
93
|
"dependencies": {
|
94
|
-
"@hypercerts-org/sdk": "
|
94
|
+
"@hypercerts-org/sdk": "1.4.2-alpha.2",
|
95
95
|
"@supabase/supabase-js": "^2.39.2",
|
96
96
|
"ethers": "^6.6.2",
|
97
97
|
"merkletreejs": "^0.3.9"
|