Skip to content

Commit

Permalink
feat(kms-web3): add ability to list provider accounts as keys (#965)
Browse files Browse the repository at this point in the history
fixes #933
  • Loading branch information
simonas-notcat committed Jul 28, 2022
1 parent 0a88058 commit 31e3946
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion packages/kms-web3/src/web3-key-management-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,28 @@ export class Web3KeyManagementSystem extends AbstractKeyManagementSystem {
}

async listKeys(): Promise<ManagedKeyInfo[]> {
throw Error('not_implemented: Web3KeyManagementSystem listKeys')
const keys: ManagedKeyInfo[] = []
for (const provider in this.providers) {
const accounts = await this.providers[provider].listAccounts()
for (const account of accounts) {
const key: ManagedKeyInfo = {
kid: `${provider}-${account}`,
type: 'Secp256k1',
publicKeyHex: '',
kms: '',
meta: {
account,
provider,
algorithms: [
'eth_signMessage',
'eth_signTypedData',
]
}
}
keys.push(key)
}
}
return keys
}

async sharedSecret(args: {
Expand Down

0 comments on commit 31e3946

Please sign in to comment.