@imtbl/sdk 0.14.0-alpha → 0.14.0-alpha.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/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 +436 -39
- 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 +440 -43
- package/dist/index.d.ts +87 -25
- package/dist/index.js +440 -43
- package/dist/orderbook.d.ts +72 -16
- package/dist/orderbook.js +99 -9
- package/dist/passport.js +2 -2
- package/package.json +1 -1
package/dist/orderbook.d.ts
CHANGED
|
@@ -866,7 +866,7 @@ declare enum OrderStatus {
|
|
|
866
866
|
EXPIRED = "EXPIRED"
|
|
867
867
|
}
|
|
868
868
|
|
|
869
|
-
type Order = {
|
|
869
|
+
type Order$1 = {
|
|
870
870
|
account_address: string;
|
|
871
871
|
buy: Array<Item>;
|
|
872
872
|
fees: Array<Fee$1>;
|
|
@@ -906,17 +906,17 @@ type Order = {
|
|
|
906
906
|
|
|
907
907
|
type FulfillmentDataResult = {
|
|
908
908
|
extra_data: string;
|
|
909
|
-
order: Order;
|
|
909
|
+
order: Order$1;
|
|
910
910
|
};
|
|
911
911
|
|
|
912
|
-
type ListingResult = {
|
|
913
|
-
result: Order;
|
|
912
|
+
type ListingResult$1 = {
|
|
913
|
+
result: Order$1;
|
|
914
914
|
};
|
|
915
915
|
|
|
916
916
|
/**
|
|
917
917
|
* Pagination properties
|
|
918
918
|
*/
|
|
919
|
-
type Page = {
|
|
919
|
+
type Page$1 = {
|
|
920
920
|
/**
|
|
921
921
|
* First item as an encoded string
|
|
922
922
|
*/
|
|
@@ -927,9 +927,9 @@ type Page = {
|
|
|
927
927
|
next_cursor: string | null;
|
|
928
928
|
};
|
|
929
929
|
|
|
930
|
-
type ListListingsResult = {
|
|
931
|
-
page: Page;
|
|
932
|
-
result: Array<Order>;
|
|
930
|
+
type ListListingsResult$1 = {
|
|
931
|
+
page: Page$1;
|
|
932
|
+
result: Array<Order$1>;
|
|
933
933
|
};
|
|
934
934
|
|
|
935
935
|
/**
|
|
@@ -985,7 +985,7 @@ declare class OrdersService {
|
|
|
985
985
|
* Page cursor to retrieve previous or next page. Use the value returned in the response.
|
|
986
986
|
*/
|
|
987
987
|
pageCursor?: PageCursor;
|
|
988
|
-
}): CancelablePromise<ListListingsResult>;
|
|
988
|
+
}): CancelablePromise<ListListingsResult$1>;
|
|
989
989
|
/**
|
|
990
990
|
* Create a listing
|
|
991
991
|
* Create a listing
|
|
@@ -995,7 +995,7 @@ declare class OrdersService {
|
|
|
995
995
|
createListing({ chainName, requestBody, }: {
|
|
996
996
|
chainName: ChainName;
|
|
997
997
|
requestBody: CreateListingRequestBody;
|
|
998
|
-
}): CancelablePromise<ListingResult>;
|
|
998
|
+
}): CancelablePromise<ListingResult$1>;
|
|
999
999
|
/**
|
|
1000
1000
|
* Get a single listing by ID
|
|
1001
1001
|
* Get a single listing by ID
|
|
@@ -1008,7 +1008,7 @@ declare class OrdersService {
|
|
|
1008
1008
|
* Global Order identifier
|
|
1009
1009
|
*/
|
|
1010
1010
|
listingId: string;
|
|
1011
|
-
}): CancelablePromise<ListingResult>;
|
|
1011
|
+
}): CancelablePromise<ListingResult$1>;
|
|
1012
1012
|
/**
|
|
1013
1013
|
* Retrieve fulfillment data for orders
|
|
1014
1014
|
* Retrieve signed fulfillment data based on the list of order IDs and corresponding fees.
|
|
@@ -1056,7 +1056,7 @@ interface CreateListingParams {
|
|
|
1056
1056
|
orderComponents: OrderComponents;
|
|
1057
1057
|
orderHash: string;
|
|
1058
1058
|
orderSignature: string;
|
|
1059
|
-
makerFee?:
|
|
1059
|
+
makerFee?: FeeValue;
|
|
1060
1060
|
}
|
|
1061
1061
|
type ListListingsParams = Omit<Parameters<typeof OrdersService.prototype.listListings>[0], 'chainName'>;
|
|
1062
1062
|
declare enum FeeType {
|
|
@@ -1065,11 +1065,13 @@ declare enum FeeType {
|
|
|
1065
1065
|
PROTOCOL = "PROTOCOL",
|
|
1066
1066
|
ROYALTY = "ROYALTY"
|
|
1067
1067
|
}
|
|
1068
|
-
interface
|
|
1069
|
-
type: FeeType;
|
|
1068
|
+
interface FeeValue {
|
|
1070
1069
|
recipient: string;
|
|
1071
1070
|
amount: string;
|
|
1072
1071
|
}
|
|
1072
|
+
interface Fee extends FeeValue {
|
|
1073
|
+
type: FeeType;
|
|
1074
|
+
}
|
|
1073
1075
|
declare enum TransactionPurpose {
|
|
1074
1076
|
APPROVAL = "APPROVAL",
|
|
1075
1077
|
FULFILL_ORDER = "FULFILL_ORDER"
|
|
@@ -1099,10 +1101,64 @@ interface SignableAction {
|
|
|
1099
1101
|
type Action = TransactionAction | SignableAction;
|
|
1100
1102
|
interface FulfillOrderResponse {
|
|
1101
1103
|
actions: Action[];
|
|
1104
|
+
/**
|
|
1105
|
+
* User MUST submit the fulfillment transaction before the expiration
|
|
1106
|
+
* Submitting after the expiration will result in a on chain revert
|
|
1107
|
+
*/
|
|
1108
|
+
expiration: string;
|
|
1109
|
+
order: Order;
|
|
1102
1110
|
}
|
|
1103
1111
|
interface CancelOrderResponse {
|
|
1104
1112
|
unsignedCancelOrderTransaction: PopulatedTransaction;
|
|
1105
1113
|
}
|
|
1114
|
+
interface Order {
|
|
1115
|
+
id: string;
|
|
1116
|
+
accountAddress: string;
|
|
1117
|
+
buy: (ERC20Item | NativeItem)[];
|
|
1118
|
+
sell: ERC721Item[];
|
|
1119
|
+
fees: Fee[];
|
|
1120
|
+
chain: {
|
|
1121
|
+
id: string;
|
|
1122
|
+
name: string;
|
|
1123
|
+
};
|
|
1124
|
+
createTime: string;
|
|
1125
|
+
updateTime: string;
|
|
1126
|
+
/**
|
|
1127
|
+
* Time after which the Order is considered active
|
|
1128
|
+
*/
|
|
1129
|
+
startTime: string;
|
|
1130
|
+
/**
|
|
1131
|
+
* Time after which the Order is expired
|
|
1132
|
+
*/
|
|
1133
|
+
endTime: string;
|
|
1134
|
+
protocolData: {
|
|
1135
|
+
orderType: 'FULL_RESTRICTED';
|
|
1136
|
+
zoneAddress: string;
|
|
1137
|
+
counter: string;
|
|
1138
|
+
seaportAddress: string;
|
|
1139
|
+
seaportVersion: string;
|
|
1140
|
+
};
|
|
1141
|
+
salt: string;
|
|
1142
|
+
signature: string;
|
|
1143
|
+
status: OrderStatus;
|
|
1144
|
+
}
|
|
1145
|
+
interface ListingResult {
|
|
1146
|
+
result: Order;
|
|
1147
|
+
}
|
|
1148
|
+
interface ListListingsResult {
|
|
1149
|
+
page: Page;
|
|
1150
|
+
result: Order[];
|
|
1151
|
+
}
|
|
1152
|
+
interface Page {
|
|
1153
|
+
/**
|
|
1154
|
+
* First item as an encoded string
|
|
1155
|
+
*/
|
|
1156
|
+
previousCursor: string | null;
|
|
1157
|
+
/**
|
|
1158
|
+
* Last item as an encoded string
|
|
1159
|
+
*/
|
|
1160
|
+
nextCursor: string | null;
|
|
1161
|
+
}
|
|
1106
1162
|
|
|
1107
1163
|
/**
|
|
1108
1164
|
* zkEVM orderbook SDK
|
|
@@ -1155,7 +1211,7 @@ declare class Orderbook {
|
|
|
1155
1211
|
* @param {string} fulfillerAddress - The address of the account fulfilling the order.
|
|
1156
1212
|
* @return {FulfillOrderResponse} Approval and fulfilment transactions.
|
|
1157
1213
|
*/
|
|
1158
|
-
fulfillOrder(listingId: string, takerAddress: string, takerFee?:
|
|
1214
|
+
fulfillOrder(listingId: string, takerAddress: string, takerFee?: FeeValue): Promise<FulfillOrderResponse>;
|
|
1159
1215
|
/**
|
|
1160
1216
|
* Get an unsigned cancel order transaction. Orders can only be cancelled by
|
|
1161
1217
|
* the account that created them.
|
|
@@ -1170,4 +1226,4 @@ declare const constants: {
|
|
|
1170
1226
|
estimatedFulfillmentGasGwei: number;
|
|
1171
1227
|
};
|
|
1172
1228
|
|
|
1173
|
-
export { Action, ActionType, CancelOrderResponse, CreateListingParams, ERC20Item, ERC721Item, Fee, FeeType, FulfillOrderResponse, ListListingsParams, ListListingsResult, ListingResult, NativeItem, Order, OrderStatus, Orderbook, PrepareListingParams, PrepareListingResponse, RoyaltyInfo, SignableAction, SignablePurpose, TransactionAction, TransactionBuilder, TransactionPurpose, constants };
|
|
1229
|
+
export { Action, ActionType, CancelOrderResponse, CreateListingParams, ERC20Item, ERC721Item, Fee, FeeType, FeeValue, FulfillOrderResponse, ListListingsParams, ListListingsResult, ListingResult, NativeItem, Order, OrderStatus, Orderbook, Page, PrepareListingParams, PrepareListingResponse, RoyaltyInfo, SignableAction, SignablePurpose, TransactionAction, TransactionBuilder, TransactionPurpose, constants };
|
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);
|
|
@@ -924,7 +995,7 @@ class ImmutableApiClient {
|
|
|
924
995
|
],
|
|
925
996
|
fees: makerFee ? [{
|
|
926
997
|
amount: makerFee.amount,
|
|
927
|
-
fee_type:
|
|
998
|
+
fee_type: FeeType.MAKER_MARKETPLACE,
|
|
928
999
|
recipient: makerFee.recipient,
|
|
929
1000
|
}] : [],
|
|
930
1001
|
end_time: new Date(parseInt(`${orderComponents.endTime.toString()}000`, 10)).toISOString(),
|
|
@@ -1052,8 +1123,11 @@ class Orderbook {
|
|
|
1052
1123
|
* @param {string} listingId - The listingId to find.
|
|
1053
1124
|
* @return {ListingResult} The returned order result.
|
|
1054
1125
|
*/
|
|
1055
|
-
getListing(listingId) {
|
|
1056
|
-
|
|
1126
|
+
async getListing(listingId) {
|
|
1127
|
+
const apiListing = await this.apiClient.getListing(listingId);
|
|
1128
|
+
return {
|
|
1129
|
+
result: mapFromOpenApiOrder(apiListing.result),
|
|
1130
|
+
};
|
|
1057
1131
|
}
|
|
1058
1132
|
/**
|
|
1059
1133
|
* List orders. This method is used to get a list of orders filtered by conditions specified
|
|
@@ -1061,8 +1135,12 @@ class Orderbook {
|
|
|
1061
1135
|
* @param {ListListingsParams} listOrderParams - Filtering, ordering and page parameters.
|
|
1062
1136
|
* @return {ListListingsResult} The paged orders.
|
|
1063
1137
|
*/
|
|
1064
|
-
listListings(listOrderParams) {
|
|
1065
|
-
|
|
1138
|
+
async listListings(listOrderParams) {
|
|
1139
|
+
const apiListings = await this.apiClient.listListings(listOrderParams);
|
|
1140
|
+
return {
|
|
1141
|
+
page: mapFromOpenApiPage(apiListings.page),
|
|
1142
|
+
result: apiListings.result.map(mapFromOpenApiOrder),
|
|
1143
|
+
};
|
|
1066
1144
|
}
|
|
1067
1145
|
/**
|
|
1068
1146
|
* Get required transactions and messages for signing prior to creating a listing
|
|
@@ -1084,8 +1162,20 @@ class Orderbook {
|
|
|
1084
1162
|
* @param {CreateListingParams} createListingParams - create an order with the given params.
|
|
1085
1163
|
* @return {ListingResult} The result of the order created in the Immutable services.
|
|
1086
1164
|
*/
|
|
1087
|
-
createListing(createListingParams) {
|
|
1088
|
-
|
|
1165
|
+
async createListing(createListingParams) {
|
|
1166
|
+
const makerFee = createListingParams.makerFee
|
|
1167
|
+
? {
|
|
1168
|
+
...createListingParams.makerFee,
|
|
1169
|
+
type: FeeType.MAKER_MARKETPLACE,
|
|
1170
|
+
}
|
|
1171
|
+
: undefined;
|
|
1172
|
+
const apiListingResponse = await this.apiClient.createListing({
|
|
1173
|
+
...createListingParams,
|
|
1174
|
+
makerFee,
|
|
1175
|
+
});
|
|
1176
|
+
return {
|
|
1177
|
+
result: mapFromOpenApiOrder(apiListingResponse.result),
|
|
1178
|
+
};
|
|
1089
1179
|
}
|
|
1090
1180
|
/**
|
|
1091
1181
|
* Get unsigned transactions that can be submitted to fulfil an open order. If the approval
|
|
@@ -1102,7 +1192,7 @@ class Orderbook {
|
|
|
1102
1192
|
fee: takerFee
|
|
1103
1193
|
? {
|
|
1104
1194
|
amount: takerFee.amount,
|
|
1105
|
-
fee_type:
|
|
1195
|
+
fee_type: FeeType.TAKER_MARKETPLACE,
|
|
1106
1196
|
recipient: takerFee.recipient,
|
|
1107
1197
|
}
|
|
1108
1198
|
: undefined,
|
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.14.0-alpha' };
|
|
1460
|
+
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.14.0-alpha.2' };
|
|
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.14.0-alpha',
|
|
1516
|
+
sdkVersion: 'ts-immutable-sdk-0.14.0-alpha.2',
|
|
1517
1517
|
});
|
|
1518
1518
|
/**
|
|
1519
1519
|
* Sets `sdkVersion` at the time of build
|
package/package.json
CHANGED