@imtbl/sdk 0.14.0-alpha → 0.14.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.
@@ -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?: Fee;
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 Fee {
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"
@@ -1103,6 +1105,54 @@ interface FulfillOrderResponse {
1103
1105
  interface CancelOrderResponse {
1104
1106
  unsignedCancelOrderTransaction: PopulatedTransaction;
1105
1107
  }
1108
+ interface Order {
1109
+ id: string;
1110
+ accountAddress: string;
1111
+ buy: (ERC20Item | NativeItem)[];
1112
+ sell: ERC721Item[];
1113
+ fees: Fee[];
1114
+ chain: {
1115
+ id: string;
1116
+ name: string;
1117
+ };
1118
+ createTime: string;
1119
+ updateTime: string;
1120
+ /**
1121
+ * Time after which the Order is considered active
1122
+ */
1123
+ startTime: string;
1124
+ /**
1125
+ * Time after which the Order is expired
1126
+ */
1127
+ endTime: string;
1128
+ protocolData: {
1129
+ orderType: 'FULL_RESTRICTED';
1130
+ zoneAddress: string;
1131
+ counter: string;
1132
+ seaportAddress: string;
1133
+ seaportVersion: string;
1134
+ };
1135
+ salt: string;
1136
+ signature: string;
1137
+ status: OrderStatus;
1138
+ }
1139
+ interface ListingResult {
1140
+ result: Order;
1141
+ }
1142
+ interface ListListingsResult {
1143
+ page: Page;
1144
+ result: Order[];
1145
+ }
1146
+ interface Page {
1147
+ /**
1148
+ * First item as an encoded string
1149
+ */
1150
+ previousCursor: string | null;
1151
+ /**
1152
+ * Last item as an encoded string
1153
+ */
1154
+ nextCursor: string | null;
1155
+ }
1106
1156
 
1107
1157
  /**
1108
1158
  * zkEVM orderbook SDK
@@ -1155,7 +1205,7 @@ declare class Orderbook {
1155
1205
  * @param {string} fulfillerAddress - The address of the account fulfilling the order.
1156
1206
  * @return {FulfillOrderResponse} Approval and fulfilment transactions.
1157
1207
  */
1158
- fulfillOrder(listingId: string, takerAddress: string, takerFee?: Fee): Promise<FulfillOrderResponse>;
1208
+ fulfillOrder(listingId: string, takerAddress: string, takerFee?: FeeValue): Promise<FulfillOrderResponse>;
1159
1209
  /**
1160
1210
  * Get an unsigned cancel order transaction. Orders can only be cancelled by
1161
1211
  * the account that created them.
@@ -1170,4 +1220,4 @@ declare const constants: {
1170
1220
  estimatedFulfillmentGasGwei: number;
1171
1221
  };
1172
1222
 
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 };
1223
+ 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
@@ -924,7 +924,7 @@ class ImmutableApiClient {
924
924
  ],
925
925
  fees: makerFee ? [{
926
926
  amount: makerFee.amount,
927
- fee_type: makerFee.type,
927
+ fee_type: FeeType.MAKER_MARKETPLACE,
928
928
  recipient: makerFee.recipient,
929
929
  }] : [],
930
930
  end_time: new Date(parseInt(`${orderComponents.endTime.toString()}000`, 10)).toISOString(),
@@ -993,6 +993,67 @@ function getOrderbookConfig(environment) {
993
993
  }
994
994
  }
995
995
 
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
+
996
1057
  class SeaportLibFactory {
997
1058
  defaultSeaportContractAddress;
998
1059
  provider;
@@ -1052,8 +1113,11 @@ class Orderbook {
1052
1113
  * @param {string} listingId - The listingId to find.
1053
1114
  * @return {ListingResult} The returned order result.
1054
1115
  */
1055
- getListing(listingId) {
1056
- return this.apiClient.getListing(listingId);
1116
+ async getListing(listingId) {
1117
+ const apiListing = await this.apiClient.getListing(listingId);
1118
+ return {
1119
+ result: mapFromOpenApiOrder(apiListing.result),
1120
+ };
1057
1121
  }
1058
1122
  /**
1059
1123
  * List orders. This method is used to get a list of orders filtered by conditions specified
@@ -1061,8 +1125,12 @@ class Orderbook {
1061
1125
  * @param {ListListingsParams} listOrderParams - Filtering, ordering and page parameters.
1062
1126
  * @return {ListListingsResult} The paged orders.
1063
1127
  */
1064
- listListings(listOrderParams) {
1065
- return this.apiClient.listListings(listOrderParams);
1128
+ async listListings(listOrderParams) {
1129
+ const apiListings = await this.apiClient.listListings(listOrderParams);
1130
+ return {
1131
+ page: mapFromOpenApiPage(apiListings.page),
1132
+ result: apiListings.result.map(mapFromOpenApiOrder),
1133
+ };
1066
1134
  }
1067
1135
  /**
1068
1136
  * Get required transactions and messages for signing prior to creating a listing
@@ -1084,8 +1152,20 @@ class Orderbook {
1084
1152
  * @param {CreateListingParams} createListingParams - create an order with the given params.
1085
1153
  * @return {ListingResult} The result of the order created in the Immutable services.
1086
1154
  */
1087
- createListing(createListingParams) {
1088
- return this.apiClient.createListing(createListingParams);
1155
+ async createListing(createListingParams) {
1156
+ const makerFee = createListingParams.makerFee
1157
+ ? {
1158
+ ...createListingParams.makerFee,
1159
+ type: FeeType.MAKER_MARKETPLACE,
1160
+ }
1161
+ : undefined;
1162
+ const apiListingResponse = await this.apiClient.createListing({
1163
+ ...createListingParams,
1164
+ makerFee,
1165
+ });
1166
+ return {
1167
+ result: mapFromOpenApiOrder(apiListingResponse.result),
1168
+ };
1089
1169
  }
1090
1170
  /**
1091
1171
  * Get unsigned transactions that can be submitted to fulfil an open order. If the approval
@@ -1102,7 +1182,7 @@ class Orderbook {
1102
1182
  fee: takerFee
1103
1183
  ? {
1104
1184
  amount: takerFee.amount,
1105
- fee_type: takerFee.type,
1185
+ fee_type: FeeType.TAKER_MARKETPLACE,
1106
1186
  recipient: takerFee.recipient,
1107
1187
  }
1108
1188
  : 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.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.14.0-alpha',
1516
+ sdkVersion: 'ts-immutable-sdk-0.14.0-alpha.1',
1517
1517
  });
1518
1518
  /**
1519
1519
  * Sets `sdkVersion` at the time of build
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@imtbl/sdk",
3
3
  "description": "Immutable Unified SDK",
4
- "version": "0.14.0-alpha",
4
+ "version": "0.14.0-alpha.1",
5
5
  "author": "Immutable",
6
6
  "browser": "./dist/index.browser.js",
7
7
  "bugs": "https://github.com/immutable/ts-immutable-sdk/issues",