diff --git a/.yarn/versions/202cd75a.yml b/.yarn/versions/202cd75a.yml new file mode 100644 index 000000000..a4cff9472 --- /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 diff --git a/packages/rpcs/wallet_createAccount/index.js b/packages/rpcs/wallet_createAccount/index.js index 83d6ae8d1..8c7ad75b3 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 583f9d8fd..1ad2c223b 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 3b6dd409f..2414ce518 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 }