@@ -10,6 +10,8 @@ import { splitAwsKmsArn } from "../../server/utils/wallets/awsKmsArn";
10
10
import { splitGcpKmsResourcePath } from "../../server/utils/wallets/gcpKmsResourcePath" ;
11
11
import { getLocalWallet } from "../../server/utils/wallets/getLocalWallet" ;
12
12
import { getSmartWallet } from "../../server/utils/wallets/getSmartWallet" ;
13
+ import { decrypt } from "../crypto" ;
14
+ import { env } from "../env" ;
13
15
import { getConfig } from "./getConfig" ;
14
16
15
17
export const walletsCache = new Map < string , EVMWallet > ( ) ;
@@ -64,9 +66,9 @@ export const getWallet = async <TWallet extends EVMWallet>({
64
66
walletDetails . awsKmsAccessKeyId ??
65
67
config . walletConfiguration . aws ?. awsAccessKeyId ;
66
68
67
- const secretAccessKey =
68
- walletDetails . awsKmsSecretAccessKey ??
69
- config . walletConfiguration . aws ?. awsSecretAccessKey ;
69
+ const secretAccessKey = walletDetails . awsKmsSecretAccessKey
70
+ ? decrypt ( walletDetails . awsKmsSecretAccessKey , env . ENCRYPTION_PASSWORD )
71
+ : config . walletConfiguration . aws ?. awsSecretAccessKey ;
70
72
71
73
if ( ! ( accessKeyId && secretAccessKey ) ) {
72
74
throw new Error (
@@ -95,9 +97,12 @@ export const getWallet = async <TWallet extends EVMWallet>({
95
97
const email =
96
98
walletDetails . gcpApplicationCredentialEmail ??
97
99
config . walletConfiguration . gcp ?. gcpApplicationCredentialEmail ;
98
- const privateKey =
99
- walletDetails . gcpApplicationCredentialPrivateKey ??
100
- config . walletConfiguration . gcp ?. gcpApplicationCredentialPrivateKey ;
100
+ const privateKey = walletDetails . gcpApplicationCredentialPrivateKey
101
+ ? decrypt (
102
+ walletDetails . gcpApplicationCredentialPrivateKey ,
103
+ env . ENCRYPTION_PASSWORD ,
104
+ )
105
+ : config . walletConfiguration . gcp ?. gcpApplicationCredentialPrivateKey ;
101
106
102
107
if ( ! ( email && privateKey ) ) {
103
108
throw new Error (
0 commit comments