Skip to content

Commit

Permalink
Merge branch 'develop' into feat/broadcast-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
cs1707 committed Sep 19, 2023
2 parents 8b09b0d + 5611558 commit 89d223d
Show file tree
Hide file tree
Showing 38 changed files with 2,573 additions and 256 deletions.
12 changes: 12 additions & 0 deletions __tests__/migration/contactMigration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ const data: { preference: PreferenceStore; contactBook } = {
walletSavedList: [],
watchAddressPreference: {},
testnetBalanceMap: {},
addressSortStore: {
search: '',
sortType: 'usd',
},
},
contactBook: {
'0x10b26700b0a2d3f5ef12fa250aba818ee3b43bf4': {
Expand Down Expand Up @@ -188,6 +192,10 @@ test('should migrate when no alians', () => {
walletSavedList: [],
watchAddressPreference: {},
testnetBalanceMap: {},
addressSortStore: {
search: '',
sortType: 'usd',
},
},
contactBook: {
'0x10b26700b0a2d3f5ef12fa250aba818ee3b43bf4': {
Expand Down Expand Up @@ -316,6 +324,10 @@ test('should migrate when no contacts', () => {
walletSavedList: [],
watchAddressPreference: {},
testnetBalanceMap: {},
addressSortStore: {
search: '',
sortType: 'usd',
},
},
contactBook: {},
};
Expand Down
Binary file modified _raw/images/rabby-site-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion _raw/locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,11 @@
"backup-seed-phrase": "Backup Seed Phrase",
"delete-all-addresses-but-keep-the-seed-phrase": "Delete all addresses, but keep the seed phrase",
"delete-all-addresses-and-the-seed-phrase": "Delete all addresses and the seed phrase",
"seed-phrase-delete-title": "Delete seed phrase?"
"seed-phrase-delete-title": "Delete seed phrase?",
"sort-by-balance": "Sort by balance",
"sort-by-address-type": "Sort by address type",
"sort-by-address-note": "Sort by address note",
"sort-address": "Sort Address"
},
"dashboard": {
"home": {
Expand Down
5 changes: 3 additions & 2 deletions _raw/locales/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
{ "code": "es", "name": "Español" },
{ "code": "fr_FR", "name": "Français" },
{ "code": "ua_UA", "name": "Українська" },
{ "code": "tr", "name": "Türkçe" }
]
{ "code": "tr", "name": "Türkçe" },
{ "code": "pt_BR", "name": "Português Brasileiro"}
]
1,620 changes: 1,620 additions & 0 deletions _raw/locales/pt_BR/messages.json

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion _raw/locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,11 @@
"seed-phrase-delete-title": "删除助记词?",
"update-balance-data": "刷新所有余额",
"watch-address": "观察地址",
"whitelisted-address": "白名单地址"
"whitelisted-address": "白名单地址",
"sort-by-balance": "按地址金额排序",
"sort-by-address-type": "按地址类型排序",
"sort-by-address-note": "按地址备注排序",
"sort-address": "地址排序"
},
"receive": {
"title": "在 {{chain}} 上接收{{token}}",
Expand Down
2 changes: 1 addition & 1 deletion _raw/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "__MSG_appName__",
"short_name": "__MSG_appName__",
"version": "0.92.22",
"version": "0.92.23",
"default_locale": "en",
"description": "__MSG_appDescription__",
"icons": {
Expand Down
5 changes: 5 additions & 0 deletions changeLogs/09223.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- Supported to sort address based on address note and type
- Supported PGN chain
- Supported 4 testnets, including EvmOS Testnet, BitTorrent Donau Testnet, Flare Coston2 Testnet, and PGN Sepolia
- Supported swap on Base chain
- Supported new language - Brazilian Portuguese
2 changes: 2 additions & 0 deletions changeLogs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import version09219 from './09219.md';
import version09220 from './09220.md';
import version09221 from './09221.md';
import version09222 from './09222.md';
import version09223 from './09223.md';

const version = process.env.release || '0';
const versionMap = {
Expand Down Expand Up @@ -88,6 +89,7 @@ const versionMap = {
'0.92.20': version09220,
'0.92.21': version09221,
'0.92.22': version09222,
'0.92.23': version09223,
};
export const getUpdateContent = () => {
return versionMap[version];
Expand Down
5 changes: 5 additions & 0 deletions changeLogs/zh_CN/09223.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- 地址列表支持按照地址类型和地址备注排序
- 支持 PGN 链
- 支持4条测试网,包括EvmOS Testnet、BitTorrent Donau Testnet、Flare Coston2 Testnet、PGN Sepolia
- Swap 支持 Base 链
- 支持葡语(巴西)
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rabby",
"version": "0.92.22",
"version": "0.92.23",
"description": "A browser plugin for DeFi users",
"scripts": {
"clean": "mkdir -p dist && rm -rf dist/*",
Expand Down Expand Up @@ -44,7 +44,7 @@
"@rabby-wallet/page-provider": "^0.1.20",
"@rabby-wallet/rabby-api": "^0.6.22-alpha.0",
"@rabby-wallet/rabby-security-engine": "^1.1.16",
"@rabby-wallet/rabby-swap": "^0.0.28",
"@rabby-wallet/rabby-swap": "^0.0.29",
"@rabby-wallet/widgets": "^1.0.9",
"@rematch/core": "^2.2.0",
"@rematch/select": "^3.1.2",
Expand Down
131 changes: 83 additions & 48 deletions src/background/controller/provider/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
i18n,
swapService,
transactionBroadcastWatchService,
notificationService,
} from 'background/service';
import { notification } from 'background/webapi';
import { Session } from 'background/service/session';
Expand Down Expand Up @@ -423,6 +424,22 @@ class ProviderController extends BaseController {
) {
await new Promise((r) => setTimeout(r, 200));
}
const statsData = {
signed: false,
signedSuccess: false,
submit: false,
submitSuccess: false,
type: currentAccount.brandName,
chainId: chainItem?.serverId || '',
category: KEYRING_CATEGORY_MAP[currentAccount.type],
preExecSuccess: cacheExplain
? cacheExplain.pre_exec.success && cacheExplain.calcSuccess
: true,
createBy: options?.data?.$ctx?.ga ? 'rabby' : 'dapp',
source: options?.data?.$ctx?.ga?.source || '',
trigger: options?.data?.$ctx?.ga?.trigger || '',
};

try {
const signedTx = await keyringService.signTransaction(
keyring,
Expand All @@ -435,18 +452,20 @@ class ProviderController extends BaseController {
currentAccount.type === KEYRING_TYPE.CoboArgusKeyring
) {
signedTransactionSuccess = true;
stats.report('signedTransaction', {
type: currentAccount.brandName,
chainId: chainItem?.serverId || '',
category: KEYRING_CATEGORY_MAP[currentAccount.type],
success: true,
preExecSuccess: cacheExplain
? cacheExplain.pre_exec.success && cacheExplain.calcSuccess
: true,
createBy: options?.data?.$ctx?.ga ? 'rabby' : 'dapp',
source: options?.data?.$ctx?.ga?.source || '',
trigger: options?.data?.$ctx?.ga?.trigger || '',
});
// stats.report('signedTransaction', {
// type: currentAccount.brandName,
// chainId: chainItem?.serverId || '',
// category: KEYRING_CATEGORY_MAP[currentAccount.type],
// success: true,
// preExecSuccess: cacheExplain
// ? cacheExplain.pre_exec.success && cacheExplain.calcSuccess
// : true,
// createBy: options?.data?.$ctx?.ga ? 'rabby' : 'dapp',
// source: options?.data?.$ctx?.ga?.source || '',
// trigger: options?.data?.$ctx?.ga?.trigger || '',
// });
statsData.signed = true;
statsData.signedSuccess = true;
return;
}

Expand All @@ -469,18 +488,23 @@ class ProviderController extends BaseController {

const { r, s, v, ...other } = approvalRes;

stats.report('submitTransaction', {
type: currentAccount.brandName,
chainId: chainItem?.serverId || '',
category: KEYRING_CATEGORY_MAP[currentAccount.type],
success: true,
preExecSuccess: cacheExplain
? cacheExplain.pre_exec.success && cacheExplain.calcSuccess
: true,
createBy: options?.data?.$ctx?.ga ? 'rabby' : 'dapp',
source: options?.data?.$ctx?.ga?.source || '',
trigger: options?.data?.$ctx?.ga?.trigger || '',
});
// todo
// swapService.postSwap(chain, hash, other);

// stats.report('submitTransaction', {
// type: currentAccount.brandName,
// chainId: chainItem?.serverId || '',
// category: KEYRING_CATEGORY_MAP[currentAccount.type],
// success: true,
// preExecSuccess: cacheExplain
// ? cacheExplain.pre_exec.success && cacheExplain.calcSuccess
// : true,
// createBy: options?.data?.$ctx?.ga ? 'rabby' : 'dapp',
// source: options?.data?.$ctx?.ga?.source || '',
// trigger: options?.data?.$ctx?.ga?.trigger || '',
// });
statsData.submit = true;
statsData.submitSuccess = true;
if (isSend) {
pageStateCacheService.clear();
}
Expand Down Expand Up @@ -650,6 +674,12 @@ class ProviderController extends BaseController {
hash: signedTx,
pushType: 'default',
});
// onTransactionSubmitted(signedTx);
if (currentAccount.type === KEYRING_TYPE.WalletConnectKeyring) {
statsData.signed = true;
statsData.signedSuccess = true;
}
notificationService.setStatsData(statsData);
return signedTx;
}

Expand All @@ -676,18 +706,20 @@ class ProviderController extends BaseController {
}
}
signedTransactionSuccess = true;
stats.report('signedTransaction', {
type: currentAccount.brandName,
chainId: chainItem?.serverId || '',
category: KEYRING_CATEGORY_MAP[currentAccount.type],
success: true,
preExecSuccess: cacheExplain
? cacheExplain.pre_exec.success && cacheExplain.calcSuccess
: true,
createBy: options?.data?.$ctx?.ga ? 'rabby' : 'dapp',
source: options?.data?.$ctx?.ga?.source || '',
trigger: options?.data?.$ctx?.ga?.trigger || '',
});
// stats.report('signedTransaction', {
// type: currentAccount.brandName,
// chainId: chainItem?.serverId || '',
// category: KEYRING_CATEGORY_MAP[currentAccount.type],
// success: true,
// preExecSuccess: cacheExplain
// ? cacheExplain.pre_exec.success && cacheExplain.calcSuccess
// : true,
// createBy: options?.data?.$ctx?.ga ? 'rabby' : 'dapp',
// source: options?.data?.$ctx?.ga?.source || '',
// trigger: options?.data?.$ctx?.ga?.trigger || '',
// });
statsData.signed = true;
statsData.signedSuccess = true;
eventBus.emit(EVENTS.broadcastToUI, {
method: EVENTS.TX_SUBMITTING,
});
Expand Down Expand Up @@ -762,20 +794,23 @@ class ProviderController extends BaseController {
}
} catch (e) {
if (!signedTransactionSuccess) {
stats.report('signedTransaction', {
type: currentAccount.brandName,
chainId: chainItem?.serverId || '',
category: KEYRING_CATEGORY_MAP[currentAccount.type],
success: false,
preExecSuccess: cacheExplain
? cacheExplain.pre_exec.success && cacheExplain.calcSuccess
: true,
createBy: options?.data?.$ctx?.ga ? 'rabby' : 'dapp',
source: options?.data?.$ctx?.ga?.source || '',
trigger: options?.data?.$ctx?.ga?.trigger || '',
});
// stats.report('signedTransaction', {
// type: currentAccount.brandName,
// chainId: chainItem?.serverId || '',
// category: KEYRING_CATEGORY_MAP[currentAccount.type],
// success: false,
// preExecSuccess: cacheExplain
// ? cacheExplain.pre_exec.success && cacheExplain.calcSuccess
// : true,
// createBy: options?.data?.$ctx?.ga ? 'rabby' : 'dapp',
// source: options?.data?.$ctx?.ga?.source || '',
// trigger: options?.data?.$ctx?.ga?.trigger || '',
// });
statsData.signed = true;
statsData.signedSuccess = false;
}
// transactionHistoryService.removeSigningTx(signingTxId!);
notificationService.setStatsData(statsData);
throw new Error(e);
}
};
Expand Down
29 changes: 29 additions & 0 deletions src/background/controller/provider/rpcFlow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import eventBus from '@/eventBus';
import { resemblesETHAddress } from '@/utils';
import { ProviderRequest } from './type';
import * as Sentry from '@sentry/browser';
import stats from '@/stats';

const isSignApproval = (type: string) => {
const SIGN_APPROVALS = ['SignText', 'SignTypedData', 'SignTx'];
Expand Down Expand Up @@ -282,7 +283,35 @@ const flowContext = flow

export default (request: ProviderRequest) => {
const ctx: any = { request: { ...request, requestedApproval: false } };
notificationService.setStatsData();
return flowContext(ctx).finally(() => {
const statsData = notificationService.getStatsData();

if (statsData?.signed) {
stats.report('signedTransaction', {
type: statsData?.type,
chainId: statsData?.chainId,
category: statsData?.category,
success: statsData?.signedSuccess,
preExecSuccess: statsData?.preExecSuccess,
createBy: statsData?.createBy,
source: statsData?.source,
trigger: statsData?.trigger,
});
}
if (statsData?.submit) {
stats.report('submitTransaction', {
type: statsData?.type,
chainId: statsData?.chainId,
category: statsData?.category,
success: statsData?.submitSuccess,
preExecSuccess: statsData?.preExecSuccess,
createBy: statsData?.createBy,
source: statsData?.source,
trigger: statsData?.trigger,
});
}

if (ctx.request.requestedApproval) {
flow.requestedApproval = false;
// only unlock notification if current flow is an approval flow
Expand Down
3 changes: 3 additions & 0 deletions src/background/controller/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,9 @@ export class WalletController extends BaseController {
getLastSelectedGasTopUpChain = preferenceService.getLastSelectedGasTopUpChain;
setLastSelectedGasTopUpChain = preferenceService.setLastSelectedGasTopUpChain;

getAddressSortStoreValue = preferenceService.getAddressSortStoreValue;
setAddressSortStoreValue = preferenceService.setAddressSortStoreValue;

getLastSelectedSwapChain = swapService.getSelectedChain;
setLastSelectedSwapChain = swapService.setSelectedChain;
getSwap = swapService.getSwap;
Expand Down
Loading

0 comments on commit 89d223d

Please sign in to comment.