@imtbl/sdk 1.20.3-alpha → 1.20.4
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 +2 -2
- package/dist/browser/checkout/{BridgeWidget-e433c650.js → BridgeWidget-764186df.js} +1 -1
- package/dist/browser/checkout/{HorizontalMenu-actual-c339d259.js → HorizontalMenu-actual-f804d6c1.js} +1 -1
- package/dist/browser/checkout/{OnRampWidget-791b2c23.js → OnRampWidget-d202910b.js} +1 -1
- package/dist/browser/checkout/{SaleWidget-b8d7781a.js → SaleWidget-21a0da95.js} +1 -1
- package/dist/browser/checkout/{SpendingCapHero-dd5b1386.js → SpendingCapHero-4cf86bc9.js} +1 -1
- package/dist/browser/checkout/{SwapWidget-a77d1670.js → SwapWidget-fa573621.js} +1 -1
- package/dist/browser/checkout/{TopUpView-dbf35ba5.js → TopUpView-20c59619.js} +1 -1
- package/dist/browser/checkout/{WalletWidget-2705fff8.js → WalletWidget-a7dae882.js} +1 -1
- package/dist/browser/checkout/{auto-track-236dc818.js → auto-track-47f8ae7b.js} +1 -1
- package/dist/browser/checkout/{balance-643231e9.js → balance-13198af0.js} +1 -1
- package/dist/browser/checkout/{index-e3a0f33f.js → index-394d516d.js} +2 -2
- package/dist/browser/checkout/{index-d7add53c.js → index-6707b5f0.js} +1 -1
- package/dist/browser/checkout/{index-e906b328.js → index-760c2a62.js} +1 -1
- package/dist/browser/checkout/{index-6e098a9e.js → index-761d51ab.js} +1 -1
- package/dist/browser/checkout/{index-b9730d0c.js → index-800f3b79.js} +1 -1
- package/dist/browser/checkout/{index-c8393089.js → index-8b5981fa.js} +1 -1
- package/dist/browser/checkout/{index-69e9466c.js → index-9daeacd3.js} +1 -1
- package/dist/browser/checkout/index-c8504cfe.js +1 -0
- package/dist/browser/checkout/{index.umd-b2990cfb.js → index.umd-cbd7b2eb.js} +1 -1
- package/dist/browser/checkout/{retry-c8740b81.js → retry-ce6e6559.js} +1 -1
- package/dist/browser/checkout/sdk.js +4 -4
- package/dist/browser/checkout/widgets-esm.js +1 -1
- package/dist/browser/checkout/widgets.js +1 -1
- package/dist/checkout.d.ts +4 -2
- package/dist/checkout.js +4 -4
- package/dist/config.js +1 -1
- package/dist/index.browser.js +5 -5
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +41 -32
- package/dist/index.d.ts +4 -2
- package/dist/index.js +42 -33
- package/dist/orderbook.js +1 -1
- package/dist/passport.js +40 -31
- package/dist/x.js +3 -3
- package/package.json +1 -1
- package/dist/browser/checkout/index-01833964.js +0 -1
package/dist/passport.js
CHANGED
|
@@ -10,7 +10,7 @@ import hashJS from 'hash.js';
|
|
|
10
10
|
import { ec, curves } from 'elliptic';
|
|
11
11
|
import 'ethereumjs-wallet';
|
|
12
12
|
import 'assert';
|
|
13
|
-
import { BigNumber, Contract, errors,
|
|
13
|
+
import { utils as utils$2, BigNumber, Contract, errors, ethers, constants } from 'ethers';
|
|
14
14
|
import '@ethersproject/abstract-signer';
|
|
15
15
|
import { UserManager, User, ErrorTimeout, ErrorResponse, InMemoryWebStorage, WebStorageStateStore } from 'oidc-client-ts';
|
|
16
16
|
import jwt_decode from 'jwt-decode';
|
|
@@ -18,7 +18,7 @@ import * as crypto from 'crypto';
|
|
|
18
18
|
import { Magic } from 'magic-sdk';
|
|
19
19
|
import { OpenIdExtension } from '@magic-ext/oidc';
|
|
20
20
|
import { generateLegacyStarkPrivateKey, createStarkSigner } from '@imtbl/core-sdk';
|
|
21
|
-
import {
|
|
21
|
+
import { StaticJsonRpcProvider, Web3Provider } from '@ethersproject/providers';
|
|
22
22
|
import { EventEmitter } from 'events';
|
|
23
23
|
import { walletContracts } from '@0xsequence/abi';
|
|
24
24
|
import { v1 } from '@0xsequence/core';
|
|
@@ -11350,7 +11350,7 @@ class MultiRollupApiClients {
|
|
|
11350
11350
|
}
|
|
11351
11351
|
|
|
11352
11352
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
11353
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-1.20.
|
|
11353
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-1.20.4' };
|
|
11354
11354
|
const createConfig$1 = ({ basePath, headers, }) => {
|
|
11355
11355
|
if (!basePath.trim()) {
|
|
11356
11356
|
throw Error('basePath can not be empty');
|
|
@@ -11529,7 +11529,7 @@ const flattenProperties = (properties) => {
|
|
|
11529
11529
|
};
|
|
11530
11530
|
|
|
11531
11531
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
11532
|
-
const SDK_VERSION = '1.20.
|
|
11532
|
+
const SDK_VERSION = '1.20.4';
|
|
11533
11533
|
const getReferrer = () => {
|
|
11534
11534
|
if (isNode()) {
|
|
11535
11535
|
return '';
|
|
@@ -11779,7 +11779,7 @@ const addKeysToHeadersOverride = (baseConfig, overrides) => {
|
|
|
11779
11779
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
11780
11780
|
class ApiConfiguration extends index$2.Configuration {
|
|
11781
11781
|
}
|
|
11782
|
-
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.20.
|
|
11782
|
+
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.20.4' };
|
|
11783
11783
|
/**
|
|
11784
11784
|
* @dev use createImmutableXConfiguration instead
|
|
11785
11785
|
*/
|
|
@@ -11818,7 +11818,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
11818
11818
|
chainID,
|
|
11819
11819
|
coreContractAddress,
|
|
11820
11820
|
registrationContractAddress,
|
|
11821
|
-
sdkVersion: 'ts-immutable-sdk-1.20.
|
|
11821
|
+
sdkVersion: 'ts-immutable-sdk-1.20.4',
|
|
11822
11822
|
baseConfig,
|
|
11823
11823
|
});
|
|
11824
11824
|
const production = ({ baseConfig }) => createImmutableXConfiguration({
|
|
@@ -20596,9 +20596,9 @@ function digestOfTransactionsAndNonce(nonce, normalisedTransactions) {
|
|
|
20596
20596
|
const packMetaTransactionsNonceData = utils$2.defaultAbiCoder.encode(['uint256', META_TRANSACTIONS_TYPE], [nonce, normalisedTransactions]);
|
|
20597
20597
|
return utils$2.keccak256(packMetaTransactionsNonceData);
|
|
20598
20598
|
}
|
|
20599
|
-
const getNonce = async (
|
|
20599
|
+
const getNonce = async (rpcProvider, smartContractWalletAddress) => {
|
|
20600
20600
|
try {
|
|
20601
|
-
const contract = new Contract(smartContractWalletAddress, walletContracts.mainModule.abi,
|
|
20601
|
+
const contract = new Contract(smartContractWalletAddress, walletContracts.mainModule.abi, rpcProvider);
|
|
20602
20602
|
const result = await contract.nonce();
|
|
20603
20603
|
if (result instanceof BigNumber) {
|
|
20604
20604
|
return result;
|
|
@@ -20700,11 +20700,11 @@ const getEip155ChainId = (chainId) => `eip155:${chainId}`;
|
|
|
20700
20700
|
|
|
20701
20701
|
class RelayerClient {
|
|
20702
20702
|
config;
|
|
20703
|
-
|
|
20703
|
+
rpcProvider;
|
|
20704
20704
|
authManager;
|
|
20705
|
-
constructor({ config,
|
|
20705
|
+
constructor({ config, rpcProvider, authManager }) {
|
|
20706
20706
|
this.config = config;
|
|
20707
|
-
this.
|
|
20707
|
+
this.rpcProvider = rpcProvider;
|
|
20708
20708
|
this.authManager = authManager;
|
|
20709
20709
|
}
|
|
20710
20710
|
async postToRelayer(request) {
|
|
@@ -20729,7 +20729,7 @@ class RelayerClient {
|
|
|
20729
20729
|
return jsonResponse;
|
|
20730
20730
|
}
|
|
20731
20731
|
async ethSendTransaction(to, data) {
|
|
20732
|
-
const { chainId } = await this.
|
|
20732
|
+
const { chainId } = await this.rpcProvider.detectNetwork();
|
|
20733
20733
|
const payload = {
|
|
20734
20734
|
method: 'eth_sendTransaction',
|
|
20735
20735
|
params: [{
|
|
@@ -20750,7 +20750,7 @@ class RelayerClient {
|
|
|
20750
20750
|
return result;
|
|
20751
20751
|
}
|
|
20752
20752
|
async imGetFeeOptions(userAddress, data) {
|
|
20753
|
-
const { chainId } = await this.
|
|
20753
|
+
const { chainId } = await this.rpcProvider.detectNetwork();
|
|
20754
20754
|
const payload = {
|
|
20755
20755
|
method: 'im_getFeeOptions',
|
|
20756
20756
|
params: [{
|
|
@@ -20763,7 +20763,7 @@ class RelayerClient {
|
|
|
20763
20763
|
return result;
|
|
20764
20764
|
}
|
|
20765
20765
|
async imSignTypedData(address, eip712Payload) {
|
|
20766
|
-
const { chainId } = await this.
|
|
20766
|
+
const { chainId } = await this.rpcProvider.detectNetwork();
|
|
20767
20767
|
const payload = {
|
|
20768
20768
|
method: 'im_signTypedData',
|
|
20769
20769
|
params: [{
|
|
@@ -20810,11 +20810,11 @@ class JsonRpcError extends Error {
|
|
|
20810
20810
|
}
|
|
20811
20811
|
|
|
20812
20812
|
const MESSAGE_TO_SIGN = 'Only sign this message from Immutable Passport';
|
|
20813
|
-
async function registerZkEvmUser({ authManager, ethSigner, multiRollupApiClients, accessToken,
|
|
20813
|
+
async function registerZkEvmUser({ authManager, ethSigner, multiRollupApiClients, accessToken, rpcProvider, }) {
|
|
20814
20814
|
const [ethereumAddress, ethereumSignature, network, chainListResponse] = await Promise.all([
|
|
20815
20815
|
ethSigner.getAddress(),
|
|
20816
20816
|
signRaw(MESSAGE_TO_SIGN, ethSigner),
|
|
20817
|
-
|
|
20817
|
+
rpcProvider.detectNetwork(),
|
|
20818
20818
|
multiRollupApiClients.chainsApi.listChains(),
|
|
20819
20819
|
]);
|
|
20820
20820
|
const eipChainId = getEip155ChainId(network.chainId);
|
|
@@ -21035,15 +21035,15 @@ const getMetaTransactions = async (metaTransaction, nonce, chainId, walletAddres
|
|
|
21035
21035
|
}
|
|
21036
21036
|
return [metaTransaction, feeMetaTransaction];
|
|
21037
21037
|
};
|
|
21038
|
-
const sendTransaction = ({ params, ethSigner,
|
|
21038
|
+
const sendTransaction = ({ params, ethSigner, rpcProvider, relayerClient, guardianClient, zkevmAddress, }) => guardianClient
|
|
21039
21039
|
.withConfirmationScreen({ width: 480, height: 720 })(async () => {
|
|
21040
21040
|
const transactionRequest = params[0];
|
|
21041
21041
|
if (!transactionRequest.to) {
|
|
21042
21042
|
throw new JsonRpcError(RpcErrorCode.INVALID_PARAMS, 'eth_sendTransaction requires a "to" field');
|
|
21043
21043
|
}
|
|
21044
|
-
const { chainId } = await
|
|
21044
|
+
const { chainId } = await rpcProvider.detectNetwork();
|
|
21045
21045
|
const chainIdBigNumber = BigNumber.from(chainId);
|
|
21046
|
-
const nonce = await getNonce(
|
|
21046
|
+
const nonce = await getNonce(rpcProvider, zkevmAddress);
|
|
21047
21047
|
const metaTransaction = {
|
|
21048
21048
|
to: transactionRequest.to,
|
|
21049
21049
|
data: transactionRequest.data,
|
|
@@ -21131,14 +21131,14 @@ const transformTypedData = (typedData, chainId) => {
|
|
|
21131
21131
|
}
|
|
21132
21132
|
return transformedTypedData;
|
|
21133
21133
|
};
|
|
21134
|
-
const signTypedDataV4 = async ({ params, method, ethSigner,
|
|
21134
|
+
const signTypedDataV4 = async ({ params, method, ethSigner, rpcProvider, relayerClient, guardianClient, }) => guardianClient
|
|
21135
21135
|
.withConfirmationScreen({ width: 480, height: 720 })(async () => {
|
|
21136
21136
|
const fromAddress = params[0];
|
|
21137
21137
|
const typedDataParam = params[1];
|
|
21138
21138
|
if (!fromAddress || !typedDataParam) {
|
|
21139
21139
|
throw new JsonRpcError(RpcErrorCode.INVALID_PARAMS, `${method} requires an address and a typed data JSON`);
|
|
21140
21140
|
}
|
|
21141
|
-
const { chainId } = await
|
|
21141
|
+
const { chainId } = await rpcProvider.detectNetwork();
|
|
21142
21142
|
const typedData = transformTypedData(typedDataParam, chainId);
|
|
21143
21143
|
await guardianClient.validateMessage({ chainID: String(chainId), payload: typedData });
|
|
21144
21144
|
const relayerSignature = await relayerClient.imSignTypedData(fromAddress, typedData);
|
|
@@ -21151,7 +21151,7 @@ class ZkEvmProvider {
|
|
|
21151
21151
|
#config;
|
|
21152
21152
|
#eventEmitter;
|
|
21153
21153
|
#guardianClient;
|
|
21154
|
-
#
|
|
21154
|
+
#rpcProvider; // Used for read
|
|
21155
21155
|
#magicAdapter;
|
|
21156
21156
|
#multiRollupApiClients;
|
|
21157
21157
|
#relayerClient;
|
|
@@ -21171,19 +21171,19 @@ class ZkEvmProvider {
|
|
|
21171
21171
|
this.#config = config;
|
|
21172
21172
|
this.#guardianClient = guardianClient;
|
|
21173
21173
|
if (config.crossSdkBridgeEnabled) {
|
|
21174
|
-
//
|
|
21174
|
+
// StaticJsonRpcProvider by default sets the referrer as "client".
|
|
21175
21175
|
// On Unreal 4 this errors as the browser used is expecting a valid URL.
|
|
21176
|
-
this.#
|
|
21176
|
+
this.#rpcProvider = new StaticJsonRpcProvider({
|
|
21177
21177
|
url: this.#config.zkEvmRpcUrl,
|
|
21178
21178
|
fetchOptions: { referrer: 'http://imtblgamesdk.local' },
|
|
21179
21179
|
});
|
|
21180
21180
|
}
|
|
21181
21181
|
else {
|
|
21182
|
-
this.#
|
|
21182
|
+
this.#rpcProvider = new StaticJsonRpcProvider(this.#config.zkEvmRpcUrl);
|
|
21183
21183
|
}
|
|
21184
21184
|
this.#relayerClient = new RelayerClient({
|
|
21185
21185
|
config: this.#config,
|
|
21186
|
-
|
|
21186
|
+
rpcProvider: this.#rpcProvider,
|
|
21187
21187
|
authManager: this.#authManager,
|
|
21188
21188
|
});
|
|
21189
21189
|
this.#multiRollupApiClients = multiRollupApiClients;
|
|
@@ -21254,7 +21254,7 @@ class ZkEvmProvider {
|
|
|
21254
21254
|
authManager: this.#authManager,
|
|
21255
21255
|
multiRollupApiClients: this.#multiRollupApiClients,
|
|
21256
21256
|
accessToken: user.accessToken,
|
|
21257
|
-
|
|
21257
|
+
rpcProvider: this.#rpcProvider,
|
|
21258
21258
|
});
|
|
21259
21259
|
}
|
|
21260
21260
|
else {
|
|
@@ -21272,7 +21272,7 @@ class ZkEvmProvider {
|
|
|
21272
21272
|
params: request.params || [],
|
|
21273
21273
|
ethSigner,
|
|
21274
21274
|
guardianClient: this.#guardianClient,
|
|
21275
|
-
|
|
21275
|
+
rpcProvider: this.#rpcProvider,
|
|
21276
21276
|
relayerClient: this.#relayerClient,
|
|
21277
21277
|
zkevmAddress: this.#zkEvmAddress,
|
|
21278
21278
|
});
|
|
@@ -21290,11 +21290,21 @@ class ZkEvmProvider {
|
|
|
21290
21290
|
method: request.method,
|
|
21291
21291
|
params: request.params || [],
|
|
21292
21292
|
ethSigner,
|
|
21293
|
-
|
|
21293
|
+
rpcProvider: this.#rpcProvider,
|
|
21294
21294
|
relayerClient: this.#relayerClient,
|
|
21295
21295
|
guardianClient: this.#guardianClient,
|
|
21296
21296
|
});
|
|
21297
21297
|
}
|
|
21298
|
+
case 'eth_chainId': {
|
|
21299
|
+
// Call detect network to fetch the chainId so to take advantage of
|
|
21300
|
+
// the caching layer provided by StaticJsonRpcProvider.
|
|
21301
|
+
// In case Passport is changed from StaticJsonRpcProvider to a
|
|
21302
|
+
// JsonRpcProvider, this function will still work as expected given
|
|
21303
|
+
// that detectNetwork call _uncachedDetectNetwork which will force
|
|
21304
|
+
// the provider to re-fetch the chainId from remote.
|
|
21305
|
+
const { chainId } = await this.#rpcProvider.detectNetwork();
|
|
21306
|
+
return utils$2.hexlify(chainId);
|
|
21307
|
+
}
|
|
21298
21308
|
// Pass through methods
|
|
21299
21309
|
case 'eth_gasPrice':
|
|
21300
21310
|
case 'eth_getBalance':
|
|
@@ -21303,13 +21313,12 @@ class ZkEvmProvider {
|
|
|
21303
21313
|
case 'eth_estimateGas':
|
|
21304
21314
|
case 'eth_call':
|
|
21305
21315
|
case 'eth_blockNumber':
|
|
21306
|
-
case 'eth_chainId':
|
|
21307
21316
|
case 'eth_getBlockByHash':
|
|
21308
21317
|
case 'eth_getBlockByNumber':
|
|
21309
21318
|
case 'eth_getTransactionByHash':
|
|
21310
21319
|
case 'eth_getTransactionReceipt':
|
|
21311
21320
|
case 'eth_getTransactionCount': {
|
|
21312
|
-
return this.#
|
|
21321
|
+
return this.#rpcProvider.send(request.method, request.params || []);
|
|
21313
21322
|
}
|
|
21314
21323
|
default: {
|
|
21315
21324
|
throw new JsonRpcError(ProviderErrorCode.UNSUPPORTED_METHOD, 'Method not supported');
|
package/dist/x.js
CHANGED
|
@@ -8953,7 +8953,7 @@ const flattenProperties = (properties) => {
|
|
|
8953
8953
|
};
|
|
8954
8954
|
|
|
8955
8955
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
8956
|
-
const SDK_VERSION = '1.20.
|
|
8956
|
+
const SDK_VERSION = '1.20.4';
|
|
8957
8957
|
const getReferrer = () => {
|
|
8958
8958
|
if (isNode()) {
|
|
8959
8959
|
return '';
|
|
@@ -9196,7 +9196,7 @@ const addKeysToHeadersOverride = (baseConfig, overrides) => {
|
|
|
9196
9196
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
9197
9197
|
class ApiConfiguration extends index$2.Configuration {
|
|
9198
9198
|
}
|
|
9199
|
-
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.20.
|
|
9199
|
+
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.20.4' };
|
|
9200
9200
|
/**
|
|
9201
9201
|
* @dev use createImmutableXConfiguration instead
|
|
9202
9202
|
*/
|
|
@@ -9235,7 +9235,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
9235
9235
|
chainID,
|
|
9236
9236
|
coreContractAddress,
|
|
9237
9237
|
registrationContractAddress,
|
|
9238
|
-
sdkVersion: 'ts-immutable-sdk-1.20.
|
|
9238
|
+
sdkVersion: 'ts-immutable-sdk-1.20.4',
|
|
9239
9239
|
baseConfig,
|
|
9240
9240
|
});
|
|
9241
9241
|
const production = ({ baseConfig }) => createImmutableXConfiguration({
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{cs as n,ct as t}from"./index-e3a0f33f.js";function i(i){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){switch(t.label){case 0:return[4,import("./index.umd-b2990cfb.js").then((function(n){return n.i}))];case 1:return n=t.sent(),i._plugins=n,[2]}}))}))}export{i as loadLegacyVideoPlugins};
|