refactor of WalletManager