@imtbl/sdk 0.4.4 → 0.6.1-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.d.ts +1971 -0
- package/dist/blockchain_data.js +2528 -0
- package/dist/browser/checkout.js +2 -0
- package/dist/checkout_sdk.d.ts +1203 -0
- package/dist/checkout_sdk.js +18615 -0
- package/dist/checkout_widgets.d.ts +25725 -0
- package/dist/checkout_widgets.js +325 -0
- package/dist/erc20.d.ts +296 -0
- package/dist/erc20.js +371 -0
- package/dist/erc721_permissioned_mintable.d.ts +486 -0
- package/dist/erc721_permissioned_mintable.js +1364 -0
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +61 -8
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +28842 -6916
- package/dist/index.d.ts +25319 -6791
- package/dist/index.js +28781 -6850
- package/dist/orderbook.d.ts +250 -0
- package/dist/orderbook.js +1981 -0
- package/dist/passport.js +47 -30
- package/package.json +25 -1
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.6.1-alpha' };
|
|
1461
1461
|
const createConfig = ({ basePath, headers, }) => {
|
|
1462
1462
|
if (!basePath.trim()) {
|
|
1463
1463
|
throw Error('basePath can not be empty');
|
|
@@ -1487,10 +1487,10 @@ const multiRollupConfig = {
|
|
|
1487
1487
|
}),
|
|
1488
1488
|
getSandbox: () => ({
|
|
1489
1489
|
indexer: createConfig({
|
|
1490
|
-
basePath: 'https://
|
|
1490
|
+
basePath: 'https://api.sandbox.immutable.com',
|
|
1491
1491
|
}),
|
|
1492
1492
|
orderBook: createConfig({
|
|
1493
|
-
basePath: 'https://
|
|
1493
|
+
basePath: 'https://api.sandbox.immutable.com',
|
|
1494
1494
|
}),
|
|
1495
1495
|
passport: createConfig({
|
|
1496
1496
|
basePath: 'https://api.sandbox.immutable.com',
|
|
@@ -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.6.1-alpha',
|
|
1517
1517
|
});
|
|
1518
1518
|
/**
|
|
1519
1519
|
* Sets `sdkVersion` at the time of build
|
|
@@ -6253,7 +6253,7 @@ const transformGuardianTransactions = (txs) => {
|
|
|
6253
6253
|
}));
|
|
6254
6254
|
}
|
|
6255
6255
|
catch (error) {
|
|
6256
|
-
const errorMessage =
|
|
6256
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
6257
6257
|
throw new JsonRpcError(RpcErrorCode.INVALID_PARAMS, `Transaction failed to parsing: ${errorMessage}`);
|
|
6258
6258
|
}
|
|
6259
6259
|
};
|
|
@@ -6270,8 +6270,28 @@ class GuardianClient {
|
|
|
6270
6270
|
}));
|
|
6271
6271
|
this.imxEtherAddress = imxEtherAddress;
|
|
6272
6272
|
}
|
|
6273
|
-
|
|
6274
|
-
|
|
6273
|
+
/**
|
|
6274
|
+
* Open confirmation screen and close it automatically if the
|
|
6275
|
+
* underlying task fails.
|
|
6276
|
+
*/
|
|
6277
|
+
withConfirmationScreen(popupWindowSize) {
|
|
6278
|
+
return (task) => this.withConfirmationScreenTask(popupWindowSize)(task)();
|
|
6279
|
+
}
|
|
6280
|
+
withConfirmationScreenTask(popupWindowSize) {
|
|
6281
|
+
return (task) => async () => {
|
|
6282
|
+
this.confirmationScreen.loading(popupWindowSize);
|
|
6283
|
+
try {
|
|
6284
|
+
const result = await task();
|
|
6285
|
+
return result;
|
|
6286
|
+
}
|
|
6287
|
+
catch (err) {
|
|
6288
|
+
this.confirmationScreen.closeWindow();
|
|
6289
|
+
throw err;
|
|
6290
|
+
}
|
|
6291
|
+
};
|
|
6292
|
+
}
|
|
6293
|
+
withDefaultConfirmationScreenTask(task) {
|
|
6294
|
+
return this.withConfirmationScreenTask()(task);
|
|
6275
6295
|
}
|
|
6276
6296
|
async validate({ payloadHash }) {
|
|
6277
6297
|
const finallyFn = () => {
|
|
@@ -6320,7 +6340,7 @@ class GuardianClient {
|
|
|
6320
6340
|
return transactionEvaluationResponseAxiosResponse.data;
|
|
6321
6341
|
}
|
|
6322
6342
|
catch (error) {
|
|
6323
|
-
const errorMessage =
|
|
6343
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
6324
6344
|
throw new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, `Transaction failed to validate with error: ${errorMessage}`);
|
|
6325
6345
|
}
|
|
6326
6346
|
}
|
|
@@ -6390,8 +6410,7 @@ async function exchangeTransfer({ user, starkSigner, request, exchangesApi, }) {
|
|
|
6390
6410
|
|
|
6391
6411
|
const ERC721$1 = 'ERC721';
|
|
6392
6412
|
async function createOrder({ starkSigner, user, request, ordersApi, guardianClient, }) {
|
|
6393
|
-
return withPassportError(async () => {
|
|
6394
|
-
guardianClient.loading();
|
|
6413
|
+
return withPassportError(guardianClient.withDefaultConfirmationScreenTask(async () => {
|
|
6395
6414
|
const { ethAddress } = user.imx;
|
|
6396
6415
|
const amountSell = request.sell.type === ERC721$1 ? '1' : request.sell.amount;
|
|
6397
6416
|
const amountBuy = request.buy.type === ERC721$1 ? '1' : request.buy.amount;
|
|
@@ -6440,11 +6459,10 @@ async function createOrder({ starkSigner, user, request, ordersApi, guardianClie
|
|
|
6440
6459
|
return {
|
|
6441
6460
|
...createOrderResponse.data,
|
|
6442
6461
|
};
|
|
6443
|
-
}, PassportErrorType.CREATE_ORDER_ERROR);
|
|
6462
|
+
}), PassportErrorType.CREATE_ORDER_ERROR);
|
|
6444
6463
|
}
|
|
6445
6464
|
async function cancelOrder({ user, starkSigner, request, ordersApi, guardianClient, }) {
|
|
6446
|
-
return withPassportError(async () => {
|
|
6447
|
-
guardianClient.loading();
|
|
6465
|
+
return withPassportError(guardianClient.withDefaultConfirmationScreenTask(async () => {
|
|
6448
6466
|
const getSignableCancelOrderRequest = {
|
|
6449
6467
|
order_id: request.order_id,
|
|
6450
6468
|
};
|
|
@@ -6471,7 +6489,7 @@ async function cancelOrder({ user, starkSigner, request, ordersApi, guardianClie
|
|
|
6471
6489
|
order_id: cancelOrderResponse.data.order_id,
|
|
6472
6490
|
status: cancelOrderResponse.data.status,
|
|
6473
6491
|
};
|
|
6474
|
-
}, PassportErrorType.CANCEL_ORDER_ERROR);
|
|
6492
|
+
}), PassportErrorType.CANCEL_ORDER_ERROR);
|
|
6475
6493
|
}
|
|
6476
6494
|
|
|
6477
6495
|
async function registerPassport({ ethSigner, starkSigner, usersApi }, authorization) {
|
|
@@ -6501,8 +6519,7 @@ async function registerPassport({ ethSigner, starkSigner, usersApi }, authorizat
|
|
|
6501
6519
|
}
|
|
6502
6520
|
|
|
6503
6521
|
async function createTrade({ request, tradesApi, user, starkSigner, guardianClient, }) {
|
|
6504
|
-
return withPassportError(async () => {
|
|
6505
|
-
guardianClient.loading();
|
|
6522
|
+
return withPassportError(guardianClient.withDefaultConfirmationScreenTask(async () => {
|
|
6506
6523
|
const { ethAddress } = user.imx;
|
|
6507
6524
|
const getSignableTradeRequest = {
|
|
6508
6525
|
expiration_timestamp: request.expiration_timestamp,
|
|
@@ -6543,13 +6560,12 @@ async function createTrade({ request, tradesApi, user, starkSigner, guardianClie
|
|
|
6543
6560
|
headers,
|
|
6544
6561
|
});
|
|
6545
6562
|
return createTradeResponse;
|
|
6546
|
-
}, PassportErrorType.CREATE_TRADE_ERROR);
|
|
6563
|
+
}), PassportErrorType.CREATE_TRADE_ERROR);
|
|
6547
6564
|
}
|
|
6548
6565
|
|
|
6549
6566
|
const ERC721 = 'ERC721';
|
|
6550
6567
|
async function transfer({ request, transfersApi, starkSigner, user, guardianClient, }) {
|
|
6551
|
-
return withPassportError(async () => {
|
|
6552
|
-
guardianClient.loading();
|
|
6568
|
+
return withPassportError(guardianClient.withDefaultConfirmationScreenTask(async () => {
|
|
6553
6569
|
const transferAmount = request.type === ERC721 ? '1' : request.amount;
|
|
6554
6570
|
const getSignableTransferRequest = {
|
|
6555
6571
|
sender: user.imx.ethAddress,
|
|
@@ -6591,12 +6607,11 @@ async function transfer({ request, transfersApi, starkSigner, user, guardianClie
|
|
|
6591
6607
|
time: responseData.time,
|
|
6592
6608
|
transfer_id: responseData.transfer_id,
|
|
6593
6609
|
};
|
|
6594
|
-
}, PassportErrorType.TRANSFER_ERROR);
|
|
6610
|
+
}), PassportErrorType.TRANSFER_ERROR);
|
|
6595
6611
|
}
|
|
6596
6612
|
async function batchNftTransfer({ user, starkSigner, request, transfersApi, guardianClient, }) {
|
|
6597
|
-
|
|
6598
|
-
|
|
6599
|
-
guardianClient.loading(popupWindowSize);
|
|
6613
|
+
// eslint-disable-next-line function-paren-newline
|
|
6614
|
+
return withPassportError(guardianClient.withConfirmationScreenTask({ width: 480, height: 784 })(async () => {
|
|
6600
6615
|
const { ethAddress } = user.imx;
|
|
6601
6616
|
const signableRequests = request.map((nftTransfer) => ({
|
|
6602
6617
|
amount: '1',
|
|
@@ -6644,7 +6659,7 @@ async function batchNftTransfer({ user, starkSigner, request, transfersApi, guar
|
|
|
6644
6659
|
return {
|
|
6645
6660
|
transfer_ids: response?.data.transfer_ids,
|
|
6646
6661
|
};
|
|
6647
|
-
}, PassportErrorType.TRANSFER_ERROR);
|
|
6662
|
+
}), PassportErrorType.TRANSFER_ERROR);
|
|
6648
6663
|
}
|
|
6649
6664
|
|
|
6650
6665
|
class PassportImxProvider {
|
|
@@ -6937,7 +6952,7 @@ class PassportConfiguration {
|
|
|
6937
6952
|
this.passportDomain = 'https://passport.sandbox.immutable.com';
|
|
6938
6953
|
this.imxPublicApiDomain = 'https://api.sandbox.immutable.com';
|
|
6939
6954
|
this.zkEvmRpcUrl = 'https://rpc.testnet.immutable.com';
|
|
6940
|
-
this.zkEvmChainId = 'eip155:
|
|
6955
|
+
this.zkEvmChainId = 'eip155:13472';
|
|
6941
6956
|
this.relayerUrl = 'https://api.sandbox.immutable.com/relayer-mr';
|
|
6942
6957
|
this.multiRollupConfig = multiRollupConfig.getSandbox();
|
|
6943
6958
|
break;
|
|
@@ -7323,9 +7338,8 @@ const chainIdNumber = (chainId) => {
|
|
|
7323
7338
|
|
|
7324
7339
|
const MAX_TRANSACTION_HASH_RETRIEVAL_RETRIES = 30;
|
|
7325
7340
|
const TRANSACTION_HASH_RETRIEVAL_WAIT = 1000;
|
|
7326
|
-
const sendTransaction =
|
|
7327
|
-
|
|
7328
|
-
guardianClient.loading(popupWindowSize);
|
|
7341
|
+
const sendTransaction = ({ params, magicProvider, jsonRpcProvider, relayerClient, guardianClient, config, user, }) => guardianClient
|
|
7342
|
+
.withConfirmationScreen({ width: 480, height: 520 })(async () => {
|
|
7329
7343
|
const transactionRequest = params[0];
|
|
7330
7344
|
if (!transactionRequest.to) {
|
|
7331
7345
|
throw new JsonRpcError(RpcErrorCode.INVALID_PARAMS, 'eth_sendTransaction requires a "to" field');
|
|
@@ -7390,11 +7404,14 @@ const sendTransaction = async ({ params, magicProvider, jsonRpcProvider, relayer
|
|
|
7390
7404
|
interval: TRANSACTION_HASH_RETRIEVAL_WAIT,
|
|
7391
7405
|
finalErr: new JsonRpcError(RpcErrorCode.RPC_SERVER_ERROR, 'transaction hash not generated in time'),
|
|
7392
7406
|
});
|
|
7393
|
-
if (![
|
|
7407
|
+
if (![
|
|
7408
|
+
RelayerTransactionStatus.SUBMITTED,
|
|
7409
|
+
RelayerTransactionStatus.SUCCESSFUL,
|
|
7410
|
+
].includes(relayerTransaction.status)) {
|
|
7394
7411
|
throw new JsonRpcError(RpcErrorCode.RPC_SERVER_ERROR, `Transaction failed to submit with status ${relayerTransaction.status}`);
|
|
7395
7412
|
}
|
|
7396
7413
|
return relayerTransaction.hash;
|
|
7397
|
-
};
|
|
7414
|
+
});
|
|
7398
7415
|
|
|
7399
7416
|
class ZkEvmProvider {
|
|
7400
7417
|
authManager;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imtbl/sdk",
|
|
3
3
|
"description": "Immutable Unified SDK",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.1-alpha",
|
|
5
5
|
"author": "Immutable",
|
|
6
6
|
"browser": "./dist/index.browser.js",
|
|
7
7
|
"bugs": "https://github.com/immutable/ts-immutable-sdk/issues",
|
|
@@ -70,6 +70,10 @@
|
|
|
70
70
|
"types": "./dist/config.d.ts",
|
|
71
71
|
"import": "./dist/config.js"
|
|
72
72
|
},
|
|
73
|
+
"./blockchain_data": {
|
|
74
|
+
"types": "./dist/blockchain_data.d.ts",
|
|
75
|
+
"import": "./dist/blockchain_data.js"
|
|
76
|
+
},
|
|
73
77
|
"./immutablex_client": {
|
|
74
78
|
"types": "./dist/immutablex_client.d.ts",
|
|
75
79
|
"import": "./dist/immutablex_client.js"
|
|
@@ -78,9 +82,29 @@
|
|
|
78
82
|
"types": "./dist/passport.d.ts",
|
|
79
83
|
"import": "./dist/passport.js"
|
|
80
84
|
},
|
|
85
|
+
"./orderbook": {
|
|
86
|
+
"types": "./dist/orderbook.d.ts",
|
|
87
|
+
"import": "./dist/orderbook.js"
|
|
88
|
+
},
|
|
81
89
|
"./provider": {
|
|
82
90
|
"types": "./dist/provider.d.ts",
|
|
83
91
|
"import": "./dist/provider.js"
|
|
92
|
+
},
|
|
93
|
+
"./checkout_sdk": {
|
|
94
|
+
"types": "./dist/checkout_sdk.d.ts",
|
|
95
|
+
"import": "./dist/checkout_sdk.js"
|
|
96
|
+
},
|
|
97
|
+
"./checkout_widgets": {
|
|
98
|
+
"types": "./dist/checkout_widgets.d.ts",
|
|
99
|
+
"import": "./dist/checkout_widgets.js"
|
|
100
|
+
},
|
|
101
|
+
"./erc20": {
|
|
102
|
+
"types": "./dist/erc20.d.ts",
|
|
103
|
+
"import": "./dist/erc20.js"
|
|
104
|
+
},
|
|
105
|
+
"./erc721_permissioned_mintable": {
|
|
106
|
+
"types": "./dist/erc721_permissioned_mintable.d.ts",
|
|
107
|
+
"import": "./dist/erc721_permissioned_mintable.js"
|
|
84
108
|
}
|
|
85
109
|
},
|
|
86
110
|
"files": [
|