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

Converted to webapp to more easily view the archive #343

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 0 additions & 14 deletions .babelrc

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ __pycache__/

# Ignore build releases.
rose-wallet-*.zip

.parcel-cache
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"version": "1.15.0",
"private": true,
"scripts": {
"build": "env NODE_OPTIONS=--openssl-legacy-provider webpack --mode production",
"buildProd": "env NODE_OPTIONS=--openssl-legacy-provider webpack --mode production",
"dev": "env NODE_OPTIONS=--openssl-legacy-provider webpack --mode development --progress --watch",
"build": "yarn parcel build ./public/static/popup.html",
"buildProd": "yarn build",
"dev": "yarn parcel ./public/static/popup.html",
"lint": "yarn run eslint src",
"test": "jest"
},
Expand Down Expand Up @@ -71,6 +71,7 @@
"@babel/preset-env": "7.12.7",
"@babel/preset-react": "7.12.7",
"@babel/runtime": "7.12.5",
"@parcel/transformer-sass": "2.12.0",
"@types/chrome": "^0.0.193",
"@types/lodash": "^4.14.195",
"@types/prop-types": "^15.7.4",
Expand All @@ -91,10 +92,12 @@
"jest-chrome": "^0.7.2",
"jsdom": "^20.0.0",
"jsdom-global": "^3.0.2",
"parcel": "^2.12.0",
"polyfill-crypto.getrandomvalues": "1.0.0",
"react-scripts": "4.0.1",
"sass": "^1.45.1",
"sinon": "^11.1.1",
"stream-browserify": "^3.0.0",
"url-loader": "4.1.1",
"webpack": "4.44.2",
"webpack-cli": "4.2.0"
Expand Down
3 changes: 0 additions & 3 deletions public/oasis-xu-frame.html

This file was deleted.

3 changes: 1 addition & 2 deletions public/static/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script src="./common.js"></script>
<script src="./popup.js"></script>
<script type="module" src="../../src/index.js"></script>
</body>

</html>
73 changes: 2 additions & 71 deletions src/background/messageListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@
DAPP_CHANGE_CONNECTING_ADDRESS, DAPP_GET_CURRENT_OPEN_WINDOW, GET_APP_LOCK_STATUS,
FRAME_GET_APPROVE_ACCOUNT, FRAME_GET_ACCOUNT_PUBLIC_KEY, FRAME_GET_ACCOUNT_SIGNER, FRAME_SEND_TRANSFER, RESET_WALLET, WALLET_SEND_RUNTIME_WITHDRAW, WALLET_SEND_RUNTIME_DEPOSIT, WALLET_SEND_RUNTIME_EVM_WITHDRAW
} from "../constant/types";
import extension from 'extensionizer'
import extension from './../mockWebextension'

Check warning on line 36 in src/background/messageListener.js

View workflow job for this annotation

GitHub Actions / lint

Unknown word (Webextension)
import apiService from "./service/APIService";
import extDappService from "./service/ExtDappService";
import { openPopupWindow } from '../utils/popup';

