@imtbl/sdk 0.28.5-alpha.3 → 0.28.6-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 +35 -0
- package/dist/browser/checkout/widgets.js +890 -0
- package/dist/checkout_sdk.d.ts +12688 -0
- package/dist/checkout_sdk.js +25850 -0
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +34 -8
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +23085 -1027
- package/dist/index.d.ts +3903 -68
- package/dist/index.js +23091 -1035
- package/dist/orderbook.d.ts +1600 -0
- package/dist/orderbook.js +1580 -0
- package/dist/passport.d.ts +1 -7
- package/dist/passport.js +21 -67
- package/dist/provider.d.ts +27 -32
- package/dist/provider.js +2 -22
- package/package.json +27 -4
package/dist/passport.d.ts
CHANGED
|
@@ -9732,12 +9732,6 @@ interface IMXProvider {
|
|
|
9732
9732
|
* @return {Promise<RegisterUserResponse>} Returns a promise that resolves with the user registration response
|
|
9733
9733
|
*/
|
|
9734
9734
|
registerOffchain(): Promise<RegisterUserResponse>;
|
|
9735
|
-
/**
|
|
9736
|
-
* Checks if a User is registered off-chain
|
|
9737
|
-
*
|
|
9738
|
-
* @return {Promise<boolean>} Returns a promise that resolves with true if the User is registered with IMX, false otherwise
|
|
9739
|
-
*/
|
|
9740
|
-
isRegisteredOffchain(): Promise<boolean>;
|
|
9741
9735
|
/**
|
|
9742
9736
|
* Checks if a User is registered on-chain
|
|
9743
9737
|
*
|
|
@@ -10190,7 +10184,7 @@ type UserProfile = {
|
|
|
10190
10184
|
};
|
|
10191
10185
|
declare enum Networks {
|
|
10192
10186
|
PRODUCTION = "mainnet",
|
|
10193
|
-
SANDBOX = "
|
|
10187
|
+
SANDBOX = "goerli"
|
|
10194
10188
|
}
|
|
10195
10189
|
interface OidcConfiguration {
|
|
10196
10190
|
clientId: string;
|
package/dist/passport.js
CHANGED
|
@@ -2072,7 +2072,7 @@ class MultiRollupApiClients {
|
|
|
2072
2072
|
}
|
|
2073
2073
|
|
|
2074
2074
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2075
|
-
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.28.
|
|
2075
|
+
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.28.6-alpha' };
|
|
2076
2076
|
const createConfig = ({ basePath, headers, }) => {
|
|
2077
2077
|
if (!basePath.trim()) {
|
|
2078
2078
|
throw Error('basePath can not be empty');
|
|
@@ -2128,7 +2128,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
2128
2128
|
chainID,
|
|
2129
2129
|
coreContractAddress,
|
|
2130
2130
|
registrationContractAddress,
|
|
2131
|
-
sdkVersion: 'ts-immutable-sdk-0.28.
|
|
2131
|
+
sdkVersion: 'ts-immutable-sdk-0.28.6-alpha',
|
|
2132
2132
|
});
|
|
2133
2133
|
/**
|
|
2134
2134
|
* Sets `sdkVersion` at the time of build
|
|
@@ -7056,63 +7056,39 @@ class AuthManager {
|
|
|
7056
7056
|
}
|
|
7057
7057
|
}
|
|
7058
7058
|
|
|
7059
|
-
const lazyLoad = (promiseToAwait, initialiseFunction) => (promiseToAwait().then(initialiseFunction));
|
|
7060
|
-
const lazyDocumentReady = (initialiseFunction) => {
|
|
7061
|
-
const documentReadyPromise = () => new Promise((resolve) => {
|
|
7062
|
-
if (window.document.readyState === 'complete') {
|
|
7063
|
-
resolve();
|
|
7064
|
-
}
|
|
7065
|
-
else {
|
|
7066
|
-
const onReadyStateChange = () => {
|
|
7067
|
-
if (window.document.readyState === 'complete') {
|
|
7068
|
-
resolve();
|
|
7069
|
-
window.document.removeEventListener('readystatechange', onReadyStateChange);
|
|
7070
|
-
}
|
|
7071
|
-
};
|
|
7072
|
-
window.document.addEventListener('readystatechange', onReadyStateChange);
|
|
7073
|
-
}
|
|
7074
|
-
});
|
|
7075
|
-
return lazyLoad(documentReadyPromise, initialiseFunction);
|
|
7076
|
-
};
|
|
7077
|
-
|
|
7078
7059
|
class MagicAdapter {
|
|
7079
7060
|
config;
|
|
7080
|
-
|
|
7061
|
+
magicClient;
|
|
7081
7062
|
constructor(config) {
|
|
7082
7063
|
this.config = config;
|
|
7083
7064
|
if (typeof window !== 'undefined') {
|
|
7084
|
-
this.
|
|
7085
|
-
|
|
7086
|
-
extensions: [new OpenIdExtension()],
|
|
7087
|
-
network: this.config.network,
|
|
7088
|
-
});
|
|
7089
|
-
client.preload();
|
|
7090
|
-
return client;
|
|
7091
|
-
});
|
|
7092
|
-
}
|
|
7093
|
-
}
|
|
7094
|
-
get magicClient() {
|
|
7095
|
-
if (!this.lazyMagicClient) {
|
|
7096
|
-
throw new Error('Cannot perform this action outside of the browser');
|
|
7065
|
+
this.magicClient = this.initMagicClient();
|
|
7066
|
+
this.magicClient.preload();
|
|
7097
7067
|
}
|
|
7098
|
-
return this.lazyMagicClient;
|
|
7099
7068
|
}
|
|
7100
7069
|
async login(idToken) {
|
|
7101
7070
|
return withPassportError(async () => {
|
|
7102
|
-
|
|
7103
|
-
|
|
7071
|
+
if (!this.magicClient) {
|
|
7072
|
+
this.magicClient = this.initMagicClient();
|
|
7073
|
+
}
|
|
7074
|
+
await this.magicClient.openid.loginWithOIDC({
|
|
7104
7075
|
jwt: idToken,
|
|
7105
7076
|
providerId: this.config.magicProviderId,
|
|
7106
7077
|
});
|
|
7107
|
-
return magicClient.rpcProvider;
|
|
7078
|
+
return this.magicClient.rpcProvider;
|
|
7108
7079
|
}, PassportErrorType.WALLET_CONNECTION_ERROR);
|
|
7109
7080
|
}
|
|
7110
7081
|
async logout() {
|
|
7111
|
-
|
|
7112
|
-
|
|
7113
|
-
await magicClient.user.logout();
|
|
7082
|
+
if (this.magicClient?.user) {
|
|
7083
|
+
await this.magicClient.user.logout();
|
|
7114
7084
|
}
|
|
7115
7085
|
}
|
|
7086
|
+
initMagicClient() {
|
|
7087
|
+
return new Magic(this.config.magicPublishableApiKey, {
|
|
7088
|
+
extensions: [new OpenIdExtension()],
|
|
7089
|
+
network: this.config.network,
|
|
7090
|
+
});
|
|
7091
|
+
}
|
|
7116
7092
|
}
|
|
7117
7093
|
|
|
7118
7094
|
const getStarkSigner = async (signer) => withPassportError(async () => {
|
|
@@ -7339,7 +7315,7 @@ var PassportEvents;
|
|
|
7339
7315
|
var Networks;
|
|
7340
7316
|
(function (Networks) {
|
|
7341
7317
|
Networks["PRODUCTION"] = "mainnet";
|
|
7342
|
-
Networks["SANDBOX"] = "
|
|
7318
|
+
Networks["SANDBOX"] = "goerli";
|
|
7343
7319
|
})(Networks || (Networks = {}));
|
|
7344
7320
|
|
|
7345
7321
|
async function exchangeTransfer({ user, starkSigner, request, exchangesApi, }) {
|
|
@@ -7688,11 +7664,6 @@ class PassportImxProvider {
|
|
|
7688
7664
|
}
|
|
7689
7665
|
// TODO: Remove once implemented
|
|
7690
7666
|
// eslint-disable-next-line class-methods-use-this
|
|
7691
|
-
isRegisteredOffchain() {
|
|
7692
|
-
throw new PassportError('Operation not supported', PassportErrorType.OPERATION_NOT_SUPPORTED_ERROR);
|
|
7693
|
-
}
|
|
7694
|
-
// TODO: Remove once implemented
|
|
7695
|
-
// eslint-disable-next-line class-methods-use-this
|
|
7696
7667
|
isRegisteredOnchain() {
|
|
7697
7668
|
throw new PassportError('Operation not supported', PassportErrorType.OPERATION_NOT_SUPPORTED_ERROR);
|
|
7698
7669
|
}
|
|
@@ -7786,17 +7757,7 @@ class PassportImxProviderFactory {
|
|
|
7786
7757
|
this.passportEventEmitter = passportEventEmitter;
|
|
7787
7758
|
}
|
|
7788
7759
|
async getProvider() {
|
|
7789
|
-
|
|
7790
|
-
try {
|
|
7791
|
-
user = await this.authManager.loginSilent();
|
|
7792
|
-
}
|
|
7793
|
-
catch (e) {
|
|
7794
|
-
// eslint-disable-next-line no-console
|
|
7795
|
-
console.warn(e);
|
|
7796
|
-
}
|
|
7797
|
-
if (!user) {
|
|
7798
|
-
user = await this.authManager.login();
|
|
7799
|
-
}
|
|
7760
|
+
const user = await this.authManager.loginSilent() || await this.authManager.login();
|
|
7800
7761
|
return this.createProviderInstance(user);
|
|
7801
7762
|
}
|
|
7802
7763
|
async getProviderSilent() {
|
|
@@ -8851,14 +8812,7 @@ class Passport {
|
|
|
8851
8812
|
*/
|
|
8852
8813
|
async login(options) {
|
|
8853
8814
|
const { useCachedSession = false } = options || {};
|
|
8854
|
-
let user =
|
|
8855
|
-
try {
|
|
8856
|
-
user = await this.authManager.loginSilent();
|
|
8857
|
-
}
|
|
8858
|
-
catch (error) {
|
|
8859
|
-
// eslint-disable-next-line no-console
|
|
8860
|
-
console.warn('loginSilent failed with error:', error);
|
|
8861
|
-
}
|
|
8815
|
+
let user = await this.authManager.loginSilent();
|
|
8862
8816
|
if (!user && !useCachedSession) {
|
|
8863
8817
|
user = await this.authManager.login();
|
|
8864
8818
|
}
|
package/dist/provider.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ProviderConfiguration as ProviderConfiguration$1 } from 'config';
|
|
2
|
+
|
|
1
3
|
declare type Bytes = ArrayLike<number>;
|
|
2
4
|
declare type BytesLike = Bytes | string;
|
|
3
5
|
interface Hexable {
|
|
@@ -831,12 +833,6 @@ interface IMXProvider {
|
|
|
831
833
|
* @return {Promise<RegisterUserResponse>} Returns a promise that resolves with the user registration response
|
|
832
834
|
*/
|
|
833
835
|
registerOffchain(): Promise<RegisterUserResponse>;
|
|
834
|
-
/**
|
|
835
|
-
* Checks if a User is registered off-chain
|
|
836
|
-
*
|
|
837
|
-
* @return {Promise<boolean>} Returns a promise that resolves with true if the User is registered with IMX, false otherwise
|
|
838
|
-
*/
|
|
839
|
-
isRegisteredOffchain(): Promise<boolean>;
|
|
840
836
|
/**
|
|
841
837
|
* Checks if a User is registered on-chain
|
|
842
838
|
*
|
|
@@ -909,6 +905,31 @@ interface IMXProvider {
|
|
|
909
905
|
completeWithdrawal(starkPublicKey: string, token: AnyToken): Promise<TransactionResponse>;
|
|
910
906
|
}
|
|
911
907
|
|
|
908
|
+
declare class GenericIMXProvider implements IMXProvider {
|
|
909
|
+
private readonly config;
|
|
910
|
+
private readonly signers;
|
|
911
|
+
constructor(config: ProviderConfiguration$1, ethSigner: Signer, starkSigner: StarkSigner);
|
|
912
|
+
getAddress(): Promise<string>;
|
|
913
|
+
registerOffchain(): Promise<RegisterUserResponse>;
|
|
914
|
+
batchNftTransfer(request: Array<NftTransferDetails>): Promise<CreateTransferResponse>;
|
|
915
|
+
cancelOrder(request: GetSignableCancelOrderRequest): Promise<CancelOrderResponse>;
|
|
916
|
+
completeWithdrawal(starkPublicKey: string, token: AnyToken): Promise<TransactionResponse>;
|
|
917
|
+
createOrder(request: UnsignedOrderRequest): Promise<CreateOrderResponse>;
|
|
918
|
+
createTrade(request: GetSignableTradeRequest): Promise<CreateTradeResponse>;
|
|
919
|
+
deposit(tokenAmount: TokenAmount): Promise<TransactionResponse>;
|
|
920
|
+
exchangeTransfer(request: UnsignedExchangeTransferRequest): Promise<CreateTransferResponseV1>;
|
|
921
|
+
isRegisteredOnchain(): Promise<boolean>;
|
|
922
|
+
prepareWithdrawal(request: TokenAmount): Promise<CreateWithdrawalResponse>;
|
|
923
|
+
transfer(request: UnsignedTransferRequest): Promise<CreateTransferResponseV1>;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
declare class MetaMaskIMXProvider extends GenericIMXProvider {
|
|
927
|
+
private static imxSigner;
|
|
928
|
+
static connect(config: ProviderConfiguration$1): Promise<MetaMaskIMXProvider>;
|
|
929
|
+
static disconnect(): Promise<void>;
|
|
930
|
+
static signMessage(message: string): Promise<string>;
|
|
931
|
+
}
|
|
932
|
+
|
|
912
933
|
declare enum Environment {
|
|
913
934
|
PRODUCTION = "production",
|
|
914
935
|
SANDBOX = "sandbox"
|
|
@@ -941,30 +962,4 @@ declare class ProviderConfiguration {
|
|
|
941
962
|
constructor({ baseConfig, overrides }: ProviderModuleConfiguration);
|
|
942
963
|
}
|
|
943
964
|
|
|
944
|
-
declare class GenericIMXProvider implements IMXProvider {
|
|
945
|
-
private readonly config;
|
|
946
|
-
private readonly signers;
|
|
947
|
-
constructor(config: ProviderConfiguration, ethSigner: Signer, starkSigner: StarkSigner);
|
|
948
|
-
getAddress(): Promise<string>;
|
|
949
|
-
isRegisteredOffchain(): Promise<boolean>;
|
|
950
|
-
registerOffchain(): Promise<RegisterUserResponse>;
|
|
951
|
-
batchNftTransfer(request: Array<NftTransferDetails>): Promise<CreateTransferResponse>;
|
|
952
|
-
cancelOrder(request: GetSignableCancelOrderRequest): Promise<CancelOrderResponse>;
|
|
953
|
-
completeWithdrawal(starkPublicKey: string, token: AnyToken): Promise<TransactionResponse>;
|
|
954
|
-
createOrder(request: UnsignedOrderRequest): Promise<CreateOrderResponse>;
|
|
955
|
-
createTrade(request: GetSignableTradeRequest): Promise<CreateTradeResponse>;
|
|
956
|
-
deposit(tokenAmount: TokenAmount): Promise<TransactionResponse>;
|
|
957
|
-
exchangeTransfer(request: UnsignedExchangeTransferRequest): Promise<CreateTransferResponseV1>;
|
|
958
|
-
isRegisteredOnchain(): Promise<boolean>;
|
|
959
|
-
prepareWithdrawal(request: TokenAmount): Promise<CreateWithdrawalResponse>;
|
|
960
|
-
transfer(request: UnsignedTransferRequest): Promise<CreateTransferResponseV1>;
|
|
961
|
-
}
|
|
962
|
-
|
|
963
|
-
declare class MetaMaskIMXProvider extends GenericIMXProvider {
|
|
964
|
-
private static imxSigner;
|
|
965
|
-
static connect(config: ProviderConfiguration): Promise<MetaMaskIMXProvider>;
|
|
966
|
-
static disconnect(): Promise<void>;
|
|
967
|
-
static signMessage(message: string): Promise<string>;
|
|
968
|
-
}
|
|
969
|
-
|
|
970
965
|
export { GenericIMXProvider, IMXProvider, MetaMaskIMXProvider, ProviderConfiguration };
|
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';
|
|
5
4
|
import { parseUnits } from '@ethersproject/units';
|
|
6
5
|
import { BigNumber } from '@ethersproject/bignumber';
|
|
7
6
|
import { ethers } from 'ethers';
|
|
8
7
|
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,22 +285,6 @@ 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
|
-
}
|
|
304
288
|
async function isRegisteredOnChain(starkPublicKey, ethSigner, config) {
|
|
305
289
|
await validateChain(ethSigner, config.immutableXConfig);
|
|
306
290
|
const registrationContract = Contracts.Registration.connect(config.immutableXConfig.ethConfiguration.registrationContractAddress, ethSigner);
|
|
@@ -836,11 +820,7 @@ class GenericIMXProvider {
|
|
|
836
820
|
this.signers = { ethSigner, starkSigner };
|
|
837
821
|
}
|
|
838
822
|
async getAddress() {
|
|
839
|
-
return this.signers.ethSigner.getAddress();
|
|
840
|
-
}
|
|
841
|
-
async isRegisteredOffchain() {
|
|
842
|
-
const ethAddress = await this.getAddress();
|
|
843
|
-
return isRegisteredOffchain(ethAddress, this.config);
|
|
823
|
+
return await this.signers.ethSigner.getAddress();
|
|
844
824
|
}
|
|
845
825
|
registerOffchain() {
|
|
846
826
|
return registerOffchain(this.signers, this.config);
|
package/package.json
CHANGED
|
@@ -1,32 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imtbl/sdk",
|
|
3
3
|
"description": "Immutable Unified SDK",
|
|
4
|
-
"version": "0.28.
|
|
4
|
+
"version": "0.28.6-alpha",
|
|
5
5
|
"author": "Immutable",
|
|
6
6
|
"browser": "./dist/index.browser.js",
|
|
7
7
|
"bugs": "https://github.com/immutable/ts-immutable-sdk/issues",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@0xsequence/abi": "^0.43.34",
|
|
10
10
|
"@0xsequence/config": "^0.43.34",
|
|
11
|
+
"@biom3/design-tokens": "0.2.4-beta",
|
|
12
|
+
"@biom3/react": "^0.10.12",
|
|
11
13
|
"@ethersproject/abi": "^5.7.0",
|
|
12
14
|
"@ethersproject/abstract-signer": "^5.7.0",
|
|
13
15
|
"@ethersproject/providers": "^5.7.2",
|
|
14
16
|
"@ethersproject/wallet": "^5.7.0",
|
|
15
17
|
"@imtbl/core-sdk": "^2.4.0",
|
|
18
|
+
"@imtbl/react-analytics": "0.2.1-alpha",
|
|
16
19
|
"@jest/globals": "^29.5.0",
|
|
17
|
-
"@magic-ext/oidc": "^
|
|
20
|
+
"@magic-ext/oidc": "^1.0.1",
|
|
18
21
|
"@metamask/detect-provider": "^2.0.0",
|
|
19
22
|
"@opensea/seaport-js": "2.0.7",
|
|
20
23
|
"@uniswap/router-sdk": "^1.4.0",
|
|
21
24
|
"@uniswap/sdk-core": "^3.0.1",
|
|
22
25
|
"@uniswap/v3-sdk": "^3.9.0",
|
|
26
|
+
"assert": "^2.0.0",
|
|
23
27
|
"axios": "^1.3.5",
|
|
24
28
|
"bn.js": "^5.2.1",
|
|
29
|
+
"buffer": "^6.0.3",
|
|
30
|
+
"crypto-browserify": "^3.12.0",
|
|
25
31
|
"enc-utils": "^3.0.0",
|
|
26
32
|
"ethers": "^5.7.2",
|
|
33
|
+
"https-browserify": "^1.0.0",
|
|
27
34
|
"jwt-decode": "^3.1.2",
|
|
28
|
-
"magic-sdk": "^
|
|
29
|
-
"oidc-client-ts": "^2.2.1"
|
|
35
|
+
"magic-sdk": "^13.3.1",
|
|
36
|
+
"oidc-client-ts": "^2.2.1",
|
|
37
|
+
"os-browserify": "^0.3.0",
|
|
38
|
+
"pako": "^2.1.0",
|
|
39
|
+
"react": "^18.2.0",
|
|
40
|
+
"react-dom": "^18.2.0",
|
|
41
|
+
"react-router-dom": "^6.11.0",
|
|
42
|
+
"stream-browserify": "^3.0.0",
|
|
43
|
+
"stream-http": "^3.2.0",
|
|
44
|
+
"url": "^0.11.0"
|
|
30
45
|
},
|
|
31
46
|
"devDependencies": {
|
|
32
47
|
"@imtbl/blockchain-data": "0.0.0",
|
|
@@ -83,9 +98,17 @@
|
|
|
83
98
|
"types": "./dist/passport.d.ts",
|
|
84
99
|
"import": "./dist/passport.js"
|
|
85
100
|
},
|
|
101
|
+
"./orderbook": {
|
|
102
|
+
"types": "./dist/orderbook.d.ts",
|
|
103
|
+
"import": "./dist/orderbook.js"
|
|
104
|
+
},
|
|
86
105
|
"./provider": {
|
|
87
106
|
"types": "./dist/provider.d.ts",
|
|
88
107
|
"import": "./dist/provider.js"
|
|
108
|
+
},
|
|
109
|
+
"./checkout_sdk": {
|
|
110
|
+
"types": "./dist/checkout_sdk.d.ts",
|
|
111
|
+
"import": "./dist/checkout_sdk.js"
|
|
89
112
|
}
|
|
90
113
|
},
|
|
91
114
|
"files": [
|