From 08a371efae275e5b7bb0fca35df6414d9229524f Mon Sep 17 00:00:00 2001 From: mosi Date: Thu, 5 Dec 2024 10:53:40 +0800 Subject: [PATCH 1/2] fix: check group before insert account --- packages/rpcs/wallet_createAccount/index.js | 21 ++++++++++++++----- packages/rpcs/wallet_deleteAccount/index.js | 4 +++- .../rpcs/wallet_deleteAccountGroup/index.js | 4 +++- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/packages/rpcs/wallet_createAccount/index.js b/packages/rpcs/wallet_createAccount/index.js index 83d6ae8d..8c7ad75b 100644 --- a/packages/rpcs/wallet_createAccount/index.js +++ b/packages/rpcs/wallet_createAccount/index.js @@ -44,7 +44,7 @@ export const main = async ({ nickname: 1, }, }) - if (!group) throw InvalidParams('Invalid account group id') + if (!group) throw InvalidParams(`Invalid account group id ${accountGroupId}`) const {vault} = group if (vault.type !== 'hd') @@ -78,8 +78,19 @@ export const main = async ({ only0x1Prefixed: vault.cfxOnly, }), })), - ).then(params => - params.map(({eid, netId, type, addr: {address, privateKey}}) => { + ).then(params => { + const _group = findGroup({ + groupId: accountGroupId, + g: { + account: {nickname: 1}, + vault: {type: 1, ddata: 1, data: 1, cfxOnly: 1}, + nickname: 1, + }, + }) + // check group is deleted or not + if (!_group) + throw InvalidParams(`Invalid account group id ${accountGroupId}`) + return params.map(({eid, netId, type, addr: {address, privateKey}}) => { const accountId = findAccount({ groupId: accountGroupId, @@ -110,8 +121,8 @@ export const main = async ({ ]) return tempids.accountId ?? accountId - }), - ) + }) + }) )[0] if (_popup && select) { diff --git a/packages/rpcs/wallet_deleteAccount/index.js b/packages/rpcs/wallet_deleteAccount/index.js index 583f9d8f..1ad2c223 100644 --- a/packages/rpcs/wallet_deleteAccount/index.js +++ b/packages/rpcs/wallet_deleteAccount/index.js @@ -53,6 +53,8 @@ export const main = async ({ const sideEffects = retractAccount({accountId, hwVaultData: ddata}) - await Promise.all(sideEffects.map(([method, params]) => rpcs[method](params))) + await Promise.all( + sideEffects?.map(([method, params]) => rpcs[method]?.(params)), + ) return true } diff --git a/packages/rpcs/wallet_deleteAccountGroup/index.js b/packages/rpcs/wallet_deleteAccountGroup/index.js index 3b6dd409..2414ce51 100644 --- a/packages/rpcs/wallet_deleteAccountGroup/index.js +++ b/packages/rpcs/wallet_deleteAccountGroup/index.js @@ -37,6 +37,8 @@ export const main = async ({ const sideEffects = retractGroup({groupId: group.eid}) - await Promise.all(sideEffects.map(([method, params]) => rpcs[method](params))) + await Promise.all( + sideEffects?.map(([method, params]) => rpcs[method]?.(params)), + ) return true } From f7430157e4b83b2adabae5346feaaf245e08018d Mon Sep 17 00:00:00 2001 From: mosi Date: Thu, 5 Dec 2024 10:56:47 +0800 Subject: [PATCH 2/2] feat: version --- .yarn/versions/202cd75a.yml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .yarn/versions/202cd75a.yml diff --git a/.yarn/versions/202cd75a.yml b/.yarn/versions/202cd75a.yml new file mode 100644 index 00000000..a4cff947 --- /dev/null +++ b/.yarn/versions/202cd75a.yml @@ -0,0 +1,9 @@ +releases: + "@fluent-wallet/wallet_create-account": patch + "@fluent-wallet/wallet_delete-account": patch + "@fluent-wallet/wallet_delete-account-group": patch + browser-extension: patch + helios-background: patch + +declined: + - helios