@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.cjs
CHANGED
|
@@ -10641,7 +10641,7 @@ class MultiRollupApiClients {
|
|
|
10641
10641
|
}
|
|
10642
10642
|
|
|
10643
10643
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
10644
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.45.
|
|
10644
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.45.4' };
|
|
10645
10645
|
const createConfig = ({ basePath, headers, }) => {
|
|
10646
10646
|
if (!basePath.trim()) {
|
|
10647
10647
|
throw Error('basePath can not be empty');
|
|
@@ -10713,7 +10713,7 @@ class APIError extends Error {
|
|
|
10713
10713
|
|
|
10714
10714
|
/* eslint-disable implicit-arrow-linebreak */
|
|
10715
10715
|
const defaultHeaders = {
|
|
10716
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.45.
|
|
10716
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.45.4',
|
|
10717
10717
|
};
|
|
10718
10718
|
/**
|
|
10719
10719
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -11152,7 +11152,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
11152
11152
|
chainID,
|
|
11153
11153
|
coreContractAddress,
|
|
11154
11154
|
registrationContractAddress,
|
|
11155
|
-
sdkVersion: 'ts-immutable-sdk-0.45.
|
|
11155
|
+
sdkVersion: 'ts-immutable-sdk-0.45.4',
|
|
11156
11156
|
});
|
|
11157
11157
|
/**
|
|
11158
11158
|
* Sets `sdkVersion` at the time of build
|
|
@@ -36482,7 +36482,7 @@ class ApproveError extends ExchangeError {
|
|
|
36482
36482
|
/* Autogenerated file. Do not edit manually. */
|
|
36483
36483
|
/* tslint:disable */
|
|
36484
36484
|
/* eslint-disable */
|
|
36485
|
-
const _abi$
|
|
36485
|
+
const _abi$4 = [
|
|
36486
36486
|
{
|
|
36487
36487
|
constant: true,
|
|
36488
36488
|
inputs: [],
|
|
@@ -36705,19 +36705,19 @@ const _abi$3 = [
|
|
|
36705
36705
|
},
|
|
36706
36706
|
];
|
|
36707
36707
|
class ERC20__factory {
|
|
36708
|
-
static abi = _abi$
|
|
36708
|
+
static abi = _abi$4;
|
|
36709
36709
|
static createInterface() {
|
|
36710
|
-
return new ethers.utils.Interface(_abi$
|
|
36710
|
+
return new ethers.utils.Interface(_abi$4);
|
|
36711
36711
|
}
|
|
36712
36712
|
static connect(address, signerOrProvider) {
|
|
36713
|
-
return new ethers.Contract(address, _abi$
|
|
36713
|
+
return new ethers.Contract(address, _abi$4, signerOrProvider);
|
|
36714
36714
|
}
|
|
36715
36715
|
}
|
|
36716
36716
|
|
|
36717
36717
|
/* Autogenerated file. Do not edit manually. */
|
|
36718
36718
|
/* tslint:disable */
|
|
36719
36719
|
/* eslint-disable */
|
|
36720
|
-
const _abi$
|
|
36720
|
+
const _abi$3 = [
|
|
36721
36721
|
{
|
|
36722
36722
|
inputs: [
|
|
36723
36723
|
{
|
|
@@ -37491,7 +37491,7 @@ class ImmutableSwapProxy__factory extends ethers.ContractFactory {
|
|
|
37491
37491
|
super(...args);
|
|
37492
37492
|
}
|
|
37493
37493
|
else {
|
|
37494
|
-
super(_abi$
|
|
37494
|
+
super(_abi$3, _bytecode$2, args[0]);
|
|
37495
37495
|
}
|
|
37496
37496
|
}
|
|
37497
37497
|
deploy(_admin, _uniRouter, _wimx, overrides) {
|
|
@@ -37507,19 +37507,19 @@ class ImmutableSwapProxy__factory extends ethers.ContractFactory {
|
|
|
37507
37507
|
return super.connect(signer);
|
|
37508
37508
|
}
|
|
37509
37509
|
static bytecode = _bytecode$2;
|
|
37510
|
-
static abi = _abi$
|
|
37510
|
+
static abi = _abi$3;
|
|
37511
37511
|
static createInterface() {
|
|
37512
|
-
return new ethers.utils.Interface(_abi$
|
|
37512
|
+
return new ethers.utils.Interface(_abi$3);
|
|
37513
37513
|
}
|
|
37514
37514
|
static connect(address, signerOrProvider) {
|
|
37515
|
-
return new ethers.Contract(address, _abi$
|
|
37515
|
+
return new ethers.Contract(address, _abi$3, signerOrProvider);
|
|
37516
37516
|
}
|
|
37517
37517
|
}
|
|
37518
37518
|
|
|
37519
37519
|
/* Autogenerated file. Do not edit manually. */
|
|
37520
37520
|
/* tslint:disable */
|
|
37521
37521
|
/* eslint-disable */
|
|
37522
|
-
const _abi$
|
|
37522
|
+
const _abi$2 = [
|
|
37523
37523
|
{
|
|
37524
37524
|
inputs: [],
|
|
37525
37525
|
name: "getCurrentBlockTimestamp",
|
|
@@ -37619,7 +37619,7 @@ class Multicall__factory extends ethers.ContractFactory {
|
|
|
37619
37619
|
super(...args);
|
|
37620
37620
|
}
|
|
37621
37621
|
else {
|
|
37622
|
-
super(_abi$
|
|
37622
|
+
super(_abi$2, _bytecode$1, args[0]);
|
|
37623
37623
|
}
|
|
37624
37624
|
}
|
|
37625
37625
|
deploy(overrides) {
|
|
@@ -37635,19 +37635,19 @@ class Multicall__factory extends ethers.ContractFactory {
|
|
|
37635
37635
|
return super.connect(signer);
|
|
37636
37636
|
}
|
|
37637
37637
|
static bytecode = _bytecode$1;
|
|
37638
|
-
static abi = _abi$
|
|
37638
|
+
static abi = _abi$2;
|
|
37639
37639
|
static createInterface() {
|
|
37640
|
-
return new ethers.utils.Interface(_abi$
|
|
37640
|
+
return new ethers.utils.Interface(_abi$2);
|
|
37641
37641
|
}
|
|
37642
37642
|
static connect(address, signerOrProvider) {
|
|
37643
|
-
return new ethers.Contract(address, _abi$
|
|
37643
|
+
return new ethers.Contract(address, _abi$2, signerOrProvider);
|
|
37644
37644
|
}
|
|
37645
37645
|
}
|
|
37646
37646
|
|
|
37647
37647
|
/* Autogenerated file. Do not edit manually. */
|
|
37648
37648
|
/* tslint:disable */
|
|
37649
37649
|
/* eslint-disable */
|
|
37650
|
-
const _abi = [
|
|
37650
|
+
const _abi$1 = [
|
|
37651
37651
|
{
|
|
37652
37652
|
inputs: [],
|
|
37653
37653
|
stateMutability: "nonpayable",
|
|
@@ -38643,7 +38643,7 @@ class UniswapV3Pool__factory extends ethers.ContractFactory {
|
|
|
38643
38643
|
super(...args);
|
|
38644
38644
|
}
|
|
38645
38645
|
else {
|
|
38646
|
-
super(_abi, _bytecode, args[0]);
|
|
38646
|
+
super(_abi$1, _bytecode, args[0]);
|
|
38647
38647
|
}
|
|
38648
38648
|
}
|
|
38649
38649
|
deploy(overrides) {
|
|
@@ -38659,6 +38659,298 @@ class UniswapV3Pool__factory extends ethers.ContractFactory {
|
|
|
38659
38659
|
return super.connect(signer);
|
|
38660
38660
|
}
|
|
38661
38661
|
static bytecode = _bytecode;
|
|
38662
|
+
static abi = _abi$1;
|
|
38663
|
+
static createInterface() {
|
|
38664
|
+
return new ethers.utils.Interface(_abi$1);
|
|
38665
|
+
}
|
|
38666
|
+
static connect(address, signerOrProvider) {
|
|
38667
|
+
return new ethers.Contract(address, _abi$1, signerOrProvider);
|
|
38668
|
+
}
|
|
38669
|
+
}
|
|
38670
|
+
|
|
38671
|
+
/* Autogenerated file. Do not edit manually. */
|
|
38672
|
+
/* tslint:disable */
|
|
38673
|
+
/* eslint-disable */
|
|
38674
|
+
const _abi = [
|
|
38675
|
+
{
|
|
38676
|
+
constant: true,
|
|
38677
|
+
inputs: [],
|
|
38678
|
+
name: "name",
|
|
38679
|
+
outputs: [
|
|
38680
|
+
{
|
|
38681
|
+
name: "",
|
|
38682
|
+
type: "string",
|
|
38683
|
+
},
|
|
38684
|
+
],
|
|
38685
|
+
payable: false,
|
|
38686
|
+
stateMutability: "view",
|
|
38687
|
+
type: "function",
|
|
38688
|
+
},
|
|
38689
|
+
{
|
|
38690
|
+
constant: false,
|
|
38691
|
+
inputs: [
|
|
38692
|
+
{
|
|
38693
|
+
name: "guy",
|
|
38694
|
+
type: "address",
|
|
38695
|
+
},
|
|
38696
|
+
{
|
|
38697
|
+
name: "wad",
|
|
38698
|
+
type: "uint256",
|
|
38699
|
+
},
|
|
38700
|
+
],
|
|
38701
|
+
name: "approve",
|
|
38702
|
+
outputs: [
|
|
38703
|
+
{
|
|
38704
|
+
name: "",
|
|
38705
|
+
type: "bool",
|
|
38706
|
+
},
|
|
38707
|
+
],
|
|
38708
|
+
payable: false,
|
|
38709
|
+
stateMutability: "nonpayable",
|
|
38710
|
+
type: "function",
|
|
38711
|
+
},
|
|
38712
|
+
{
|
|
38713
|
+
constant: true,
|
|
38714
|
+
inputs: [],
|
|
38715
|
+
name: "totalSupply",
|
|
38716
|
+
outputs: [
|
|
38717
|
+
{
|
|
38718
|
+
name: "",
|
|
38719
|
+
type: "uint256",
|
|
38720
|
+
},
|
|
38721
|
+
],
|
|
38722
|
+
payable: false,
|
|
38723
|
+
stateMutability: "view",
|
|
38724
|
+
type: "function",
|
|
38725
|
+
},
|
|
38726
|
+
{
|
|
38727
|
+
constant: false,
|
|
38728
|
+
inputs: [
|
|
38729
|
+
{
|
|
38730
|
+
name: "src",
|
|
38731
|
+
type: "address",
|
|
38732
|
+
},
|
|
38733
|
+
{
|
|
38734
|
+
name: "dst",
|
|
38735
|
+
type: "address",
|
|
38736
|
+
},
|
|
38737
|
+
{
|
|
38738
|
+
name: "wad",
|
|
38739
|
+
type: "uint256",
|
|
38740
|
+
},
|
|
38741
|
+
],
|
|
38742
|
+
name: "transferFrom",
|
|
38743
|
+
outputs: [
|
|
38744
|
+
{
|
|
38745
|
+
name: "",
|
|
38746
|
+
type: "bool",
|
|
38747
|
+
},
|
|
38748
|
+
],
|
|
38749
|
+
payable: false,
|
|
38750
|
+
stateMutability: "nonpayable",
|
|
38751
|
+
type: "function",
|
|
38752
|
+
},
|
|
38753
|
+
{
|
|
38754
|
+
constant: false,
|
|
38755
|
+
inputs: [
|
|
38756
|
+
{
|
|
38757
|
+
name: "wad",
|
|
38758
|
+
type: "uint256",
|
|
38759
|
+
},
|
|
38760
|
+
],
|
|
38761
|
+
name: "withdraw",
|
|
38762
|
+
outputs: [],
|
|
38763
|
+
payable: false,
|
|
38764
|
+
stateMutability: "nonpayable",
|
|
38765
|
+
type: "function",
|
|
38766
|
+
},
|
|
38767
|
+
{
|
|
38768
|
+
constant: true,
|
|
38769
|
+
inputs: [],
|
|
38770
|
+
name: "decimals",
|
|
38771
|
+
outputs: [
|
|
38772
|
+
{
|
|
38773
|
+
name: "",
|
|
38774
|
+
type: "uint8",
|
|
38775
|
+
},
|
|
38776
|
+
],
|
|
38777
|
+
payable: false,
|
|
38778
|
+
stateMutability: "view",
|
|
38779
|
+
type: "function",
|
|
38780
|
+
},
|
|
38781
|
+
{
|
|
38782
|
+
constant: true,
|
|
38783
|
+
inputs: [
|
|
38784
|
+
{
|
|
38785
|
+
name: "",
|
|
38786
|
+
type: "address",
|
|
38787
|
+
},
|
|
38788
|
+
],
|
|
38789
|
+
name: "balanceOf",
|
|
38790
|
+
outputs: [
|
|
38791
|
+
{
|
|
38792
|
+
name: "",
|
|
38793
|
+
type: "uint256",
|
|
38794
|
+
},
|
|
38795
|
+
],
|
|
38796
|
+
payable: false,
|
|
38797
|
+
stateMutability: "view",
|
|
38798
|
+
type: "function",
|
|
38799
|
+
},
|
|
38800
|
+
{
|
|
38801
|
+
constant: true,
|
|
38802
|
+
inputs: [],
|
|
38803
|
+
name: "symbol",
|
|
38804
|
+
outputs: [
|
|
38805
|
+
{
|
|
38806
|
+
name: "",
|
|
38807
|
+
type: "string",
|
|
38808
|
+
},
|
|
38809
|
+
],
|
|
38810
|
+
payable: false,
|
|
38811
|
+
stateMutability: "view",
|
|
38812
|
+
type: "function",
|
|
38813
|
+
},
|
|
38814
|
+
{
|
|
38815
|
+
constant: false,
|
|
38816
|
+
inputs: [
|
|
38817
|
+
{
|
|
38818
|
+
name: "dst",
|
|
38819
|
+
type: "address",
|
|
38820
|
+
},
|
|
38821
|
+
{
|
|
38822
|
+
name: "wad",
|
|
38823
|
+
type: "uint256",
|
|
38824
|
+
},
|
|
38825
|
+
],
|
|
38826
|
+
name: "transfer",
|
|
38827
|
+
outputs: [
|
|
38828
|
+
{
|
|
38829
|
+
name: "",
|
|
38830
|
+
type: "bool",
|
|
38831
|
+
},
|
|
38832
|
+
],
|
|
38833
|
+
payable: false,
|
|
38834
|
+
stateMutability: "nonpayable",
|
|
38835
|
+
type: "function",
|
|
38836
|
+
},
|
|
38837
|
+
{
|
|
38838
|
+
constant: false,
|
|
38839
|
+
inputs: [],
|
|
38840
|
+
name: "deposit",
|
|
38841
|
+
outputs: [],
|
|
38842
|
+
payable: true,
|
|
38843
|
+
stateMutability: "payable",
|
|
38844
|
+
type: "function",
|
|
38845
|
+
},
|
|
38846
|
+
{
|
|
38847
|
+
constant: true,
|
|
38848
|
+
inputs: [
|
|
38849
|
+
{
|
|
38850
|
+
name: "",
|
|
38851
|
+
type: "address",
|
|
38852
|
+
},
|
|
38853
|
+
{
|
|
38854
|
+
name: "",
|
|
38855
|
+
type: "address",
|
|
38856
|
+
},
|
|
38857
|
+
],
|
|
38858
|
+
name: "allowance",
|
|
38859
|
+
outputs: [
|
|
38860
|
+
{
|
|
38861
|
+
name: "",
|
|
38862
|
+
type: "uint256",
|
|
38863
|
+
},
|
|
38864
|
+
],
|
|
38865
|
+
payable: false,
|
|
38866
|
+
stateMutability: "view",
|
|
38867
|
+
type: "function",
|
|
38868
|
+
},
|
|
38869
|
+
{
|
|
38870
|
+
payable: true,
|
|
38871
|
+
stateMutability: "payable",
|
|
38872
|
+
type: "fallback",
|
|
38873
|
+
},
|
|
38874
|
+
{
|
|
38875
|
+
anonymous: false,
|
|
38876
|
+
inputs: [
|
|
38877
|
+
{
|
|
38878
|
+
indexed: true,
|
|
38879
|
+
name: "src",
|
|
38880
|
+
type: "address",
|
|
38881
|
+
},
|
|
38882
|
+
{
|
|
38883
|
+
indexed: true,
|
|
38884
|
+
name: "guy",
|
|
38885
|
+
type: "address",
|
|
38886
|
+
},
|
|
38887
|
+
{
|
|
38888
|
+
indexed: false,
|
|
38889
|
+
name: "wad",
|
|
38890
|
+
type: "uint256",
|
|
38891
|
+
},
|
|
38892
|
+
],
|
|
38893
|
+
name: "Approval",
|
|
38894
|
+
type: "event",
|
|
38895
|
+
},
|
|
38896
|
+
{
|
|
38897
|
+
anonymous: false,
|
|
38898
|
+
inputs: [
|
|
38899
|
+
{
|
|
38900
|
+
indexed: true,
|
|
38901
|
+
name: "src",
|
|
38902
|
+
type: "address",
|
|
38903
|
+
},
|
|
38904
|
+
{
|
|
38905
|
+
indexed: true,
|
|
38906
|
+
name: "dst",
|
|
38907
|
+
type: "address",
|
|
38908
|
+
},
|
|
38909
|
+
{
|
|
38910
|
+
indexed: false,
|
|
38911
|
+
name: "wad",
|
|
38912
|
+
type: "uint256",
|
|
38913
|
+
},
|
|
38914
|
+
],
|
|
38915
|
+
name: "Transfer",
|
|
38916
|
+
type: "event",
|
|
38917
|
+
},
|
|
38918
|
+
{
|
|
38919
|
+
anonymous: false,
|
|
38920
|
+
inputs: [
|
|
38921
|
+
{
|
|
38922
|
+
indexed: true,
|
|
38923
|
+
name: "dst",
|
|
38924
|
+
type: "address",
|
|
38925
|
+
},
|
|
38926
|
+
{
|
|
38927
|
+
indexed: false,
|
|
38928
|
+
name: "wad",
|
|
38929
|
+
type: "uint256",
|
|
38930
|
+
},
|
|
38931
|
+
],
|
|
38932
|
+
name: "Deposit",
|
|
38933
|
+
type: "event",
|
|
38934
|
+
},
|
|
38935
|
+
{
|
|
38936
|
+
anonymous: false,
|
|
38937
|
+
inputs: [
|
|
38938
|
+
{
|
|
38939
|
+
indexed: true,
|
|
38940
|
+
name: "src",
|
|
38941
|
+
type: "address",
|
|
38942
|
+
},
|
|
38943
|
+
{
|
|
38944
|
+
indexed: false,
|
|
38945
|
+
name: "wad",
|
|
38946
|
+
type: "uint256",
|
|
38947
|
+
},
|
|
38948
|
+
],
|
|
38949
|
+
name: "Withdrawal",
|
|
38950
|
+
type: "event",
|
|
38951
|
+
},
|
|
38952
|
+
];
|
|
38953
|
+
class WIMX__factory {
|
|
38662
38954
|
static abi = _abi;
|
|
38663
38955
|
static createInterface() {
|
|
38664
38956
|
return new ethers.utils.Interface(_abi);
|
|
@@ -39287,6 +39579,13 @@ class NativeTokenService {
|
|
|
39287
39579
|
maybeWrapAmount(amount) {
|
|
39288
39580
|
return newAmount(amount.value, this.maybeWrapToken(amount.token));
|
|
39289
39581
|
}
|
|
39582
|
+
isWrappedNative(token) {
|
|
39583
|
+
return token.type === 'erc20' && token.address.toLowerCase() === this.wrappedToken.address.toLowerCase();
|
|
39584
|
+
}
|
|
39585
|
+
isWrapOrUnwrap(tokenIn, tokenOut) {
|
|
39586
|
+
return ((tokenIn === this.nativeToken && (this.isWrappedNative(tokenOut))) ||
|
|
39587
|
+
((this.isWrappedNative(tokenIn)) && tokenOut === this.nativeToken));
|
|
39588
|
+
}
|
|
39290
39589
|
}
|
|
39291
39590
|
|
|
39292
39591
|
// slippageToPercent takes the slippage as a percentage (e.g. 0.1) and
|
|
@@ -39385,6 +39684,16 @@ class Fees {
|
|
|
39385
39684
|
}
|
|
39386
39685
|
}
|
|
39387
39686
|
|
|
39687
|
+
// 45038 is the upper bound of the gas estimate for the deposit function.
|
|
39688
|
+
// This upper bound is reached when a user is wrapping for the first time (cold + unused storage slot)
|
|
39689
|
+
// The lower bound is 27,938, so the difference is 17,100 gas. If transactions are 10 gwei IMX,
|
|
39690
|
+
// this is about 0.000171 IMX difference. In order to avoid an extra remote call, we just use the upper bound instead.
|
|
39691
|
+
const IMX_WRAP_GAS_COST = 45038;
|
|
39692
|
+
// 35216 is the upper bound of the gas estimate for the withdraw function.
|
|
39693
|
+
// The differenfce between upper and normal is less than 0.0001 IMX, so we just use the upper bound
|
|
39694
|
+
// to avoid an extra remote call.
|
|
39695
|
+
const IMX_UNWRAP_GAS_COST = 35216;
|
|
39696
|
+
|
|
39388
39697
|
const IMMUTABLE_TESTNET_RPC_URL = 'https://rpc.testnet.immutable.com';
|
|
39389
39698
|
const IMMUTABLE_TESTNET_CHAIN_ID = 13473;
|
|
39390
39699
|
|
|
@@ -39898,6 +40207,67 @@ class Exchange {
|
|
|
39898
40207
|
decimals,
|
|
39899
40208
|
};
|
|
39900
40209
|
}
|
|
40210
|
+
async getUnwrapTransaction(fromAddress, tokenAmount, wimxInterface, gasPrice) {
|
|
40211
|
+
const calldata = wimxInterface.encodeFunctionData('withdraw', [tokenAmount]);
|
|
40212
|
+
const gasEstimate = ethers.ethers.BigNumber.from(IMX_UNWRAP_GAS_COST);
|
|
40213
|
+
const gasFeeEstimate = gasPrice ? toPublicAmount(calculateGasFee(gasPrice, gasEstimate)) : null;
|
|
40214
|
+
// This transaction is for calling calling `withdraw` on the WETH/WIMX contract.
|
|
40215
|
+
const transactionDetails = {
|
|
40216
|
+
transaction: {
|
|
40217
|
+
data: calldata,
|
|
40218
|
+
to: this.wrappedNativeToken.address,
|
|
40219
|
+
from: fromAddress,
|
|
40220
|
+
},
|
|
40221
|
+
gasFeeEstimate,
|
|
40222
|
+
};
|
|
40223
|
+
return {
|
|
40224
|
+
transaction: transactionDetails,
|
|
40225
|
+
approval: null,
|
|
40226
|
+
};
|
|
40227
|
+
}
|
|
40228
|
+
getWrapTransaction(fromAddress, tokenAmount, wimxInterface, gasPrice) {
|
|
40229
|
+
const calldata = wimxInterface.encodeFunctionData('deposit');
|
|
40230
|
+
const gasEstimate = ethers.ethers.BigNumber.from(IMX_WRAP_GAS_COST);
|
|
40231
|
+
const gasFeeEstimate = gasPrice ? toPublicAmount(calculateGasFee(gasPrice, gasEstimate)) : null;
|
|
40232
|
+
// This transaction is for calling calling `deposit` on the WETH/WIMX contract.
|
|
40233
|
+
const transactionDetails = {
|
|
40234
|
+
transaction: {
|
|
40235
|
+
data: calldata,
|
|
40236
|
+
to: this.wrappedNativeToken.address,
|
|
40237
|
+
value: tokenAmount,
|
|
40238
|
+
from: fromAddress,
|
|
40239
|
+
},
|
|
40240
|
+
gasFeeEstimate,
|
|
40241
|
+
};
|
|
40242
|
+
return {
|
|
40243
|
+
transaction: transactionDetails,
|
|
40244
|
+
approval: null,
|
|
40245
|
+
};
|
|
40246
|
+
}
|
|
40247
|
+
async getUnsignedWrapUnwrapTx(tokenSpecified, amountIn, fromAddress, gasPrice) {
|
|
40248
|
+
const isWrap = amountIn.token.type === 'native';
|
|
40249
|
+
const quoteToken = tokenSpecified.type === 'native' ? this.wrappedNativeToken : this.nativeToken;
|
|
40250
|
+
const otherTokenCoinAmount = {
|
|
40251
|
+
token: quoteToken,
|
|
40252
|
+
value: amountIn.value,
|
|
40253
|
+
};
|
|
40254
|
+
// The quote is always 1:1 (0 {price impact, slippage}) when wrapping/unwrapping.
|
|
40255
|
+
const quote = {
|
|
40256
|
+
amount: toPublicAmount(otherTokenCoinAmount),
|
|
40257
|
+
amountWithMaxSlippage: toPublicAmount(otherTokenCoinAmount),
|
|
40258
|
+
slippage: 0,
|
|
40259
|
+
fees: [],
|
|
40260
|
+
};
|
|
40261
|
+
const wimxInterface = WIMX__factory.createInterface();
|
|
40262
|
+
let transactionDetails;
|
|
40263
|
+
if (isWrap) {
|
|
40264
|
+
transactionDetails = this.getWrapTransaction(fromAddress, otherTokenCoinAmount.value, wimxInterface, gasPrice);
|
|
40265
|
+
}
|
|
40266
|
+
else {
|
|
40267
|
+
transactionDetails = await this.getUnwrapTransaction(fromAddress, otherTokenCoinAmount.value, wimxInterface, gasPrice);
|
|
40268
|
+
}
|
|
40269
|
+
return { quote, approval: transactionDetails.approval, swap: transactionDetails.transaction };
|
|
40270
|
+
}
|
|
39901
40271
|
async getUnsignedSwapTx(fromAddress, tokenInLiteral, tokenOutLiteral, amount, slippagePercent, maxHops, deadline, tradeType) {
|
|
39902
40272
|
Exchange.validate(tokenInLiteral, tokenOutLiteral, maxHops, slippagePercent, fromAddress);
|
|
39903
40273
|
// get the decimals of the tokens that will be swapped
|
|
@@ -39913,6 +40283,11 @@ class Exchange {
|
|
|
39913
40283
|
// determine which amount was specified for the swap from the TradeType
|
|
39914
40284
|
const [tokenSpecified, otherToken] = tradeType === Uniswap.TradeType.EXACT_INPUT ? [tokenIn, tokenOut] : [tokenOut, tokenIn];
|
|
39915
40285
|
const amountSpecified = newAmount(amount, tokenSpecified);
|
|
40286
|
+
if (this.nativeTokenService.isWrapOrUnwrap(tokenIn, tokenOut)) {
|
|
40287
|
+
// If the user is swapping between the native token and the wrapped native token,
|
|
40288
|
+
// we want to just wrap/unwrap the native token instead of swapping
|
|
40289
|
+
return this.getUnsignedWrapUnwrapTx(tokenSpecified, newAmount(amount, tokenIn), fromAddress, gasPrice);
|
|
40290
|
+
}
|
|
39916
40291
|
const fees = new Fees(secondaryFees, tokenIn);
|
|
39917
40292
|
const ourQuoteReqAmount = getOurQuoteReqAmount(amountSpecified, fees, tradeType, this.nativeTokenService);
|
|
39918
40293
|
// Quotes will always use ERC20s. If the user-specified token is Native, we use the Wrapped Native Token pool
|
|
@@ -40199,6 +40574,7 @@ var WalletAction;
|
|
|
40199
40574
|
WalletAction["ADD_NETWORK"] = "wallet_addEthereumChain";
|
|
40200
40575
|
WalletAction["SWITCH_NETWORK"] = "wallet_switchEthereumChain";
|
|
40201
40576
|
WalletAction["GET_CHAINID"] = "eth_chainId";
|
|
40577
|
+
WalletAction["REQUEST_PERMISSIONS"] = "wallet_requestPermissions";
|
|
40202
40578
|
})(WalletAction || (WalletAction = {}));
|
|
40203
40579
|
/**
|
|
40204
40580
|
* Enum representing the platform filters used in {@link GetWalletAllowListParams}.
|
|
@@ -40909,7 +41285,7 @@ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
|
|
|
40909
41285
|
maxPriorityFeePerGas: ethers.BigNumber.from(10e9),
|
|
40910
41286
|
};
|
|
40911
41287
|
|
|
40912
|
-
const SDK_VERSION_MARKER = '0.45.
|
|
41288
|
+
const SDK_VERSION_MARKER = '0.45.4';
|
|
40913
41289
|
// This SDK version is replaced by the `yarn build` command ran on the root level
|
|
40914
41290
|
const globalPackageVersion = () => SDK_VERSION_MARKER;
|
|
40915
41291
|
|
|
@@ -41493,6 +41869,21 @@ async function connectSite(web3Provider) {
|
|
|
41493
41869
|
}, { type: CheckoutErrorType.USER_REJECTED_REQUEST_ERROR });
|
|
41494
41870
|
return web3Provider;
|
|
41495
41871
|
}
|
|
41872
|
+
async function requestPermissions(web3Provider) {
|
|
41873
|
+
if (!web3Provider || !web3Provider.provider?.request) {
|
|
41874
|
+
throw new CheckoutError('Incompatible provider', CheckoutErrorType.PROVIDER_REQUEST_MISSING_ERROR, { details: 'Attempting to connect with an incompatible provider' });
|
|
41875
|
+
}
|
|
41876
|
+
await withCheckoutError(async () => {
|
|
41877
|
+
if (!web3Provider.provider.request)
|
|
41878
|
+
return;
|
|
41879
|
+
await web3Provider.provider.request({
|
|
41880
|
+
method: WalletAction.REQUEST_PERMISSIONS,
|
|
41881
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
41882
|
+
params: [{ eth_accounts: {} }],
|
|
41883
|
+
});
|
|
41884
|
+
}, { type: CheckoutErrorType.USER_REJECTED_REQUEST_ERROR });
|
|
41885
|
+
return web3Provider;
|
|
41886
|
+
}
|
|
41496
41887
|
|
|
41497
41888
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
41498
41889
|
async function getMetaMaskProvider() {
|
|
@@ -44641,7 +45032,12 @@ class Checkout {
|
|
|
44641
45032
|
*/
|
|
44642
45033
|
async connect(params) {
|
|
44643
45034
|
const web3Provider = await validateProvider(this.config, params.provider, { allowUnsupportedProvider: true });
|
|
44644
|
-
|
|
45035
|
+
if (params.requestWalletPermissions && !web3Provider.provider?.isPassport) {
|
|
45036
|
+
await requestPermissions(web3Provider);
|
|
45037
|
+
}
|
|
45038
|
+
else {
|
|
45039
|
+
await connectSite(web3Provider);
|
|
45040
|
+
}
|
|
44645
45041
|
return { provider: web3Provider };
|
|
44646
45042
|
}
|
|
44647
45043
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -28391,9 +28391,11 @@ type ChainTokensConfig = {
|
|
|
28391
28391
|
/**
|
|
28392
28392
|
* Interface representing the params of {@link Checkout.connect}.
|
|
28393
28393
|
* @property {Web3Provider} provider - The provider used to connect to the network.
|
|
28394
|
+
* @property {boolean | undefined} requestWalletPermissions - A boolean that will trigger a permission request for wallet connection.
|
|
28394
28395
|
*/
|
|
28395
28396
|
interface ConnectParams {
|
|
28396
28397
|
provider: Web3Provider;
|
|
28398
|
+
requestWalletPermissions?: boolean;
|
|
28397
28399
|
}
|
|
28398
28400
|
/**
|
|
28399
28401
|
* Interface representing the result of {@link Checkout.connect}.
|
|
@@ -28411,7 +28413,7 @@ interface CheckConnectionParams {
|
|
|
28411
28413
|
}
|
|
28412
28414
|
/**
|
|
28413
28415
|
* Interface representing the result of {@link Checkout.checkIsWalletConnected}.
|
|
28414
|
-
* @property {boolean} isConnected - A boolean indicating the connection status of
|
|
28416
|
+
* @property {boolean} isConnected - A boolean indicating the connection status of the Web3 provider.
|
|
28415
28417
|
* @property {string} walletAddress - The wallet address used to check the connection.
|
|
28416
28418
|
*/
|
|
28417
28419
|
interface CheckConnectionResult {
|