Pass through wallet to swap api (#28)

This commit is contained in:
Armani Ferrante 2021-05-31 14:43:45 -07:00 committed by GitHub
parent 49f82b7def
commit 4537ffdfcd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@project-serum/swap-ui",
"version": "0.1.0-alpha.18",
"version": "0.1.0-alpha.19",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"homepage": "https://github.com/project-serum/swap-ui",
@ -15,7 +15,7 @@
"@material-ui/core": "^4.11.4",
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "^4.0.0-alpha.58",
"@project-serum/anchor": "^0.6.0-beta.1",
"@project-serum/anchor": "^0.7.0",
"@solana/spl-token-registry": "^0.2.86",
"@solana/web3.js": "^1.10.1",
"material-ui-popup-state": "^1.8.3",

View File

@ -319,6 +319,8 @@ function SwapButton() {
const canSwap = useCanSwap();
const referral = useReferral(fromMarket);
const fair = useSwapFair();
const fromWallet = useOwnedTokenAccount(fromMint);
const toWallet = useOwnedTokenAccount(toMint);
// Click handler.
const sendSwapTransaction = async () => {
@ -347,6 +349,8 @@ function SwapButton() {
await swapClient.swap({
fromMint,
toMint,
fromWallet: fromWallet ? fromWallet.publicKey : undefined,
toWallet: toWallet ? toWallet.publicKey : undefined,
amount,
minExchangeRate,
referral,