Skip to content

Commit 2608c61

Browse files
committed
fix: making placeholder authorizations work with session keys
1 parent 76a3318 commit 2608c61

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/utils.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
Transaction,
99
} from '@wharfkit/antelope'
1010
import type {Fetch, LocaleDefinitions} from '@wharfkit/common'
11-
import {SigningRequest} from '@wharfkit/signing-request'
11+
import {PlaceholderAuth, SigningRequest} from '@wharfkit/signing-request'
1212
import {TransactArgs, TransactPlugin} from './transact'
1313
import {WalletPlugin} from './wallet'
1414

@@ -139,6 +139,8 @@ export function extractActions(args: TransactArgs): AnyAction[] {
139139

140140
/**
141141
* Check if an action has an authorization matching a given permission level.
142+
* Also matches PlaceholderAuth (actor: '............1', permission: '............2')
143+
* since placeholders will be resolved to the actual permission level.
142144
*
143145
* @param action AnyAction
144146
* @param permissionLevel PermissionLevel
@@ -148,7 +150,10 @@ export function actionMatchesPermission(
148150
action: AnyAction,
149151
permissionLevel: PermissionLevel
150152
): boolean {
151-
return action.authorization.some((auth: PermissionLevelType) => permissionLevel.equals(auth))
153+
return action.authorization.some(
154+
(auth: PermissionLevelType) =>
155+
permissionLevel.equals(auth) || PlaceholderAuth.equals(auth)
156+
)
152157
}
153158

154159
function rewriteAuthIfMatches(

0 commit comments

Comments
 (0)