Update Sollet Extension

This commit is contained in:
jhlx 2021-08-06 10:02:57 +08:00
parent c887be818c
commit ec9bc85750
4 changed files with 46 additions and 35 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "Sollet", "name": "Sollet",
"description": "Solana SPL Token Wallet", "description": "Solana SPL Token Wallet",
"version": "0.3.0", "version": "0.3.1",
"browser_action": { "browser_action": {
"default_popup": "index.html", "default_popup": "index.html",
"default_title": "Open the popup" "default_title": "Open the popup"
@ -14,14 +14,20 @@
}, },
"background": { "background": {
"persistent": true, "persistent": true,
"scripts": ["background.js"] "scripts": [
"background.js"
]
}, },
"permissions": [ "permissions": [
"storage" "storage"
], ],
"content_scripts": [ "content_scripts": [
{ {
"matches": ["file://*/*", "http://*/*", "https://*/*"], "matches": [
"file://*/*",
"http://*/*",
"https://*/*"
],
"js": [ "js": [
"contentscript.js" "contentscript.js"
], ],
@ -29,7 +35,8 @@
"all_frames": true "all_frames": true
} }
], ],
"web_accessible_resources": ["script.js"], "web_accessible_resources": [
"script.js"
],
"content_security_policy": "script-src 'self' 'sha256-ek+jXksbUr00x+EdLLqiv69t8hATh5rPjHVvVVGA9ms='; object-src 'self'" "content_security_policy": "script-src 'self' 'sha256-ek+jXksbUr00x+EdLLqiv69t8hATh5rPjHVvVVGA9ms='; object-src 'self'"
} }

View File

@ -70,21 +70,23 @@ export default function NavigationFrame({ children }) {
return ( return (
<> <>
<AppBar position="static"> <AppBar position="static">
<div {!isExtension && (
style={{ <div
textAlign: 'center', style={{
background: '#fafafa', textAlign: 'center',
color: 'black', background: '#fafafa',
paddingLeft: '24px', color: 'black',
paddingRight: '24px', paddingLeft: '24px',
fontSize: '14px', paddingRight: '24px',
}} fontSize: '14px',
> }}
<Typography> >
Beware of sites attempting to impersonate sollet.io or other DeFi <Typography>
services. Beware of sites attempting to impersonate sollet.io or other DeFi
</Typography> services.
</div> </Typography>
</div>
)}
<Toolbar> <Toolbar>
<Typography variant="h6" className={classes.title} component="h1"> <Typography variant="h6" className={classes.title} component="h1">
{isExtensionWidth ? 'Sollet' : 'Solana SPL Token Wallet'} {isExtensionWidth ? 'Sollet' : 'Solana SPL Token Wallet'}

View File

@ -10,7 +10,6 @@ import SwapHoriz from '@material-ui/icons/SwapHoriz';
import PopupState, { bindTrigger, bindPopover } from 'material-ui-popup-state'; import PopupState, { bindTrigger, bindPopover } from 'material-ui-popup-state';
import Swap from '@project-serum/swap-ui'; import Swap from '@project-serum/swap-ui';
import { Provider } from '@project-serum/anchor'; import { Provider } from '@project-serum/anchor';
import { Connection, TransactionSignature } from '@solana/web3.js';
import { TokenListContainer } from '@solana/spl-token-registry'; import { TokenListContainer } from '@solana/spl-token-registry';
import { useTokenInfos } from '../utils/tokens/names'; import { useTokenInfos } from '../utils/tokens/names';
import { useSendTransaction } from '../utils/notifications'; import { useSendTransaction } from '../utils/notifications';
@ -22,9 +21,9 @@ import DialogForm from './DialogForm';
export default function SwapButton({ size }) { export default function SwapButton({ size }) {
const isExtensionWidth = useIsExtensionWidth(); const isExtensionWidth = useIsExtensionWidth();
if (isExtensionWidth) { if (isExtensionWidth) {
return <SwapButtonDialog />; return <SwapButtonDialog size={size} />;
} else { } else {
return <SwapButtonPopover />; return <SwapButtonPopover size={size} />;
} }
} }
@ -119,9 +118,9 @@ function SwapButtonPopover({ size }) {
class NotifyingProvider extends Provider { class NotifyingProvider extends Provider {
constructor( constructor(
connection: Connection, connection,
wallet: Wallet, wallet,
sendTransaction: (Promise<TransactionSignature>, Function) => void, sendTransaction,
) { ) {
super(connection, wallet, { super(connection, wallet, {
commitment: 'recent', commitment: 'recent',
@ -130,10 +129,10 @@ class NotifyingProvider extends Provider {
} }
async send( async send(
tx: Transaction, tx,
signers?: Array<Signer | undefined>, signers,
opts?: ConfirmOptions, opts,
): Promise<TransactionSignature> { ) {
return new Promise((onSuccess, onError) => { return new Promise((onSuccess, onError) => {
this.sendTransaction(super.send(tx, signers, opts), { this.sendTransaction(super.send(tx, signers, opts), {
onSuccess, onSuccess,
@ -143,11 +142,11 @@ class NotifyingProvider extends Provider {
} }
async sendAll( async sendAll(
txs: Array<{ tx: Transaction, signers: Array<Signer | undefined> }>, txs,
opts?: ConfirmOptions, opts,
): Promise<Array<TransactionSignature>> { ) {
return new Promise(async (resolve, onError) => { return new Promise(async (resolve, onError) => {
let txSigs: Array<TransactionSignature> = []; let txSigs = [];
for (const tx of txs) { for (const tx of txs) {
txSigs.push( txSigs.push(
await new Promise((onSuccess) => { await new Promise((onSuccess) => {

View File

@ -117,6 +117,7 @@ const toInstruction = async (
); );
} else if (programId.equals(RAYDIUM_STAKE_PROGRAM_ID)) { } else if (programId.equals(RAYDIUM_STAKE_PROGRAM_ID)) {
console.log('[' + index + '] Handled as raydium stake instruction'); console.log('[' + index + '] Handled as raydium stake instruction');
// @ts-ignore
const decodedInstruction = decodeStakeInstruction(decoded); const decodedInstruction = decodeStakeInstruction(decoded);
return await handleRayStakeInstruction( return await handleRayStakeInstruction(
connection, connection,
@ -126,6 +127,7 @@ const toInstruction = async (
); );
} else if (programId.equals(RAYDIUM_LP_PROGRAM_ID)) { } else if (programId.equals(RAYDIUM_LP_PROGRAM_ID)) {
console.log('[' + index + '] Handled as raydium lp instruction'); console.log('[' + index + '] Handled as raydium lp instruction');
// @ts-ignore
const decodedInstruction = decodeLpInstruction(decoded); const decodedInstruction = decodeLpInstruction(decoded);
return await handleRayLpInstruction( return await handleRayLpInstruction(
connection, connection,
@ -135,6 +137,7 @@ const toInstruction = async (
); );
} else if (programId.equals(MANGO_PROGRAM_ID) || programId.equals(MANGO_PROGRAM_ID_V2)) { } else if (programId.equals(MANGO_PROGRAM_ID) || programId.equals(MANGO_PROGRAM_ID_V2)) {
console.log('[' + index + '] Handled as mango markets instruction'); console.log('[' + index + '] Handled as mango markets instruction');
// @ts-ignore
let decodedInstruction = decodeMangoInstruction(decoded); let decodedInstruction = decodeMangoInstruction(decoded);
return await handleMangoInstruction( return await handleMangoInstruction(
connection, connection,