@lifi/sdk 3.0.0-alpha.3 → 3.0.0-alpha.6
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/LiFi.d.ts +7 -3
- package/dist/LiFi.js +5 -1
- package/dist/allowance/setAllowance.d.ts +2 -1
- package/dist/allowance/setAllowance.js +23 -7
- package/dist/cjs/LiFi.d.ts +7 -3
- package/dist/cjs/LiFi.js +5 -1
- package/dist/cjs/allowance/setAllowance.d.ts +2 -1
- package/dist/cjs/allowance/setAllowance.js +23 -7
- package/dist/cjs/execution/StepExecutionManager.js +30 -25
- package/dist/cjs/execution/checkAllowance.js +1 -1
- package/dist/cjs/types/internal.types.d.ts +4 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/execution/StepExecutionManager.js +30 -25
- package/dist/execution/checkAllowance.js +1 -1
- package/dist/types/internal.types.d.ts +4 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +60 -62
package/dist/LiFi.d.ts
CHANGED
|
@@ -144,24 +144,28 @@ export declare class LiFi extends RouteExecutionManager {
|
|
|
144
144
|
* @param token - The token that should be checked
|
|
145
145
|
* @param ownerAddress - The owner of the token
|
|
146
146
|
* @param spenderAddress - The spender address that has to be approved
|
|
147
|
+
* @returns Returns allowance
|
|
147
148
|
*/
|
|
148
149
|
getTokenAllowance: (token: Token, ownerAddress: string, spenderAddress: string) => Promise<bigint | undefined>;
|
|
149
150
|
/**
|
|
150
|
-
* Get the current allowance for a list of token
|
|
151
|
+
* Get the current allowance for a list of token/spender address pairs.
|
|
151
152
|
* @param ownerAddress - The owner of the tokens
|
|
152
153
|
* @param tokens - A list of token and spender address pairs
|
|
154
|
+
* @returns Returns array of tokens and their allowance
|
|
153
155
|
*/
|
|
154
156
|
getTokenAllowanceMulticall: (ownerAddress: string, tokens: TokenSpender[]) => Promise<TokenAllowance[]>;
|
|
155
157
|
/**
|
|
156
158
|
* Set approval for a certain token and amount.
|
|
157
159
|
* @param request - The approval request
|
|
160
|
+
* @returns Returns Hash or nothing
|
|
158
161
|
*/
|
|
159
|
-
setTokenApproval: (request: ApproveTokenRequest) => Promise<Hash |
|
|
162
|
+
setTokenApproval: (request: ApproveTokenRequest) => Promise<Hash | undefined>;
|
|
160
163
|
/**
|
|
161
164
|
* Revoke approval for a certain token.
|
|
162
165
|
* @param request - The revoke request
|
|
166
|
+
* @returns Returns Hash or nothing
|
|
163
167
|
*/
|
|
164
|
-
revokeTokenApproval: (request: RevokeApprovalRequest) => Promise<Hash |
|
|
168
|
+
revokeTokenApproval: (request: RevokeApprovalRequest) => Promise<Hash | undefined>;
|
|
165
169
|
/**
|
|
166
170
|
* Get all the available connections for swap/bridging tokens
|
|
167
171
|
* @param connectionRequest ConnectionsRequest
|
package/dist/LiFi.js
CHANGED
|
@@ -202,14 +202,16 @@ export class LiFi extends RouteExecutionManager {
|
|
|
202
202
|
* @param token - The token that should be checked
|
|
203
203
|
* @param ownerAddress - The owner of the token
|
|
204
204
|
* @param spenderAddress - The spender address that has to be approved
|
|
205
|
+
* @returns Returns allowance
|
|
205
206
|
*/
|
|
206
207
|
this.getTokenAllowance = async (token, ownerAddress, spenderAddress) => {
|
|
207
208
|
return getTokenAllowance(token, ownerAddress, spenderAddress);
|
|
208
209
|
};
|
|
209
210
|
/**
|
|
210
|
-
* Get the current allowance for a list of token
|
|
211
|
+
* Get the current allowance for a list of token/spender address pairs.
|
|
211
212
|
* @param ownerAddress - The owner of the tokens
|
|
212
213
|
* @param tokens - A list of token and spender address pairs
|
|
214
|
+
* @returns Returns array of tokens and their allowance
|
|
213
215
|
*/
|
|
214
216
|
this.getTokenAllowanceMulticall = async (ownerAddress, tokens) => {
|
|
215
217
|
return getTokenAllowanceMulticall(ownerAddress, tokens);
|
|
@@ -217,6 +219,7 @@ export class LiFi extends RouteExecutionManager {
|
|
|
217
219
|
/**
|
|
218
220
|
* Set approval for a certain token and amount.
|
|
219
221
|
* @param request - The approval request
|
|
222
|
+
* @returns Returns Hash or nothing
|
|
220
223
|
*/
|
|
221
224
|
this.setTokenApproval = (request) => {
|
|
222
225
|
return setTokenAllowance(request);
|
|
@@ -224,6 +227,7 @@ export class LiFi extends RouteExecutionManager {
|
|
|
224
227
|
/**
|
|
225
228
|
* Revoke approval for a certain token.
|
|
226
229
|
* @param request - The revoke request
|
|
230
|
+
* @returns Returns Hash or nothing
|
|
227
231
|
*/
|
|
228
232
|
this.revokeTokenApproval = (request) => {
|
|
229
233
|
return revokeTokenApproval(request);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Hash, WalletClient } from 'viem';
|
|
2
|
+
import type { InternalExecutionSettings } from '../types';
|
|
2
3
|
import type { ApproveTokenRequest, RevokeApprovalRequest } from './types';
|
|
3
|
-
export declare const setAllowance: (walletClient: WalletClient, tokenAddress: string, contractAddress: string, amount: bigint, returnPopulatedTransaction?: boolean) => Promise<Hash>;
|
|
4
|
+
export declare const setAllowance: (walletClient: WalletClient, tokenAddress: string, contractAddress: string, amount: bigint, settings?: InternalExecutionSettings, returnPopulatedTransaction?: boolean) => Promise<Hash>;
|
|
4
5
|
export declare const setTokenAllowance: ({ walletClient, token, spenderAddress, amount, infiniteApproval, }: ApproveTokenRequest) => Promise<Hash | undefined>;
|
|
5
6
|
export declare const revokeTokenApproval: ({ walletClient, token, spenderAddress, }: RevokeApprovalRequest) => Promise<Hash | undefined>;
|
|
@@ -3,7 +3,7 @@ import { approveAbi } from '../types';
|
|
|
3
3
|
import { getMaxPriorityFeePerGas } from '../utils';
|
|
4
4
|
import { isNativeTokenAddress } from '../utils/utils';
|
|
5
5
|
import { getAllowance } from './getAllowance';
|
|
6
|
-
export const setAllowance = async (walletClient, tokenAddress, contractAddress, amount, returnPopulatedTransaction) => {
|
|
6
|
+
export const setAllowance = async (walletClient, tokenAddress, contractAddress, amount, settings, returnPopulatedTransaction) => {
|
|
7
7
|
const data = encodeFunctionData({
|
|
8
8
|
abi: approveAbi,
|
|
9
9
|
functionName: 'approve',
|
|
@@ -13,15 +13,31 @@ export const setAllowance = async (walletClient, tokenAddress, contractAddress,
|
|
|
13
13
|
return data;
|
|
14
14
|
}
|
|
15
15
|
const client = walletClient.extend(publicActions);
|
|
16
|
-
let
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
let transactionRequest = {
|
|
17
|
+
to: tokenAddress,
|
|
18
|
+
data,
|
|
19
|
+
maxPriorityFeePerGas: walletClient.account?.type === 'local'
|
|
20
|
+
? await getMaxPriorityFeePerGas(client)
|
|
21
|
+
: undefined,
|
|
22
|
+
};
|
|
23
|
+
if (settings?.updateTransactionRequestHook) {
|
|
24
|
+
const customizedTransactionRequest = await settings.updateTransactionRequestHook({
|
|
25
|
+
requestType: 'approve',
|
|
26
|
+
...transactionRequest,
|
|
27
|
+
});
|
|
28
|
+
transactionRequest = {
|
|
29
|
+
...transactionRequest,
|
|
30
|
+
...customizedTransactionRequest,
|
|
31
|
+
};
|
|
19
32
|
}
|
|
20
33
|
return client.sendTransaction({
|
|
21
|
-
to:
|
|
34
|
+
to: transactionRequest.to,
|
|
22
35
|
account: walletClient.account,
|
|
23
|
-
data,
|
|
24
|
-
|
|
36
|
+
data: transactionRequest.data,
|
|
37
|
+
gas: transactionRequest.gas,
|
|
38
|
+
gasPrice: transactionRequest.gasPrice,
|
|
39
|
+
maxFeePerGas: transactionRequest.maxFeePerGas,
|
|
40
|
+
maxPriorityFeePerGas: transactionRequest.maxPriorityFeePerGas,
|
|
25
41
|
chain: null,
|
|
26
42
|
});
|
|
27
43
|
};
|
package/dist/cjs/LiFi.d.ts
CHANGED
|
@@ -144,24 +144,28 @@ export declare class LiFi extends RouteExecutionManager {
|
|
|
144
144
|
* @param token - The token that should be checked
|
|
145
145
|
* @param ownerAddress - The owner of the token
|
|
146
146
|
* @param spenderAddress - The spender address that has to be approved
|
|
147
|
+
* @returns Returns allowance
|
|
147
148
|
*/
|
|
148
149
|
getTokenAllowance: (token: Token, ownerAddress: string, spenderAddress: string) => Promise<bigint | undefined>;
|
|
149
150
|
/**
|
|
150
|
-
* Get the current allowance for a list of token
|
|
151
|
+
* Get the current allowance for a list of token/spender address pairs.
|
|
151
152
|
* @param ownerAddress - The owner of the tokens
|
|
152
153
|
* @param tokens - A list of token and spender address pairs
|
|
154
|
+
* @returns Returns array of tokens and their allowance
|
|
153
155
|
*/
|
|
154
156
|
getTokenAllowanceMulticall: (ownerAddress: string, tokens: TokenSpender[]) => Promise<TokenAllowance[]>;
|
|
155
157
|
/**
|
|
156
158
|
* Set approval for a certain token and amount.
|
|
157
159
|
* @param request - The approval request
|
|
160
|
+
* @returns Returns Hash or nothing
|
|
158
161
|
*/
|
|
159
|
-
setTokenApproval: (request: ApproveTokenRequest) => Promise<Hash |
|
|
162
|
+
setTokenApproval: (request: ApproveTokenRequest) => Promise<Hash | undefined>;
|
|
160
163
|
/**
|
|
161
164
|
* Revoke approval for a certain token.
|
|
162
165
|
* @param request - The revoke request
|
|
166
|
+
* @returns Returns Hash or nothing
|
|
163
167
|
*/
|
|
164
|
-
revokeTokenApproval: (request: RevokeApprovalRequest) => Promise<Hash |
|
|
168
|
+
revokeTokenApproval: (request: RevokeApprovalRequest) => Promise<Hash | undefined>;
|
|
165
169
|
/**
|
|
166
170
|
* Get all the available connections for swap/bridging tokens
|
|
167
171
|
* @param connectionRequest ConnectionsRequest
|
package/dist/cjs/LiFi.js
CHANGED
|
@@ -231,14 +231,16 @@ class LiFi extends RouteExecutionManager_1.RouteExecutionManager {
|
|
|
231
231
|
* @param token - The token that should be checked
|
|
232
232
|
* @param ownerAddress - The owner of the token
|
|
233
233
|
* @param spenderAddress - The spender address that has to be approved
|
|
234
|
+
* @returns Returns allowance
|
|
234
235
|
*/
|
|
235
236
|
this.getTokenAllowance = async (token, ownerAddress, spenderAddress) => {
|
|
236
237
|
return (0, allowance_1.getTokenAllowance)(token, ownerAddress, spenderAddress);
|
|
237
238
|
};
|
|
238
239
|
/**
|
|
239
|
-
* Get the current allowance for a list of token
|
|
240
|
+
* Get the current allowance for a list of token/spender address pairs.
|
|
240
241
|
* @param ownerAddress - The owner of the tokens
|
|
241
242
|
* @param tokens - A list of token and spender address pairs
|
|
243
|
+
* @returns Returns array of tokens and their allowance
|
|
242
244
|
*/
|
|
243
245
|
this.getTokenAllowanceMulticall = async (ownerAddress, tokens) => {
|
|
244
246
|
return (0, allowance_1.getTokenAllowanceMulticall)(ownerAddress, tokens);
|
|
@@ -246,6 +248,7 @@ class LiFi extends RouteExecutionManager_1.RouteExecutionManager {
|
|
|
246
248
|
/**
|
|
247
249
|
* Set approval for a certain token and amount.
|
|
248
250
|
* @param request - The approval request
|
|
251
|
+
* @returns Returns Hash or nothing
|
|
249
252
|
*/
|
|
250
253
|
this.setTokenApproval = (request) => {
|
|
251
254
|
return (0, allowance_1.setTokenAllowance)(request);
|
|
@@ -253,6 +256,7 @@ class LiFi extends RouteExecutionManager_1.RouteExecutionManager {
|
|
|
253
256
|
/**
|
|
254
257
|
* Revoke approval for a certain token.
|
|
255
258
|
* @param request - The revoke request
|
|
259
|
+
* @returns Returns Hash or nothing
|
|
256
260
|
*/
|
|
257
261
|
this.revokeTokenApproval = (request) => {
|
|
258
262
|
return (0, allowance_1.revokeTokenApproval)(request);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Hash, WalletClient } from 'viem';
|
|
2
|
+
import type { InternalExecutionSettings } from '../types';
|
|
2
3
|
import type { ApproveTokenRequest, RevokeApprovalRequest } from './types';
|
|
3
|
-
export declare const setAllowance: (walletClient: WalletClient, tokenAddress: string, contractAddress: string, amount: bigint, returnPopulatedTransaction?: boolean) => Promise<Hash>;
|
|
4
|
+
export declare const setAllowance: (walletClient: WalletClient, tokenAddress: string, contractAddress: string, amount: bigint, settings?: InternalExecutionSettings, returnPopulatedTransaction?: boolean) => Promise<Hash>;
|
|
4
5
|
export declare const setTokenAllowance: ({ walletClient, token, spenderAddress, amount, infiniteApproval, }: ApproveTokenRequest) => Promise<Hash | undefined>;
|
|
5
6
|
export declare const revokeTokenApproval: ({ walletClient, token, spenderAddress, }: RevokeApprovalRequest) => Promise<Hash | undefined>;
|
|
@@ -6,7 +6,7 @@ const types_1 = require("../types");
|
|
|
6
6
|
const utils_1 = require("../utils");
|
|
7
7
|
const utils_2 = require("../utils/utils");
|
|
8
8
|
const getAllowance_1 = require("./getAllowance");
|
|
9
|
-
const setAllowance = async (walletClient, tokenAddress, contractAddress, amount, returnPopulatedTransaction) => {
|
|
9
|
+
const setAllowance = async (walletClient, tokenAddress, contractAddress, amount, settings, returnPopulatedTransaction) => {
|
|
10
10
|
const data = (0, viem_1.encodeFunctionData)({
|
|
11
11
|
abi: types_1.approveAbi,
|
|
12
12
|
functionName: 'approve',
|
|
@@ -16,15 +16,31 @@ const setAllowance = async (walletClient, tokenAddress, contractAddress, amount,
|
|
|
16
16
|
return data;
|
|
17
17
|
}
|
|
18
18
|
const client = walletClient.extend(viem_1.publicActions);
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
let transactionRequest = {
|
|
20
|
+
to: tokenAddress,
|
|
21
|
+
data,
|
|
22
|
+
maxPriorityFeePerGas: walletClient.account?.type === 'local'
|
|
23
|
+
? await (0, utils_1.getMaxPriorityFeePerGas)(client)
|
|
24
|
+
: undefined,
|
|
25
|
+
};
|
|
26
|
+
if (settings?.updateTransactionRequestHook) {
|
|
27
|
+
const customizedTransactionRequest = await settings.updateTransactionRequestHook({
|
|
28
|
+
requestType: 'approve',
|
|
29
|
+
...transactionRequest,
|
|
30
|
+
});
|
|
31
|
+
transactionRequest = {
|
|
32
|
+
...transactionRequest,
|
|
33
|
+
...customizedTransactionRequest,
|
|
34
|
+
};
|
|
22
35
|
}
|
|
23
36
|
return client.sendTransaction({
|
|
24
|
-
to:
|
|
37
|
+
to: transactionRequest.to,
|
|
25
38
|
account: walletClient.account,
|
|
26
|
-
data,
|
|
27
|
-
|
|
39
|
+
data: transactionRequest.data,
|
|
40
|
+
gas: transactionRequest.gas,
|
|
41
|
+
gasPrice: transactionRequest.gasPrice,
|
|
42
|
+
maxFeePerGas: transactionRequest.maxFeePerGas,
|
|
43
|
+
maxPriorityFeePerGas: transactionRequest.maxPriorityFeePerGas,
|
|
28
44
|
chain: null,
|
|
29
45
|
});
|
|
30
46
|
};
|
|
@@ -92,30 +92,7 @@ class StepExecutionManager {
|
|
|
92
92
|
execution: step.execution,
|
|
93
93
|
};
|
|
94
94
|
}
|
|
95
|
-
|
|
96
|
-
to: step.transactionRequest?.to,
|
|
97
|
-
from: step.transactionRequest?.from,
|
|
98
|
-
data: step.transactionRequest?.data,
|
|
99
|
-
value: step.transactionRequest?.value
|
|
100
|
-
? BigInt(step.transactionRequest.value)
|
|
101
|
-
: undefined,
|
|
102
|
-
maxPriorityFeePerGas: walletClient.account?.type === 'local'
|
|
103
|
-
? await (0, utils_1.getMaxPriorityFeePerGas)(client)
|
|
104
|
-
: undefined,
|
|
105
|
-
// gas: step.transactionRequest?.gasLimit
|
|
106
|
-
// ? BigInt(step.transactionRequest.gasLimit as string)
|
|
107
|
-
// : undefined,
|
|
108
|
-
// gasPrice: step.transactionRequest?.gasPrice
|
|
109
|
-
// ? BigInt(step.transactionRequest.gasPrice as string)
|
|
110
|
-
// : undefined,
|
|
111
|
-
// maxFeePerGas: step.transactionRequest?.maxFeePerGas
|
|
112
|
-
// ? BigInt(step.transactionRequest.maxFeePerGas as string)
|
|
113
|
-
// : undefined,
|
|
114
|
-
// maxPriorityFeePerGas: step.transactionRequest?.maxPriorityFeePerGas
|
|
115
|
-
// ? BigInt(step.transactionRequest.maxPriorityFeePerGas as string)
|
|
116
|
-
// : undefined,
|
|
117
|
-
};
|
|
118
|
-
if (!transactionRequest) {
|
|
95
|
+
if (!step.transactionRequest) {
|
|
119
96
|
throw new errors_1.TransactionError(errors_1.LiFiErrorCode.TransactionUnprepared, 'Unable to prepare transaction.');
|
|
120
97
|
}
|
|
121
98
|
// STEP 3: Send the transaction
|
|
@@ -130,8 +107,33 @@ class StepExecutionManager {
|
|
|
130
107
|
if (!this.allowUserInteraction) {
|
|
131
108
|
return step.execution;
|
|
132
109
|
}
|
|
110
|
+
let transactionRequest = {
|
|
111
|
+
to: step.transactionRequest.to,
|
|
112
|
+
from: step.transactionRequest.from,
|
|
113
|
+
data: step.transactionRequest.data,
|
|
114
|
+
value: step.transactionRequest.value
|
|
115
|
+
? BigInt(step.transactionRequest.value)
|
|
116
|
+
: undefined,
|
|
117
|
+
gas: step.transactionRequest.gasLimit
|
|
118
|
+
? BigInt(step.transactionRequest.gasLimit)
|
|
119
|
+
: undefined,
|
|
120
|
+
// gasPrice: step.transactionRequest.gasPrice
|
|
121
|
+
// ? BigInt(step.transactionRequest.gasPrice as string)
|
|
122
|
+
// : undefined,
|
|
123
|
+
// maxFeePerGas: step.transactionRequest.maxFeePerGas
|
|
124
|
+
// ? BigInt(step.transactionRequest.maxFeePerGas as string)
|
|
125
|
+
// : undefined,
|
|
126
|
+
maxPriorityFeePerGas: walletClient.account?.type === 'local'
|
|
127
|
+
? await (0, utils_1.getMaxPriorityFeePerGas)(client)
|
|
128
|
+
: step.transactionRequest.maxPriorityFeePerGas
|
|
129
|
+
? BigInt(step.transactionRequest.maxPriorityFeePerGas)
|
|
130
|
+
: undefined,
|
|
131
|
+
};
|
|
133
132
|
if (settings.updateTransactionRequestHook) {
|
|
134
|
-
const customizedTransactionRequest = await settings.updateTransactionRequestHook(
|
|
133
|
+
const customizedTransactionRequest = await settings.updateTransactionRequestHook({
|
|
134
|
+
requestType: 'transaction',
|
|
135
|
+
...transactionRequest,
|
|
136
|
+
});
|
|
135
137
|
transactionRequest = {
|
|
136
138
|
...transactionRequest,
|
|
137
139
|
...customizedTransactionRequest,
|
|
@@ -157,6 +159,9 @@ class StepExecutionManager {
|
|
|
157
159
|
to: transactionRequest.to,
|
|
158
160
|
account: walletClient.account,
|
|
159
161
|
data: transactionRequest.data,
|
|
162
|
+
gas: transactionRequest.gas,
|
|
163
|
+
gasPrice: transactionRequest.gasPrice,
|
|
164
|
+
maxFeePerGas: transactionRequest.maxFeePerGas,
|
|
160
165
|
maxPriorityFeePerGas: transactionRequest.maxPriorityFeePerGas,
|
|
161
166
|
chain: null,
|
|
162
167
|
});
|
|
@@ -24,7 +24,7 @@ const checkAllowance = async (walletClient, step, statusManager, settings, chain
|
|
|
24
24
|
? viem_1.maxUint256
|
|
25
25
|
: fromAmount;
|
|
26
26
|
if (shouldBatchTransactions) {
|
|
27
|
-
const approveTxHash = await (0, allowance_1.setAllowance)(walletClient, step.action.fromToken.address, step.estimate.approvalAddress, approvalAmount, true);
|
|
27
|
+
const approveTxHash = await (0, allowance_1.setAllowance)(walletClient, step.action.fromToken.address, step.estimate.approvalAddress, approvalAmount, settings, true);
|
|
28
28
|
allowanceProcess = statusManager.updateProcess(step, allowanceProcess.type, 'DONE');
|
|
29
29
|
return approveTxHash;
|
|
30
30
|
}
|
|
@@ -21,7 +21,10 @@ export interface ExecutionParams {
|
|
|
21
21
|
settings: InternalExecutionSettings;
|
|
22
22
|
}
|
|
23
23
|
export type UpdateRouteHook = (updatedRoute: Route) => void;
|
|
24
|
-
export
|
|
24
|
+
export interface TransactionRequestParameters extends TransactionParameters {
|
|
25
|
+
requestType: 'approve' | 'transaction';
|
|
26
|
+
}
|
|
27
|
+
export type TransactionRequestUpdateHook = (updatedTxRequest: TransactionRequestParameters) => Promise<TransactionParameters>;
|
|
25
28
|
export type Config = {
|
|
26
29
|
apiUrl: string;
|
|
27
30
|
rpcs: Record<ChainId, string[]>;
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/sdk";
|
|
2
|
-
export declare const version = "3.0.0-alpha.
|
|
2
|
+
export declare const version = "3.0.0-alpha.6";
|
package/dist/cjs/version.js
CHANGED
|
@@ -86,30 +86,7 @@ export class StepExecutionManager {
|
|
|
86
86
|
execution: step.execution,
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
-
|
|
90
|
-
to: step.transactionRequest?.to,
|
|
91
|
-
from: step.transactionRequest?.from,
|
|
92
|
-
data: step.transactionRequest?.data,
|
|
93
|
-
value: step.transactionRequest?.value
|
|
94
|
-
? BigInt(step.transactionRequest.value)
|
|
95
|
-
: undefined,
|
|
96
|
-
maxPriorityFeePerGas: walletClient.account?.type === 'local'
|
|
97
|
-
? await getMaxPriorityFeePerGas(client)
|
|
98
|
-
: undefined,
|
|
99
|
-
// gas: step.transactionRequest?.gasLimit
|
|
100
|
-
// ? BigInt(step.transactionRequest.gasLimit as string)
|
|
101
|
-
// : undefined,
|
|
102
|
-
// gasPrice: step.transactionRequest?.gasPrice
|
|
103
|
-
// ? BigInt(step.transactionRequest.gasPrice as string)
|
|
104
|
-
// : undefined,
|
|
105
|
-
// maxFeePerGas: step.transactionRequest?.maxFeePerGas
|
|
106
|
-
// ? BigInt(step.transactionRequest.maxFeePerGas as string)
|
|
107
|
-
// : undefined,
|
|
108
|
-
// maxPriorityFeePerGas: step.transactionRequest?.maxPriorityFeePerGas
|
|
109
|
-
// ? BigInt(step.transactionRequest.maxPriorityFeePerGas as string)
|
|
110
|
-
// : undefined,
|
|
111
|
-
};
|
|
112
|
-
if (!transactionRequest) {
|
|
89
|
+
if (!step.transactionRequest) {
|
|
113
90
|
throw new TransactionError(LiFiErrorCode.TransactionUnprepared, 'Unable to prepare transaction.');
|
|
114
91
|
}
|
|
115
92
|
// STEP 3: Send the transaction
|
|
@@ -124,8 +101,33 @@ export class StepExecutionManager {
|
|
|
124
101
|
if (!this.allowUserInteraction) {
|
|
125
102
|
return step.execution;
|
|
126
103
|
}
|
|
104
|
+
let transactionRequest = {
|
|
105
|
+
to: step.transactionRequest.to,
|
|
106
|
+
from: step.transactionRequest.from,
|
|
107
|
+
data: step.transactionRequest.data,
|
|
108
|
+
value: step.transactionRequest.value
|
|
109
|
+
? BigInt(step.transactionRequest.value)
|
|
110
|
+
: undefined,
|
|
111
|
+
gas: step.transactionRequest.gasLimit
|
|
112
|
+
? BigInt(step.transactionRequest.gasLimit)
|
|
113
|
+
: undefined,
|
|
114
|
+
// gasPrice: step.transactionRequest.gasPrice
|
|
115
|
+
// ? BigInt(step.transactionRequest.gasPrice as string)
|
|
116
|
+
// : undefined,
|
|
117
|
+
// maxFeePerGas: step.transactionRequest.maxFeePerGas
|
|
118
|
+
// ? BigInt(step.transactionRequest.maxFeePerGas as string)
|
|
119
|
+
// : undefined,
|
|
120
|
+
maxPriorityFeePerGas: walletClient.account?.type === 'local'
|
|
121
|
+
? await getMaxPriorityFeePerGas(client)
|
|
122
|
+
: step.transactionRequest.maxPriorityFeePerGas
|
|
123
|
+
? BigInt(step.transactionRequest.maxPriorityFeePerGas)
|
|
124
|
+
: undefined,
|
|
125
|
+
};
|
|
127
126
|
if (settings.updateTransactionRequestHook) {
|
|
128
|
-
const customizedTransactionRequest = await settings.updateTransactionRequestHook(
|
|
127
|
+
const customizedTransactionRequest = await settings.updateTransactionRequestHook({
|
|
128
|
+
requestType: 'transaction',
|
|
129
|
+
...transactionRequest,
|
|
130
|
+
});
|
|
129
131
|
transactionRequest = {
|
|
130
132
|
...transactionRequest,
|
|
131
133
|
...customizedTransactionRequest,
|
|
@@ -151,6 +153,9 @@ export class StepExecutionManager {
|
|
|
151
153
|
to: transactionRequest.to,
|
|
152
154
|
account: walletClient.account,
|
|
153
155
|
data: transactionRequest.data,
|
|
156
|
+
gas: transactionRequest.gas,
|
|
157
|
+
gasPrice: transactionRequest.gasPrice,
|
|
158
|
+
maxFeePerGas: transactionRequest.maxFeePerGas,
|
|
154
159
|
maxPriorityFeePerGas: transactionRequest.maxPriorityFeePerGas,
|
|
155
160
|
chain: null,
|
|
156
161
|
});
|
|
@@ -21,7 +21,7 @@ export const checkAllowance = async (walletClient, step, statusManager, settings
|
|
|
21
21
|
? maxUint256
|
|
22
22
|
: fromAmount;
|
|
23
23
|
if (shouldBatchTransactions) {
|
|
24
|
-
const approveTxHash = await setAllowance(walletClient, step.action.fromToken.address, step.estimate.approvalAddress, approvalAmount, true);
|
|
24
|
+
const approveTxHash = await setAllowance(walletClient, step.action.fromToken.address, step.estimate.approvalAddress, approvalAmount, settings, true);
|
|
25
25
|
allowanceProcess = statusManager.updateProcess(step, allowanceProcess.type, 'DONE');
|
|
26
26
|
return approveTxHash;
|
|
27
27
|
}
|
|
@@ -21,7 +21,10 @@ export interface ExecutionParams {
|
|
|
21
21
|
settings: InternalExecutionSettings;
|
|
22
22
|
}
|
|
23
23
|
export type UpdateRouteHook = (updatedRoute: Route) => void;
|
|
24
|
-
export
|
|
24
|
+
export interface TransactionRequestParameters extends TransactionParameters {
|
|
25
|
+
requestType: 'approve' | 'transaction';
|
|
26
|
+
}
|
|
27
|
+
export type TransactionRequestUpdateHook = (updatedTxRequest: TransactionRequestParameters) => Promise<TransactionParameters>;
|
|
25
28
|
export type Config = {
|
|
26
29
|
apiUrl: string;
|
|
27
30
|
rpcs: Record<ChainId, string[]>;
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/sdk";
|
|
2
|
-
export declare const version = "3.0.0-alpha.
|
|
2
|
+
export declare const version = "3.0.0-alpha.6";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/sdk';
|
|
2
|
-
export const version = '3.0.0-alpha.
|
|
2
|
+
export const version = '3.0.0-alpha.6';
|
package/package.json
CHANGED
|
@@ -1,23 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/sdk",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.6",
|
|
4
4
|
"description": "LI.FI Any-to-Any Cross-Chain-Swap SDK",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"bridge",
|
|
7
|
+
"bridge-aggregation",
|
|
8
|
+
"cross-chain",
|
|
9
|
+
"cross-chain-applications",
|
|
10
|
+
"cross-chain-bridge",
|
|
11
|
+
"dapp",
|
|
12
|
+
"defi",
|
|
13
|
+
"ethereum",
|
|
14
|
+
"ethers",
|
|
15
|
+
"lifi",
|
|
16
|
+
"metamask",
|
|
17
|
+
"multi-chain",
|
|
18
|
+
"sdk",
|
|
19
|
+
"swap",
|
|
20
|
+
"viem",
|
|
21
|
+
"wagmi",
|
|
22
|
+
"web3",
|
|
23
|
+
"web3-react"
|
|
24
|
+
],
|
|
25
|
+
"homepage": "https://github.com/lifinance/sdk",
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/lifinance/sdk/issues"
|
|
28
|
+
},
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+ssh://git@github.com/lifinance/sdk.git"
|
|
32
|
+
},
|
|
33
|
+
"license": "Apache-2.0",
|
|
34
|
+
"author": "Max Klenk <max@li.finance>",
|
|
5
35
|
"main": "./dist/cjs/index.js",
|
|
6
36
|
"module": "./dist/index.js",
|
|
7
37
|
"types": "./dist/index.d.ts",
|
|
38
|
+
"directories": {
|
|
39
|
+
"test": "tests"
|
|
40
|
+
},
|
|
41
|
+
"files": [
|
|
42
|
+
"dist"
|
|
43
|
+
],
|
|
8
44
|
"scripts": {
|
|
9
45
|
"addscope": "node tools/packagejson name @lifi/sdk",
|
|
10
46
|
"build": "yarn clean && tsc --project ./tsconfig.json && tsc --project ./tsconfig.cjs.json",
|
|
11
47
|
"clean": "node tools/cleanup",
|
|
12
48
|
"coverage": "vitest run --coverage",
|
|
49
|
+
"_postinstall": "husky install",
|
|
13
50
|
"lint": "eslint --ext .tsx --ext .ts ./src",
|
|
14
51
|
"lint:fix": "eslint --ext .tsx --ext .ts ./src --fix",
|
|
52
|
+
"prepack": "pinst --disable",
|
|
53
|
+
"postpack": "pinst --enable",
|
|
15
54
|
"package": "npm run build && npm pack",
|
|
16
|
-
"postpublish": "npm run use:gitReadme && pinst --enable",
|
|
17
55
|
"pre-commit": "lint-staged",
|
|
18
56
|
"pre-push": "yarn types:check && yarn build && yarn test:unit",
|
|
19
|
-
"
|
|
20
|
-
"prepublishOnly": "run-s build use:npmReadme && pinst --enable",
|
|
57
|
+
"prepublishOnly": "npm run build",
|
|
21
58
|
"prettier:fix": "prettier --write ./src/.",
|
|
22
59
|
"release": "standard-version -a",
|
|
23
60
|
"release:alpha": "standard-version -a --prerelease alpha --skip.changelog",
|
|
@@ -27,87 +64,48 @@
|
|
|
27
64
|
"test:e2e": "yarn test -c vitest.e2e.config.ts",
|
|
28
65
|
"test:unit": "yarn test .unit.spec.ts",
|
|
29
66
|
"types:check": "tsc --noEmit",
|
|
30
|
-
"use:gitReadme": "mv 'README.md' 'npm.README.md' && mv 'git.README.md' 'README.md'",
|
|
31
|
-
"use:npmReadme": "mv 'README.md' 'git.README.md' && mv 'npm.README.md' 'README.md'",
|
|
32
67
|
"watch": "tsc -w -p ./tsconfig.json"
|
|
33
68
|
},
|
|
34
|
-
"standard-version": {
|
|
35
|
-
"scripts": {
|
|
36
|
-
"postbump": "node scripts/version.js && git add ."
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
69
|
"lint-staged": {
|
|
40
70
|
"src/**/*.{ts,tsx}": [
|
|
41
71
|
"yarn run lint:fix",
|
|
42
72
|
"yarn run prettier:fix"
|
|
43
73
|
]
|
|
44
74
|
},
|
|
45
|
-
"files": [
|
|
46
|
-
"dist"
|
|
47
|
-
],
|
|
48
|
-
"publishConfig": {
|
|
49
|
-
"access": "public"
|
|
50
|
-
},
|
|
51
|
-
"author": "Max Klenk <max@li.finance>",
|
|
52
|
-
"license": "Apache-2.0",
|
|
53
|
-
"keywords": [
|
|
54
|
-
"bridge",
|
|
55
|
-
"bridge-aggregation",
|
|
56
|
-
"cross-chain",
|
|
57
|
-
"cross-chain-applications",
|
|
58
|
-
"cross-chain-bridge",
|
|
59
|
-
"dapp",
|
|
60
|
-
"defi",
|
|
61
|
-
"ethereum",
|
|
62
|
-
"ethers",
|
|
63
|
-
"lifi",
|
|
64
|
-
"metamask",
|
|
65
|
-
"multi-chain",
|
|
66
|
-
"sdk",
|
|
67
|
-
"swap",
|
|
68
|
-
"viem",
|
|
69
|
-
"wagmi",
|
|
70
|
-
"web3",
|
|
71
|
-
"web3-react"
|
|
72
|
-
],
|
|
73
|
-
"homepage": "https://github.com/lifinance/sdk",
|
|
74
|
-
"repository": {
|
|
75
|
-
"type": "git",
|
|
76
|
-
"url": "git+ssh://git@github.com/lifinance/sdk.git"
|
|
77
|
-
},
|
|
78
|
-
"bugs": {
|
|
79
|
-
"url": "https://github.com/lifinance/sdk/issues"
|
|
80
|
-
},
|
|
81
75
|
"dependencies": {
|
|
82
|
-
"@lifi/types": "^9.0.0-alpha.
|
|
76
|
+
"@lifi/types": "^9.0.0-alpha.11",
|
|
83
77
|
"eth-rpc-errors": "^4.0.3",
|
|
84
|
-
"viem": "^1.
|
|
78
|
+
"viem": "^1.9.2"
|
|
85
79
|
},
|
|
86
80
|
"devDependencies": {
|
|
87
81
|
"@commitlint/cli": "^17.7.1",
|
|
88
82
|
"@commitlint/config-conventional": "^17.7.0",
|
|
89
83
|
"@mswjs/interceptors": "^0.22.16",
|
|
90
84
|
"@types/ws": "^8.5.5",
|
|
91
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
92
|
-
"@typescript-eslint/parser": "^6.
|
|
93
|
-
"@vitest/coverage-v8": "^0.34.
|
|
85
|
+
"@typescript-eslint/eslint-plugin": "^6.5.0",
|
|
86
|
+
"@typescript-eslint/parser": "^6.5.0",
|
|
87
|
+
"@vitest/coverage-v8": "^0.34.3",
|
|
94
88
|
"cross-fetch": "^4.0.0",
|
|
95
|
-
"eslint": "^8.
|
|
89
|
+
"eslint": "^8.48.0",
|
|
96
90
|
"eslint-config-prettier": "^9.0.0",
|
|
97
|
-
"eslint-plugin-jsdoc": "^46.
|
|
91
|
+
"eslint-plugin-jsdoc": "^46.5.1",
|
|
98
92
|
"eslint-plugin-prettier": "^5.0.0",
|
|
99
93
|
"husky": "^8.0.3",
|
|
100
|
-
"lint-staged": "^
|
|
94
|
+
"lint-staged": "^14.0.1",
|
|
101
95
|
"msw": "1.0.1",
|
|
102
|
-
"npm-run-all": "^4.1.5",
|
|
103
96
|
"pinst": "^3.0.0",
|
|
104
|
-
"prettier": "^3.0.
|
|
97
|
+
"prettier": "^3.0.3",
|
|
105
98
|
"standard-version": "^9.5.0",
|
|
106
|
-
"typescript": "^5.
|
|
107
|
-
"vitest": "^0.34.
|
|
99
|
+
"typescript": "^5.2.2",
|
|
100
|
+
"vitest": "^0.34.3"
|
|
108
101
|
},
|
|
109
|
-
"
|
|
110
|
-
|
|
102
|
+
"packageManager": "yarn@3.6.3",
|
|
103
|
+
"publishConfig": {
|
|
104
|
+
"access": "public"
|
|
111
105
|
},
|
|
112
|
-
"
|
|
106
|
+
"standard-version": {
|
|
107
|
+
"scripts": {
|
|
108
|
+
"postbump": "node scripts/version.js && git add ."
|
|
109
|
+
}
|
|
110
|
+
}
|
|
113
111
|
}
|