Skip to content
Open
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
1 change: 1 addition & 0 deletions packages/7715-permission-types/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Add `makePermissionDecoderConfigs` to resolve the `PermissionDecoderConfig`s to be used with @metamask/gator-permissions-controller ([#259](https://github.com/MetaMask/smart-accounts-kit/pull/259))
- Add permission schema metadata and MetaMask facilitator address utilities ([#267](https://github.com/MetaMask/smart-accounts-kit/pull/267))

## [0.7.1]

Expand Down
1 change: 1 addition & 0 deletions packages/7715-permission-types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ export {
type DeployedContractsByName,
type PermissionDecoderConfig,
} from './permissions';
export * from './permissions/schema';
1 change: 1 addition & 0 deletions packages/7715-permission-types/src/permissions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type { ExpiryRule } from './rules/expiry';
export type { PayeeRule } from './rules/payee';
export type { RedeemerRule } from './rules/redeemer';
export type { DeployedContractsByName, PermissionDecoderConfig };
export * from './schema';
/**
* Builds the canonical set of permission decoders for a chain.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/** Milliseconds in common time periods. */
export const SECOND = 1000;
export const HOUR = 60 * 60 * SECOND;
export const DAY = 24 * HOUR;
export const WEEK = 7 * DAY;
export const FORTNIGHT = 2 * WEEK;
export const MONTH = 30 * DAY;
export const YEAR = 365 * DAY;

/** Maximum uint256 value as lowercase hex. */
export const MAX_UINT256 =
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff';
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
export const METAMASK_FACILITATOR_ADDRESSES = [
'0xB01caEa8c6C47bbf4F4b4c5080Ca642043359C2E',
'0xC066ac5D385419B1A8c43A0E146fA439837a8B8c',
'0xB42F812A44c22cc6b861478900401ee759EbEAD6',
] as const;

export const METAMASK_FACILITATOR_ADDRESSES_DEV = [
'0xb4827A2a066CD2Ef88560EFdf063dD05C6c41cC7',
] as const;

export const ALL_METAMASK_FACILITATOR_ADDRESSES = [
...METAMASK_FACILITATOR_ADDRESSES,
...METAMASK_FACILITATOR_ADDRESSES_DEV,
] as const;

const METAMASK_FACILITATOR_ADDRESSES_LOWERCASE = new Set<string>(
ALL_METAMASK_FACILITATOR_ADDRESSES.map((address) => address.toLowerCase()),
);

/**
* Checks whether an address is a known MetaMask facilitator address.
*
* @param address - Address to check.
* @returns True if the address is a known MetaMask facilitator address.
*/
export function isMetaMaskFacilitatorAddress(address: string): boolean {
return METAMASK_FACILITATOR_ADDRESSES_LOWERCASE.has(address.toLowerCase());
}

/**
* Checks whether every provided address is a known MetaMask facilitator address.
*
* @param addresses - Addresses to check.
* @returns True when the list is non-empty and all entries are known facilitators.
*/
export function areOnlyMetaMaskFacilitatorAddresses(
addresses: string[] | null | undefined,
): boolean {
if (!addresses?.length) {
return false;
}

return addresses.every(isMetaMaskFacilitatorAddress);
}
Loading
Loading