Skip to content

Commit

Permalink
Merge branch 'develop' into feat/tab-send
Browse files Browse the repository at this point in the history
  • Loading branch information
cs1707 committed Jan 23, 2025
2 parents d448cec + a58740f commit c8ce799
Show file tree
Hide file tree
Showing 45 changed files with 3,445 additions and 169 deletions.
6 changes: 5 additions & 1 deletion _raw/locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2347,9 +2347,12 @@
"amount": "Amount",
"to": "To",
"selectChain": "Select Chain",
"selectAddr": "Select Address",
"recipientAddress": "Recipient address",
"destinationChain": "Destination chain",
"deductGasFees": "Received amount will deduct gas fees"
"deductGasFees": "Received amount will deduct gas fees",
"noEligibleAddr": "No eligible address for withdrawal",
"noEligibleChain": "No eligible chain for withdrawal"
},
"withdrawConfirmModal": {
"title": "Transferred to your DeBank L2 Wallet",
Expand Down Expand Up @@ -2648,6 +2651,7 @@
"noMatch": "No Match",
"noMatchSuggestion": "Try to search contract address on {{ chainName }}",
"hot": "Hot",
"common": "Common",
"recent": "Recent"
},
"ModalPreviewNFTItem": {
Expand Down
2,695 changes: 2,695 additions & 0 deletions _raw/locales/id/messages.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion _raw/locales/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
{ "code": "pt-BR", "name": "Português Brasileiro" },
{ "code": "ru", "name": "Русский" },
{ "code": "de", "name": "Deutsch" },
{ "code": "ja", "name": "日本語" }
{ "code": "ja", "name": "日本語" },
{ "code": "id", "name": "Bahasa Indonesia" }
]
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"@rabby-wallet/eth-walletconnect-keyring": "2.1.5",
"@rabby-wallet/eth-watch-keyring": "1.0.0",
"@rabby-wallet/gnosis-sdk": "1.3.10",
"@rabby-wallet/page-provider": "0.4.4",
"@rabby-wallet/page-provider": "0.4.6",
"@rabby-wallet/rabby-action": "0.1.8",
"@rabby-wallet/rabby-api": "0.9.9",
"@rabby-wallet/rabby-security-engine": "2.0.7",
Expand Down Expand Up @@ -122,7 +122,6 @@
"react": "17.0.2",
"react-countup": "6.5.0",
"react-dom": "17.0.2",
"react-ga": "3.3.0",
"react-idle-timer": "5.7.2",
"react-markdown": "7.1.0",
"react-redux": "8.0.1",
Expand Down
21 changes: 14 additions & 7 deletions src/background/controller/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ import Browser from 'webextension-polyfill';
import { hashSafeMessage } from '@safe-global/protocol-kit';
import { userGuideService } from '../service/userGuide';
import { metamaskModeService } from '../service/metamaskModeService';
import { ga4 } from '@/utils/ga4';

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

Expand Down Expand Up @@ -3477,9 +3478,9 @@ export class WalletController extends BaseController {
} catch {
const Keyring = keyringService.getKeyringClassForType(type);
keyring = new Keyring(
hasBridge(type)
(await hasBridge(type))
? {
bridge: getKeyringBridge(type),
bridge: await getKeyringBridge(type),
}
: undefined
);
Expand Down Expand Up @@ -3545,7 +3546,7 @@ export class WalletController extends BaseController {
keyringType
);
keyring = new keystoneKeyring({
bridge: getKeyringBridge(keyringType),
bridge: await getKeyringBridge(keyringType),
});
stashKeyringId = Object.values(stashKeyrings).length + 1;
stashKeyrings[stashKeyringId] = keyring;
Expand Down Expand Up @@ -3574,7 +3575,7 @@ export class WalletController extends BaseController {
keyringType
);
keyring = new keystoneKeyring({
bridge: getKeyringBridge(keyringType),
bridge: await getKeyringBridge(keyringType),
});
stashKeyringId = Object.values(stashKeyrings).length + 1;
stashKeyrings[stashKeyringId] = keyring;
Expand Down Expand Up @@ -3720,7 +3721,7 @@ export class WalletController extends BaseController {
return keyring.getEncryptionPublicKey(address, options);
};

requestKeyring = (
requestKeyring = async (
type: string,
methodName: string,
keyringId: number | null,
Expand All @@ -3735,7 +3736,9 @@ export class WalletController extends BaseController {
} catch {
const Keyring = keyringService.getKeyringClassForType(type);
keyring = new Keyring(
hasBridge(type) ? { bridge: getKeyringBridge(type) } : undefined
(await hasBridge(type))
? { bridge: await getKeyringBridge(type) }
: undefined
);
}
}
Expand Down Expand Up @@ -4382,7 +4385,7 @@ export class WalletController extends BaseController {
keyringType
);
keyring = new keystoneKeyring({
bridge: getKeyringBridge(keyringType),
bridge: await getKeyringBridge(keyringType),
});
stashKeyringId = this.addKeyringToStash(keyring);
}
Expand Down Expand Up @@ -4877,6 +4880,10 @@ export class WalletController extends BaseController {
action: 'Success Add Network',
label: `${source}_${String(chain.id)}`,
});

