Skip to content

Commit c4d0d6a

Browse files
authored
fix: default delegation.salt and caveat.args should be 0x00 (#138)
* Default value for delegation salt should be '0x00' instead of '0x' * Default value for caveat args should be '0x00' instead of '0x' * Update delegation encoding tests - use static input data - assert encoded data hex literals * Mark exported constants as 'as const'
1 parent 1c850d0 commit c4d0d6a

81 files changed

Lines changed: 285 additions & 277 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/delegation-core/src/delegation.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,30 @@ import type { CaveatStruct, DelegationStruct, Hex } from './types';
1515
/**
1616
* When designated as the delegate address in a delegation, this allows any beneficiary to redeem the delegation.
1717
*/
18-
export const ANY_BENEFICIARY = '0x0000000000000000000000000000000000000a11';
18+
export const ANY_BENEFICIARY =
19+
'0x0000000000000000000000000000000000000a11' as const;
1920

2021
/**
2122
* To be used on a delegation as the root authority.
2223
*/
2324
export const ROOT_AUTHORITY =
24-
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff';
25+
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' as const;
2526

2627
/**
2728
* The typehash for a delegation, used when generating a delegation hash.
2829
*
2930
* keccak('Delegation(address delegate,address delegator,bytes32 authority,Caveat[] caveats,uint256 salt)Caveat(address enforcer,bytes terms)')
3031
*/
3132
export const DELEGATION_TYPEHASH =
32-
'0x88c1d2ecf185adf710588203a5f263f0ff61be0d33da39792cde19ba9aa4331e';
33+
'0x88c1d2ecf185adf710588203a5f263f0ff61be0d33da39792cde19ba9aa4331e' as const;
3334

3435
/**
3536
* The typehash for a caveat, used when generating a caveat hash.
3637
*
3738
* keccak('Caveat(address enforcer,bytes terms)')
3839
*/
3940
export const CAVEAT_TYPEHASH =
40-
'0x80ad7e1b04ee6d994a125f4714ca0720908bd80ed16063ec8aee4b88e9253e2d';
41+
'0x80ad7e1b04ee6d994a125f4714ca0720908bd80ed16063ec8aee4b88e9253e2d' as const;
4142

4243
/**
4344
* The ABI types for an array of delegations.

packages/delegator-e2e/test/actions/signDelegationActions.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ test('should handle delegation with additional caveats', async () => {
163163
{
164164
enforcer: '0x1111111111111111111111111111111111111111',
165165
terms: '0x1234',
166-
args: '0x',
166+
args: '0x00',
167167
},
168168
],
169169
});

packages/smart-accounts-kit/src/caveatBuilder/allowedCalldataBuilder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ export const allowedCalldataBuilder = (
4444
return {
4545
enforcer: AllowedCalldataEnforcer,
4646
terms,
47-
args: '0x',
47+
args: '0x00',
4848
};
4949
};

packages/smart-accounts-kit/src/caveatBuilder/allowedMethodsBuilder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const allowedMethodsBuilder = (
5151
return {
5252
enforcer: AllowedMethodsEnforcer,
5353
terms,
54-
args: '0x',
54+
args: '0x00',
5555
};
5656
};
5757

packages/smart-accounts-kit/src/caveatBuilder/allowedTargetsBuilder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ export const allowedTargetsBuilder = (
5454
return {
5555
enforcer: AllowedTargetsEnforcer,
5656
terms,
57-
args: '0x',
57+
args: '0x00',
5858
};
5959
};

packages/smart-accounts-kit/src/caveatBuilder/argsEqualityCheckBuilder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ export const argsEqualityCheckBuilder = (
3939
return {
4040
enforcer: ArgsEqualityCheckEnforcer,
4141
terms: args,
42-
args: '0x',
42+
args: '0x00',
4343
};
4444
};

packages/smart-accounts-kit/src/caveatBuilder/blockNumberBuilder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ export const blockNumberBuilder = (
6363
return {
6464
enforcer: BlockNumberEnforcer,
6565
terms,
66-
args: '0x',
66+
args: '0x00',
6767
};
6868
};

packages/smart-accounts-kit/src/caveatBuilder/caveatBuilder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class CaveatBuilder<
103103
): CaveatBuilder<TCaveatBuilderMap> {
104104
if (typeof nameOrCaveat === 'object') {
105105
const caveat = {
106-
args: '0x' as const,
106+
args: '0x00' as const,
107107
...nameOrCaveat,
108108
};
109109

packages/smart-accounts-kit/src/caveatBuilder/deployedBuilder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ export const deployedBuilder = (
6161
return {
6262
enforcer: DeployedEnforcer,
6363
terms,
64-
args: '0x',
64+
args: '0x00',
6565
};
6666
};

packages/smart-accounts-kit/src/caveatBuilder/erc1155BalanceChangeBuilder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,6 @@ export const erc1155BalanceChangeBuilder = (
8383
return {
8484
enforcer: ERC1155BalanceChangeEnforcer,
8585
terms,
86-
args: '0x',
86+
args: '0x00',
8787
};
8888
};

0 commit comments

Comments
 (0)