@imtbl/sdk 0.6.0-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 +20 -4
- package/dist/checkout_sdk.js +2212 -122
- package/dist/checkout_widgets.d.ts +10498 -154
- package/dist/checkout_widgets.js +57 -8
- 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 +239 -71
- package/dist/index.d.ts +77 -16
- package/dist/index.js +239 -71
- package/dist/orderbook.d.ts +30 -11
- package/dist/orderbook.js +61 -33
- package/dist/passport.js +2 -2
- package/package.json +1 -1
package/dist/orderbook.js
CHANGED
|
@@ -528,6 +528,21 @@ var OrderStatus;
|
|
|
528
528
|
OrderStatus["EXPIRED"] = "EXPIRED";
|
|
529
529
|
})(OrderStatus || (OrderStatus = {}));
|
|
530
530
|
|
|
531
|
+
var TransactionPurpose;
|
|
532
|
+
(function (TransactionPurpose) {
|
|
533
|
+
TransactionPurpose["APPROVAL"] = "APPROVAL";
|
|
534
|
+
TransactionPurpose["FULFILL_ORDER"] = "FULFILL_ORDER";
|
|
535
|
+
})(TransactionPurpose || (TransactionPurpose = {}));
|
|
536
|
+
var SignablePurpose;
|
|
537
|
+
(function (SignablePurpose) {
|
|
538
|
+
SignablePurpose["CREATE_LISTING"] = "CREATE_LISTING";
|
|
539
|
+
})(SignablePurpose || (SignablePurpose = {}));
|
|
540
|
+
var ActionType;
|
|
541
|
+
(function (ActionType) {
|
|
542
|
+
ActionType["TRANSACTION"] = "TRANSACTION";
|
|
543
|
+
ActionType["SIGNABLE"] = "SIGNABLE";
|
|
544
|
+
})(ActionType || (ActionType = {}));
|
|
545
|
+
|
|
531
546
|
/* eslint-disable */
|
|
532
547
|
// TODO: Resolve these from seaport-js.
|
|
533
548
|
// There is some bundling issue that is preventing this from working
|
|
@@ -604,12 +619,14 @@ function getOrderComponentsFromMessage(orderMessage) {
|
|
|
604
619
|
|
|
605
620
|
// Add 20% more gas than estimate to prevent out of gas errors
|
|
606
621
|
// This can always be overwritten by the user signing the transaction
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
.
|
|
612
|
-
|
|
622
|
+
function prepareTransaction(transactionMethods) {
|
|
623
|
+
return async () => {
|
|
624
|
+
const transaction = await transactionMethods.buildTransaction();
|
|
625
|
+
transaction.gasLimit = await transactionMethods.estimateGas();
|
|
626
|
+
transaction.gasLimit = transaction.gasLimit
|
|
627
|
+
.add(transaction.gasLimit.div(5));
|
|
628
|
+
return transaction;
|
|
629
|
+
};
|
|
613
630
|
}
|
|
614
631
|
|
|
615
632
|
function mapImmutableOrderToSeaportOrderComponents(order, counter, zoneAddress) {
|
|
@@ -691,31 +708,39 @@ class Seaport {
|
|
|
691
708
|
this.zoneContractAddress = zoneContractAddress;
|
|
692
709
|
}
|
|
693
710
|
async prepareSeaportOrder(offerer, listingItem, considerationItem, royaltyInfo, orderStart, orderExpiry) {
|
|
694
|
-
const { actions } = await this.createSeaportOrder(offerer, listingItem, considerationItem, royaltyInfo, orderStart, orderExpiry);
|
|
695
|
-
|
|
696
|
-
const approvalAction =
|
|
711
|
+
const { actions: seaportActions } = await this.createSeaportOrder(offerer, listingItem, considerationItem, royaltyInfo, orderStart, orderExpiry);
|
|
712
|
+
const listingActions = [];
|
|
713
|
+
const approvalAction = seaportActions
|
|
697
714
|
.find((action) => action.type === 'approval');
|
|
698
715
|
if (approvalAction) {
|
|
699
|
-
|
|
716
|
+
listingActions.push({
|
|
717
|
+
type: ActionType.TRANSACTION,
|
|
718
|
+
purpose: TransactionPurpose.APPROVAL,
|
|
719
|
+
buildTransaction: prepareTransaction(approvalAction.transactionMethods),
|
|
720
|
+
});
|
|
700
721
|
}
|
|
701
|
-
const createAction =
|
|
722
|
+
const createAction = seaportActions
|
|
702
723
|
.find((action) => action.type === 'create');
|
|
703
724
|
if (!createAction) {
|
|
704
725
|
throw new Error('No create order action found');
|
|
705
726
|
}
|
|
706
727
|
const orderMessageToSign = await createAction.getMessageToSign();
|
|
707
728
|
const orderComponents = getOrderComponentsFromMessage(orderMessageToSign);
|
|
729
|
+
listingActions.push({
|
|
730
|
+
type: ActionType.SIGNABLE,
|
|
731
|
+
purpose: SignablePurpose.CREATE_LISTING,
|
|
732
|
+
message: await this.getTypedDataFromOrderComponents(orderComponents),
|
|
733
|
+
});
|
|
708
734
|
return {
|
|
709
|
-
|
|
710
|
-
typedOrderMessageForSigning: await this.getTypedDataFromOrderComponents(orderComponents),
|
|
735
|
+
actions: listingActions,
|
|
711
736
|
orderComponents,
|
|
712
737
|
orderHash: this.getSeaportLib().getOrderHash(orderComponents),
|
|
713
738
|
};
|
|
714
739
|
}
|
|
715
|
-
async
|
|
740
|
+
async fulfillOrder(order, account) {
|
|
716
741
|
const orderComponents = await this.mapImmutableOrderToSeaportOrderComponents(order);
|
|
717
742
|
const seaportLib = this.getSeaportLib(order);
|
|
718
|
-
const { actions } = await seaportLib.fulfillOrders({
|
|
743
|
+
const { actions: seaportActions } = await seaportLib.fulfillOrders({
|
|
719
744
|
accountAddress: account,
|
|
720
745
|
fulfillOrderDetails: [{
|
|
721
746
|
order: {
|
|
@@ -725,28 +750,33 @@ class Seaport {
|
|
|
725
750
|
extraData: order.protocol_data.operator_signature,
|
|
726
751
|
}],
|
|
727
752
|
});
|
|
728
|
-
|
|
729
|
-
const approvalAction =
|
|
753
|
+
const fulfillmentActions = [];
|
|
754
|
+
const approvalAction = seaportActions
|
|
730
755
|
.find((action) => action.type === 'approval');
|
|
731
756
|
if (approvalAction) {
|
|
732
|
-
|
|
757
|
+
fulfillmentActions.push({
|
|
758
|
+
type: ActionType.TRANSACTION,
|
|
759
|
+
buildTransaction: prepareTransaction(approvalAction.transactionMethods),
|
|
760
|
+
purpose: TransactionPurpose.APPROVAL,
|
|
761
|
+
});
|
|
733
762
|
}
|
|
734
|
-
const
|
|
763
|
+
const fulfilOrderAction = seaportActions
|
|
735
764
|
.find((action) => action.type === 'exchange');
|
|
736
|
-
if (!
|
|
765
|
+
if (!fulfilOrderAction) {
|
|
737
766
|
throw new Error('No exchange action found');
|
|
738
767
|
}
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
};
|
|
768
|
+
fulfillmentActions.push({
|
|
769
|
+
type: ActionType.TRANSACTION,
|
|
770
|
+
buildTransaction: prepareTransaction(fulfilOrderAction.transactionMethods),
|
|
771
|
+
purpose: TransactionPurpose.FULFILL_ORDER,
|
|
772
|
+
});
|
|
773
|
+
return { actions: fulfillmentActions };
|
|
744
774
|
}
|
|
745
775
|
async cancelOrder(order, account) {
|
|
746
776
|
const orderComponents = await this.mapImmutableOrderToSeaportOrderComponents(order);
|
|
747
777
|
const seaportLib = this.getSeaportLib(order);
|
|
748
778
|
const cancellationTransaction = await seaportLib.cancelOrders([orderComponents], account);
|
|
749
|
-
return prepareTransaction(cancellationTransaction);
|
|
779
|
+
return prepareTransaction(cancellationTransaction)();
|
|
750
780
|
}
|
|
751
781
|
mapImmutableOrderToSeaportOrderComponents(order) {
|
|
752
782
|
const orderCounter = order.protocol_data.counter;
|
|
@@ -910,9 +940,9 @@ function getOrderbookConfig(environment) {
|
|
|
910
940
|
switch (environment) {
|
|
911
941
|
case Environment.SANDBOX:
|
|
912
942
|
return {
|
|
913
|
-
seaportContractAddress: '
|
|
914
|
-
zoneContractAddress: '
|
|
915
|
-
apiEndpoint: 'https://
|
|
943
|
+
seaportContractAddress: '0x410000346E270aDbC89b2b688177d3AE76348dE9',
|
|
944
|
+
zoneContractAddress: '0x979C2aCA989A56554Eb63E01e576E3179Cdad5A0',
|
|
945
|
+
apiEndpoint: 'https://order-book-mr.sandbox.imtbl.com',
|
|
916
946
|
chainName: TESTNET_CHAIN_NAME,
|
|
917
947
|
provider: new providers.JsonRpcProvider('https://rpc.testnet.immutable.com'),
|
|
918
948
|
};
|
|
@@ -1954,7 +1984,7 @@ class Orderbook {
|
|
|
1954
1984
|
if (orderResult.result.status !== OrderStatus.ACTIVE) {
|
|
1955
1985
|
throw new Error(`Cannot fulfil order that is not active. Current status: ${orderResult.result.status}`);
|
|
1956
1986
|
}
|
|
1957
|
-
return this.seaport.
|
|
1987
|
+
return this.seaport.fulfillOrder(orderResult.result, takerAddress);
|
|
1958
1988
|
}
|
|
1959
1989
|
/**
|
|
1960
1990
|
* Get an unsigned cancel order transaction. Orders can only be cancelled by
|
|
@@ -1978,6 +2008,4 @@ class Orderbook {
|
|
|
1978
2008
|
}
|
|
1979
2009
|
}
|
|
1980
2010
|
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
export { Orderbook, module };
|
|
2011
|
+
export { ActionType, Orderbook, SignablePurpose, TransactionPurpose };
|
package/dist/passport.js
CHANGED
|
@@ -1457,7 +1457,7 @@ class MultiRollupApiClients {
|
|
|
1457
1457
|
}
|
|
1458
1458
|
|
|
1459
1459
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1460
|
-
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.
|
|
1460
|
+
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.7.0-alpha.1' };
|
|
1461
1461
|
const createConfig = ({ basePath, headers, }) => {
|
|
1462
1462
|
if (!basePath.trim()) {
|
|
1463
1463
|
throw Error('basePath can not be empty');
|
|
@@ -1513,7 +1513,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
1513
1513
|
chainID,
|
|
1514
1514
|
coreContractAddress,
|
|
1515
1515
|
registrationContractAddress,
|
|
1516
|
-
sdkVersion: 'ts-immutable-sdk-0.
|
|
1516
|
+
sdkVersion: 'ts-immutable-sdk-0.7.0-alpha.1',
|
|
1517
1517
|
});
|
|
1518
1518
|
/**
|
|
1519
1519
|
* Sets `sdkVersion` at the time of build
|
package/package.json
CHANGED