@imtbl/sdk 0.6.1-alpha → 0.7.0-alpha.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/dist/blockchain_data.js +1 -1
- package/dist/browser/checkout.js +2 -2
- package/dist/checkout_sdk.d.ts +2 -1
- package/dist/checkout_sdk.js +61 -30
- package/dist/checkout_widgets.d.ts +2 -1
- package/dist/checkout_widgets.js +1 -1
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +8 -8
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +69 -35
- package/dist/index.d.ts +48 -9
- package/dist/index.js +69 -35
- package/dist/orderbook.d.ts +30 -9
- package/dist/orderbook.js +61 -31
- package/dist/passport.js +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2420,7 +2420,7 @@ class MultiRollupApiClients {
|
|
|
2420
2420
|
}
|
|
2421
2421
|
|
|
2422
2422
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2423
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.
|
|
2423
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.7.0-alpha.1' };
|
|
2424
2424
|
const createConfig = ({ basePath, headers, }) => {
|
|
2425
2425
|
if (!basePath.trim()) {
|
|
2426
2426
|
throw Error('basePath can not be empty');
|
|
@@ -2480,7 +2480,7 @@ class APIError extends Error {
|
|
|
2480
2480
|
|
|
2481
2481
|
/* eslint-disable implicit-arrow-linebreak */
|
|
2482
2482
|
const defaultHeaders = {
|
|
2483
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.
|
|
2483
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.7.0-alpha.1',
|
|
2484
2484
|
};
|
|
2485
2485
|
/**
|
|
2486
2486
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -2752,7 +2752,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
2752
2752
|
chainID,
|
|
2753
2753
|
coreContractAddress,
|
|
2754
2754
|
registrationContractAddress,
|
|
2755
|
-
sdkVersion: 'ts-immutable-sdk-0.
|
|
2755
|
+
sdkVersion: 'ts-immutable-sdk-0.7.0-alpha.1',
|
|
2756
2756
|
});
|
|
2757
2757
|
/**
|
|
2758
2758
|
* Sets `sdkVersion` at the time of build
|
|
@@ -9491,6 +9491,21 @@ var OrderStatus;
|
|
|
9491
9491
|
OrderStatus["EXPIRED"] = "EXPIRED";
|
|
9492
9492
|
})(OrderStatus || (OrderStatus = {}));
|
|
9493
9493
|
|
|
9494
|
+
var TransactionPurpose;
|
|
9495
|
+
(function (TransactionPurpose) {
|
|
9496
|
+
TransactionPurpose["APPROVAL"] = "APPROVAL";
|
|
9497
|
+
TransactionPurpose["FULFILL_ORDER"] = "FULFILL_ORDER";
|
|
9498
|
+
})(TransactionPurpose || (TransactionPurpose = {}));
|
|
9499
|
+
var SignablePurpose;
|
|
9500
|
+
(function (SignablePurpose) {
|
|
9501
|
+
SignablePurpose["CREATE_LISTING"] = "CREATE_LISTING";
|
|
9502
|
+
})(SignablePurpose || (SignablePurpose = {}));
|
|
9503
|
+
var ActionType;
|
|
9504
|
+
(function (ActionType) {
|
|
9505
|
+
ActionType["TRANSACTION"] = "TRANSACTION";
|
|
9506
|
+
ActionType["SIGNABLE"] = "SIGNABLE";
|
|
9507
|
+
})(ActionType || (ActionType = {}));
|
|
9508
|
+
|
|
9494
9509
|
/* eslint-disable */
|
|
9495
9510
|
// TODO: Resolve these from seaport-js.
|
|
9496
9511
|
// There is some bundling issue that is preventing this from working
|
|
@@ -9567,12 +9582,14 @@ function getOrderComponentsFromMessage(orderMessage) {
|
|
|
9567
9582
|
|
|
9568
9583
|
// Add 20% more gas than estimate to prevent out of gas errors
|
|
9569
9584
|
// This can always be overwritten by the user signing the transaction
|
|
9570
|
-
|
|
9571
|
-
|
|
9572
|
-
|
|
9573
|
-
|
|
9574
|
-
.
|
|
9575
|
-
|
|
9585
|
+
function prepareTransaction(transactionMethods) {
|
|
9586
|
+
return async () => {
|
|
9587
|
+
const transaction = await transactionMethods.buildTransaction();
|
|
9588
|
+
transaction.gasLimit = await transactionMethods.estimateGas();
|
|
9589
|
+
transaction.gasLimit = transaction.gasLimit
|
|
9590
|
+
.add(transaction.gasLimit.div(5));
|
|
9591
|
+
return transaction;
|
|
9592
|
+
};
|
|
9576
9593
|
}
|
|
9577
9594
|
|
|
9578
9595
|
function mapImmutableOrderToSeaportOrderComponents(order, counter, zoneAddress) {
|
|
@@ -9654,31 +9671,39 @@ class Seaport {
|
|
|
9654
9671
|
this.zoneContractAddress = zoneContractAddress;
|
|
9655
9672
|
}
|
|
9656
9673
|
async prepareSeaportOrder(offerer, listingItem, considerationItem, royaltyInfo, orderStart, orderExpiry) {
|
|
9657
|
-
const { actions } = await this.createSeaportOrder(offerer, listingItem, considerationItem, royaltyInfo, orderStart, orderExpiry);
|
|
9658
|
-
|
|
9659
|
-
const approvalAction =
|
|
9674
|
+
const { actions: seaportActions } = await this.createSeaportOrder(offerer, listingItem, considerationItem, royaltyInfo, orderStart, orderExpiry);
|
|
9675
|
+
const listingActions = [];
|
|
9676
|
+
const approvalAction = seaportActions
|
|
9660
9677
|
.find((action) => action.type === 'approval');
|
|
9661
9678
|
if (approvalAction) {
|
|
9662
|
-
|
|
9679
|
+
listingActions.push({
|
|
9680
|
+
type: ActionType.TRANSACTION,
|
|
9681
|
+
purpose: TransactionPurpose.APPROVAL,
|
|
9682
|
+
buildTransaction: prepareTransaction(approvalAction.transactionMethods),
|
|
9683
|
+
});
|
|
9663
9684
|
}
|
|
9664
|
-
const createAction =
|
|
9685
|
+
const createAction = seaportActions
|
|
9665
9686
|
.find((action) => action.type === 'create');
|
|
9666
9687
|
if (!createAction) {
|
|
9667
9688
|
throw new Error('No create order action found');
|
|
9668
9689
|
}
|
|
9669
9690
|
const orderMessageToSign = await createAction.getMessageToSign();
|
|
9670
9691
|
const orderComponents = getOrderComponentsFromMessage(orderMessageToSign);
|
|
9692
|
+
listingActions.push({
|
|
9693
|
+
type: ActionType.SIGNABLE,
|
|
9694
|
+
purpose: SignablePurpose.CREATE_LISTING,
|
|
9695
|
+
message: await this.getTypedDataFromOrderComponents(orderComponents),
|
|
9696
|
+
});
|
|
9671
9697
|
return {
|
|
9672
|
-
|
|
9673
|
-
typedOrderMessageForSigning: await this.getTypedDataFromOrderComponents(orderComponents),
|
|
9698
|
+
actions: listingActions,
|
|
9674
9699
|
orderComponents,
|
|
9675
9700
|
orderHash: this.getSeaportLib().getOrderHash(orderComponents),
|
|
9676
9701
|
};
|
|
9677
9702
|
}
|
|
9678
|
-
async
|
|
9703
|
+
async fulfillOrder(order, account) {
|
|
9679
9704
|
const orderComponents = await this.mapImmutableOrderToSeaportOrderComponents(order);
|
|
9680
9705
|
const seaportLib = this.getSeaportLib(order);
|
|
9681
|
-
const { actions } = await seaportLib.fulfillOrders({
|
|
9706
|
+
const { actions: seaportActions } = await seaportLib.fulfillOrders({
|
|
9682
9707
|
accountAddress: account,
|
|
9683
9708
|
fulfillOrderDetails: [{
|
|
9684
9709
|
order: {
|
|
@@ -9688,28 +9713,33 @@ class Seaport {
|
|
|
9688
9713
|
extraData: order.protocol_data.operator_signature,
|
|
9689
9714
|
}],
|
|
9690
9715
|
});
|
|
9691
|
-
|
|
9692
|
-
const approvalAction =
|
|
9716
|
+
const fulfillmentActions = [];
|
|
9717
|
+
const approvalAction = seaportActions
|
|
9693
9718
|
.find((action) => action.type === 'approval');
|
|
9694
9719
|
if (approvalAction) {
|
|
9695
|
-
|
|
9720
|
+
fulfillmentActions.push({
|
|
9721
|
+
type: ActionType.TRANSACTION,
|
|
9722
|
+
buildTransaction: prepareTransaction(approvalAction.transactionMethods),
|
|
9723
|
+
purpose: TransactionPurpose.APPROVAL,
|
|
9724
|
+
});
|
|
9696
9725
|
}
|
|
9697
|
-
const
|
|
9726
|
+
const fulfilOrderAction = seaportActions
|
|
9698
9727
|
.find((action) => action.type === 'exchange');
|
|
9699
|
-
if (!
|
|
9728
|
+
if (!fulfilOrderAction) {
|
|
9700
9729
|
throw new Error('No exchange action found');
|
|
9701
9730
|
}
|
|
9702
|
-
|
|
9703
|
-
|
|
9704
|
-
|
|
9705
|
-
|
|
9706
|
-
};
|
|
9731
|
+
fulfillmentActions.push({
|
|
9732
|
+
type: ActionType.TRANSACTION,
|
|
9733
|
+
buildTransaction: prepareTransaction(fulfilOrderAction.transactionMethods),
|
|
9734
|
+
purpose: TransactionPurpose.FULFILL_ORDER,
|
|
9735
|
+
});
|
|
9736
|
+
return { actions: fulfillmentActions };
|
|
9707
9737
|
}
|
|
9708
9738
|
async cancelOrder(order, account) {
|
|
9709
9739
|
const orderComponents = await this.mapImmutableOrderToSeaportOrderComponents(order);
|
|
9710
9740
|
const seaportLib = this.getSeaportLib(order);
|
|
9711
9741
|
const cancellationTransaction = await seaportLib.cancelOrders([orderComponents], account);
|
|
9712
|
-
return prepareTransaction(cancellationTransaction);
|
|
9742
|
+
return prepareTransaction(cancellationTransaction)();
|
|
9713
9743
|
}
|
|
9714
9744
|
mapImmutableOrderToSeaportOrderComponents(order) {
|
|
9715
9745
|
const orderCounter = order.protocol_data.counter;
|
|
@@ -9873,9 +9903,9 @@ function getOrderbookConfig(environment) {
|
|
|
9873
9903
|
switch (environment) {
|
|
9874
9904
|
case Environment$1.SANDBOX:
|
|
9875
9905
|
return {
|
|
9876
|
-
seaportContractAddress: '
|
|
9877
|
-
zoneContractAddress: '
|
|
9878
|
-
apiEndpoint: 'https://
|
|
9906
|
+
seaportContractAddress: '0x410000346E270aDbC89b2b688177d3AE76348dE9',
|
|
9907
|
+
zoneContractAddress: '0x979C2aCA989A56554Eb63E01e576E3179Cdad5A0',
|
|
9908
|
+
apiEndpoint: 'https://order-book-mr.sandbox.imtbl.com',
|
|
9879
9909
|
chainName: TESTNET_CHAIN_NAME,
|
|
9880
9910
|
provider: new ethers.providers.JsonRpcProvider('https://rpc.testnet.immutable.com'),
|
|
9881
9911
|
};
|
|
@@ -10917,7 +10947,7 @@ class Orderbook {
|
|
|
10917
10947
|
if (orderResult.result.status !== OrderStatus.ACTIVE) {
|
|
10918
10948
|
throw new Error(`Cannot fulfil order that is not active. Current status: ${orderResult.result.status}`);
|
|
10919
10949
|
}
|
|
10920
|
-
return this.seaport.
|
|
10950
|
+
return this.seaport.fulfillOrder(orderResult.result, takerAddress);
|
|
10921
10951
|
}
|
|
10922
10952
|
/**
|
|
10923
10953
|
* Get an unsigned cancel order transaction. Orders can only be cancelled by
|
|
@@ -10943,7 +10973,10 @@ class Orderbook {
|
|
|
10943
10973
|
|
|
10944
10974
|
var orderbook = /*#__PURE__*/Object.freeze({
|
|
10945
10975
|
__proto__: null,
|
|
10946
|
-
|
|
10976
|
+
get ActionType () { return ActionType; },
|
|
10977
|
+
Orderbook: Orderbook,
|
|
10978
|
+
get SignablePurpose () { return SignablePurpose; },
|
|
10979
|
+
get TransactionPurpose () { return TransactionPurpose; }
|
|
10947
10980
|
});
|
|
10948
10981
|
|
|
10949
10982
|
function isChainValid(chainID, config) {
|
|
@@ -27556,6 +27589,7 @@ var $4f91c5f280efe242$export$a75605c67ea83a5a;
|
|
|
27556
27589
|
var $e768639828688ca3$export$2d7a51a18d87e21d;
|
|
27557
27590
|
(function(WalletProviderName) {
|
|
27558
27591
|
WalletProviderName["METAMASK"] = "metamask";
|
|
27592
|
+
WalletProviderName["PASSPORT"] = "passport";
|
|
27559
27593
|
})($e768639828688ca3$export$2d7a51a18d87e21d || ($e768639828688ca3$export$2d7a51a18d87e21d = {}));
|
|
27560
27594
|
const $e768639828688ca3$export$44dde05038008549 = {
|
|
27561
27595
|
allowMistmatchedChainId: false,
|
|
@@ -28644,7 +28678,7 @@ var checkout_sdk = /*#__PURE__*/Object.freeze({
|
|
|
28644
28678
|
function $parcel$export(e, n, v, s) {
|
|
28645
28679
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
28646
28680
|
}
|
|
28647
|
-
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.
|
|
28681
|
+
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.7.0-alpha.1";
|
|
28648
28682
|
const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
|
|
28649
28683
|
const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
|
|
28650
28684
|
|
package/dist/index.d.ts
CHANGED
|
@@ -13170,12 +13170,7 @@ interface PrepareListingParams {
|
|
|
13170
13170
|
orderExpiry?: Date;
|
|
13171
13171
|
}
|
|
13172
13172
|
interface PrepareListingResponse {
|
|
13173
|
-
|
|
13174
|
-
typedOrderMessageForSigning: {
|
|
13175
|
-
domain: TypedDataDomain;
|
|
13176
|
-
types: Record<string, TypedDataField[]>;
|
|
13177
|
-
value: Record<string, any>;
|
|
13178
|
-
};
|
|
13173
|
+
actions: Action[];
|
|
13179
13174
|
orderComponents: OrderComponents;
|
|
13180
13175
|
orderHash: string;
|
|
13181
13176
|
}
|
|
@@ -13185,14 +13180,43 @@ interface CreateListingParams {
|
|
|
13185
13180
|
orderSignature: string;
|
|
13186
13181
|
}
|
|
13187
13182
|
type ListListingsParams = Omit<Parameters<typeof OrdersService.prototype.listListings>[0], 'chainName'>;
|
|
13183
|
+
declare enum TransactionPurpose {
|
|
13184
|
+
APPROVAL = "APPROVAL",
|
|
13185
|
+
FULFILL_ORDER = "FULFILL_ORDER"
|
|
13186
|
+
}
|
|
13187
|
+
declare enum SignablePurpose {
|
|
13188
|
+
CREATE_LISTING = "CREATE_LISTING"
|
|
13189
|
+
}
|
|
13190
|
+
declare enum ActionType {
|
|
13191
|
+
TRANSACTION = "TRANSACTION",
|
|
13192
|
+
SIGNABLE = "SIGNABLE"
|
|
13193
|
+
}
|
|
13194
|
+
type TransactionBuilder = () => Promise<PopulatedTransaction>;
|
|
13195
|
+
interface TransactionAction {
|
|
13196
|
+
type: ActionType.TRANSACTION;
|
|
13197
|
+
purpose: TransactionPurpose;
|
|
13198
|
+
buildTransaction: TransactionBuilder;
|
|
13199
|
+
}
|
|
13200
|
+
interface SignableAction {
|
|
13201
|
+
type: ActionType.SIGNABLE;
|
|
13202
|
+
purpose: SignablePurpose;
|
|
13203
|
+
message: {
|
|
13204
|
+
domain: TypedDataDomain;
|
|
13205
|
+
types: Record<string, TypedDataField[]>;
|
|
13206
|
+
value: Record<string, any>;
|
|
13207
|
+
};
|
|
13208
|
+
}
|
|
13209
|
+
type Action = TransactionAction | SignableAction;
|
|
13188
13210
|
interface FulfillOrderResponse {
|
|
13189
|
-
|
|
13190
|
-
unsignedFulfillmentTransaction: PopulatedTransaction;
|
|
13211
|
+
actions: Action[];
|
|
13191
13212
|
}
|
|
13192
13213
|
interface CancelOrderResponse {
|
|
13193
13214
|
unsignedCancelOrderTransaction: PopulatedTransaction;
|
|
13194
13215
|
}
|
|
13195
13216
|
|
|
13217
|
+
type orderbook_d_Action = Action;
|
|
13218
|
+
type orderbook_d_ActionType = ActionType;
|
|
13219
|
+
declare const orderbook_d_ActionType: typeof ActionType;
|
|
13196
13220
|
type orderbook_d_CancelOrderResponse = CancelOrderResponse;
|
|
13197
13221
|
type orderbook_d_CreateListingParams = CreateListingParams;
|
|
13198
13222
|
type orderbook_d_ERC20Item = ERC20Item;
|
|
@@ -13205,8 +13229,17 @@ declare const orderbook_d_Orderbook: typeof Orderbook;
|
|
|
13205
13229
|
type orderbook_d_PrepareListingParams = PrepareListingParams;
|
|
13206
13230
|
type orderbook_d_PrepareListingResponse = PrepareListingResponse;
|
|
13207
13231
|
type orderbook_d_RoyaltyInfo = RoyaltyInfo;
|
|
13232
|
+
type orderbook_d_SignableAction = SignableAction;
|
|
13233
|
+
type orderbook_d_SignablePurpose = SignablePurpose;
|
|
13234
|
+
declare const orderbook_d_SignablePurpose: typeof SignablePurpose;
|
|
13235
|
+
type orderbook_d_TransactionAction = TransactionAction;
|
|
13236
|
+
type orderbook_d_TransactionBuilder = TransactionBuilder;
|
|
13237
|
+
type orderbook_d_TransactionPurpose = TransactionPurpose;
|
|
13238
|
+
declare const orderbook_d_TransactionPurpose: typeof TransactionPurpose;
|
|
13208
13239
|
declare namespace orderbook_d {
|
|
13209
13240
|
export {
|
|
13241
|
+
orderbook_d_Action as Action,
|
|
13242
|
+
orderbook_d_ActionType as ActionType,
|
|
13210
13243
|
orderbook_d_CancelOrderResponse as CancelOrderResponse,
|
|
13211
13244
|
orderbook_d_CreateListingParams as CreateListingParams,
|
|
13212
13245
|
orderbook_d_ERC20Item as ERC20Item,
|
|
@@ -13218,6 +13251,11 @@ declare namespace orderbook_d {
|
|
|
13218
13251
|
orderbook_d_PrepareListingParams as PrepareListingParams,
|
|
13219
13252
|
orderbook_d_PrepareListingResponse as PrepareListingResponse,
|
|
13220
13253
|
orderbook_d_RoyaltyInfo as RoyaltyInfo,
|
|
13254
|
+
orderbook_d_SignableAction as SignableAction,
|
|
13255
|
+
orderbook_d_SignablePurpose as SignablePurpose,
|
|
13256
|
+
orderbook_d_TransactionAction as TransactionAction,
|
|
13257
|
+
orderbook_d_TransactionBuilder as TransactionBuilder,
|
|
13258
|
+
orderbook_d_TransactionPurpose as TransactionPurpose,
|
|
13221
13259
|
};
|
|
13222
13260
|
}
|
|
13223
13261
|
|
|
@@ -13646,7 +13684,8 @@ interface SendTransactionResult {
|
|
|
13646
13684
|
* Enum representing the names of different wallet providers.
|
|
13647
13685
|
*/
|
|
13648
13686
|
declare enum WalletProviderName {
|
|
13649
|
-
METAMASK = "metamask"
|
|
13687
|
+
METAMASK = "metamask",
|
|
13688
|
+
PASSPORT = "passport"
|
|
13650
13689
|
}
|
|
13651
13690
|
/**
|
|
13652
13691
|
* Interface for the parameters required to create a wallet provider {@link Checkout.createProvider}.
|
package/dist/index.js
CHANGED
|
@@ -2398,7 +2398,7 @@ class MultiRollupApiClients {
|
|
|
2398
2398
|
}
|
|
2399
2399
|
|
|
2400
2400
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2401
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.
|
|
2401
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.7.0-alpha.1' };
|
|
2402
2402
|
const createConfig = ({ basePath, headers, }) => {
|
|
2403
2403
|
if (!basePath.trim()) {
|
|
2404
2404
|
throw Error('basePath can not be empty');
|
|
@@ -2458,7 +2458,7 @@ class APIError extends Error {
|
|
|
2458
2458
|
|
|
2459
2459
|
/* eslint-disable implicit-arrow-linebreak */
|
|
2460
2460
|
const defaultHeaders = {
|
|
2461
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.
|
|
2461
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.7.0-alpha.1',
|
|
2462
2462
|
};
|
|
2463
2463
|
/**
|
|
2464
2464
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -2730,7 +2730,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
2730
2730
|
chainID,
|
|
2731
2731
|
coreContractAddress,
|
|
2732
2732
|
registrationContractAddress,
|
|
2733
|
-
sdkVersion: 'ts-immutable-sdk-0.
|
|
2733
|
+
sdkVersion: 'ts-immutable-sdk-0.7.0-alpha.1',
|
|
2734
2734
|
});
|
|
2735
2735
|
/**
|
|
2736
2736
|
* Sets `sdkVersion` at the time of build
|
|
@@ -9469,6 +9469,21 @@ var OrderStatus;
|
|
|
9469
9469
|
OrderStatus["EXPIRED"] = "EXPIRED";
|
|
9470
9470
|
})(OrderStatus || (OrderStatus = {}));
|
|
9471
9471
|
|
|
9472
|
+
var TransactionPurpose;
|
|
9473
|
+
(function (TransactionPurpose) {
|
|
9474
|
+
TransactionPurpose["APPROVAL"] = "APPROVAL";
|
|
9475
|
+
TransactionPurpose["FULFILL_ORDER"] = "FULFILL_ORDER";
|
|
9476
|
+
})(TransactionPurpose || (TransactionPurpose = {}));
|
|
9477
|
+
var SignablePurpose;
|
|
9478
|
+
(function (SignablePurpose) {
|
|
9479
|
+
SignablePurpose["CREATE_LISTING"] = "CREATE_LISTING";
|
|
9480
|
+
})(SignablePurpose || (SignablePurpose = {}));
|
|
9481
|
+
var ActionType;
|
|
9482
|
+
(function (ActionType) {
|
|
9483
|
+
ActionType["TRANSACTION"] = "TRANSACTION";
|
|
9484
|
+
ActionType["SIGNABLE"] = "SIGNABLE";
|
|
9485
|
+
})(ActionType || (ActionType = {}));
|
|
9486
|
+
|
|
9472
9487
|
/* eslint-disable */
|
|
9473
9488
|
// TODO: Resolve these from seaport-js.
|
|
9474
9489
|
// There is some bundling issue that is preventing this from working
|
|
@@ -9545,12 +9560,14 @@ function getOrderComponentsFromMessage(orderMessage) {
|
|
|
9545
9560
|
|
|
9546
9561
|
// Add 20% more gas than estimate to prevent out of gas errors
|
|
9547
9562
|
// This can always be overwritten by the user signing the transaction
|
|
9548
|
-
|
|
9549
|
-
|
|
9550
|
-
|
|
9551
|
-
|
|
9552
|
-
.
|
|
9553
|
-
|
|
9563
|
+
function prepareTransaction(transactionMethods) {
|
|
9564
|
+
return async () => {
|
|
9565
|
+
const transaction = await transactionMethods.buildTransaction();
|
|
9566
|
+
transaction.gasLimit = await transactionMethods.estimateGas();
|
|
9567
|
+
transaction.gasLimit = transaction.gasLimit
|
|
9568
|
+
.add(transaction.gasLimit.div(5));
|
|
9569
|
+
return transaction;
|
|
9570
|
+
};
|
|
9554
9571
|
}
|
|
9555
9572
|
|
|
9556
9573
|
function mapImmutableOrderToSeaportOrderComponents(order, counter, zoneAddress) {
|
|
@@ -9632,31 +9649,39 @@ class Seaport {
|
|
|
9632
9649
|
this.zoneContractAddress = zoneContractAddress;
|
|
9633
9650
|
}
|
|
9634
9651
|
async prepareSeaportOrder(offerer, listingItem, considerationItem, royaltyInfo, orderStart, orderExpiry) {
|
|
9635
|
-
const { actions } = await this.createSeaportOrder(offerer, listingItem, considerationItem, royaltyInfo, orderStart, orderExpiry);
|
|
9636
|
-
|
|
9637
|
-
const approvalAction =
|
|
9652
|
+
const { actions: seaportActions } = await this.createSeaportOrder(offerer, listingItem, considerationItem, royaltyInfo, orderStart, orderExpiry);
|
|
9653
|
+
const listingActions = [];
|
|
9654
|
+
const approvalAction = seaportActions
|
|
9638
9655
|
.find((action) => action.type === 'approval');
|
|
9639
9656
|
if (approvalAction) {
|
|
9640
|
-
|
|
9657
|
+
listingActions.push({
|
|
9658
|
+
type: ActionType.TRANSACTION,
|
|
9659
|
+
purpose: TransactionPurpose.APPROVAL,
|
|
9660
|
+
buildTransaction: prepareTransaction(approvalAction.transactionMethods),
|
|
9661
|
+
});
|
|
9641
9662
|
}
|
|
9642
|
-
const createAction =
|
|
9663
|
+
const createAction = seaportActions
|
|
9643
9664
|
.find((action) => action.type === 'create');
|
|
9644
9665
|
if (!createAction) {
|
|
9645
9666
|
throw new Error('No create order action found');
|
|
9646
9667
|
}
|
|
9647
9668
|
const orderMessageToSign = await createAction.getMessageToSign();
|
|
9648
9669
|
const orderComponents = getOrderComponentsFromMessage(orderMessageToSign);
|
|
9670
|
+
listingActions.push({
|
|
9671
|
+
type: ActionType.SIGNABLE,
|
|
9672
|
+
purpose: SignablePurpose.CREATE_LISTING,
|
|
9673
|
+
message: await this.getTypedDataFromOrderComponents(orderComponents),
|
|
9674
|
+
});
|
|
9649
9675
|
return {
|
|
9650
|
-
|
|
9651
|
-
typedOrderMessageForSigning: await this.getTypedDataFromOrderComponents(orderComponents),
|
|
9676
|
+
actions: listingActions,
|
|
9652
9677
|
orderComponents,
|
|
9653
9678
|
orderHash: this.getSeaportLib().getOrderHash(orderComponents),
|
|
9654
9679
|
};
|
|
9655
9680
|
}
|
|
9656
|
-
async
|
|
9681
|
+
async fulfillOrder(order, account) {
|
|
9657
9682
|
const orderComponents = await this.mapImmutableOrderToSeaportOrderComponents(order);
|
|
9658
9683
|
const seaportLib = this.getSeaportLib(order);
|
|
9659
|
-
const { actions } = await seaportLib.fulfillOrders({
|
|
9684
|
+
const { actions: seaportActions } = await seaportLib.fulfillOrders({
|
|
9660
9685
|
accountAddress: account,
|
|
9661
9686
|
fulfillOrderDetails: [{
|
|
9662
9687
|
order: {
|
|
@@ -9666,28 +9691,33 @@ class Seaport {
|
|
|
9666
9691
|
extraData: order.protocol_data.operator_signature,
|
|
9667
9692
|
}],
|
|
9668
9693
|
});
|
|
9669
|
-
|
|
9670
|
-
const approvalAction =
|
|
9694
|
+
const fulfillmentActions = [];
|
|
9695
|
+
const approvalAction = seaportActions
|
|
9671
9696
|
.find((action) => action.type === 'approval');
|
|
9672
9697
|
if (approvalAction) {
|
|
9673
|
-
|
|
9698
|
+
fulfillmentActions.push({
|
|
9699
|
+
type: ActionType.TRANSACTION,
|
|
9700
|
+
buildTransaction: prepareTransaction(approvalAction.transactionMethods),
|
|
9701
|
+
purpose: TransactionPurpose.APPROVAL,
|
|
9702
|
+
});
|
|
9674
9703
|
}
|
|
9675
|
-
const
|
|
9704
|
+
const fulfilOrderAction = seaportActions
|
|
9676
9705
|
.find((action) => action.type === 'exchange');
|
|
9677
|
-
if (!
|
|
9706
|
+
if (!fulfilOrderAction) {
|
|
9678
9707
|
throw new Error('No exchange action found');
|
|
9679
9708
|
}
|
|
9680
|
-
|
|
9681
|
-
|
|
9682
|
-
|
|
9683
|
-
|
|
9684
|
-
};
|
|
9709
|
+
fulfillmentActions.push({
|
|
9710
|
+
type: ActionType.TRANSACTION,
|
|
9711
|
+
buildTransaction: prepareTransaction(fulfilOrderAction.transactionMethods),
|
|
9712
|
+
purpose: TransactionPurpose.FULFILL_ORDER,
|
|
9713
|
+
});
|
|
9714
|
+
return { actions: fulfillmentActions };
|
|
9685
9715
|
}
|
|
9686
9716
|
async cancelOrder(order, account) {
|
|
9687
9717
|
const orderComponents = await this.mapImmutableOrderToSeaportOrderComponents(order);
|
|
9688
9718
|
const seaportLib = this.getSeaportLib(order);
|
|
9689
9719
|
const cancellationTransaction = await seaportLib.cancelOrders([orderComponents], account);
|
|
9690
|
-
return prepareTransaction(cancellationTransaction);
|
|
9720
|
+
return prepareTransaction(cancellationTransaction)();
|
|
9691
9721
|
}
|
|
9692
9722
|
mapImmutableOrderToSeaportOrderComponents(order) {
|
|
9693
9723
|
const orderCounter = order.protocol_data.counter;
|
|
@@ -9851,9 +9881,9 @@ function getOrderbookConfig(environment) {
|
|
|
9851
9881
|
switch (environment) {
|
|
9852
9882
|
case Environment$1.SANDBOX:
|
|
9853
9883
|
return {
|
|
9854
|
-
seaportContractAddress: '
|
|
9855
|
-
zoneContractAddress: '
|
|
9856
|
-
apiEndpoint: 'https://
|
|
9884
|
+
seaportContractAddress: '0x410000346E270aDbC89b2b688177d3AE76348dE9',
|
|
9885
|
+
zoneContractAddress: '0x979C2aCA989A56554Eb63E01e576E3179Cdad5A0',
|
|
9886
|
+
apiEndpoint: 'https://order-book-mr.sandbox.imtbl.com',
|
|
9857
9887
|
chainName: TESTNET_CHAIN_NAME,
|
|
9858
9888
|
provider: new providers.JsonRpcProvider('https://rpc.testnet.immutable.com'),
|
|
9859
9889
|
};
|
|
@@ -10895,7 +10925,7 @@ class Orderbook {
|
|
|
10895
10925
|
if (orderResult.result.status !== OrderStatus.ACTIVE) {
|
|
10896
10926
|
throw new Error(`Cannot fulfil order that is not active. Current status: ${orderResult.result.status}`);
|
|
10897
10927
|
}
|
|
10898
|
-
return this.seaport.
|
|
10928
|
+
return this.seaport.fulfillOrder(orderResult.result, takerAddress);
|
|
10899
10929
|
}
|
|
10900
10930
|
/**
|
|
10901
10931
|
* Get an unsigned cancel order transaction. Orders can only be cancelled by
|
|
@@ -10921,7 +10951,10 @@ class Orderbook {
|
|
|
10921
10951
|
|
|
10922
10952
|
var orderbook = /*#__PURE__*/Object.freeze({
|
|
10923
10953
|
__proto__: null,
|
|
10924
|
-
|
|
10954
|
+
get ActionType () { return ActionType; },
|
|
10955
|
+
Orderbook: Orderbook,
|
|
10956
|
+
get SignablePurpose () { return SignablePurpose; },
|
|
10957
|
+
get TransactionPurpose () { return TransactionPurpose; }
|
|
10925
10958
|
});
|
|
10926
10959
|
|
|
10927
10960
|
function isChainValid(chainID, config) {
|
|
@@ -27534,6 +27567,7 @@ var $4f91c5f280efe242$export$a75605c67ea83a5a;
|
|
|
27534
27567
|
var $e768639828688ca3$export$2d7a51a18d87e21d;
|
|
27535
27568
|
(function(WalletProviderName) {
|
|
27536
27569
|
WalletProviderName["METAMASK"] = "metamask";
|
|
27570
|
+
WalletProviderName["PASSPORT"] = "passport";
|
|
27537
27571
|
})($e768639828688ca3$export$2d7a51a18d87e21d || ($e768639828688ca3$export$2d7a51a18d87e21d = {}));
|
|
27538
27572
|
const $e768639828688ca3$export$44dde05038008549 = {
|
|
27539
27573
|
allowMistmatchedChainId: false,
|
|
@@ -28622,7 +28656,7 @@ var checkout_sdk = /*#__PURE__*/Object.freeze({
|
|
|
28622
28656
|
function $parcel$export(e, n, v, s) {
|
|
28623
28657
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
28624
28658
|
}
|
|
28625
|
-
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.
|
|
28659
|
+
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.7.0-alpha.1";
|
|
28626
28660
|
const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
|
|
28627
28661
|
const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
|
|
28628
28662
|
|
package/dist/orderbook.d.ts
CHANGED
|
@@ -224,12 +224,7 @@ interface PrepareListingParams {
|
|
|
224
224
|
orderExpiry?: Date;
|
|
225
225
|
}
|
|
226
226
|
interface PrepareListingResponse {
|
|
227
|
-
|
|
228
|
-
typedOrderMessageForSigning: {
|
|
229
|
-
domain: TypedDataDomain;
|
|
230
|
-
types: Record<string, TypedDataField[]>;
|
|
231
|
-
value: Record<string, any>;
|
|
232
|
-
};
|
|
227
|
+
actions: Action[];
|
|
233
228
|
orderComponents: OrderComponents;
|
|
234
229
|
orderHash: string;
|
|
235
230
|
}
|
|
@@ -239,12 +234,38 @@ interface CreateListingParams {
|
|
|
239
234
|
orderSignature: string;
|
|
240
235
|
}
|
|
241
236
|
type ListListingsParams = Omit<Parameters<typeof OrdersService.prototype.listListings>[0], 'chainName'>;
|
|
237
|
+
declare enum TransactionPurpose {
|
|
238
|
+
APPROVAL = "APPROVAL",
|
|
239
|
+
FULFILL_ORDER = "FULFILL_ORDER"
|
|
240
|
+
}
|
|
241
|
+
declare enum SignablePurpose {
|
|
242
|
+
CREATE_LISTING = "CREATE_LISTING"
|
|
243
|
+
}
|
|
244
|
+
declare enum ActionType {
|
|
245
|
+
TRANSACTION = "TRANSACTION",
|
|
246
|
+
SIGNABLE = "SIGNABLE"
|
|
247
|
+
}
|
|
248
|
+
type TransactionBuilder = () => Promise<PopulatedTransaction>;
|
|
249
|
+
interface TransactionAction {
|
|
250
|
+
type: ActionType.TRANSACTION;
|
|
251
|
+
purpose: TransactionPurpose;
|
|
252
|
+
buildTransaction: TransactionBuilder;
|
|
253
|
+
}
|
|
254
|
+
interface SignableAction {
|
|
255
|
+
type: ActionType.SIGNABLE;
|
|
256
|
+
purpose: SignablePurpose;
|
|
257
|
+
message: {
|
|
258
|
+
domain: TypedDataDomain;
|
|
259
|
+
types: Record<string, TypedDataField[]>;
|
|
260
|
+
value: Record<string, any>;
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
type Action = TransactionAction | SignableAction;
|
|
242
264
|
interface FulfillOrderResponse {
|
|
243
|
-
|
|
244
|
-
unsignedFulfillmentTransaction: PopulatedTransaction;
|
|
265
|
+
actions: Action[];
|
|
245
266
|
}
|
|
246
267
|
interface CancelOrderResponse {
|
|
247
268
|
unsignedCancelOrderTransaction: PopulatedTransaction;
|
|
248
269
|
}
|
|
249
270
|
|
|
250
|
-
export { CancelOrderResponse, CreateListingParams, ERC20Item, ERC721Item, FulfillOrderResponse, ListListingsParams, NativeItem, Orderbook, PrepareListingParams, PrepareListingResponse, RoyaltyInfo };
|
|
271
|
+
export { Action, ActionType, CancelOrderResponse, CreateListingParams, ERC20Item, ERC721Item, FulfillOrderResponse, ListListingsParams, NativeItem, Orderbook, PrepareListingParams, PrepareListingResponse, RoyaltyInfo, SignableAction, SignablePurpose, TransactionAction, TransactionBuilder, TransactionPurpose };
|