Skip to content

Commit

Permalink
refactor: having retrievePublicKeys return PublicKey instances
Browse files Browse the repository at this point in the history
  • Loading branch information
dafuga committed Dec 4, 2024
1 parent 08c15fd commit a6ed425
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Chains,
Checksum256Type,
CreateAccountContext,
PublicKey,
} from '@wharfkit/session'
import {AccountCreationPluginMetadata} from '@wharfkit/session'
import {MetaMaskInpageProvider, RequestArguments} from '@metamask/providers'
Expand Down Expand Up @@ -136,20 +137,23 @@ export class AccountCreationPluginMetamask

async retrievePublicKeys(
chainId: Checksum256Type
): Promise<{ownerPublicKey: string; activePublicKey: string}> {
): Promise<{ownerPublicKey: PublicKey; activePublicKey: PublicKey}> {
await this.initialize()
if (!this.provider) {
throw new Error('Metamask not found')
}
const ownerPublicKey = (await this.invokeSnap({
const ownerPublicKeyString = (await this.invokeSnap({
method: 'antelope_getOwnerPublicKey',
params: {chainId: String(chainId)},
})) as string
const activePublicKey = (await this.invokeSnap({
const activePublicKeyString = (await this.invokeSnap({
method: 'antelope_getActivePublicKey',
params: {chainId: String(chainId)},
})) as string
return {ownerPublicKey, activePublicKey}
return {
ownerPublicKey: PublicKey.from(ownerPublicKeyString),
activePublicKey: PublicKey.from(activePublicKeyString),
}
}

async request({method, params}) {
Expand Down

0 comments on commit a6ed425

Please sign in to comment.