Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:fix fix swaps for SA #3303

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9a128d5
Merge branch 'main' of https://github.com/reown-com/appkit
svenvoskamp Sep 19, 2024
71f4058
Merge branch 'main' of https://github.com/reown-com/appkit
svenvoskamp Sep 20, 2024
bc7b24e
Merge branch 'main' of https://github.com/reown-com/appkit
svenvoskamp Sep 23, 2024
2b9a3db
Merge branch 'main' of https://github.com/reown-com/appkit
svenvoskamp Sep 24, 2024
3bdbaec
Merge branch 'main' of https://github.com/reown-com/appkit
svenvoskamp Sep 26, 2024
b60643a
Merge branch 'main' of https://github.com/reown-com/appkit
svenvoskamp Sep 27, 2024
7db0f42
Merge branch 'main' of https://github.com/reown-com/appkit
svenvoskamp Oct 2, 2024
34d19b4
Merge branch 'main' of https://github.com/reown-com/appkit
svenvoskamp Oct 9, 2024
9ac3b69
Merge branch 'main' of https://github.com/reown-com/appkit
svenvoskamp Nov 13, 2024
e5d5f33
Merge branch 'main' of https://github.com/reown-com/appkit
svenvoskamp Nov 14, 2024
ecab080
Merge branch 'main' of https://github.com/reown-com/appkit
svenvoskamp Nov 14, 2024
2c7cd61
Merge branch 'main' of https://github.com/reown-com/appkit
svenvoskamp Nov 15, 2024
1065e16
Merge branch 'main' of https://github.com/reown-com/appkit
svenvoskamp Nov 15, 2024
9164df0
Merge branch 'main' of https://github.com/reown-com/appkit
svenvoskamp Nov 18, 2024
672b9e8
Merge branch 'main' of https://github.com/reown-com/appkit
svenvoskamp Nov 18, 2024
7715f95
Merge branch 'main' of https://github.com/reown-com/appkit
svenvoskamp Nov 19, 2024
3c67cb1
Merge branch 'main' of https://github.com/reown-com/appkit
svenvoskamp Nov 19, 2024
05646dd
Merge branch 'main' of https://github.com/reown-com/appkit
svenvoskamp Nov 20, 2024
7193992
Merge branch 'main' of https://github.com/reown-com/appkit
svenvoskamp Nov 20, 2024
7151a56
Merge branch 'main' of https://github.com/reown-com/appkit
svenvoskamp Nov 21, 2024
775803c
Merge branch 'main' of https://github.com/reown-com/appkit
svenvoskamp Nov 21, 2024
04a61e8
fix swaps
svenvoskamp Nov 21, 2024
7ff7f0e
fix build
svenvoskamp Nov 21, 2024
4f95183
Merge branch 'main' into fix/fix-sa-swaps
svenvoskamp Nov 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/appkit/exports/constants.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const PACKAGE_VERSION = '1.5.0'
export const PACKAGE_VERSION = '1.5.1'
29 changes: 8 additions & 21 deletions packages/core/src/controllers/SwapController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ export const SwapController = {

switch (ChainController.state?.activeCaipNetwork?.chainNamespace) {
case 'solana':
state.gasFee = res.standard ?? '0'
state.gasFee = res.standard ?? ''
state.gasPriceInUSD = NumberUtil.multiply(res.standard, state.networkPrice)
.dividedBy(1e9)
.toNumber()
Expand All @@ -467,15 +467,15 @@ export const SwapController = {
case 'eip155':
default:
// eslint-disable-next-line no-case-declarations
const value = res.standard ?? '0'
const value = res.standard
// eslint-disable-next-line no-case-declarations
const gasFee = BigInt(value)
const gasFee = BigInt(value ?? '0')
// eslint-disable-next-line no-case-declarations
const gasLimit = BigInt(INITIAL_GAS_LIMIT)
// eslint-disable-next-line no-case-declarations
const gasPrice = SwapCalculationUtil.getGasPriceInUSD(state.networkPrice, gasLimit, gasFee)

state.gasFee = value
state.gasFee = value ?? ''
state.gasPriceInUSD = gasPrice

return { gasPrice: gasFee, gasPriceInUSD: gasPrice }
Expand Down Expand Up @@ -559,7 +559,7 @@ export const SwapController = {
if (hasAllowance) {
transaction = await this.createSwapTransaction()
} else {
transaction = await this.createAllowanceTransaction()
transaction = (await this.createAllowanceTransaction()) as TransactionParams
}

state.loadingBuildTransaction = false
Expand Down Expand Up @@ -610,24 +610,11 @@ export const SwapController = {
value: BigInt(response.tx.value),
toAmount: state.toTokenAmount
}

state.swapTransaction = undefined
state.approvalTransaction = {
data: transaction.data,
to: transaction.to,
gas: transaction.gas ?? BigInt(0),
gasPrice: transaction.gasPrice,
value: transaction.value,
toAmount: transaction.toAmount
}
state.approvalTransaction = transaction as TransactionParams

return {
data: transaction.data,
to: transaction.to,
gas: transaction.gas ?? BigInt(0),
gasPrice: transaction.gasPrice,
value: transaction.value,
toAmount: transaction.toAmount
}
return transaction
} catch (error) {
RouterController.goBack()
SnackController.showError('Failed to create approval transaction')
Expand Down
Loading