@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/checkout.d.ts
CHANGED
|
@@ -22518,9 +22518,11 @@ type ChainTokensConfig = {
|
|
|
22518
22518
|
/**
|
|
22519
22519
|
* Interface representing the params of {@link Checkout.connect}.
|
|
22520
22520
|
* @property {Web3Provider} provider - The provider used to connect to the network.
|
|
22521
|
+
* @property {boolean | undefined} requestWalletPermissions - A boolean that will trigger a permission request for wallet connection.
|
|
22521
22522
|
*/
|
|
22522
22523
|
interface ConnectParams {
|
|
22523
22524
|
provider: Web3Provider;
|
|
22525
|
+
requestWalletPermissions?: boolean;
|
|
22524
22526
|
}
|
|
22525
22527
|
/**
|
|
22526
22528
|
* Interface representing the result of {@link Checkout.connect}.
|
|
@@ -22538,7 +22540,7 @@ interface CheckConnectionParams {
|
|
|
22538
22540
|
}
|
|
22539
22541
|
/**
|
|
22540
22542
|
* Interface representing the result of {@link Checkout.checkIsWalletConnected}.
|
|
22541
|
-
* @property {boolean} isConnected - A boolean indicating the connection status of
|
|
22543
|
+
* @property {boolean} isConnected - A boolean indicating the connection status of the Web3 provider.
|
|
22542
22544
|
* @property {string} walletAddress - The wallet address used to check the connection.
|
|
22543
22545
|
*/
|
|
22544
22546
|
interface CheckConnectionResult {
|
package/dist/checkout.js
CHANGED
|
@@ -16871,7 +16871,7 @@ class ApproveError extends ExchangeError {
|
|
|
16871
16871
|
/* Autogenerated file. Do not edit manually. */
|
|
16872
16872
|
/* tslint:disable */
|
|
16873
16873
|
/* eslint-disable */
|
|
16874
|
-
const _abi$
|
|
16874
|
+
const _abi$4 = [
|
|
16875
16875
|
{
|
|
16876
16876
|
constant: true,
|
|
16877
16877
|
inputs: [],
|
|
@@ -17094,19 +17094,19 @@ const _abi$3 = [
|
|
|
17094
17094
|
},
|
|
17095
17095
|
];
|
|
17096
17096
|
class ERC20__factory {
|
|
17097
|
-
static abi = _abi$
|
|
17097
|
+
static abi = _abi$4;
|
|
17098
17098
|
static createInterface() {
|
|
17099
|
-
return new utils$2.Interface(_abi$
|
|
17099
|
+
return new utils$2.Interface(_abi$4);
|
|
17100
17100
|
}
|
|
17101
17101
|
static connect(address, signerOrProvider) {
|
|
17102
|
-
return new Contract$1(address, _abi$
|
|
17102
|
+
return new Contract$1(address, _abi$4, signerOrProvider);
|
|
17103
17103
|
}
|
|
17104
17104
|
}
|
|
17105
17105
|
|
|
17106
17106
|
/* Autogenerated file. Do not edit manually. */
|
|
17107
17107
|
/* tslint:disable */
|
|
17108
17108
|
/* eslint-disable */
|
|
17109
|
-
const _abi$
|
|
17109
|
+
const _abi$3 = [
|
|
17110
17110
|
{
|
|
17111
17111
|
inputs: [
|
|
17112
17112
|
{
|
|
@@ -17880,7 +17880,7 @@ class ImmutableSwapProxy__factory extends ContractFactory {
|
|
|
17880
17880
|
super(...args);
|
|
17881
17881
|
}
|
|
17882
17882
|
else {
|
|
17883
|
-
super(_abi$
|
|
17883
|
+
super(_abi$3, _bytecode$2, args[0]);
|
|
17884
17884
|
}
|
|
17885
17885
|
}
|
|
17886
17886
|
deploy(_admin, _uniRouter, _wimx, overrides) {
|
|
@@ -17896,19 +17896,19 @@ class ImmutableSwapProxy__factory extends ContractFactory {
|
|
|
17896
17896
|
return super.connect(signer);
|
|
17897
17897
|
}
|
|
17898
17898
|
static bytecode = _bytecode$2;
|
|
17899
|
-
static abi = _abi$
|
|
17899
|
+
static abi = _abi$3;
|
|
17900
17900
|
static createInterface() {
|
|
17901
|
-
return new utils$2.Interface(_abi$
|
|
17901
|
+
return new utils$2.Interface(_abi$3);
|
|
17902
17902
|
}
|
|
17903
17903
|
static connect(address, signerOrProvider) {
|
|
17904
|
-
return new Contract$1(address, _abi$
|
|
17904
|
+
return new Contract$1(address, _abi$3, signerOrProvider);
|
|
17905
17905
|
}
|
|
17906
17906
|
}
|
|
17907
17907
|
|
|
17908
17908
|
/* Autogenerated file. Do not edit manually. */
|
|
17909
17909
|
/* tslint:disable */
|
|
17910
17910
|
/* eslint-disable */
|
|
17911
|
-
const _abi$
|
|
17911
|
+
const _abi$2 = [
|
|
17912
17912
|
{
|
|
17913
17913
|
inputs: [],
|
|
17914
17914
|
name: "getCurrentBlockTimestamp",
|
|
@@ -18008,7 +18008,7 @@ class Multicall__factory extends ContractFactory {
|
|
|
18008
18008
|
super(...args);
|
|
18009
18009
|
}
|
|
18010
18010
|
else {
|
|
18011
|
-
super(_abi$
|
|
18011
|
+
super(_abi$2, _bytecode$1, args[0]);
|
|
18012
18012
|
}
|
|
18013
18013
|
}
|
|
18014
18014
|
deploy(overrides) {
|
|
@@ -18024,19 +18024,19 @@ class Multicall__factory extends ContractFactory {
|
|
|
18024
18024
|
return super.connect(signer);
|
|
18025
18025
|
}
|
|
18026
18026
|
static bytecode = _bytecode$1;
|
|
18027
|
-
static abi = _abi$
|
|
18027
|
+
static abi = _abi$2;
|
|
18028
18028
|
static createInterface() {
|
|
18029
|
-
return new utils$2.Interface(_abi$
|
|
18029
|
+
return new utils$2.Interface(_abi$2);
|
|
18030
18030
|
}
|
|
18031
18031
|
static connect(address, signerOrProvider) {
|
|
18032
|
-
return new Contract$1(address, _abi$
|
|
18032
|
+
return new Contract$1(address, _abi$2, signerOrProvider);
|
|
18033
18033
|
}
|
|
18034
18034
|
}
|
|
18035
18035
|
|
|
18036
18036
|
/* Autogenerated file. Do not edit manually. */
|
|
18037
18037
|
/* tslint:disable */
|
|
18038
18038
|
/* eslint-disable */
|
|
18039
|
-
const _abi = [
|
|
18039
|
+
const _abi$1 = [
|
|
18040
18040
|
{
|
|
18041
18041
|
inputs: [],
|
|
18042
18042
|
stateMutability: "nonpayable",
|
|
@@ -19032,7 +19032,7 @@ class UniswapV3Pool__factory extends ContractFactory {
|
|
|
19032
19032
|
super(...args);
|
|
19033
19033
|
}
|
|
19034
19034
|
else {
|
|
19035
|
-
super(_abi, _bytecode, args[0]);
|
|
19035
|
+
super(_abi$1, _bytecode, args[0]);
|
|
19036
19036
|
}
|
|
19037
19037
|
}
|
|
19038
19038
|
deploy(overrides) {
|
|
@@ -19048,6 +19048,298 @@ class UniswapV3Pool__factory extends ContractFactory {
|
|
|
19048
19048
|
return super.connect(signer);
|
|
19049
19049
|
}
|
|
19050
19050
|
static bytecode = _bytecode;
|
|
19051
|
+
static abi = _abi$1;
|
|
19052
|
+
static createInterface() {
|
|
19053
|
+
return new utils$2.Interface(_abi$1);
|
|
19054
|
+
}
|
|
19055
|
+
static connect(address, signerOrProvider) {
|
|
19056
|
+
return new Contract$1(address, _abi$1, signerOrProvider);
|
|
19057
|
+
}
|
|
19058
|
+
}
|
|
19059
|
+
|
|
19060
|
+
/* Autogenerated file. Do not edit manually. */
|
|
19061
|
+
/* tslint:disable */
|
|
19062
|
+
/* eslint-disable */
|
|
19063
|
+
const _abi = [
|
|
19064
|
+
{
|
|
19065
|
+
constant: true,
|
|
19066
|
+
inputs: [],
|
|
19067
|
+
name: "name",
|
|
19068
|
+
outputs: [
|
|
19069
|
+
{
|
|
19070
|
+
name: "",
|
|
19071
|
+
type: "string",
|
|
19072
|
+
},
|
|
19073
|
+
],
|
|
19074
|
+
payable: false,
|
|
19075
|
+
stateMutability: "view",
|
|
19076
|
+
type: "function",
|
|
19077
|
+
},
|
|
19078
|
+
{
|
|
19079
|
+
constant: false,
|
|
19080
|
+
inputs: [
|
|
19081
|
+
{
|
|
19082
|
+
name: "guy",
|
|
19083
|
+
type: "address",
|
|
19084
|
+
},
|
|
19085
|
+
{
|
|
19086
|
+
name: "wad",
|
|
19087
|
+
type: "uint256",
|
|
19088
|
+
},
|
|
19089
|
+
],
|
|
19090
|
+
name: "approve",
|
|
19091
|
+
outputs: [
|
|
19092
|
+
{
|
|
19093
|
+
name: "",
|
|
19094
|
+
type: "bool",
|
|
19095
|
+
},
|
|
19096
|
+
],
|
|
19097
|
+
payable: false,
|
|
19098
|
+
stateMutability: "nonpayable",
|
|
19099
|
+
type: "function",
|
|
19100
|
+
},
|
|
19101
|
+
{
|
|
19102
|
+
constant: true,
|
|
19103
|
+
inputs: [],
|
|
19104
|
+
name: "totalSupply",
|
|
19105
|
+
outputs: [
|
|
19106
|
+
{
|
|
19107
|
+
name: "",
|
|
19108
|
+
type: "uint256",
|
|
19109
|
+
},
|
|
19110
|
+
],
|
|
19111
|
+
payable: false,
|
|
19112
|
+
stateMutability: "view",
|
|
19113
|
+
type: "function",
|
|
19114
|
+
},
|
|
19115
|
+
{
|
|
19116
|
+
constant: false,
|
|
19117
|
+
inputs: [
|
|
19118
|
+
{
|
|
19119
|
+
name: "src",
|
|
19120
|
+
type: "address",
|
|
19121
|
+
},
|
|
19122
|
+
{
|
|
19123
|
+
name: "dst",
|
|
19124
|
+
type: "address",
|
|
19125
|
+
},
|
|
19126
|
+
{
|
|
19127
|
+
name: "wad",
|
|
19128
|
+
type: "uint256",
|
|
19129
|
+
},
|
|
19130
|
+
],
|
|
19131
|
+
name: "transferFrom",
|
|
19132
|
+
outputs: [
|
|
19133
|
+
{
|
|
19134
|
+
name: "",
|
|
19135
|
+
type: "bool",
|
|
19136
|
+
},
|
|
19137
|
+
],
|
|
19138
|
+
payable: false,
|
|
19139
|
+
stateMutability: "nonpayable",
|
|
19140
|
+
type: "function",
|
|
19141
|
+
},
|
|
19142
|
+
{
|
|
19143
|
+
constant: false,
|
|
19144
|
+
inputs: [
|
|
19145
|
+
{
|
|
19146
|
+
name: "wad",
|
|
19147
|
+
type: "uint256",
|
|
19148
|
+
},
|
|
19149
|
+
],
|
|
19150
|
+
name: "withdraw",
|
|
19151
|
+
outputs: [],
|
|
19152
|
+
payable: false,
|
|
19153
|
+
stateMutability: "nonpayable",
|
|
19154
|
+
type: "function",
|
|
19155
|
+
},
|
|
19156
|
+
{
|
|
19157
|
+
constant: true,
|
|
19158
|
+
inputs: [],
|
|
19159
|
+
name: "decimals",
|
|
19160
|
+
outputs: [
|
|
19161
|
+
{
|
|
19162
|
+
name: "",
|
|
19163
|
+
type: "uint8",
|
|
19164
|
+
},
|
|
19165
|
+
],
|
|
19166
|
+
payable: false,
|
|
19167
|
+
stateMutability: "view",
|
|
19168
|
+
type: "function",
|
|
19169
|
+
},
|
|
19170
|
+
{
|
|
19171
|
+
constant: true,
|
|
19172
|
+
inputs: [
|
|
19173
|
+
{
|
|
19174
|
+
name: "",
|
|
19175
|
+
type: "address",
|
|
19176
|
+
},
|
|
19177
|
+
],
|
|
19178
|
+
name: "balanceOf",
|
|
19179
|
+
outputs: [
|
|
19180
|
+
{
|
|
19181
|
+
name: "",
|
|
19182
|
+
type: "uint256",
|
|
19183
|
+
},
|
|
19184
|
+
],
|
|
19185
|
+
payable: false,
|
|
19186
|
+
stateMutability: "view",
|
|
19187
|
+
type: "function",
|
|
19188
|
+
},
|
|
19189
|
+
{
|
|
19190
|
+
constant: true,
|
|
19191
|
+
inputs: [],
|
|
19192
|
+
name: "symbol",
|
|
19193
|
+
outputs: [
|
|
19194
|
+
{
|
|
19195
|
+
name: "",
|
|
19196
|
+
type: "string",
|
|
19197
|
+
},
|
|
19198
|
+
],
|
|
19199
|
+
payable: false,
|
|
19200
|
+
stateMutability: "view",
|
|
19201
|
+
type: "function",
|
|
19202
|
+
},
|
|
19203
|
+
{
|
|
19204
|
+
constant: false,
|
|
19205
|
+
inputs: [
|
|
19206
|
+
{
|
|
19207
|
+
name: "dst",
|
|
19208
|
+
type: "address",
|
|
19209
|
+
},
|
|
19210
|
+
{
|
|
19211
|
+
name: "wad",
|
|
19212
|
+
type: "uint256",
|
|
19213
|
+
},
|
|
19214
|
+
],
|
|
19215
|
+
name: "transfer",
|
|
19216
|
+
outputs: [
|
|
19217
|
+
{
|
|
19218
|
+
name: "",
|
|
19219
|
+
type: "bool",
|
|
19220
|
+
},
|
|
19221
|
+
],
|
|
19222
|
+
payable: false,
|
|
19223
|
+
stateMutability: "nonpayable",
|
|
19224
|
+
type: "function",
|
|
19225
|
+
},
|
|
19226
|
+
{
|
|
19227
|
+
constant: false,
|
|
19228
|
+
inputs: [],
|
|
19229
|
+
name: "deposit",
|
|
19230
|
+
outputs: [],
|
|
19231
|
+
payable: true,
|
|
19232
|
+
stateMutability: "payable",
|
|
19233
|
+
type: "function",
|
|
19234
|
+
},
|
|
19235
|
+
{
|
|
19236
|
+
constant: true,
|
|
19237
|
+
inputs: [
|
|
19238
|
+
{
|
|
19239
|
+
name: "",
|
|
19240
|
+
type: "address",
|
|
19241
|
+
},
|
|
19242
|
+
{
|
|
19243
|
+
name: "",
|
|
19244
|
+
type: "address",
|
|
19245
|
+
},
|
|
19246
|
+
],
|
|
19247
|
+
name: "allowance",
|
|
19248
|
+
outputs: [
|
|
19249
|
+
{
|
|
19250
|
+
name: "",
|
|
19251
|
+
type: "uint256",
|
|
19252
|
+
},
|
|
19253
|
+
],
|
|
19254
|
+
payable: false,
|
|
19255
|
+
stateMutability: "view",
|
|
19256
|
+
type: "function",
|
|
19257
|
+
},
|
|
19258
|
+
{
|
|
19259
|
+
payable: true,
|
|
19260
|
+
stateMutability: "payable",
|
|
19261
|
+
type: "fallback",
|
|
19262
|
+
},
|
|
19263
|
+
{
|
|
19264
|
+
anonymous: false,
|
|
19265
|
+
inputs: [
|
|
19266
|
+
{
|
|
19267
|
+
indexed: true,
|
|
19268
|
+
name: "src",
|
|
19269
|
+
type: "address",
|
|
19270
|
+
},
|
|
19271
|
+
{
|
|
19272
|
+
indexed: true,
|
|
19273
|
+
name: "guy",
|
|
19274
|
+
type: "address",
|
|
19275
|
+
},
|
|
19276
|
+
{
|
|
19277
|
+
indexed: false,
|
|
19278
|
+
name: "wad",
|
|
19279
|
+
type: "uint256",
|
|
19280
|
+
},
|
|
19281
|
+
],
|
|
19282
|
+
name: "Approval",
|
|
19283
|
+
type: "event",
|
|
19284
|
+
},
|
|
19285
|
+
{
|
|
19286
|
+
anonymous: false,
|
|
19287
|
+
inputs: [
|
|
19288
|
+
{
|
|
19289
|
+
indexed: true,
|
|
19290
|
+
name: "src",
|
|
19291
|
+
type: "address",
|
|
19292
|
+
},
|
|
19293
|
+
{
|
|
19294
|
+
indexed: true,
|
|
19295
|
+
name: "dst",
|
|
19296
|
+
type: "address",
|
|
19297
|
+
},
|
|
19298
|
+
{
|
|
19299
|
+
indexed: false,
|
|
19300
|
+
name: "wad",
|
|
19301
|
+
type: "uint256",
|
|
19302
|
+
},
|
|
19303
|
+
],
|
|
19304
|
+
name: "Transfer",
|
|
19305
|
+
type: "event",
|
|
19306
|
+
},
|
|
19307
|
+
{
|
|
19308
|
+
anonymous: false,
|
|
19309
|
+
inputs: [
|
|
19310
|
+
{
|
|
19311
|
+
indexed: true,
|
|
19312
|
+
name: "dst",
|
|
19313
|
+
type: "address",
|
|
19314
|
+
},
|
|
19315
|
+
{
|
|
19316
|
+
indexed: false,
|
|
19317
|
+
name: "wad",
|
|
19318
|
+
type: "uint256",
|
|
19319
|
+
},
|
|
19320
|
+
],
|
|
19321
|
+
name: "Deposit",
|
|
19322
|
+
type: "event",
|
|
19323
|
+
},
|
|
19324
|
+
{
|
|
19325
|
+
anonymous: false,
|
|
19326
|
+
inputs: [
|
|
19327
|
+
{
|
|
19328
|
+
indexed: true,
|
|
19329
|
+
name: "src",
|
|
19330
|
+
type: "address",
|
|
19331
|
+
},
|
|
19332
|
+
{
|
|
19333
|
+
indexed: false,
|
|
19334
|
+
name: "wad",
|
|
19335
|
+
type: "uint256",
|
|
19336
|
+
},
|
|
19337
|
+
],
|
|
19338
|
+
name: "Withdrawal",
|
|
19339
|
+
type: "event",
|
|
19340
|
+
},
|
|
19341
|
+
];
|
|
19342
|
+
class WIMX__factory {
|
|
19051
19343
|
static abi = _abi;
|
|
19052
19344
|
static createInterface() {
|
|
19053
19345
|
return new utils$2.Interface(_abi);
|
|
@@ -19676,6 +19968,13 @@ class NativeTokenService {
|
|
|
19676
19968
|
maybeWrapAmount(amount) {
|
|
19677
19969
|
return newAmount(amount.value, this.maybeWrapToken(amount.token));
|
|
19678
19970
|
}
|
|
19971
|
+
isWrappedNative(token) {
|
|
19972
|
+
return token.type === 'erc20' && token.address.toLowerCase() === this.wrappedToken.address.toLowerCase();
|
|
19973
|
+
}
|
|
19974
|
+
isWrapOrUnwrap(tokenIn, tokenOut) {
|
|
19975
|
+
return ((tokenIn === this.nativeToken && (this.isWrappedNative(tokenOut))) ||
|
|
19976
|
+
((this.isWrappedNative(tokenIn)) && tokenOut === this.nativeToken));
|
|
19977
|
+
}
|
|
19679
19978
|
}
|
|
19680
19979
|
|
|
19681
19980
|
// slippageToPercent takes the slippage as a percentage (e.g. 0.1) and
|
|
@@ -19774,6 +20073,16 @@ class Fees {
|
|
|
19774
20073
|
}
|
|
19775
20074
|
}
|
|
19776
20075
|
|
|
20076
|
+
// 45038 is the upper bound of the gas estimate for the deposit function.
|
|
20077
|
+
// This upper bound is reached when a user is wrapping for the first time (cold + unused storage slot)
|
|
20078
|
+
// The lower bound is 27,938, so the difference is 17,100 gas. If transactions are 10 gwei IMX,
|
|
20079
|
+
// this is about 0.000171 IMX difference. In order to avoid an extra remote call, we just use the upper bound instead.
|
|
20080
|
+
const IMX_WRAP_GAS_COST = 45038;
|
|
20081
|
+
// 35216 is the upper bound of the gas estimate for the withdraw function.
|
|
20082
|
+
// The differenfce between upper and normal is less than 0.0001 IMX, so we just use the upper bound
|
|
20083
|
+
// to avoid an extra remote call.
|
|
20084
|
+
const IMX_UNWRAP_GAS_COST = 35216;
|
|
20085
|
+
|
|
19777
20086
|
const IMMUTABLE_TESTNET_RPC_URL = 'https://rpc.testnet.immutable.com';
|
|
19778
20087
|
const IMMUTABLE_TESTNET_CHAIN_ID = 13473;
|
|
19779
20088
|
|
|
@@ -20287,6 +20596,67 @@ class Exchange {
|
|
|
20287
20596
|
decimals,
|
|
20288
20597
|
};
|
|
20289
20598
|
}
|
|
20599
|
+
async getUnwrapTransaction(fromAddress, tokenAmount, wimxInterface, gasPrice) {
|
|
20600
|
+
const calldata = wimxInterface.encodeFunctionData('withdraw', [tokenAmount]);
|
|
20601
|
+
const gasEstimate = ethers.BigNumber.from(IMX_UNWRAP_GAS_COST);
|
|
20602
|
+
const gasFeeEstimate = gasPrice ? toPublicAmount(calculateGasFee(gasPrice, gasEstimate)) : null;
|
|
20603
|
+
// This transaction is for calling calling `withdraw` on the WETH/WIMX contract.
|
|
20604
|
+
const transactionDetails = {
|
|
20605
|
+
transaction: {
|
|
20606
|
+
data: calldata,
|
|
20607
|
+
to: this.wrappedNativeToken.address,
|
|
20608
|
+
from: fromAddress,
|
|
20609
|
+
},
|
|
20610
|
+
gasFeeEstimate,
|
|
20611
|
+
};
|
|
20612
|
+
return {
|
|
20613
|
+
transaction: transactionDetails,
|
|
20614
|
+
approval: null,
|
|
20615
|
+
};
|
|
20616
|
+
}
|
|
20617
|
+
getWrapTransaction(fromAddress, tokenAmount, wimxInterface, gasPrice) {
|
|
20618
|
+
const calldata = wimxInterface.encodeFunctionData('deposit');
|
|
20619
|
+
const gasEstimate = ethers.BigNumber.from(IMX_WRAP_GAS_COST);
|
|
20620
|
+
const gasFeeEstimate = gasPrice ? toPublicAmount(calculateGasFee(gasPrice, gasEstimate)) : null;
|
|
20621
|
+
// This transaction is for calling calling `deposit` on the WETH/WIMX contract.
|
|
20622
|
+
const transactionDetails = {
|
|
20623
|
+
transaction: {
|
|
20624
|
+
data: calldata,
|
|
20625
|
+
to: this.wrappedNativeToken.address,
|
|
20626
|
+
value: tokenAmount,
|
|
20627
|
+
from: fromAddress,
|
|
20628
|
+
},
|
|
20629
|
+
gasFeeEstimate,
|
|
20630
|
+
};
|
|
20631
|
+
return {
|
|
20632
|
+
transaction: transactionDetails,
|
|
20633
|
+
approval: null,
|
|
20634
|
+
};
|
|
20635
|
+
}
|
|
20636
|
+
async getUnsignedWrapUnwrapTx(tokenSpecified, amountIn, fromAddress, gasPrice) {
|
|
20637
|
+
const isWrap = amountIn.token.type === 'native';
|
|
20638
|
+
const quoteToken = tokenSpecified.type === 'native' ? this.wrappedNativeToken : this.nativeToken;
|
|
20639
|
+
const otherTokenCoinAmount = {
|
|
20640
|
+
token: quoteToken,
|
|
20641
|
+
value: amountIn.value,
|
|
20642
|
+
};
|
|
20643
|
+
// The quote is always 1:1 (0 {price impact, slippage}) when wrapping/unwrapping.
|
|
20644
|
+
const quote = {
|
|
20645
|
+
amount: toPublicAmount(otherTokenCoinAmount),
|
|
20646
|
+
amountWithMaxSlippage: toPublicAmount(otherTokenCoinAmount),
|
|
20647
|
+
slippage: 0,
|
|
20648
|
+
fees: [],
|
|
20649
|
+
};
|
|
20650
|
+
const wimxInterface = WIMX__factory.createInterface();
|
|
20651
|
+
let transactionDetails;
|
|
20652
|
+
if (isWrap) {
|
|
20653
|
+
transactionDetails = this.getWrapTransaction(fromAddress, otherTokenCoinAmount.value, wimxInterface, gasPrice);
|
|
20654
|
+
}
|
|
20655
|
+
else {
|
|
20656
|
+
transactionDetails = await this.getUnwrapTransaction(fromAddress, otherTokenCoinAmount.value, wimxInterface, gasPrice);
|
|
20657
|
+
}
|
|
20658
|
+
return { quote, approval: transactionDetails.approval, swap: transactionDetails.transaction };
|
|
20659
|
+
}
|
|
20290
20660
|
async getUnsignedSwapTx(fromAddress, tokenInLiteral, tokenOutLiteral, amount, slippagePercent, maxHops, deadline, tradeType) {
|
|
20291
20661
|
Exchange.validate(tokenInLiteral, tokenOutLiteral, maxHops, slippagePercent, fromAddress);
|
|
20292
20662
|
// get the decimals of the tokens that will be swapped
|
|
@@ -20302,6 +20672,11 @@ class Exchange {
|
|
|
20302
20672
|
// determine which amount was specified for the swap from the TradeType
|
|
20303
20673
|
const [tokenSpecified, otherToken] = tradeType === TradeType.EXACT_INPUT ? [tokenIn, tokenOut] : [tokenOut, tokenIn];
|
|
20304
20674
|
const amountSpecified = newAmount(amount, tokenSpecified);
|
|
20675
|
+
if (this.nativeTokenService.isWrapOrUnwrap(tokenIn, tokenOut)) {
|
|
20676
|
+
// If the user is swapping between the native token and the wrapped native token,
|
|
20677
|
+
// we want to just wrap/unwrap the native token instead of swapping
|
|
20678
|
+
return this.getUnsignedWrapUnwrapTx(tokenSpecified, newAmount(amount, tokenIn), fromAddress, gasPrice);
|
|
20679
|
+
}
|
|
20305
20680
|
const fees = new Fees(secondaryFees, tokenIn);
|
|
20306
20681
|
const ourQuoteReqAmount = getOurQuoteReqAmount(amountSpecified, fees, tradeType, this.nativeTokenService);
|
|
20307
20682
|
// Quotes will always use ERC20s. If the user-specified token is Native, we use the Wrapped Native Token pool
|
|
@@ -25961,7 +26336,7 @@ class APIError extends Error {
|
|
|
25961
26336
|
|
|
25962
26337
|
/* eslint-disable implicit-arrow-linebreak */
|
|
25963
26338
|
const defaultHeaders = {
|
|
25964
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.45.
|
|
26339
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.45.4',
|
|
25965
26340
|
};
|
|
25966
26341
|
/**
|
|
25967
26342
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -26612,6 +26987,7 @@ var WalletAction;
|
|
|
26612
26987
|
WalletAction["ADD_NETWORK"] = "wallet_addEthereumChain";
|
|
26613
26988
|
WalletAction["SWITCH_NETWORK"] = "wallet_switchEthereumChain";
|
|
26614
26989
|
WalletAction["GET_CHAINID"] = "eth_chainId";
|
|
26990
|
+
WalletAction["REQUEST_PERMISSIONS"] = "wallet_requestPermissions";
|
|
26615
26991
|
})(WalletAction || (WalletAction = {}));
|
|
26616
26992
|
/**
|
|
26617
26993
|
* Enum representing the platform filters used in {@link GetWalletAllowListParams}.
|
|
@@ -27322,7 +27698,7 @@ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
|
|
|
27322
27698
|
maxPriorityFeePerGas: BigNumber$1.from(10e9),
|
|
27323
27699
|
};
|
|
27324
27700
|
|
|
27325
|
-
const SDK_VERSION_MARKER = '0.45.
|
|
27701
|
+
const SDK_VERSION_MARKER = '0.45.4';
|
|
27326
27702
|
// This SDK version is replaced by the `yarn build` command ran on the root level
|
|
27327
27703
|
const globalPackageVersion = () => SDK_VERSION_MARKER;
|
|
27328
27704
|
|
|
@@ -27906,6 +28282,21 @@ async function connectSite(web3Provider) {
|
|
|
27906
28282
|
}, { type: CheckoutErrorType.USER_REJECTED_REQUEST_ERROR });
|
|
27907
28283
|
return web3Provider;
|
|
27908
28284
|
}
|
|
28285
|
+
async function requestPermissions(web3Provider) {
|
|
28286
|
+
if (!web3Provider || !web3Provider.provider?.request) {
|
|
28287
|
+
throw new CheckoutError('Incompatible provider', CheckoutErrorType.PROVIDER_REQUEST_MISSING_ERROR, { details: 'Attempting to connect with an incompatible provider' });
|
|
28288
|
+
}
|
|
28289
|
+
await withCheckoutError(async () => {
|
|
28290
|
+
if (!web3Provider.provider.request)
|
|
28291
|
+
return;
|
|
28292
|
+
await web3Provider.provider.request({
|
|
28293
|
+
method: WalletAction.REQUEST_PERMISSIONS,
|
|
28294
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
28295
|
+
params: [{ eth_accounts: {} }],
|
|
28296
|
+
});
|
|
28297
|
+
}, { type: CheckoutErrorType.USER_REJECTED_REQUEST_ERROR });
|
|
28298
|
+
return web3Provider;
|
|
28299
|
+
}
|
|
27909
28300
|
|
|
27910
28301
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
27911
28302
|
async function getMetaMaskProvider() {
|
|
@@ -31054,7 +31445,12 @@ class Checkout {
|
|
|
31054
31445
|
*/
|
|
31055
31446
|
async connect(params) {
|
|
31056
31447
|
const web3Provider = await validateProvider(this.config, params.provider, { allowUnsupportedProvider: true });
|
|
31057
|
-
|
|
31448
|
+
if (params.requestWalletPermissions && !web3Provider.provider?.isPassport) {
|
|
31449
|
+
await requestPermissions(web3Provider);
|
|
31450
|
+
}
|
|
31451
|
+
else {
|
|
31452
|
+
await connectSite(web3Provider);
|
|
31453
|
+
}
|
|
31058
31454
|
return { provider: web3Provider };
|
|
31059
31455
|
}
|
|
31060
31456
|
/**
|