opensea-js 2.0.0 → 2.0.1-beta.2
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/README.md +2 -3
- package/lib/seaport.d.ts +41 -1
- package/lib/seaport.js +180 -49
- package/lib/seaport.js.map +1 -1
- package/lib/utils/utils.d.ts +1 -1
- package/lib/utils/utils.js +34 -13
- package/lib/utils/utils.js.map +1 -1
- package/package.json +1 -1
- package/lib/abi/CheezeWizardsBasicTournamentAbi.json +0 -523
- package/lib/abi/DecentralandEstatesAbi.json +0 -614
- package/lib/abi/ERC1155Abi.json +0 -2346
- package/lib/abi/ERC721v3Abi.json +0 -470
- package/lib/abi/UniswapExchangeAbi.json +0 -451
- package/lib/abi/UniswapFactoryAbi.json +0 -67
- package/lib/abi/WrappedNFTAbi.json +0 -331
- package/lib/abi/WrappedNFTFactoryAbi.json +0 -250
- package/lib/typechain/contracts/CheezeWizardsBasicTournamentAbi.d.ts +0 -232
- package/lib/typechain/contracts/CheezeWizardsBasicTournamentAbi.js +0 -6
- package/lib/typechain/contracts/CheezeWizardsBasicTournamentAbi.js.map +0 -1
- package/lib/typechain/contracts/DecentralandEstatesAbi.d.ts +0 -189
- package/lib/typechain/contracts/DecentralandEstatesAbi.js +0 -6
- package/lib/typechain/contracts/DecentralandEstatesAbi.js.map +0 -1
- package/lib/typechain/contracts/ERC1155Abi.d.ts +0 -436
- package/lib/typechain/contracts/ERC1155Abi.js +0 -6
- package/lib/typechain/contracts/ERC1155Abi.js.map +0 -1
- package/lib/typechain/contracts/ERC721v3Abi.d.ts +0 -76
- package/lib/typechain/contracts/ERC721v3Abi.js +0 -6
- package/lib/typechain/contracts/ERC721v3Abi.js.map +0 -1
- package/lib/typechain/contracts/UniswapExchangeAbi.d.ts +0 -132
- package/lib/typechain/contracts/UniswapExchangeAbi.js +0 -6
- package/lib/typechain/contracts/UniswapExchangeAbi.js.map +0 -1
- package/lib/typechain/contracts/UniswapFactoryAbi.d.ts +0 -37
- package/lib/typechain/contracts/UniswapFactoryAbi.js +0 -6
- package/lib/typechain/contracts/UniswapFactoryAbi.js.map +0 -1
- package/lib/typechain/contracts/WrappedNFTAbi.d.ts +0 -80
- package/lib/typechain/contracts/WrappedNFTAbi.js +0 -6
- package/lib/typechain/contracts/WrappedNFTAbi.js.map +0 -1
- package/lib/typechain/contracts/WrappedNFTFactoryAbi.d.ts +0 -57
- package/lib/typechain/contracts/WrappedNFTFactoryAbi.js +0 -6
- package/lib/typechain/contracts/WrappedNFTFactoryAbi.js.map +0 -1
- package/lib/typechain/contracts/types.d.ts +0 -54
- package/lib/typechain/contracts/types.js +0 -3
- package/lib/typechain/contracts/types.js.map +0 -1
package/README.md
CHANGED
|
@@ -44,6 +44,7 @@ Published on [GitHub](https://github.com/ProjectOpenSea/opensea-js) and [npm](ht
|
|
|
44
44
|
- [Migrating to version 1.0](#migrating-to-version-10)
|
|
45
45
|
- [Development Information](#development-information)
|
|
46
46
|
- [Diagnosing Common Issues](#diagnosing-common-issues)
|
|
47
|
+
- [Testing your branch locally](#testing-your-branch-locally)
|
|
47
48
|
|
|
48
49
|
## Synopsis
|
|
49
50
|
|
|
@@ -57,7 +58,7 @@ Happy seafaring! ⛵️
|
|
|
57
58
|
|
|
58
59
|
## Installation
|
|
59
60
|
|
|
60
|
-
We recommend switching to Node.js version
|
|
61
|
+
We recommend switching to Node.js version 16 to make sure common crypto dependencies work. Execute `nvm use`, if you have Node Version Manager.
|
|
61
62
|
|
|
62
63
|
Then, in your project, run:
|
|
63
64
|
|
|
@@ -687,8 +688,6 @@ See the [Changelog](CHANGELOG.md).
|
|
|
687
688
|
|
|
688
689
|
**Setup**
|
|
689
690
|
|
|
690
|
-
[Node >= v8.11.2](https://nodejs.org/en/) required.
|
|
691
|
-
|
|
692
691
|
Before any development, install the required NPM dependencies:
|
|
693
692
|
|
|
694
693
|
```bash
|
package/lib/seaport.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { EventSubscription } from "fbemitter";
|
|
|
3
3
|
import Web3 from "web3";
|
|
4
4
|
import { WyvernProtocol } from "wyvern-js";
|
|
5
5
|
import { OpenSeaAPI } from "./api";
|
|
6
|
-
import { Asset, ComputedFees, ECSignature, EventData, EventType, FeeMethod, OpenSeaAPIConfig, OpenSeaAsset, OpenSeaFungibleToken, Order, OrderSide, PartialReadonlyContractAbi, UnhashedOrder, UnsignedOrder, WyvernAsset, WyvernSchemaName } from "./types";
|
|
6
|
+
import { Asset, ComputedFees, ECSignature, EventData, EventType, FeeMethod, OpenSeaAPIConfig, OpenSeaAsset, OpenSeaFungibleToken, Order, OrderSide, PartialReadonlyContractAbi, UnhashedOrder, UnsignedOrder, WyvernAsset, WyvernAtomicMatchParameters, WyvernSchemaName } from "./types";
|
|
7
7
|
export declare class OpenSeaPort {
|
|
8
8
|
web3: Web3;
|
|
9
9
|
web3ReadOnly: Web3;
|
|
@@ -321,6 +321,43 @@ export declare class OpenSeaPort {
|
|
|
321
321
|
recipientAddress?: string;
|
|
322
322
|
referrerAddress?: string;
|
|
323
323
|
}): Promise<string>;
|
|
324
|
+
/**
|
|
325
|
+
* Returns estimated amount of gas required for Fullfilling the order.
|
|
326
|
+
* @param param0 __namedParamaters Object
|
|
327
|
+
* @param order The order to fulfill, a.k.a. "take"
|
|
328
|
+
* @param accountAddress The taker's wallet address
|
|
329
|
+
* @param recipientAddress The optional address to receive the order's item(s) or curriencies. If not specified, defaults to accountAddress.
|
|
330
|
+
* @param referrerAddress The optional address that referred the order
|
|
331
|
+
* @returns gasEstimation
|
|
332
|
+
*/
|
|
333
|
+
getFulfillOrderGasEstimation({ order, accountAddress, recipientAddress, referrerAddress, }: {
|
|
334
|
+
order: Order;
|
|
335
|
+
accountAddress: string;
|
|
336
|
+
recipientAddress?: string;
|
|
337
|
+
referrerAddress?: string;
|
|
338
|
+
}): Promise<number>;
|
|
339
|
+
/**
|
|
340
|
+
* Returns data required to fulfill the transaction.
|
|
341
|
+
* @param param0 __namedParamaters Object
|
|
342
|
+
* @param order The order to fulfill, a.k.a. "take"
|
|
343
|
+
* @param accountAddress The taker's wallet address
|
|
344
|
+
* @param recipientAddress The optional address to receive the order's item(s) or curriencies. If not specified, defaults to accountAddress.
|
|
345
|
+
* @param referrerAddress The optional address that referred the order
|
|
346
|
+
* @returns gasEstimation
|
|
347
|
+
*/
|
|
348
|
+
getFulfillOrderArgs({ order, accountAddress, recipientAddress, referrerAddress, }: {
|
|
349
|
+
order: Order;
|
|
350
|
+
accountAddress: string;
|
|
351
|
+
recipientAddress?: string;
|
|
352
|
+
referrerAddress?: string;
|
|
353
|
+
}): Promise<{
|
|
354
|
+
args: WyvernAtomicMatchParameters;
|
|
355
|
+
txnData: {
|
|
356
|
+
from: string;
|
|
357
|
+
value?: BigNumber;
|
|
358
|
+
gas?: number;
|
|
359
|
+
};
|
|
360
|
+
}>;
|
|
324
361
|
/**
|
|
325
362
|
* Cancel an order on-chain, preventing it from ever being fulfilled.
|
|
326
363
|
* @param param0 __namedParameters Object
|
|
@@ -782,6 +819,9 @@ export declare class OpenSeaPort {
|
|
|
782
819
|
*/
|
|
783
820
|
private _getPriceParameters;
|
|
784
821
|
private _getMetadata;
|
|
822
|
+
private _validateOrderMatch;
|
|
823
|
+
private _getAtomicMatchCallArgs;
|
|
824
|
+
private _getAtomicMatchGasEstimation;
|
|
785
825
|
private _atomicMatch;
|
|
786
826
|
private _getRequiredAmountForTakingSellOrder;
|
|
787
827
|
/**
|
package/lib/seaport.js
CHANGED
|
@@ -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 !== null && quantities !== void 0 ? quantities : assets.map(function (_a) { return 1; }),
|
|
549
549
|
accountAddress: accountAddress,
|
|
550
550
|
startAmount: startAmount,
|
|
551
551
|
expirationTime: expirationTime,
|
|
552
|
-
paymentTokenAddress: paymentTokenAddress,
|
|
552
|
+
paymentTokenAddress: paymentTokenAddress !== null && paymentTokenAddress !== void 0 ? paymentTokenAddress : WyvernSchemas.tokens[this._networkName].canonicalWrappedEther.address,
|
|
553
553
|
extraBountyBasisPoints: 0,
|
|
554
554
|
sellOrder: sellOrder,
|
|
555
555
|
referrerAddress: referrerAddress,
|
|
@@ -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 !== null && paymentTokenAddress !== void 0 ? paymentTokenAddress : WyvernSchemas.tokens[this._networkName].canonicalWrappedEther.address,
|
|
621
621
|
extraBountyBasisPoints: 0,
|
|
622
622
|
sellOrder: sellOrder,
|
|
623
623
|
referrerAddress: referrerAddress,
|
|
@@ -981,6 +981,77 @@ 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
|
+
};
|
|
984
1055
|
/**
|
|
985
1056
|
* Cancel an order on-chain, preventing it from ever being fulfilled.
|
|
986
1057
|
* @param param0 __namedParameters Object
|
|
@@ -3329,17 +3400,15 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
3329
3400
|
}
|
|
3330
3401
|
return undefined;
|
|
3331
3402
|
};
|
|
3332
|
-
OpenSeaPort.prototype.
|
|
3333
|
-
var buy = _b.buy, sell = _b.sell, accountAddress = _b.accountAddress
|
|
3403
|
+
OpenSeaPort.prototype._validateOrderMatch = function (_b) {
|
|
3404
|
+
var buy = _b.buy, sell = _b.sell, accountAddress = _b.accountAddress;
|
|
3334
3405
|
return __awaiter(this, void 0, void 0, function () {
|
|
3335
|
-
var
|
|
3336
|
-
return __generator(this, function (
|
|
3337
|
-
switch (
|
|
3406
|
+
var shouldValidateBuy, shouldValidateSell;
|
|
3407
|
+
return __generator(this, function (_c) {
|
|
3408
|
+
switch (_c.label) {
|
|
3338
3409
|
case 0:
|
|
3339
3410
|
shouldValidateBuy = true;
|
|
3340
3411
|
shouldValidateSell = true;
|
|
3341
|
-
wyvernProtocol = this._getWyvernProtocolForOrder(buy);
|
|
3342
|
-
wyvernProtocolReadOnly = this._getWyvernProtocolForOrder(buy, true);
|
|
3343
3412
|
if (!(sell.maker.toLowerCase() == accountAddress.toLowerCase())) return [3 /*break*/, 2];
|
|
3344
3413
|
// USER IS THE SELLER, only validate the buy order
|
|
3345
3414
|
return [4 /*yield*/, this._sellOrderValidationAndApprovals({
|
|
@@ -3348,11 +3417,11 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
3348
3417
|
})];
|
|
3349
3418
|
case 1:
|
|
3350
3419
|
// USER IS THE SELLER, only validate the buy order
|
|
3351
|
-
|
|
3420
|
+
_c.sent();
|
|
3352
3421
|
shouldValidateSell = false;
|
|
3353
|
-
return [3 /*break*/,
|
|
3422
|
+
return [3 /*break*/, 4];
|
|
3354
3423
|
case 2:
|
|
3355
|
-
if (!(buy.maker.toLowerCase() == accountAddress.toLowerCase())) return [3 /*break*/,
|
|
3424
|
+
if (!(buy.maker.toLowerCase() == accountAddress.toLowerCase())) return [3 /*break*/, 4];
|
|
3356
3425
|
// USER IS THE BUYER, only validate the sell order
|
|
3357
3426
|
return [4 /*yield*/, this._buyOrderValidationAndApprovals({
|
|
3358
3427
|
order: buy,
|
|
@@ -3361,30 +3430,43 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
3361
3430
|
})];
|
|
3362
3431
|
case 3:
|
|
3363
3432
|
// USER IS THE BUYER, only validate the sell order
|
|
3364
|
-
|
|
3433
|
+
_c.sent();
|
|
3365
3434
|
shouldValidateBuy = false;
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
case 4:
|
|
3369
|
-
value = _d.sent();
|
|
3370
|
-
_d.label = 5;
|
|
3371
|
-
case 5: return [3 /*break*/, 6];
|
|
3372
|
-
case 6: return [4 /*yield*/, this._validateMatch({
|
|
3435
|
+
return [3 /*break*/, 4];
|
|
3436
|
+
case 4: return [4 /*yield*/, this._validateMatch({
|
|
3373
3437
|
buy: buy,
|
|
3374
3438
|
sell: sell,
|
|
3375
3439
|
accountAddress: accountAddress,
|
|
3376
3440
|
shouldValidateBuy: shouldValidateBuy,
|
|
3377
3441
|
shouldValidateSell: shouldValidateSell,
|
|
3378
3442
|
})];
|
|
3379
|
-
case
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3443
|
+
case 5:
|
|
3444
|
+
_c.sent();
|
|
3445
|
+
return [2 /*return*/];
|
|
3446
|
+
}
|
|
3447
|
+
});
|
|
3448
|
+
});
|
|
3449
|
+
};
|
|
3450
|
+
OpenSeaPort.prototype._getAtomicMatchCallArgs = function (_b) {
|
|
3451
|
+
var buy = _b.buy, sell = _b.sell, accountAddress = _b.accountAddress, _c = _b.metadata, metadata = _c === void 0 ? constants_1.NULL_BLOCK_HASH : _c;
|
|
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
|
+
};
|
|
3388
3470
|
args = [
|
|
3389
3471
|
[
|
|
3390
3472
|
buy.exchange,
|
|
@@ -3447,30 +3529,79 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
3447
3529
|
metadata,
|
|
3448
3530
|
],
|
|
3449
3531
|
];
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3532
|
+
return [2 /*return*/, {
|
|
3533
|
+
args: args,
|
|
3534
|
+
txnData: txnData,
|
|
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]);
|
|
3453
3548
|
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)];
|
|
3454
|
-
case
|
|
3455
|
-
gasEstimate =
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
error_13 = _d.sent();
|
|
3549
|
+
case 1:
|
|
3550
|
+
gasEstimate = _c.sent();
|
|
3551
|
+
return [2 /*return*/, this._correctGasAmount(gasEstimate)];
|
|
3552
|
+
case 2:
|
|
3553
|
+
error_13 = _c.sent();
|
|
3460
3554
|
console.error("Failed atomic match with args: ", args, error_13);
|
|
3461
3555
|
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
|
|
3462
3556
|
? error_13.message.substr(0, debugging_1.MAX_ERROR_LENGTH)
|
|
3463
3557
|
: "unknown", "...\""));
|
|
3464
|
-
case
|
|
3465
|
-
|
|
3558
|
+
case 3: return [2 /*return*/];
|
|
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]);
|
|
3466
3597
|
this.logger("Fulfilling order with gas set to ".concat(txnData.gas));
|
|
3467
3598
|
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)];
|
|
3468
|
-
case
|
|
3599
|
+
case 4:
|
|
3469
3600
|
txHash =
|
|
3470
|
-
|
|
3471
|
-
return [3 /*break*/,
|
|
3472
|
-
case
|
|
3473
|
-
error_14 =
|
|
3601
|
+
_f.sent();
|
|
3602
|
+
return [3 /*break*/, 6];
|
|
3603
|
+
case 5:
|
|
3604
|
+
error_14 = _f.sent();
|
|
3474
3605
|
console.error(error_14);
|
|
3475
3606
|
this._dispatch(types_1.EventType.TransactionDenied, {
|
|
3476
3607
|
error: error_14,
|
|
@@ -3482,7 +3613,7 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
3482
3613
|
throw new Error("Failed to authorize transaction: \"".concat(error_14 instanceof Error && error_14.message
|
|
3483
3614
|
? error_14.message
|
|
3484
3615
|
: "user denied", "...\""));
|
|
3485
|
-
case
|
|
3616
|
+
case 6: return [2 /*return*/, txHash];
|
|
3486
3617
|
}
|
|
3487
3618
|
});
|
|
3488
3619
|
});
|
|
@@ -3568,7 +3699,7 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
3568
3699
|
expirationTime: order.expirationTime.toString(),
|
|
3569
3700
|
salt: order.salt.toString(),
|
|
3570
3701
|
};
|
|
3571
|
-
message =
|
|
3702
|
+
message = {
|
|
3572
3703
|
types: constants_1.EIP_712_ORDER_TYPES,
|
|
3573
3704
|
domain: {
|
|
3574
3705
|
name: constants_1.EIP_712_WYVERN_DOMAIN_NAME,
|
|
@@ -3578,7 +3709,7 @@ var OpenSeaPort = /** @class */ (function () {
|
|
|
3578
3709
|
},
|
|
3579
3710
|
primaryType: "Order",
|
|
3580
3711
|
message: __assign(__assign({}, orderForSigning), { nonce: signerOrderNonce.toNumber() }),
|
|
3581
|
-
}
|
|
3712
|
+
};
|
|
3582
3713
|
return [4 /*yield*/, (0, utils_1.signTypedDataAsync)(this.web3, message, signerAddress)];
|
|
3583
3714
|
case 5:
|
|
3584
3715
|
ecSignature = _b.sent();
|