@imtbl/sdk 0.28.6-alpha.1 → 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/blockchain_data.js +1 -1
- package/dist/browser/checkout/sdk.js +6 -6
- package/dist/browser/checkout/widgets.js +51 -51
- package/dist/checkout_sdk.d.ts +42 -21
- package/dist/checkout_sdk.js +75 -62
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +12 -12
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +163 -84
- package/dist/index.d.ts +46 -20
- package/dist/index.js +164 -85
- package/dist/passport.d.ts +7 -1
- package/dist/passport.js +67 -21
- package/dist/provider.d.ts +7 -0
- package/dist/provider.js +22 -2
- package/package.json +3 -3
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
|
|
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.
|
|
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": "^
|
|
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": "^
|
|
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",
|