@imtbl/sdk 0.14.0-alpha.1 → 0.15.0-alpha
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 -0
- package/dist/checkout_sdk.js +411 -94
- package/dist/checkout_widgets.js +1 -1
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +7 -7
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +415 -98
- package/dist/index.d.ts +12 -1
- package/dist/index.js +415 -98
- package/dist/orderbook.d.ts +10 -1
- package/dist/orderbook.js +77 -67
- package/dist/passport.js +2 -2
- package/package.json +1 -1
package/dist/orderbook.js
CHANGED
|
@@ -575,6 +575,67 @@ var ActionType;
|
|
|
575
575
|
ActionType["SIGNABLE"] = "SIGNABLE";
|
|
576
576
|
})(ActionType || (ActionType = {}));
|
|
577
577
|
|
|
578
|
+
function mapFromOpenApiOrder(order) {
|
|
579
|
+
const buyItems = order.buy.map((item) => {
|
|
580
|
+
if (item.item_type === 'ERC20') {
|
|
581
|
+
return {
|
|
582
|
+
type: 'ERC20',
|
|
583
|
+
contractAddress: item.contract_address,
|
|
584
|
+
amount: item.start_amount,
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
if (item.item_type === 'NATIVE') {
|
|
588
|
+
return {
|
|
589
|
+
type: 'NATIVE',
|
|
590
|
+
amount: item.start_amount,
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
throw new Error('Buy items must be either ERC20 or NATIVE');
|
|
594
|
+
});
|
|
595
|
+
const sellItems = order.sell.map((item) => {
|
|
596
|
+
if (item.item_type === 'ERC721') {
|
|
597
|
+
return {
|
|
598
|
+
type: 'ERC721',
|
|
599
|
+
contractAddress: item.contract_address,
|
|
600
|
+
tokenId: item.token_id,
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
throw new Error('Sell items must ERC721');
|
|
604
|
+
});
|
|
605
|
+
return {
|
|
606
|
+
id: order.id,
|
|
607
|
+
accountAddress: order.account_address,
|
|
608
|
+
buy: buyItems,
|
|
609
|
+
sell: sellItems,
|
|
610
|
+
fees: order.fees.map((fee) => ({
|
|
611
|
+
amount: fee.amount,
|
|
612
|
+
recipient: fee.recipient,
|
|
613
|
+
type: fee.fee_type,
|
|
614
|
+
})),
|
|
615
|
+
chain: order.chain,
|
|
616
|
+
createTime: order.create_time,
|
|
617
|
+
endTime: order.end_time,
|
|
618
|
+
protocolData: {
|
|
619
|
+
counter: order.protocol_data.counter,
|
|
620
|
+
orderType: order.protocol_data.order_type,
|
|
621
|
+
seaportAddress: order.protocol_data.seaport_address,
|
|
622
|
+
seaportVersion: order.protocol_data.seaport_version,
|
|
623
|
+
zoneAddress: order.protocol_data.zone_address,
|
|
624
|
+
},
|
|
625
|
+
salt: order.salt,
|
|
626
|
+
signature: order.signature,
|
|
627
|
+
startTime: order.start_time,
|
|
628
|
+
status: order.status,
|
|
629
|
+
updateTime: order.update_time,
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
function mapFromOpenApiPage(page) {
|
|
633
|
+
return {
|
|
634
|
+
nextCursor: page.next_cursor,
|
|
635
|
+
previousCursor: page.previous_cursor,
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
|
|
578
639
|
/* eslint-disable */
|
|
579
640
|
// TODO: Resolve these from seaport-js.
|
|
580
641
|
// There is some bundling issue that is preventing this from working
|
|
@@ -804,7 +865,17 @@ class Seaport {
|
|
|
804
865
|
buildTransaction: prepareTransaction(fulfilOrderAction.transactionMethods),
|
|
805
866
|
purpose: TransactionPurpose.FULFILL_ORDER,
|
|
806
867
|
});
|
|
807
|
-
|
|
868
|
+
// Expirtaion bytes in SIP7 extra data [21:29]
|
|
869
|
+
// In hex string -> [21 * 2 + 2 (0x) : 29 * 2]
|
|
870
|
+
// In JS slice (start, end_inclusive), (44,60)
|
|
871
|
+
// 8 bytes uint64 epoch time in seconds
|
|
872
|
+
const expirationHex = extraData.slice(44, 60);
|
|
873
|
+
const expirationInSeconds = parseInt(expirationHex, 16);
|
|
874
|
+
return {
|
|
875
|
+
actions: fulfillmentActions,
|
|
876
|
+
expiration: (new Date(expirationInSeconds * 1000)).toISOString(),
|
|
877
|
+
order: mapFromOpenApiOrder(order),
|
|
878
|
+
};
|
|
808
879
|
}
|
|
809
880
|
async cancelOrder(order, account) {
|
|
810
881
|
const { orderComponents } = this.mapImmutableOrderToSeaportOrderComponents(order);
|
|
@@ -922,11 +993,11 @@ class ImmutableApiClient {
|
|
|
922
993
|
contract_address: orderComponents.consideration[0].token,
|
|
923
994
|
},
|
|
924
995
|
],
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
996
|
+
fee: makerFee ? {
|
|
997
|
+
amount: makerFee.amount,
|
|
998
|
+
fee_type: FeeType.MAKER_MARKETPLACE,
|
|
999
|
+
recipient: makerFee.recipient,
|
|
1000
|
+
} : undefined,
|
|
930
1001
|
end_time: new Date(parseInt(`${orderComponents.endTime.toString()}000`, 10)).toISOString(),
|
|
931
1002
|
protocol_data: {
|
|
932
1003
|
order_type: ProtocolData.order_type.FULL_RESTRICTED,
|
|
@@ -993,67 +1064,6 @@ function getOrderbookConfig(environment) {
|
|
|
993
1064
|
}
|
|
994
1065
|
}
|
|
995
1066
|
|
|
996
|
-
function mapFromOpenApiOrder(order) {
|
|
997
|
-
const buyItems = order.buy.map((item) => {
|
|
998
|
-
if (item.item_type === 'ERC20') {
|
|
999
|
-
return {
|
|
1000
|
-
type: 'ERC20',
|
|
1001
|
-
contractAddress: item.contract_address,
|
|
1002
|
-
amount: item.start_amount,
|
|
1003
|
-
};
|
|
1004
|
-
}
|
|
1005
|
-
if (item.item_type === 'NATIVE') {
|
|
1006
|
-
return {
|
|
1007
|
-
type: 'NATIVE',
|
|
1008
|
-
amount: item.start_amount,
|
|
1009
|
-
};
|
|
1010
|
-
}
|
|
1011
|
-
throw new Error('Buy items must be either ERC20 or NATIVE');
|
|
1012
|
-
});
|
|
1013
|
-
const sellItems = order.sell.map((item) => {
|
|
1014
|
-
if (item.item_type === 'ERC721') {
|
|
1015
|
-
return {
|
|
1016
|
-
type: 'ERC721',
|
|
1017
|
-
contractAddress: item.contract_address,
|
|
1018
|
-
tokenId: item.token_id,
|
|
1019
|
-
};
|
|
1020
|
-
}
|
|
1021
|
-
throw new Error('Sell items must ERC721');
|
|
1022
|
-
});
|
|
1023
|
-
return {
|
|
1024
|
-
id: order.id,
|
|
1025
|
-
accountAddress: order.account_address,
|
|
1026
|
-
buy: buyItems,
|
|
1027
|
-
sell: sellItems,
|
|
1028
|
-
fees: order.fees.map((fee) => ({
|
|
1029
|
-
amount: fee.amount,
|
|
1030
|
-
recipient: fee.recipient,
|
|
1031
|
-
type: fee.fee_type,
|
|
1032
|
-
})),
|
|
1033
|
-
chain: order.chain,
|
|
1034
|
-
createTime: order.create_time,
|
|
1035
|
-
endTime: order.end_time,
|
|
1036
|
-
protocolData: {
|
|
1037
|
-
counter: order.protocol_data.counter,
|
|
1038
|
-
orderType: order.protocol_data.order_type,
|
|
1039
|
-
seaportAddress: order.protocol_data.seaport_address,
|
|
1040
|
-
seaportVersion: order.protocol_data.seaport_version,
|
|
1041
|
-
zoneAddress: order.protocol_data.zone_address,
|
|
1042
|
-
},
|
|
1043
|
-
salt: order.salt,
|
|
1044
|
-
signature: order.signature,
|
|
1045
|
-
startTime: order.start_time,
|
|
1046
|
-
status: order.status,
|
|
1047
|
-
updateTime: order.update_time,
|
|
1048
|
-
};
|
|
1049
|
-
}
|
|
1050
|
-
function mapFromOpenApiPage(page) {
|
|
1051
|
-
return {
|
|
1052
|
-
nextCursor: page.next_cursor,
|
|
1053
|
-
previousCursor: page.previous_cursor,
|
|
1054
|
-
};
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
1067
|
class SeaportLibFactory {
|
|
1058
1068
|
defaultSeaportContractAddress;
|
|
1059
1069
|
provider;
|
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.15.0-alpha' };
|
|
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.15.0-alpha',
|
|
1517
1517
|
});
|
|
1518
1518
|
/**
|
|
1519
1519
|
* Sets `sdkVersion` at the time of build
|
package/package.json
CHANGED