@imtbl/sdk 0.28.6-alpha → 0.28.7-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/provider.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import { Config, TransfersApi, OrdersApi, UsersApi, Contracts, TradesApi, ExchangesApi, WithdrawalsApi, MintsApi, DepositsApi, EncodingApi, TokensApi } from '@imtbl/core-sdk';
2
2
  import BN from 'bn.js';
3
3
  import * as encUtils from 'enc-utils';
4
+ import { AxiosError } from 'axios';
4
5
  import { parseUnits } from '@ethersproject/units';
5
6
  import { BigNumber } from '@ethersproject/bignumber';
6
7
  import { ethers } from 'ethers';
7
8
  import detectEthereumProvider from '@metamask/detect-provider';
8
- import 'axios';
9
9
 
10
10
  // used to sign message with L1 keys. Used for registration
11
11
  function serializeEthSignature(sig) {
@@ -285,6 +285,22 @@ async function registerOffchain(signers, config) {
285
285
  });
286
286
  return registeredUser.data;
287
287
  }
288
+ async function isRegisteredOffchain(ethAddress, config) {
289
+ try {
290
+ const usersApi = new UsersApi(config.immutableXConfig.apiConfiguration);
291
+ const getUsersResult = await usersApi.getUsers({
292
+ user: ethAddress,
293
+ });
294
+ const { accounts } = getUsersResult.data;
295
+ return accounts?.length > 0;
296
+ }
297
+ catch (ex) {
298
+ if (ex instanceof AxiosError && ex.response?.status === 404) {
299
+ return false;
300
+ }
301
+ throw ex;
302
+ }
303
+ }
288
304
  async function isRegisteredOnChain(starkPublicKey, ethSigner, config) {
289
305
  await validateChain(ethSigner, config.immutableXConfig);
290
306
  const registrationContract = Contracts.Registration.connect(config.immutableXConfig.ethConfiguration.registrationContractAddress, ethSigner);
@@ -820,7 +836,11 @@ class GenericIMXProvider {
820
836
  this.signers = { ethSigner, starkSigner };
821
837
  }
822
838
  async getAddress() {
823
- return await this.signers.ethSigner.getAddress();
839
+ return this.signers.ethSigner.getAddress();
840
+ }
841
+ async isRegisteredOffchain() {
842
+ const ethAddress = await this.getAddress();
843
+ return isRegisteredOffchain(ethAddress, this.config);
824
844
  }
825
845
  registerOffchain() {
826
846
  return registerOffchain(this.signers, this.config);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@imtbl/sdk",
3
3
  "description": "Immutable Unified SDK",
4
- "version": "0.28.6-alpha",
4
+ "version": "0.28.7-alpha",
5
5
  "author": "Immutable",
6
6
  "browser": "./dist/index.browser.js",
7
7
  "bugs": "https://github.com/immutable/ts-immutable-sdk/issues",
@@ -17,7 +17,7 @@
17
17
  "@imtbl/core-sdk": "^2.4.0",
18
18
  "@imtbl/react-analytics": "0.2.1-alpha",
19
19
  "@jest/globals": "^29.5.0",
20
- "@magic-ext/oidc": "^1.0.1",
20
+ "@magic-ext/oidc": "^4.2.0",
21
21
  "@metamask/detect-provider": "^2.0.0",
22
22
  "@opensea/seaport-js": "2.0.7",
23
23
  "@uniswap/router-sdk": "^1.4.0",
@@ -32,7 +32,7 @@
32
32
  "ethers": "^5.7.2",
33
33
  "https-browserify": "^1.0.0",
34
34
  "jwt-decode": "^3.1.2",
35
- "magic-sdk": "^13.3.1",
35
+ "magic-sdk": "^21.2.0",
36
36
  "oidc-client-ts": "^2.2.1",
37
37
  "os-browserify": "^0.3.0",
38
38
  "pako": "^2.1.0",