Skip to content

Commit

Permalink
chore: tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Feb 1, 2025
1 parent c86adbc commit 1d5e8a5
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions src/core/Implementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,14 +526,22 @@ export function dialog(parameters: dialog.Parameters = {}) {
})
if (!key) throw new Error('key not found.')

const rpc = Key.toRpc(key)

// Send a request off to the dialog to authorize the key.
const provider = getProvider(store)
await provider.request({
method: 'experimental_authorizeKey',
params: [
{
address,
...(Key.toRpc(key) as any),
expiry: rpc.expiry,
key: {
publicKey: rpc.publicKey,
type: rpc.type,
},
permissions: rpc.permissions,
role: rpc.role,
},
],
})
Expand Down Expand Up @@ -585,9 +593,7 @@ export function dialog(parameters: dialog.Parameters = {}) {
})

// Convert the key into RPC format.
const authorizeKey_rpc = authorizeKey
? Key.toRpc(authorizeKey)
: undefined
const rpc = authorizeKey ? Key.toRpc(authorizeKey) : undefined

// Send a request off to the dialog to create an account.
const { accounts } = await provider.request({
Expand All @@ -596,15 +602,17 @@ export function dialog(parameters: dialog.Parameters = {}) {
{
capabilities: {
...request.params?.[0]?.capabilities,
authorizeKey: (authorizeKey_rpc?.publicKey
authorizeKey: rpc?.publicKey
? {
...authorizeKey_rpc,
expiry: rpc.expiry,
key: {
publicKey: authorizeKey_rpc?.publicKey,
type: authorizeKey_rpc?.type,
publicKey: rpc.publicKey,
type: rpc.type,
},
permissions: rpc.permissions,
role: rpc.role,
}
: undefined) as never,
: undefined,
},
},
],
Expand Down Expand Up @@ -703,9 +711,7 @@ export function dialog(parameters: dialog.Parameters = {}) {
})

// Convert the key into RPC format.
const authorizeKey_rpc = authorizeKey
? Key.toRpc(authorizeKey)
: undefined
const rpc = authorizeKey ? Key.toRpc(authorizeKey) : undefined

// Send a request to the dialog.
const result = await provider.request({
Expand All @@ -715,15 +721,17 @@ export function dialog(parameters: dialog.Parameters = {}) {
...request.params?.[0],
capabilities: {
...request.params?.[0]?.capabilities,
authorizeKey: (authorizeKey_rpc?.publicKey
authorizeKey: rpc?.publicKey
? {
...authorizeKey_rpc,
expiry: rpc.expiry,
key: {
publicKey: authorizeKey_rpc?.publicKey,
type: authorizeKey_rpc?.type,
publicKey: rpc.publicKey,
type: rpc.type,
},
permissions: rpc.permissions,
role: rpc.role,
}
: undefined) as never,
: undefined,
},
},
],
Expand Down

0 comments on commit 1d5e8a5

Please sign in to comment.