@imtbl/sdk 0.28.1-alpha → 0.28.3
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 +4 -0
- package/dist/blockchain_data.js +1 -1
- package/dist/browser/checkout.js +2 -2
- package/dist/checkout_sdk.d.ts +856 -1141
- package/dist/checkout_sdk.js +23 -4
- package/dist/checkout_widgets.d.ts +856 -1141
- package/dist/checkout_widgets.js +1 -1
- package/dist/config.d.ts +4 -0
- package/dist/config.js +22 -1
- package/dist/immutablex_client.d.ts +811 -1128
- package/dist/immutablex_client.js +2 -1
- package/dist/index.browser.js +53 -53
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +82 -53
- package/dist/index.d.ts +859 -1144
- package/dist/index.js +82 -53
- package/dist/orderbook.d.ts +4 -0
- package/dist/passport.d.ts +856 -1141
- package/dist/passport.js +57 -49
- package/dist/provider.d.ts +4 -0
- package/dist/provider.js +3 -0
- package/package.json +2 -2
- package/dist/global.d.ts +0 -42
package/dist/index.cjs
CHANGED
|
@@ -55,10 +55,29 @@ var Environment$1;
|
|
|
55
55
|
})(Environment$1 || (Environment$1 = {}));
|
|
56
56
|
class ImmutableConfiguration {
|
|
57
57
|
environment;
|
|
58
|
+
rateLimitingKey;
|
|
58
59
|
apiKey;
|
|
60
|
+
clientAppId;
|
|
59
61
|
constructor(options) {
|
|
60
62
|
this.environment = options.environment;
|
|
61
|
-
|
|
63
|
+
if (options.rateLimitingKey) {
|
|
64
|
+
this.rateLimitingKey = options.rateLimitingKey;
|
|
65
|
+
globalAxios$1.defaults.headers.common['x-api-key'] = this.rateLimitingKey;
|
|
66
|
+
}
|
|
67
|
+
if (options.apiKey) {
|
|
68
|
+
if (!options.apiKey.startsWith('sk_imapik-')) {
|
|
69
|
+
throw new Error('Invalid API key');
|
|
70
|
+
}
|
|
71
|
+
this.apiKey = options.apiKey;
|
|
72
|
+
globalAxios$1.defaults.headers.common['x-immutable-api-key'] = this.apiKey;
|
|
73
|
+
}
|
|
74
|
+
if (options.clientAppId) {
|
|
75
|
+
if (!options.clientAppId.startsWith('cai_imapik-')) {
|
|
76
|
+
throw new Error('Invalid Client App Id');
|
|
77
|
+
}
|
|
78
|
+
this.clientAppId = options.clientAppId;
|
|
79
|
+
globalAxios$1.defaults.headers.common['x-immutable-client-app-id'] = this.clientAppId;
|
|
80
|
+
}
|
|
62
81
|
}
|
|
63
82
|
}
|
|
64
83
|
|
|
@@ -3632,7 +3651,7 @@ class MultiRollupApiClients {
|
|
|
3632
3651
|
}
|
|
3633
3652
|
|
|
3634
3653
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
3635
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.28.
|
|
3654
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.28.3' };
|
|
3636
3655
|
const createConfig = ({ basePath, headers, }) => {
|
|
3637
3656
|
if (!basePath.trim()) {
|
|
3638
3657
|
throw Error('basePath can not be empty');
|
|
@@ -3692,7 +3711,7 @@ class APIError extends Error {
|
|
|
3692
3711
|
|
|
3693
3712
|
/* eslint-disable implicit-arrow-linebreak */
|
|
3694
3713
|
const defaultHeaders = {
|
|
3695
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.28.
|
|
3714
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.28.3',
|
|
3696
3715
|
};
|
|
3697
3716
|
/**
|
|
3698
3717
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -4103,7 +4122,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
4103
4122
|
chainID,
|
|
4104
4123
|
coreContractAddress,
|
|
4105
4124
|
registrationContractAddress,
|
|
4106
|
-
sdkVersion: 'ts-immutable-sdk-0.28.
|
|
4125
|
+
sdkVersion: 'ts-immutable-sdk-0.28.3',
|
|
4107
4126
|
});
|
|
4108
4127
|
/**
|
|
4109
4128
|
* Sets `sdkVersion` at the time of build
|
|
@@ -9573,13 +9592,12 @@ async function batchNftTransfer({ user, starkSigner, request, transfersApi, guar
|
|
|
9573
9592
|
}),
|
|
9574
9593
|
receiver: nftTransfer.receiver,
|
|
9575
9594
|
}));
|
|
9576
|
-
const getSignableTransferRequestV2 = {
|
|
9577
|
-
sender_ether_key: ethAddress,
|
|
9578
|
-
signable_requests: signableRequests,
|
|
9579
|
-
};
|
|
9580
9595
|
const headers = { Authorization: `Bearer ${user.accessToken}` };
|
|
9581
9596
|
const signableResult = await transfersApi.getSignableTransfer({
|
|
9582
|
-
getSignableTransferRequestV2
|
|
9597
|
+
getSignableTransferRequestV2: {
|
|
9598
|
+
sender_ether_key: ethAddress,
|
|
9599
|
+
signable_requests: signableRequests,
|
|
9600
|
+
},
|
|
9583
9601
|
}, { headers });
|
|
9584
9602
|
await guardianClient.evaluateImxTransaction({
|
|
9585
9603
|
user,
|
|
@@ -10360,36 +10378,19 @@ const loginZkEvmUser = async ({ authManager, config, magicAdapter, multiRollupAp
|
|
|
10360
10378
|
|
|
10361
10379
|
const MAX_TRANSACTION_HASH_RETRIEVAL_RETRIES = 30;
|
|
10362
10380
|
const TRANSACTION_HASH_RETRIEVAL_WAIT = 1000;
|
|
10363
|
-
const
|
|
10364
|
-
.withConfirmationScreen({ width: 480, height: 520 })(async () => {
|
|
10365
|
-
const transactionRequest = params[0];
|
|
10366
|
-
if (!transactionRequest.to) {
|
|
10367
|
-
throw new JsonRpcError(RpcErrorCode.INVALID_PARAMS, 'eth_sendTransaction requires a "to" field');
|
|
10368
|
-
}
|
|
10369
|
-
const { chainId } = await jsonRpcProvider.ready;
|
|
10370
|
-
const chainIdBigNumber = ethers.BigNumber.from(chainId);
|
|
10371
|
-
const magicWeb3Provider = new providers.Web3Provider(magicProvider);
|
|
10372
|
-
const signer = magicWeb3Provider.getSigner();
|
|
10373
|
-
const nonce = await getNonce(jsonRpcProvider, user.zkEvm.ethAddress);
|
|
10374
|
-
const metaTransaction = {
|
|
10375
|
-
to: transactionRequest.to,
|
|
10376
|
-
data: transactionRequest.data,
|
|
10377
|
-
nonce,
|
|
10378
|
-
value: transactionRequest.value,
|
|
10379
|
-
revertOnError: true,
|
|
10380
|
-
};
|
|
10381
|
+
const getMetaTransactions = async (metaTransaction, nonce, chainId, walletAddress, signer, relayerClient) => {
|
|
10381
10382
|
// NOTE: We sign the transaction before getting the fee options because
|
|
10382
10383
|
// accurate estimation of a transaction gas cost is only possible if the smart
|
|
10383
10384
|
// wallet contract can actually execute it (in a simulated environment) - and
|
|
10384
10385
|
// it can only execute signed transactions.
|
|
10385
|
-
const signedTransaction = await getSignedMetaTransactions([metaTransaction], nonce,
|
|
10386
|
+
const signedTransaction = await getSignedMetaTransactions([metaTransaction], nonce, chainId, walletAddress, signer);
|
|
10386
10387
|
// TODO: ID-698 Add support for non-native gas payments (e.g ERC20, feeTransaction initialisation must change)
|
|
10387
10388
|
// NOTE: "Fee Options" represent the multiple ways we could pay for the gas
|
|
10388
10389
|
// used in this transaction. Each fee option has a "recipientAddress" we
|
|
10389
10390
|
// should transfer the payment to, an amount and a currency. We choose one
|
|
10390
10391
|
// option and build a transaction that sends the expected currency amount for
|
|
10391
10392
|
// that option to the specified address.
|
|
10392
|
-
const feeOptions = await relayerClient.imGetFeeOptions(
|
|
10393
|
+
const feeOptions = await relayerClient.imGetFeeOptions(walletAddress, signedTransaction);
|
|
10393
10394
|
const imxFeeOption = feeOptions.find((feeOption) => feeOption.tokenSymbol === 'IMX');
|
|
10394
10395
|
if (!imxFeeOption) {
|
|
10395
10396
|
throw new Error('Failed to retrieve fees for IMX token');
|
|
@@ -10400,15 +10401,39 @@ const sendTransaction = ({ params, magicProvider, jsonRpcProvider, relayerClient
|
|
|
10400
10401
|
value: imxFeeOption.tokenPrice,
|
|
10401
10402
|
revertOnError: true,
|
|
10402
10403
|
};
|
|
10404
|
+
if (ethers.BigNumber.from(feeMetaTransaction.value).isZero()) {
|
|
10405
|
+
return [metaTransaction];
|
|
10406
|
+
}
|
|
10407
|
+
return [metaTransaction, feeMetaTransaction];
|
|
10408
|
+
};
|
|
10409
|
+
const sendTransaction = ({ params, magicProvider, jsonRpcProvider, relayerClient, guardianClient, user, }) => guardianClient
|
|
10410
|
+
.withConfirmationScreen({ width: 480, height: 520 })(async () => {
|
|
10411
|
+
const transactionRequest = params[0];
|
|
10412
|
+
if (!transactionRequest.to) {
|
|
10413
|
+
throw new JsonRpcError(RpcErrorCode.INVALID_PARAMS, 'eth_sendTransaction requires a "to" field');
|
|
10414
|
+
}
|
|
10415
|
+
const { chainId } = await jsonRpcProvider.ready;
|
|
10416
|
+
const chainIdBigNumber = ethers.BigNumber.from(chainId);
|
|
10417
|
+
const magicWeb3Provider = new providers.Web3Provider(magicProvider);
|
|
10418
|
+
const signer = magicWeb3Provider.getSigner();
|
|
10419
|
+
const nonce = await getNonce(jsonRpcProvider, user.zkEvm.ethAddress);
|
|
10420
|
+
const metaTransaction = {
|
|
10421
|
+
to: transactionRequest.to,
|
|
10422
|
+
data: transactionRequest.data,
|
|
10423
|
+
nonce,
|
|
10424
|
+
value: transactionRequest.value,
|
|
10425
|
+
revertOnError: true,
|
|
10426
|
+
};
|
|
10427
|
+
const metaTransactions = await getMetaTransactions(metaTransaction, nonce, chainIdBigNumber, user.zkEvm.ethAddress, signer, relayerClient);
|
|
10403
10428
|
await guardianClient.validateEVMTransaction({
|
|
10404
10429
|
chainId: getEip155ChainId(chainId),
|
|
10405
10430
|
nonce: convertBigNumberishToString(nonce),
|
|
10406
10431
|
user,
|
|
10407
|
-
metaTransactions
|
|
10432
|
+
metaTransactions,
|
|
10408
10433
|
});
|
|
10409
10434
|
// NOTE: We sign again because we now are adding the fee transaction, so the
|
|
10410
10435
|
// whole payload is different and needs a new signature.
|
|
10411
|
-
const signedTransactions = await getSignedMetaTransactions(
|
|
10436
|
+
const signedTransactions = await getSignedMetaTransactions(metaTransactions, nonce, chainIdBigNumber, user.zkEvm.ethAddress, signer);
|
|
10412
10437
|
const relayerId = await relayerClient.ethSendTransaction(user.zkEvm.ethAddress, signedTransactions);
|
|
10413
10438
|
const retrieveRelayerTransaction = async () => {
|
|
10414
10439
|
const tx = await relayerClient.imGetTransactionByHash(relayerId);
|
|
@@ -10747,33 +10772,16 @@ class Passport {
|
|
|
10747
10772
|
passportEventEmitter: this.passportEventEmitter,
|
|
10748
10773
|
});
|
|
10749
10774
|
}
|
|
10750
|
-
async signIn(options) {
|
|
10751
|
-
const { useCachedSession = false } = options || {};
|
|
10752
|
-
let user = await this.authManager.loginSilent();
|
|
10753
|
-
if (!user && !useCachedSession) {
|
|
10754
|
-
user = await this.authManager.login();
|
|
10755
|
-
}
|
|
10756
|
-
if (!user) {
|
|
10757
|
-
return null;
|
|
10758
|
-
}
|
|
10759
|
-
return user.profile;
|
|
10760
|
-
}
|
|
10761
10775
|
/**
|
|
10762
|
-
* @deprecated The method
|
|
10776
|
+
* @deprecated The method `login` with an argument of `{ useCachedSession: true }` should be used in conjunction with
|
|
10777
|
+
* `connectImx` instead.
|
|
10763
10778
|
*/
|
|
10764
10779
|
async connectImxSilent() {
|
|
10765
10780
|
return this.passportImxProviderFactory.getProviderSilent();
|
|
10766
10781
|
}
|
|
10767
|
-
async connectImx(
|
|
10768
|
-
const { useCachedSession = false } = options || {};
|
|
10769
|
-
if (useCachedSession) {
|
|
10770
|
-
return this.passportImxProviderFactory.getProviderSilent();
|
|
10771
|
-
}
|
|
10782
|
+
async connectImx() {
|
|
10772
10783
|
return this.passportImxProviderFactory.getProvider();
|
|
10773
10784
|
}
|
|
10774
|
-
async loginWithDeviceFlow() {
|
|
10775
|
-
return this.authManager.loginWithDeviceFlow();
|
|
10776
|
-
}
|
|
10777
10785
|
async connectImxDeviceFlow(deviceCode, interval, timeoutMs) {
|
|
10778
10786
|
return this.passportImxProviderFactory.getProviderWithDeviceFlow(deviceCode, interval, timeoutMs);
|
|
10779
10787
|
}
|
|
@@ -10805,6 +10813,25 @@ class Passport {
|
|
|
10805
10813
|
multiRollupApiClients: this.multiRollupApiClients,
|
|
10806
10814
|
});
|
|
10807
10815
|
}
|
|
10816
|
+
/**
|
|
10817
|
+
*
|
|
10818
|
+
* Initiates the authorisation flow.
|
|
10819
|
+
*
|
|
10820
|
+
* @param options.useCachedSession = false - If true, and no active session exists, then the user will not be
|
|
10821
|
+
* prompted to log in and the Promise will resolve with a null value.
|
|
10822
|
+
* @returns {Promise<UserProfile | null>} the user profile if the user is logged in, otherwise null
|
|
10823
|
+
*/
|
|
10824
|
+
async login(options) {
|
|
10825
|
+
const { useCachedSession = false } = options || {};
|
|
10826
|
+
let user = await this.authManager.loginSilent();
|
|
10827
|
+
if (!user && !useCachedSession) {
|
|
10828
|
+
user = await this.authManager.login();
|
|
10829
|
+
}
|
|
10830
|
+
return user ? user.profile : null;
|
|
10831
|
+
}
|
|
10832
|
+
async loginWithDeviceFlow() {
|
|
10833
|
+
return this.authManager.loginWithDeviceFlow();
|
|
10834
|
+
}
|
|
10808
10835
|
async loginCallback() {
|
|
10809
10836
|
return this.authManager.loginCallback();
|
|
10810
10837
|
}
|
|
@@ -12667,6 +12694,8 @@ async function getSignableRegistrationOnchain(etherKey, starkPublicKey, usersApi
|
|
|
12667
12694
|
return {
|
|
12668
12695
|
operator_signature: response.data.operator_signature,
|
|
12669
12696
|
payload_hash: response.data.payload_hash,
|
|
12697
|
+
readable_transaction: response.data.readable_transaction,
|
|
12698
|
+
verification_signature: response.data.verification_signature,
|
|
12670
12699
|
};
|
|
12671
12700
|
}
|
|
12672
12701
|
|
|
@@ -30317,7 +30346,7 @@ class $fd8a8472dcc3ec2b$export$ef140a6b05dfc786 {
|
|
|
30317
30346
|
|
|
30318
30347
|
const $458d407830d66110$export$e6a390ea6399b7d8 = (config, debugString, seconds)=>{
|
|
30319
30348
|
// eslint-disable-next-line no-console
|
|
30320
|
-
if (!config.isProduction) console.
|
|
30349
|
+
if (!config.isProduction) console.info(debugString, seconds);
|
|
30321
30350
|
};
|
|
30322
30351
|
const $458d407830d66110$export$5280dbcb91c8b391 = async (config, debugString, promise)=>{
|
|
30323
30352
|
const startTime = performance.now();
|
|
@@ -33558,7 +33587,7 @@ var $045213b18e9f1f94$export$75be0f6af9650f2c;
|
|
|
33558
33587
|
})($045213b18e9f1f94$export$75be0f6af9650f2c || ($045213b18e9f1f94$export$75be0f6af9650f2c = {}));
|
|
33559
33588
|
|
|
33560
33589
|
|
|
33561
|
-
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.28.
|
|
33590
|
+
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.28.3";
|
|
33562
33591
|
const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
|
|
33563
33592
|
const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
|
|
33564
33593
|
|