ga4.fireEvent('Add_CustomNetwork', {
event_category: 'Custom Network',
});
}
return res;
};
Expand Down
27 changes: 26 additions & 1 deletion src/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ import { isSameAddress } from './utils';
import rpcCache from './utils/rpcCache';
import { storage } from './webapi';
import { metamaskModeService } from './service/metamaskModeService';
import { ga4 } from '@/utils/ga4';
import { ALARMS_USER_ENABLE } from './utils/alarms';

Safe.adapter = fetchAdapter as any;

Expand Down Expand Up @@ -116,9 +118,14 @@ async function restoreAppState() {
syncChainService.roll();
transactionWatchService.roll();
transactionBroadcastWatchService.roll();
startEnableUser();
walletController.syncMainnetChainList();

// check if user has enabled the extension
chrome.alarms.create(ALARMS_USER_ENABLE, {
when: Date.now(),
periodInMinutes: 60,
});

if (!keyringService.isBooted()) {
userGuideService.init();
}
Expand Down Expand Up @@ -171,6 +178,10 @@ restoreAppState();
action: 'Custom Network Status',
value: customTestnetLength,
});

ga4.fireEvent('Has Custom Network', {
event_category: 'Custom Network',
});
}
const chains = preferenceService.getSavedChains();
matomoRequestEvent({
Expand Down Expand Up @@ -201,6 +212,10 @@ restoreAppState();
label: [group[0].action, group[0].label, group.length].join('|'),
value: group.length,
});

ga4.fireEvent(`${group[0].category}_${group[0].label}`, {
event_category: 'UserAddress',
});
});
preferenceService.updateSendLogTime(Date.now());
};
Expand Down Expand Up @@ -422,6 +437,10 @@ function startEnableUser() {
category: 'User',
action: 'enable',
});

ga4.fireEvent('User_Enable', {
event_category: 'User Enable',
});
preferenceService.updateSendEnableTime(Date.now());
}

Expand All @@ -434,3 +453,9 @@ async function onInstall() {
await userGuideService.openUserGuide();
}
}

browser.alarms.onAlarm.addListener((alarm) => {
if (alarm.name === ALARMS_USER_ENABLE) {
startEnableUser();
}
});
11 changes: 10 additions & 1 deletion src/background/service/customTestnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { http as axios } from '../utils/http';
import { matomoRequestEvent } from '@/utils/matomo-request';
import RPCService, { RPCServiceStore } from './rpc';
import { storage } from '../webapi';
import { ga4 } from '@/utils/ga4';

const MAX_READ_CONTRACT_TIME = 8000;

Expand Down Expand Up @@ -194,6 +195,10 @@ class CustomTestnetService {
action: 'Custom Network Status',
value: this.getList().length,
});

ga4.fireEvent('Has_CustomNetwork', {
event_category: 'Custom Network',
});
}
return this.store.customTestnet[chain.id];
};
Expand All @@ -211,6 +216,10 @@ class CustomTestnetService {
action: 'Custom Network Status',
value: this.getList().length,
});

ga4.fireEvent('Has_CustomNetwork', {
event_category: 'Custom Network',
});
}
};

Expand Down Expand Up @@ -729,7 +738,7 @@ const createClientByChain = (chain: TestnetChainBase) => {
},
},
}),
transport: http(chain.rpcUrl, { timeout: 300000 }),
transport: http(chain.rpcUrl, { timeout: 30_000 }),
});
};

Expand Down
16 changes: 8 additions & 8 deletions src/background/service/keyring/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,26 @@ const BitBox02Bridge = isManifestV3
? require('./eth-bitbox02-keyring/bitbox02-offscreen-bridge')
: require('./eth-bitbox02-keyring/bitbox02-bridge');

export function getKeyringBridge(type: string) {
export const getKeyringBridge = async (type: string) => {
if (type === KEYRING_CLASS.HARDWARE.IMKEY) {
return new ImKeyBridge.default();
return new (await ImKeyBridge).default();
}

if (type === KEYRING_CLASS.HARDWARE.ONEKEY) {
return new OneKeyBridge.default();
return new (await OneKeyBridge).default();
}

if (type === KEYRING_CLASS.HARDWARE.TREZOR) {
return new TrezorBridge.default();
return new (await TrezorBridge).default();
}

if (type === KEYRING_CLASS.HARDWARE.BITBOX02) {
return new BitBox02Bridge.default();
return new (await BitBox02Bridge).default();
}

return;
}
};

export const hasBridge = (type: string) => {
return !!getKeyringBridge(type);
export const hasBridge = async (type: string) => {
return !!(await getKeyringBridge(type));
};
Loading

0 comments on commit c8ce799

Please sign in to comment.