@imtbl/sdk 0.28.4 → 0.28.5
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.js +2 -2
- package/dist/checkout_sdk.d.ts +7 -1
- package/dist/checkout_sdk.js +69 -53
- package/dist/checkout_widgets.d.ts +26 -4
- package/dist/checkout_widgets.js +2 -1
- 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 +140 -74
- package/dist/index.d.ts +28 -3
- package/dist/index.js +141 -75
- package/dist/passport.d.ts +7 -1
- package/dist/passport.js +48 -19
- package/dist/provider.d.ts +7 -0
- package/dist/provider.js +22 -2
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -3651,7 +3651,7 @@ class MultiRollupApiClients {
|
|
|
3651
3651
|
}
|
|
3652
3652
|
|
|
3653
3653
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
3654
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.28.
|
|
3654
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.28.5' };
|
|
3655
3655
|
const createConfig = ({ basePath, headers, }) => {
|
|
3656
3656
|
if (!basePath.trim()) {
|
|
3657
3657
|
throw Error('basePath can not be empty');
|
|
@@ -3711,7 +3711,7 @@ class APIError extends Error {
|
|
|
3711
3711
|
|
|
3712
3712
|
/* eslint-disable implicit-arrow-linebreak */
|
|
3713
3713
|
const defaultHeaders = {
|
|
3714
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.28.
|
|
3714
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.28.5',
|
|
3715
3715
|
};
|
|
3716
3716
|
/**
|
|
3717
3717
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -4122,7 +4122,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
4122
4122
|
chainID,
|
|
4123
4123
|
coreContractAddress,
|
|
4124
4124
|
registrationContractAddress,
|
|
4125
|
-
sdkVersion: 'ts-immutable-sdk-0.28.
|
|
4125
|
+
sdkVersion: 'ts-immutable-sdk-0.28.5',
|
|
4126
4126
|
});
|
|
4127
4127
|
/**
|
|
4128
4128
|
* Sets `sdkVersion` at the time of build
|
|
@@ -9067,39 +9067,63 @@ class AuthManager {
|
|
|
9067
9067
|
}
|
|
9068
9068
|
}
|
|
9069
9069
|
|
|
9070
|
+
const lazyLoad = (promiseToAwait, initialiseFunction) => (promiseToAwait().then(initialiseFunction));
|
|
9071
|
+
const lazyDocumentReady = (initialiseFunction) => {
|
|
9072
|
+
const documentReadyPromise = () => new Promise((resolve) => {
|
|
9073
|
+
if (window.document.readyState === 'complete') {
|
|
9074
|
+
resolve();
|
|
9075
|
+
}
|
|
9076
|
+
else {
|
|
9077
|
+
const onReadyStateChange = () => {
|
|
9078
|
+
if (window.document.readyState === 'complete') {
|
|
9079
|
+
resolve();
|
|
9080
|
+
window.document.removeEventListener('readystatechange', onReadyStateChange);
|
|
9081
|
+
}
|
|
9082
|
+
};
|
|
9083
|
+
window.document.addEventListener('readystatechange', onReadyStateChange);
|
|
9084
|
+
}
|
|
9085
|
+
});
|
|
9086
|
+
return lazyLoad(documentReadyPromise, initialiseFunction);
|
|
9087
|
+
};
|
|
9088
|
+
|
|
9070
9089
|
class MagicAdapter {
|
|
9071
9090
|
config;
|
|
9072
|
-
|
|
9091
|
+
lazyMagicClient;
|
|
9073
9092
|
constructor(config) {
|
|
9074
9093
|
this.config = config;
|
|
9075
9094
|
if (typeof window !== 'undefined') {
|
|
9076
|
-
this.
|
|
9077
|
-
|
|
9095
|
+
this.lazyMagicClient = lazyDocumentReady(() => {
|
|
9096
|
+
const client = new magicSdk.Magic(this.config.magicPublishableApiKey, {
|
|
9097
|
+
extensions: [new oidc.OpenIdExtension()],
|
|
9098
|
+
network: this.config.network,
|
|
9099
|
+
});
|
|
9100
|
+
client.preload();
|
|
9101
|
+
return client;
|
|
9102
|
+
});
|
|
9103
|
+
}
|
|
9104
|
+
}
|
|
9105
|
+
get magicClient() {
|
|
9106
|
+
if (!this.lazyMagicClient) {
|
|
9107
|
+
throw new Error('Cannot perform this action outside of the browser');
|
|
9078
9108
|
}
|
|
9109
|
+
return this.lazyMagicClient;
|
|
9079
9110
|
}
|
|
9080
9111
|
async login(idToken) {
|
|
9081
9112
|
return withPassportError(async () => {
|
|
9082
|
-
|
|
9083
|
-
|
|
9084
|
-
}
|
|
9085
|
-
await this.magicClient.openid.loginWithOIDC({
|
|
9113
|
+
const magicClient = await this.magicClient;
|
|
9114
|
+
await magicClient.openid.loginWithOIDC({
|
|
9086
9115
|
jwt: idToken,
|
|
9087
9116
|
providerId: this.config.magicProviderId,
|
|
9088
9117
|
});
|
|
9089
|
-
return
|
|
9118
|
+
return magicClient.rpcProvider;
|
|
9090
9119
|
}, PassportErrorType.WALLET_CONNECTION_ERROR);
|
|
9091
9120
|
}
|
|
9092
9121
|
async logout() {
|
|
9093
|
-
|
|
9094
|
-
|
|
9122
|
+
const magicClient = await this.magicClient;
|
|
9123
|
+
if (magicClient.user) {
|
|
9124
|
+
await magicClient.user.logout();
|
|
9095
9125
|
}
|
|
9096
9126
|
}
|
|
9097
|
-
initMagicClient() {
|
|
9098
|
-
return new magicSdk.Magic(this.config.magicPublishableApiKey, {
|
|
9099
|
-
extensions: [new oidc.OpenIdExtension()],
|
|
9100
|
-
network: this.config.network,
|
|
9101
|
-
});
|
|
9102
|
-
}
|
|
9103
9127
|
}
|
|
9104
9128
|
|
|
9105
9129
|
const getStarkSigner = async (signer) => withPassportError(async () => {
|
|
@@ -9326,7 +9350,7 @@ var PassportEvents;
|
|
|
9326
9350
|
var Networks;
|
|
9327
9351
|
(function (Networks) {
|
|
9328
9352
|
Networks["PRODUCTION"] = "mainnet";
|
|
9329
|
-
Networks["SANDBOX"] = "
|
|
9353
|
+
Networks["SANDBOX"] = "sepolia";
|
|
9330
9354
|
})(Networks || (Networks = {}));
|
|
9331
9355
|
|
|
9332
9356
|
async function exchangeTransfer$1({ user, starkSigner, request, exchangesApi, }) {
|
|
@@ -9675,6 +9699,11 @@ class PassportImxProvider {
|
|
|
9675
9699
|
}
|
|
9676
9700
|
// TODO: Remove once implemented
|
|
9677
9701
|
// eslint-disable-next-line class-methods-use-this
|
|
9702
|
+
isRegisteredOffchain() {
|
|
9703
|
+
throw new PassportError('Operation not supported', PassportErrorType.OPERATION_NOT_SUPPORTED_ERROR);
|
|
9704
|
+
}
|
|
9705
|
+
// TODO: Remove once implemented
|
|
9706
|
+
// eslint-disable-next-line class-methods-use-this
|
|
9678
9707
|
isRegisteredOnchain() {
|
|
9679
9708
|
throw new PassportError('Operation not supported', PassportErrorType.OPERATION_NOT_SUPPORTED_ERROR);
|
|
9680
9709
|
}
|
|
@@ -12671,6 +12700,22 @@ async function registerOffchain(signers, config) {
|
|
|
12671
12700
|
});
|
|
12672
12701
|
return registeredUser.data;
|
|
12673
12702
|
}
|
|
12703
|
+
async function isRegisteredOffchain(ethAddress, config) {
|
|
12704
|
+
try {
|
|
12705
|
+
const usersApi = new coreSdk.UsersApi(config.immutableXConfig.apiConfiguration);
|
|
12706
|
+
const getUsersResult = await usersApi.getUsers({
|
|
12707
|
+
user: ethAddress,
|
|
12708
|
+
});
|
|
12709
|
+
const { accounts } = getUsersResult.data;
|
|
12710
|
+
return accounts?.length > 0;
|
|
12711
|
+
}
|
|
12712
|
+
catch (ex) {
|
|
12713
|
+
if (ex instanceof globalAxios$1.AxiosError && ex.response?.status === 404) {
|
|
12714
|
+
return false;
|
|
12715
|
+
}
|
|
12716
|
+
throw ex;
|
|
12717
|
+
}
|
|
12718
|
+
}
|
|
12674
12719
|
async function isRegisteredOnChain(starkPublicKey, ethSigner, config) {
|
|
12675
12720
|
await validateChain(ethSigner, config.immutableXConfig);
|
|
12676
12721
|
const registrationContract = coreSdk.Contracts.Registration.connect(config.immutableXConfig.ethConfiguration.registrationContractAddress, ethSigner);
|
|
@@ -13206,7 +13251,11 @@ class GenericIMXProvider {
|
|
|
13206
13251
|
this.signers = { ethSigner, starkSigner };
|
|
13207
13252
|
}
|
|
13208
13253
|
async getAddress() {
|
|
13209
|
-
return
|
|
13254
|
+
return this.signers.ethSigner.getAddress();
|
|
13255
|
+
}
|
|
13256
|
+
async isRegisteredOffchain() {
|
|
13257
|
+
const ethAddress = await this.getAddress();
|
|
13258
|
+
return isRegisteredOffchain(ethAddress, this.config);
|
|
13210
13259
|
}
|
|
13211
13260
|
registerOffchain() {
|
|
13212
13261
|
return registerOffchain(this.signers, this.config);
|
|
@@ -30399,6 +30448,7 @@ async function $1564e43dde50bb61$export$60e0fe116a0e6ed0(web3Provider, walletAdd
|
|
|
30399
30448
|
}
|
|
30400
30449
|
// Blockscout client singleton per chain id
|
|
30401
30450
|
const $1564e43dde50bb61$var$blockscoutClientMap = new Map();
|
|
30451
|
+
const $1564e43dde50bb61$export$be5483d07cfa803d = ()=>$1564e43dde50bb61$var$blockscoutClientMap.clear();
|
|
30402
30452
|
const $1564e43dde50bb61$export$8c978679845804d4 = async (walletAddress, chainId, filterTokens)=>{
|
|
30403
30453
|
// Shuffle the mapping of the tokens configuration so it is a hashmap
|
|
30404
30454
|
// for faster access to tokens config objects.
|
|
@@ -30500,6 +30550,8 @@ const $1564e43dde50bb61$export$a3238cee431627c6 = async (config, web3Provider, w
|
|
|
30500
30550
|
};
|
|
30501
30551
|
};
|
|
30502
30552
|
const $1564e43dde50bb61$export$fee49741664a4d7e = async (config, web3Provider, walletAddress, chainId)=>{
|
|
30553
|
+
// eslint-disable-next-line no-param-reassign
|
|
30554
|
+
chainId ||= await web3Provider.getSigner().getChainId();
|
|
30503
30555
|
const { tokens: tokens } = await ($efe60cea83bfc4e8$export$473cec51305fdae8)(config, {
|
|
30504
30556
|
type: ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ALL,
|
|
30505
30557
|
chainId: chainId
|
|
@@ -30521,7 +30573,7 @@ const $1564e43dde50bb61$export$fee49741664a4d7e = async (config, web3Provider, w
|
|
|
30521
30573
|
// Please remove this hack once https://immutable.atlassian.net/browse/WT-1710
|
|
30522
30574
|
// is done.
|
|
30523
30575
|
const isL1Chain = ($4013c5c91bb535f6$export$9b794d067cdd1af6)(config) === chainId;
|
|
30524
|
-
return ($458d407830d66110$export$5280dbcb91c8b391)(config, `Time to fetch balances using blockscout for ${chainId}`, $1564e43dde50bb61$export$8c978679845804d4(walletAddress, chainId, isL1Chain ? tokens : []));
|
|
30576
|
+
return await ($458d407830d66110$export$5280dbcb91c8b391)(config, `Time to fetch balances using blockscout for ${chainId}`, $1564e43dde50bb61$export$8c978679845804d4(walletAddress, chainId, isL1Chain ? tokens : []));
|
|
30525
30577
|
}
|
|
30526
30578
|
// This fallback to use ERC20s calls which is a best effort solution
|
|
30527
30579
|
// Fails in fetching data from the RCP calls might result in some
|
|
@@ -30892,6 +30944,7 @@ async function $2e7bf45a7c9a9570$export$942c8de7174809fc(params, readOnlyProvide
|
|
|
30892
30944
|
|
|
30893
30945
|
|
|
30894
30946
|
|
|
30947
|
+
|
|
30895
30948
|
const $ddc6bcd0896481e5$export$2fbfa41a4de56a89 = (erc20allowances, erc721allowances)=>{
|
|
30896
30949
|
const aggregatedAllowances = [];
|
|
30897
30950
|
if (!erc20allowances.sufficient) {
|
|
@@ -31198,7 +31251,7 @@ const $35c3fc7013888ba5$export$be546c525d418988 = async (provider, ownerAddress,
|
|
|
31198
31251
|
|
|
31199
31252
|
|
|
31200
31253
|
|
|
31201
|
-
|
|
31254
|
+
|
|
31202
31255
|
|
|
31203
31256
|
|
|
31204
31257
|
|
|
@@ -31391,17 +31444,14 @@ const $73d2282a108cc7e2$export$6ab9757fda54db7e = (itemRequirement, balances)=>{
|
|
|
31391
31444
|
/**
|
|
31392
31445
|
* Gets the balances for all NATIVE and ERC20 balance requirements.
|
|
31393
31446
|
*/ const $beb896e098e41faf$var$getTokenBalances = async (config, provider, ownerAddress, itemRequirements)=>{
|
|
31394
|
-
let tokenBalances = [];
|
|
31395
31447
|
try {
|
|
31396
|
-
const
|
|
31397
|
-
|
|
31398
|
-
|
|
31399
|
-
|
|
31400
|
-
];
|
|
31448
|
+
const tokenMap = new Map();
|
|
31449
|
+
(0, $73d2282a108cc7e2$export$ed7929b58bab85da)(itemRequirements).forEach((item)=>tokenMap.set((item.address || "").toLocaleLowerCase(), item));
|
|
31450
|
+
const { balances: balances } = await (0, $1564e43dde50bb61$export$fee49741664a4d7e)(config, provider, ownerAddress);
|
|
31451
|
+
return balances.filter((balance)=>tokenMap.get((balance.token.address || "").toLocaleLowerCase()));
|
|
31401
31452
|
} catch (error) {
|
|
31402
31453
|
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Failed to get balances", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_BALANCE_ERROR);
|
|
31403
31454
|
}
|
|
31404
|
-
return tokenBalances;
|
|
31405
31455
|
};
|
|
31406
31456
|
/**
|
|
31407
31457
|
* Gets the balances for all ERC721 balance requirements.
|
|
@@ -31439,42 +31489,46 @@ const $73d2282a108cc7e2$export$6ab9757fda54db7e = (itemRequirement, balances)=>{
|
|
|
31439
31489
|
};
|
|
31440
31490
|
const $beb896e098e41faf$export$ddfc885f43c3cb6e = async (config, provider, ownerAddress, itemRequirements)=>{
|
|
31441
31491
|
const aggregatedItems = ($aa6caea9a60d18c7$export$f96d1c819a615a64)(itemRequirements);
|
|
31442
|
-
|
|
31443
|
-
|
|
31444
|
-
|
|
31492
|
+
const requiredToken = [];
|
|
31493
|
+
const requiredERC721 = [];
|
|
31494
|
+
aggregatedItems.forEach((item)=>{
|
|
31495
|
+
switch(item.type){
|
|
31496
|
+
case ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20:
|
|
31497
|
+
case ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE:
|
|
31498
|
+
requiredToken.push(item);
|
|
31499
|
+
break;
|
|
31500
|
+
case ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721:
|
|
31501
|
+
requiredERC721.push(item);
|
|
31502
|
+
break;
|
|
31503
|
+
}
|
|
31504
|
+
});
|
|
31505
|
+
if (requiredERC721.length === 0 && requiredToken.length === 0) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Unsupported item requirement balance check", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).UNSUPPORTED_BALANCE_REQUIREMENT_ERROR);
|
|
31445
31506
|
// Get all ERC20 and NATIVE balances
|
|
31446
|
-
const
|
|
31447
|
-
|
|
31448
|
-
if (tokenItemRequirements.length > 0) currentBalances.push($beb896e098e41faf$var$getTokenBalances(config, provider, ownerAddress, aggregatedItems));
|
|
31507
|
+
const balancePromises = [];
|
|
31508
|
+
if (requiredToken.length > 0) balancePromises.push($beb896e098e41faf$var$getTokenBalances(config, provider, ownerAddress, aggregatedItems));
|
|
31449
31509
|
// Get all ERC721 balances
|
|
31450
|
-
|
|
31451
|
-
if (erc721ItemRequirements.length > 0) currentBalances.push($beb896e098e41faf$var$getERC721Balances(provider, ownerAddress, aggregatedItems));
|
|
31510
|
+
if (requiredERC721.length > 0) balancePromises.push($beb896e098e41faf$var$getERC721Balances(provider, ownerAddress, aggregatedItems));
|
|
31452
31511
|
// Wait for all balances and calculate the requirements
|
|
31453
|
-
const
|
|
31454
|
-
|
|
31455
|
-
|
|
31456
|
-
|
|
31457
|
-
|
|
31458
|
-
|
|
31459
|
-
|
|
31460
|
-
|
|
31461
|
-
|
|
31462
|
-
|
|
31463
|
-
|
|
31464
|
-
|
|
31465
|
-
|
|
31466
|
-
|
|
31467
|
-
|
|
31468
|
-
|
|
31469
|
-
|
|
31470
|
-
|
|
31471
|
-
|
|
31472
|
-
|
|
31473
|
-
return requirements;
|
|
31474
|
-
});
|
|
31475
|
-
const sufficient = balanceRequirements.reduce((acc, balanceRequirement)=>{
|
|
31476
|
-
return acc && balanceRequirement.sufficient;
|
|
31477
|
-
}, true);
|
|
31512
|
+
const promisesResponses = await Promise.all(balancePromises);
|
|
31513
|
+
const balanceRequirements = [];
|
|
31514
|
+
// Get all ERC20 and NATIVE balances
|
|
31515
|
+
if (requiredToken.length > 0 && promisesResponses.length > 0) {
|
|
31516
|
+
const result = promisesResponses.shift();
|
|
31517
|
+
if (result) requiredToken.forEach((item)=>{
|
|
31518
|
+
balanceRequirements.push(($73d2282a108cc7e2$export$6ab9757fda54db7e)(item, result));
|
|
31519
|
+
});
|
|
31520
|
+
}
|
|
31521
|
+
// Get all ERC721 balances
|
|
31522
|
+
if (requiredERC721.length > 0 && promisesResponses.length > 0) {
|
|
31523
|
+
const result = promisesResponses.shift();
|
|
31524
|
+
if (result) requiredERC721.forEach((item)=>{
|
|
31525
|
+
balanceRequirements.push(($73d2282a108cc7e2$export$9b757e40b19984c3)(item, result));
|
|
31526
|
+
});
|
|
31527
|
+
}
|
|
31528
|
+
// Find if there are any requirements that aren't sufficient.
|
|
31529
|
+
// If there is not item with sufficient === false then the requirements
|
|
31530
|
+
// are satisfied.
|
|
31531
|
+
const sufficient = balanceRequirements.find((req)=>req.sufficient === false) === undefined;
|
|
31478
31532
|
return {
|
|
31479
31533
|
sufficient: sufficient,
|
|
31480
31534
|
balanceRequirements: balanceRequirements
|
|
@@ -32058,7 +32112,9 @@ const $15fe1c77041bd4f4$export$9e73e22953cebcfc = async (config, readOnlyProvide
|
|
|
32058
32112
|
|
|
32059
32113
|
const $887d24b47765b1c0$export$c37d8687c27b9660 = "0x0000000000000000000000000000000000000001";
|
|
32060
32114
|
const $887d24b47765b1c0$export$1430626eec86fce9 = (chainId)=>{
|
|
32115
|
+
if (chainId === ($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_MAINNET) return "imtbl-zkevm-mainnet";
|
|
32061
32116
|
if (chainId === ($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_TESTNET) return "imtbl-zkevm-testnet";
|
|
32117
|
+
if (chainId === ($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_DEVNET) return "imtbl-zkevm-devent";
|
|
32062
32118
|
return "";
|
|
32063
32119
|
};
|
|
32064
32120
|
const $887d24b47765b1c0$export$53e663abd9b77fc1 = async (chainId, config)=>{
|
|
@@ -32879,7 +32935,6 @@ const $a7367d01c6e76b1c$export$d62081fac18000c2 = (orderHash, orderComponents, a
|
|
|
32879
32935
|
|
|
32880
32936
|
|
|
32881
32937
|
|
|
32882
|
-
|
|
32883
32938
|
const $9051cee080948594$export$9ac1563efd38130 = 1; // 100%
|
|
32884
32939
|
const $9051cee080948594$export$768e717351d4b176 = 6; // will allow 0.000001 (0.0001%) as the minimum value
|
|
32885
32940
|
const $9051cee080948594$var$calculateFeesPercent = (orderFee, amountBn)=>{
|
|
@@ -32920,6 +32975,7 @@ const $9051cee080948594$export$1e69c9cfc42e28d8 = (orderFees, weiAmount, decimal
|
|
|
32920
32975
|
|
|
32921
32976
|
|
|
32922
32977
|
|
|
32978
|
+
|
|
32923
32979
|
const $64863c39386de592$export$4249179755829904 = (type, contractAddress, amount, spenderAddress)=>{
|
|
32924
32980
|
switch(type){
|
|
32925
32981
|
case ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20:
|
|
@@ -32951,16 +33007,24 @@ const $64863c39386de592$export$8f2ff92ab8657f0b = (gasLimit, fulfillmentTransact
|
|
|
32951
33007
|
};
|
|
32952
33008
|
};
|
|
32953
33009
|
const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, orders)=>{
|
|
32954
|
-
|
|
33010
|
+
if (orders.length === 0) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No orders were provided to the orders array. Please provide at least one order.", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).FULFILL_ORDER_LISTING_ERROR);
|
|
32955
33011
|
let order;
|
|
32956
33012
|
let spenderAddress = "";
|
|
33013
|
+
let decimals = 18;
|
|
32957
33014
|
const gasLimit = (constants).estimatedFulfillmentGasGwei;
|
|
32958
|
-
|
|
33015
|
+
const orderbook = $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config);
|
|
33016
|
+
const blockchainClient = $67fc622a2b913d5f$export$436dd76f23f463ff(config);
|
|
33017
|
+
const fulfillerAddress = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get the address from the provider", provider.getSigner().getAddress());
|
|
33018
|
+
// Prefetch balances and store them in memory
|
|
33019
|
+
($1564e43dde50bb61$export$be5483d07cfa803d)();
|
|
33020
|
+
($1564e43dde50bb61$export$fee49741664a4d7e)(config, provider, fulfillerAddress, ($4013c5c91bb535f6$export$9b794d067cdd1af6)(config));
|
|
33021
|
+
($1564e43dde50bb61$export$fee49741664a4d7e)(config, provider, fulfillerAddress, ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config));
|
|
32959
33022
|
const { id: id, takerFees: takerFees } = orders[0];
|
|
33023
|
+
let orderChainName;
|
|
32960
33024
|
try {
|
|
32961
|
-
orderbook = $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config);
|
|
32962
33025
|
order = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to fetch the listing from the orderbook", orderbook.getListing(id));
|
|
32963
|
-
const { seaportContractAddress: seaportContractAddress } = orderbook.config();
|
|
33026
|
+
const { seaportContractAddress: seaportContractAddress, chainName: chainName } = orderbook.config();
|
|
33027
|
+
orderChainName = chainName;
|
|
32964
33028
|
spenderAddress = seaportContractAddress;
|
|
32965
33029
|
} catch (err) {
|
|
32966
33030
|
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("An error occurred while getting the order listing", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_ORDER_LISTING_ERROR, {
|
|
@@ -32973,10 +33037,12 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
|
|
|
32973
33037
|
message: "No buy side tokens found on order"
|
|
32974
33038
|
});
|
|
32975
33039
|
const buyToken = order.result.buy[0];
|
|
32976
|
-
|
|
32977
|
-
|
|
32978
|
-
|
|
32979
|
-
|
|
33040
|
+
if (buyToken.type === "ERC20") {
|
|
33041
|
+
const token = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get decimals of token contract for the buy token", blockchainClient.getToken({
|
|
33042
|
+
contractAddress: buyToken.contractAddress,
|
|
33043
|
+
chainName: orderChainName
|
|
33044
|
+
}));
|
|
33045
|
+
if (token.result.decimals) decimals = token.result.decimals;
|
|
32980
33046
|
}
|
|
32981
33047
|
let fees = [];
|
|
32982
33048
|
if (takerFees && takerFees.length > 0) fees = ($9051cee080948594$export$1e69c9cfc42e28d8)(takerFees, buyToken.amount, decimals);
|
|
@@ -32985,7 +33051,6 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
|
|
|
32985
33051
|
let orderActions = [];
|
|
32986
33052
|
const fulfillOrderStartTime = performance.now();
|
|
32987
33053
|
try {
|
|
32988
|
-
const fulfillerAddress = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get the address from the provider", provider.getSigner().getAddress());
|
|
32989
33054
|
const { actions: actions } = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to call fulfillOrder from the orderbook", orderbook.fulfillOrder(id, fulfillerAddress, fees));
|
|
32990
33055
|
orderActions = actions;
|
|
32991
33056
|
unsignedApprovalTransactions = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to construct the unsigned approval transactions", (0, $a7367d01c6e76b1c$export$f64a20a30eb98855)(actions));
|
|
@@ -33585,7 +33650,7 @@ var $045213b18e9f1f94$export$75be0f6af9650f2c;
|
|
|
33585
33650
|
})($045213b18e9f1f94$export$75be0f6af9650f2c || ($045213b18e9f1f94$export$75be0f6af9650f2c = {}));
|
|
33586
33651
|
|
|
33587
33652
|
|
|
33588
|
-
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.28.
|
|
33653
|
+
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.28.5";
|
|
33589
33654
|
const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
|
|
33590
33655
|
const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
|
|
33591
33656
|
|
|
@@ -33770,6 +33835,7 @@ $parcel$export($9b3189b6b155842e$exports, "SaleEventType", () => $9b3189b6b15584
|
|
|
33770
33835
|
SaleEventType["SUCCESS"] = "success";
|
|
33771
33836
|
SaleEventType["FAILURE"] = "failure";
|
|
33772
33837
|
SaleEventType["REJECTED"] = "rejected";
|
|
33838
|
+
SaleEventType["TRANSACTION_SUCCESS"] = "transaction-success";
|
|
33773
33839
|
})($9b3189b6b155842e$export$881881ffb3bd733e || ($9b3189b6b155842e$export$881881ffb3bd733e = {}));
|
|
33774
33840
|
|
|
33775
33841
|
|
package/dist/index.d.ts
CHANGED
|
@@ -14422,6 +14422,12 @@ interface IMXProvider {
|
|
|
14422
14422
|
* @return {Promise<RegisterUserResponse>} Returns a promise that resolves with the user registration response
|
|
14423
14423
|
*/
|
|
14424
14424
|
registerOffchain(): Promise<RegisterUserResponse>;
|
|
14425
|
+
/**
|
|
14426
|
+
* Checks if a User is registered off-chain
|
|
14427
|
+
*
|
|
14428
|
+
* @return {Promise<boolean>} Returns a promise that resolves with true if the User is registered with IMX, false otherwise
|
|
14429
|
+
*/
|
|
14430
|
+
isRegisteredOffchain(): Promise<boolean>;
|
|
14425
14431
|
/**
|
|
14426
14432
|
* Checks if a User is registered on-chain
|
|
14427
14433
|
*
|
|
@@ -14499,6 +14505,7 @@ declare class GenericIMXProvider implements IMXProvider {
|
|
|
14499
14505
|
private readonly signers;
|
|
14500
14506
|
constructor(config: ProviderConfiguration$1, ethSigner: Signer, starkSigner: StarkSigner);
|
|
14501
14507
|
getAddress(): Promise<string>;
|
|
14508
|
+
isRegisteredOffchain(): Promise<boolean>;
|
|
14502
14509
|
registerOffchain(): Promise<RegisterUserResponse>;
|
|
14503
14510
|
batchNftTransfer(request: Array<NftTransferDetails>): Promise<CreateTransferResponse>;
|
|
14504
14511
|
cancelOrder(request: GetSignableCancelOrderRequest): Promise<CancelOrderResponse>;
|
|
@@ -14537,7 +14544,7 @@ type UserProfile = {
|
|
|
14537
14544
|
};
|
|
14538
14545
|
declare enum Networks {
|
|
14539
14546
|
PRODUCTION = "mainnet",
|
|
14540
|
-
SANDBOX = "
|
|
14547
|
+
SANDBOX = "sepolia"
|
|
14541
14548
|
}
|
|
14542
14549
|
interface OidcConfiguration {
|
|
14543
14550
|
clientId: string;
|
|
@@ -32173,11 +32180,12 @@ declare enum SaleEventType {
|
|
|
32173
32180
|
CLOSE_WIDGET = "close-widget",
|
|
32174
32181
|
SUCCESS = "success",
|
|
32175
32182
|
FAILURE = "failure",
|
|
32176
|
-
REJECTED = "rejected"
|
|
32183
|
+
REJECTED = "rejected",
|
|
32184
|
+
TRANSACTION_SUCCESS = "transaction-success"
|
|
32177
32185
|
}
|
|
32178
32186
|
/**
|
|
32179
32187
|
* Represents a successful Sale transaction.
|
|
32180
|
-
* @property {
|
|
32188
|
+
* @property {Array} transactions - The executed transactions
|
|
32181
32189
|
*/
|
|
32182
32190
|
type SaleSuccess = {
|
|
32183
32191
|
transactions: {
|
|
@@ -32190,10 +32198,25 @@ type SaleSuccess = {
|
|
|
32190
32198
|
* Type representing a Sale Widget with type FAILURE.
|
|
32191
32199
|
* @property {string} reason - The reason why the swap failed.
|
|
32192
32200
|
* @property {number} timestamp - The timestamp of the failed swap.
|
|
32201
|
+
* @property {Array} transactions - The executed transactions
|
|
32193
32202
|
*/
|
|
32194
32203
|
type SaleFailed = {
|
|
32195
32204
|
reason: string;
|
|
32196
32205
|
timestamp: number;
|
|
32206
|
+
transactions: {
|
|
32207
|
+
method: string;
|
|
32208
|
+
hash: string | undefined;
|
|
32209
|
+
}[];
|
|
32210
|
+
};
|
|
32211
|
+
/**
|
|
32212
|
+
* Type representing a Sale Widget with type TRANSACTION_SUCCESS.
|
|
32213
|
+
* @property {Object} transactions - The executed transactions
|
|
32214
|
+
*/
|
|
32215
|
+
type SaleTransactionSuccess = {
|
|
32216
|
+
transactions: {
|
|
32217
|
+
method: string;
|
|
32218
|
+
hash: string | undefined;
|
|
32219
|
+
}[];
|
|
32197
32220
|
};
|
|
32198
32221
|
/**
|
|
32199
32222
|
* Enum representing the events emitted by the widgets.
|
|
@@ -32484,6 +32507,7 @@ type checkout_widgets_d_SaleEventType = SaleEventType;
|
|
|
32484
32507
|
declare const checkout_widgets_d_SaleEventType: typeof SaleEventType;
|
|
32485
32508
|
type checkout_widgets_d_SaleFailed = SaleFailed;
|
|
32486
32509
|
type checkout_widgets_d_SaleSuccess = SaleSuccess;
|
|
32510
|
+
type checkout_widgets_d_SaleTransactionSuccess = SaleTransactionSuccess;
|
|
32487
32511
|
type checkout_widgets_d_SemanticVersion = SemanticVersion;
|
|
32488
32512
|
type checkout_widgets_d_SwapEventType = SwapEventType;
|
|
32489
32513
|
declare const checkout_widgets_d_SwapEventType: typeof SwapEventType;
|
|
@@ -32538,6 +32562,7 @@ declare namespace checkout_widgets_d {
|
|
|
32538
32562
|
checkout_widgets_d_SaleEventType as SaleEventType,
|
|
32539
32563
|
checkout_widgets_d_SaleFailed as SaleFailed,
|
|
32540
32564
|
checkout_widgets_d_SaleSuccess as SaleSuccess,
|
|
32565
|
+
checkout_widgets_d_SaleTransactionSuccess as SaleTransactionSuccess,
|
|
32541
32566
|
checkout_widgets_d_SemanticVersion as SemanticVersion,
|
|
32542
32567
|
checkout_widgets_d_SwapEventType as SwapEventType,
|
|
32543
32568
|
checkout_widgets_d_SwapFailed as SwapFailed,
|