@imtbl/sdk 0.13.1-alpha.1 → 0.14.0-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.js +2 -2
- package/dist/checkout_sdk.js +24 -56
- package/dist/checkout_widgets.js +1 -1
- package/dist/{erc721_hybrid_permissioned_mintable.d.ts → erc721.d.ts} +29 -8
- package/dist/{erc721_hybrid_permissioned_mintable.js → erc721.js} +190 -119
- package/dist/{erc721_permissioned_mintable.d.ts → erc721_mint_by_id.d.ts} +23 -2
- package/dist/{erc721_permissioned_mintable.js → erc721_mint_by_id.js} +168 -18
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +14 -14
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +392 -203
- package/dist/index.d.ts +59 -17
- package/dist/index.js +392 -203
- package/dist/passport.js +2 -2
- package/package.json +9 -9
package/dist/checkout_sdk.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ethers, ContractFactory, utils, Contract as Contract$1, BigNumber as BigNumber$1, providers, constants as constants$1 } from 'ethers';
|
|
2
2
|
import { Web3Provider, JsonRpcProvider } from '@ethersproject/providers';
|
|
3
3
|
import $7v2Z6$metamaskdetectprovider from '@metamask/detect-provider';
|
|
4
|
-
import {
|
|
4
|
+
import { TradeType, Token, Percent, CurrencyAmount } from '@uniswap/sdk-core';
|
|
5
5
|
import assert from 'assert';
|
|
6
6
|
import { BigNumber as BigNumber$2 } from '@ethersproject/bignumber';
|
|
7
7
|
import { FeeAmount, Route, SwapQuoter, Pool, Trade, toHex as toHex$1, encodeRouteToPath } from '@uniswap/v3-sdk';
|
|
@@ -12897,20 +12897,12 @@ function applySlippage(tradeType, amount, slippage) {
|
|
|
12897
12897
|
return ethers.BigNumber.from(amountWithSlippage.toString());
|
|
12898
12898
|
}
|
|
12899
12899
|
function prepareUserQuote(otherToken, tradeInfo, slippage, fees) {
|
|
12900
|
-
const resultToken = otherToken.wrapped;
|
|
12901
|
-
const tokenInfo = {
|
|
12902
|
-
chainId: resultToken.chainId,
|
|
12903
|
-
address: resultToken.address,
|
|
12904
|
-
decimals: resultToken.decimals,
|
|
12905
|
-
symbol: resultToken.symbol,
|
|
12906
|
-
name: resultToken.name,
|
|
12907
|
-
};
|
|
12908
12900
|
const quote = getQuoteAmountFromTradeType(tradeInfo);
|
|
12909
12901
|
const amountWithSlippage = applySlippage(tradeInfo.tradeType, quote.value, slippage);
|
|
12910
12902
|
return {
|
|
12911
12903
|
amount: quote,
|
|
12912
12904
|
amountWithMaxSlippage: {
|
|
12913
|
-
token:
|
|
12905
|
+
token: otherToken,
|
|
12914
12906
|
value: amountWithSlippage,
|
|
12915
12907
|
},
|
|
12916
12908
|
slippage,
|
|
@@ -14931,13 +14923,6 @@ function isValidNonZeroAddress(address) {
|
|
|
14931
14923
|
}
|
|
14932
14924
|
}
|
|
14933
14925
|
const tokenInfoToUniswapToken = (tokenInfo) => new Token(tokenInfo.chainId, tokenInfo.address, tokenInfo.decimals, tokenInfo.symbol, tokenInfo.name);
|
|
14934
|
-
const uniswapTokenToTokenInfo = (token) => ({
|
|
14935
|
-
chainId: token.chainId,
|
|
14936
|
-
address: token.address,
|
|
14937
|
-
decimals: token.decimals,
|
|
14938
|
-
symbol: token.symbol,
|
|
14939
|
-
name: token.name,
|
|
14940
|
-
});
|
|
14941
14926
|
const toCurrencyAmount = (amount) => {
|
|
14942
14927
|
const token = tokenInfoToUniswapToken(amount.token);
|
|
14943
14928
|
return CurrencyAmount.fromRawAmount(token, amount.value.toString());
|
|
@@ -14998,6 +14983,7 @@ async function getQuotesForRoutes(multicallContract, quoterContractAddress, rout
|
|
|
14998
14983
|
amountIn: tradeType === TradeType.EXACT_INPUT ? amountSpecified : newAmount(quoteAmount, routes[i].input),
|
|
14999
14984
|
amountOut: tradeType === TradeType.EXACT_INPUT ? newAmount(quoteAmount, routes[i].output) : amountSpecified,
|
|
15000
14985
|
gasEstimate: ethers.BigNumber.from(decodedQuoteResult[gasEstimateIndex]),
|
|
14986
|
+
tradeType,
|
|
15001
14987
|
});
|
|
15002
14988
|
}
|
|
15003
14989
|
}
|
|
@@ -15160,14 +15146,7 @@ class Router {
|
|
|
15160
15146
|
throw new NoRoutesAvailableError();
|
|
15161
15147
|
}
|
|
15162
15148
|
// Get the best quote from all of the given routes
|
|
15163
|
-
|
|
15164
|
-
return {
|
|
15165
|
-
route,
|
|
15166
|
-
amountIn,
|
|
15167
|
-
amountOut,
|
|
15168
|
-
tradeType,
|
|
15169
|
-
gasEstimate,
|
|
15170
|
-
};
|
|
15149
|
+
return await this.getBestQuoteFromRoutes(multicallContract, routes, amountSpecified, tradeType);
|
|
15171
15150
|
}
|
|
15172
15151
|
async getBestQuoteFromRoutes(multicallContract, routes, amountSpecified, tradeType) {
|
|
15173
15152
|
const quotes = await getQuotesForRoutes(multicallContract, this.routingContracts.quoterAddress, routes, amountSpecified, tradeType);
|
|
@@ -15176,23 +15155,11 @@ class Router {
|
|
|
15176
15155
|
}
|
|
15177
15156
|
// We want to maximise the amountOut for the EXACT_INPUT type
|
|
15178
15157
|
if (tradeType === TradeType.EXACT_INPUT) {
|
|
15179
|
-
|
|
15180
|
-
return {
|
|
15181
|
-
route: bestQuote.route,
|
|
15182
|
-
amountIn: bestQuote.amountIn,
|
|
15183
|
-
amountOut: bestQuote.amountOut,
|
|
15184
|
-
gasEstimate: bestQuote.gasEstimate,
|
|
15185
|
-
};
|
|
15158
|
+
return this.bestQuoteForAmountIn(quotes);
|
|
15186
15159
|
}
|
|
15187
15160
|
// We want to minimise the amountIn for the EXACT_OUTPUT type
|
|
15188
15161
|
if (tradeType === TradeType.EXACT_OUTPUT) {
|
|
15189
|
-
|
|
15190
|
-
return {
|
|
15191
|
-
route: bestQuote.route,
|
|
15192
|
-
amountIn: bestQuote.amountIn,
|
|
15193
|
-
amountOut: bestQuote.amountOut,
|
|
15194
|
-
gasEstimate: bestQuote.gasEstimate,
|
|
15195
|
-
};
|
|
15162
|
+
return this.bestQuoteForAmountOut(quotes);
|
|
15196
15163
|
}
|
|
15197
15164
|
throw new Error('Invalid trade type');
|
|
15198
15165
|
}
|
|
@@ -15231,9 +15198,9 @@ maxHops, // the maximum number of pools that can be traversed
|
|
|
15231
15198
|
currentRoute = [], // list of pools already traversed
|
|
15232
15199
|
routes = [], // list of all routes found so far
|
|
15233
15200
|
startTokenIn = tokenIn) => {
|
|
15234
|
-
const currencyIn =
|
|
15235
|
-
const currencyOut =
|
|
15236
|
-
const startCurrencyIn =
|
|
15201
|
+
const currencyIn = tokenInfoToUniswapToken(tokenIn);
|
|
15202
|
+
const currencyOut = tokenInfoToUniswapToken(tokenOut);
|
|
15203
|
+
const startCurrencyIn = tokenInfoToUniswapToken(startTokenIn);
|
|
15237
15204
|
for (const pool of pools) {
|
|
15238
15205
|
// if the pool doesn't have the tokenIn or if it has already been traversed,
|
|
15239
15206
|
// skip to the next pool
|
|
@@ -15263,7 +15230,7 @@ class Fees {
|
|
|
15263
15230
|
amount;
|
|
15264
15231
|
constructor(secondaryFees, token) {
|
|
15265
15232
|
this.secondaryFees = secondaryFees;
|
|
15266
|
-
this.amount =
|
|
15233
|
+
this.amount = newAmount(BigNumber$1.from(0), token);
|
|
15267
15234
|
}
|
|
15268
15235
|
addAmount(amount) {
|
|
15269
15236
|
this.amount = addAmount(this.amount, amount);
|
|
@@ -15576,20 +15543,21 @@ class Exchange {
|
|
|
15576
15543
|
getERC20Decimals(tokenOutAddress, this.provider),
|
|
15577
15544
|
this.getSecondaryFees(),
|
|
15578
15545
|
]);
|
|
15579
|
-
const tokenIn =
|
|
15580
|
-
|
|
15546
|
+
const tokenIn = {
|
|
15547
|
+
address: tokenInAddress,
|
|
15548
|
+
chainId: this.chainId,
|
|
15549
|
+
decimals: tokenInDecimals,
|
|
15550
|
+
};
|
|
15551
|
+
const tokenOut = {
|
|
15552
|
+
address: tokenOutAddress,
|
|
15553
|
+
chainId: this.chainId,
|
|
15554
|
+
decimals: tokenOutDecimals,
|
|
15555
|
+
};
|
|
15581
15556
|
// determine which amount was specified for the swap from the TradeType
|
|
15582
|
-
|
|
15583
|
-
|
|
15584
|
-
|
|
15585
|
-
|
|
15586
|
-
otherToken = tokenOut;
|
|
15587
|
-
}
|
|
15588
|
-
else {
|
|
15589
|
-
amountSpecified = newAmount(amount, tokenOut);
|
|
15590
|
-
otherToken = tokenIn;
|
|
15591
|
-
}
|
|
15592
|
-
const fees = new Fees(secondaryFees, uniswapTokenToTokenInfo(tokenIn));
|
|
15557
|
+
const [tokenSpecified, otherToken] = tradeType === TradeType.EXACT_INPUT
|
|
15558
|
+
? [tokenIn, tokenOut] : [tokenOut, tokenIn];
|
|
15559
|
+
const amountSpecified = newAmount(amount, tokenSpecified);
|
|
15560
|
+
const fees = new Fees(secondaryFees, tokenIn);
|
|
15593
15561
|
const ourQuoteReqAmount = getOurQuoteReqAmount(amountSpecified, fees, tradeType);
|
|
15594
15562
|
// get quote and gas details
|
|
15595
15563
|
const [ourQuote, gasPrice] = await Promise.all([
|
package/dist/checkout_widgets.js
CHANGED
|
@@ -4,7 +4,7 @@ import { useEffect } from 'react';
|
|
|
4
4
|
function $parcel$export(e, n, v, s) {
|
|
5
5
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
6
6
|
}
|
|
7
|
-
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.
|
|
7
|
+
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.14.0-alpha";
|
|
8
8
|
const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
|
|
9
9
|
const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
|
|
10
10
|
|
|
@@ -270,6 +270,14 @@ declare namespace ERC721Hybrid {
|
|
|
270
270
|
to: string;
|
|
271
271
|
quantity: BigNumber;
|
|
272
272
|
};
|
|
273
|
+
type IDBurnStruct = {
|
|
274
|
+
owner: PromiseOrValue<string>;
|
|
275
|
+
tokenIds: PromiseOrValue<BigNumberish>[];
|
|
276
|
+
};
|
|
277
|
+
type IDBurnStructOutput = [string, BigNumber[]] & {
|
|
278
|
+
owner: string;
|
|
279
|
+
tokenIds: BigNumber[];
|
|
280
|
+
};
|
|
273
281
|
type TransferRequestStruct = {
|
|
274
282
|
from: PromiseOrValue<string>;
|
|
275
283
|
tos: PromiseOrValue<string>[];
|
|
@@ -285,7 +293,8 @@ declare namespace ERC721Hybrid {
|
|
|
285
293
|
type Mint = ERC721Hybrid.MintStruct;
|
|
286
294
|
type IDMint = ERC721Hybrid.IDMintStruct;
|
|
287
295
|
type TransferRequest = ERC721Hybrid.TransferRequestStruct;
|
|
288
|
-
|
|
296
|
+
type IDBurn = ERC721Hybrid.IDBurnStruct;
|
|
297
|
+
declare class ERC721 {
|
|
289
298
|
private readonly contract;
|
|
290
299
|
constructor(contractAddress: string);
|
|
291
300
|
/**
|
|
@@ -388,6 +397,18 @@ declare class ERC721HybridPermissionedMintable {
|
|
|
388
397
|
populateBurnBatch(tokenIds: PromiseOrValue<BigNumberish>[], overrides?: Overrides & {
|
|
389
398
|
from?: PromiseOrValue<string>;
|
|
390
399
|
}): Promise<PopulatedTransaction>;
|
|
400
|
+
/**
|
|
401
|
+
* @returns a populated transaction for the safe burn contract function
|
|
402
|
+
*/
|
|
403
|
+
populateSafeBurn(owner: PromiseOrValue<string>, tokenId: PromiseOrValue<BigNumberish>, overrides?: Overrides & {
|
|
404
|
+
from?: PromiseOrValue<string>;
|
|
405
|
+
}): Promise<PopulatedTransaction>;
|
|
406
|
+
/**
|
|
407
|
+
* @returns a populated transaction for the safe burn batch contract function
|
|
408
|
+
*/
|
|
409
|
+
populateSafeBurnBatch(burns: IDBurn[], overrides?: Overrides & {
|
|
410
|
+
from?: PromiseOrValue<string>;
|
|
411
|
+
}): Promise<PopulatedTransaction>;
|
|
391
412
|
/**
|
|
392
413
|
* @returns a populated transaction for the grantMinterRole contract function
|
|
393
414
|
*/
|
|
@@ -403,13 +424,13 @@ declare class ERC721HybridPermissionedMintable {
|
|
|
403
424
|
/**
|
|
404
425
|
* @returns a populated transaction for the mint by ID contract function
|
|
405
426
|
*/
|
|
406
|
-
|
|
427
|
+
populateMint(to: PromiseOrValue<string>, tokenId: PromiseOrValue<BigNumberish>, overrides?: Overrides & {
|
|
407
428
|
from?: PromiseOrValue<string>;
|
|
408
429
|
}): Promise<PopulatedTransaction>;
|
|
409
430
|
/**
|
|
410
431
|
* @returns a populated transaction for the safe mint by ID contract function
|
|
411
432
|
*/
|
|
412
|
-
|
|
433
|
+
populateSafeMint(to: PromiseOrValue<string>, tokenId: PromiseOrValue<BigNumberish>, overrides?: Overrides & {
|
|
413
434
|
from?: PromiseOrValue<string>;
|
|
414
435
|
}): Promise<PopulatedTransaction>;
|
|
415
436
|
/**
|
|
@@ -427,25 +448,25 @@ declare class ERC721HybridPermissionedMintable {
|
|
|
427
448
|
/**
|
|
428
449
|
* @returns a populated transaction for the batch mint by quantity contract function
|
|
429
450
|
*/
|
|
430
|
-
|
|
451
|
+
populateMintBatchByQuantity(mints: Mint[], overrides?: Overrides & {
|
|
431
452
|
from?: PromiseOrValue<string>;
|
|
432
453
|
}): Promise<PopulatedTransaction>;
|
|
433
454
|
/**
|
|
434
455
|
* @returns a populated transaction for the batch safe mint by quantity contract function
|
|
435
456
|
*/
|
|
436
|
-
|
|
457
|
+
populateSafeMintBatchByQuantity(mints: Mint[], overrides?: Overrides & {
|
|
437
458
|
from?: PromiseOrValue<string>;
|
|
438
459
|
}): Promise<PopulatedTransaction>;
|
|
439
460
|
/**
|
|
440
461
|
* @returns a populated transaction for the batch mint by ID to multiple recipients contract function
|
|
441
462
|
*/
|
|
442
|
-
|
|
463
|
+
populateMintBatch(mints: IDMint[], overrides?: Overrides & {
|
|
443
464
|
from?: PromiseOrValue<string>;
|
|
444
465
|
}): Promise<PopulatedTransaction>;
|
|
445
466
|
/**
|
|
446
467
|
* @returns a populated transaction for the batch safe mint by ID to multiple recipients contract function
|
|
447
468
|
*/
|
|
448
|
-
|
|
469
|
+
populateSafeMintBatch(mints: IDMint[], overrides?: Overrides & {
|
|
449
470
|
from?: PromiseOrValue<string>;
|
|
450
471
|
}): Promise<PopulatedTransaction>;
|
|
451
472
|
/**
|
|
@@ -528,4 +549,4 @@ declare class ERC721HybridPermissionedMintable {
|
|
|
528
549
|
}): Promise<PopulatedTransaction>;
|
|
529
550
|
}
|
|
530
551
|
|
|
531
|
-
export {
|
|
552
|
+
export { ERC721 };
|