File tree Expand file tree Collapse file tree
primitives-cli/src/subcommands Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -107,12 +107,15 @@ async function generateSessionsTopology(
107107
108108 if ( isLeaf || depth <= 1 ) {
109109 const permissionsCount = Math . floor ( ( options ?. seededRandom ?? Math . random ) ( ) * ( options ?. maxPermissions ?? 5 ) ) + 1
110+ const permissions = await Promise . all (
111+ Array . from ( { length : permissionsCount } , ( ) => generateRandomPermission ( options ) ) ,
112+ )
110113 return {
111114 type : 'session-permissions' ,
112115 signer : randomAddress ( options ) ,
113116 valueLimit : randomBigInt ( 100n , options ) ,
114117 deadline : randomBigInt ( 1000n , options ) ,
115- permissions : await Promise . all ( Array . from ( { length : permissionsCount } , ( ) => generateRandomPermission ( options ) ) ) ,
118+ permissions : permissions as [ Permission . Permission , ... Permission . Permission [ ] ] ,
116119 }
117120 }
118121
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ export type SessionPermissions = {
2424 signer : Address . Address
2525 valueLimit : bigint
2626 deadline : bigint
27- permissions : Permission [ ]
27+ permissions : [ Permission , ... Permission [ ] ]
2828}
2929
3030export const MAX_PERMISSIONS_COUNT = 2 ** 7 - 1
@@ -89,11 +89,14 @@ export function decodeSessionPermissions(bytes: Bytes.Bytes): SessionPermissions
8989 permissions . push ( permission )
9090 pointer += consumed
9191 }
92+ if ( permissions . length === 0 ) {
93+ throw new Error ( 'No permissions' )
94+ }
9295 return {
9396 signer,
9497 valueLimit,
9598 deadline,
96- permissions,
99+ permissions : permissions as [ Permission , ... Permission [ ] ] ,
97100 }
98101}
99102
You can’t perform that action at this time.
0 commit comments