@imtbl/sdk 0.45.2 → 0.45.4
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 +4 -4
- package/dist/browser/checkout/widgets.js +59 -59
- package/dist/checkout.d.ts +3 -1
- package/dist/checkout.js +415 -19
- package/dist/index.browser.js +12 -12
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +417 -21
- package/dist/index.d.ts +3 -1
- package/dist/index.js +417 -21
- package/dist/passport.js +2 -2
- package/dist/x.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10619,7 +10619,7 @@ class MultiRollupApiClients {
|
|
|
10619
10619
|
}
|
|
10620
10620
|
|
|
10621
10621
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
10622
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.45.
|
|
10622
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.45.4' };
|
|
10623
10623
|
const createConfig = ({ basePath, headers, }) => {
|
|
10624
10624
|
if (!basePath.trim()) {
|
|
10625
10625
|
throw Error('basePath can not be empty');
|
|
@@ -10691,7 +10691,7 @@ class APIError extends Error {
|
|
|
10691
10691
|
|
|
10692
10692
|
/* eslint-disable implicit-arrow-linebreak */
|
|
10693
10693
|
const defaultHeaders = {
|
|
10694
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.45.
|
|
10694
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.45.4',
|
|
10695
10695
|
};
|
|
10696
10696
|
/**
|
|
10697
10697
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -11130,7 +11130,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
11130
11130
|
chainID,
|
|
11131
11131
|
coreContractAddress,
|
|
11132
11132
|
registrationContractAddress,
|
|
11133
|
-
sdkVersion: 'ts-immutable-sdk-0.45.
|
|
11133
|
+
sdkVersion: 'ts-immutable-sdk-0.45.4',
|
|
11134
11134
|
});
|
|
11135
11135
|
/**
|
|
11136
11136
|
* Sets `sdkVersion` at the time of build
|
|
@@ -36460,7 +36460,7 @@ class ApproveError extends ExchangeError {
|
|
|
36460
36460
|
/* Autogenerated file. Do not edit manually. */
|
|
36461
36461
|
/* tslint:disable */
|
|
36462
36462
|
/* eslint-disable */
|
|
36463
|
-
const _abi$
|
|
36463
|
+
const _abi$4 = [
|
|
36464
36464
|
{
|
|
36465
36465
|
constant: true,
|
|
36466
36466
|
inputs: [],
|
|
@@ -36683,19 +36683,19 @@ const _abi$3 = [
|
|
|
36683
36683
|
},
|
|
36684
36684
|
];
|
|
36685
36685
|
class ERC20__factory {
|
|
36686
|
-
static abi = _abi$
|
|
36686
|
+
static abi = _abi$4;
|
|
36687
36687
|
static createInterface() {
|
|
36688
|
-
return new utils$3.Interface(_abi$
|
|
36688
|
+
return new utils$3.Interface(_abi$4);
|
|
36689
36689
|
}
|
|
36690
36690
|
static connect(address, signerOrProvider) {
|
|
36691
|
-
return new Contract$1(address, _abi$
|
|
36691
|
+
return new Contract$1(address, _abi$4, signerOrProvider);
|
|
36692
36692
|
}
|
|
36693
36693
|
}
|
|
36694
36694
|
|
|
36695
36695
|
/* Autogenerated file. Do not edit manually. */
|
|
36696
36696
|
/* tslint:disable */
|
|
36697
36697
|
/* eslint-disable */
|
|
36698
|
-
const _abi$
|
|
36698
|
+
const _abi$3 = [
|
|
36699
36699
|
{
|
|
36700
36700
|
inputs: [
|
|
36701
36701
|
{
|
|
@@ -37469,7 +37469,7 @@ class ImmutableSwapProxy__factory extends ContractFactory {
|
|
|
37469
37469
|
super(...args);
|
|
37470
37470
|
}
|
|
37471
37471
|
else {
|
|
37472
|
-
super(_abi$
|
|
37472
|
+
super(_abi$3, _bytecode$2, args[0]);
|
|
37473
37473
|
}
|
|
37474
37474
|
}
|
|
37475
37475
|
deploy(_admin, _uniRouter, _wimx, overrides) {
|
|
@@ -37485,19 +37485,19 @@ class ImmutableSwapProxy__factory extends ContractFactory {
|
|
|
37485
37485
|
return super.connect(signer);
|
|
37486
37486
|
}
|
|
37487
37487
|
static bytecode = _bytecode$2;
|
|
37488
|
-
static abi = _abi$
|
|
37488
|
+
static abi = _abi$3;
|
|
37489
37489
|
static createInterface() {
|
|
37490
|
-
return new utils$3.Interface(_abi$
|
|
37490
|
+
return new utils$3.Interface(_abi$3);
|
|
37491
37491
|
}
|
|
37492
37492
|
static connect(address, signerOrProvider) {
|
|
37493
|
-
return new Contract$1(address, _abi$
|
|
37493
|
+
return new Contract$1(address, _abi$3, signerOrProvider);
|
|
37494
37494
|
}
|
|
37495
37495
|
}
|
|
37496
37496
|
|
|
37497
37497
|
/* Autogenerated file. Do not edit manually. */
|
|
37498
37498
|
/* tslint:disable */
|
|
37499
37499
|
/* eslint-disable */
|
|
37500
|
-
const _abi$
|
|
37500
|
+
const _abi$2 = [
|
|
37501
37501
|
{
|
|
37502
37502
|
inputs: [],
|
|
37503
37503
|
name: "getCurrentBlockTimestamp",
|
|
@@ -37597,7 +37597,7 @@ class Multicall__factory extends ContractFactory {
|
|
|
37597
37597
|
super(...args);
|
|
37598
37598
|
}
|
|
37599
37599
|
else {
|
|
37600
|
-
super(_abi$
|
|
37600
|
+
super(_abi$2, _bytecode$1, args[0]);
|
|
37601
37601
|
}
|
|
37602
37602
|
}
|
|
37603
37603
|
deploy(overrides) {
|
|
@@ -37613,19 +37613,19 @@ class Multicall__factory extends ContractFactory {
|
|
|
37613
37613
|
return super.connect(signer);
|
|
37614
37614
|
}
|
|
37615
37615
|
static bytecode = _bytecode$1;
|
|
37616
|
-
static abi = _abi$
|
|
37616
|
+
static abi = _abi$2;
|
|
37617
37617
|
static createInterface() {
|
|
37618
|
-
return new utils$3.Interface(_abi$
|
|
37618
|
+
return new utils$3.Interface(_abi$2);
|
|
37619
37619
|
}
|
|
37620
37620
|
static connect(address, signerOrProvider) {
|
|
37621
|
-
return new Contract$1(address, _abi$
|
|
37621
|
+
return new Contract$1(address, _abi$2, signerOrProvider);
|
|
37622
37622
|
}
|
|
37623
37623
|
}
|
|
37624
37624
|
|
|
37625
37625
|
/* Autogenerated file. Do not edit manually. */
|
|
37626
37626
|
/* tslint:disable */
|
|
37627
37627
|
/* eslint-disable */
|
|
37628
|
-
const _abi = [
|
|
37628
|
+
const _abi$1 = [
|
|
37629
37629
|
{
|
|
37630
37630
|
inputs: [],
|
|
37631
37631
|
stateMutability: "nonpayable",
|
|
@@ -38621,7 +38621,7 @@ class UniswapV3Pool__factory extends ContractFactory {
|
|
|
38621
38621
|
super(...args);
|
|
38622
38622
|
}
|
|
38623
38623
|
else {
|
|
38624
|
-
super(_abi, _bytecode, args[0]);
|
|
38624
|
+
super(_abi$1, _bytecode, args[0]);
|
|
38625
38625
|
}
|
|
38626
38626
|
}
|
|
38627
38627
|
deploy(overrides) {
|
|
@@ -38637,6 +38637,298 @@ class UniswapV3Pool__factory extends ContractFactory {
|
|
|
38637
38637
|
return super.connect(signer);
|
|
38638
38638
|
}
|
|
38639
38639
|
static bytecode = _bytecode;
|
|
38640
|
+
static abi = _abi$1;
|
|
38641
|
+
static createInterface() {
|
|
38642
|
+
return new utils$3.Interface(_abi$1);
|
|
38643
|
+
}
|
|
38644
|
+
static connect(address, signerOrProvider) {
|
|
38645
|
+
return new Contract$1(address, _abi$1, signerOrProvider);
|
|
38646
|
+
}
|
|
38647
|
+
}
|
|
38648
|
+
|
|
38649
|
+
/* Autogenerated file. Do not edit manually. */
|
|
38650
|
+
/* tslint:disable */
|
|
38651
|
+
/* eslint-disable */
|
|
38652
|
+
const _abi = [
|
|
38653
|
+
{
|
|
38654
|
+
constant: true,
|
|
38655
|
+
inputs: [],
|
|
38656
|
+
name: "name",
|
|
38657
|
+
outputs: [
|
|
38658
|
+
{
|
|
38659
|
+
name: "",
|
|
38660
|
+
type: "string",
|
|
38661
|
+
},
|
|
38662
|
+
],
|
|
38663
|
+
payable: false,
|
|
38664
|
+
stateMutability: "view",
|
|
38665
|
+
type: "function",
|
|
38666
|
+
},
|
|
38667
|
+
{
|
|
38668
|
+
constant: false,
|
|
38669
|
+
inputs: [
|
|
38670
|
+
{
|
|
38671
|
+
name: "guy",
|
|
38672
|
+
type: "address",
|
|
38673
|
+
},
|
|
38674
|
+
{
|
|
38675
|
+
name: "wad",
|
|
38676
|
+
type: "uint256",
|
|
38677
|
+
},
|
|
38678
|
+
],
|
|
38679
|
+
name: "approve",
|
|
38680
|
+
outputs: [
|
|
38681
|
+
{
|
|
38682
|
+
name: "",
|
|
38683
|
+
type: "bool",
|
|
38684
|
+
},
|
|
38685
|
+
],
|
|
38686
|
+
payable: false,
|
|
38687
|
+
stateMutability: "nonpayable",
|
|
38688
|
+
type: "function",
|
|
38689
|
+
},
|
|
38690
|
+
{
|
|
38691
|
+
constant: true,
|
|
38692
|
+
inputs: [],
|
|
38693
|
+
name: "totalSupply",
|
|
38694
|
+
outputs: [
|
|
38695
|
+
{
|
|
38696
|
+
name: "",
|
|
38697
|
+
type: "uint256",
|
|
38698
|
+
},
|
|
38699
|
+
],
|
|
38700
|
+
payable: false,
|
|
38701
|
+
stateMutability: "view",
|
|
38702
|
+
type: "function",
|
|
38703
|
+
},
|
|
38704
|
+
{
|
|
38705
|
+
constant: false,
|
|
38706
|
+
inputs: [
|
|
38707
|
+
{
|
|
38708
|
+
name: "src",
|
|
38709
|
+
type: "address",
|
|
38710
|
+
},
|
|
38711
|
+
{
|
|
38712
|
+
name: "dst",
|
|
38713
|
+
type: "address",
|
|
38714
|
+
},
|
|
38715
|
+
{
|
|
38716
|
+
name: "wad",
|
|
38717
|
+
type: "uint256",
|
|
38718
|
+
},
|
|
38719
|
+
],
|
|
38720
|
+
name: "transferFrom",
|
|
38721
|
+
outputs: [
|
|
38722
|
+
{
|
|
38723
|
+
name: "",
|
|
38724
|
+
type: "bool",
|
|
38725
|
+
},
|
|
38726
|
+
],
|
|
38727
|
+
payable: false,
|
|
38728
|
+
stateMutability: "nonpayable",
|
|
38729
|
+
type: "function",
|
|
38730
|
+
},
|
|
38731
|
+
{
|
|
38732
|
+
constant: false,
|
|
38733
|
+
inputs: [
|
|
38734
|
+
{
|
|
38735
|
+
name: "wad",
|
|
38736
|
+
type: "uint256",
|
|
38737
|
+
},
|
|
38738
|
+
],
|
|
38739
|
+
name: "withdraw",
|
|
38740
|
+
outputs: [],
|
|
38741
|
+
payable: false,
|
|
38742
|
+
stateMutability: "nonpayable",
|
|
38743
|
+
type: "function",
|
|
38744
|
+
},
|
|
38745
|
+
{
|
|
38746
|
+
constant: true,
|
|
38747
|
+
inputs: [],
|
|
38748
|
+
name: "decimals",
|
|
38749
|
+
outputs: [
|
|
38750
|
+
{
|
|
38751
|
+
name: "",
|
|
38752
|
+
type: "uint8",
|
|
38753
|
+
},
|
|
38754
|
+
],
|
|
38755
|
+
payable: false,
|
|
38756
|
+
stateMutability: "view",
|
|
38757
|
+
type: "function",
|
|
38758
|
+
},
|
|
38759
|
+
{
|
|
38760
|
+
constant: true,
|
|
38761
|
+
inputs: [
|
|
38762
|
+
{
|
|
38763
|
+
name: "",
|
|
38764
|
+
type: "address",
|
|
38765
|
+
},
|
|
38766
|
+
],
|
|
38767
|
+
name: "balanceOf",
|
|
38768
|
+
outputs: [
|
|
38769
|
+
{
|
|
38770
|
+
name: "",
|
|
38771
|
+
type: "uint256",
|
|
38772
|
+
},
|
|
38773
|
+
],
|
|
38774
|
+
payable: false,
|
|
38775
|
+
stateMutability: "view",
|
|
38776
|
+
type: "function",
|
|
38777
|
+
},
|
|
38778
|
+
{
|
|
38779
|
+
constant: true,
|
|
38780
|
+
inputs: [],
|
|
38781
|
+
name: "symbol",
|
|
38782
|
+
outputs: [
|
|
38783
|
+
{
|
|
38784
|
+
name: "",
|
|
38785
|
+
type: "string",
|
|
38786
|
+
},
|
|
38787
|
+
],
|
|
38788
|
+
payable: false,
|
|
38789
|
+
stateMutability: "view",
|
|
38790
|
+
type: "function",
|
|
38791
|
+
},
|
|
38792
|
+
{
|
|
38793
|
+
constant: false,
|
|
38794
|
+
inputs: [
|
|
38795
|
+
{
|
|
38796
|
+
name: "dst",
|
|
38797
|
+
type: "address",
|
|
38798
|
+
},
|
|
38799
|
+
{
|
|
38800
|
+
name: "wad",
|
|
38801
|
+
type: "uint256",
|
|
38802
|
+
},
|
|
38803
|
+
],
|
|
38804
|
+
name: "transfer",
|
|
38805
|
+
outputs: [
|
|
38806
|
+
{
|
|
38807
|
+
name: "",
|
|
38808
|
+
type: "bool",
|
|
38809
|
+
},
|
|
38810
|
+
],
|
|
38811
|
+
payable: false,
|
|
38812
|
+
stateMutability: "nonpayable",
|
|
38813
|
+
type: "function",
|
|
38814
|
+
},
|
|
38815
|
+
{
|
|
38816
|
+
constant: false,
|
|
38817
|
+
inputs: [],
|
|
38818
|
+
name: "deposit",
|
|
38819
|
+
outputs: [],
|
|
38820
|
+
payable: true,
|
|
38821
|
+
stateMutability: "payable",
|
|
38822
|
+
type: "function",
|
|
38823
|
+
},
|
|
38824
|
+
{
|
|
38825
|
+
constant: true,
|
|
38826
|
+
inputs: [
|
|
38827
|
+
{
|
|
38828
|
+
name: "",
|
|
38829
|
+
type: "address",
|
|
38830
|
+
},
|
|
38831
|
+
{
|
|
38832
|
+
name: "",
|
|
38833
|
+
type: "address",
|
|
38834
|
+
},
|
|
38835
|
+
],
|
|
38836
|
+
name: "allowance",
|
|
38837
|
+
outputs: [
|
|
38838
|
+
{
|
|
38839
|
+
name: "",
|
|
38840
|
+
type: "uint256",
|
|
38841
|
+
},
|
|
38842
|
+
],
|
|
38843
|
+
payable: false,
|
|
38844
|
+
stateMutability: "view",
|
|
38845
|
+
type: "function",
|
|
38846
|
+
},
|
|
38847
|
+
{
|
|
38848
|
+
payable: true,
|
|
38849
|
+
stateMutability: "payable",
|
|
38850
|
+
type: "fallback",
|
|
38851
|
+
},
|
|
38852
|
+
{
|
|
38853
|
+
anonymous: false,
|
|
38854
|
+
inputs: [
|
|
38855
|
+
{
|
|
38856
|
+
indexed: true,
|
|
38857
|
+
name: "src",
|
|
38858
|
+
type: "address",
|
|
38859
|
+
},
|
|
38860
|
+
{
|
|
38861
|
+
indexed: true,
|
|
38862
|
+
name: "guy",
|
|
38863
|
+
type: "address",
|
|
38864
|
+
},
|
|
38865
|
+
{
|
|
38866
|
+
indexed: false,
|
|
38867
|
+
name: "wad",
|
|
38868
|
+
type: "uint256",
|
|
38869
|
+
},
|
|
38870
|
+
],
|
|
38871
|
+
name: "Approval",
|
|
38872
|
+
type: "event",
|
|
38873
|
+
},
|
|
38874
|
+
{
|
|
38875
|
+
anonymous: false,
|
|
38876
|
+
inputs: [
|
|
38877
|
+
{
|
|
38878
|
+
indexed: true,
|
|
38879
|
+
name: "src",
|
|
38880
|
+
type: "address",
|
|
38881
|
+
},
|
|
38882
|
+
{
|
|
38883
|
+
indexed: true,
|
|
38884
|
+
name: "dst",
|
|
38885
|
+
type: "address",
|
|
38886
|
+
},
|
|
38887
|
+
{
|
|
38888
|
+
indexed: false,
|
|
38889
|
+
name: "wad",
|
|
38890
|
+
type: "uint256",
|
|
38891
|
+
},
|
|
38892
|
+
],
|
|
38893
|
+
name: "Transfer",
|
|
38894
|
+
type: "event",
|
|
38895
|
+
},
|
|
38896
|
+
{
|
|
38897
|
+
anonymous: false,
|
|
38898
|
+
inputs: [
|
|
38899
|
+
{
|
|
38900
|
+
indexed: true,
|
|
38901
|
+
name: "dst",
|
|
38902
|
+
type: "address",
|
|
38903
|
+
},
|
|
38904
|
+
{
|
|
38905
|
+
indexed: false,
|
|
38906
|
+
name: "wad",
|
|
38907
|
+
type: "uint256",
|
|
38908
|
+
},
|
|
38909
|
+
],
|
|
38910
|
+
name: "Deposit",
|
|
38911
|
+
type: "event",
|
|
38912
|
+
},
|
|
38913
|
+
{
|
|
38914
|
+
anonymous: false,
|
|
38915
|
+
inputs: [
|
|
38916
|
+
{
|
|
38917
|
+
indexed: true,
|
|
38918
|
+
name: "src",
|
|
38919
|
+
type: "address",
|
|
38920
|
+
},
|
|
38921
|
+
{
|
|
38922
|
+
indexed: false,
|
|
38923
|
+
name: "wad",
|
|
38924
|
+
type: "uint256",
|
|
38925
|
+
},
|
|
38926
|
+
],
|
|
38927
|
+
name: "Withdrawal",
|
|
38928
|
+
type: "event",
|
|
38929
|
+
},
|
|
38930
|
+
];
|
|
38931
|
+
class WIMX__factory {
|
|
38640
38932
|
static abi = _abi;
|
|
38641
38933
|
static createInterface() {
|
|
38642
38934
|
return new utils$3.Interface(_abi);
|
|
@@ -39265,6 +39557,13 @@ class NativeTokenService {
|
|
|
39265
39557
|
maybeWrapAmount(amount) {
|
|
39266
39558
|
return newAmount(amount.value, this.maybeWrapToken(amount.token));
|
|
39267
39559
|
}
|
|
39560
|
+
isWrappedNative(token) {
|
|
39561
|
+
return token.type === 'erc20' && token.address.toLowerCase() === this.wrappedToken.address.toLowerCase();
|
|
39562
|
+
}
|
|
39563
|
+
isWrapOrUnwrap(tokenIn, tokenOut) {
|
|
39564
|
+
return ((tokenIn === this.nativeToken && (this.isWrappedNative(tokenOut))) ||
|
|
39565
|
+
((this.isWrappedNative(tokenIn)) && tokenOut === this.nativeToken));
|
|
39566
|
+
}
|
|
39268
39567
|
}
|
|
39269
39568
|
|
|
39270
39569
|
// slippageToPercent takes the slippage as a percentage (e.g. 0.1) and
|
|
@@ -39363,6 +39662,16 @@ class Fees {
|
|
|
39363
39662
|
}
|
|
39364
39663
|
}
|
|
39365
39664
|
|
|
39665
|
+
// 45038 is the upper bound of the gas estimate for the deposit function.
|
|
39666
|
+
// This upper bound is reached when a user is wrapping for the first time (cold + unused storage slot)
|
|
39667
|
+
// The lower bound is 27,938, so the difference is 17,100 gas. If transactions are 10 gwei IMX,
|
|
39668
|
+
// this is about 0.000171 IMX difference. In order to avoid an extra remote call, we just use the upper bound instead.
|
|
39669
|
+
const IMX_WRAP_GAS_COST = 45038;
|
|
39670
|
+
// 35216 is the upper bound of the gas estimate for the withdraw function.
|
|
39671
|
+
// The differenfce between upper and normal is less than 0.0001 IMX, so we just use the upper bound
|
|
39672
|
+
// to avoid an extra remote call.
|
|
39673
|
+
const IMX_UNWRAP_GAS_COST = 35216;
|
|
39674
|
+
|
|
39366
39675
|
const IMMUTABLE_TESTNET_RPC_URL = 'https://rpc.testnet.immutable.com';
|
|
39367
39676
|
const IMMUTABLE_TESTNET_CHAIN_ID = 13473;
|
|
39368
39677
|
|
|
@@ -39876,6 +40185,67 @@ class Exchange {
|
|
|
39876
40185
|
decimals,
|
|
39877
40186
|
};
|
|
39878
40187
|
}
|
|
40188
|
+
async getUnwrapTransaction(fromAddress, tokenAmount, wimxInterface, gasPrice) {
|
|
40189
|
+
const calldata = wimxInterface.encodeFunctionData('withdraw', [tokenAmount]);
|
|
40190
|
+
const gasEstimate = ethers.BigNumber.from(IMX_UNWRAP_GAS_COST);
|
|
40191
|
+
const gasFeeEstimate = gasPrice ? toPublicAmount(calculateGasFee(gasPrice, gasEstimate)) : null;
|
|
40192
|
+
// This transaction is for calling calling `withdraw` on the WETH/WIMX contract.
|
|
40193
|
+
const transactionDetails = {
|
|
40194
|
+
transaction: {
|
|
40195
|
+
data: calldata,
|
|
40196
|
+
to: this.wrappedNativeToken.address,
|
|
40197
|
+
from: fromAddress,
|
|
40198
|
+
},
|
|
40199
|
+
gasFeeEstimate,
|
|
40200
|
+
};
|
|
40201
|
+
return {
|
|
40202
|
+
transaction: transactionDetails,
|
|
40203
|
+
approval: null,
|
|
40204
|
+
};
|
|
40205
|
+
}
|
|
40206
|
+
getWrapTransaction(fromAddress, tokenAmount, wimxInterface, gasPrice) {
|
|
40207
|
+
const calldata = wimxInterface.encodeFunctionData('deposit');
|
|
40208
|
+
const gasEstimate = ethers.BigNumber.from(IMX_WRAP_GAS_COST);
|
|
40209
|
+
const gasFeeEstimate = gasPrice ? toPublicAmount(calculateGasFee(gasPrice, gasEstimate)) : null;
|
|
40210
|
+
// This transaction is for calling calling `deposit` on the WETH/WIMX contract.
|
|
40211
|
+
const transactionDetails = {
|
|
40212
|
+
transaction: {
|
|
40213
|
+
data: calldata,
|
|
40214
|
+
to: this.wrappedNativeToken.address,
|
|
40215
|
+
value: tokenAmount,
|
|
40216
|
+
from: fromAddress,
|
|
40217
|
+
},
|
|
40218
|
+
gasFeeEstimate,
|
|
40219
|
+
};
|
|
40220
|
+
return {
|
|
40221
|
+
transaction: transactionDetails,
|
|
40222
|
+
approval: null,
|
|
40223
|
+
};
|
|
40224
|
+
}
|
|
40225
|
+
async getUnsignedWrapUnwrapTx(tokenSpecified, amountIn, fromAddress, gasPrice) {
|
|
40226
|
+
const isWrap = amountIn.token.type === 'native';
|
|
40227
|
+
const quoteToken = tokenSpecified.type === 'native' ? this.wrappedNativeToken : this.nativeToken;
|
|
40228
|
+
const otherTokenCoinAmount = {
|
|
40229
|
+
token: quoteToken,
|
|
40230
|
+
value: amountIn.value,
|
|
40231
|
+
};
|
|
40232
|
+
// The quote is always 1:1 (0 {price impact, slippage}) when wrapping/unwrapping.
|
|
40233
|
+
const quote = {
|
|
40234
|
+
amount: toPublicAmount(otherTokenCoinAmount),
|
|
40235
|
+
amountWithMaxSlippage: toPublicAmount(otherTokenCoinAmount),
|
|
40236
|
+
slippage: 0,
|
|
40237
|
+
fees: [],
|
|
40238
|
+
};
|
|
40239
|
+
const wimxInterface = WIMX__factory.createInterface();
|
|
40240
|
+
let transactionDetails;
|
|
40241
|
+
if (isWrap) {
|
|
40242
|
+
transactionDetails = this.getWrapTransaction(fromAddress, otherTokenCoinAmount.value, wimxInterface, gasPrice);
|
|
40243
|
+
}
|
|
40244
|
+
else {
|
|
40245
|
+
transactionDetails = await this.getUnwrapTransaction(fromAddress, otherTokenCoinAmount.value, wimxInterface, gasPrice);
|
|
40246
|
+
}
|
|
40247
|
+
return { quote, approval: transactionDetails.approval, swap: transactionDetails.transaction };
|
|
40248
|
+
}
|
|
39879
40249
|
async getUnsignedSwapTx(fromAddress, tokenInLiteral, tokenOutLiteral, amount, slippagePercent, maxHops, deadline, tradeType) {
|
|
39880
40250
|
Exchange.validate(tokenInLiteral, tokenOutLiteral, maxHops, slippagePercent, fromAddress);
|
|
39881
40251
|
// get the decimals of the tokens that will be swapped
|
|
@@ -39891,6 +40261,11 @@ class Exchange {
|
|
|
39891
40261
|
// determine which amount was specified for the swap from the TradeType
|
|
39892
40262
|
const [tokenSpecified, otherToken] = tradeType === TradeType.EXACT_INPUT ? [tokenIn, tokenOut] : [tokenOut, tokenIn];
|
|
39893
40263
|
const amountSpecified = newAmount(amount, tokenSpecified);
|
|
40264
|
+
if (this.nativeTokenService.isWrapOrUnwrap(tokenIn, tokenOut)) {
|
|
40265
|
+
// If the user is swapping between the native token and the wrapped native token,
|
|
40266
|
+
// we want to just wrap/unwrap the native token instead of swapping
|
|
40267
|
+
return this.getUnsignedWrapUnwrapTx(tokenSpecified, newAmount(amount, tokenIn), fromAddress, gasPrice);
|
|
40268
|
+
}
|
|
39894
40269
|
const fees = new Fees(secondaryFees, tokenIn);
|
|
39895
40270
|
const ourQuoteReqAmount = getOurQuoteReqAmount(amountSpecified, fees, tradeType, this.nativeTokenService);
|
|
39896
40271
|
// Quotes will always use ERC20s. If the user-specified token is Native, we use the Wrapped Native Token pool
|
|
@@ -40177,6 +40552,7 @@ var WalletAction;
|
|
|
40177
40552
|
WalletAction["ADD_NETWORK"] = "wallet_addEthereumChain";
|
|
40178
40553
|
WalletAction["SWITCH_NETWORK"] = "wallet_switchEthereumChain";
|
|
40179
40554
|
WalletAction["GET_CHAINID"] = "eth_chainId";
|
|
40555
|
+
WalletAction["REQUEST_PERMISSIONS"] = "wallet_requestPermissions";
|
|
40180
40556
|
})(WalletAction || (WalletAction = {}));
|
|
40181
40557
|
/**
|
|
40182
40558
|
* Enum representing the platform filters used in {@link GetWalletAllowListParams}.
|
|
@@ -40887,7 +41263,7 @@ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
|
|
|
40887
41263
|
maxPriorityFeePerGas: BigNumber$1.from(10e9),
|
|
40888
41264
|
};
|
|
40889
41265
|
|
|
40890
|
-
const SDK_VERSION_MARKER = '0.45.
|
|
41266
|
+
const SDK_VERSION_MARKER = '0.45.4';
|
|
40891
41267
|
// This SDK version is replaced by the `yarn build` command ran on the root level
|
|
40892
41268
|
const globalPackageVersion = () => SDK_VERSION_MARKER;
|
|
40893
41269
|
|
|
@@ -41471,6 +41847,21 @@ async function connectSite(web3Provider) {
|
|
|
41471
41847
|
}, { type: CheckoutErrorType.USER_REJECTED_REQUEST_ERROR });
|
|
41472
41848
|
return web3Provider;
|
|
41473
41849
|
}
|
|
41850
|
+
async function requestPermissions(web3Provider) {
|
|
41851
|
+
if (!web3Provider || !web3Provider.provider?.request) {
|
|
41852
|
+
throw new CheckoutError('Incompatible provider', CheckoutErrorType.PROVIDER_REQUEST_MISSING_ERROR, { details: 'Attempting to connect with an incompatible provider' });
|
|
41853
|
+
}
|
|
41854
|
+
await withCheckoutError(async () => {
|
|
41855
|
+
if (!web3Provider.provider.request)
|
|
41856
|
+
return;
|
|
41857
|
+
await web3Provider.provider.request({
|
|
41858
|
+
method: WalletAction.REQUEST_PERMISSIONS,
|
|
41859
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
41860
|
+
params: [{ eth_accounts: {} }],
|
|
41861
|
+
});
|
|
41862
|
+
}, { type: CheckoutErrorType.USER_REJECTED_REQUEST_ERROR });
|
|
41863
|
+
return web3Provider;
|
|
41864
|
+
}
|
|
41474
41865
|
|
|
41475
41866
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
41476
41867
|
async function getMetaMaskProvider() {
|
|
@@ -44619,7 +45010,12 @@ class Checkout {
|
|
|
44619
45010
|
*/
|
|
44620
45011
|
async connect(params) {
|
|
44621
45012
|
const web3Provider = await validateProvider(this.config, params.provider, { allowUnsupportedProvider: true });
|
|
44622
|
-
|
|
45013
|
+
if (params.requestWalletPermissions && !web3Provider.provider?.isPassport) {
|
|
45014
|
+
await requestPermissions(web3Provider);
|
|
45015
|
+
}
|
|
45016
|
+
else {
|
|
45017
|
+
await connectSite(web3Provider);
|
|
45018
|
+
}
|
|
44623
45019
|
return { provider: web3Provider };
|
|
44624
45020
|
}
|
|
44625
45021
|
/**
|
package/dist/passport.js
CHANGED
|
@@ -8724,7 +8724,7 @@ class MultiRollupApiClients {
|
|
|
8724
8724
|
}
|
|
8725
8725
|
|
|
8726
8726
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
8727
|
-
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.45.
|
|
8727
|
+
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.45.4' };
|
|
8728
8728
|
const createConfig = ({ basePath, headers, }) => {
|
|
8729
8729
|
if (!basePath.trim()) {
|
|
8730
8730
|
throw Error('basePath can not be empty');
|
|
@@ -8792,7 +8792,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
8792
8792
|
chainID,
|
|
8793
8793
|
coreContractAddress,
|
|
8794
8794
|
registrationContractAddress,
|
|
8795
|
-
sdkVersion: 'ts-immutable-sdk-0.45.
|
|
8795
|
+
sdkVersion: 'ts-immutable-sdk-0.45.4',
|
|
8796
8796
|
});
|
|
8797
8797
|
/**
|
|
8798
8798
|
* Sets `sdkVersion` at the time of build
|
package/dist/x.js
CHANGED
|
@@ -23,7 +23,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
23
23
|
chainID,
|
|
24
24
|
coreContractAddress,
|
|
25
25
|
registrationContractAddress,
|
|
26
|
-
sdkVersion: 'ts-immutable-sdk-0.45.
|
|
26
|
+
sdkVersion: 'ts-immutable-sdk-0.45.4',
|
|
27
27
|
});
|
|
28
28
|
/**
|
|
29
29
|
* Sets `sdkVersion` at the time of build
|
package/package.json
CHANGED