Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,13 @@ import {
} from './specificActionERC20TransferBatchBuilder';
import { timestamp, timestampBuilder } from './timestampBuilder';
import { valueLte, valueLteBuilder } from './valueLteBuilder';
import type { CaveatType } from '../constants';

// While we could derive CoreCaveatMap from the createCaveatBuilder function,
// doing so would significantly complicate type resolution. By explicitly
// declaring the return type of createCaveatBuilder, we ensure the caveat
// map remains synchronized with the actual implementation.
type CoreCaveatMap = {
type CoreCaveatMapByString = {
allowedMethods: typeof allowedMethodsBuilder;
allowedTargets: typeof allowedTargetsBuilder;
deployed: typeof deployedBuilder;
Expand Down Expand Up @@ -122,6 +123,10 @@ type CoreCaveatMap = {
ownershipTransfer: typeof ownershipTransferBuilder;
};

type CoreCaveatMap = CoreCaveatMapByString & {
[K in CaveatType as `${K}`]: CoreCaveatMapByString[`${K}`];
};

/**
* A caveat builder type that includes all core caveat types pre-configured.
* This type represents a fully configured caveat builder with all the standard
Expand Down
39 changes: 39 additions & 0 deletions packages/smart-accounts-kit/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,42 @@ export enum ScopeType {
OwnershipTransfer = 'ownershipTransfer',
FunctionCall = 'functionCall',
}

/**
* Caveat types for enforcer functions used in delegations.
* Can be used when defining caveats either via CaveatBuilder.addCaveat
* or in the caveats array in createDelegation.
*/
export enum CaveatType {
AllowedMethods = 'allowedMethods',
AllowedTargets = 'allowedTargets',
Deployed = 'deployed',
AllowedCalldata = 'allowedCalldata',
Erc20BalanceChange = 'erc20BalanceChange',
Erc721BalanceChange = 'erc721BalanceChange',
Erc1155BalanceChange = 'erc1155BalanceChange',
ValueLte = 'valueLte',
LimitedCalls = 'limitedCalls',
Id = 'id',
Nonce = 'nonce',
Timestamp = 'timestamp',
BlockNumber = 'blockNumber',
Erc20TransferAmount = 'erc20TransferAmount',
Erc20Streaming = 'erc20Streaming',
NativeTokenStreaming = 'nativeTokenStreaming',
Erc721Transfer = 'erc721Transfer',
NativeTokenTransferAmount = 'nativeTokenTransferAmount',
NativeBalanceChange = 'nativeBalanceChange',
Redeemer = 'redeemer',
NativeTokenPayment = 'nativeTokenPayment',
ArgsEqualityCheck = 'argsEqualityCheck',
SpecificActionERC20TransferBatch = 'specificActionERC20TransferBatch',
Erc20PeriodTransfer = 'erc20PeriodTransfer',
NativeTokenPeriodTransfer = 'nativeTokenPeriodTransfer',
ExactCalldataBatch = 'exactCalldataBatch',
ExactCalldata = 'exactCalldata',
ExactExecution = 'exactExecution',
ExactExecutionBatch = 'exactExecutionBatch',
MultiTokenPeriod = 'multiTokenPeriod',
OwnershipTransfer = 'ownershipTransfer',
}
7 changes: 6 additions & 1 deletion packages/smart-accounts-kit/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ export {
getSmartAccountsEnvironment,
} from './smartAccountsEnvironment';

export { Implementation, TransferWindow, ScopeType } from './constants';
export {
Implementation,
TransferWindow,
ScopeType,
CaveatType,
} from './constants';

export { createExecution, ExecutionMode } from './executions';

Expand Down
Loading
Loading