Skip to content

Conversation

@blueogin
Copy link
Collaborator

@blueogin blueogin commented Dec 9, 2025

Description

Added the KMS wallet, which signs transactions using keys stored in AWS KMS.
The kms-ethereum-signing dependency is the modularized PoC project I previously built.

About # (link your issue here)

How Has This Been Tested?

The KMS wallet is tested in adminWalletKMS.test.ts.

Checklist:

  • PR title matches follow: (Feature|Bug|Chore) Task Name
  • My code follows the style guidelines of this project
  • I have followed all the instructions described in the initial task (check Definitions of Done)
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have added reference to a related issue in the repository
  • I have added a detailed description of the changes proposed in the pull request. I am as descriptive as possible, assisting reviewers as much as possible.
  • I have added screenshots related to my pull request (for frontend tasks)
  • I have pasted a gif showing the feature.
  • @mentions of the person or team responsible for reviewing proposed changes

- Added KMS wallet support to handle Ethereum transactions securely using AWS Key Management Service.
- Updated configuration to allow KMS key IDs and region settings.
- Refactored AdminWallet and Web3Wallet to support KMS-based transaction signing.
- Introduced KMSWallet class to encapsulate KMS operations.
- Added tests for KMS transaction submission and wallet functionality.
- Updated KMSWallet and Web3Wallet to store and retrieve wallet addresses in a case-insensitive manner.
- Removed unnecessary console log from KMSWallet during transaction signing.
- Adjusted tests to ensure KMS wallet address normalization is correctly handled.
…ated package versions in package.json and package-lock.json

const sendTx = this.mainnetWeb3.eth.sendSignedTransaction(signedTx)

return new Promise((res, rej) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reduce duplicate code

const region = this.getRegion(address)

try {
if (transaction.rpcUrl != undefined && transaction.rpcUrl.includes('localhost')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

write a comment why you do this

this.networkId = networkId
this.numberOfAdminWalletAccounts = conf.privateKey ? 1 : conf.numberOfAdminWalletAccounts
// Determine number of accounts based on configuration
let kmsKeyIds = null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just read existing kmskeys from aws? maybe read keys by tags?

Comment on lines +118 to +125
if (conf.kmsKeyIds) {
kmsKeyIds = conf.kmsKeyIds
.split(',')
.map(k => k.trim())
.filter(k => k)
}
if (kmsKeyIds && kmsKeyIds.length > 0) {
this.numberOfAdminWalletAccounts = kmsKeyIds.length
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be moved to initialize and keys should be fetched by group/tag

this.wallets[normalizedAddress] = { address, kmsKeyId, isKMS: true }
}

getKMSKeyIds() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be fetched from aws by group/tag


getKMSKeyIds() {
// Support comma-separated list of keys
if (this.conf.kmsKeyIds) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of kmskeyids use kmsKeysTag

addresses.forEach(address => {
const keyId = this.kmsWallet.getKeyId(address)
this.addKMSWallet(address, keyId)
// Add KMS addresses to filledAddresses (they don't need admin verification)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not true, need same checks as in mnemonic.
dont duplicate code

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure balance check are run for these addresses also

* Send transaction using KMS signing
* @private
*/
async sendTransactionWithKMS(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deduplicate code like in AdminWallet you have just one sendTransaction method

env: 'PRIVATE_KEY',
default: undefined
},
kmsKeyIds: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use kmsKeysTag

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants