Skip to content

Commit f2801f9

Browse files
committed
revert: putting actionMatchesPermission changes back in
1 parent bc5682b commit f2801f9

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/utils.ts

Lines changed: 8 additions & 3 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 {SigningRequest, PlaceholderAuth} from '@wharfkit/signing-request'
1212
import {TransactArgs, TransactPlugin} from './transact'
1313
import {WalletPlugin} from './wallet'
1414

@@ -139,6 +139,9 @@ 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+
* because willUseSessionKey() is called before placeholders are resolved,
144+
* and we need to detect if the action would match after resolution.
142145
*
143146
* @param action AnyAction
144147
* @param permissionLevel PermissionLevel
@@ -148,15 +151,17 @@ export function actionMatchesPermission(
148151
action: AnyAction,
149152
permissionLevel: PermissionLevel
150153
): boolean {
151-
return action.authorization.some((auth: PermissionLevelType) => permissionLevel.equals(auth))
154+
return action.authorization.some(
155+
(auth: PermissionLevelType) => permissionLevel.equals(auth) || PlaceholderAuth.equals(auth)
156+
)
152157
}
153158

154159
function rewriteAuthIfMatches(
155160
auth: PermissionLevelType,
156161
permissionLevel: PermissionLevel,
157162
newPermission: Name
158163
): PermissionLevelType {
159-
if (permissionLevel.equals(auth)) {
164+
if (permissionLevel.equals(auth) || PlaceholderAuth.equals(auth)) {
160165
return PermissionLevel.from({
161166
actor: permissionLevel.actor,
162167
permission: newPermission,

0 commit comments

Comments
 (0)