function internalMessageListener(message, sender, sendResponseSerializable) {
const sendResponse = (response) => {
Expand All @@ -56,10 +54,7 @@
return sendResponseSerializable(response)
}

const { messageSource, action, payload } = message;
if (messageSource) {
return false
}
const { action, payload } = message;
switch (action) {
case WALLET_CREATE_PWD:
sendResponse(apiService.createPwd(payload.pwd));
Expand Down Expand Up @@ -189,73 +184,9 @@
case WALLET_RESET_LAST_ACTIVE_TIME:
sendResponse(apiService.setLastActiveTime())
break
case WALLET_OPEN_ROUTE_IN_PERSISTENT_POPUP:
openPopupWindow(extension.extension.getURL(payload.route), 'persistentPopup', undefined, {
left: payload.left,
top: payload.top,
}).then((result) => {
sendResponse(result);
});
break
case GET_APP_LOCK_STATUS:
sendResponse(apiService.getLockStatus())
break
case FRAME_GET_APPROVE_ACCOUNT:
extDappService.requestAccounts(payload.origin).then((account) => {
sendResponse(account);
}).catch((err)=>{
sendResponse(err)
})
break

case FRAME_GET_ACCOUNT_PUBLIC_KEY:
extDappService.getApproveAccountPublicKey(payload.origin).then((account) => {
sendResponse(account);
}).catch((err)=>{
sendResponse(err)
})
break

case FRAME_GET_ACCOUNT_SIGNER:
extDappService.getApproveAccountSigner(payload).then((account) => {
sendResponse(account);
}).catch((err)=>sendResponse(err))
break
case FRAME_SEND_TRANSFER:
extDappService.signTransaction(payload.params,payload.origin).then((account) => {
sendResponse(account);
}).catch((err)=>sendResponse(err))
break
case GET_SIGN_PARAMS:
sendResponse(extDappService.getSignParams())
break
case DAPP_GET_APPROVE_ACCOUNT:
extDappService.getCurrentApproveAccount(payload.siteUrl,payload.address).then((account)=>{
sendResponse(account)
})
break
case DAPP_GET_ALL_APPROVE_ACCOUNT:
sendResponse(extDappService.getAllApproveAccount(payload.siteUrl))
break
case DAPP_GET_CONNECT_STATUS:
sendResponse(extDappService.getConnectedStatus(payload.siteUrl,payload.address))
break
case DAPP_DISCONNECT_SITE:
sendResponse(extDappService.disconnectDapp(payload.siteUrl,payload.address,payload.currentAddress))
break

case DAPP_ACCOUNT_CONNECT_SITE:
sendResponse(extDappService.setDAppCurrentConnect(payload.siteUrl,payload.account))
break
case DAPP_DELETE_ACCOUNT_CONNECT_HIS:
sendResponse(extDappService.deleteDAppConnect(payload.address,payload.currentAddress))
break
case DAPP_CHANGE_CONNECTING_ADDRESS:
sendResponse(extDappService.changeCurrentConnecting(payload.address))
break
case DAPP_GET_CURRENT_OPEN_WINDOW:
sendResponse(extDappService.getCurrentOpenWindow())
break
case RESET_WALLET:
sendResponse(apiService.resetWallet())
break
Expand Down
24 changes: 11 additions & 13 deletions src/background/service/APIService.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { decode } from 'base64-arraybuffer';
import BigNumber from 'bignumber.js';
import * as bip39 from 'bip39';
import extension from 'extensionizer';
import extension from './../../mockWebextension';

Check warning on line 6 in src/background/service/APIService.js

View workflow job for this annotation

GitHub Actions / lint

Unknown word (Webextension)
import { Buffer } from 'safe-buffer';
import nacl from 'tweetnacl';
import { cointypes, LOCK_TIME } from '../../../config';
Expand Down Expand Up @@ -142,8 +142,8 @@
if (!status) {
this.memStore.putState(this.initLockedState())
extension.runtime.sendMessage({
type: FROM_BACK_TO_RECORD,
action: SET_LOCK,
type: FROM_BACK_TO_RECORD,
});
}else{
this.memStore.updateState({ isUnlocked: status })
Expand Down Expand Up @@ -933,21 +933,18 @@
? getExplorerUrl() + "paratimes/transactions/" + encodeURIComponent(hash) + "?runtime=" + encodeURIComponent(runtimeId)
: getExplorerUrl() + "transactions/" + encodeURIComponent(hash)

const notificationListener = (clickedNotificationId) => {
if(notificationLinkAsId !== clickedNotificationId) return
extension.notifications.onClicked.removeListener(notificationListener)
openTab(notificationLinkAsId)
}
extension.notifications.onClicked.addListener(notificationListener)
extension.notifications.create(notificationLinkAsId, {
title: getLanguage('notificationTitle'),
message: getLanguage('notificationContent'),
iconUrl: '/img/oasis.png',
type: 'basic'

Notification.requestPermission().then((permission) => {
if (permission === 'granted') {
const notification = new Notification(getLanguage('notificationTitle'), { body: getLanguage('notificationContent'), icon: '/img/oasis.png' });
notification.addEventListener('click', () => openTab(notificationLinkAsId))
}
});

return
}
checkTxStatus = (hash,hideNotify,callback) => {
Notification.requestPermission().then((permission) => {})
this.fetchTransactionStatus(hash,hideNotify,callback)
}
onSuccess=(data,hash,hideNotify,callback)=>{
Expand Down Expand Up @@ -988,6 +985,7 @@
})
}
createNotificationAfterRuntimeTxSucceeds = (hash,runtimeId) => {
Notification.requestPermission().then((permission) => {})
this.fetchRuntimeTxStatus(hash,runtimeId)
}
fetchRuntimeTxStatus = (hash,runtimeId) => {
Expand Down
Loading
Loading