@hypercerts-org/marketplace-sdk 0.3.36 → 0.3.37
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/constants/addresses.d.ts +0 -3
- package/dist/errors.d.ts +5 -0
- package/dist/index.cjs.js +106 -72
- package/dist/index.esm.js +106 -74
- package/dist/types.d.ts +5 -8
- package/package.json +3 -3
package/dist/errors.d.ts
CHANGED
package/dist/index.cjs.js
CHANGED
@@ -684,6 +684,8 @@ var strategies = /*#__PURE__*/Object.freeze({
|
|
684
684
|
strategyInfo: strategyInfo
|
685
685
|
});
|
686
686
|
|
687
|
+
/** All possible supported currencies */
|
688
|
+
const SUPPORTED_CURRENCIES = ["ETH", "WETH", "DAI", "CELO", "cUSD", "USDT", "USDC"];
|
687
689
|
/** List of supported chains */
|
688
690
|
exports.ChainId = void 0;
|
689
691
|
(function (ChainId) {
|
@@ -692,7 +694,6 @@ exports.ChainId = void 0;
|
|
692
694
|
ChainId[ChainId["HARDHAT"] = 31337] = "HARDHAT";
|
693
695
|
ChainId[ChainId["OPTIMISM"] = 10] = "OPTIMISM";
|
694
696
|
ChainId[ChainId["CELO"] = 42220] = "CELO";
|
695
|
-
ChainId[ChainId["BASE"] = 8453] = "BASE";
|
696
697
|
ChainId[ChainId["ARBITRUM_SEPOLIA"] = 421614] = "ARBITRUM_SEPOLIA";
|
697
698
|
ChainId[ChainId["ARBITRUM"] = 42161] = "ARBITRUM";
|
698
699
|
})(exports.ChainId || (exports.ChainId = {}));
|
@@ -1099,48 +1100,46 @@ var asDeployedChain$1 = /*#__PURE__*/Object.freeze({
|
|
1099
1100
|
asDeployedChain: asDeployedChain
|
1100
1101
|
});
|
1101
1102
|
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
}
|
1108
|
-
const
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
}
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1103
|
+
function getRequiredAddress(chainId, contractName) {
|
1104
|
+
const chainIdStr = chainId.toString();
|
1105
|
+
const deployment = contracts.deployments[chainIdStr];
|
1106
|
+
if (!deployment) {
|
1107
|
+
throw new Error(`Missing deployment for chain ${chainId}`);
|
1108
|
+
}
|
1109
|
+
const address = deployment[contractName];
|
1110
|
+
if (!address) {
|
1111
|
+
throw new Error(`Missing required address for ${contractName} on chain ${chainId}`);
|
1112
|
+
}
|
1113
|
+
return ethers.getAddress(address);
|
1114
|
+
}
|
1115
|
+
// Helper function to create addresses for a network
|
1116
|
+
const createNetworkAddresses = (chainId) => ({
|
1117
|
+
EXCHANGE_V2: getRequiredAddress(chainId, "HypercertExchange"),
|
1118
|
+
TRANSFER_MANAGER_V2: getRequiredAddress(chainId, "TransferManager"),
|
1119
|
+
ORDER_VALIDATOR_V2: getRequiredAddress(chainId, "OrderValidatorV2A"),
|
1120
|
+
MINTER: getRequiredAddress(chainId, "HypercertMinterUUPS"),
|
1121
|
+
});
|
1122
|
+
// Network chain IDs
|
1123
|
+
const CHAIN_IDS = {
|
1124
|
+
// Testnets
|
1125
|
+
SEPOLIA: 11155111,
|
1126
|
+
BASE_SEPOLIA: 84532,
|
1127
|
+
ARBITRUM_SEPOLIA: 421614,
|
1128
|
+
// Mainnets
|
1129
|
+
OPTIMISM: 10,
|
1130
|
+
CELO: 42220,
|
1131
|
+
ARBITRUM: 42161,
|
1131
1132
|
};
|
1132
|
-
/**
|
1133
|
-
* List of useful contract addresses
|
1134
|
-
*/
|
1135
1133
|
const addressesByNetwork = {
|
1136
1134
|
// Testnets
|
1137
|
-
[exports.ChainId.SEPOLIA]:
|
1138
|
-
[exports.ChainId.HARDHAT]:
|
1139
|
-
[exports.ChainId.BASE_SEPOLIA]:
|
1135
|
+
[exports.ChainId.SEPOLIA]: createNetworkAddresses(CHAIN_IDS.SEPOLIA),
|
1136
|
+
[exports.ChainId.HARDHAT]: createNetworkAddresses(CHAIN_IDS.SEPOLIA), // Using Sepolia for Hardhat
|
1137
|
+
[exports.ChainId.BASE_SEPOLIA]: createNetworkAddresses(CHAIN_IDS.BASE_SEPOLIA),
|
1138
|
+
[exports.ChainId.ARBITRUM_SEPOLIA]: createNetworkAddresses(CHAIN_IDS.ARBITRUM_SEPOLIA),
|
1140
1139
|
// Production nets
|
1141
|
-
[exports.ChainId.OPTIMISM]:
|
1142
|
-
[exports.ChainId.CELO]:
|
1143
|
-
[exports.ChainId.
|
1140
|
+
[exports.ChainId.OPTIMISM]: createNetworkAddresses(CHAIN_IDS.OPTIMISM),
|
1141
|
+
[exports.ChainId.CELO]: createNetworkAddresses(CHAIN_IDS.CELO),
|
1142
|
+
[exports.ChainId.ARBITRUM]: createNetworkAddresses(CHAIN_IDS.ARBITRUM),
|
1144
1143
|
};
|
1145
1144
|
|
1146
1145
|
const currencyAddressesPerChain = {
|
@@ -1175,16 +1174,10 @@ const currencyAddressesPerChain = {
|
|
1175
1174
|
USDC: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
|
1176
1175
|
},
|
1177
1176
|
[exports.ChainId.CELO]: {
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
},
|
1183
|
-
[exports.ChainId.BASE]: {
|
1184
|
-
ETH: ethers.ZeroAddress,
|
1185
|
-
WETH: "0x4200000000000000000000000000000000000006",
|
1186
|
-
DAI: "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",
|
1187
|
-
USDC: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
1177
|
+
CELO: "0x471EcE3750Da237f93B8E339c536989b8978a438",
|
1178
|
+
cUSD: "0x765DE816845861e75A25fCA122bb6898B8B1282a",
|
1179
|
+
USDC: "0xcebA9300f2b948710d2653dD7B07f33A8B32118C",
|
1180
|
+
USDT: "0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e",
|
1188
1181
|
},
|
1189
1182
|
[exports.ChainId.ARBITRUM]: {
|
1190
1183
|
ETH: ethers.ZeroAddress,
|
@@ -1195,20 +1188,39 @@ const currencyAddressesPerChain = {
|
|
1195
1188
|
};
|
1196
1189
|
const getCurrencies = (chainId) => {
|
1197
1190
|
const currenciesForChain = currencyAddressesPerChain[chainId];
|
1191
|
+
if ("ETH" in currenciesForChain) {
|
1192
|
+
return {
|
1193
|
+
ETH: {
|
1194
|
+
symbol: "ETH",
|
1195
|
+
address: currenciesForChain.ETH,
|
1196
|
+
decimals: 18,
|
1197
|
+
},
|
1198
|
+
WETH: {
|
1199
|
+
symbol: "WETH",
|
1200
|
+
address: currenciesForChain.WETH,
|
1201
|
+
decimals: 18,
|
1202
|
+
},
|
1203
|
+
DAI: {
|
1204
|
+
symbol: "DAI",
|
1205
|
+
address: currenciesForChain.DAI,
|
1206
|
+
decimals: 18,
|
1207
|
+
},
|
1208
|
+
USDC: {
|
1209
|
+
symbol: "USDC",
|
1210
|
+
address: currenciesForChain.USDC,
|
1211
|
+
decimals: 6,
|
1212
|
+
},
|
1213
|
+
};
|
1214
|
+
}
|
1198
1215
|
return {
|
1199
|
-
|
1200
|
-
symbol: "
|
1201
|
-
address: currenciesForChain.
|
1202
|
-
decimals: 18,
|
1203
|
-
},
|
1204
|
-
WETH: {
|
1205
|
-
symbol: "WETH",
|
1206
|
-
address: currenciesForChain.WETH,
|
1216
|
+
CELO: {
|
1217
|
+
symbol: "CELO",
|
1218
|
+
address: currenciesForChain.CELO,
|
1207
1219
|
decimals: 18,
|
1208
1220
|
},
|
1209
|
-
|
1210
|
-
symbol: "
|
1211
|
-
address: currenciesForChain.
|
1221
|
+
cUSD: {
|
1222
|
+
symbol: "cUSD",
|
1223
|
+
address: currenciesForChain.cUSD,
|
1212
1224
|
decimals: 18,
|
1213
1225
|
},
|
1214
1226
|
USDC: {
|
@@ -1216,6 +1228,11 @@ const getCurrencies = (chainId) => {
|
|
1216
1228
|
address: currenciesForChain.USDC,
|
1217
1229
|
decimals: 6,
|
1218
1230
|
},
|
1231
|
+
USDT: {
|
1232
|
+
symbol: "USDT",
|
1233
|
+
address: currenciesForChain.USDT,
|
1234
|
+
decimals: 6,
|
1235
|
+
},
|
1219
1236
|
};
|
1220
1237
|
};
|
1221
1238
|
const currenciesByNetwork = {
|
@@ -1224,7 +1241,6 @@ const currenciesByNetwork = {
|
|
1224
1241
|
[exports.ChainId.BASE_SEPOLIA]: getCurrencies(exports.ChainId.BASE_SEPOLIA),
|
1225
1242
|
[exports.ChainId.OPTIMISM]: getCurrencies(exports.ChainId.OPTIMISM),
|
1226
1243
|
[exports.ChainId.CELO]: getCurrencies(exports.ChainId.CELO),
|
1227
|
-
[exports.ChainId.BASE]: getCurrencies(exports.ChainId.BASE),
|
1228
1244
|
[exports.ChainId.ARBITRUM_SEPOLIA]: getCurrencies(exports.ChainId.ARBITRUM_SEPOLIA),
|
1229
1245
|
[exports.ChainId.ARBITRUM]: getCurrencies(exports.ChainId.ARBITRUM),
|
1230
1246
|
};
|
@@ -1254,6 +1270,14 @@ const chainInfo = {
|
|
1254
1270
|
baseApiUrl: "https://staging-api.hypercerts.org",
|
1255
1271
|
osApiUrl: "https://testnets-api.opensea.io"
|
1256
1272
|
},
|
1273
|
+
[exports.ChainId.ARBITRUM]: {
|
1274
|
+
label: "Arbitrum",
|
1275
|
+
appUrl: "https://app.hypercerts.org",
|
1276
|
+
explorer: "https://arbitrum.io",
|
1277
|
+
rpcUrl: "https://arbitrum.io",
|
1278
|
+
baseApiUrl: "https://api.hypercerts.org",
|
1279
|
+
osApiUrl: "https://testnets-api.opensea.io"
|
1280
|
+
},
|
1257
1281
|
[exports.ChainId.ARBITRUM_SEPOLIA]: {
|
1258
1282
|
label: "Arbitrum Sepolia",
|
1259
1283
|
appUrl: "https://testnet.hypercerts.org",
|
@@ -1278,14 +1302,6 @@ const chainInfo = {
|
|
1278
1302
|
baseApiUrl: "https://api.hypercerts.org",
|
1279
1303
|
osApiUrl: "https://testnets-api.opensea.io"
|
1280
1304
|
},
|
1281
|
-
[exports.ChainId.BASE]: {
|
1282
|
-
label: "Base",
|
1283
|
-
appUrl: "https://app.hypercerts.org",
|
1284
|
-
explorer: "https://basescan.io",
|
1285
|
-
rpcUrl: "https://mainnet.base.org",
|
1286
|
-
baseApiUrl: "https://api.hypercerts.org",
|
1287
|
-
osApiUrl: "https://testnets-api.opensea.io"
|
1288
|
-
}
|
1289
1305
|
};
|
1290
1306
|
|
1291
1307
|
/** Maximum amount of orders in a merkle tree
|
@@ -1340,6 +1356,13 @@ class ErrorItemId extends Error {
|
|
1340
1356
|
this.name = "ErrorItemId";
|
1341
1357
|
}
|
1342
1358
|
}
|
1359
|
+
/** Currency is not supported */
|
1360
|
+
class ErrorCurrency extends Error {
|
1361
|
+
constructor() {
|
1362
|
+
super("Currency is not defined or supported");
|
1363
|
+
this.name = "ErrorCurrency";
|
1364
|
+
}
|
1365
|
+
}
|
1343
1366
|
|
1344
1367
|
var IERC1155 = [
|
1345
1368
|
{
|
@@ -7764,11 +7787,14 @@ class HypercertExchangeClient {
|
|
7764
7787
|
* @param CreateMakerInput
|
7765
7788
|
* @returns the maker object, isCurrencyApproved, and isBalanceSufficient
|
7766
7789
|
*/
|
7767
|
-
async createMakerBid({ collection, strategyId, collectionType, subsetNonce, orderNonce, endTime, price, itemIds, amounts = [1], currency
|
7790
|
+
async createMakerBid({ collection, strategyId, collectionType, subsetNonce, orderNonce, endTime, price, itemIds, amounts = [1], currency, startTime = Math.floor(Date.now() / 1000), additionalParameters = [], }) {
|
7768
7791
|
const signer = this.getSigner();
|
7769
7792
|
if (!this.isTimestampValid(startTime) || !this.isTimestampValid(endTime)) {
|
7770
7793
|
throw new ErrorTimestamp();
|
7771
7794
|
}
|
7795
|
+
if (!currency) {
|
7796
|
+
throw new ErrorCurrency();
|
7797
|
+
}
|
7772
7798
|
const signerAddress = await signer.getAddress();
|
7773
7799
|
const spenderAddress = this.addresses.EXCHANGE_V2;
|
7774
7800
|
// Use this.provider (MulticallProvider) in order to batch the calls
|
@@ -8112,11 +8138,14 @@ class HypercertExchangeClient {
|
|
8112
8138
|
* @param currency Currency used to buy the fractions (default to WETH)
|
8113
8139
|
* @param additionalParameters Additional parameters used to support complex orders
|
8114
8140
|
*/
|
8115
|
-
async createDirectFractionsSaleMakerAsk({ itemIds, price, startTime, endTime, currency
|
8141
|
+
async createDirectFractionsSaleMakerAsk({ itemIds, price, startTime, endTime, currency, additionalParameters = [], }) {
|
8116
8142
|
const address = await this.signer?.getAddress();
|
8117
8143
|
if (!address) {
|
8118
8144
|
throw new Error("No signer address could be determined");
|
8119
8145
|
}
|
8146
|
+
if (!currency) {
|
8147
|
+
throw new ErrorCurrency();
|
8148
|
+
}
|
8120
8149
|
const chainId = this.chainId;
|
8121
8150
|
const { nonce_counter } = await this.api.fetchOrderNonce({
|
8122
8151
|
address,
|
@@ -8153,11 +8182,14 @@ class HypercertExchangeClient {
|
|
8153
8182
|
* @param sellLeftoverFraction Whether or not the seller wants to sell the leftover units
|
8154
8183
|
* @param root Merkle tree root (optional)
|
8155
8184
|
*/
|
8156
|
-
async createFractionalSaleMakerAsk({ itemIds, price, startTime, endTime, currency
|
8185
|
+
async createFractionalSaleMakerAsk({ itemIds, price, startTime, endTime, currency, maxUnitAmount, minUnitAmount, minUnitsToKeep, sellLeftoverFraction, root, }) {
|
8157
8186
|
const address = await this.signer?.getAddress();
|
8158
8187
|
if (!address) {
|
8159
8188
|
throw new Error("No signer address could be determined");
|
8160
8189
|
}
|
8190
|
+
if (!currency) {
|
8191
|
+
throw new ErrorCurrency();
|
8192
|
+
}
|
8161
8193
|
const chainId = this.chainId;
|
8162
8194
|
const { nonce_counter } = await this.api.fetchOrderNonce({
|
8163
8195
|
address,
|
@@ -8253,6 +8285,7 @@ const utils = {
|
|
8253
8285
|
exports.ApiClient = ApiClient;
|
8254
8286
|
exports.Eip712MakerMerkleTree = Eip712MakerMerkleTree;
|
8255
8287
|
exports.Eip712MerkleTree = Eip712MerkleTree;
|
8288
|
+
exports.ErrorCurrency = ErrorCurrency;
|
8256
8289
|
exports.ErrorItemId = ErrorItemId;
|
8257
8290
|
exports.ErrorMerkleTreeDepth = ErrorMerkleTreeDepth;
|
8258
8291
|
exports.ErrorQuoteType = ErrorQuoteType;
|
@@ -8266,6 +8299,7 @@ exports.IERC721Abi = abiIERC721;
|
|
8266
8299
|
exports.LooksRareProtocolAbi = LooksRareProtocol;
|
8267
8300
|
exports.MAX_ORDERS_PER_TREE = MAX_ORDERS_PER_TREE;
|
8268
8301
|
exports.OrderValidatorV2AAbi = OrderValidatorV2A;
|
8302
|
+
exports.SUPPORTED_CURRENCIES = SUPPORTED_CURRENCIES;
|
8269
8303
|
exports.TransferManagerAbi = TransferManager;
|
8270
8304
|
exports.WETHAbi = WETH;
|
8271
8305
|
exports.addressesByNetwork = addressesByNetwork;
|
package/dist/index.esm.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Contract, ZeroAddress, AbiCoder, TypedDataEncoder, keccak256, solidityPackedKeccak256, ethers, ZeroHash, MaxUint256 } from 'ethers';
|
1
|
+
import { Contract, ZeroAddress, AbiCoder, TypedDataEncoder, keccak256, solidityPackedKeccak256, ethers, getAddress, ZeroHash, MaxUint256 } from 'ethers';
|
2
2
|
import { HypercertExchangeAbi, TransferManagerAbi, OrderValidatorV2AAbi, deployments, asDeployedChain as asDeployedChain$2 } from '@hypercerts-org/contracts';
|
3
3
|
import { MerkleTree } from 'merkletreejs';
|
4
4
|
import { keccak256 as keccak256$1 } from 'js-sha3';
|
@@ -682,6 +682,8 @@ var strategies = /*#__PURE__*/Object.freeze({
|
|
682
682
|
strategyInfo: strategyInfo
|
683
683
|
});
|
684
684
|
|
685
|
+
/** All possible supported currencies */
|
686
|
+
const SUPPORTED_CURRENCIES = ["ETH", "WETH", "DAI", "CELO", "cUSD", "USDT", "USDC"];
|
685
687
|
/** List of supported chains */
|
686
688
|
var ChainId;
|
687
689
|
(function (ChainId) {
|
@@ -690,7 +692,6 @@ var ChainId;
|
|
690
692
|
ChainId[ChainId["HARDHAT"] = 31337] = "HARDHAT";
|
691
693
|
ChainId[ChainId["OPTIMISM"] = 10] = "OPTIMISM";
|
692
694
|
ChainId[ChainId["CELO"] = 42220] = "CELO";
|
693
|
-
ChainId[ChainId["BASE"] = 8453] = "BASE";
|
694
695
|
ChainId[ChainId["ARBITRUM_SEPOLIA"] = 421614] = "ARBITRUM_SEPOLIA";
|
695
696
|
ChainId[ChainId["ARBITRUM"] = 42161] = "ARBITRUM";
|
696
697
|
})(ChainId || (ChainId = {}));
|
@@ -1097,48 +1098,46 @@ var asDeployedChain$1 = /*#__PURE__*/Object.freeze({
|
|
1097
1098
|
asDeployedChain: asDeployedChain
|
1098
1099
|
});
|
1099
1100
|
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
}
|
1106
|
-
const
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
}
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1101
|
+
function getRequiredAddress(chainId, contractName) {
|
1102
|
+
const chainIdStr = chainId.toString();
|
1103
|
+
const deployment = deployments[chainIdStr];
|
1104
|
+
if (!deployment) {
|
1105
|
+
throw new Error(`Missing deployment for chain ${chainId}`);
|
1106
|
+
}
|
1107
|
+
const address = deployment[contractName];
|
1108
|
+
if (!address) {
|
1109
|
+
throw new Error(`Missing required address for ${contractName} on chain ${chainId}`);
|
1110
|
+
}
|
1111
|
+
return getAddress(address);
|
1112
|
+
}
|
1113
|
+
// Helper function to create addresses for a network
|
1114
|
+
const createNetworkAddresses = (chainId) => ({
|
1115
|
+
EXCHANGE_V2: getRequiredAddress(chainId, "HypercertExchange"),
|
1116
|
+
TRANSFER_MANAGER_V2: getRequiredAddress(chainId, "TransferManager"),
|
1117
|
+
ORDER_VALIDATOR_V2: getRequiredAddress(chainId, "OrderValidatorV2A"),
|
1118
|
+
MINTER: getRequiredAddress(chainId, "HypercertMinterUUPS"),
|
1119
|
+
});
|
1120
|
+
// Network chain IDs
|
1121
|
+
const CHAIN_IDS = {
|
1122
|
+
// Testnets
|
1123
|
+
SEPOLIA: 11155111,
|
1124
|
+
BASE_SEPOLIA: 84532,
|
1125
|
+
ARBITRUM_SEPOLIA: 421614,
|
1126
|
+
// Mainnets
|
1127
|
+
OPTIMISM: 10,
|
1128
|
+
CELO: 42220,
|
1129
|
+
ARBITRUM: 42161,
|
1129
1130
|
};
|
1130
|
-
/**
|
1131
|
-
* List of useful contract addresses
|
1132
|
-
*/
|
1133
1131
|
const addressesByNetwork = {
|
1134
1132
|
// Testnets
|
1135
|
-
[ChainId.SEPOLIA]:
|
1136
|
-
[ChainId.HARDHAT]:
|
1137
|
-
[ChainId.BASE_SEPOLIA]:
|
1133
|
+
[ChainId.SEPOLIA]: createNetworkAddresses(CHAIN_IDS.SEPOLIA),
|
1134
|
+
[ChainId.HARDHAT]: createNetworkAddresses(CHAIN_IDS.SEPOLIA), // Using Sepolia for Hardhat
|
1135
|
+
[ChainId.BASE_SEPOLIA]: createNetworkAddresses(CHAIN_IDS.BASE_SEPOLIA),
|
1136
|
+
[ChainId.ARBITRUM_SEPOLIA]: createNetworkAddresses(CHAIN_IDS.ARBITRUM_SEPOLIA),
|
1138
1137
|
// Production nets
|
1139
|
-
[ChainId.OPTIMISM]:
|
1140
|
-
[ChainId.CELO]:
|
1141
|
-
[ChainId.
|
1138
|
+
[ChainId.OPTIMISM]: createNetworkAddresses(CHAIN_IDS.OPTIMISM),
|
1139
|
+
[ChainId.CELO]: createNetworkAddresses(CHAIN_IDS.CELO),
|
1140
|
+
[ChainId.ARBITRUM]: createNetworkAddresses(CHAIN_IDS.ARBITRUM),
|
1142
1141
|
};
|
1143
1142
|
|
1144
1143
|
const currencyAddressesPerChain = {
|
@@ -1173,16 +1172,10 @@ const currencyAddressesPerChain = {
|
|
1173
1172
|
USDC: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
|
1174
1173
|
},
|
1175
1174
|
[ChainId.CELO]: {
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
},
|
1181
|
-
[ChainId.BASE]: {
|
1182
|
-
ETH: ZeroAddress,
|
1183
|
-
WETH: "0x4200000000000000000000000000000000000006",
|
1184
|
-
DAI: "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",
|
1185
|
-
USDC: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
1175
|
+
CELO: "0x471EcE3750Da237f93B8E339c536989b8978a438",
|
1176
|
+
cUSD: "0x765DE816845861e75A25fCA122bb6898B8B1282a",
|
1177
|
+
USDC: "0xcebA9300f2b948710d2653dD7B07f33A8B32118C",
|
1178
|
+
USDT: "0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e",
|
1186
1179
|
},
|
1187
1180
|
[ChainId.ARBITRUM]: {
|
1188
1181
|
ETH: ZeroAddress,
|
@@ -1193,20 +1186,39 @@ const currencyAddressesPerChain = {
|
|
1193
1186
|
};
|
1194
1187
|
const getCurrencies = (chainId) => {
|
1195
1188
|
const currenciesForChain = currencyAddressesPerChain[chainId];
|
1189
|
+
if ("ETH" in currenciesForChain) {
|
1190
|
+
return {
|
1191
|
+
ETH: {
|
1192
|
+
symbol: "ETH",
|
1193
|
+
address: currenciesForChain.ETH,
|
1194
|
+
decimals: 18,
|
1195
|
+
},
|
1196
|
+
WETH: {
|
1197
|
+
symbol: "WETH",
|
1198
|
+
address: currenciesForChain.WETH,
|
1199
|
+
decimals: 18,
|
1200
|
+
},
|
1201
|
+
DAI: {
|
1202
|
+
symbol: "DAI",
|
1203
|
+
address: currenciesForChain.DAI,
|
1204
|
+
decimals: 18,
|
1205
|
+
},
|
1206
|
+
USDC: {
|
1207
|
+
symbol: "USDC",
|
1208
|
+
address: currenciesForChain.USDC,
|
1209
|
+
decimals: 6,
|
1210
|
+
},
|
1211
|
+
};
|
1212
|
+
}
|
1196
1213
|
return {
|
1197
|
-
|
1198
|
-
symbol: "
|
1199
|
-
address: currenciesForChain.
|
1200
|
-
decimals: 18,
|
1201
|
-
},
|
1202
|
-
WETH: {
|
1203
|
-
symbol: "WETH",
|
1204
|
-
address: currenciesForChain.WETH,
|
1214
|
+
CELO: {
|
1215
|
+
symbol: "CELO",
|
1216
|
+
address: currenciesForChain.CELO,
|
1205
1217
|
decimals: 18,
|
1206
1218
|
},
|
1207
|
-
|
1208
|
-
symbol: "
|
1209
|
-
address: currenciesForChain.
|
1219
|
+
cUSD: {
|
1220
|
+
symbol: "cUSD",
|
1221
|
+
address: currenciesForChain.cUSD,
|
1210
1222
|
decimals: 18,
|
1211
1223
|
},
|
1212
1224
|
USDC: {
|
@@ -1214,6 +1226,11 @@ const getCurrencies = (chainId) => {
|
|
1214
1226
|
address: currenciesForChain.USDC,
|
1215
1227
|
decimals: 6,
|
1216
1228
|
},
|
1229
|
+
USDT: {
|
1230
|
+
symbol: "USDT",
|
1231
|
+
address: currenciesForChain.USDT,
|
1232
|
+
decimals: 6,
|
1233
|
+
},
|
1217
1234
|
};
|
1218
1235
|
};
|
1219
1236
|
const currenciesByNetwork = {
|
@@ -1222,7 +1239,6 @@ const currenciesByNetwork = {
|
|
1222
1239
|
[ChainId.BASE_SEPOLIA]: getCurrencies(ChainId.BASE_SEPOLIA),
|
1223
1240
|
[ChainId.OPTIMISM]: getCurrencies(ChainId.OPTIMISM),
|
1224
1241
|
[ChainId.CELO]: getCurrencies(ChainId.CELO),
|
1225
|
-
[ChainId.BASE]: getCurrencies(ChainId.BASE),
|
1226
1242
|
[ChainId.ARBITRUM_SEPOLIA]: getCurrencies(ChainId.ARBITRUM_SEPOLIA),
|
1227
1243
|
[ChainId.ARBITRUM]: getCurrencies(ChainId.ARBITRUM),
|
1228
1244
|
};
|
@@ -1252,6 +1268,14 @@ const chainInfo = {
|
|
1252
1268
|
baseApiUrl: "https://staging-api.hypercerts.org",
|
1253
1269
|
osApiUrl: "https://testnets-api.opensea.io"
|
1254
1270
|
},
|
1271
|
+
[ChainId.ARBITRUM]: {
|
1272
|
+
label: "Arbitrum",
|
1273
|
+
appUrl: "https://app.hypercerts.org",
|
1274
|
+
explorer: "https://arbitrum.io",
|
1275
|
+
rpcUrl: "https://arbitrum.io",
|
1276
|
+
baseApiUrl: "https://api.hypercerts.org",
|
1277
|
+
osApiUrl: "https://testnets-api.opensea.io"
|
1278
|
+
},
|
1255
1279
|
[ChainId.ARBITRUM_SEPOLIA]: {
|
1256
1280
|
label: "Arbitrum Sepolia",
|
1257
1281
|
appUrl: "https://testnet.hypercerts.org",
|
@@ -1276,14 +1300,6 @@ const chainInfo = {
|
|
1276
1300
|
baseApiUrl: "https://api.hypercerts.org",
|
1277
1301
|
osApiUrl: "https://testnets-api.opensea.io"
|
1278
1302
|
},
|
1279
|
-
[ChainId.BASE]: {
|
1280
|
-
label: "Base",
|
1281
|
-
appUrl: "https://app.hypercerts.org",
|
1282
|
-
explorer: "https://basescan.io",
|
1283
|
-
rpcUrl: "https://mainnet.base.org",
|
1284
|
-
baseApiUrl: "https://api.hypercerts.org",
|
1285
|
-
osApiUrl: "https://testnets-api.opensea.io"
|
1286
|
-
}
|
1287
1303
|
};
|
1288
1304
|
|
1289
1305
|
/** Maximum amount of orders in a merkle tree
|
@@ -1338,6 +1354,13 @@ class ErrorItemId extends Error {
|
|
1338
1354
|
this.name = "ErrorItemId";
|
1339
1355
|
}
|
1340
1356
|
}
|
1357
|
+
/** Currency is not supported */
|
1358
|
+
class ErrorCurrency extends Error {
|
1359
|
+
constructor() {
|
1360
|
+
super("Currency is not defined or supported");
|
1361
|
+
this.name = "ErrorCurrency";
|
1362
|
+
}
|
1363
|
+
}
|
1341
1364
|
|
1342
1365
|
var IERC1155 = [
|
1343
1366
|
{
|
@@ -7762,11 +7785,14 @@ class HypercertExchangeClient {
|
|
7762
7785
|
* @param CreateMakerInput
|
7763
7786
|
* @returns the maker object, isCurrencyApproved, and isBalanceSufficient
|
7764
7787
|
*/
|
7765
|
-
async createMakerBid({ collection, strategyId, collectionType, subsetNonce, orderNonce, endTime, price, itemIds, amounts = [1], currency
|
7788
|
+
async createMakerBid({ collection, strategyId, collectionType, subsetNonce, orderNonce, endTime, price, itemIds, amounts = [1], currency, startTime = Math.floor(Date.now() / 1000), additionalParameters = [], }) {
|
7766
7789
|
const signer = this.getSigner();
|
7767
7790
|
if (!this.isTimestampValid(startTime) || !this.isTimestampValid(endTime)) {
|
7768
7791
|
throw new ErrorTimestamp();
|
7769
7792
|
}
|
7793
|
+
if (!currency) {
|
7794
|
+
throw new ErrorCurrency();
|
7795
|
+
}
|
7770
7796
|
const signerAddress = await signer.getAddress();
|
7771
7797
|
const spenderAddress = this.addresses.EXCHANGE_V2;
|
7772
7798
|
// Use this.provider (MulticallProvider) in order to batch the calls
|
@@ -8110,11 +8136,14 @@ class HypercertExchangeClient {
|
|
8110
8136
|
* @param currency Currency used to buy the fractions (default to WETH)
|
8111
8137
|
* @param additionalParameters Additional parameters used to support complex orders
|
8112
8138
|
*/
|
8113
|
-
async createDirectFractionsSaleMakerAsk({ itemIds, price, startTime, endTime, currency
|
8139
|
+
async createDirectFractionsSaleMakerAsk({ itemIds, price, startTime, endTime, currency, additionalParameters = [], }) {
|
8114
8140
|
const address = await this.signer?.getAddress();
|
8115
8141
|
if (!address) {
|
8116
8142
|
throw new Error("No signer address could be determined");
|
8117
8143
|
}
|
8144
|
+
if (!currency) {
|
8145
|
+
throw new ErrorCurrency();
|
8146
|
+
}
|
8118
8147
|
const chainId = this.chainId;
|
8119
8148
|
const { nonce_counter } = await this.api.fetchOrderNonce({
|
8120
8149
|
address,
|
@@ -8151,11 +8180,14 @@ class HypercertExchangeClient {
|
|
8151
8180
|
* @param sellLeftoverFraction Whether or not the seller wants to sell the leftover units
|
8152
8181
|
* @param root Merkle tree root (optional)
|
8153
8182
|
*/
|
8154
|
-
async createFractionalSaleMakerAsk({ itemIds, price, startTime, endTime, currency
|
8183
|
+
async createFractionalSaleMakerAsk({ itemIds, price, startTime, endTime, currency, maxUnitAmount, minUnitAmount, minUnitsToKeep, sellLeftoverFraction, root, }) {
|
8155
8184
|
const address = await this.signer?.getAddress();
|
8156
8185
|
if (!address) {
|
8157
8186
|
throw new Error("No signer address could be determined");
|
8158
8187
|
}
|
8188
|
+
if (!currency) {
|
8189
|
+
throw new ErrorCurrency();
|
8190
|
+
}
|
8159
8191
|
const chainId = this.chainId;
|
8160
8192
|
const { nonce_counter } = await this.api.fetchOrderNonce({
|
8161
8193
|
address,
|
@@ -8248,4 +8280,4 @@ const utils = {
|
|
8248
8280
|
...asDeployedChain$1,
|
8249
8281
|
};
|
8250
8282
|
|
8251
|
-
export { ApiClient, 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, currenciesByNetwork, defaultMerkleTree, utils };
|
8283
|
+
export { ApiClient, ChainId, CollectionType, Eip712MakerMerkleTree, Eip712MerkleTree, ErrorCurrency, 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, SUPPORTED_CURRENCIES, StrategyType, TransferManager as TransferManagerAbi, WETH as WETHAbi, addressesByNetwork, chainInfo, currenciesByNetwork, defaultMerkleTree, utils };
|
package/dist/types.d.ts
CHANGED
@@ -7,19 +7,17 @@ export interface Addresses {
|
|
7
7
|
ORDER_VALIDATOR_V2: `0x${string}`;
|
8
8
|
MINTER: `0x${string}`;
|
9
9
|
}
|
10
|
-
/** List of supported currencies */
|
11
|
-
export interface Currencies {
|
12
|
-
ETH: Currency;
|
13
|
-
WETH: Currency;
|
14
|
-
USDC: Currency;
|
15
|
-
DAI: Currency;
|
16
|
-
}
|
17
10
|
/** Available information about a currency */
|
18
11
|
export interface Currency {
|
19
12
|
symbol: string;
|
20
13
|
address: `0x${string}`;
|
21
14
|
decimals: number;
|
22
15
|
}
|
16
|
+
/** All possible supported currencies */
|
17
|
+
export declare const SUPPORTED_CURRENCIES: readonly ["ETH", "WETH", "DAI", "CELO", "cUSD", "USDT", "USDC"];
|
18
|
+
export type SupportedCurrencySymbol = (typeof SUPPORTED_CURRENCIES)[number];
|
19
|
+
/** Type for currency configuration */
|
20
|
+
export type Currencies = Partial<Record<SupportedCurrencySymbol, Currency>>;
|
23
21
|
/** List of supported chains */
|
24
22
|
export declare enum ChainId {
|
25
23
|
SEPOLIA = 11155111,
|
@@ -27,7 +25,6 @@ export declare enum ChainId {
|
|
27
25
|
HARDHAT = 31337,
|
28
26
|
OPTIMISM = 10,
|
29
27
|
CELO = 42220,
|
30
|
-
BASE = 8453,
|
31
28
|
ARBITRUM_SEPOLIA = 421614,
|
32
29
|
ARBITRUM = 42161
|
33
30
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@hypercerts-org/marketplace-sdk",
|
3
|
-
"version": "0.3.
|
3
|
+
"version": "0.3.37",
|
4
4
|
"license": "MIT",
|
5
5
|
"main": "dist/index.cjs.js",
|
6
6
|
"module": "dist/index.esm.js",
|
@@ -48,7 +48,7 @@
|
|
48
48
|
"@0no-co/graphqlsp": "^1.12.8",
|
49
49
|
"@commitlint/cli": "^17.0.2",
|
50
50
|
"@commitlint/config-conventional": "^17.0.2",
|
51
|
-
"@hypercerts-org/contracts": "2.0.0-alpha.
|
51
|
+
"@hypercerts-org/contracts": "2.0.0-alpha.11",
|
52
52
|
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
53
53
|
"@looksrare/contracts-exchange-v1": "^1.2.0",
|
54
54
|
"@looksrare/contracts-exchange-v2": "^0.1.2",
|
@@ -93,7 +93,7 @@
|
|
93
93
|
"typescript": "^5.3.3"
|
94
94
|
},
|
95
95
|
"dependencies": {
|
96
|
-
"@hypercerts-org/sdk": "2.
|
96
|
+
"@hypercerts-org/sdk": "2.3.0",
|
97
97
|
"@supabase/supabase-js": "^2.39.2",
|
98
98
|
"@urql/core": "^5.0.4",
|
99
99
|
"ethers": "^6.6.2",
|