Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feat/add_custom_token
Browse files Browse the repository at this point in the history
  • Loading branch information
richardo2016x committed Apr 26, 2024
2 parents 5595d1a + 43a6897 commit b99568a
Show file tree
Hide file tree
Showing 66 changed files with 777 additions and 515 deletions.
63 changes: 63 additions & 0 deletions _raw/css/Noto+Sans+JP.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
@font-face {
font-family: 'Noto Sans JP';
font-style: normal;
font-weight: 100;
font-display: swap;
src: url(https://fonts.gstatic.com/s/notosansjp/v52/-F6jfjtqLzI2JPCgQBnw7HFyzSD-AsregP8VFBEi75s.ttf) format('truetype');
}
@font-face {
font-family: 'Noto Sans JP';
font-style: normal;
font-weight: 200;
font-display: swap;
src: url(https://fonts.gstatic.com/s/notosansjp/v52/-F6jfjtqLzI2JPCgQBnw7HFyzSD-AsregP8VFJEj75s.ttf) format('truetype');
}
@font-face {
font-family: 'Noto Sans JP';
font-style: normal;
font-weight: 300;
font-display: swap;
src: url(https://fonts.gstatic.com/s/notosansjp/v52/-F6jfjtqLzI2JPCgQBnw7HFyzSD-AsregP8VFE8j75s.ttf) format('truetype');
}
@font-face {
font-family: 'Noto Sans JP';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(https://fonts.gstatic.com/s/notosansjp/v52/-F6jfjtqLzI2JPCgQBnw7HFyzSD-AsregP8VFBEj75s.ttf) format('truetype');
}
@font-face {
font-family: 'Noto Sans JP';
font-style: normal;
font-weight: 500;
font-display: swap;
src: url(https://fonts.gstatic.com/s/notosansjp/v52/-F6jfjtqLzI2JPCgQBnw7HFyzSD-AsregP8VFCMj75s.ttf) format('truetype');
}
@font-face {
font-family: 'Noto Sans JP';
font-style: normal;
font-weight: 600;
font-display: swap;
src: url(https://fonts.gstatic.com/s/notosansjp/v52/-F6jfjtqLzI2JPCgQBnw7HFyzSD-AsregP8VFM8k75s.ttf) format('truetype');
}
@font-face {
font-family: 'Noto Sans JP';
font-style: normal;
font-weight: 700;
font-display: swap;
src: url(https://fonts.gstatic.com/s/notosansjp/v52/-F6jfjtqLzI2JPCgQBnw7HFyzSD-AsregP8VFPYk75s.ttf) format('truetype');
}
@font-face {
font-family: 'Noto Sans JP';
font-style: normal;
font-weight: 800;
font-display: swap;
src: url(https://fonts.gstatic.com/s/notosansjp/v52/-F6jfjtqLzI2JPCgQBnw7HFyzSD-AsregP8VFJEk75s.ttf) format('truetype');
}
@font-face {
font-family: 'Noto Sans JP';
font-style: normal;
font-weight: 900;
font-display: swap;
src: url(https://fonts.gstatic.com/s/notosansjp/v52/-F6jfjtqLzI2JPCgQBnw7HFyzSD-AsregP8VFLgk75s.ttf) format('truetype');
}
3 changes: 2 additions & 1 deletion _raw/locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,8 @@
"disconnectRecentlyUsed": {
"title_one": "Disconnect <strong>{{count}}</strong> connected Dapp",
"title_other": "Disconnect <strong>{{count}}</strong> connected Dapps",
"description": "Pinned DApps will remain connected"
"description": "Pinned DApps will remain connected",
"title": "Disconnect recently used <strong>{{count}}</strong> DApps"
},
"title": "Connected Dapp",
"pinned": "Pinned",
Expand Down
2 changes: 1 addition & 1 deletion _raw/locales/zh-CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@
"Balance": "余额",
"Confirm": "确认",
"Continue": "继续",
"Including-service-fee": "包含 ${{fee}} 服务费",
"Including-service-fee": "包含 {{fee}} 服务费",
"InsufficientBalance": "当前链的 Rabby 合约地址余额不足,\n请稍后再试",
"InsufficientBalanceTips": "余额不足",
"Loading_Tokens": "正在加载代币...",
Expand Down
2 changes: 1 addition & 1 deletion _raw/locales/zh-HK/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@
"Balance": "結餘",
"Confirm": "確認",
"Continue": "繼續",
"Including-service-fee": "包含 ${{fee}} 服務費",
"Including-service-fee": "包含 {{fee}} 服務費",
"InsufficientBalance": "當前鏈的 Rabby 合約地址結餘不足,\n請稍後再試",
"InsufficientBalanceTips": "結餘不足",
"Loading_Tokens": "正在加載代幣...",
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@
"@rabby-wallet/eth-lattice-keyring": "1.1.0",
"@rabby-wallet/eth-simple-keyring": "5.0.1",
"@rabby-wallet/eth-trezor-keyring": "2.5.1",
"@rabby-wallet/eth-walletconnect-keyring": "2.1.2",
"@rabby-wallet/eth-walletconnect-keyring": "2.1.3",
"@rabby-wallet/eth-watch-keyring": "1.0.0",
"@rabby-wallet/gnosis-sdk": "1.3.6",
"@rabby-wallet/page-provider": "0.3.2",
"@rabby-wallet/page-provider": "0.3.3",
"@rabby-wallet/rabby-api": "0.7.13",
"@rabby-wallet/rabby-security-engine": "1.1.20",
"@rabby-wallet/rabby-swap": "0.0.34",
"@rabby-wallet/rabby-swap": "0.0.36",
"@rabby-wallet/widgets": "1.0.9",
"@rematch/core": "2.2.0",
"@rematch/select": "3.1.2",
Expand Down
6 changes: 6 additions & 0 deletions src/background/controller/provider/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,9 @@ class ProviderController extends BaseController {
createBy: options?.data?.$ctx?.ga ? 'rabby' : 'dapp',
source: options?.data?.$ctx?.ga?.source || '',
trigger: options?.data?.$ctx?.ga?.trigger || '',
networkType: chainItem?.isTestnet
? 'Custom Network'
: 'Integrated Network',
reported: false,
};

Expand Down Expand Up @@ -574,6 +577,9 @@ class ProviderController extends BaseController {
createBy: options?.data?.$ctx?.ga ? 'rabby' : 'dapp',
source: options?.data?.$ctx?.ga?.source || '',
trigger: options?.data?.$ctx?.ga?.trigger || '',
networkType: chainItem?.isTestnet
? 'Custom Network'
: 'Integrated Network',
});
if (!isSpeedUp && !isCancel) {
transactionHistoryService.addSubmitFailedTransaction({
Expand Down
5 changes: 3 additions & 2 deletions src/background/controller/provider/rpcFlow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import * as Sentry from '@sentry/browser';
import stats from '@/stats';
import { addHexPrefix, stripHexPrefix } from 'ethereumjs-util';
import { findChain } from '@/utils/chain';
import browser from 'webextension-polyfill';

const isSignApproval = (type: string) => {
const SIGN_APPROVALS = ['SignText', 'SignTypedData', 'SignTx'];
Expand All @@ -25,7 +24,7 @@ const lockedOrigins = new Set<string>();
const connectOrigins = new Set<string>();

const getScreenAvailHeight = async () => {
return (await browser.windows.getCurrent()).height || 1000;
return 1000;
};

const flow = new PromiseFlow<{
Expand Down Expand Up @@ -304,6 +303,7 @@ function reportStatsData() {
createBy: statsData?.createBy,
source: statsData?.source,
trigger: statsData?.trigger,
networkType: statsData?.networkType,
};
if (statsData.signMethod) {
sData.signMethod = statsData.signMethod;
Expand All @@ -320,6 +320,7 @@ function reportStatsData() {
createBy: statsData?.createBy,
source: statsData?.source,
trigger: statsData?.trigger,
networkType: statsData?.networkType || '',
});
}

Expand Down
26 changes: 24 additions & 2 deletions src/background/controller/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ import { customTestnetService } from '../service/customTestnet';
import { getKeyringBridge, hasBridge } from '../service/keyring/bridge';
import { http } from '../utils/http';
import { syncChainService } from '../service/syncChain';
import { matomoRequestEvent } from '@/utils/matomo-request';

const stashKeyrings: Record<string | number, any> = {};

Expand Down Expand Up @@ -1335,7 +1336,9 @@ export class WalletController extends BaseController {
};
addConnectedSiteV2 = permissionService.addConnectedSiteV2;
removeAllRecentConnectedSites = () => {
const sites = permissionService.getRecentConnectedSites();
const sites = permissionService
.getRecentConnectedSites()
.filter((item) => !item.isTop);
sites.forEach((item) => {
this.removeConnectedSite(item.origin);
});
Expand Down Expand Up @@ -3684,7 +3687,26 @@ export class WalletController extends BaseController {
return signature;
};

addCustomTestnet = customTestnetService.add;
addCustomTestnet = async (
chain: Parameters<typeof customTestnetService.add>[0],
ctx?: {
ga?: {
source?: string;
};
}
) => {
const source = ctx?.ga?.source || 'setting';

const res = await customTestnetService.add(chain);
if (!('error' in res)) {
matomoRequestEvent({
category: 'Custom Network',
action: 'Success Add Network',
label: `${source}_${String(chain.id)}`,
});
}
return res;
};
updateCustomTestnet = customTestnetService.update;
removeCustomTestnet = customTestnetService.remove;
getCustomTestnetList = customTestnetService.getList;
Expand Down
17 changes: 9 additions & 8 deletions src/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,7 @@ restoreAppState();
let interval: NodeJS.Timeout | null;
keyringService.on('unlock', () => {
walletController.syncMainnetChainList();
const customTestnetLength = customTestnetService.getList()?.length;
if (customTestnetLength) {
matomoRequestEvent({
category: 'Custom Network',
action: 'Custom Network Status',
value: customTestnetLength,
});
}

if (interval) {
clearInterval(interval);
}
Expand All @@ -136,6 +129,14 @@ restoreAppState();
if (dayjs(time).utc().isSame(dayjs().utc(), 'day')) {
return;
}
const customTestnetLength = customTestnetService.getList()?.length;
if (customTestnetLength) {
matomoRequestEvent({
category: 'Custom Network',
action: 'Custom Network Status',
value: customTestnetLength,
});
}
const chains = preferenceService.getSavedChains();
matomoRequestEvent({
category: 'User',
Expand Down
8 changes: 1 addition & 7 deletions src/background/service/customTestnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,7 @@ class CustomTestnetService {
};
this.chains[chain.id] = createClientByChain(chain);
this.syncChainList();
if (isAdd) {
matomoRequestEvent({
category: 'Custom Network',
action: 'Success Add Network',
label: String(chain.id),
});
}

if (this.getList().length) {
matomoRequestEvent({
category: 'Custom Network',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,9 @@ class OneKeyKeyring extends EventEmitter {
tx.s = Buffer.from(payload.s, 'hex');
return tx;
}
).then(resolve);
)
.then(resolve)
.catch(reject);
} else {
this._signTransaction(
address,
Expand All @@ -368,7 +370,9 @@ class OneKeyKeyring extends EventEmitter {
freeze: Object.isFrozen(tx),
});
}
).then(resolve);
)
.then(resolve)
.catch(reject);
}
// This is necessary to avoid popup collision
// between the unlock & sign trezor popups
Expand Down
16 changes: 13 additions & 3 deletions src/background/service/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export type StatsData = {
trigger: any;
reported: boolean;
signMethod?: string;
networkType?: string;
};

// something need user approval in window
Expand Down Expand Up @@ -258,15 +259,24 @@ class NotificationService extends Events {
: null;
const explain = signingTx?.explain;

if (explain && currentAccount) {
const chain = findChain({
id: signingTx?.rawTx.chainId,
});

if ((explain || chain?.isTestnet) && currentAccount) {
stats.report('preExecTransaction', {
type: currentAccount.brandName,
category: KEYRING_CATEGORY_MAP[currentAccount.type],
chainId: explain.native_token.chain,
success: explain.calcSuccess && explain.pre_exec.success,
chainId: chain?.serverId || '',
success: explain
? explain.calcSuccess && explain.pre_exec.success
: true,
createBy: data?.params.$ctx?.ga ? 'rabby' : 'dapp',
source: data?.params.$ctx?.ga?.source || '',
trigger: data?.params.$ctx?.ga.trigger || '',
networkType: chain?.isTestnet
? 'Custom Network'
: 'Integrated Network',
});
}
};
Expand Down
3 changes: 0 additions & 3 deletions src/background/service/permission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ export interface ConnectedSite {
chain: CHAINS_ENUM;
e?: number;
isSigned: boolean;
/**
* @deprecated
*/
isTop: boolean;
order?: number;
isConnected: boolean;
Expand Down
7 changes: 4 additions & 3 deletions src/background/service/transactionHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -728,12 +728,13 @@ class TxHistory {
stats.report('completeTransaction', {
chainId: chain.serverId,
success,
preExecSuccess: Boolean(
target.explain?.pre_exec.success && target.explain?.calcSuccess
),
preExecSuccess: target?.explain
? target.explain?.pre_exec.success && target.explain?.calcSuccess
: true,
createBy: target?.$ctx?.ga ? 'rabby' : 'dapp',
source: target?.$ctx?.ga?.source || '',
trigger: target?.$ctx?.ga?.trigger || '',
networkType: chain?.isTestnet ? 'Custom Network' : 'Integrated Network',
});
}
this.clearBefore({ address, chainId, nonce });
Expand Down
Loading

0 comments on commit b99568a

Please sign in to comment.