@imtbl/sdk 0.16.0 → 0.17.0
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.d.ts +151 -26
- package/dist/blockchain_data.js +350 -32
- package/dist/browser/checkout.js +2 -2
- package/dist/checkout_sdk.d.ts +236 -3
- package/dist/checkout_sdk.js +1139 -309
- package/dist/checkout_widgets.d.ts +1 -0
- package/dist/erc721.d.ts +40 -0
- package/dist/erc721.js +173 -1
- package/dist/erc721_mint_by_id.d.ts +14 -0
- package/dist/erc721_mint_by_id.js +165 -19
- package/dist/index.browser.js +15 -15
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +1963 -485
- package/dist/index.d.ts +594 -18
- package/dist/index.js +1805 -327
- package/dist/orderbook.d.ts +150 -4
- package/dist/orderbook.js +135 -0
- package/dist/passport.d.ts +1 -0
- package/dist/passport.js +273 -10
- package/package.json +6 -2
package/dist/orderbook.d.ts
CHANGED
|
@@ -811,9 +811,6 @@ type CreateListingRequestBody = {
|
|
|
811
811
|
* Buy item for listing should either be NATIVE or ERC20 item
|
|
812
812
|
*/
|
|
813
813
|
buy: Array<Item>;
|
|
814
|
-
/**
|
|
815
|
-
* The maker marketplace fee
|
|
816
|
-
*/
|
|
817
814
|
fee?: Fee$1;
|
|
818
815
|
/**
|
|
819
816
|
* Time after which the Order is considered expired
|
|
@@ -935,6 +932,54 @@ type ListListingsResult$1 = {
|
|
|
935
932
|
result: Array<Order$1>;
|
|
936
933
|
};
|
|
937
934
|
|
|
935
|
+
/**
|
|
936
|
+
* The metadata related to the transaction in which the activity occurred
|
|
937
|
+
*/
|
|
938
|
+
type TradeBlockchainMetadata = {
|
|
939
|
+
/**
|
|
940
|
+
* The transaction hash of the trade
|
|
941
|
+
*/
|
|
942
|
+
transaction_hash: string;
|
|
943
|
+
/**
|
|
944
|
+
* EVM block number (uint64 as string)
|
|
945
|
+
*/
|
|
946
|
+
block_number: string;
|
|
947
|
+
/**
|
|
948
|
+
* Transaction index in a block (uint32 as string)
|
|
949
|
+
*/
|
|
950
|
+
transaction_index: string;
|
|
951
|
+
/**
|
|
952
|
+
* The log index of the fulfillment event in a block (uint32 as string)
|
|
953
|
+
*/
|
|
954
|
+
log_index: string;
|
|
955
|
+
};
|
|
956
|
+
|
|
957
|
+
type Trade$1 = {
|
|
958
|
+
buy: Array<Item>;
|
|
959
|
+
buyer_address: string;
|
|
960
|
+
buyer_fees: Array<Fee$1>;
|
|
961
|
+
chain: Chain;
|
|
962
|
+
order_id: string;
|
|
963
|
+
blockchain_metadata: TradeBlockchainMetadata;
|
|
964
|
+
/**
|
|
965
|
+
* Time the on-chain trade event is indexed by the order book system
|
|
966
|
+
*/
|
|
967
|
+
indexed_at: string;
|
|
968
|
+
/**
|
|
969
|
+
* Global Trade identifier
|
|
970
|
+
*/
|
|
971
|
+
id: string;
|
|
972
|
+
sell: Array<Item>;
|
|
973
|
+
seller_address: string;
|
|
974
|
+
maker_address: string;
|
|
975
|
+
taker_address: string;
|
|
976
|
+
};
|
|
977
|
+
|
|
978
|
+
type ListTradeResult = {
|
|
979
|
+
page: Page$1;
|
|
980
|
+
result: Array<Trade$1>;
|
|
981
|
+
};
|
|
982
|
+
|
|
938
983
|
/**
|
|
939
984
|
* Encoded page cursor to retrieve previous or next page. Use the value returned in the response.
|
|
940
985
|
*/
|
|
@@ -945,6 +990,10 @@ type PageCursor = string;
|
|
|
945
990
|
*/
|
|
946
991
|
type PageSize = number;
|
|
947
992
|
|
|
993
|
+
type TradeResult$1 = {
|
|
994
|
+
result: Trade$1;
|
|
995
|
+
};
|
|
996
|
+
|
|
948
997
|
declare class OrdersService {
|
|
949
998
|
readonly httpRequest: BaseHttpRequest;
|
|
950
999
|
constructor(httpRequest: BaseHttpRequest);
|
|
@@ -1024,6 +1073,45 @@ declare class OrdersService {
|
|
|
1024
1073
|
}): CancelablePromise<{
|
|
1025
1074
|
result: Array<FulfillmentDataResult>;
|
|
1026
1075
|
}>;
|
|
1076
|
+
/**
|
|
1077
|
+
* List all trades
|
|
1078
|
+
* List all trades
|
|
1079
|
+
* @returns ListTradeResult OK response.
|
|
1080
|
+
* @throws ApiError
|
|
1081
|
+
*/
|
|
1082
|
+
listTrades({ chainName, accountAddress, pageSize, sortBy, sortDirection, pageCursor, }: {
|
|
1083
|
+
chainName: ChainName;
|
|
1084
|
+
accountAddress?: string;
|
|
1085
|
+
/**
|
|
1086
|
+
* Maximum number of trades to return per page
|
|
1087
|
+
*/
|
|
1088
|
+
pageSize?: PageSize;
|
|
1089
|
+
/**
|
|
1090
|
+
* Trade field to sort by
|
|
1091
|
+
*/
|
|
1092
|
+
sortBy?: 'created_at';
|
|
1093
|
+
/**
|
|
1094
|
+
* Ascending or descending direction for sort
|
|
1095
|
+
*/
|
|
1096
|
+
sortDirection?: 'asc' | 'desc';
|
|
1097
|
+
/**
|
|
1098
|
+
* Page cursor to retrieve previous or next page. Use the value returned in the response.
|
|
1099
|
+
*/
|
|
1100
|
+
pageCursor?: PageCursor;
|
|
1101
|
+
}): CancelablePromise<ListTradeResult>;
|
|
1102
|
+
/**
|
|
1103
|
+
* Get a single trade by ID
|
|
1104
|
+
* Get a single trade by ID
|
|
1105
|
+
* @returns TradeResult OK response.
|
|
1106
|
+
* @throws ApiError
|
|
1107
|
+
*/
|
|
1108
|
+
getTrade({ chainName, tradeId, }: {
|
|
1109
|
+
chainName: ChainName;
|
|
1110
|
+
/**
|
|
1111
|
+
* Global Trade identifier
|
|
1112
|
+
*/
|
|
1113
|
+
tradeId: string;
|
|
1114
|
+
}): CancelablePromise<TradeResult$1>;
|
|
1027
1115
|
}
|
|
1028
1116
|
|
|
1029
1117
|
interface ERC721Item {
|
|
@@ -1062,6 +1150,7 @@ interface CreateListingParams {
|
|
|
1062
1150
|
makerFee?: FeeValue;
|
|
1063
1151
|
}
|
|
1064
1152
|
type ListListingsParams = Omit<Parameters<typeof OrdersService.prototype.listListings>[0], 'chainName'>;
|
|
1153
|
+
type ListTradesParams = Omit<Parameters<typeof OrdersService.prototype.listTrades>[0], 'chainName'>;
|
|
1065
1154
|
declare enum FeeType {
|
|
1066
1155
|
MAKER_MARKETPLACE = "MAKER_MARKETPLACE",
|
|
1067
1156
|
TAKER_MARKETPLACE = "TAKER_MARKETPLACE",
|
|
@@ -1162,6 +1251,50 @@ interface Page {
|
|
|
1162
1251
|
*/
|
|
1163
1252
|
nextCursor: string | null;
|
|
1164
1253
|
}
|
|
1254
|
+
interface Trade {
|
|
1255
|
+
id: string;
|
|
1256
|
+
orderId: string;
|
|
1257
|
+
chain: {
|
|
1258
|
+
id: string;
|
|
1259
|
+
name: string;
|
|
1260
|
+
};
|
|
1261
|
+
buy: (ERC20Item | NativeItem)[];
|
|
1262
|
+
sell: ERC721Item[];
|
|
1263
|
+
buyerFees: Fee[];
|
|
1264
|
+
sellerAddress: string;
|
|
1265
|
+
buyerAddress: string;
|
|
1266
|
+
makerAddress: string;
|
|
1267
|
+
takerAddress: string;
|
|
1268
|
+
/**
|
|
1269
|
+
* Time the on-chain event was indexed by the Immutable order book service
|
|
1270
|
+
*/
|
|
1271
|
+
indexedAt: string;
|
|
1272
|
+
blockchainMetadata: {
|
|
1273
|
+
/**
|
|
1274
|
+
* The transaction hash of the trade
|
|
1275
|
+
*/
|
|
1276
|
+
transactionHash: string;
|
|
1277
|
+
/**
|
|
1278
|
+
* EVM block number (uint64 as string)
|
|
1279
|
+
*/
|
|
1280
|
+
blockNumber: string;
|
|
1281
|
+
/**
|
|
1282
|
+
* Transaction index in a block (uint32 as string)
|
|
1283
|
+
*/
|
|
1284
|
+
transactionIndex: string;
|
|
1285
|
+
/**
|
|
1286
|
+
* The log index of the fulfillment event in a block (uint32 as string)
|
|
1287
|
+
*/
|
|
1288
|
+
logIndex: string;
|
|
1289
|
+
};
|
|
1290
|
+
}
|
|
1291
|
+
interface TradeResult {
|
|
1292
|
+
result: Trade;
|
|
1293
|
+
}
|
|
1294
|
+
interface ListTradesResult {
|
|
1295
|
+
page: Page;
|
|
1296
|
+
result: Trade[];
|
|
1297
|
+
}
|
|
1165
1298
|
|
|
1166
1299
|
/**
|
|
1167
1300
|
* zkEVM orderbook SDK
|
|
@@ -1184,6 +1317,12 @@ declare class Orderbook {
|
|
|
1184
1317
|
* @return {ListingResult} The returned order result.
|
|
1185
1318
|
*/
|
|
1186
1319
|
getListing(listingId: string): Promise<ListingResult>;
|
|
1320
|
+
/**
|
|
1321
|
+
* Get a trade by ID
|
|
1322
|
+
* @param {string} tradeId - The tradeId to find.
|
|
1323
|
+
* @return {TradeResult} The returned order result.
|
|
1324
|
+
*/
|
|
1325
|
+
getTrade(tradeId: string): Promise<TradeResult>;
|
|
1187
1326
|
/**
|
|
1188
1327
|
* List orders. This method is used to get a list of orders filtered by conditions specified
|
|
1189
1328
|
* in the params object.
|
|
@@ -1191,6 +1330,13 @@ declare class Orderbook {
|
|
|
1191
1330
|
* @return {ListListingsResult} The paged orders.
|
|
1192
1331
|
*/
|
|
1193
1332
|
listListings(listOrderParams: ListListingsParams): Promise<ListListingsResult>;
|
|
1333
|
+
/**
|
|
1334
|
+
* List trades. This method is used to get a list of trades filtered by conditions specified
|
|
1335
|
+
* in the params object
|
|
1336
|
+
* @param {ListTradesParams} listTradesParams - Filtering, ordering and page parameters.
|
|
1337
|
+
* @return {ListTradesResult} The paged trades.
|
|
1338
|
+
*/
|
|
1339
|
+
listTrades(listTradesParams: ListTradesParams): Promise<ListTradesResult>;
|
|
1194
1340
|
/**
|
|
1195
1341
|
* Get required transactions and messages for signing prior to creating a listing
|
|
1196
1342
|
* through the createListing method
|
|
@@ -1229,4 +1375,4 @@ declare const constants: {
|
|
|
1229
1375
|
estimatedFulfillmentGasGwei: number;
|
|
1230
1376
|
};
|
|
1231
1377
|
|
|
1232
|
-
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 };
|
|
1378
|
+
export { Action, ActionType, CancelOrderResponse, CreateListingParams, ERC20Item, ERC721Item, Fee, FeeType, FeeValue, FulfillOrderResponse, ListListingsParams, ListListingsResult, ListTradesParams, ListTradesResult, ListingResult, NativeItem, Order, OrderStatus, Orderbook, Page, PrepareListingParams, PrepareListingResponse, RoyaltyInfo, SignableAction, SignablePurpose, Trade, TradeResult, TransactionAction, TransactionBuilder, TransactionPurpose, constants };
|
package/dist/orderbook.js
CHANGED
|
@@ -493,6 +493,54 @@ class OrdersService {
|
|
|
493
493
|
},
|
|
494
494
|
});
|
|
495
495
|
}
|
|
496
|
+
/**
|
|
497
|
+
* List all trades
|
|
498
|
+
* List all trades
|
|
499
|
+
* @returns ListTradeResult OK response.
|
|
500
|
+
* @throws ApiError
|
|
501
|
+
*/
|
|
502
|
+
listTrades({ chainName, accountAddress, pageSize, sortBy, sortDirection, pageCursor, }) {
|
|
503
|
+
return this.httpRequest.request({
|
|
504
|
+
method: 'GET',
|
|
505
|
+
url: '/v1/chains/{chain_name}/trades',
|
|
506
|
+
path: {
|
|
507
|
+
'chain_name': chainName,
|
|
508
|
+
},
|
|
509
|
+
query: {
|
|
510
|
+
'account_address': accountAddress,
|
|
511
|
+
'page_size': pageSize,
|
|
512
|
+
'sort_by': sortBy,
|
|
513
|
+
'sort_direction': sortDirection,
|
|
514
|
+
'page_cursor': pageCursor,
|
|
515
|
+
},
|
|
516
|
+
errors: {
|
|
517
|
+
400: `Bad Request (400)`,
|
|
518
|
+
404: `The specified resource was not found (404)`,
|
|
519
|
+
500: `Internal Server Error (500)`,
|
|
520
|
+
},
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Get a single trade by ID
|
|
525
|
+
* Get a single trade by ID
|
|
526
|
+
* @returns TradeResult OK response.
|
|
527
|
+
* @throws ApiError
|
|
528
|
+
*/
|
|
529
|
+
getTrade({ chainName, tradeId, }) {
|
|
530
|
+
return this.httpRequest.request({
|
|
531
|
+
method: 'GET',
|
|
532
|
+
url: '/v1/chains/{chain_name}/trades/{trade_id}',
|
|
533
|
+
path: {
|
|
534
|
+
'chain_name': chainName,
|
|
535
|
+
'trade_id': tradeId,
|
|
536
|
+
},
|
|
537
|
+
errors: {
|
|
538
|
+
400: `Bad Request (400)`,
|
|
539
|
+
404: `The specified resource was not found (404)`,
|
|
540
|
+
500: `Internal Server Error (500)`,
|
|
541
|
+
},
|
|
542
|
+
});
|
|
543
|
+
}
|
|
496
544
|
}
|
|
497
545
|
|
|
498
546
|
class OrderBookClient {
|
|
@@ -629,6 +677,57 @@ function mapFromOpenApiOrder(order) {
|
|
|
629
677
|
updateTime: order.update_time,
|
|
630
678
|
};
|
|
631
679
|
}
|
|
680
|
+
function mapFromOpenApiTrade(trade) {
|
|
681
|
+
const buyItems = trade.buy.map((item) => {
|
|
682
|
+
if (item.item_type === 'ERC20') {
|
|
683
|
+
return {
|
|
684
|
+
type: 'ERC20',
|
|
685
|
+
contractAddress: item.contract_address,
|
|
686
|
+
amount: item.start_amount,
|
|
687
|
+
};
|
|
688
|
+
}
|
|
689
|
+
if (item.item_type === 'NATIVE') {
|
|
690
|
+
return {
|
|
691
|
+
type: 'NATIVE',
|
|
692
|
+
amount: item.start_amount,
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
throw new Error('Buy items must be either ERC20 or NATIVE');
|
|
696
|
+
});
|
|
697
|
+
const sellItems = trade.sell.map((item) => {
|
|
698
|
+
if (item.item_type === 'ERC721') {
|
|
699
|
+
return {
|
|
700
|
+
type: 'ERC721',
|
|
701
|
+
contractAddress: item.contract_address,
|
|
702
|
+
tokenId: item.token_id,
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
throw new Error('Sell items must ERC721');
|
|
706
|
+
});
|
|
707
|
+
return {
|
|
708
|
+
id: trade.id,
|
|
709
|
+
orderId: trade.order_id,
|
|
710
|
+
buy: buyItems,
|
|
711
|
+
sell: sellItems,
|
|
712
|
+
buyerFees: trade.buyer_fees.map((fee) => ({
|
|
713
|
+
amount: fee.amount,
|
|
714
|
+
recipient: fee.recipient,
|
|
715
|
+
type: fee.fee_type,
|
|
716
|
+
})),
|
|
717
|
+
chain: trade.chain,
|
|
718
|
+
indexedAt: trade.indexed_at,
|
|
719
|
+
blockchainMetadata: {
|
|
720
|
+
blockNumber: trade.blockchain_metadata.block_number,
|
|
721
|
+
logIndex: trade.blockchain_metadata.log_index,
|
|
722
|
+
transactionHash: trade.blockchain_metadata.transaction_hash,
|
|
723
|
+
transactionIndex: trade.blockchain_metadata.transaction_index,
|
|
724
|
+
},
|
|
725
|
+
buyerAddress: trade.buyer_address,
|
|
726
|
+
makerAddress: trade.maker_address,
|
|
727
|
+
sellerAddress: trade.seller_address,
|
|
728
|
+
takerAddress: trade.taker_address,
|
|
729
|
+
};
|
|
730
|
+
}
|
|
632
731
|
function mapFromOpenApiPage(page) {
|
|
633
732
|
return {
|
|
634
733
|
nextCursor: page.next_cursor,
|
|
@@ -958,12 +1057,24 @@ class ImmutableApiClient {
|
|
|
958
1057
|
listingId,
|
|
959
1058
|
});
|
|
960
1059
|
}
|
|
1060
|
+
async getTrade(tradeId) {
|
|
1061
|
+
return this.orderbookService.getTrade({
|
|
1062
|
+
chainName: this.chainName,
|
|
1063
|
+
tradeId,
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
961
1066
|
async listListings(listOrderParams) {
|
|
962
1067
|
return this.orderbookService.listListings({
|
|
963
1068
|
chainName: this.chainName,
|
|
964
1069
|
...listOrderParams,
|
|
965
1070
|
});
|
|
966
1071
|
}
|
|
1072
|
+
async listTrades(listTradesParams) {
|
|
1073
|
+
return this.orderbookService.listTrades({
|
|
1074
|
+
chainName: this.chainName,
|
|
1075
|
+
...listTradesParams,
|
|
1076
|
+
});
|
|
1077
|
+
}
|
|
967
1078
|
async createListing({ orderHash, orderComponents, orderSignature, makerFee, }) {
|
|
968
1079
|
if (orderComponents.offer.length !== 1) {
|
|
969
1080
|
throw new Error('Only one item can be listed at a time');
|
|
@@ -1129,6 +1240,17 @@ class Orderbook {
|
|
|
1129
1240
|
result: mapFromOpenApiOrder(apiListing.result),
|
|
1130
1241
|
};
|
|
1131
1242
|
}
|
|
1243
|
+
/**
|
|
1244
|
+
* Get a trade by ID
|
|
1245
|
+
* @param {string} tradeId - The tradeId to find.
|
|
1246
|
+
* @return {TradeResult} The returned order result.
|
|
1247
|
+
*/
|
|
1248
|
+
async getTrade(tradeId) {
|
|
1249
|
+
const apiListing = await this.apiClient.getTrade(tradeId);
|
|
1250
|
+
return {
|
|
1251
|
+
result: mapFromOpenApiTrade(apiListing.result),
|
|
1252
|
+
};
|
|
1253
|
+
}
|
|
1132
1254
|
/**
|
|
1133
1255
|
* List orders. This method is used to get a list of orders filtered by conditions specified
|
|
1134
1256
|
* in the params object.
|
|
@@ -1142,6 +1264,19 @@ class Orderbook {
|
|
|
1142
1264
|
result: apiListings.result.map(mapFromOpenApiOrder),
|
|
1143
1265
|
};
|
|
1144
1266
|
}
|
|
1267
|
+
/**
|
|
1268
|
+
* List trades. This method is used to get a list of trades filtered by conditions specified
|
|
1269
|
+
* in the params object
|
|
1270
|
+
* @param {ListTradesParams} listTradesParams - Filtering, ordering and page parameters.
|
|
1271
|
+
* @return {ListTradesResult} The paged trades.
|
|
1272
|
+
*/
|
|
1273
|
+
async listTrades(listTradesParams) {
|
|
1274
|
+
const apiListings = await this.apiClient.listTrades(listTradesParams);
|
|
1275
|
+
return {
|
|
1276
|
+
page: mapFromOpenApiPage(apiListings.page),
|
|
1277
|
+
result: apiListings.result.map(mapFromOpenApiTrade),
|
|
1278
|
+
};
|
|
1279
|
+
}
|
|
1145
1280
|
/**
|
|
1146
1281
|
* Get required transactions and messages for signing prior to creating a listing
|
|
1147
1282
|
* through the createListing method
|
package/dist/passport.d.ts
CHANGED
|
@@ -10610,6 +10610,7 @@ declare class Passport {
|
|
|
10610
10610
|
getUserInfoDeviceFlow(): Promise<UserProfile | undefined>;
|
|
10611
10611
|
getIdToken(): Promise<string | undefined>;
|
|
10612
10612
|
getAccessToken(): Promise<string | undefined>;
|
|
10613
|
+
getLinkedAddresses(): Promise<string[]>;
|
|
10613
10614
|
}
|
|
10614
10615
|
|
|
10615
10616
|
export { AccountsChangedEvent, DeviceConnectResponse, DeviceTokenResponse, JsonRpcError, JsonRpcRequestCallback, JsonRpcRequestPayload, JsonRpcResponsePayload, Networks, Passport, PassportError, PassportModuleConfiguration, PassportOverrides, Provider, ProviderErrorCode, ProviderEvent, RequestArguments, RpcErrorCode, UserProfile };
|