opensea-js 2.0.1-beta.2 → 2.0.2-beta.1
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/lib/__tests__/api/api.js +5 -3
- package/lib/__tests__/api/api.js.map +1 -1
- package/lib/__tests__/seaport/bundles.js +218 -18
- package/lib/__tests__/seaport/bundles.js.map +1 -1
- package/lib/__tests__/seaport/fees.js +0 -1
- package/lib/__tests__/seaport/fees.js.map +1 -1
- package/lib/__tests__/seaport/orders.js +218 -26
- package/lib/__tests__/seaport/orders.js.map +1 -1
- package/lib/__tests__/seaport/staticCall.js +0 -3
- package/lib/__tests__/seaport/staticCall.js.map +1 -1
- package/lib/__tests__/utils.d.ts +1 -0
- package/lib/__tests__/utils.js +9 -0
- package/lib/__tests__/utils.js.map +1 -0
- package/lib/abi/CheezeWizardsBasicTournamentAbi.json +523 -0
- package/lib/abi/DecentralandEstatesAbi.json +614 -0
- package/lib/abi/ERC1155Abi.json +2346 -0
- package/lib/abi/ERC721v3Abi.json +470 -0
- package/lib/abi/UniswapExchangeAbi.json +451 -0
- package/lib/abi/UniswapFactoryAbi.json +67 -0
- package/lib/abi/WrappedNFTAbi.json +331 -0
- package/lib/abi/WrappedNFTFactoryAbi.json +250 -0
- package/lib/constants.d.ts +2 -1
- package/lib/constants.js +4 -3
- package/lib/constants.js.map +1 -1
- package/lib/seaport.d.ts +10 -50
- package/lib/seaport.js +126 -233
- package/lib/seaport.js.map +1 -1
- package/lib/typechain/contracts/CheezeWizardsBasicTournamentAbi.d.ts +232 -0
- package/lib/typechain/contracts/CheezeWizardsBasicTournamentAbi.js +6 -0
- package/lib/typechain/contracts/CheezeWizardsBasicTournamentAbi.js.map +1 -0
- package/lib/typechain/contracts/DecentralandEstatesAbi.d.ts +189 -0
- package/lib/typechain/contracts/DecentralandEstatesAbi.js +6 -0
- package/lib/typechain/contracts/DecentralandEstatesAbi.js.map +1 -0
- package/lib/typechain/contracts/ERC1155Abi.d.ts +436 -0
- package/lib/typechain/contracts/ERC1155Abi.js +6 -0
- package/lib/typechain/contracts/ERC1155Abi.js.map +1 -0
- package/lib/typechain/contracts/ERC721v3Abi.d.ts +76 -0
- package/lib/typechain/contracts/ERC721v3Abi.js +6 -0
- package/lib/typechain/contracts/ERC721v3Abi.js.map +1 -0
- package/lib/typechain/contracts/UniswapExchangeAbi.d.ts +132 -0
- package/lib/typechain/contracts/UniswapExchangeAbi.js +6 -0
- package/lib/typechain/contracts/UniswapExchangeAbi.js.map +1 -0
- package/lib/typechain/contracts/UniswapFactoryAbi.d.ts +37 -0
- package/lib/typechain/contracts/UniswapFactoryAbi.js +6 -0
- package/lib/typechain/contracts/UniswapFactoryAbi.js.map +1 -0
- package/lib/typechain/contracts/WrappedNFTAbi.d.ts +80 -0
- package/lib/typechain/contracts/WrappedNFTAbi.js +6 -0
- package/lib/typechain/contracts/WrappedNFTAbi.js.map +1 -0
- package/lib/typechain/contracts/WrappedNFTFactoryAbi.d.ts +57 -0
- package/lib/typechain/contracts/WrappedNFTFactoryAbi.js +6 -0
- package/lib/typechain/contracts/WrappedNFTFactoryAbi.js.map +1 -0
- package/lib/typechain/contracts/types.d.ts +54 -0
- package/lib/typechain/contracts/types.js +3 -0
- package/lib/typechain/contracts/types.js.map +1 -0
- package/lib/utils/utils.d.ts +5 -0
- package/lib/utils/utils.js +11 -1
- package/lib/utils/utils.js.map +1 -1
- package/package.json +1 -1
package/lib/seaport.js
CHANGED
|
@@ -522,13 +522,13 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
522
522
|
* @param quantities The quantity of each asset to sell. Defaults to 1 for each.
|
|
523
523
|
* @param accountAddress Address of the maker's wallet
|
|
524
524
|
* @param startAmount Value of the offer, in units of the payment token (or wrapped ETH if no payment token address specified)
|
|
525
|
-
* @param expirationTime Expiration time for the order, in seconds.
|
|
525
|
+
* @param expirationTime Expiration time for the order, in seconds.
|
|
526
526
|
* @param paymentTokenAddress Optional address for using an ERC-20 token in the order. If unspecified, defaults to W-ETH
|
|
527
527
|
* @param sellOrder Optional sell order (like an English auction) to ensure fee and schema compatibility
|
|
528
528
|
* @param referrerAddress The optional address that referred the order
|
|
529
529
|
*/
|
|
530
530
|
OpenSeaPort.prototype.createBundleBuyOrder = function (_b) {
|
|
531
|
-
var assets = _b.assets, collection = _b.collection, quantities = _b.quantities, accountAddress = _b.accountAddress, startAmount = _b.startAmount, _c = _b.expirationTime, expirationTime = _c === void 0 ? 0 : _c, paymentTokenAddress = _b.paymentTokenAddress, sellOrder = _b.sellOrder, referrerAddress = _b.referrerAddress;
|
|
531
|
+
var assets = _b.assets, collection = _b.collection, quantities = _b.quantities, accountAddress = _b.accountAddress, startAmount = _b.startAmount, _c = _b.expirationTime, expirationTime = _c === void 0 ? (0, utils_1.getMaxOrderExpirationTimestamp)() : _c, paymentTokenAddress = _b.paymentTokenAddress, sellOrder = _b.sellOrder, referrerAddress = _b.referrerAddress;
|
|
532
532
|
return __awaiter(this, void 0, void 0, function () {
|
|
533
533
|
var order, hashedOrder, signature, error_1, orderWithSignature;
|
|
534
534
|
return __generator(this, function (_d) {
|
|
@@ -545,11 +545,11 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
545
545
|
return [4 /*yield*/, this._makeBundleBuyOrder({
|
|
546
546
|
assets: assets,
|
|
547
547
|
collection: collection,
|
|
548
|
-
quantities: quantities
|
|
548
|
+
quantities: quantities,
|
|
549
549
|
accountAddress: accountAddress,
|
|
550
550
|
startAmount: startAmount,
|
|
551
551
|
expirationTime: expirationTime,
|
|
552
|
-
paymentTokenAddress: paymentTokenAddress
|
|
552
|
+
paymentTokenAddress: paymentTokenAddress,
|
|
553
553
|
extraBountyBasisPoints: 0,
|
|
554
554
|
sellOrder: sellOrder,
|
|
555
555
|
referrerAddress: referrerAddress,
|
|
@@ -593,13 +593,13 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
593
593
|
* @param accountAddress Address of the maker's wallet
|
|
594
594
|
* @param startAmount Value of the offer, in units of the payment token (or wrapped ETH if no payment token address specified)
|
|
595
595
|
* @param quantity The number of assets to bid for (if fungible or semi-fungible). Defaults to 1. In units, not base units, e.g. not wei.
|
|
596
|
-
* @param expirationTime Expiration time for the order, in seconds.
|
|
596
|
+
* @param expirationTime Expiration time for the order, in seconds.
|
|
597
597
|
* @param paymentTokenAddress Optional address for using an ERC-20 token in the order. If unspecified, defaults to W-ETH
|
|
598
598
|
* @param sellOrder Optional sell order (like an English auction) to ensure fee and schema compatibility
|
|
599
599
|
* @param referrerAddress The optional address that referred the order
|
|
600
600
|
*/
|
|
601
601
|
OpenSeaPort.prototype.createBuyOrder = function (_b) {
|
|
602
|
-
var asset = _b.asset, accountAddress = _b.accountAddress, startAmount = _b.startAmount, _c = _b.quantity, quantity = _c === void 0 ? 1 : _c, _d = _b.expirationTime, expirationTime = _d === void 0 ? 0 : _d, paymentTokenAddress = _b.paymentTokenAddress, sellOrder = _b.sellOrder, referrerAddress = _b.referrerAddress;
|
|
602
|
+
var asset = _b.asset, accountAddress = _b.accountAddress, startAmount = _b.startAmount, _c = _b.quantity, quantity = _c === void 0 ? 1 : _c, _d = _b.expirationTime, expirationTime = _d === void 0 ? (0, utils_1.getMaxOrderExpirationTimestamp)() : _d, paymentTokenAddress = _b.paymentTokenAddress, sellOrder = _b.sellOrder, referrerAddress = _b.referrerAddress;
|
|
603
603
|
return __awaiter(this, void 0, void 0, function () {
|
|
604
604
|
var order, hashedOrder, signature, error_2, orderWithSignature;
|
|
605
605
|
return __generator(this, function (_e) {
|
|
@@ -617,7 +617,7 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
617
617
|
accountAddress: accountAddress,
|
|
618
618
|
startAmount: startAmount,
|
|
619
619
|
expirationTime: expirationTime,
|
|
620
|
-
paymentTokenAddress: paymentTokenAddress
|
|
620
|
+
paymentTokenAddress: paymentTokenAddress,
|
|
621
621
|
extraBountyBasisPoints: 0,
|
|
622
622
|
sellOrder: sellOrder,
|
|
623
623
|
referrerAddress: referrerAddress,
|
|
@@ -665,7 +665,7 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
665
665
|
* @param endAmount Optional price of the asset at the end of its expiration time. Units are in the amount of a token above the token's decimal places (integer part). For example, for ether, expected units are in ETH, not wei.
|
|
666
666
|
* @param quantity The number of assets to sell (if fungible or semi-fungible). Defaults to 1. In units, not base units, e.g. not wei.
|
|
667
667
|
* @param listingTime Optional time when the order will become fulfillable, in UTC seconds. Undefined means it will start now.
|
|
668
|
-
* @param expirationTime Expiration time for the order, in UTC seconds.
|
|
668
|
+
* @param expirationTime Expiration time for the order, in UTC seconds.
|
|
669
669
|
* @param waitForHighestBid If set to true, this becomes an English auction that increases in price for every bid. The highest bid wins when the auction expires, as long as it's at least `startAmount`. `expirationTime` must be > 0.
|
|
670
670
|
* @param englishAuctionReservePrice Optional price level, below which orders may be placed but will not be matched. Orders below the reserve can be manually accepted but will not be automatically matched.
|
|
671
671
|
* @param paymentTokenAddress Address of the ERC-20 token to accept in return. If undefined or null, uses Ether.
|
|
@@ -674,7 +674,7 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
674
674
|
* @param buyerEmail Optional email of the user that's allowed to purchase this item. If specified, a user will have to verify this email before being able to take the order.
|
|
675
675
|
*/
|
|
676
676
|
OpenSeaPort.prototype.createSellOrder = function (_b) {
|
|
677
|
-
var asset = _b.asset, accountAddress = _b.accountAddress, startAmount = _b.startAmount, endAmount = _b.endAmount, _c = _b.quantity, quantity = _c === void 0 ? 1 : _c, listingTime = _b.listingTime, _d = _b.expirationTime, expirationTime = _d === void 0 ? 0 : _d, _e = _b.waitForHighestBid, waitForHighestBid = _e === void 0 ? false : _e, englishAuctionReservePrice = _b.englishAuctionReservePrice, paymentTokenAddress = _b.paymentTokenAddress, _f = _b.extraBountyBasisPoints, extraBountyBasisPoints = _f === void 0 ? 0 : _f, buyerAddress = _b.buyerAddress, buyerEmail = _b.buyerEmail;
|
|
677
|
+
var asset = _b.asset, accountAddress = _b.accountAddress, startAmount = _b.startAmount, endAmount = _b.endAmount, _c = _b.quantity, quantity = _c === void 0 ? 1 : _c, listingTime = _b.listingTime, _d = _b.expirationTime, expirationTime = _d === void 0 ? (0, utils_1.getMaxOrderExpirationTimestamp)() : _d, _e = _b.waitForHighestBid, waitForHighestBid = _e === void 0 ? false : _e, englishAuctionReservePrice = _b.englishAuctionReservePrice, paymentTokenAddress = _b.paymentTokenAddress, _f = _b.extraBountyBasisPoints, extraBountyBasisPoints = _f === void 0 ? 0 : _f, buyerAddress = _b.buyerAddress, buyerEmail = _b.buyerEmail;
|
|
678
678
|
return __awaiter(this, void 0, void 0, function () {
|
|
679
679
|
var order, hashedOrder, signature, error_3, orderWithSignature;
|
|
680
680
|
return __generator(this, function (_g) {
|
|
@@ -735,7 +735,7 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
735
735
|
* @param endAmount Optional price of the asset at the end of its expiration time. If not specified, will be set to `startAmount`. Units are in the amount of a token above the token's decimal places (integer part). For example, for ether, expected units are in ETH, not wei.
|
|
736
736
|
* @param quantity The number of assets to sell at one time (if fungible or semi-fungible). Defaults to 1. In units, not base units, e.g. not wei.
|
|
737
737
|
* @param listingTime Optional time when the order will become fulfillable, in UTC seconds. Undefined means it will start now.
|
|
738
|
-
* @param expirationTime Expiration time for the order, in seconds.
|
|
738
|
+
* @param expirationTime Expiration time for the order, in seconds.
|
|
739
739
|
* @param waitForHighestBid If set to true, this becomes an English auction that increases in price for every bid. The highest bid wins when the auction expires, as long as it's at least `startAmount`. `expirationTime` must be > 0.
|
|
740
740
|
* @param paymentTokenAddress Address of the ERC-20 token to accept in return. If undefined or null, uses Ether.
|
|
741
741
|
* @param extraBountyBasisPoints Optional basis points (1/100th of a percent) to reward someone for referring the fulfillment of each order
|
|
@@ -745,7 +745,7 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
745
745
|
* @returns The number of orders created in total
|
|
746
746
|
*/
|
|
747
747
|
OpenSeaPort.prototype.createFactorySellOrders = function (_b) {
|
|
748
|
-
var assets = _b.assets, accountAddress = _b.accountAddress, startAmount = _b.startAmount, endAmount = _b.endAmount, _c = _b.quantity, quantity = _c === void 0 ? 1 : _c, listingTime = _b.listingTime, _d = _b.expirationTime, expirationTime = _d === void 0 ? 0 : _d, _e = _b.waitForHighestBid, waitForHighestBid = _e === void 0 ? false : _e, paymentTokenAddress = _b.paymentTokenAddress, _f = _b.extraBountyBasisPoints, extraBountyBasisPoints = _f === void 0 ? 0 : _f, buyerAddress = _b.buyerAddress, buyerEmail = _b.buyerEmail, _g = _b.numberOfOrders, numberOfOrders = _g === void 0 ? 1 : _g;
|
|
748
|
+
var assets = _b.assets, accountAddress = _b.accountAddress, startAmount = _b.startAmount, endAmount = _b.endAmount, _c = _b.quantity, quantity = _c === void 0 ? 1 : _c, listingTime = _b.listingTime, _d = _b.expirationTime, expirationTime = _d === void 0 ? (0, utils_1.getMaxOrderExpirationTimestamp)() : _d, _e = _b.waitForHighestBid, waitForHighestBid = _e === void 0 ? false : _e, paymentTokenAddress = _b.paymentTokenAddress, _f = _b.extraBountyBasisPoints, extraBountyBasisPoints = _f === void 0 ? 0 : _f, buyerAddress = _b.buyerAddress, buyerEmail = _b.buyerEmail, _g = _b.numberOfOrders, numberOfOrders = _g === void 0 ? 1 : _g;
|
|
749
749
|
return __awaiter(this, void 0, void 0, function () {
|
|
750
750
|
var dummyOrder, _makeAndPostOneSellOrder, range, batches, numOrdersCreated, _h, batches_1, subRange, batchOrdersCreated;
|
|
751
751
|
var _this = this;
|
|
@@ -873,7 +873,7 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
873
873
|
* @param startAmount Price of the asset at the start of the auction, or minimum acceptable bid if it's an English auction.
|
|
874
874
|
* @param endAmount Optional price of the asset at the end of its expiration time. If not specified, will be set to `startAmount`.
|
|
875
875
|
* @param listingTime Optional time when the order will become fulfillable, in UTC seconds. Undefined means it will start now.
|
|
876
|
-
* @param expirationTime Expiration time for the order, in seconds.
|
|
876
|
+
* @param expirationTime Expiration time for the order, in seconds.
|
|
877
877
|
* @param waitForHighestBid If set to true, this becomes an English auction that increases in price for every bid. The highest bid wins when the auction expires, as long as it's at least `startAmount`. `expirationTime` must be > 0.
|
|
878
878
|
* @param englishAuctionReservePrice Optional price level, below which orders may be placed but will not be matched. Orders below the reserve can be manually accepted but will not be automatically matched.
|
|
879
879
|
* @param paymentTokenAddress Address of the ERC-20 token to accept in return. If undefined or null, uses Ether.
|
|
@@ -881,7 +881,7 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
881
881
|
* @param buyerAddress Optional address that's allowed to purchase this bundle. If specified, no other address will be able to take the order, unless it's the null address.
|
|
882
882
|
*/
|
|
883
883
|
OpenSeaPort.prototype.createBundleSellOrder = function (_b) {
|
|
884
|
-
var bundleName = _b.bundleName, bundleDescription = _b.bundleDescription, bundleExternalLink = _b.bundleExternalLink, assets = _b.assets, collection = _b.collection, quantities = _b.quantities, accountAddress = _b.accountAddress, startAmount = _b.startAmount, endAmount = _b.endAmount, _c = _b.expirationTime, expirationTime = _c === void 0 ? 0 : _c, listingTime = _b.listingTime, _d = _b.waitForHighestBid, waitForHighestBid = _d === void 0 ? false : _d, englishAuctionReservePrice = _b.englishAuctionReservePrice, paymentTokenAddress = _b.paymentTokenAddress, _e = _b.extraBountyBasisPoints, extraBountyBasisPoints = _e === void 0 ? 0 : _e, buyerAddress = _b.buyerAddress;
|
|
884
|
+
var bundleName = _b.bundleName, bundleDescription = _b.bundleDescription, bundleExternalLink = _b.bundleExternalLink, assets = _b.assets, collection = _b.collection, quantities = _b.quantities, accountAddress = _b.accountAddress, startAmount = _b.startAmount, endAmount = _b.endAmount, _c = _b.expirationTime, expirationTime = _c === void 0 ? (0, utils_1.getMaxOrderExpirationTimestamp)() : _c, listingTime = _b.listingTime, _d = _b.waitForHighestBid, waitForHighestBid = _d === void 0 ? false : _d, englishAuctionReservePrice = _b.englishAuctionReservePrice, paymentTokenAddress = _b.paymentTokenAddress, _e = _b.extraBountyBasisPoints, extraBountyBasisPoints = _e === void 0 ? 0 : _e, buyerAddress = _b.buyerAddress;
|
|
885
885
|
return __awaiter(this, void 0, void 0, function () {
|
|
886
886
|
var order, hashedOrder, signature, error_5, orderWithSignature;
|
|
887
887
|
return __generator(this, function (_f) {
|
|
@@ -981,77 +981,6 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
981
981
|
});
|
|
982
982
|
});
|
|
983
983
|
};
|
|
984
|
-
/**
|
|
985
|
-
* Returns estimated amount of gas required for Fullfilling the order.
|
|
986
|
-
* @param param0 __namedParamaters Object
|
|
987
|
-
* @param order The order to fulfill, a.k.a. "take"
|
|
988
|
-
* @param accountAddress The taker's wallet address
|
|
989
|
-
* @param recipientAddress The optional address to receive the order's item(s) or curriencies. If not specified, defaults to accountAddress.
|
|
990
|
-
* @param referrerAddress The optional address that referred the order
|
|
991
|
-
* @returns gasEstimation
|
|
992
|
-
*/
|
|
993
|
-
OpenSeaPort.prototype.getFulfillOrderGasEstimation = function (_b) {
|
|
994
|
-
var order = _b.order, accountAddress = _b.accountAddress, recipientAddress = _b.recipientAddress, referrerAddress = _b.referrerAddress;
|
|
995
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
996
|
-
var matchingOrder, _c, buy, sell, metadata, _d, args, txnData, wyvernProtocolReadOnly;
|
|
997
|
-
return __generator(this, function (_e) {
|
|
998
|
-
switch (_e.label) {
|
|
999
|
-
case 0:
|
|
1000
|
-
matchingOrder = this._makeMatchingOrder({
|
|
1001
|
-
order: order,
|
|
1002
|
-
accountAddress: accountAddress,
|
|
1003
|
-
recipientAddress: recipientAddress || accountAddress,
|
|
1004
|
-
});
|
|
1005
|
-
_c = (0, utils_1.assignOrdersToSides)(order, matchingOrder), buy = _c.buy, sell = _c.sell;
|
|
1006
|
-
metadata = this._getMetadata(order, referrerAddress);
|
|
1007
|
-
return [4 /*yield*/, this._getAtomicMatchCallArgs({
|
|
1008
|
-
buy: buy,
|
|
1009
|
-
sell: sell,
|
|
1010
|
-
accountAddress: accountAddress,
|
|
1011
|
-
metadata: metadata,
|
|
1012
|
-
})];
|
|
1013
|
-
case 1:
|
|
1014
|
-
_d = _e.sent(), args = _d.args, txnData = _d.txnData;
|
|
1015
|
-
wyvernProtocolReadOnly = this._getWyvernProtocolForOrder(buy, true);
|
|
1016
|
-
return [2 /*return*/, this._getAtomicMatchGasEstimation({
|
|
1017
|
-
args: args,
|
|
1018
|
-
txnData: txnData,
|
|
1019
|
-
wyvernProtocolReadOnly: wyvernProtocolReadOnly,
|
|
1020
|
-
})];
|
|
1021
|
-
}
|
|
1022
|
-
});
|
|
1023
|
-
});
|
|
1024
|
-
};
|
|
1025
|
-
/**
|
|
1026
|
-
* Returns data required to fulfill the transaction.
|
|
1027
|
-
* @param param0 __namedParamaters Object
|
|
1028
|
-
* @param order The order to fulfill, a.k.a. "take"
|
|
1029
|
-
* @param accountAddress The taker's wallet address
|
|
1030
|
-
* @param recipientAddress The optional address to receive the order's item(s) or curriencies. If not specified, defaults to accountAddress.
|
|
1031
|
-
* @param referrerAddress The optional address that referred the order
|
|
1032
|
-
* @returns gasEstimation
|
|
1033
|
-
*/
|
|
1034
|
-
OpenSeaPort.prototype.getFulfillOrderArgs = function (_b) {
|
|
1035
|
-
var order = _b.order, accountAddress = _b.accountAddress, recipientAddress = _b.recipientAddress, referrerAddress = _b.referrerAddress;
|
|
1036
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1037
|
-
var matchingOrder, _c, buy, sell, metadata;
|
|
1038
|
-
return __generator(this, function (_d) {
|
|
1039
|
-
matchingOrder = this._makeMatchingOrder({
|
|
1040
|
-
order: order,
|
|
1041
|
-
accountAddress: accountAddress,
|
|
1042
|
-
recipientAddress: recipientAddress || accountAddress,
|
|
1043
|
-
});
|
|
1044
|
-
_c = (0, utils_1.assignOrdersToSides)(order, matchingOrder), buy = _c.buy, sell = _c.sell;
|
|
1045
|
-
metadata = this._getMetadata(order, referrerAddress);
|
|
1046
|
-
return [2 /*return*/, this._getAtomicMatchCallArgs({
|
|
1047
|
-
buy: buy,
|
|
1048
|
-
sell: sell,
|
|
1049
|
-
accountAddress: accountAddress,
|
|
1050
|
-
metadata: metadata,
|
|
1051
|
-
})];
|
|
1052
|
-
});
|
|
1053
|
-
});
|
|
1054
|
-
};
|
|
1055
984
|
/**
|
|
1056
985
|
* Cancel an order on-chain, preventing it from ever being fulfilled.
|
|
1057
986
|
* @param param0 __namedParameters Object
|
|
@@ -2260,7 +2189,7 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
2260
2189
|
});
|
|
2261
2190
|
};
|
|
2262
2191
|
OpenSeaPort.prototype._makeBuyOrder = function (_b) {
|
|
2263
|
-
var asset = _b.asset, quantity = _b.quantity, accountAddress = _b.accountAddress, startAmount = _b.startAmount, _c = _b.expirationTime, expirationTime = _c === void 0 ? 0 : _c, paymentTokenAddress = _b.paymentTokenAddress, _d = _b.extraBountyBasisPoints, extraBountyBasisPoints = _d === void 0 ? 0 : _d, sellOrder = _b.sellOrder, referrerAddress = _b.referrerAddress;
|
|
2192
|
+
var asset = _b.asset, quantity = _b.quantity, accountAddress = _b.accountAddress, startAmount = _b.startAmount, _c = _b.expirationTime, expirationTime = _c === void 0 ? (0, utils_1.getMaxOrderExpirationTimestamp)() : _c, paymentTokenAddress = _b.paymentTokenAddress, _d = _b.extraBountyBasisPoints, extraBountyBasisPoints = _d === void 0 ? 0 : _d, sellOrder = _b.sellOrder, referrerAddress = _b.referrerAddress;
|
|
2264
2193
|
return __awaiter(this, void 0, void 0, function () {
|
|
2265
2194
|
var schema, quantityBN, wyAsset, openSeaAsset, taker, _e, totalBuyerFeeBasisPoints, totalSellerFeeBasisPoints, _f, makerRelayerFee, takerRelayerFee, makerProtocolFee, takerProtocolFee, makerReferrerFee, feeRecipient, feeMethod, _g, target, calldata, replacementPattern, _h, basePrice, extra, paymentToken, times, _j, staticTarget, staticExtradata, exchange;
|
|
2266
2195
|
return __generator(this, function (_k) {
|
|
@@ -2288,7 +2217,9 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
2288
2217
|
return [4 /*yield*/, this._getPriceParameters(types_1.OrderSide.Buy, paymentTokenAddress, expirationTime, startAmount)];
|
|
2289
2218
|
case 3:
|
|
2290
2219
|
_h = _k.sent(), basePrice = _h.basePrice, extra = _h.extra, paymentToken = _h.paymentToken;
|
|
2291
|
-
times = this._getTimeParameters(
|
|
2220
|
+
times = this._getTimeParameters({
|
|
2221
|
+
expirationTimestamp: expirationTime,
|
|
2222
|
+
});
|
|
2292
2223
|
return [4 /*yield*/, this._getStaticCallTargetAndExtraData({
|
|
2293
2224
|
asset: openSeaAsset,
|
|
2294
2225
|
useTxnOriginStaticCall: false,
|
|
@@ -2339,11 +2270,11 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
2339
2270
|
});
|
|
2340
2271
|
};
|
|
2341
2272
|
OpenSeaPort.prototype._makeSellOrder = function (_b) {
|
|
2342
|
-
var asset = _b.asset, quantity = _b.quantity, accountAddress = _b.accountAddress, startAmount = _b.startAmount, endAmount = _b.endAmount, listingTime = _b.listingTime,
|
|
2273
|
+
var asset = _b.asset, quantity = _b.quantity, accountAddress = _b.accountAddress, startAmount = _b.startAmount, endAmount = _b.endAmount, listingTime = _b.listingTime, _c = _b.expirationTime, expirationTime = _c === void 0 ? (0, utils_1.getMaxOrderExpirationTimestamp)() : _c, waitForHighestBid = _b.waitForHighestBid, _d = _b.englishAuctionReservePrice, englishAuctionReservePrice = _d === void 0 ? 0 : _d, paymentTokenAddress = _b.paymentTokenAddress, extraBountyBasisPoints = _b.extraBountyBasisPoints, buyerAddress = _b.buyerAddress;
|
|
2343
2274
|
return __awaiter(this, void 0, void 0, function () {
|
|
2344
|
-
var schema, quantityBN, wyAsset, openSeaAsset,
|
|
2345
|
-
return __generator(this, function (
|
|
2346
|
-
switch (
|
|
2275
|
+
var schema, quantityBN, wyAsset, openSeaAsset, _e, totalSellerFeeBasisPoints, totalBuyerFeeBasisPoints, sellerBountyBasisPoints, _f, target, calldata, replacementPattern, orderSaleKind, _g, basePrice, extra, paymentToken, reservePrice, times, _h, makerRelayerFee, takerRelayerFee, makerProtocolFee, takerProtocolFee, makerReferrerFee, feeRecipient, feeMethod, _j, staticTarget, staticExtradata, exchange;
|
|
2276
|
+
return __generator(this, function (_k) {
|
|
2277
|
+
switch (_k.label) {
|
|
2347
2278
|
case 0:
|
|
2348
2279
|
accountAddress = (0, utils_1.validateAndFormatWalletAddress)(this.web3, accountAddress);
|
|
2349
2280
|
schema = this._getSchema(asset.schemaName);
|
|
@@ -2351,34 +2282,38 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
2351
2282
|
wyAsset = (0, utils_1.getWyvernAsset)(schema, asset, quantityBN);
|
|
2352
2283
|
return [4 /*yield*/, this.api.getAsset(asset)];
|
|
2353
2284
|
case 1:
|
|
2354
|
-
openSeaAsset =
|
|
2285
|
+
openSeaAsset = _k.sent();
|
|
2355
2286
|
return [4 /*yield*/, this.computeFees({
|
|
2356
2287
|
asset: openSeaAsset,
|
|
2357
2288
|
side: types_1.OrderSide.Sell,
|
|
2358
2289
|
extraBountyBasisPoints: extraBountyBasisPoints,
|
|
2359
2290
|
})];
|
|
2360
2291
|
case 2:
|
|
2361
|
-
|
|
2362
|
-
|
|
2292
|
+
_e = _k.sent(), totalSellerFeeBasisPoints = _e.totalSellerFeeBasisPoints, totalBuyerFeeBasisPoints = _e.totalBuyerFeeBasisPoints, sellerBountyBasisPoints = _e.sellerBountyBasisPoints;
|
|
2293
|
+
_f = (0, schema_1.encodeSell)(schema, wyAsset, accountAddress, waitForHighestBid
|
|
2363
2294
|
? undefined
|
|
2364
|
-
: utils_1.merkleValidatorByNetwork[this._networkName]), target =
|
|
2295
|
+
: utils_1.merkleValidatorByNetwork[this._networkName]), target = _f.target, calldata = _f.calldata, replacementPattern = _f.replacementPattern;
|
|
2365
2296
|
orderSaleKind = endAmount != null && endAmount !== startAmount
|
|
2366
2297
|
? types_1.SaleKind.DutchAuction
|
|
2367
2298
|
: types_1.SaleKind.FixedPrice;
|
|
2368
2299
|
return [4 /*yield*/, this._getPriceParameters(types_1.OrderSide.Sell, paymentTokenAddress, expirationTime, startAmount, endAmount, waitForHighestBid, englishAuctionReservePrice)];
|
|
2369
2300
|
case 3:
|
|
2370
|
-
|
|
2371
|
-
times = this._getTimeParameters(
|
|
2372
|
-
|
|
2301
|
+
_g = _k.sent(), basePrice = _g.basePrice, extra = _g.extra, paymentToken = _g.paymentToken, reservePrice = _g.reservePrice;
|
|
2302
|
+
times = this._getTimeParameters({
|
|
2303
|
+
expirationTimestamp: expirationTime,
|
|
2304
|
+
listingTimestamp: listingTime,
|
|
2305
|
+
waitingForBestCounterOrder: waitForHighestBid,
|
|
2306
|
+
});
|
|
2307
|
+
_h = this._getSellFeeParameters(totalBuyerFeeBasisPoints, totalSellerFeeBasisPoints, waitForHighestBid, sellerBountyBasisPoints), makerRelayerFee = _h.makerRelayerFee, takerRelayerFee = _h.takerRelayerFee, makerProtocolFee = _h.makerProtocolFee, takerProtocolFee = _h.takerProtocolFee, makerReferrerFee = _h.makerReferrerFee, feeRecipient = _h.feeRecipient, feeMethod = _h.feeMethod;
|
|
2373
2308
|
return [4 /*yield*/, this._getStaticCallTargetAndExtraData({
|
|
2374
2309
|
asset: openSeaAsset,
|
|
2375
2310
|
useTxnOriginStaticCall: waitForHighestBid,
|
|
2376
2311
|
})];
|
|
2377
2312
|
case 4:
|
|
2378
|
-
|
|
2313
|
+
_j = _k.sent(), staticTarget = _j.staticTarget, staticExtradata = _j.staticExtradata;
|
|
2379
2314
|
return [4 /*yield*/, this._getOrderCreateWyvernExchangeAddress()];
|
|
2380
2315
|
case 5:
|
|
2381
|
-
exchange =
|
|
2316
|
+
exchange = _k.sent();
|
|
2382
2317
|
return [2 /*return*/, {
|
|
2383
2318
|
exchange: exchange ||
|
|
2384
2319
|
wyvern_js_1.WyvernProtocol.getExchangeContractAddress(this._networkName),
|
|
@@ -2502,7 +2437,7 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
2502
2437
|
});
|
|
2503
2438
|
};
|
|
2504
2439
|
OpenSeaPort.prototype._makeBundleBuyOrder = function (_b) {
|
|
2505
|
-
var assets = _b.assets, collection = _b.collection, quantities = _b.quantities, accountAddress = _b.accountAddress, startAmount = _b.startAmount, _c = _b.expirationTime, expirationTime = _c === void 0 ? 0 : _c, paymentTokenAddress = _b.paymentTokenAddress, _d = _b.extraBountyBasisPoints, extraBountyBasisPoints = _d === void 0 ? 0 : _d, sellOrder = _b.sellOrder, referrerAddress = _b.referrerAddress;
|
|
2440
|
+
var assets = _b.assets, collection = _b.collection, quantities = _b.quantities, accountAddress = _b.accountAddress, startAmount = _b.startAmount, _c = _b.expirationTime, expirationTime = _c === void 0 ? (0, utils_1.getMaxOrderExpirationTimestamp)() : _c, paymentTokenAddress = _b.paymentTokenAddress, _d = _b.extraBountyBasisPoints, extraBountyBasisPoints = _d === void 0 ? 0 : _d, sellOrder = _b.sellOrder, referrerAddress = _b.referrerAddress;
|
|
2506
2441
|
return __awaiter(this, void 0, void 0, function () {
|
|
2507
2442
|
var quantityBNs, bundle, orderedSchemas, taker, asset, _e, _f, totalBuyerFeeBasisPoints, totalSellerFeeBasisPoints, _g, makerRelayerFee, takerRelayerFee, makerProtocolFee, takerProtocolFee, makerReferrerFee, feeRecipient, feeMethod, _h, calldata, replacementPattern, _j, basePrice, extra, paymentToken, times, exchange;
|
|
2508
2443
|
var _this = this;
|
|
@@ -2538,7 +2473,9 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
2538
2473
|
return [4 /*yield*/, this._getPriceParameters(types_1.OrderSide.Buy, paymentTokenAddress, expirationTime, startAmount)];
|
|
2539
2474
|
case 5:
|
|
2540
2475
|
_j = _k.sent(), basePrice = _j.basePrice, extra = _j.extra, paymentToken = _j.paymentToken;
|
|
2541
|
-
times = this._getTimeParameters(
|
|
2476
|
+
times = this._getTimeParameters({
|
|
2477
|
+
expirationTimestamp: expirationTime,
|
|
2478
|
+
});
|
|
2542
2479
|
return [4 /*yield*/, this._getOrderCreateWyvernExchangeAddress()];
|
|
2543
2480
|
case 6:
|
|
2544
2481
|
exchange = _k.sent();
|
|
@@ -2580,12 +2517,12 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
2580
2517
|
});
|
|
2581
2518
|
};
|
|
2582
2519
|
OpenSeaPort.prototype._makeBundleSellOrder = function (_b) {
|
|
2583
|
-
var bundleName = _b.bundleName, bundleDescription = _b.bundleDescription, bundleExternalLink = _b.bundleExternalLink, assets = _b.assets, collection = _b.collection, quantities = _b.quantities, accountAddress = _b.accountAddress, startAmount = _b.startAmount, endAmount = _b.endAmount, listingTime = _b.listingTime,
|
|
2520
|
+
var bundleName = _b.bundleName, bundleDescription = _b.bundleDescription, bundleExternalLink = _b.bundleExternalLink, assets = _b.assets, collection = _b.collection, quantities = _b.quantities, accountAddress = _b.accountAddress, startAmount = _b.startAmount, endAmount = _b.endAmount, listingTime = _b.listingTime, _c = _b.expirationTime, expirationTime = _c === void 0 ? (0, utils_1.getMaxOrderExpirationTimestamp)() : _c, waitForHighestBid = _b.waitForHighestBid, _d = _b.englishAuctionReservePrice, englishAuctionReservePrice = _d === void 0 ? 0 : _d, paymentTokenAddress = _b.paymentTokenAddress, extraBountyBasisPoints = _b.extraBountyBasisPoints, buyerAddress = _b.buyerAddress;
|
|
2584
2521
|
return __awaiter(this, void 0, void 0, function () {
|
|
2585
|
-
var quantityBNs, bundle, orderedSchemas, asset,
|
|
2522
|
+
var quantityBNs, bundle, orderedSchemas, asset, _e, _f, totalSellerFeeBasisPoints, totalBuyerFeeBasisPoints, sellerBountyBasisPoints, _g, calldata, replacementPattern, _h, basePrice, extra, paymentToken, reservePrice, times, orderSaleKind, _j, makerRelayerFee, takerRelayerFee, makerProtocolFee, takerProtocolFee, makerReferrerFee, feeRecipient, exchange;
|
|
2586
2523
|
var _this = this;
|
|
2587
|
-
return __generator(this, function (
|
|
2588
|
-
switch (
|
|
2524
|
+
return __generator(this, function (_k) {
|
|
2525
|
+
switch (_k.label) {
|
|
2589
2526
|
case 0:
|
|
2590
2527
|
accountAddress = (0, utils_1.validateAndFormatWalletAddress)(this.web3, accountAddress);
|
|
2591
2528
|
quantityBNs = quantities.map(function (quantity, i) {
|
|
@@ -2599,32 +2536,36 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
2599
2536
|
if (!collection) return [3 /*break*/, 2];
|
|
2600
2537
|
return [4 /*yield*/, this.api.getAsset(assets[0])];
|
|
2601
2538
|
case 1:
|
|
2602
|
-
|
|
2539
|
+
_e = _k.sent();
|
|
2603
2540
|
return [3 /*break*/, 3];
|
|
2604
2541
|
case 2:
|
|
2605
|
-
|
|
2606
|
-
|
|
2542
|
+
_e = undefined;
|
|
2543
|
+
_k.label = 3;
|
|
2607
2544
|
case 3:
|
|
2608
|
-
asset =
|
|
2545
|
+
asset = _e;
|
|
2609
2546
|
return [4 /*yield*/, this.computeFees({
|
|
2610
2547
|
asset: asset,
|
|
2611
2548
|
side: types_1.OrderSide.Sell,
|
|
2612
2549
|
extraBountyBasisPoints: extraBountyBasisPoints,
|
|
2613
2550
|
})];
|
|
2614
2551
|
case 4:
|
|
2615
|
-
|
|
2616
|
-
|
|
2552
|
+
_f = _k.sent(), totalSellerFeeBasisPoints = _f.totalSellerFeeBasisPoints, totalBuyerFeeBasisPoints = _f.totalBuyerFeeBasisPoints, sellerBountyBasisPoints = _f.sellerBountyBasisPoints;
|
|
2553
|
+
_g = (0, schema_1.encodeAtomicizedSell)(orderedSchemas, bundle.assets, accountAddress, this._wyvernProtocol, this._networkName), calldata = _g.calldata, replacementPattern = _g.replacementPattern;
|
|
2617
2554
|
return [4 /*yield*/, this._getPriceParameters(types_1.OrderSide.Sell, paymentTokenAddress, expirationTime, startAmount, endAmount, waitForHighestBid, englishAuctionReservePrice)];
|
|
2618
2555
|
case 5:
|
|
2619
|
-
|
|
2620
|
-
times = this._getTimeParameters(
|
|
2556
|
+
_h = _k.sent(), basePrice = _h.basePrice, extra = _h.extra, paymentToken = _h.paymentToken, reservePrice = _h.reservePrice;
|
|
2557
|
+
times = this._getTimeParameters({
|
|
2558
|
+
expirationTimestamp: expirationTime,
|
|
2559
|
+
listingTimestamp: listingTime,
|
|
2560
|
+
waitingForBestCounterOrder: waitForHighestBid,
|
|
2561
|
+
});
|
|
2621
2562
|
orderSaleKind = endAmount != null && endAmount !== startAmount
|
|
2622
2563
|
? types_1.SaleKind.DutchAuction
|
|
2623
2564
|
: types_1.SaleKind.FixedPrice;
|
|
2624
|
-
|
|
2565
|
+
_j = this._getSellFeeParameters(totalBuyerFeeBasisPoints, totalSellerFeeBasisPoints, waitForHighestBid, sellerBountyBasisPoints), makerRelayerFee = _j.makerRelayerFee, takerRelayerFee = _j.takerRelayerFee, makerProtocolFee = _j.makerProtocolFee, takerProtocolFee = _j.takerProtocolFee, makerReferrerFee = _j.makerReferrerFee, feeRecipient = _j.feeRecipient;
|
|
2625
2566
|
return [4 /*yield*/, this._getOrderCreateWyvernExchangeAddress()];
|
|
2626
2567
|
case 6:
|
|
2627
|
-
exchange =
|
|
2568
|
+
exchange = _k.sent();
|
|
2628
2569
|
return [2 /*return*/, {
|
|
2629
2570
|
exchange: exchange ||
|
|
2630
2571
|
wyvern_js_1.WyvernProtocol.getExchangeContractAddress(this._networkName),
|
|
@@ -2700,7 +2641,10 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
2700
2641
|
}
|
|
2701
2642
|
};
|
|
2702
2643
|
var _c = computeOrderParams(), target = _c.target, calldata = _c.calldata, replacementPattern = _c.replacementPattern;
|
|
2703
|
-
var times = this._getTimeParameters(
|
|
2644
|
+
var times = this._getTimeParameters({
|
|
2645
|
+
expirationTimestamp: 0,
|
|
2646
|
+
isMatchingOrder: true,
|
|
2647
|
+
});
|
|
2704
2648
|
// Compat for matching buy orders that have fee recipient still on them
|
|
2705
2649
|
var feeRecipient = order.feeRecipient == constants_1.NULL_ADDRESS ? constants_1.OPENSEA_FEE_RECIPIENT : constants_1.NULL_ADDRESS;
|
|
2706
2650
|
var matchingOrder = {
|
|
@@ -3283,43 +3227,52 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
3283
3227
|
* @param listingTimestamp Timestamp to start the order (in seconds), or undefined to start it now
|
|
3284
3228
|
* @param waitingForBestCounterOrder Whether this order should be hidden until the best match is found
|
|
3285
3229
|
*/
|
|
3286
|
-
OpenSeaPort.prototype._getTimeParameters = function (
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3230
|
+
OpenSeaPort.prototype._getTimeParameters = function (_b) {
|
|
3231
|
+
var _c = _b.expirationTimestamp, expirationTimestamp = _c === void 0 ? (0, utils_1.getMaxOrderExpirationTimestamp)() : _c, listingTimestamp = _b.listingTimestamp, _d = _b.waitingForBestCounterOrder, waitingForBestCounterOrder = _d === void 0 ? false : _d, _e = _b.isMatchingOrder, isMatchingOrder = _e === void 0 ? false : _e;
|
|
3232
|
+
var maxExpirationDate = new Date();
|
|
3233
|
+
maxExpirationDate.setMonth(maxExpirationDate.getMonth() + constants_1.MAX_EXPIRATION_MONTHS);
|
|
3234
|
+
var maxExpirationTimeStamp = Math.round(maxExpirationDate.getTime() / 1000);
|
|
3290
3235
|
var minListingTimestamp = Math.round(Date.now() / 1000);
|
|
3291
|
-
if (expirationTimestamp
|
|
3292
|
-
|
|
3293
|
-
throw new Error("Expiration time must be at least ".concat(constants_1.MIN_EXPIRATION_SECONDS, " seconds from now, or zero (non-expiring)."));
|
|
3236
|
+
if (!isMatchingOrder && expirationTimestamp === 0) {
|
|
3237
|
+
throw new Error("Expiration time cannot be 0");
|
|
3294
3238
|
}
|
|
3295
3239
|
if (listingTimestamp && listingTimestamp < minListingTimestamp) {
|
|
3296
3240
|
throw new Error("Listing time cannot be in the past.");
|
|
3297
3241
|
}
|
|
3298
|
-
if (listingTimestamp &&
|
|
3299
|
-
expirationTimestamp != 0 &&
|
|
3300
|
-
listingTimestamp >= expirationTimestamp) {
|
|
3242
|
+
if (listingTimestamp && listingTimestamp >= expirationTimestamp) {
|
|
3301
3243
|
throw new Error("Listing time must be before the expiration time.");
|
|
3302
3244
|
}
|
|
3303
|
-
if (waitingForBestCounterOrder && expirationTimestamp == 0) {
|
|
3304
|
-
throw new Error("English auctions must have an expiration time.");
|
|
3305
|
-
}
|
|
3306
3245
|
if (waitingForBestCounterOrder && listingTimestamp) {
|
|
3307
3246
|
throw new Error("Cannot schedule an English auction for the future.");
|
|
3308
3247
|
}
|
|
3309
3248
|
if (parseInt(expirationTimestamp.toString()) != expirationTimestamp) {
|
|
3310
3249
|
throw new Error("Expiration timestamp must be a whole number of seconds");
|
|
3311
3250
|
}
|
|
3251
|
+
if (expirationTimestamp > maxExpirationTimeStamp) {
|
|
3252
|
+
throw new Error("Expiration time must not exceed six months from now");
|
|
3253
|
+
}
|
|
3312
3254
|
if (waitingForBestCounterOrder) {
|
|
3313
3255
|
listingTimestamp = expirationTimestamp;
|
|
3314
3256
|
// Expire one week from now, to ensure server can match it
|
|
3315
3257
|
// Later, this will expire closer to the listingTime
|
|
3316
3258
|
expirationTimestamp =
|
|
3317
3259
|
expirationTimestamp + constants_1.ORDER_MATCHING_LATENCY_SECONDS;
|
|
3260
|
+
// The minimum expiration time has to be at least fifteen minutes from now
|
|
3261
|
+
var minEnglishAuctionListingTimestamp = minListingTimestamp + constants_1.MIN_EXPIRATION_MINUTES * 60;
|
|
3262
|
+
if (!isMatchingOrder &&
|
|
3263
|
+
listingTimestamp < minEnglishAuctionListingTimestamp) {
|
|
3264
|
+
throw new Error("Expiration time must be at least ".concat(constants_1.MIN_EXPIRATION_MINUTES, " minutes from now"));
|
|
3265
|
+
}
|
|
3318
3266
|
}
|
|
3319
3267
|
else {
|
|
3320
3268
|
// Small offset to account for latency
|
|
3321
3269
|
listingTimestamp =
|
|
3322
3270
|
listingTimestamp || Math.round(Date.now() / 1000 - 100);
|
|
3271
|
+
// The minimum expiration time has to be at least fifteen minutes from now
|
|
3272
|
+
var minExpirationTimestamp = listingTimestamp + constants_1.MIN_EXPIRATION_MINUTES * 60;
|
|
3273
|
+
if (!isMatchingOrder && expirationTimestamp < minExpirationTimestamp) {
|
|
3274
|
+
throw new Error("Expiration time must be at least ".concat(constants_1.MIN_EXPIRATION_MINUTES, " minutes from the listing date"));
|
|
3275
|
+
}
|
|
3323
3276
|
}
|
|
3324
3277
|
return {
|
|
3325
3278
|
listingTime: (0, utils_1.makeBigNumber)(listingTimestamp),
|
|
@@ -3400,15 +3353,17 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
3400
3353
|
}
|
|
3401
3354
|
return undefined;
|
|
3402
3355
|
};
|
|
3403
|
-
OpenSeaPort.prototype.
|
|
3404
|
-
var buy = _b.buy, sell = _b.sell, accountAddress = _b.accountAddress;
|
|
3356
|
+
OpenSeaPort.prototype._atomicMatch = function (_b) {
|
|
3357
|
+
var buy = _b.buy, sell = _b.sell, accountAddress = _b.accountAddress, _c = _b.metadata, metadata = _c === void 0 ? constants_1.NULL_BLOCK_HASH : _c;
|
|
3405
3358
|
return __awaiter(this, void 0, void 0, function () {
|
|
3406
|
-
var shouldValidateBuy, shouldValidateSell;
|
|
3407
|
-
return __generator(this, function (
|
|
3408
|
-
switch (
|
|
3359
|
+
var value, shouldValidateBuy, shouldValidateSell, wyvernProtocol, wyvernProtocolReadOnly, txHash, txnData, args, gasEstimate, error_13, error_14;
|
|
3360
|
+
return __generator(this, function (_d) {
|
|
3361
|
+
switch (_d.label) {
|
|
3409
3362
|
case 0:
|
|
3410
3363
|
shouldValidateBuy = true;
|
|
3411
3364
|
shouldValidateSell = true;
|
|
3365
|
+
wyvernProtocol = this._getWyvernProtocolForOrder(buy);
|
|
3366
|
+
wyvernProtocolReadOnly = this._getWyvernProtocolForOrder(buy, true);
|
|
3412
3367
|
if (!(sell.maker.toLowerCase() == accountAddress.toLowerCase())) return [3 /*break*/, 2];
|
|
3413
3368
|
// USER IS THE SELLER, only validate the buy order
|
|
3414
3369
|
return [4 /*yield*/, this._sellOrderValidationAndApprovals({
|
|
@@ -3417,11 +3372,11 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
3417
3372
|
})];
|
|
3418
3373
|
case 1:
|
|
3419
3374
|
// USER IS THE SELLER, only validate the buy order
|
|
3420
|
-
|
|
3375
|
+
_d.sent();
|
|
3421
3376
|
shouldValidateSell = false;
|
|
3422
|
-
return [3 /*break*/,
|
|
3377
|
+
return [3 /*break*/, 6];
|
|
3423
3378
|
case 2:
|
|
3424
|
-
if (!(buy.maker.toLowerCase() == accountAddress.toLowerCase())) return [3 /*break*/,
|
|
3379
|
+
if (!(buy.maker.toLowerCase() == accountAddress.toLowerCase())) return [3 /*break*/, 6];
|
|
3425
3380
|
// USER IS THE BUYER, only validate the sell order
|
|
3426
3381
|
return [4 /*yield*/, this._buyOrderValidationAndApprovals({
|
|
3427
3382
|
order: buy,
|
|
@@ -3430,43 +3385,30 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
3430
3385
|
})];
|
|
3431
3386
|
case 3:
|
|
3432
3387
|
// USER IS THE BUYER, only validate the sell order
|
|
3433
|
-
|
|
3388
|
+
_d.sent();
|
|
3434
3389
|
shouldValidateBuy = false;
|
|
3435
|
-
return [3 /*break*/,
|
|
3436
|
-
|
|
3390
|
+
if (!(buy.paymentToken == constants_1.NULL_ADDRESS)) return [3 /*break*/, 5];
|
|
3391
|
+
return [4 /*yield*/, this._getRequiredAmountForTakingSellOrder(sell)];
|
|
3392
|
+
case 4:
|
|
3393
|
+
value = _d.sent();
|
|
3394
|
+
_d.label = 5;
|
|
3395
|
+
case 5: return [3 /*break*/, 6];
|
|
3396
|
+
case 6: return [4 /*yield*/, this._validateMatch({
|
|
3437
3397
|
buy: buy,
|
|
3438
3398
|
sell: sell,
|
|
3439
3399
|
accountAddress: accountAddress,
|
|
3440
3400
|
shouldValidateBuy: shouldValidateBuy,
|
|
3441
3401
|
shouldValidateSell: shouldValidateSell,
|
|
3442
3402
|
})];
|
|
3443
|
-
case
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
3453
|
-
var value, txnData, args;
|
|
3454
|
-
return __generator(this, function (_d) {
|
|
3455
|
-
switch (_d.label) {
|
|
3456
|
-
case 0:
|
|
3457
|
-
this._validateOrderMatch({ buy: buy, sell: sell, accountAddress: accountAddress });
|
|
3458
|
-
if (!(buy.maker.toLowerCase() == accountAddress.toLowerCase() &&
|
|
3459
|
-
buy.paymentToken == constants_1.NULL_ADDRESS)) return [3 /*break*/, 2];
|
|
3460
|
-
return [4 /*yield*/, this._getRequiredAmountForTakingSellOrder(sell)];
|
|
3461
|
-
case 1:
|
|
3462
|
-
// If using ETH to pay, set the value of the transaction to the current price
|
|
3463
|
-
value = _d.sent();
|
|
3464
|
-
_d.label = 2;
|
|
3465
|
-
case 2:
|
|
3466
|
-
txnData = {
|
|
3467
|
-
from: accountAddress,
|
|
3468
|
-
value: value,
|
|
3469
|
-
};
|
|
3403
|
+
case 7:
|
|
3404
|
+
_d.sent();
|
|
3405
|
+
this._dispatch(types_1.EventType.MatchOrders, {
|
|
3406
|
+
buy: buy,
|
|
3407
|
+
sell: sell,
|
|
3408
|
+
accountAddress: accountAddress,
|
|
3409
|
+
matchMetadata: metadata,
|
|
3410
|
+
});
|
|
3411
|
+
txnData = { from: accountAddress, value: value };
|
|
3470
3412
|
args = [
|
|
3471
3413
|
[
|
|
3472
3414
|
buy.exchange,
|
|
@@ -3529,79 +3471,30 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
3529
3471
|
metadata,
|
|
3530
3472
|
],
|
|
3531
3473
|
];
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
}];
|
|
3536
|
-
}
|
|
3537
|
-
});
|
|
3538
|
-
});
|
|
3539
|
-
};
|
|
3540
|
-
OpenSeaPort.prototype._getAtomicMatchGasEstimation = function (_b) {
|
|
3541
|
-
var args = _b.args, txnData = _b.txnData, wyvernProtocolReadOnly = _b.wyvernProtocolReadOnly;
|
|
3542
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
3543
|
-
var gasEstimate, error_13;
|
|
3544
|
-
return __generator(this, function (_c) {
|
|
3545
|
-
switch (_c.label) {
|
|
3546
|
-
case 0:
|
|
3547
|
-
_c.trys.push([0, 2, , 3]);
|
|
3474
|
+
_d.label = 8;
|
|
3475
|
+
case 8:
|
|
3476
|
+
_d.trys.push([8, 10, , 11]);
|
|
3548
3477
|
return [4 /*yield*/, wyvernProtocolReadOnly.wyvernExchange.atomicMatch_.estimateGasAsync(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10], txnData)];
|
|
3549
|
-
case
|
|
3550
|
-
gasEstimate =
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3478
|
+
case 9:
|
|
3479
|
+
gasEstimate = _d.sent();
|
|
3480
|
+
txnData.gas = this._correctGasAmount(gasEstimate);
|
|
3481
|
+
return [3 /*break*/, 11];
|
|
3482
|
+
case 10:
|
|
3483
|
+
error_13 = _d.sent();
|
|
3554
3484
|
console.error("Failed atomic match with args: ", args, error_13);
|
|
3555
3485
|
throw new Error("Oops, the Ethereum network rejected this transaction :( The OpenSea devs have been alerted, but this problem is typically due an item being locked or untransferrable. The exact error was \"".concat(error_13 instanceof Error
|
|
3556
3486
|
? error_13.message.substr(0, debugging_1.MAX_ERROR_LENGTH)
|
|
3557
3487
|
: "unknown", "...\""));
|
|
3558
|
-
case
|
|
3559
|
-
|
|
3560
|
-
});
|
|
3561
|
-
});
|
|
3562
|
-
};
|
|
3563
|
-
OpenSeaPort.prototype._atomicMatch = function (_b) {
|
|
3564
|
-
var buy = _b.buy, sell = _b.sell, accountAddress = _b.accountAddress, _c = _b.metadata, metadata = _c === void 0 ? constants_1.NULL_BLOCK_HASH : _c;
|
|
3565
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
3566
|
-
var wyvernProtocol, wyvernProtocolReadOnly, _d, args, txnData, _e, txHash, error_14;
|
|
3567
|
-
return __generator(this, function (_f) {
|
|
3568
|
-
switch (_f.label) {
|
|
3569
|
-
case 0:
|
|
3570
|
-
wyvernProtocol = this._getWyvernProtocolForOrder(buy);
|
|
3571
|
-
wyvernProtocolReadOnly = this._getWyvernProtocolForOrder(buy, true);
|
|
3572
|
-
return [4 /*yield*/, this._getAtomicMatchCallArgs({
|
|
3573
|
-
buy: buy,
|
|
3574
|
-
sell: sell,
|
|
3575
|
-
accountAddress: accountAddress,
|
|
3576
|
-
metadata: metadata,
|
|
3577
|
-
})];
|
|
3578
|
-
case 1:
|
|
3579
|
-
_d = _f.sent(), args = _d.args, txnData = _d.txnData;
|
|
3580
|
-
_e = txnData;
|
|
3581
|
-
return [4 /*yield*/, this._getAtomicMatchGasEstimation({
|
|
3582
|
-
args: args,
|
|
3583
|
-
txnData: txnData,
|
|
3584
|
-
wyvernProtocolReadOnly: wyvernProtocolReadOnly,
|
|
3585
|
-
})];
|
|
3586
|
-
case 2:
|
|
3587
|
-
_e.gas = _f.sent();
|
|
3588
|
-
this._dispatch(types_1.EventType.MatchOrders, {
|
|
3589
|
-
buy: buy,
|
|
3590
|
-
sell: sell,
|
|
3591
|
-
accountAddress: accountAddress,
|
|
3592
|
-
matchMetadata: metadata,
|
|
3593
|
-
});
|
|
3594
|
-
_f.label = 3;
|
|
3595
|
-
case 3:
|
|
3596
|
-
_f.trys.push([3, 5, , 6]);
|
|
3488
|
+
case 11:
|
|
3489
|
+
_d.trys.push([11, 13, , 14]);
|
|
3597
3490
|
this.logger("Fulfilling order with gas set to ".concat(txnData.gas));
|
|
3598
3491
|
return [4 /*yield*/, wyvernProtocol.wyvernExchange.atomicMatch_.sendTransactionAsync(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10], txnData)];
|
|
3599
|
-
case
|
|
3492
|
+
case 12:
|
|
3600
3493
|
txHash =
|
|
3601
|
-
|
|
3602
|
-
return [3 /*break*/,
|
|
3603
|
-
case
|
|
3604
|
-
error_14 =
|
|
3494
|
+
_d.sent();
|
|
3495
|
+
return [3 /*break*/, 14];
|
|
3496
|
+
case 13:
|
|
3497
|
+
error_14 = _d.sent();
|
|
3605
3498
|
console.error(error_14);
|
|
3606
3499
|
this._dispatch(types_1.EventType.TransactionDenied, {
|
|
3607
3500
|
error: error_14,
|
|
@@ -3613,7 +3506,7 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
3613
3506
|
throw new Error("Failed to authorize transaction: \"".concat(error_14 instanceof Error && error_14.message
|
|
3614
3507
|
? error_14.message
|
|
3615
3508
|
: "user denied", "...\""));
|
|
3616
|
-
case
|
|
3509
|
+
case 14: return [2 /*return*/, txHash];
|
|
3617
3510
|
}
|
|
3618
3511
|
});
|
|
3619
3512
|
});
|