Skip to content

Commit

Permalink
enhancement: using different owner and active key
Browse files Browse the repository at this point in the history
  • Loading branch information
dafuga committed Dec 4, 2024
1 parent a0783d6 commit c1a0831
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ export class AccountCreationPluginMetamask
qs.set('scope', String(context.appName))
}

const publicKey = await this.retrievePublicKey(currentChain.id)
const {ownerPublicKey, activePublicKey} = await this.retrievePublicKeys(currentChain.id)

qs.set('owner_key', String(publicKey))
qs.set('active_key', String(publicKey))
qs.set('owner_key', String(ownerPublicKey))
qs.set('active_key', String(activePublicKey))
const accountCreator = new AccountCreator({
supportedChains: [String(currentChain.id)],
fullCreationServiceUrl: `${this.accountCreationServiceUrl}?${qs.toString()}`,
Expand Down Expand Up @@ -135,16 +135,22 @@ export class AccountCreationPluginMetamask
}
}

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

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

0 comments on commit c1a0831

Please sign in to comment.