Compare commits
6 Commits
Author | SHA1 | Date |
---|---|---|
armaniferrante | d41271f9c9 | |
armaniferrante | 1aae052784 | |
armaniferrante | 9cc0495d4a | |
Shardul Aeer | 3f213aa5ae | |
Shardul Aeer | 80b0fa4605 | |
Armani Ferrante | 4a92cad65a |
|
@ -11,6 +11,7 @@ import {
|
|||
Connection,
|
||||
Transaction,
|
||||
TransactionSignature,
|
||||
PublicKey,
|
||||
} from "@solana/web3.js";
|
||||
import {
|
||||
TokenListContainer,
|
||||
|
@ -118,6 +119,13 @@ function AppInner() {
|
|||
);
|
||||
}
|
||||
|
||||
// Cast wallet to AnchorWallet in order to be compatible with Anchor's Provider class
|
||||
interface AnchorWallet {
|
||||
signTransaction(tx: Transaction): Promise<Transaction>;
|
||||
signAllTransactions(txs: Transaction[]): Promise<Transaction[]>;
|
||||
publicKey: PublicKey;
|
||||
}
|
||||
|
||||
// Custom provider to display notifications whenever a transaction is sent.
|
||||
//
|
||||
// Note that this is an Anchor wallet/network provider--not a React provider,
|
||||
|
@ -137,7 +145,8 @@ class NotifyingProvider extends Provider {
|
|||
opts: ConfirmOptions,
|
||||
onTransaction: (tx: TransactionSignature | undefined, err?: Error) => void
|
||||
) {
|
||||
super(connection, wallet, opts);
|
||||
const newWallet = wallet as AnchorWallet;
|
||||
super(connection, newWallet, opts);
|
||||
this.onTransaction = onTransaction;
|
||||
}
|
||||
|
||||
|
@ -151,7 +160,9 @@ class NotifyingProvider extends Provider {
|
|||
this.onTransaction(txSig);
|
||||
return txSig;
|
||||
} catch (err) {
|
||||
this.onTransaction(undefined, err);
|
||||
if (err instanceof Error || err === undefined) {
|
||||
this.onTransaction(undefined, err);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
@ -167,7 +178,9 @@ class NotifyingProvider extends Provider {
|
|||
});
|
||||
return txSigs;
|
||||
} catch (err) {
|
||||
this.onTransaction(undefined, err);
|
||||
if (err instanceof Error || err === undefined) {
|
||||
this.onTransaction(undefined, err);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
66
package.json
66
package.json
|
@ -1,23 +1,23 @@
|
|||
{
|
||||
"name": "@project-serum/swap-ui",
|
||||
"version": "0.2.2",
|
||||
"version": "0.2.5",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"homepage": "https://github.com/project-serum/swap-ui",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@project-serum/serum": "^0.13.34",
|
||||
"@project-serum/swap": "^0.1.0-alpha.31",
|
||||
"@solana/spl-token": "^0.1.4"
|
||||
"@project-serum/serum": "^0.13.58",
|
||||
"@project-serum/swap": "^0.1.0-alpha.35",
|
||||
"@solana/spl-token": "^0.1.8"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@material-ui/core": "^4.11.4",
|
||||
"@material-ui/core": "^4.12.3",
|
||||
"@material-ui/icons": "^4.11.2",
|
||||
"@material-ui/lab": "^4.0.0-alpha.58",
|
||||
"@project-serum/anchor": "^0.7.0",
|
||||
"@solana/spl-token-registry": "^0.2.86",
|
||||
"@material-ui/lab": "^4.0.0-alpha.60",
|
||||
"@project-serum/anchor": "^0.14.0",
|
||||
"@solana/spl-token-registry": "^0.2.229",
|
||||
"@solana/web3.js": "^1.17.1",
|
||||
"material-ui-popup-state": "^1.8.3",
|
||||
"material-ui-popup-state": "^1.9.3",
|
||||
"react": "^17.0.2",
|
||||
"react-async-hook": "^3.6.2"
|
||||
},
|
||||
|
@ -35,39 +35,39 @@
|
|||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@fontsource/roboto": "4.3.0",
|
||||
"@material-ui/core": "^4.11.4",
|
||||
"@fontsource/roboto": "4.5.0",
|
||||
"@material-ui/core": "^4.12.3",
|
||||
"@material-ui/icons": "^4.11.2",
|
||||
"@material-ui/lab": "^4.0.0-alpha.58",
|
||||
"@project-serum/anchor": "^0.7.0",
|
||||
"@project-serum/serum": "^0.13.34",
|
||||
"@project-serum/sol-wallet-adapter": "^0.2.0",
|
||||
"@project-serum/swap": "^0.1.0-alpha.31",
|
||||
"@solana/spl-token": "^0.1.4",
|
||||
"@solana/spl-token-registry": "^0.2.86",
|
||||
"@solana/web3.js": "^1.17.0",
|
||||
"@testing-library/jest-dom": "^5.11.4",
|
||||
"@testing-library/react": "^11.1.0",
|
||||
"@testing-library/user-event": "^12.1.10",
|
||||
"@material-ui/lab": "^4.0.0-alpha.60",
|
||||
"@project-serum/anchor": "^0.14.0",
|
||||
"@project-serum/serum": "^0.13.58",
|
||||
"@project-serum/sol-wallet-adapter": "^0.2.5",
|
||||
"@project-serum/swap": "^0.1.0-alpha.35",
|
||||
"@solana/spl-token": "^0.1.8",
|
||||
"@solana/spl-token-registry": "^0.2.229",
|
||||
"@solana/web3.js": "^1.24.1",
|
||||
"@testing-library/jest-dom": "^5.14.1",
|
||||
"@testing-library/react": "^12.0.0",
|
||||
"@testing-library/user-event": "^13.2.1",
|
||||
"@types/bs58": "^4.0.1",
|
||||
"@types/jest": "^26.0.15",
|
||||
"@types/node": "^12.0.0",
|
||||
"@types/react": "^17.0.0",
|
||||
"@types/react-dom": "^17.0.0",
|
||||
"@types/jest": "^27.0.1",
|
||||
"@types/node": "^16.7.10",
|
||||
"@types/react": "^17.0.19",
|
||||
"@types/react-dom": "^17.0.9",
|
||||
"bs58": "^4.0.1",
|
||||
"gh-pages": "^3.1.0",
|
||||
"material-ui-popup-state": "^1.8.3",
|
||||
"notistack": "^1.0.7",
|
||||
"prettier": "^2.3.0",
|
||||
"gh-pages": "^3.2.3",
|
||||
"material-ui-popup-state": "^1.9.3",
|
||||
"notistack": "^1.0.10",
|
||||
"prettier": "^2.3.2",
|
||||
"react": "^17.0.2",
|
||||
"react-app-rewire-alias": "^1.0.3",
|
||||
"react-app-rewired": "^2.1.8",
|
||||
"react-async-hook": "^3.6.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-scripts": "4.0.3",
|
||||
"typedoc": "^0.20.36",
|
||||
"typescript": "^4.1.2",
|
||||
"web-vitals": "^1.0.1"
|
||||
"typedoc": "^0.21.9",
|
||||
"typescript": "^4.4.2",
|
||||
"web-vitals": "^2.1.0"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
|
|
|
@ -128,12 +128,18 @@ export function useOwnedTokenAccount(
|
|||
listener = provider.connection.onAccountChange(
|
||||
tokenAccount.publicKey,
|
||||
(info) => {
|
||||
const token = parseTokenAccountData(info.data);
|
||||
if (token.amount !== tokenAccount.account.amount) {
|
||||
const index = _OWNED_TOKEN_ACCOUNTS_CACHE.indexOf(tokenAccount);
|
||||
assert.ok(index >= 0);
|
||||
_OWNED_TOKEN_ACCOUNTS_CACHE[index].account = token;
|
||||
setRefresh((r) => r + 1);
|
||||
if (info.data.length !== 0) {
|
||||
try {
|
||||
const token = parseTokenAccountData(info.data);
|
||||
if (token.amount !== tokenAccount.account.amount) {
|
||||
const index = _OWNED_TOKEN_ACCOUNTS_CACHE.indexOf(tokenAccount);
|
||||
assert.ok(index >= 0);
|
||||
_OWNED_TOKEN_ACCOUNTS_CACHE[index].account = token;
|
||||
setRefresh((r) => r + 1);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("Failed to decode token AccountInfo");
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
@ -58,6 +58,8 @@ export default function Swap(props: SwapProps): ReactElement {
|
|||
toAmount,
|
||||
referral,
|
||||
} = props;
|
||||
|
||||
// @ts-ignore
|
||||
const swapClient = new SwapClient(provider, tokenList);
|
||||
const theme = createMuiTheme(
|
||||
materialTheme || {
|
||||
|
|
Loading…
Reference in New Issue