@imtbl/sdk 1.13.0 → 1.13.2-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.
- package/dist/blockchain_data.d.ts +1 -13
- package/dist/blockchain_data.js +4 -3
- package/dist/browser/checkout/{BridgeWidget-a0216abf.js → BridgeWidget-feb6e244.js} +1 -1
- package/dist/browser/checkout/{OnRampWidget-0141412f.js → OnRampWidget-bf7b0285.js} +1 -1
- package/dist/browser/checkout/SaleWidget-8bbac84d.js +2 -0
- package/dist/browser/checkout/{SpendingCapHero-f00c162d.js → SpendingCapHero-cc97026e.js} +1 -1
- package/dist/browser/checkout/{SwapWidget-7dd7ae0d.js → SwapWidget-411d726b.js} +1 -1
- package/dist/browser/checkout/{TopUpView-83b01082.js → TopUpView-62c3bb1c.js} +1 -1
- package/dist/browser/checkout/{WalletWidget-a7294770.js → WalletWidget-da4cd5a6.js} +1 -1
- package/dist/browser/checkout/{auto-track-a6ee7728.js → auto-track-42ec91ae.js} +1 -1
- package/dist/browser/checkout/{balance-cab05497.js → balance-0e3acb15.js} +1 -1
- package/dist/browser/checkout/{index-e06cc1d2.js → index-0face9fc.js} +1 -1
- package/dist/browser/checkout/{index-57f03d43.js → index-1383cc81.js} +2 -2
- package/dist/browser/checkout/{index-fb6525df.js → index-2a04a2f2.js} +1 -1
- package/dist/browser/checkout/{index-a53ae4b9.js → index-4ceb8896.js} +1 -1
- package/dist/browser/checkout/index-4eeff6a1.js +1 -0
- package/dist/browser/checkout/{index-f13a14b5.js → index-6b30a04c.js} +1 -1
- package/dist/browser/checkout/{index-51cb702e.js → index-912bd43f.js} +1 -1
- package/dist/browser/checkout/{index-b10fea31.js → index-a4e5665c.js} +1 -1
- package/dist/browser/checkout/{index.umd-ebf23be8.js → index.umd-22e11686.js} +1 -1
- package/dist/browser/checkout/{retry-242a2c60.js → retry-4271fac2.js} +1 -1
- package/dist/browser/checkout/sdk.js +7 -7
- package/dist/browser/checkout/{useTransakEvents-4a36b909.js → useTransakEvents-4f11a227.js} +1 -1
- package/dist/browser/checkout/widgets-esm.js +1 -1
- package/dist/browser/checkout/widgets.js +60 -60
- package/dist/checkout.d.ts +1 -13
- package/dist/checkout.js +6 -5
- package/dist/config.d.ts +2 -17
- package/dist/config.js +3 -21
- package/dist/index.browser.js +13 -13
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +89 -79
- package/dist/index.d.ts +1 -22
- package/dist/index.js +90 -80
- package/dist/orderbook.d.ts +1 -13
- package/dist/orderbook.js +1 -1
- package/dist/passport.d.ts +1 -13
- package/dist/passport.js +85 -54
- package/dist/x.d.ts +1 -13
- package/dist/x.js +2 -2
- package/package.json +1 -1
- package/dist/browser/checkout/SaleWidget-dfb3ec06.js +0 -2
- package/dist/browser/checkout/index-1c0cb426.js +0 -1
package/dist/index.cjs
CHANGED
|
@@ -174,7 +174,7 @@ const flattenProperties$1 = (properties) => {
|
|
|
174
174
|
};
|
|
175
175
|
|
|
176
176
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
177
|
-
const SDK_VERSION$1 = '1.13.
|
|
177
|
+
const SDK_VERSION$1 = '1.13.2-alpha.1';
|
|
178
178
|
const getReferrer$1 = () => {
|
|
179
179
|
if (isNode$1()) {
|
|
180
180
|
return '';
|
|
@@ -410,6 +410,7 @@ const addKeysToHeadersOverride = (baseConfig, overrides) => {
|
|
|
410
410
|
}
|
|
411
411
|
if (baseConfig.publishableKey) {
|
|
412
412
|
newHeaders[KeyHeaders$1.PUBLISHABLE_KEY] = baseConfig.publishableKey;
|
|
413
|
+
setPublishableApiKey(baseConfig.publishableKey);
|
|
413
414
|
}
|
|
414
415
|
if (baseConfig.rateLimitingKey) {
|
|
415
416
|
newHeaders[KeyHeaders$1.RATE_LIMITING_KEY] = baseConfig.rateLimitingKey;
|
|
@@ -429,35 +430,13 @@ const addKeysToHeadersOverride = (baseConfig, overrides) => {
|
|
|
429
430
|
headers: newHeaders,
|
|
430
431
|
};
|
|
431
432
|
};
|
|
432
|
-
const API_KEY_PREFIX = 'sk_imapik-';
|
|
433
|
-
const PUBLISHABLE_KEY_PREFIX$1 = 'pk_imapik-';
|
|
434
|
-
const addApiKeyToAxiosHeader = (apiKey) => {
|
|
435
|
-
if (!apiKey.startsWith(API_KEY_PREFIX)) {
|
|
436
|
-
throw new Error('Invalid API key. Create your api key in Immutable developer hub. https://hub.immutable.com');
|
|
437
|
-
}
|
|
438
|
-
globalAxios$1.defaults.headers.common[KeyHeaders$1.API_KEY] = apiKey;
|
|
439
|
-
};
|
|
440
|
-
const addPublishableKeyToAxiosHeader = (publishableKey) => {
|
|
441
|
-
if (!publishableKey.startsWith(PUBLISHABLE_KEY_PREFIX$1)) {
|
|
442
|
-
throw new Error('Invalid Publishable key. Create your Publishable key in Immutable developer hub.'
|
|
443
|
-
+ ' https://hub.immutable.com');
|
|
444
|
-
}
|
|
445
|
-
setPublishableApiKey(publishableKey);
|
|
446
|
-
globalAxios$1.defaults.headers.common[KeyHeaders$1.PUBLISHABLE_KEY] = publishableKey;
|
|
447
|
-
};
|
|
448
|
-
const addRateLimitingKeyToAxiosHeader = (rateLimitingKey) => {
|
|
449
|
-
globalAxios$1.defaults.headers.common[KeyHeaders$1.RATE_LIMITING_KEY] = rateLimitingKey;
|
|
450
|
-
};
|
|
451
433
|
|
|
452
434
|
var config = /*#__PURE__*/Object.freeze({
|
|
453
435
|
__proto__: null,
|
|
454
436
|
get Environment () { return Environment$1; },
|
|
455
437
|
ImmutableConfiguration: ImmutableConfiguration,
|
|
456
438
|
get KeyHeaders () { return KeyHeaders$1; },
|
|
457
|
-
|
|
458
|
-
addKeysToHeadersOverride: addKeysToHeadersOverride,
|
|
459
|
-
addPublishableKeyToAxiosHeader: addPublishableKeyToAxiosHeader,
|
|
460
|
-
addRateLimitingKeyToAxiosHeader: addRateLimitingKeyToAxiosHeader
|
|
439
|
+
addKeysToHeadersOverride: addKeysToHeadersOverride
|
|
461
440
|
});
|
|
462
441
|
|
|
463
442
|
/* tslint:disable */
|
|
@@ -11571,7 +11550,7 @@ class MultiRollupApiClients {
|
|
|
11571
11550
|
}
|
|
11572
11551
|
|
|
11573
11552
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
11574
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-1.13.
|
|
11553
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-1.13.2-alpha.1' };
|
|
11575
11554
|
const createConfig = ({ basePath, headers, }) => {
|
|
11576
11555
|
if (!basePath.trim()) {
|
|
11577
11556
|
throw Error('basePath can not be empty');
|
|
@@ -11643,7 +11622,7 @@ class APIError extends Error {
|
|
|
11643
11622
|
|
|
11644
11623
|
/* eslint-disable implicit-arrow-linebreak */
|
|
11645
11624
|
const defaultHeaders = {
|
|
11646
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.13.
|
|
11625
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.13.2-alpha.1',
|
|
11647
11626
|
};
|
|
11648
11627
|
/**
|
|
11649
11628
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -12126,7 +12105,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
12126
12105
|
chainID,
|
|
12127
12106
|
coreContractAddress,
|
|
12128
12107
|
registrationContractAddress,
|
|
12129
|
-
sdkVersion: 'ts-immutable-sdk-1.13.
|
|
12108
|
+
sdkVersion: 'ts-immutable-sdk-1.13.2-alpha.1',
|
|
12130
12109
|
});
|
|
12131
12110
|
/**
|
|
12132
12111
|
* Sets `sdkVersion` at the time of build
|
|
@@ -16732,6 +16711,17 @@ class DeviceCredentialsManager {
|
|
|
16732
16711
|
}
|
|
16733
16712
|
}
|
|
16734
16713
|
|
|
16714
|
+
const shouldLog = process?.env?.JEST_WORKER_ID === undefined;
|
|
16715
|
+
const warn = (...args) => {
|
|
16716
|
+
if (shouldLog) {
|
|
16717
|
+
// eslint-disable-next-line no-console
|
|
16718
|
+
console.warn(...args);
|
|
16719
|
+
}
|
|
16720
|
+
};
|
|
16721
|
+
var logger$f = {
|
|
16722
|
+
warn,
|
|
16723
|
+
};
|
|
16724
|
+
|
|
16735
16725
|
function isIdTokenExpired(idToken) {
|
|
16736
16726
|
if (!idToken) {
|
|
16737
16727
|
return false;
|
|
@@ -16894,8 +16884,7 @@ class AuthManager {
|
|
|
16894
16884
|
user = await this.getUser();
|
|
16895
16885
|
}
|
|
16896
16886
|
catch (err) {
|
|
16897
|
-
|
|
16898
|
-
console.warn('failed to retrieve a cached user session:', err);
|
|
16887
|
+
logger$f.warn('Failed to retrieve a cached user session', err);
|
|
16899
16888
|
}
|
|
16900
16889
|
return user || this.login();
|
|
16901
16890
|
}
|
|
@@ -17039,8 +17028,7 @@ class AuthManager {
|
|
|
17039
17028
|
}
|
|
17040
17029
|
forceUserRefreshInBackground() {
|
|
17041
17030
|
this.refreshTokenAndUpdatePromise().catch((error) => {
|
|
17042
|
-
|
|
17043
|
-
console.warn('Failed to refresh user token', error);
|
|
17031
|
+
logger$f.warn('Failed to refresh user token', error);
|
|
17044
17032
|
});
|
|
17045
17033
|
}
|
|
17046
17034
|
async forceUserRefresh() {
|
|
@@ -17541,7 +17529,7 @@ async function registerOffchain$1(userAdminKeySigner, starkSigner, unregisteredU
|
|
|
17541
17529
|
return response;
|
|
17542
17530
|
}
|
|
17543
17531
|
catch (err) {
|
|
17544
|
-
if (globalAxios$1.isAxiosError(err) && err.status === 409) {
|
|
17532
|
+
if (globalAxios$1.isAxiosError(err) && err.response?.status === 409) {
|
|
17545
17533
|
// The user already registered, but the user token is not updated yet.
|
|
17546
17534
|
await forceUserRefresh(authManager);
|
|
17547
17535
|
return { tx_hash: '' };
|
|
@@ -17560,8 +17548,8 @@ class PassportImxProvider {
|
|
|
17560
17548
|
/**
|
|
17561
17549
|
* This property is set during initialisation and stores the signers in a promise.
|
|
17562
17550
|
* This property is not meant to be accessed directly, but through the
|
|
17563
|
-
* `
|
|
17564
|
-
* @see
|
|
17551
|
+
* `#getSigners` method.
|
|
17552
|
+
* @see #getSigners
|
|
17565
17553
|
*/
|
|
17566
17554
|
signers;
|
|
17567
17555
|
signerInitialisationError;
|
|
@@ -17571,7 +17559,7 @@ class PassportImxProvider {
|
|
|
17571
17559
|
this.magicAdapter = magicAdapter;
|
|
17572
17560
|
this.imxApiClients = imxApiClients;
|
|
17573
17561
|
this.guardianClient = guardianClient;
|
|
17574
|
-
this
|
|
17562
|
+
this.#initialiseSigners();
|
|
17575
17563
|
passportEventEmitter.on(PassportEvents.LOGGED_OUT, this.handleLogout);
|
|
17576
17564
|
}
|
|
17577
17565
|
handleLogout = () => {
|
|
@@ -17586,10 +17574,10 @@ class PassportImxProvider {
|
|
|
17586
17574
|
* so that it doesn't result in an unhandled promise rejection.
|
|
17587
17575
|
*
|
|
17588
17576
|
* This error is thrown when the signers are requested through:
|
|
17589
|
-
* @see
|
|
17577
|
+
* @see #getSigners
|
|
17590
17578
|
*
|
|
17591
17579
|
*/
|
|
17592
|
-
initialiseSigners() {
|
|
17580
|
+
#initialiseSigners() {
|
|
17593
17581
|
const generateSigners = async () => {
|
|
17594
17582
|
const user = await this.authManager.getUser();
|
|
17595
17583
|
// The user will be present because the factory validates it
|
|
@@ -17611,11 +17599,14 @@ class PassportImxProvider {
|
|
|
17611
17599
|
}
|
|
17612
17600
|
});
|
|
17613
17601
|
}
|
|
17614
|
-
async
|
|
17602
|
+
async #getAuthenticatedUser() {
|
|
17615
17603
|
const user = await this.authManager.getUser();
|
|
17616
17604
|
if (!user || !this.signers) {
|
|
17617
17605
|
throw new PassportError('User has been logged out', PassportErrorType.NOT_LOGGED_IN_ERROR);
|
|
17618
17606
|
}
|
|
17607
|
+
return user;
|
|
17608
|
+
}
|
|
17609
|
+
async #getSigners() {
|
|
17619
17610
|
const signers = await this.signers;
|
|
17620
17611
|
// Throw the stored error if the signers failed to initialise
|
|
17621
17612
|
if (typeof signers === 'undefined') {
|
|
@@ -17624,17 +17615,24 @@ class PassportImxProvider {
|
|
|
17624
17615
|
}
|
|
17625
17616
|
throw new Error('Signers failed to initialise');
|
|
17626
17617
|
}
|
|
17627
|
-
return
|
|
17618
|
+
return signers;
|
|
17628
17619
|
}
|
|
17629
|
-
async getRegisteredImxUserAndSigners() {
|
|
17630
|
-
const
|
|
17620
|
+
async #getRegisteredImxUserAndSigners() {
|
|
17621
|
+
const [user, signers] = await Promise.all([
|
|
17622
|
+
this.#getAuthenticatedUser(),
|
|
17623
|
+
this.#getSigners(),
|
|
17624
|
+
]);
|
|
17631
17625
|
if (!isUserImx(user)) {
|
|
17632
17626
|
throw new PassportError('User has not been registered with StarkEx', PassportErrorType.USER_NOT_REGISTERED_ERROR);
|
|
17633
17627
|
}
|
|
17634
|
-
return {
|
|
17628
|
+
return {
|
|
17629
|
+
user,
|
|
17630
|
+
starkSigner: signers.starkSigner,
|
|
17631
|
+
ethSigner: signers.ethSigner,
|
|
17632
|
+
};
|
|
17635
17633
|
}
|
|
17636
17634
|
async transfer(request) {
|
|
17637
|
-
const { user, starkSigner } = await this
|
|
17635
|
+
const { user, starkSigner } = await this.#getRegisteredImxUserAndSigners();
|
|
17638
17636
|
return transfer$1({
|
|
17639
17637
|
request,
|
|
17640
17638
|
user,
|
|
@@ -17644,20 +17642,22 @@ class PassportImxProvider {
|
|
|
17644
17642
|
});
|
|
17645
17643
|
}
|
|
17646
17644
|
async registerOffchain() {
|
|
17647
|
-
const
|
|
17648
|
-
|
|
17645
|
+
const [user, signers] = await Promise.all([
|
|
17646
|
+
this.#getAuthenticatedUser(),
|
|
17647
|
+
this.#getSigners(),
|
|
17648
|
+
]);
|
|
17649
|
+
return await registerOffchain$1(signers.ethSigner, signers.starkSigner, user, this.authManager, this.imxApiClients);
|
|
17649
17650
|
}
|
|
17650
17651
|
async isRegisteredOffchain() {
|
|
17651
|
-
const
|
|
17652
|
+
const user = await this.#getAuthenticatedUser();
|
|
17652
17653
|
return !!user.imx;
|
|
17653
17654
|
}
|
|
17654
|
-
// TODO: Remove once implemented
|
|
17655
17655
|
// eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars
|
|
17656
17656
|
isRegisteredOnchain() {
|
|
17657
17657
|
throw new PassportError('Operation not supported', PassportErrorType.OPERATION_NOT_SUPPORTED_ERROR);
|
|
17658
17658
|
}
|
|
17659
17659
|
async createOrder(request) {
|
|
17660
|
-
const { user, starkSigner } = await this
|
|
17660
|
+
const { user, starkSigner } = await this.#getRegisteredImxUserAndSigners();
|
|
17661
17661
|
return createOrder$1({
|
|
17662
17662
|
request,
|
|
17663
17663
|
user,
|
|
@@ -17667,7 +17667,7 @@ class PassportImxProvider {
|
|
|
17667
17667
|
});
|
|
17668
17668
|
}
|
|
17669
17669
|
async cancelOrder(request) {
|
|
17670
|
-
const { user, starkSigner } = await this
|
|
17670
|
+
const { user, starkSigner } = await this.#getRegisteredImxUserAndSigners();
|
|
17671
17671
|
return cancelOrder$1({
|
|
17672
17672
|
request,
|
|
17673
17673
|
user,
|
|
@@ -17677,7 +17677,7 @@ class PassportImxProvider {
|
|
|
17677
17677
|
});
|
|
17678
17678
|
}
|
|
17679
17679
|
async createTrade(request) {
|
|
17680
|
-
const { user, starkSigner } = await this
|
|
17680
|
+
const { user, starkSigner } = await this.#getRegisteredImxUserAndSigners();
|
|
17681
17681
|
return createTrade$1({
|
|
17682
17682
|
request,
|
|
17683
17683
|
user,
|
|
@@ -17687,7 +17687,7 @@ class PassportImxProvider {
|
|
|
17687
17687
|
});
|
|
17688
17688
|
}
|
|
17689
17689
|
async batchNftTransfer(request) {
|
|
17690
|
-
const { user, starkSigner } = await this
|
|
17690
|
+
const { user, starkSigner } = await this.#getRegisteredImxUserAndSigners();
|
|
17691
17691
|
return batchNftTransfer({
|
|
17692
17692
|
request,
|
|
17693
17693
|
user,
|
|
@@ -17697,7 +17697,7 @@ class PassportImxProvider {
|
|
|
17697
17697
|
});
|
|
17698
17698
|
}
|
|
17699
17699
|
async exchangeTransfer(request) {
|
|
17700
|
-
const { user, starkSigner } = await this
|
|
17700
|
+
const { user, starkSigner } = await this.#getRegisteredImxUserAndSigners();
|
|
17701
17701
|
return exchangeTransfer$1({
|
|
17702
17702
|
request,
|
|
17703
17703
|
user,
|
|
@@ -17705,17 +17705,14 @@ class PassportImxProvider {
|
|
|
17705
17705
|
exchangesApi: this.immutableXClient.exchangeApi,
|
|
17706
17706
|
});
|
|
17707
17707
|
}
|
|
17708
|
-
// TODO: Remove once implemented
|
|
17709
17708
|
// eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars
|
|
17710
17709
|
deposit(deposit) {
|
|
17711
17710
|
throw new PassportError('Operation not supported', PassportErrorType.OPERATION_NOT_SUPPORTED_ERROR);
|
|
17712
17711
|
}
|
|
17713
|
-
// TODO: Remove once implemented
|
|
17714
17712
|
// eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars
|
|
17715
17713
|
prepareWithdrawal(request) {
|
|
17716
17714
|
throw new PassportError('Operation not supported', PassportErrorType.OPERATION_NOT_SUPPORTED_ERROR);
|
|
17717
17715
|
}
|
|
17718
|
-
// TODO: Remove once implemented
|
|
17719
17716
|
// eslint-disable-next-line class-methods-use-this
|
|
17720
17717
|
completeWithdrawal(
|
|
17721
17718
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -17725,7 +17722,10 @@ class PassportImxProvider {
|
|
|
17725
17722
|
throw new PassportError('Operation not supported', PassportErrorType.OPERATION_NOT_SUPPORTED_ERROR);
|
|
17726
17723
|
}
|
|
17727
17724
|
async getAddress() {
|
|
17728
|
-
const
|
|
17725
|
+
const user = await this.#getAuthenticatedUser();
|
|
17726
|
+
if (!isUserImx(user)) {
|
|
17727
|
+
throw new PassportError('User has not been registered with StarkEx', PassportErrorType.USER_NOT_REGISTERED_ERROR);
|
|
17728
|
+
}
|
|
17729
17729
|
return Promise.resolve(user.imx.ethAddress);
|
|
17730
17730
|
}
|
|
17731
17731
|
}
|
|
@@ -18082,33 +18082,45 @@ function getNormalisedTransactions(txs) {
|
|
|
18082
18082
|
return txs.map((t) => ({
|
|
18083
18083
|
delegateCall: t.delegateCall === true,
|
|
18084
18084
|
revertOnError: t.revertOnError === true,
|
|
18085
|
-
gasLimit: t.gasLimit ?? ethers.
|
|
18086
|
-
target: t.to ?? ethers.
|
|
18087
|
-
value: t.value ?? ethers.
|
|
18085
|
+
gasLimit: t.gasLimit ?? ethers.constants.Zero,
|
|
18086
|
+
target: t.to ?? ethers.constants.AddressZero,
|
|
18087
|
+
value: t.value ?? ethers.constants.Zero,
|
|
18088
18088
|
data: t.data ?? [],
|
|
18089
18089
|
}));
|
|
18090
18090
|
}
|
|
18091
18091
|
function digestOfTransactionsAndNonce(nonce, normalisedTransactions) {
|
|
18092
|
-
const packMetaTransactionsNonceData = ethers.
|
|
18093
|
-
return ethers.
|
|
18092
|
+
const packMetaTransactionsNonceData = ethers.utils.defaultAbiCoder.encode(['uint256', META_TRANSACTIONS_TYPE], [nonce, normalisedTransactions]);
|
|
18093
|
+
return ethers.utils.keccak256(packMetaTransactionsNonceData);
|
|
18094
18094
|
}
|
|
18095
18095
|
const getNonce = async (jsonRpcProvider, smartContractWalletAddress) => {
|
|
18096
|
-
|
|
18097
|
-
|
|
18098
|
-
const
|
|
18099
|
-
|
|
18096
|
+
try {
|
|
18097
|
+
const contract = new ethers.Contract(smartContractWalletAddress, abi.walletContracts.mainModule.abi, jsonRpcProvider);
|
|
18098
|
+
const result = await contract.nonce();
|
|
18099
|
+
if (result instanceof ethers.BigNumber) {
|
|
18100
|
+
return result;
|
|
18101
|
+
}
|
|
18100
18102
|
}
|
|
18101
|
-
|
|
18103
|
+
catch (error) {
|
|
18104
|
+
if (error instanceof Error
|
|
18105
|
+
&& 'code' in error
|
|
18106
|
+
&& error.code === ethers.errors.CALL_EXCEPTION) {
|
|
18107
|
+
// The most likely reason for a CALL_EXCEPTION is that the smart contract wallet
|
|
18108
|
+
// has not been deployed yet, so we should default to a nonce of 0.
|
|
18109
|
+
return ethers.BigNumber.from(0);
|
|
18110
|
+
}
|
|
18111
|
+
throw error;
|
|
18112
|
+
}
|
|
18113
|
+
throw new Error('Unexpected result from contract.nonce() call.');
|
|
18102
18114
|
};
|
|
18103
|
-
const encodeMessageSubDigest = (chainId, walletAddress, digest) => (ethers.
|
|
18115
|
+
const encodeMessageSubDigest = (chainId, walletAddress, digest) => (ethers.utils.solidityPack(['string', 'uint256', 'address', 'bytes32'], [ETH_SIGN_PREFIX, chainId, walletAddress, digest]));
|
|
18104
18116
|
const getSignedMetaTransactions = async (metaTransactions, nonce, chainId, walletAddress, signer) => {
|
|
18105
18117
|
const normalisedMetaTransactions = getNormalisedTransactions(metaTransactions);
|
|
18106
18118
|
// Get the hash
|
|
18107
18119
|
const digest = digestOfTransactionsAndNonce(nonce, normalisedMetaTransactions);
|
|
18108
18120
|
const completePayload = encodeMessageSubDigest(chainId, walletAddress, digest);
|
|
18109
|
-
const hash = ethers.
|
|
18121
|
+
const hash = ethers.utils.keccak256(completePayload);
|
|
18110
18122
|
// Sign the digest
|
|
18111
|
-
const hashArray = ethers.
|
|
18123
|
+
const hashArray = ethers.utils.arrayify(hash);
|
|
18112
18124
|
const ethsigNoType = await signer.signMessage(hashArray);
|
|
18113
18125
|
const signedDigest = `${ethsigNoType}${ETH_SIGN_FLAG}`;
|
|
18114
18126
|
// Add metadata
|
|
@@ -18125,7 +18137,7 @@ const getSignedMetaTransactions = async (metaTransactions, nonce, chainId, walle
|
|
|
18125
18137
|
],
|
|
18126
18138
|
});
|
|
18127
18139
|
// Encode the transaction;
|
|
18128
|
-
const walletInterface = new ethers.
|
|
18140
|
+
const walletInterface = new ethers.utils.Interface(abi.walletContracts.mainModule.abi);
|
|
18129
18141
|
return walletInterface.encodeFunctionData(walletInterface.getFunction('execute'), [
|
|
18130
18142
|
normalisedMetaTransactions,
|
|
18131
18143
|
nonce,
|
|
@@ -18142,13 +18154,13 @@ const getSignedTypedData = async (typedData, relayerSignature, chainId, walletAd
|
|
|
18142
18154
|
// @ts-ignore
|
|
18143
18155
|
delete types.EIP712Domain;
|
|
18144
18156
|
// Hash the EIP712 payload and generate the complete payload
|
|
18145
|
-
const { _TypedDataEncoder: typedDataEncoder } = ethers.
|
|
18157
|
+
const { _TypedDataEncoder: typedDataEncoder } = ethers.utils;
|
|
18146
18158
|
const typedDataHash = typedDataEncoder.hash(typedData.domain, types, typedData.message);
|
|
18147
18159
|
const messageSubDigest = encodeMessageSubDigest(chainId, walletAddress, typedDataHash);
|
|
18148
|
-
const hash = ethers.
|
|
18160
|
+
const hash = ethers.utils.keccak256(messageSubDigest);
|
|
18149
18161
|
// Sign the sub digest
|
|
18150
18162
|
// https://github.com/immutable/wallet-contracts/blob/7824b5f24b2e0eb2dc465ecb5cd71f3984556b73/src/contracts/modules/commons/ModuleAuth.sol#L155
|
|
18151
|
-
const hashArray = ethers.
|
|
18163
|
+
const hashArray = ethers.utils.arrayify(hash);
|
|
18152
18164
|
const ethsigNoType = await signer.signMessage(hashArray);
|
|
18153
18165
|
const signedDigest = `${ethsigNoType}${ETH_SIGN_FLAG}`;
|
|
18154
18166
|
// Combine the relayer and user signatures; sort by address to match the imageHash order
|
|
@@ -19012,8 +19024,7 @@ class Passport {
|
|
|
19012
19024
|
if (useCachedSession) {
|
|
19013
19025
|
throw error;
|
|
19014
19026
|
}
|
|
19015
|
-
|
|
19016
|
-
console.warn('login failed to retrieve a cached user session', error);
|
|
19027
|
+
logger$f.warn('Failed to retrieve a cached user session', error);
|
|
19017
19028
|
}
|
|
19018
19029
|
if (!user && !useCachedSession) {
|
|
19019
19030
|
user = await this.authManager.login(options?.anonymousId);
|
|
@@ -19047,8 +19058,7 @@ class Passport {
|
|
|
19047
19058
|
await this.confirmationScreen.logout();
|
|
19048
19059
|
}
|
|
19049
19060
|
catch (err) {
|
|
19050
|
-
|
|
19051
|
-
console.warn('Failed to logout from confirmation screen', err);
|
|
19061
|
+
logger$f.warn('Failed to logout from confirmation screen', err);
|
|
19052
19062
|
}
|
|
19053
19063
|
await Promise.allSettled([
|
|
19054
19064
|
this.authManager.logout(),
|
|
@@ -37857,7 +37867,7 @@ const flattenProperties = (properties) => {
|
|
|
37857
37867
|
};
|
|
37858
37868
|
|
|
37859
37869
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
37860
|
-
const SDK_VERSION = '1.13.
|
|
37870
|
+
const SDK_VERSION = '1.13.2-alpha.1';
|
|
37861
37871
|
const getReferrer = () => {
|
|
37862
37872
|
if (isNode()) {
|
|
37863
37873
|
return '';
|
|
@@ -43033,7 +43043,7 @@ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
|
|
|
43033
43043
|
maxPriorityFeePerGas: ethers.BigNumber.from(10e9),
|
|
43034
43044
|
};
|
|
43035
43045
|
|
|
43036
|
-
const SDK_VERSION_MARKER = '1.13.
|
|
43046
|
+
const SDK_VERSION_MARKER = '1.13.2-alpha.1';
|
|
43037
43047
|
// This SDK version is replaced by the `yarn build` command ran on the root level
|
|
43038
43048
|
const globalPackageVersion = () => SDK_VERSION_MARKER;
|
|
43039
43049
|
|
package/dist/index.d.ts
CHANGED
|
@@ -23,23 +23,8 @@ declare class ImmutableConfiguration {
|
|
|
23
23
|
declare const addKeysToHeadersOverride: <T extends {
|
|
24
24
|
headers?: Record<string, string> | undefined;
|
|
25
25
|
}>(baseConfig: ImmutableConfiguration | undefined, overrides: T | undefined) => T | undefined;
|
|
26
|
-
declare const addApiKeyToAxiosHeader: (apiKey: string) => void;
|
|
27
|
-
declare const addPublishableKeyToAxiosHeader: (publishableKey: string) => void;
|
|
28
|
-
declare const addRateLimitingKeyToAxiosHeader: (rateLimitingKey: string) => void;
|
|
29
|
-
type ImmutableConfigurationWithRequireableFields<T> = ImmutableConfiguration & (T extends {
|
|
30
|
-
apiKey: 'required';
|
|
31
|
-
} ? Required<{
|
|
32
|
-
apiKey: string;
|
|
33
|
-
}> : {}) & (T extends {
|
|
34
|
-
publishableKey: 'required';
|
|
35
|
-
} ? Required<{
|
|
36
|
-
publishableKey: string;
|
|
37
|
-
}> : {});
|
|
38
|
-
type ImmutableConfigurationWithOmitableFields<T> = T extends {
|
|
39
|
-
apiKey: 'omit';
|
|
40
|
-
} ? Omit<ImmutableConfigurationWithRequireableFields<T>, 'apiKey'> : ImmutableConfigurationWithRequireableFields<T>;
|
|
41
26
|
interface ModuleConfiguration<T> {
|
|
42
|
-
baseConfig:
|
|
27
|
+
baseConfig: ImmutableConfiguration;
|
|
43
28
|
overrides?: T;
|
|
44
29
|
}
|
|
45
30
|
|
|
@@ -50,20 +35,14 @@ declare const config_d_ImmutableConfiguration: typeof ImmutableConfiguration;
|
|
|
50
35
|
type config_d_KeyHeaders = KeyHeaders;
|
|
51
36
|
declare const config_d_KeyHeaders: typeof KeyHeaders;
|
|
52
37
|
type config_d_ModuleConfiguration<T> = ModuleConfiguration<T>;
|
|
53
|
-
declare const config_d_addApiKeyToAxiosHeader: typeof addApiKeyToAxiosHeader;
|
|
54
38
|
declare const config_d_addKeysToHeadersOverride: typeof addKeysToHeadersOverride;
|
|
55
|
-
declare const config_d_addPublishableKeyToAxiosHeader: typeof addPublishableKeyToAxiosHeader;
|
|
56
|
-
declare const config_d_addRateLimitingKeyToAxiosHeader: typeof addRateLimitingKeyToAxiosHeader;
|
|
57
39
|
declare namespace config_d {
|
|
58
40
|
export {
|
|
59
41
|
config_d_Environment as Environment,
|
|
60
42
|
config_d_ImmutableConfiguration as ImmutableConfiguration,
|
|
61
43
|
config_d_KeyHeaders as KeyHeaders,
|
|
62
44
|
config_d_ModuleConfiguration as ModuleConfiguration,
|
|
63
|
-
config_d_addApiKeyToAxiosHeader as addApiKeyToAxiosHeader,
|
|
64
45
|
config_d_addKeysToHeadersOverride as addKeysToHeadersOverride,
|
|
65
|
-
config_d_addPublishableKeyToAxiosHeader as addPublishableKeyToAxiosHeader,
|
|
66
|
-
config_d_addRateLimitingKeyToAxiosHeader as addRateLimitingKeyToAxiosHeader,
|
|
67
46
|
};
|
|
68
47
|
}
|
|
69
48
|
|