@imtbl/sdk 0.15.1-alpha → 0.15.2-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 +66 -76
- package/dist/checkout_widgets.js +1 -1
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +6 -6
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +70 -80
- package/dist/index.js +70 -80
- package/dist/passport.js +2 -2
- package/package.json +1 -1
package/dist/checkout_sdk.js
CHANGED
|
@@ -17264,13 +17264,6 @@ var $4b58188d47aafe8d$export$537fa3efd10ed435;
|
|
|
17264
17264
|
GasTokenType["NATIVE"] = "NATIVE";
|
|
17265
17265
|
GasTokenType["ERC20"] = "ERC20";
|
|
17266
17266
|
})($4b58188d47aafe8d$export$537fa3efd10ed435 || ($4b58188d47aafe8d$export$537fa3efd10ed435 = {}));
|
|
17267
|
-
var $4b58188d47aafe8d$export$5d3b0ad129b9b98e;
|
|
17268
|
-
(function(TransactionRequirementType) {
|
|
17269
|
-
TransactionRequirementType["GAS"] = "GAS";
|
|
17270
|
-
TransactionRequirementType["NATIVE"] = "NATIVE";
|
|
17271
|
-
TransactionRequirementType["ERC20"] = "ERC20";
|
|
17272
|
-
TransactionRequirementType["ERC721"] = "ERC721";
|
|
17273
|
-
})($4b58188d47aafe8d$export$5d3b0ad129b9b98e || ($4b58188d47aafe8d$export$5d3b0ad129b9b98e = {}));
|
|
17274
17267
|
|
|
17275
17268
|
|
|
17276
17269
|
|
|
@@ -17724,13 +17717,19 @@ const $dbe95599a4661140$export$8e0e7ffc78696d30 = async (web3Provider, transacti
|
|
|
17724
17717
|
|
|
17725
17718
|
|
|
17726
17719
|
|
|
17720
|
+
const $dff2555fa96dda9a$var$doesChainSupportEIP1559 = (feeData)=>!!feeData.maxFeePerGas && !!feeData.maxPriorityFeePerGas;
|
|
17721
|
+
const $dff2555fa96dda9a$export$aa28f3111c524ec5 = (feeData)=>{
|
|
17722
|
+
if ($dff2555fa96dda9a$var$doesChainSupportEIP1559(feeData)) return (BigNumber$1).from(feeData.maxFeePerGas).add((BigNumber$1).from(feeData.maxPriorityFeePerGas));
|
|
17723
|
+
if (feeData.gasPrice) return (BigNumber$1).from(feeData.gasPrice);
|
|
17724
|
+
return null;
|
|
17725
|
+
};
|
|
17726
|
+
|
|
17727
|
+
|
|
17727
17728
|
const $570856c68db0bd36$var$GAS_LIMIT = 140000;
|
|
17728
|
-
const $570856c68db0bd36$var$doesChainSupportEIP1559 = (feeData)=>!!feeData.maxFeePerGas && !!feeData.maxPriorityFeePerGas;
|
|
17729
|
-
const $570856c68db0bd36$var$getGasPriceInWei = (feeData)=>$570856c68db0bd36$var$doesChainSupportEIP1559(feeData) ? (BigNumber$1).from(feeData.maxFeePerGas).add((BigNumber$1).from(feeData.maxPriorityFeePerGas)) : feeData.gasPrice && (BigNumber$1).from(feeData.gasPrice);
|
|
17730
17729
|
const $570856c68db0bd36$var$getGasEstimates = async (provider)=>{
|
|
17731
17730
|
const txnGasLimitInWei = $570856c68db0bd36$var$GAS_LIMIT; // todo: fetch gasLimit from bridgeSDK when they add new fn
|
|
17732
17731
|
const feeData = await provider.getFeeData();
|
|
17733
|
-
const gasPriceInWei = $
|
|
17732
|
+
const gasPriceInWei = ($dff2555fa96dda9a$export$aa28f3111c524ec5)(feeData);
|
|
17734
17733
|
if (!gasPriceInWei) return undefined;
|
|
17735
17734
|
return gasPriceInWei.mul(txnGasLimitInWei);
|
|
17736
17735
|
};
|
|
@@ -18007,8 +18006,6 @@ async function $2e7bf45a7c9a9570$export$942c8de7174809fc(params, readOnlyProvide
|
|
|
18007
18006
|
|
|
18008
18007
|
|
|
18009
18008
|
|
|
18010
|
-
|
|
18011
|
-
|
|
18012
18009
|
const $ddc6bcd0896481e5$export$2fbfa41a4de56a89 = (erc20allowances, erc721allowances)=>{
|
|
18013
18010
|
const aggregatedAllowances = [];
|
|
18014
18011
|
if (!erc20allowances.sufficient) {
|
|
@@ -18377,12 +18374,9 @@ const $aa6caea9a60d18c7$export$f96d1c819a615a64 = (itemRequirements)=>$aa6caea9a
|
|
|
18377
18374
|
|
|
18378
18375
|
const $73d2282a108cc7e2$export$ed7929b58bab85da = (itemRequirements)=>itemRequirements.map((itemRequirement)=>{
|
|
18379
18376
|
if (itemRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) return {
|
|
18380
|
-
name: "IMX",
|
|
18381
|
-
symbol: "IMX",
|
|
18382
18377
|
address: ($d85ad1457a3f1a83$export$b80040cb173ba6e9)
|
|
18383
18378
|
};
|
|
18384
18379
|
return {
|
|
18385
|
-
name: itemRequirement.type,
|
|
18386
18380
|
address: itemRequirement.contractAddress
|
|
18387
18381
|
};
|
|
18388
18382
|
});
|
|
@@ -18398,6 +18392,7 @@ const $73d2282a108cc7e2$export$9b757e40b19984c3 = (itemRequirement, balances)=>{
|
|
|
18398
18392
|
const delta = requiredBalance.sub(itemBalanceResult?.balance ?? (BigNumber$1).from(0));
|
|
18399
18393
|
let erc721BalanceResult = itemBalanceResult;
|
|
18400
18394
|
if (!erc721BalanceResult) erc721BalanceResult = {
|
|
18395
|
+
type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721,
|
|
18401
18396
|
balance: (BigNumber$1).from(0),
|
|
18402
18397
|
formattedBalance: "0",
|
|
18403
18398
|
contractAddress: itemRequirement.contractAddress,
|
|
@@ -18405,7 +18400,7 @@ const $73d2282a108cc7e2$export$9b757e40b19984c3 = (itemRequirement, balances)=>{
|
|
|
18405
18400
|
};
|
|
18406
18401
|
return {
|
|
18407
18402
|
sufficient: sufficient,
|
|
18408
|
-
type:
|
|
18403
|
+
type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721,
|
|
18409
18404
|
delta: {
|
|
18410
18405
|
balance: delta,
|
|
18411
18406
|
formattedBalance: delta.toString()
|
|
@@ -18425,23 +18420,30 @@ const $73d2282a108cc7e2$export$6ab9757fda54db7e = (itemRequirement, balances)=>{
|
|
|
18425
18420
|
return balance.token?.address === itemRequirement.contractAddress;
|
|
18426
18421
|
});
|
|
18427
18422
|
else if (itemRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) itemBalanceResult = balances.find((balance)=>{
|
|
18428
|
-
return
|
|
18423
|
+
return balance.token?.address === "" || balance.token?.address === ($d85ad1457a3f1a83$export$b80040cb173ba6e9);
|
|
18429
18424
|
});
|
|
18430
18425
|
// Calculate the balance delta
|
|
18431
18426
|
const requiredBalance = itemRequirement.amount;
|
|
18432
18427
|
const sufficient = requiredBalance.isNegative() || requiredBalance.isZero() || (itemBalanceResult?.balance.gte(requiredBalance) ?? false);
|
|
18433
18428
|
const delta = requiredBalance.sub(itemBalanceResult?.balance ?? (BigNumber$1).from(0));
|
|
18429
|
+
let name = "";
|
|
18430
|
+
let symbol = "";
|
|
18434
18431
|
let decimals = ($d85ad1457a3f1a83$export$903389470ba9433c);
|
|
18435
|
-
if (itemBalanceResult)
|
|
18432
|
+
if (itemBalanceResult) {
|
|
18433
|
+
decimals = itemBalanceResult.token?.decimals ?? ($d85ad1457a3f1a83$export$903389470ba9433c);
|
|
18434
|
+
name = itemBalanceResult.token.name;
|
|
18435
|
+
symbol = itemBalanceResult.token.symbol;
|
|
18436
|
+
}
|
|
18436
18437
|
let tokenBalanceResult = itemBalanceResult;
|
|
18437
18438
|
if (itemRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) {
|
|
18438
18439
|
// No token balance so mark as zero native
|
|
18439
18440
|
if (!tokenBalanceResult) tokenBalanceResult = {
|
|
18441
|
+
type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE,
|
|
18440
18442
|
balance: (BigNumber$1).from(0),
|
|
18441
18443
|
formattedBalance: "0",
|
|
18442
18444
|
token: {
|
|
18443
|
-
name:
|
|
18444
|
-
symbol:
|
|
18445
|
+
name: name,
|
|
18446
|
+
symbol: symbol,
|
|
18445
18447
|
decimals: ($d85ad1457a3f1a83$export$903389470ba9433c),
|
|
18446
18448
|
address: ($d85ad1457a3f1a83$export$b80040cb173ba6e9)
|
|
18447
18449
|
}
|
|
@@ -18453,9 +18455,13 @@ const $73d2282a108cc7e2$export$6ab9757fda54db7e = (itemRequirement, balances)=>{
|
|
|
18453
18455
|
balance: delta,
|
|
18454
18456
|
formattedBalance: (utils).formatUnits(delta, decimals)
|
|
18455
18457
|
},
|
|
18456
|
-
current:
|
|
18458
|
+
current: {
|
|
18459
|
+
...tokenBalanceResult,
|
|
18460
|
+
type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE
|
|
18461
|
+
},
|
|
18457
18462
|
required: {
|
|
18458
18463
|
...tokenBalanceResult,
|
|
18464
|
+
type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE,
|
|
18459
18465
|
balance: (BigNumber$1).from(itemRequirement.amount),
|
|
18460
18466
|
formattedBalance: (utils).formatUnits(itemRequirement.amount, decimals)
|
|
18461
18467
|
}
|
|
@@ -18463,10 +18469,14 @@ const $73d2282a108cc7e2$export$6ab9757fda54db7e = (itemRequirement, balances)=>{
|
|
|
18463
18469
|
}
|
|
18464
18470
|
// No token balance so mark as zero
|
|
18465
18471
|
if (!tokenBalanceResult) tokenBalanceResult = {
|
|
18472
|
+
type: itemRequirement.type,
|
|
18466
18473
|
balance: (BigNumber$1).from(0),
|
|
18467
18474
|
formattedBalance: "0",
|
|
18468
18475
|
token: {
|
|
18469
|
-
|
|
18476
|
+
name: name,
|
|
18477
|
+
symbol: symbol,
|
|
18478
|
+
address: itemRequirement.contractAddress,
|
|
18479
|
+
decimals: decimals
|
|
18470
18480
|
}
|
|
18471
18481
|
};
|
|
18472
18482
|
return {
|
|
@@ -18508,11 +18518,11 @@ const $73d2282a108cc7e2$export$6ab9757fda54db7e = (itemRequirement, balances)=>{
|
|
|
18508
18518
|
// Setup maps to be able to link data back to the associated promises
|
|
18509
18519
|
const erc721s = new Map();
|
|
18510
18520
|
const erc721OwnershipPromises = new Map();
|
|
18511
|
-
itemRequirements.
|
|
18512
|
-
|
|
18513
|
-
const contract = new (Contract$1)(
|
|
18514
|
-
erc721s.set(
|
|
18515
|
-
erc721OwnershipPromises.set(
|
|
18521
|
+
itemRequirements.forEach((itemRequirement)=>{
|
|
18522
|
+
if (itemRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721) return;
|
|
18523
|
+
const contract = new (Contract$1)(itemRequirement.contractAddress, JSON.stringify(($d85ad1457a3f1a83$export$8b8be7a2a654f23e)), provider);
|
|
18524
|
+
erc721s.set(itemRequirement.contractAddress, itemRequirement);
|
|
18525
|
+
erc721OwnershipPromises.set(itemRequirement.contractAddress, contract.ownerOf(itemRequirement.id));
|
|
18516
18526
|
});
|
|
18517
18527
|
try {
|
|
18518
18528
|
// Convert ERC721 ownership into a balance result
|
|
@@ -18523,6 +18533,7 @@ const $73d2282a108cc7e2$export$6ab9757fda54db7e = (itemRequirement, balances)=>{
|
|
|
18523
18533
|
let itemCount = 0;
|
|
18524
18534
|
if (itemRequirement && ownerAddress === erc721OwnerAddress) itemCount = 1;
|
|
18525
18535
|
erc721Balances.push({
|
|
18536
|
+
type: (0, $4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721,
|
|
18526
18537
|
balance: (0, BigNumber$1).from(itemCount),
|
|
18527
18538
|
formattedBalance: itemCount.toString(),
|
|
18528
18539
|
contractAddress: itemRequirement.contractAddress,
|
|
@@ -18574,7 +18585,7 @@ const $beb896e098e41faf$export$ddfc885f43c3cb6e = async (config, provider, owner
|
|
|
18574
18585
|
}, true);
|
|
18575
18586
|
return {
|
|
18576
18587
|
sufficient: sufficient,
|
|
18577
|
-
|
|
18588
|
+
balanceRequirements: balanceRequirements
|
|
18578
18589
|
};
|
|
18579
18590
|
};
|
|
18580
18591
|
|
|
@@ -18585,12 +18596,7 @@ const $beb896e098e41faf$export$ddfc885f43c3cb6e = async (config, provider, owner
|
|
|
18585
18596
|
|
|
18586
18597
|
|
|
18587
18598
|
|
|
18588
|
-
|
|
18589
|
-
const $7d1bfafb81e64d74$var$getGasPriceInWei = (feeData)=>{
|
|
18590
|
-
if ($7d1bfafb81e64d74$var$doesChainSupportEIP1559(feeData)) return (BigNumber$1).from(feeData.maxFeePerGas).add((BigNumber$1).from(feeData.maxPriorityFeePerGas));
|
|
18591
|
-
if (feeData.gasPrice) return (BigNumber$1).from(feeData.gasPrice);
|
|
18592
|
-
return undefined;
|
|
18593
|
-
};
|
|
18599
|
+
|
|
18594
18600
|
const $7d1bfafb81e64d74$export$e0580ae1f48db848 = async (provider, transaction)=>{
|
|
18595
18601
|
try {
|
|
18596
18602
|
return await provider.estimateGas(transaction);
|
|
@@ -18623,9 +18629,11 @@ const $7d1bfafb81e64d74$export$3a4140bd9e983e4e = async (provider, insufficientI
|
|
|
18623
18629
|
if (transactionOrGas.type === ($4b58188d47aafe8d$export$65c64e46348ee3c1).TRANSACTION) estimateGasPromises.push($7d1bfafb81e64d74$export$e0580ae1f48db848(provider, transactionOrGas.transaction));
|
|
18624
18630
|
else {
|
|
18625
18631
|
const feeData = await provider.getFeeData();
|
|
18626
|
-
const gasPrice = $
|
|
18627
|
-
|
|
18628
|
-
|
|
18632
|
+
const gasPrice = ($dff2555fa96dda9a$export$aa28f3111c524ec5)(feeData);
|
|
18633
|
+
if (gasPrice !== null) {
|
|
18634
|
+
const gas = gasPrice?.mul(transactionOrGas.gasToken.limit);
|
|
18635
|
+
if (gas) totalGas = totalGas.add(gas);
|
|
18636
|
+
}
|
|
18629
18637
|
}
|
|
18630
18638
|
// Get the gas estimates for all the transactions and calculate the total gas
|
|
18631
18639
|
const gasEstimatePromises = await Promise.all(estimateGasPromises);
|
|
@@ -18637,57 +18645,39 @@ const $7d1bfafb81e64d74$export$3a4140bd9e983e4e = async (provider, insufficientI
|
|
|
18637
18645
|
};
|
|
18638
18646
|
|
|
18639
18647
|
|
|
18648
|
+
|
|
18649
|
+
|
|
18650
|
+
const $0e7419077c373b24$export$4a2a19d99fef3b1b = (balanceCheckResult)=>{
|
|
18651
|
+
let sufficient = true;
|
|
18652
|
+
const transactionRequirements = [];
|
|
18653
|
+
for (const balance of balanceCheckResult.balanceRequirements){
|
|
18654
|
+
if (!balance.sufficient) sufficient = false;
|
|
18655
|
+
transactionRequirements.push({
|
|
18656
|
+
type: balance.type,
|
|
18657
|
+
sufficient: balance.sufficient,
|
|
18658
|
+
required: balance.required,
|
|
18659
|
+
current: balance.current,
|
|
18660
|
+
delta: balance.delta
|
|
18661
|
+
});
|
|
18662
|
+
}
|
|
18663
|
+
return {
|
|
18664
|
+
sufficient: sufficient,
|
|
18665
|
+
transactionRequirements: transactionRequirements
|
|
18666
|
+
};
|
|
18667
|
+
};
|
|
18640
18668
|
const $0e7419077c373b24$export$9e073f9ada8c81e6 = async (config, provider, itemRequirements, transactionOrGasAmount)=>{
|
|
18641
|
-
// eslint-disable-next-line no-console
|
|
18642
|
-
console.log(provider, itemRequirements, transactionOrGasAmount);
|
|
18643
18669
|
const ownerAddress = await provider.getSigner().getAddress();
|
|
18644
18670
|
let aggregatedItems = ($074f75878f618031$export$c804c9ade5c28607)(itemRequirements);
|
|
18645
18671
|
const erc20Allowances = await ($fc8b338399d890f3$export$d93c00812189e36)(provider, ownerAddress, aggregatedItems);
|
|
18646
18672
|
const erc721Allowances = await ($35c3fc7013888ba5$export$be546c525d418988)(provider, ownerAddress, aggregatedItems);
|
|
18647
|
-
// eslint-disable-next-line no-console
|
|
18648
|
-
console.log("ERC20 Allowances", erc20Allowances);
|
|
18649
|
-
// eslint-disable-next-line no-console
|
|
18650
|
-
console.log("ERC721 Allowances", erc721Allowances);
|
|
18651
18673
|
const aggregatedAllowances = ($ddc6bcd0896481e5$export$2fbfa41a4de56a89)(erc20Allowances, erc721Allowances);
|
|
18652
18674
|
const gasItem = await ($7d1bfafb81e64d74$export$3a4140bd9e983e4e)(provider, aggregatedAllowances, transactionOrGasAmount);
|
|
18653
18675
|
if (gasItem !== null) {
|
|
18654
18676
|
aggregatedItems.push(gasItem);
|
|
18655
18677
|
aggregatedItems = ($074f75878f618031$export$c804c9ade5c28607)(aggregatedItems);
|
|
18656
18678
|
}
|
|
18657
|
-
// eslint-disable-next-line no-console
|
|
18658
|
-
console.log("Aggregated Items", aggregatedItems);
|
|
18659
18679
|
const balanceRequirements = await ($beb896e098e41faf$export$ddfc885f43c3cb6e)(config, provider, ownerAddress, aggregatedItems);
|
|
18660
|
-
|
|
18661
|
-
console.log("Balance Requirements", balanceRequirements);
|
|
18662
|
-
return {
|
|
18663
|
-
sufficient: true,
|
|
18664
|
-
transactionRequirements: [
|
|
18665
|
-
{
|
|
18666
|
-
type: ($4b58188d47aafe8d$export$5d3b0ad129b9b98e).GAS,
|
|
18667
|
-
sufficient: true,
|
|
18668
|
-
required: {
|
|
18669
|
-
balance: (BigNumber$1).from(0),
|
|
18670
|
-
formattedBalance: "0",
|
|
18671
|
-
token: {
|
|
18672
|
-
name: "IMX",
|
|
18673
|
-
symbol: "IMX",
|
|
18674
|
-
address: "0x0",
|
|
18675
|
-
decimals: 18
|
|
18676
|
-
}
|
|
18677
|
-
},
|
|
18678
|
-
current: {
|
|
18679
|
-
balance: (BigNumber$1).from(1),
|
|
18680
|
-
formattedBalance: "1",
|
|
18681
|
-
token: {
|
|
18682
|
-
name: "IMX",
|
|
18683
|
-
symbol: "IMX",
|
|
18684
|
-
address: "0x0",
|
|
18685
|
-
decimals: 18
|
|
18686
|
-
}
|
|
18687
|
-
}
|
|
18688
|
-
}
|
|
18689
|
-
]
|
|
18690
|
-
};
|
|
18680
|
+
return $0e7419077c373b24$export$4a2a19d99fef3b1b(balanceRequirements);
|
|
18691
18681
|
};
|
|
18692
18682
|
|
|
18693
18683
|
|
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.15.
|
|
7
|
+
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.15.2-alpha";
|
|
8
8
|
const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
|
|
9
9
|
const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
|
|
10
10
|
|
|
@@ -16,7 +16,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
16
16
|
chainID,
|
|
17
17
|
coreContractAddress,
|
|
18
18
|
registrationContractAddress,
|
|
19
|
-
sdkVersion: 'ts-immutable-sdk-0.15.
|
|
19
|
+
sdkVersion: 'ts-immutable-sdk-0.15.2-alpha',
|
|
20
20
|
});
|
|
21
21
|
/**
|
|
22
22
|
* Sets `sdkVersion` at the time of build
|