@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/index.cjs
CHANGED
|
@@ -3649,7 +3649,7 @@ class MultiRollupApiClients {
|
|
|
3649
3649
|
}
|
|
3650
3650
|
|
|
3651
3651
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
3652
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.28.
|
|
3652
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.28.7-alpha' };
|
|
3653
3653
|
const createConfig = ({ basePath, headers, }) => {
|
|
3654
3654
|
if (!basePath.trim()) {
|
|
3655
3655
|
throw Error('basePath can not be empty');
|
|
@@ -3709,7 +3709,7 @@ class APIError extends Error {
|
|
|
3709
3709
|
|
|
3710
3710
|
/* eslint-disable implicit-arrow-linebreak */
|
|
3711
3711
|
const defaultHeaders = {
|
|
3712
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.28.
|
|
3712
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.28.7-alpha',
|
|
3713
3713
|
};
|
|
3714
3714
|
/**
|
|
3715
3715
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -4120,7 +4120,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
4120
4120
|
chainID,
|
|
4121
4121
|
coreContractAddress,
|
|
4122
4122
|
registrationContractAddress,
|
|
4123
|
-
sdkVersion: 'ts-immutable-sdk-0.28.
|
|
4123
|
+
sdkVersion: 'ts-immutable-sdk-0.28.7-alpha',
|
|
4124
4124
|
});
|
|
4125
4125
|
/**
|
|
4126
4126
|
* Sets `sdkVersion` at the time of build
|
|
@@ -9065,39 +9065,63 @@ class AuthManager {
|
|
|
9065
9065
|
}
|
|
9066
9066
|
}
|
|
9067
9067
|
|
|
9068
|
+
const lazyLoad = (promiseToAwait, initialiseFunction) => (promiseToAwait().then(initialiseFunction));
|
|
9069
|
+
const lazyDocumentReady = (initialiseFunction) => {
|
|
9070
|
+
const documentReadyPromise = () => new Promise((resolve) => {
|
|
9071
|
+
if (window.document.readyState === 'complete') {
|
|
9072
|
+
resolve();
|
|
9073
|
+
}
|
|
9074
|
+
else {
|
|
9075
|
+
const onReadyStateChange = () => {
|
|
9076
|
+
if (window.document.readyState === 'complete') {
|
|
9077
|
+
resolve();
|
|
9078
|
+
window.document.removeEventListener('readystatechange', onReadyStateChange);
|
|
9079
|
+
}
|
|
9080
|
+
};
|
|
9081
|
+
window.document.addEventListener('readystatechange', onReadyStateChange);
|
|
9082
|
+
}
|
|
9083
|
+
});
|
|
9084
|
+
return lazyLoad(documentReadyPromise, initialiseFunction);
|
|
9085
|
+
};
|
|
9086
|
+
|
|
9068
9087
|
class MagicAdapter {
|
|
9069
9088
|
config;
|
|
9070
|
-
|
|
9089
|
+
lazyMagicClient;
|
|
9071
9090
|
constructor(config) {
|
|
9072
9091
|
this.config = config;
|
|
9073
9092
|
if (typeof window !== 'undefined') {
|
|
9074
|
-
this.
|
|
9075
|
-
|
|
9093
|
+
this.lazyMagicClient = lazyDocumentReady(() => {
|
|
9094
|
+
const client = new magicSdk.Magic(this.config.magicPublishableApiKey, {
|
|
9095
|
+
extensions: [new oidc.OpenIdExtension()],
|
|
9096
|
+
network: this.config.network,
|
|
9097
|
+
});
|
|
9098
|
+
client.preload();
|
|
9099
|
+
return client;
|
|
9100
|
+
});
|
|
9101
|
+
}
|
|
9102
|
+
}
|
|
9103
|
+
get magicClient() {
|
|
9104
|
+
if (!this.lazyMagicClient) {
|
|
9105
|
+
throw new Error('Cannot perform this action outside of the browser');
|
|
9076
9106
|
}
|
|
9107
|
+
return this.lazyMagicClient;
|
|
9077
9108
|
}
|
|
9078
9109
|
async login(idToken) {
|
|
9079
9110
|
return withPassportError(async () => {
|
|
9080
|
-
|
|
9081
|
-
|
|
9082
|
-
}
|
|
9083
|
-
await this.magicClient.openid.loginWithOIDC({
|
|
9111
|
+
const magicClient = await this.magicClient;
|
|
9112
|
+
await magicClient.openid.loginWithOIDC({
|
|
9084
9113
|
jwt: idToken,
|
|
9085
9114
|
providerId: this.config.magicProviderId,
|
|
9086
9115
|
});
|
|
9087
|
-
return
|
|
9116
|
+
return magicClient.rpcProvider;
|
|
9088
9117
|
}, PassportErrorType.WALLET_CONNECTION_ERROR);
|
|
9089
9118
|
}
|
|
9090
9119
|
async logout() {
|
|
9091
|
-
|
|
9092
|
-
|
|
9120
|
+
const magicClient = await this.magicClient;
|
|
9121
|
+
if (magicClient.user) {
|
|
9122
|
+
await magicClient.user.logout();
|
|
9093
9123
|
}
|
|
9094
9124
|
}
|
|
9095
|
-
initMagicClient() {
|
|
9096
|
-
return new magicSdk.Magic(this.config.magicPublishableApiKey, {
|
|
9097
|
-
extensions: [new oidc.OpenIdExtension()],
|
|
9098
|
-
network: this.config.network,
|
|
9099
|
-
});
|
|
9100
|
-
}
|
|
9101
9125
|
}
|
|
9102
9126
|
|
|
9103
9127
|
const getStarkSigner = async (signer) => withPassportError(async () => {
|
|
@@ -9324,7 +9348,7 @@ var PassportEvents;
|
|
|
9324
9348
|
var Networks;
|
|
9325
9349
|
(function (Networks) {
|
|
9326
9350
|
Networks["PRODUCTION"] = "mainnet";
|
|
9327
|
-
Networks["SANDBOX"] = "
|
|
9351
|
+
Networks["SANDBOX"] = "sepolia";
|
|
9328
9352
|
})(Networks || (Networks = {}));
|
|
9329
9353
|
|
|
9330
9354
|
async function exchangeTransfer$1({ user, starkSigner, request, exchangesApi, }) {
|
|
@@ -9673,6 +9697,11 @@ class PassportImxProvider {
|
|
|
9673
9697
|
}
|
|
9674
9698
|
// TODO: Remove once implemented
|
|
9675
9699
|
// eslint-disable-next-line class-methods-use-this
|
|
9700
|
+
isRegisteredOffchain() {
|
|
9701
|
+
throw new PassportError('Operation not supported', PassportErrorType.OPERATION_NOT_SUPPORTED_ERROR);
|
|
9702
|
+
}
|
|
9703
|
+
// TODO: Remove once implemented
|
|
9704
|
+
// eslint-disable-next-line class-methods-use-this
|
|
9676
9705
|
isRegisteredOnchain() {
|
|
9677
9706
|
throw new PassportError('Operation not supported', PassportErrorType.OPERATION_NOT_SUPPORTED_ERROR);
|
|
9678
9707
|
}
|
|
@@ -9766,7 +9795,17 @@ class PassportImxProviderFactory {
|
|
|
9766
9795
|
this.passportEventEmitter = passportEventEmitter;
|
|
9767
9796
|
}
|
|
9768
9797
|
async getProvider() {
|
|
9769
|
-
|
|
9798
|
+
let user = null;
|
|
9799
|
+
try {
|
|
9800
|
+
user = await this.authManager.loginSilent();
|
|
9801
|
+
}
|
|
9802
|
+
catch (e) {
|
|
9803
|
+
// eslint-disable-next-line no-console
|
|
9804
|
+
console.warn(e);
|
|
9805
|
+
}
|
|
9806
|
+
if (!user) {
|
|
9807
|
+
user = await this.authManager.login();
|
|
9808
|
+
}
|
|
9770
9809
|
return this.createProviderInstance(user);
|
|
9771
9810
|
}
|
|
9772
9811
|
async getProviderSilent() {
|
|
@@ -10821,7 +10860,14 @@ class Passport {
|
|
|
10821
10860
|
*/
|
|
10822
10861
|
async login(options) {
|
|
10823
10862
|
const { useCachedSession = false } = options || {};
|
|
10824
|
-
let user =
|
|
10863
|
+
let user = null;
|
|
10864
|
+
try {
|
|
10865
|
+
user = await this.authManager.loginSilent();
|
|
10866
|
+
}
|
|
10867
|
+
catch (error) {
|
|
10868
|
+
// eslint-disable-next-line no-console
|
|
10869
|
+
console.warn('loginSilent failed with error:', error);
|
|
10870
|
+
}
|
|
10825
10871
|
if (!user && !useCachedSession) {
|
|
10826
10872
|
user = await this.authManager.login();
|
|
10827
10873
|
}
|
|
@@ -12669,6 +12715,22 @@ async function registerOffchain(signers, config) {
|
|
|
12669
12715
|
});
|
|
12670
12716
|
return registeredUser.data;
|
|
12671
12717
|
}
|
|
12718
|
+
async function isRegisteredOffchain(ethAddress, config) {
|
|
12719
|
+
try {
|
|
12720
|
+
const usersApi = new coreSdk.UsersApi(config.immutableXConfig.apiConfiguration);
|
|
12721
|
+
const getUsersResult = await usersApi.getUsers({
|
|
12722
|
+
user: ethAddress,
|
|
12723
|
+
});
|
|
12724
|
+
const { accounts } = getUsersResult.data;
|
|
12725
|
+
return accounts?.length > 0;
|
|
12726
|
+
}
|
|
12727
|
+
catch (ex) {
|
|
12728
|
+
if (ex instanceof globalAxios$1.AxiosError && ex.response?.status === 404) {
|
|
12729
|
+
return false;
|
|
12730
|
+
}
|
|
12731
|
+
throw ex;
|
|
12732
|
+
}
|
|
12733
|
+
}
|
|
12672
12734
|
async function isRegisteredOnChain(starkPublicKey, ethSigner, config) {
|
|
12673
12735
|
await validateChain(ethSigner, config.immutableXConfig);
|
|
12674
12736
|
const registrationContract = coreSdk.Contracts.Registration.connect(config.immutableXConfig.ethConfiguration.registrationContractAddress, ethSigner);
|
|
@@ -13204,7 +13266,11 @@ class GenericIMXProvider {
|
|
|
13204
13266
|
this.signers = { ethSigner, starkSigner };
|
|
13205
13267
|
}
|
|
13206
13268
|
async getAddress() {
|
|
13207
|
-
return
|
|
13269
|
+
return this.signers.ethSigner.getAddress();
|
|
13270
|
+
}
|
|
13271
|
+
async isRegisteredOffchain() {
|
|
13272
|
+
const ethAddress = await this.getAddress();
|
|
13273
|
+
return isRegisteredOffchain(ethAddress, this.config);
|
|
13208
13274
|
}
|
|
13209
13275
|
registerOffchain() {
|
|
13210
13276
|
return registerOffchain(this.signers, this.config);
|
|
@@ -29424,6 +29490,7 @@ var SaleEventType;
|
|
|
29424
29490
|
SaleEventType["SUCCESS"] = "success";
|
|
29425
29491
|
SaleEventType["FAILURE"] = "failure";
|
|
29426
29492
|
SaleEventType["REJECTED"] = "rejected";
|
|
29493
|
+
SaleEventType["TRANSACTION_SUCCESS"] = "transaction-success";
|
|
29427
29494
|
})(SaleEventType || (SaleEventType = {}));
|
|
29428
29495
|
|
|
29429
29496
|
/**
|
|
@@ -30592,6 +30659,9 @@ async function getERC20Balance(web3Provider, walletAddress, contractAddress) {
|
|
|
30592
30659
|
}
|
|
30593
30660
|
// Blockscout client singleton per chain id
|
|
30594
30661
|
const blockscoutClientMap = new Map();
|
|
30662
|
+
// This function is a utility function that can be used to reset the
|
|
30663
|
+
// blockscout map and therefore clear all the cache.
|
|
30664
|
+
const resetBlockscoutClientMap = () => blockscoutClientMap.clear();
|
|
30595
30665
|
const getIndexerBalance = async (walletAddress, chainId, filterTokens) => {
|
|
30596
30666
|
// Shuffle the mapping of the tokens configuration so it is a hashmap
|
|
30597
30667
|
// for faster access to tokens config objects.
|
|
@@ -30692,6 +30762,8 @@ const getBalances = async (config, web3Provider, walletAddress, tokens) => {
|
|
|
30692
30762
|
return { balances };
|
|
30693
30763
|
};
|
|
30694
30764
|
const getAllBalances = async (config, web3Provider, walletAddress, chainId) => {
|
|
30765
|
+
// eslint-disable-next-line no-param-reassign
|
|
30766
|
+
chainId ||= await web3Provider.getSigner().getChainId();
|
|
30695
30767
|
const { tokens } = await getTokenAllowList(config, {
|
|
30696
30768
|
type: TokenFilterTypes.ALL,
|
|
30697
30769
|
chainId,
|
|
@@ -30714,7 +30786,7 @@ const getAllBalances = async (config, web3Provider, walletAddress, chainId) => {
|
|
|
30714
30786
|
// Please remove this hack once https://immutable.atlassian.net/browse/WT-1710
|
|
30715
30787
|
// is done.
|
|
30716
30788
|
const isL1Chain = getL1ChainId(config) === chainId;
|
|
30717
|
-
return measureAsyncExecution(config, `Time to fetch balances using blockscout for ${chainId}`, getIndexerBalance(walletAddress, chainId, isL1Chain ? tokens : []));
|
|
30789
|
+
return await measureAsyncExecution(config, `Time to fetch balances using blockscout for ${chainId}`, getIndexerBalance(walletAddress, chainId, isL1Chain ? tokens : []));
|
|
30718
30790
|
}
|
|
30719
30791
|
// This fallback to use ERC20s calls which is a best effort solution
|
|
30720
30792
|
// Fails in fetching data from the RCP calls might result in some
|
|
@@ -31588,18 +31660,15 @@ const getTokenBalanceRequirement = (itemRequirement, balances) => {
|
|
|
31588
31660
|
* Gets the balances for all NATIVE and ERC20 balance requirements.
|
|
31589
31661
|
*/
|
|
31590
31662
|
const getTokenBalances = async (config, provider, ownerAddress, itemRequirements) => {
|
|
31591
|
-
let tokenBalances = [];
|
|
31592
31663
|
try {
|
|
31593
|
-
const
|
|
31594
|
-
|
|
31595
|
-
|
|
31596
|
-
|
|
31597
|
-
];
|
|
31664
|
+
const tokenMap = new Map();
|
|
31665
|
+
getTokensFromRequirements(itemRequirements).forEach((item) => tokenMap.set((item.address || '').toLocaleLowerCase(), item));
|
|
31666
|
+
const { balances } = await getAllBalances(config, provider, ownerAddress);
|
|
31667
|
+
return balances.filter((balance) => tokenMap.get((balance.token.address || '').toLocaleLowerCase()));
|
|
31598
31668
|
}
|
|
31599
31669
|
catch (error) {
|
|
31600
31670
|
throw new CheckoutError('Failed to get balances', CheckoutErrorType.GET_BALANCE_ERROR);
|
|
31601
31671
|
}
|
|
31602
|
-
return tokenBalances;
|
|
31603
31672
|
};
|
|
31604
31673
|
/**
|
|
31605
31674
|
* Gets the balances for all ERC721 balance requirements.
|
|
@@ -31646,53 +31715,56 @@ const getERC721Balances = async (provider, ownerAddress, itemRequirements) => {
|
|
|
31646
31715
|
*/
|
|
31647
31716
|
const balanceCheck = async (config, provider, ownerAddress, itemRequirements) => {
|
|
31648
31717
|
const aggregatedItems = balanceAggregator(itemRequirements);
|
|
31649
|
-
|
|
31650
|
-
|
|
31651
|
-
|
|
31652
|
-
|
|
31653
|
-
|
|
31718
|
+
const requiredToken = [];
|
|
31719
|
+
const requiredERC721 = [];
|
|
31720
|
+
aggregatedItems.forEach((item) => {
|
|
31721
|
+
switch (item.type) {
|
|
31722
|
+
case ItemType.ERC20:
|
|
31723
|
+
case ItemType.NATIVE:
|
|
31724
|
+
requiredToken.push(item);
|
|
31725
|
+
break;
|
|
31726
|
+
case ItemType.ERC721:
|
|
31727
|
+
requiredERC721.push(item);
|
|
31728
|
+
break;
|
|
31729
|
+
}
|
|
31730
|
+
});
|
|
31731
|
+
if (requiredERC721.length === 0 && requiredToken.length === 0) {
|
|
31654
31732
|
throw new CheckoutError('Unsupported item requirement balance check', CheckoutErrorType.UNSUPPORTED_BALANCE_REQUIREMENT_ERROR);
|
|
31655
31733
|
}
|
|
31656
31734
|
// Get all ERC20 and NATIVE balances
|
|
31657
|
-
const
|
|
31658
|
-
|
|
31659
|
-
.
|
|
31660
|
-
if (tokenItemRequirements.length > 0) {
|
|
31661
|
-
currentBalances.push(getTokenBalances(config, provider, ownerAddress, aggregatedItems));
|
|
31735
|
+
const balancePromises = [];
|
|
31736
|
+
if (requiredToken.length > 0) {
|
|
31737
|
+
balancePromises.push(getTokenBalances(config, provider, ownerAddress, aggregatedItems));
|
|
31662
31738
|
}
|
|
31663
31739
|
// Get all ERC721 balances
|
|
31664
|
-
|
|
31665
|
-
.
|
|
31666
|
-
if (erc721ItemRequirements.length > 0) {
|
|
31667
|
-
currentBalances.push(getERC721Balances(provider, ownerAddress, aggregatedItems));
|
|
31740
|
+
if (requiredERC721.length > 0) {
|
|
31741
|
+
balancePromises.push(getERC721Balances(provider, ownerAddress, aggregatedItems));
|
|
31668
31742
|
}
|
|
31669
31743
|
// Wait for all balances and calculate the requirements
|
|
31670
|
-
const
|
|
31671
|
-
|
|
31672
|
-
|
|
31673
|
-
|
|
31674
|
-
|
|
31675
|
-
|
|
31744
|
+
const promisesResponses = await Promise.all(balancePromises);
|
|
31745
|
+
const balanceRequirements = [];
|
|
31746
|
+
// Get all ERC20 and NATIVE balances
|
|
31747
|
+
if (requiredToken.length > 0 && promisesResponses.length > 0) {
|
|
31748
|
+
const result = promisesResponses.shift();
|
|
31749
|
+
if (result) {
|
|
31750
|
+
requiredToken.forEach((item) => {
|
|
31751
|
+
balanceRequirements.push(getTokenBalanceRequirement(item, result));
|
|
31676
31752
|
});
|
|
31677
|
-
if (erc721ItemRequirements.length > 0) {
|
|
31678
|
-
const erc721Balances = balances[1];
|
|
31679
|
-
erc721ItemRequirements.forEach((erc721ItemRequirement) => {
|
|
31680
|
-
requirements.push(getERC721BalanceRequirement(erc721ItemRequirement, erc721Balances));
|
|
31681
|
-
});
|
|
31682
|
-
}
|
|
31683
31753
|
}
|
|
31684
|
-
|
|
31685
|
-
|
|
31686
|
-
|
|
31687
|
-
|
|
31688
|
-
|
|
31754
|
+
}
|
|
31755
|
+
// Get all ERC721 balances
|
|
31756
|
+
if (requiredERC721.length > 0 && promisesResponses.length > 0) {
|
|
31757
|
+
const result = promisesResponses.shift();
|
|
31758
|
+
if (result) {
|
|
31759
|
+
requiredERC721.forEach((item) => {
|
|
31760
|
+
balanceRequirements.push(getERC721BalanceRequirement(item, result));
|
|
31689
31761
|
});
|
|
31690
31762
|
}
|
|
31691
|
-
|
|
31692
|
-
|
|
31693
|
-
|
|
31694
|
-
|
|
31695
|
-
|
|
31763
|
+
}
|
|
31764
|
+
// Find if there are any requirements that aren't sufficient.
|
|
31765
|
+
// If there is not item with sufficient === false then the requirements
|
|
31766
|
+
// are satisfied.
|
|
31767
|
+
const sufficient = balanceRequirements.find((req) => req.sufficient === false) === undefined;
|
|
31696
31768
|
return {
|
|
31697
31769
|
sufficient,
|
|
31698
31770
|
balanceRequirements,
|
|
@@ -32295,8 +32367,12 @@ const getBridgeFeeEstimate = async (config, readOnlyProviders) => {
|
|
|
32295
32367
|
// If the root address evaluates to this then its ETH
|
|
32296
32368
|
const INDEXER_ETH_ROOT_CONTRACT_ADDRESS = '0x0000000000000000000000000000000000000001';
|
|
32297
32369
|
const getIndexerChainName = (chainId) => {
|
|
32370
|
+
if (chainId === ChainId.IMTBL_ZKEVM_MAINNET)
|
|
32371
|
+
return 'imtbl-zkevm-mainnet';
|
|
32298
32372
|
if (chainId === ChainId.IMTBL_ZKEVM_TESTNET)
|
|
32299
32373
|
return 'imtbl-zkevm-testnet';
|
|
32374
|
+
if (chainId === ChainId.IMTBL_ZKEVM_DEVNET)
|
|
32375
|
+
return 'imtbl-zkevm-devent';
|
|
32300
32376
|
return '';
|
|
32301
32377
|
};
|
|
32302
32378
|
// Indexer ERC20 call does not support IMX so cannot get root chain mapping from this endpoint.
|
|
@@ -33295,18 +33371,26 @@ const getTransactionOrGas = (gasLimit, fulfillmentTransactions) => {
|
|
|
33295
33371
|
};
|
|
33296
33372
|
};
|
|
33297
33373
|
const buy = async (config, provider, orders) => {
|
|
33298
|
-
let orderbook;
|
|
33299
|
-
let order;
|
|
33300
|
-
let spenderAddress = '';
|
|
33301
|
-
const gasLimit = constants.estimatedFulfillmentGasGwei;
|
|
33302
33374
|
if (orders.length === 0) {
|
|
33303
33375
|
throw new CheckoutError('No orders were provided to the orders array. Please provide at least one order.', CheckoutErrorType.FULFILL_ORDER_LISTING_ERROR);
|
|
33304
33376
|
}
|
|
33377
|
+
let order;
|
|
33378
|
+
let spenderAddress = '';
|
|
33379
|
+
let decimals = 18;
|
|
33380
|
+
const gasLimit = constants.estimatedFulfillmentGasGwei;
|
|
33381
|
+
const orderbook = createOrderbookInstance(config);
|
|
33382
|
+
const blockchainClient = createBlockchainDataInstance(config);
|
|
33383
|
+
const fulfillerAddress = await measureAsyncExecution(config, 'Time to get the address from the provider', provider.getSigner().getAddress());
|
|
33384
|
+
// Prefetch balances and store them in memory
|
|
33385
|
+
resetBlockscoutClientMap();
|
|
33386
|
+
getAllBalances(config, provider, fulfillerAddress, getL1ChainId(config));
|
|
33387
|
+
getAllBalances(config, provider, fulfillerAddress, getL2ChainId(config));
|
|
33305
33388
|
const { id, takerFees } = orders[0];
|
|
33389
|
+
let orderChainName;
|
|
33306
33390
|
try {
|
|
33307
|
-
orderbook = createOrderbookInstance(config);
|
|
33308
33391
|
order = await measureAsyncExecution(config, 'Time to fetch the listing from the orderbook', orderbook.getListing(id));
|
|
33309
|
-
const { seaportContractAddress } = orderbook.config();
|
|
33392
|
+
const { seaportContractAddress, chainName } = orderbook.config();
|
|
33393
|
+
orderChainName = chainName;
|
|
33310
33394
|
spenderAddress = seaportContractAddress;
|
|
33311
33395
|
}
|
|
33312
33396
|
catch (err) {
|
|
@@ -33322,10 +33406,10 @@ const buy = async (config, provider, orders) => {
|
|
|
33322
33406
|
});
|
|
33323
33407
|
}
|
|
33324
33408
|
const buyToken = order.result.buy[0];
|
|
33325
|
-
|
|
33326
|
-
|
|
33327
|
-
|
|
33328
|
-
|
|
33409
|
+
if (buyToken.type === 'ERC20') {
|
|
33410
|
+
const token = await measureAsyncExecution(config, 'Time to get decimals of token contract for the buy token', blockchainClient.getToken({ contractAddress: buyToken.contractAddress, chainName: orderChainName }));
|
|
33411
|
+
if (token.result.decimals)
|
|
33412
|
+
decimals = token.result.decimals;
|
|
33329
33413
|
}
|
|
33330
33414
|
let fees = [];
|
|
33331
33415
|
if (takerFees && takerFees.length > 0) {
|
|
@@ -33336,7 +33420,6 @@ const buy = async (config, provider, orders) => {
|
|
|
33336
33420
|
let orderActions = [];
|
|
33337
33421
|
const fulfillOrderStartTime = performance.now();
|
|
33338
33422
|
try {
|
|
33339
|
-
const fulfillerAddress = await measureAsyncExecution(config, 'Time to get the address from the provider', provider.getSigner().getAddress());
|
|
33340
33423
|
const { actions } = await measureAsyncExecution(config, 'Time to call fulfillOrder from the orderbook', orderbook.fulfillOrder(id, fulfillerAddress, fees));
|
|
33341
33424
|
orderActions = actions;
|
|
33342
33425
|
unsignedApprovalTransactions = await measureAsyncExecution(config, 'Time to construct the unsigned approval transactions', getUnsignedERC20ApprovalTransactions(actions));
|
|
@@ -33674,7 +33757,7 @@ async function getItemRequirementsFromRequirements(provider, requirements) {
|
|
|
33674
33757
|
return itemRequirements;
|
|
33675
33758
|
}
|
|
33676
33759
|
|
|
33677
|
-
const SDK_VERSION_MARKER = '0.28.
|
|
33760
|
+
const SDK_VERSION_MARKER = '0.28.7-alpha';
|
|
33678
33761
|
// This SDK version is replaced by the `yarn build` command ran on the root level
|
|
33679
33762
|
const globalPackageVersion = () => SDK_VERSION_MARKER;
|
|
33680
33763
|
|
|
@@ -33835,11 +33918,7 @@ class Checkout {
|
|
|
33835
33918
|
async connect(params) {
|
|
33836
33919
|
const web3Provider = await validateProvider(this.config, params.provider, { allowUnsupportedProvider: true });
|
|
33837
33920
|
await connectSite(web3Provider);
|
|
33838
|
-
|
|
33839
|
-
return {
|
|
33840
|
-
provider: web3Provider,
|
|
33841
|
-
network: networkInfo,
|
|
33842
|
-
};
|
|
33921
|
+
return { provider: web3Provider };
|
|
33843
33922
|
}
|
|
33844
33923
|
/**
|
|
33845
33924
|
* Switches the network for the current wallet provider.
|
package/dist/index.d.ts
CHANGED
|
@@ -14421,6 +14421,12 @@ interface IMXProvider {
|
|
|
14421
14421
|
* @return {Promise<RegisterUserResponse>} Returns a promise that resolves with the user registration response
|
|
14422
14422
|
*/
|
|
14423
14423
|
registerOffchain(): Promise<RegisterUserResponse>;
|
|
14424
|
+
/**
|
|
14425
|
+
* Checks if a User is registered off-chain
|
|
14426
|
+
*
|
|
14427
|
+
* @return {Promise<boolean>} Returns a promise that resolves with true if the User is registered with IMX, false otherwise
|
|
14428
|
+
*/
|
|
14429
|
+
isRegisteredOffchain(): Promise<boolean>;
|
|
14424
14430
|
/**
|
|
14425
14431
|
* Checks if a User is registered on-chain
|
|
14426
14432
|
*
|
|
@@ -14498,6 +14504,7 @@ declare class GenericIMXProvider implements IMXProvider {
|
|
|
14498
14504
|
private readonly signers;
|
|
14499
14505
|
constructor(config: ProviderConfiguration$1, ethSigner: Signer, starkSigner: StarkSigner);
|
|
14500
14506
|
getAddress(): Promise<string>;
|
|
14507
|
+
isRegisteredOffchain(): Promise<boolean>;
|
|
14501
14508
|
registerOffchain(): Promise<RegisterUserResponse>;
|
|
14502
14509
|
batchNftTransfer(request: Array<NftTransferDetails>): Promise<CreateTransferResponse>;
|
|
14503
14510
|
cancelOrder(request: GetSignableCancelOrderRequest): Promise<CancelOrderResponse>;
|
|
@@ -14536,7 +14543,7 @@ type UserProfile = {
|
|
|
14536
14543
|
};
|
|
14537
14544
|
declare enum Networks {
|
|
14538
14545
|
PRODUCTION = "mainnet",
|
|
14539
|
-
SANDBOX = "
|
|
14546
|
+
SANDBOX = "sepolia"
|
|
14540
14547
|
}
|
|
14541
14548
|
interface OidcConfiguration {
|
|
14542
14549
|
clientId: string;
|
|
@@ -16717,21 +16724,6 @@ type ChainTokensConfig = {
|
|
|
16717
16724
|
blockscout?: boolean;
|
|
16718
16725
|
};
|
|
16719
16726
|
|
|
16720
|
-
/**
|
|
16721
|
-
* Represents information about a network.
|
|
16722
|
-
* @interface NetworkInfo
|
|
16723
|
-
* @property {string} name - The name of the network.
|
|
16724
|
-
* @property {number} chainId - The chain ID of the network.
|
|
16725
|
-
* @property {TokenInfo} nativeCurrency - Information about the native currency of the network.
|
|
16726
|
-
* @property {boolean} isSupported - Indicates whether the network is supported.
|
|
16727
|
-
*/
|
|
16728
|
-
interface NetworkInfo {
|
|
16729
|
-
name: string;
|
|
16730
|
-
chainId: number;
|
|
16731
|
-
nativeCurrency: TokenInfo;
|
|
16732
|
-
isSupported: boolean;
|
|
16733
|
-
}
|
|
16734
|
-
|
|
16735
16727
|
/**
|
|
16736
16728
|
* Interface representing the params of {@link Checkout.connect}.
|
|
16737
16729
|
* @property {Web3Provider} provider - The provider used to connect to the network.
|
|
@@ -16742,11 +16734,9 @@ interface ConnectParams {
|
|
|
16742
16734
|
/**
|
|
16743
16735
|
* Interface representing the result of {@link Checkout.connect}.
|
|
16744
16736
|
* @property {Web3Provider} provider - The provider used to connect to the network.
|
|
16745
|
-
* @property {NetworkInfo} network - Information about the connected network.
|
|
16746
16737
|
*/
|
|
16747
16738
|
interface ConnectResult {
|
|
16748
16739
|
provider: Web3Provider;
|
|
16749
|
-
network: NetworkInfo;
|
|
16750
16740
|
}
|
|
16751
16741
|
/**
|
|
16752
16742
|
* Interface representing the params of {@link Checkout.checkIsWalletConnected}.
|
|
@@ -16838,6 +16828,21 @@ interface TokenAmountEstimate {
|
|
|
16838
16828
|
token?: TokenInfo;
|
|
16839
16829
|
}
|
|
16840
16830
|
|
|
16831
|
+
/**
|
|
16832
|
+
* Represents information about a network.
|
|
16833
|
+
* @interface NetworkInfo
|
|
16834
|
+
* @property {string} name - The name of the network.
|
|
16835
|
+
* @property {number} chainId - The chain ID of the network.
|
|
16836
|
+
* @property {TokenInfo} nativeCurrency - Information about the native currency of the network.
|
|
16837
|
+
* @property {boolean} isSupported - Indicates whether the network is supported.
|
|
16838
|
+
*/
|
|
16839
|
+
interface NetworkInfo {
|
|
16840
|
+
name: string;
|
|
16841
|
+
chainId: number;
|
|
16842
|
+
nativeCurrency: TokenInfo;
|
|
16843
|
+
isSupported: boolean;
|
|
16844
|
+
}
|
|
16845
|
+
|
|
16841
16846
|
/**
|
|
16842
16847
|
* Interface representing the parameters for {@link Checkout.switchNetwork}.
|
|
16843
16848
|
* @property {Web3Provider} provider - The provider to connect to the network.
|
|
@@ -17253,11 +17258,12 @@ declare enum SaleEventType {
|
|
|
17253
17258
|
CLOSE_WIDGET = "close-widget",
|
|
17254
17259
|
SUCCESS = "success",
|
|
17255
17260
|
FAILURE = "failure",
|
|
17256
|
-
REJECTED = "rejected"
|
|
17261
|
+
REJECTED = "rejected",
|
|
17262
|
+
TRANSACTION_SUCCESS = "transaction-success"
|
|
17257
17263
|
}
|
|
17258
17264
|
/**
|
|
17259
17265
|
* Represents a successful Sale transaction.
|
|
17260
|
-
* @property {
|
|
17266
|
+
* @property {Array} transactions - The executed transactions
|
|
17261
17267
|
*/
|
|
17262
17268
|
type SaleSuccess = {
|
|
17263
17269
|
transactions: {
|
|
@@ -17270,10 +17276,25 @@ type SaleSuccess = {
|
|
|
17270
17276
|
* Type representing a Sale Widget with type FAILURE.
|
|
17271
17277
|
* @property {string} reason - The reason why the swap failed.
|
|
17272
17278
|
* @property {number} timestamp - The timestamp of the failed swap.
|
|
17279
|
+
* @property {Array} transactions - The executed transactions
|
|
17273
17280
|
*/
|
|
17274
17281
|
type SaleFailed = {
|
|
17275
17282
|
reason: string;
|
|
17276
17283
|
timestamp: number;
|
|
17284
|
+
transactions: {
|
|
17285
|
+
method: string;
|
|
17286
|
+
hash: string | undefined;
|
|
17287
|
+
}[];
|
|
17288
|
+
};
|
|
17289
|
+
/**
|
|
17290
|
+
* Type representing a Sale Widget with type TRANSACTION_SUCCESS.
|
|
17291
|
+
* @property {Object} transactions - The executed transactions
|
|
17292
|
+
*/
|
|
17293
|
+
type SaleTransactionSuccess = {
|
|
17294
|
+
transactions: {
|
|
17295
|
+
method: string;
|
|
17296
|
+
hash: string | undefined;
|
|
17297
|
+
}[];
|
|
17277
17298
|
};
|
|
17278
17299
|
|
|
17279
17300
|
/**
|
|
@@ -17559,6 +17580,7 @@ type WidgetEventData = {
|
|
|
17559
17580
|
[SaleEventType.FAILURE]: SaleFailed;
|
|
17560
17581
|
[SaleEventType.REJECTED]: any;
|
|
17561
17582
|
[SaleEventType.CLOSE_WIDGET]: {};
|
|
17583
|
+
[SaleEventType.TRANSACTION_SUCCESS]: SaleTransactionSuccess;
|
|
17562
17584
|
} & OrchestrationMapping & ProviderEventMapping;
|
|
17563
17585
|
};
|
|
17564
17586
|
/**
|
|
@@ -17991,6 +18013,7 @@ type checkout_sdk_d_ERC721ItemRequirement = ERC721ItemRequirement;
|
|
|
17991
18013
|
type checkout_sdk_d_ErrorType = ErrorType;
|
|
17992
18014
|
type checkout_sdk_d_ExchangeType = ExchangeType;
|
|
17993
18015
|
declare const checkout_sdk_d_ExchangeType: typeof ExchangeType;
|
|
18016
|
+
type checkout_sdk_d_Fee = Fee;
|
|
17994
18017
|
type checkout_sdk_d_FeePercentage = FeePercentage;
|
|
17995
18018
|
type checkout_sdk_d_FeeToken = FeeToken;
|
|
17996
18019
|
type checkout_sdk_d_FiatRampParams = FiatRampParams;
|
|
@@ -18066,6 +18089,7 @@ declare const checkout_sdk_d_SaleEventType: typeof SaleEventType;
|
|
|
18066
18089
|
type checkout_sdk_d_SaleFailed = SaleFailed;
|
|
18067
18090
|
type checkout_sdk_d_SaleItem = SaleItem;
|
|
18068
18091
|
type checkout_sdk_d_SaleSuccess = SaleSuccess;
|
|
18092
|
+
type checkout_sdk_d_SaleTransactionSuccess = SaleTransactionSuccess;
|
|
18069
18093
|
type checkout_sdk_d_SaleWidgetConfiguration = SaleWidgetConfiguration;
|
|
18070
18094
|
type checkout_sdk_d_SaleWidgetParams = SaleWidgetParams;
|
|
18071
18095
|
type checkout_sdk_d_SellOrder = SellOrder;
|
|
@@ -18173,6 +18197,7 @@ declare namespace checkout_sdk_d {
|
|
|
18173
18197
|
checkout_sdk_d_ERC721ItemRequirement as ERC721ItemRequirement,
|
|
18174
18198
|
checkout_sdk_d_ErrorType as ErrorType,
|
|
18175
18199
|
checkout_sdk_d_ExchangeType as ExchangeType,
|
|
18200
|
+
checkout_sdk_d_Fee as Fee,
|
|
18176
18201
|
checkout_sdk_d_FeePercentage as FeePercentage,
|
|
18177
18202
|
checkout_sdk_d_FeeToken as FeeToken,
|
|
18178
18203
|
checkout_sdk_d_FiatRampParams as FiatRampParams,
|
|
@@ -18237,6 +18262,7 @@ declare namespace checkout_sdk_d {
|
|
|
18237
18262
|
checkout_sdk_d_SaleFailed as SaleFailed,
|
|
18238
18263
|
checkout_sdk_d_SaleItem as SaleItem,
|
|
18239
18264
|
checkout_sdk_d_SaleSuccess as SaleSuccess,
|
|
18265
|
+
checkout_sdk_d_SaleTransactionSuccess as SaleTransactionSuccess,
|
|
18240
18266
|
checkout_sdk_d_SaleWidgetConfiguration as SaleWidgetConfiguration,
|
|
18241
18267
|
checkout_sdk_d_SaleWidgetParams as SaleWidgetParams,
|
|
18242
18268
|
checkout_sdk_d_SellOrder as SellOrder,
|