@metamask/smart-accounts-kit 0.3.0 → 0.4.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -1
- package/dist/actions/index.cjs +10 -6
- package/dist/actions/index.cjs.map +1 -1
- package/dist/actions/index.d.cts +2 -2
- package/dist/actions/index.d.ts +2 -2
- package/dist/actions/index.mjs +9 -5
- package/dist/{chunk-72UQFUL5.mjs → chunk-4A5RMDDC.mjs} +3 -3
- package/dist/{chunk-2HNEALPY.mjs → chunk-5BYJZGRI.mjs} +59 -43
- package/dist/chunk-5BYJZGRI.mjs.map +1 -0
- package/dist/{chunk-Y5MOTV4T.mjs → chunk-AUCZDOTJ.mjs} +5 -4
- package/dist/chunk-AUCZDOTJ.mjs.map +1 -0
- package/dist/{chunk-F5U55BIP.mjs → chunk-DPWYECSV.mjs} +2 -2
- package/dist/{chunk-3JBYBEYP.mjs → chunk-EHIZB5U7.mjs} +3 -3
- package/dist/chunk-EHIZB5U7.mjs.map +1 -0
- package/dist/{chunk-HJETDDBN.cjs → chunk-MIP7KJYH.cjs} +29 -3
- package/dist/chunk-MIP7KJYH.cjs.map +1 -0
- package/dist/{chunk-5ZBCTLQS.cjs → chunk-NTZ57GNF.cjs} +17 -16
- package/dist/chunk-NTZ57GNF.cjs.map +1 -0
- package/dist/{chunk-4QBJFYZ7.cjs → chunk-RAXFJGCS.cjs} +12 -12
- package/dist/{chunk-4QBJFYZ7.cjs.map → chunk-RAXFJGCS.cjs.map} +1 -1
- package/dist/{chunk-QHDMZSGQ.cjs → chunk-S2Q5ZC64.cjs} +14 -14
- package/dist/{chunk-QHDMZSGQ.cjs.map → chunk-S2Q5ZC64.cjs.map} +1 -1
- package/dist/{chunk-BJGZGTRU.mjs → chunk-TEH426Y4.mjs} +28 -2
- package/dist/chunk-TEH426Y4.mjs.map +1 -0
- package/dist/{chunk-CPLIK3VF.mjs → chunk-TPBFVDVM.mjs} +1 -1
- package/dist/chunk-TPBFVDVM.mjs.map +1 -0
- package/dist/{chunk-BWR5ZK6Z.cjs → chunk-TXN7GX6Y.cjs} +5 -5
- package/dist/chunk-TXN7GX6Y.cjs.map +1 -0
- package/dist/{chunk-T6PSFUOZ.cjs → chunk-VLKX4BR6.cjs} +1 -1
- package/dist/chunk-VLKX4BR6.cjs.map +1 -0
- package/dist/{chunk-KTAXE6PZ.mjs → chunk-W6ZI7GWI.mjs} +5 -5
- package/dist/{chunk-DLR4BZKP.cjs → chunk-YTGYVHDF.cjs} +105 -105
- package/dist/{chunk-DLR4BZKP.cjs.map → chunk-YTGYVHDF.cjs.map} +1 -1
- package/dist/{chunk-QPCM4XRT.cjs → chunk-YWRHYLKB.cjs} +92 -76
- package/dist/chunk-YWRHYLKB.cjs.map +1 -0
- package/dist/contracts/index.cjs +6 -6
- package/dist/contracts/index.d.cts +2 -2
- package/dist/contracts/index.d.ts +2 -2
- package/dist/contracts/index.mjs +5 -5
- package/dist/{delegation-C7M1fy5Q.d.cts → delegation-BnhAvKt4.d.cts} +4 -4
- package/dist/{delegation-CCMAKs7W.d.ts → delegation-DHjM_pVa.d.ts} +4 -4
- package/dist/experimental/index.cjs +3 -3
- package/dist/experimental/index.cjs.map +1 -1
- package/dist/experimental/index.mjs +1 -1
- package/dist/experimental/index.mjs.map +1 -1
- package/dist/index-BlgCQ80b.d.ts +238 -0
- package/dist/{index-BGXTbonF.d.cts → index-CX3hrztI.d.cts} +24 -24
- package/dist/index-D04LO0vH.d.cts +238 -0
- package/dist/{index-DeHcI5-n.d.ts → index-i8cod4JY.d.ts} +24 -24
- package/dist/index.cjs +20 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.mjs +8 -8
- package/dist/index.mjs.map +1 -1
- package/dist/{userOp-CFv4wNkl.d.cts → userOp-DKgjzz7B.d.cts} +3 -3
- package/dist/{userOp-CFv4wNkl.d.ts → userOp-DKgjzz7B.d.ts} +3 -3
- package/dist/utils/index.cjs +6 -6
- package/dist/utils/index.d.cts +3 -3
- package/dist/utils/index.d.ts +3 -3
- package/dist/utils/index.mjs +5 -5
- package/package.json +18 -13
- package/dist/chunk-2HNEALPY.mjs.map +0 -1
- package/dist/chunk-3JBYBEYP.mjs.map +0 -1
- package/dist/chunk-5ZBCTLQS.cjs.map +0 -1
- package/dist/chunk-BJGZGTRU.mjs.map +0 -1
- package/dist/chunk-BWR5ZK6Z.cjs.map +0 -1
- package/dist/chunk-CPLIK3VF.mjs.map +0 -1
- package/dist/chunk-HJETDDBN.cjs.map +0 -1
- package/dist/chunk-QPCM4XRT.cjs.map +0 -1
- package/dist/chunk-T6PSFUOZ.cjs.map +0 -1
- package/dist/chunk-Y5MOTV4T.mjs.map +0 -1
- package/dist/index-DYq7aOEN.d.cts +0 -1180
- package/dist/index-Do0GpCXe.d.ts +0 -1180
- /package/dist/{chunk-72UQFUL5.mjs.map → chunk-4A5RMDDC.mjs.map} +0 -0
- /package/dist/{chunk-F5U55BIP.mjs.map → chunk-DPWYECSV.mjs.map} +0 -0
- /package/dist/{chunk-KTAXE6PZ.mjs.map → chunk-W6ZI7GWI.mjs.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.4.0-beta.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- feat: add discoverability methods ([#127](https://github.com/metamask/smart-accounts-kit/pull/127))
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- **Breaking** Implement erc-7715 type scheme revisions across packages ([#128](https://github.com/metamask/smart-accounts-kit/pull/128))
|
|
19
|
+
- Resolve yarn peer dependency warnings ([#123](https://github.com/metamask/smart-accounts-kit/pull/123))
|
|
20
|
+
- Allow expiry to be omitted when requesting 7715 permissions ([#122](https://github.com/metamask/smart-accounts-kit/pull/122))
|
|
21
|
+
|
|
10
22
|
## [0.3.0]
|
|
11
23
|
|
|
12
24
|
### Fixed
|
|
@@ -30,7 +42,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
30
42
|
|
|
31
43
|
- Promote readable permissions actions (`requestExecutionPermissions`, `sendTransactionWithDelegation`, and `sendUserOperationWithDelegation`) from experimental ([#91](https://github.com/MetaMask/smart-accounts-kit/pull/91))
|
|
32
44
|
|
|
33
|
-
[Unreleased]: https://github.com/metamask/smart-accounts-kit/compare/@metamask/smart-accounts-kit@0.
|
|
45
|
+
[Unreleased]: https://github.com/metamask/smart-accounts-kit/compare/@metamask/smart-accounts-kit@0.4.0-beta.0...HEAD
|
|
46
|
+
[0.4.0-beta.0]: https://github.com/metamask/smart-accounts-kit/compare/@metamask/smart-accounts-kit@0.3.0...@metamask/smart-accounts-kit@0.4.0-beta.0
|
|
34
47
|
[0.3.0]: https://github.com/metamask/smart-accounts-kit/compare/@metamask/smart-accounts-kit@0.2.0...@metamask/smart-accounts-kit@0.3.0
|
|
35
48
|
[0.2.0]: https://github.com/metamask/smart-accounts-kit/compare/@metamask/smart-accounts-kit@0.1.0...@metamask/smart-accounts-kit@0.2.0
|
|
36
49
|
[0.1.0]: https://github.com/metamask/smart-accounts-kit/releases/tag/@metamask/smart-accounts-kit@0.1.0
|
package/dist/actions/index.cjs
CHANGED
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
var _chunkQPCM4XRTcjs = require('../chunk-QPCM4XRT.cjs');
|
|
18
|
-
require('../chunk-4QBJFYZ7.cjs');
|
|
19
|
-
require('../chunk-BWR5ZK6Z.cjs');
|
|
20
|
-
require('../chunk-T6PSFUOZ.cjs');
|
|
21
|
-
require('../chunk-HJETDDBN.cjs');
|
|
22
17
|
|
|
23
18
|
|
|
19
|
+
var _chunkYWRHYLKBcjs = require('../chunk-YWRHYLKB.cjs');
|
|
20
|
+
require('../chunk-RAXFJGCS.cjs');
|
|
21
|
+
require('../chunk-TXN7GX6Y.cjs');
|
|
22
|
+
require('../chunk-VLKX4BR6.cjs');
|
|
23
|
+
require('../chunk-MIP7KJYH.cjs');
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
@@ -35,5 +35,9 @@ require('../chunk-HJETDDBN.cjs');
|
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
exports.caveatEnforcerActions = _chunkYWRHYLKBcjs.caveatEnforcerActions; exports.erc7710BundlerActions = _chunkYWRHYLKBcjs.erc7710BundlerActions; exports.erc7710WalletActions = _chunkYWRHYLKBcjs.erc7710WalletActions; exports.erc7715ProviderActions = _chunkYWRHYLKBcjs.erc7715ProviderActions; exports.getErc20PeriodTransferEnforcerAvailableAmount = _chunkYWRHYLKBcjs.getErc20PeriodTransferEnforcerAvailableAmount; exports.getErc20StreamingEnforcerAvailableAmount = _chunkYWRHYLKBcjs.getErc20StreamingEnforcerAvailableAmount; exports.getGrantedExecutionPermissions = _chunkYWRHYLKBcjs.erc7715GetGrantedExecutionPermissionsAction; exports.getMultiTokenPeriodEnforcerAvailableAmount = _chunkYWRHYLKBcjs.getMultiTokenPeriodEnforcerAvailableAmount; exports.getNativeTokenPeriodTransferEnforcerAvailableAmount = _chunkYWRHYLKBcjs.getNativeTokenPeriodTransferEnforcerAvailableAmount; exports.getNativeTokenStreamingEnforcerAvailableAmount = _chunkYWRHYLKBcjs.getNativeTokenStreamingEnforcerAvailableAmount; exports.getSupportedExecutionPermissions = _chunkYWRHYLKBcjs.erc7715GetSupportedExecutionPermissionsAction; exports.isValid7702Implementation = _chunkYWRHYLKBcjs.isValid7702Implementation; exports.requestExecutionPermissions = _chunkYWRHYLKBcjs.erc7715RequestExecutionPermissionsAction; exports.signDelegation = _chunkYWRHYLKBcjs.signDelegation; exports.signDelegationActions = _chunkYWRHYLKBcjs.signDelegationActions; exports.signUserOperation = _chunkYWRHYLKBcjs.signUserOperation; exports.signUserOperationActions = _chunkYWRHYLKBcjs.signUserOperationActions;
|
|
39
43
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/smart-accounts-kit/smart-accounts-kit/packages/smart-accounts-kit/dist/actions/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/smart-accounts-kit/smart-accounts-kit/packages/smart-accounts-kit/dist/actions/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yhDAAC","file":"/home/runner/work/smart-accounts-kit/smart-accounts-kit/packages/smart-accounts-kit/dist/actions/index.cjs"}
|
package/dist/actions/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { C as CaveatEnforcerParams, D as DelegatedCall, M as MetaMaskExtensionClient, u as MetaMaskExtensionSchema, P as PeriodTransferResult, R as RequestExecutionPermissionsParameters, v as RequestExecutionPermissionsReturnType, m as SignDelegationParameters, n as SignDelegationReturnType, q as SignUserOperationParameters, r as SignUserOperationReturnType, S as StreamingResult, c as caveatEnforcerActions, b as erc7710BundlerActions, a as erc7710WalletActions, e as erc7715ProviderActions, g as getErc20PeriodTransferEnforcerAvailableAmount, d as getErc20StreamingEnforcerAvailableAmount, f as getMultiTokenPeriodEnforcerAvailableAmount, h as getNativeTokenPeriodTransferEnforcerAvailableAmount, j as getNativeTokenStreamingEnforcerAvailableAmount, k as isValid7702Implementation, t as requestExecutionPermissions, s as signDelegation, l as signDelegationActions, o as signUserOperation, p as signUserOperationActions } from '../index-
|
|
1
|
+
export { C as CaveatEnforcerParams, D as DelegatedCall, y as GetGrantedExecutionPermissionsResult, G as GetSupportedExecutionPermissionsResult, M as MetaMaskExtensionClient, u as MetaMaskExtensionSchema, P as PeriodTransferResult, R as RequestExecutionPermissionsParameters, v as RequestExecutionPermissionsReturnType, m as SignDelegationParameters, n as SignDelegationReturnType, q as SignUserOperationParameters, r as SignUserOperationReturnType, S as StreamingResult, z as SupportedPermissionInfo, c as caveatEnforcerActions, b as erc7710BundlerActions, a as erc7710WalletActions, e as erc7715ProviderActions, g as getErc20PeriodTransferEnforcerAvailableAmount, d as getErc20StreamingEnforcerAvailableAmount, x as getGrantedExecutionPermissions, f as getMultiTokenPeriodEnforcerAvailableAmount, h as getNativeTokenPeriodTransferEnforcerAvailableAmount, j as getNativeTokenStreamingEnforcerAvailableAmount, w as getSupportedExecutionPermissions, k as isValid7702Implementation, t as requestExecutionPermissions, s as signDelegation, l as signDelegationActions, o as signUserOperation, p as signUserOperationActions } from '../index-D04LO0vH.cjs';
|
|
2
2
|
import 'viem';
|
|
3
3
|
import '@metamask/7715-permission-types';
|
|
4
4
|
import 'viem/account-abstraction';
|
|
5
5
|
import '../types-Bwksz_U6.cjs';
|
|
6
6
|
import '@metamask/delegation-abis';
|
|
7
7
|
import 'viem/chains';
|
|
8
|
-
import '../userOp-
|
|
8
|
+
import '../userOp-DKgjzz7B.cjs';
|
package/dist/actions/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { C as CaveatEnforcerParams, D as DelegatedCall, M as MetaMaskExtensionClient, u as MetaMaskExtensionSchema, P as PeriodTransferResult, R as RequestExecutionPermissionsParameters, v as RequestExecutionPermissionsReturnType, m as SignDelegationParameters, n as SignDelegationReturnType, q as SignUserOperationParameters, r as SignUserOperationReturnType, S as StreamingResult, c as caveatEnforcerActions, b as erc7710BundlerActions, a as erc7710WalletActions, e as erc7715ProviderActions, g as getErc20PeriodTransferEnforcerAvailableAmount, d as getErc20StreamingEnforcerAvailableAmount, f as getMultiTokenPeriodEnforcerAvailableAmount, h as getNativeTokenPeriodTransferEnforcerAvailableAmount, j as getNativeTokenStreamingEnforcerAvailableAmount, k as isValid7702Implementation, t as requestExecutionPermissions, s as signDelegation, l as signDelegationActions, o as signUserOperation, p as signUserOperationActions } from '../index-
|
|
1
|
+
export { C as CaveatEnforcerParams, D as DelegatedCall, y as GetGrantedExecutionPermissionsResult, G as GetSupportedExecutionPermissionsResult, M as MetaMaskExtensionClient, u as MetaMaskExtensionSchema, P as PeriodTransferResult, R as RequestExecutionPermissionsParameters, v as RequestExecutionPermissionsReturnType, m as SignDelegationParameters, n as SignDelegationReturnType, q as SignUserOperationParameters, r as SignUserOperationReturnType, S as StreamingResult, z as SupportedPermissionInfo, c as caveatEnforcerActions, b as erc7710BundlerActions, a as erc7710WalletActions, e as erc7715ProviderActions, g as getErc20PeriodTransferEnforcerAvailableAmount, d as getErc20StreamingEnforcerAvailableAmount, x as getGrantedExecutionPermissions, f as getMultiTokenPeriodEnforcerAvailableAmount, h as getNativeTokenPeriodTransferEnforcerAvailableAmount, j as getNativeTokenStreamingEnforcerAvailableAmount, w as getSupportedExecutionPermissions, k as isValid7702Implementation, t as requestExecutionPermissions, s as signDelegation, l as signDelegationActions, o as signUserOperation, p as signUserOperationActions } from '../index-BlgCQ80b.js';
|
|
2
2
|
import 'viem';
|
|
3
3
|
import '@metamask/7715-permission-types';
|
|
4
4
|
import 'viem/account-abstraction';
|
|
5
5
|
import '../types-Bwksz_U6.js';
|
|
6
6
|
import '@metamask/delegation-abis';
|
|
7
7
|
import 'viem/chains';
|
|
8
|
-
import '../userOp-
|
|
8
|
+
import '../userOp-DKgjzz7B.js';
|
package/dist/actions/index.mjs
CHANGED
|
@@ -2,6 +2,8 @@ import {
|
|
|
2
2
|
caveatEnforcerActions,
|
|
3
3
|
erc7710BundlerActions,
|
|
4
4
|
erc7710WalletActions,
|
|
5
|
+
erc7715GetGrantedExecutionPermissionsAction,
|
|
6
|
+
erc7715GetSupportedExecutionPermissionsAction,
|
|
5
7
|
erc7715ProviderActions,
|
|
6
8
|
erc7715RequestExecutionPermissionsAction,
|
|
7
9
|
getErc20PeriodTransferEnforcerAvailableAmount,
|
|
@@ -14,11 +16,11 @@ import {
|
|
|
14
16
|
signDelegationActions,
|
|
15
17
|
signUserOperation,
|
|
16
18
|
signUserOperationActions
|
|
17
|
-
} from "../chunk-
|
|
18
|
-
import "../chunk-
|
|
19
|
-
import "../chunk-
|
|
20
|
-
import "../chunk-
|
|
21
|
-
import "../chunk-
|
|
19
|
+
} from "../chunk-5BYJZGRI.mjs";
|
|
20
|
+
import "../chunk-DPWYECSV.mjs";
|
|
21
|
+
import "../chunk-EHIZB5U7.mjs";
|
|
22
|
+
import "../chunk-TPBFVDVM.mjs";
|
|
23
|
+
import "../chunk-TEH426Y4.mjs";
|
|
22
24
|
export {
|
|
23
25
|
caveatEnforcerActions,
|
|
24
26
|
erc7710BundlerActions,
|
|
@@ -26,9 +28,11 @@ export {
|
|
|
26
28
|
erc7715ProviderActions,
|
|
27
29
|
getErc20PeriodTransferEnforcerAvailableAmount,
|
|
28
30
|
getErc20StreamingEnforcerAvailableAmount,
|
|
31
|
+
erc7715GetGrantedExecutionPermissionsAction as getGrantedExecutionPermissions,
|
|
29
32
|
getMultiTokenPeriodEnforcerAvailableAmount,
|
|
30
33
|
getNativeTokenPeriodTransferEnforcerAvailableAmount,
|
|
31
34
|
getNativeTokenStreamingEnforcerAvailableAmount,
|
|
35
|
+
erc7715GetSupportedExecutionPermissionsAction as getSupportedExecutionPermissions,
|
|
32
36
|
isValid7702Implementation,
|
|
33
37
|
erc7715RequestExecutionPermissionsAction as requestExecutionPermissions,
|
|
34
38
|
signDelegation,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
encodeExecutionCalldata
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-TPBFVDVM.mjs";
|
|
4
4
|
import {
|
|
5
5
|
__export,
|
|
6
6
|
toDelegationStruct
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-TEH426Y4.mjs";
|
|
8
8
|
|
|
9
9
|
// src/DelegationFramework/utils.ts
|
|
10
10
|
import { ERC1967Proxy } from "@metamask/delegation-abis";
|
|
@@ -828,4 +828,4 @@ export {
|
|
|
828
828
|
execute6,
|
|
829
829
|
encode_exports4
|
|
830
830
|
};
|
|
831
|
-
//# sourceMappingURL=chunk-
|
|
831
|
+
//# sourceMappingURL=chunk-4A5RMDDC.mjs.map
|
|
@@ -4,20 +4,22 @@ import {
|
|
|
4
4
|
read_exports3,
|
|
5
5
|
read_exports4,
|
|
6
6
|
read_exports5
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-DPWYECSV.mjs";
|
|
8
8
|
import {
|
|
9
9
|
getSmartAccountsEnvironment,
|
|
10
10
|
prepareSignUserOperationTypedData
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-EHIZB5U7.mjs";
|
|
12
12
|
import {
|
|
13
13
|
createExecution,
|
|
14
14
|
encodeExecutionCalldatas
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-TPBFVDVM.mjs";
|
|
16
16
|
import {
|
|
17
17
|
__export,
|
|
18
18
|
getDelegationHashOffchain,
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
isDefined,
|
|
20
|
+
prepareSignDelegationTypedData,
|
|
21
|
+
toHexOrThrow
|
|
22
|
+
} from "./chunk-TEH426Y4.mjs";
|
|
21
23
|
|
|
22
24
|
// src/actions/index.ts
|
|
23
25
|
var actions_exports = {};
|
|
@@ -28,9 +30,11 @@ __export(actions_exports, {
|
|
|
28
30
|
erc7715ProviderActions: () => erc7715ProviderActions,
|
|
29
31
|
getErc20PeriodTransferEnforcerAvailableAmount: () => getErc20PeriodTransferEnforcerAvailableAmount,
|
|
30
32
|
getErc20StreamingEnforcerAvailableAmount: () => getErc20StreamingEnforcerAvailableAmount,
|
|
33
|
+
getGrantedExecutionPermissions: () => erc7715GetGrantedExecutionPermissionsAction,
|
|
31
34
|
getMultiTokenPeriodEnforcerAvailableAmount: () => getMultiTokenPeriodEnforcerAvailableAmount,
|
|
32
35
|
getNativeTokenPeriodTransferEnforcerAvailableAmount: () => getNativeTokenPeriodTransferEnforcerAvailableAmount,
|
|
33
36
|
getNativeTokenStreamingEnforcerAvailableAmount: () => getNativeTokenStreamingEnforcerAvailableAmount,
|
|
37
|
+
getSupportedExecutionPermissions: () => erc7715GetSupportedExecutionPermissionsAction,
|
|
34
38
|
isValid7702Implementation: () => isValid7702Implementation,
|
|
35
39
|
requestExecutionPermissions: () => erc7715RequestExecutionPermissionsAction,
|
|
36
40
|
signDelegation: () => signDelegation,
|
|
@@ -128,8 +132,38 @@ async function sendUserOperationWithDelegationAction(client, parameters) {
|
|
|
128
132
|
);
|
|
129
133
|
}
|
|
130
134
|
|
|
135
|
+
// src/actions/erc7715GetGrantedExecutionPermissionsAction.ts
|
|
136
|
+
async function erc7715GetGrantedExecutionPermissionsAction(client) {
|
|
137
|
+
const result = await client.request(
|
|
138
|
+
{
|
|
139
|
+
method: "wallet_getGrantedExecutionPermissions",
|
|
140
|
+
params: []
|
|
141
|
+
},
|
|
142
|
+
{ retryCount: 0 }
|
|
143
|
+
);
|
|
144
|
+
if (!result) {
|
|
145
|
+
throw new Error("Failed to get granted execution permissions");
|
|
146
|
+
}
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// src/actions/erc7715GetSupportedExecutionPermissionsAction.ts
|
|
151
|
+
async function erc7715GetSupportedExecutionPermissionsAction(client) {
|
|
152
|
+
const result = await client.request(
|
|
153
|
+
{
|
|
154
|
+
method: "wallet_getSupportedExecutionPermissions",
|
|
155
|
+
params: []
|
|
156
|
+
},
|
|
157
|
+
{ retryCount: 0 }
|
|
158
|
+
);
|
|
159
|
+
if (!result) {
|
|
160
|
+
throw new Error("Failed to get supported execution permissions");
|
|
161
|
+
}
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
164
|
+
|
|
131
165
|
// src/actions/erc7715RequestExecutionPermissionsAction.ts
|
|
132
|
-
import {
|
|
166
|
+
import { toHex } from "viem";
|
|
133
167
|
async function erc7715RequestExecutionPermissionsAction(client, parameters) {
|
|
134
168
|
const formattedPermissionRequest = parameters.map(formatPermissionsRequest);
|
|
135
169
|
const result = await client.request(
|
|
@@ -145,22 +179,20 @@ async function erc7715RequestExecutionPermissionsAction(client, parameters) {
|
|
|
145
179
|
return result;
|
|
146
180
|
}
|
|
147
181
|
function formatPermissionsRequest(parameters) {
|
|
148
|
-
const { chainId,
|
|
182
|
+
const { chainId, from, expiry, isAdjustmentAllowed } = parameters;
|
|
149
183
|
const permissionFormatter = getPermissionFormatter(
|
|
150
184
|
parameters.permission.type
|
|
151
185
|
);
|
|
152
|
-
const
|
|
153
|
-
const rules = [
|
|
186
|
+
const rules = isDefined(expiry) ? [
|
|
154
187
|
{
|
|
155
188
|
type: "expiry",
|
|
156
|
-
isAdjustmentAllowed,
|
|
157
189
|
data: {
|
|
158
190
|
timestamp: expiry
|
|
159
191
|
}
|
|
160
192
|
}
|
|
161
|
-
];
|
|
193
|
+
] : [];
|
|
162
194
|
const optionalFields = {
|
|
163
|
-
...
|
|
195
|
+
...from ? { from } : {}
|
|
164
196
|
};
|
|
165
197
|
return {
|
|
166
198
|
...optionalFields,
|
|
@@ -169,38 +201,10 @@ function formatPermissionsRequest(parameters) {
|
|
|
169
201
|
permission: parameters.permission,
|
|
170
202
|
isAdjustmentAllowed
|
|
171
203
|
}),
|
|
172
|
-
|
|
173
|
-
// MetaMask 7715 implementation only supports AccountSigner
|
|
174
|
-
type: "account",
|
|
175
|
-
data: {
|
|
176
|
-
address: signerAddress
|
|
177
|
-
}
|
|
178
|
-
},
|
|
204
|
+
to: parameters.to,
|
|
179
205
|
rules
|
|
180
206
|
};
|
|
181
207
|
}
|
|
182
|
-
function isDefined(value) {
|
|
183
|
-
return value !== void 0 && value !== null;
|
|
184
|
-
}
|
|
185
|
-
function assertIsDefined(value, parameterName) {
|
|
186
|
-
if (!isDefined(value)) {
|
|
187
|
-
throw new Error(
|
|
188
|
-
`Invalid parameters: ${parameterName ?? "value"} is required`
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
function toHexOrThrow(value, parameterName) {
|
|
193
|
-
assertIsDefined(value, parameterName);
|
|
194
|
-
if (typeof value === "string") {
|
|
195
|
-
if (!isHex(value)) {
|
|
196
|
-
throw new Error(
|
|
197
|
-
`Invalid parameters: ${parameterName ?? "value"} is not a valid hex value`
|
|
198
|
-
);
|
|
199
|
-
}
|
|
200
|
-
return value;
|
|
201
|
-
}
|
|
202
|
-
return toHex(value);
|
|
203
|
-
}
|
|
204
208
|
function getPermissionFormatter(permissionType) {
|
|
205
209
|
switch (permissionType) {
|
|
206
210
|
case "native-token-stream":
|
|
@@ -617,7 +621,7 @@ async function isValid7702Implementation({
|
|
|
617
621
|
return false;
|
|
618
622
|
}
|
|
619
623
|
return isAddressEqual2(delegatedAddress, expectedImplementation);
|
|
620
|
-
} catch
|
|
624
|
+
} catch {
|
|
621
625
|
return false;
|
|
622
626
|
}
|
|
623
627
|
}
|
|
@@ -721,6 +725,16 @@ var erc7715ProviderActions = () => (client) => ({
|
|
|
721
725
|
client,
|
|
722
726
|
parameters
|
|
723
727
|
);
|
|
728
|
+
},
|
|
729
|
+
getSupportedExecutionPermissions: async () => {
|
|
730
|
+
return erc7715GetSupportedExecutionPermissionsAction(
|
|
731
|
+
client
|
|
732
|
+
);
|
|
733
|
+
},
|
|
734
|
+
getGrantedExecutionPermissions: async () => {
|
|
735
|
+
return erc7715GetGrantedExecutionPermissionsAction(
|
|
736
|
+
client
|
|
737
|
+
);
|
|
724
738
|
}
|
|
725
739
|
});
|
|
726
740
|
var erc7710WalletActions = () => (client) => ({
|
|
@@ -732,6 +746,8 @@ var erc7710BundlerActions = () => (client) => ({
|
|
|
732
746
|
|
|
733
747
|
export {
|
|
734
748
|
isValid7702Implementation,
|
|
749
|
+
erc7715GetGrantedExecutionPermissionsAction,
|
|
750
|
+
erc7715GetSupportedExecutionPermissionsAction,
|
|
735
751
|
erc7715RequestExecutionPermissionsAction,
|
|
736
752
|
getErc20PeriodTransferEnforcerAvailableAmount,
|
|
737
753
|
getErc20StreamingEnforcerAvailableAmount,
|
|
@@ -748,4 +764,4 @@ export {
|
|
|
748
764
|
erc7710BundlerActions,
|
|
749
765
|
actions_exports
|
|
750
766
|
};
|
|
751
|
-
//# sourceMappingURL=chunk-
|
|
767
|
+
//# sourceMappingURL=chunk-5BYJZGRI.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/actions/index.ts","../src/actions/erc7710RedeemDelegationAction.ts","../src/actions/erc7715GetGrantedExecutionPermissionsAction.ts","../src/actions/erc7715GetSupportedExecutionPermissionsAction.ts","../src/actions/erc7715RequestExecutionPermissionsAction.ts","../src/actions/getCaveatAvailableAmount.ts","../src/actions/isValid7702Implementation.ts","../src/actions/signDelegation.ts","../src/actions/signUserOperation.ts"],"sourcesContent":["import type { Client, WalletClient } from 'viem';\nimport type { BundlerClient } from 'viem/account-abstraction';\n\nimport type {\n SendTransactionWithDelegationParameters,\n SendUserOperationWithDelegationParameters,\n} from './erc7710RedeemDelegationAction';\nimport {\n sendTransactionWithDelegationAction,\n sendUserOperationWithDelegationAction,\n} from './erc7710RedeemDelegationAction';\nimport { erc7715GetGrantedExecutionPermissionsAction } from './erc7715GetGrantedExecutionPermissionsAction';\nimport { erc7715GetSupportedExecutionPermissionsAction } from './erc7715GetSupportedExecutionPermissionsAction';\nimport { erc7715RequestExecutionPermissionsAction } from './erc7715RequestExecutionPermissionsAction';\nimport type {\n MetaMaskExtensionClient,\n RequestExecutionPermissionsParameters,\n} from './erc7715RequestExecutionPermissionsAction';\n\nexport {\n // Individual action functions\n getErc20PeriodTransferEnforcerAvailableAmount,\n getErc20StreamingEnforcerAvailableAmount,\n getMultiTokenPeriodEnforcerAvailableAmount,\n getNativeTokenPeriodTransferEnforcerAvailableAmount,\n getNativeTokenStreamingEnforcerAvailableAmount,\n // Action builder\n caveatEnforcerActions,\n // Parameter types\n type CaveatEnforcerParams,\n // Result types\n type PeriodTransferResult,\n type StreamingResult,\n} from './getCaveatAvailableAmount';\n\nexport { isValid7702Implementation } from './isValid7702Implementation';\n\n// Signing actions\nexport {\n signDelegation,\n signDelegationActions,\n type SignDelegationParameters,\n type SignDelegationReturnType,\n} from './signDelegation';\n\nexport {\n signUserOperation,\n signUserOperationActions,\n type SignUserOperationParameters,\n type SignUserOperationReturnType,\n} from './signUserOperation';\n\nexport {\n erc7715RequestExecutionPermissionsAction as requestExecutionPermissions,\n type MetaMaskExtensionClient,\n type MetaMaskExtensionSchema,\n type RequestExecutionPermissionsParameters,\n type RequestExecutionPermissionsReturnType,\n} from './erc7715RequestExecutionPermissionsAction';\n\nexport { erc7715GetSupportedExecutionPermissionsAction as getSupportedExecutionPermissions } from './erc7715GetSupportedExecutionPermissionsAction';\n\nexport { erc7715GetGrantedExecutionPermissionsAction as getGrantedExecutionPermissions } from './erc7715GetGrantedExecutionPermissionsAction';\n\nexport {\n type GetSupportedExecutionPermissionsResult,\n type GetGrantedExecutionPermissionsResult,\n type SupportedPermissionInfo,\n} from './erc7715Types';\n\nexport type { DelegatedCall } from './erc7710RedeemDelegationAction';\n\nexport const erc7715ProviderActions = () => (client: Client) => ({\n requestExecutionPermissions: async (\n parameters: RequestExecutionPermissionsParameters,\n ) => {\n return erc7715RequestExecutionPermissionsAction(\n client as MetaMaskExtensionClient,\n parameters,\n );\n },\n getSupportedExecutionPermissions: async () => {\n return erc7715GetSupportedExecutionPermissionsAction(\n client as MetaMaskExtensionClient,\n );\n },\n getGrantedExecutionPermissions: async () => {\n return erc7715GetGrantedExecutionPermissionsAction(\n client as MetaMaskExtensionClient,\n );\n },\n});\n\nexport const erc7710WalletActions = () => (client: WalletClient) => ({\n sendTransactionWithDelegation: async (\n args: SendTransactionWithDelegationParameters,\n ) => sendTransactionWithDelegationAction(client, args),\n});\n\nexport const erc7710BundlerActions = () => (client: Client) => ({\n sendUserOperationWithDelegation: async (\n args: SendUserOperationWithDelegationParameters,\n ) => sendUserOperationWithDelegationAction(client as BundlerClient, args),\n});\n","import { DelegationManager } from '@metamask/delegation-abis';\nimport type {\n Account,\n Chain,\n Hex,\n OneOf,\n PublicClient,\n SendTransactionParameters,\n SendTransactionRequest,\n Transport,\n WalletClient,\n} from 'viem';\nimport { concat, encodeFunctionData, isAddressEqual } from 'viem';\nimport type {\n BundlerClient,\n SendUserOperationParameters,\n SmartAccount,\n} from 'viem/account-abstraction';\n\nimport {\n createExecution,\n encodeExecutionCalldatas,\n ExecutionMode,\n} from '../executions';\nimport { getSmartAccountsEnvironment } from '../smartAccountsEnvironment';\nimport type { Call } from '../types';\n\nexport type DelegatedCall = Call &\n OneOf<{ permissionsContext: Hex; delegationManager: Hex } | object>;\n\nexport type SendTransactionWithDelegationParameters<\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends Account | undefined = Account | undefined,\n TChainOverride extends Chain | undefined = Chain | undefined,\n TRequest extends SendTransactionRequest<TChain, TChainOverride> =\n SendTransactionRequest<TChain, TChainOverride>,\n> = SendTransactionParameters<TChain, TAccount, TChainOverride, TRequest> & {\n permissionsContext: Hex;\n delegationManager: Hex;\n};\n\n/**\n * Sends a transaction using delegation to execute operations on behalf of another account.\n *\n * @param client - The wallet client to use for sending the transaction.\n * @param args - Transaction parameters with delegation details.\n * @returns Transaction hash of the executed transaction.\n */\nexport async function sendTransactionWithDelegationAction<\n TChain extends Chain | undefined,\n TAccount extends Account | undefined,\n>(\n client: WalletClient<Transport, TChain, TAccount>,\n args: SendTransactionWithDelegationParameters<TChain, TAccount>,\n) {\n if (!args.to) {\n throw new Error(\n '`to` is required. `sendTransactionWithDelegation` cannot be used to deploy contracts.',\n );\n }\n\n const executions = [\n createExecution({\n target: args.to,\n value: args.value,\n callData: args.data,\n }),\n ];\n\n const calldata = encodeFunctionData({\n abi: DelegationManager.abi,\n functionName: 'redeemDelegations',\n args: [\n [args.permissionsContext],\n [ExecutionMode.SingleDefault],\n encodeExecutionCalldatas([executions]),\n ],\n });\n\n const {\n value: _value,\n permissionsContext: _permissionsContext,\n delegationManager: _delegationManager,\n ...rest\n } = args;\n\n const hash = await client.sendTransaction({\n ...rest,\n to: args.delegationManager,\n data: calldata,\n } as unknown as SendTransactionParameters);\n\n return hash;\n}\n\nexport type SendUserOperationWithDelegationParameters<\n TAccount extends SmartAccount | undefined = SmartAccount | undefined,\n TAccountOverride extends SmartAccount | undefined = SmartAccount | undefined,\n> = SendUserOperationParameters<TAccount, TAccountOverride, DelegatedCall[]> & {\n accountMetadata?: { factory: Hex; factoryData: Hex }[];\n calls: DelegatedCall[];\n publicClient: PublicClient<Transport, Chain>;\n};\n\n/**\n * Broadcasts a User Operation with delegation to the Bundler.\n *\n * @param client - Client to use for sending the user operation.\n * @param parameters - Parameters for the user operation with delegation.\n * @returns The User Operation hash of the broadcasted operation.\n * @example\n * import { createBundlerClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const bundlerClient = createBundlerClient({\n * chain: mainnet,\n * transport: http(),\n * })\n *\n * const userOpHash = await sendUserOperationWithDelegationAction(bundlerClient, {\n * account: bobSmartAccount,\n * calls: [\n * {\n * to: aliceCounterContractAddress,\n * data: encodeFunctionData({\n * abi: CounterMetadata.abi,\n * functionName: 'increment',\n * }),\n * value: 0n,\n * permissionsContext: '0x...',\n * delegationManager: '0x...',\n * },\n * ],\n * accountMetadata: [{ factory: '0x...', factoryData: '0x...' }], // Optional: for deploying accounts\n * })\n */\nexport async function sendUserOperationWithDelegationAction<\n TAccount extends SmartAccount | undefined,\n TAccountOverride extends SmartAccount | undefined = undefined,\n>(\n client: BundlerClient<Transport, Chain | undefined, TAccount>,\n parameters: SendUserOperationWithDelegationParameters<\n TAccount,\n TAccountOverride\n >,\n) {\n if (parameters.accountMetadata) {\n const { publicClient } = parameters;\n\n const includedAccountKeys: Record<Hex, boolean> = {};\n\n const chainId = publicClient.chain?.id;\n\n if (!chainId) {\n throw new Error('Chain ID is not set');\n }\n\n const { SimpleFactory } = getSmartAccountsEnvironment(chainId);\n\n const uniqueAccountMetadatas = parameters.accountMetadata.filter(\n (accountMetadata) => {\n if (!isAddressEqual(accountMetadata.factory, SimpleFactory)) {\n throw new Error(\n `Invalid accountMetadata: ${accountMetadata.factory} is not allowed.`,\n );\n }\n\n // ensure that factory calls are not duplicated\n const accountKey = concat([\n accountMetadata.factory,\n accountMetadata.factoryData,\n ]);\n const isDuplicate = includedAccountKeys[accountKey];\n\n includedAccountKeys[accountKey] = true;\n return !isDuplicate;\n },\n );\n\n const factoryCalls = (\n await Promise.all(\n uniqueAccountMetadatas.map(async ({ factory, factoryData }) => {\n const isDeployed = await publicClient\n .call({\n to: factory,\n data: factoryData,\n })\n .then(() => false)\n .catch(() => true);\n\n if (isDeployed) {\n return undefined;\n }\n return {\n to: factory,\n value: 0n,\n data: factoryData,\n };\n }),\n )\n ).filter((call: Call | undefined) => call !== undefined) as Call[];\n\n parameters.calls = [\n ...(factoryCalls as DelegatedCall[]),\n ...parameters.calls,\n ];\n }\n\n return client.sendUserOperation(\n parameters as unknown as SendUserOperationParameters,\n );\n}\n","import type {\n GetGrantedExecutionPermissionsResult,\n MetaMaskExtensionClient,\n} from './erc7715Types';\n\n/**\n * Retrieves all previously granted execution permissions from the wallet according to EIP-7715 specification.\n *\n * @param client - The client to use for the request.\n * @returns A promise that resolves to an array of granted permission responses.\n * @description\n * This function queries the wallet for all granted permissions that are not yet revoked.\n * Each permission response includes the chain ID, address, signer, permission details,\n * context, and dependency information.\n * @example\n * ```typescript\n * const grantedPermissions = await erc7715GetGrantedExecutionPermissionsAction(client);\n * // Returns an array of PermissionResponse objects\n * ```\n */\nexport async function erc7715GetGrantedExecutionPermissionsAction(\n client: MetaMaskExtensionClient,\n): Promise<GetGrantedExecutionPermissionsResult> {\n const result = await client.request(\n {\n method: 'wallet_getGrantedExecutionPermissions',\n params: [],\n },\n { retryCount: 0 },\n );\n\n if (!result) {\n throw new Error('Failed to get granted execution permissions');\n }\n\n return result;\n}\n","import type {\n GetSupportedExecutionPermissionsResult,\n MetaMaskExtensionClient,\n} from './erc7715Types';\n\n/**\n * Retrieves the supported execution permission types from the wallet according to EIP-7715 specification.\n *\n * @param client - The client to use for the request.\n * @returns A promise that resolves to a record of supported permission types with their chain IDs and rule types.\n * @description\n * This function queries the wallet for the permission types it supports.\n * The result is keyed by permission type and includes the supported chain IDs and rule types.\n * @example\n * ```typescript\n * const supported = await erc7715GetSupportedExecutionPermissionsAction(client);\n * // Returns:\n * // {\n * // \"native-token-allowance\": {\n * // \"chainIds\": [\"0x1\", \"0x89\"],\n * // \"ruleTypes\": [\"expiry\"]\n * // },\n * // \"erc20-token-allowance\": {\n * // \"chainIds\": [\"0x1\"],\n * // \"ruleTypes\": []\n * // }\n * // }\n * ```\n */\nexport async function erc7715GetSupportedExecutionPermissionsAction(\n client: MetaMaskExtensionClient,\n): Promise<GetSupportedExecutionPermissionsResult> {\n const result = await client.request(\n {\n method: 'wallet_getSupportedExecutionPermissions',\n params: [],\n },\n { retryCount: 0 },\n );\n\n if (!result) {\n throw new Error('Failed to get supported execution permissions');\n }\n\n return result;\n}\n","import type {\n Erc20TokenPeriodicPermission,\n Erc20TokenStreamPermission,\n Erc20TokenRevocationPermission,\n NativeTokenPeriodicPermission,\n NativeTokenStreamPermission,\n PermissionRequest,\n PermissionResponse,\n PermissionTypes,\n Rule,\n Hex,\n} from '@metamask/7715-permission-types';\nimport { toHex } from 'viem';\nimport type { Address } from 'viem';\n\nimport { isDefined, toHexOrThrow } from '../utils';\nimport type { MetaMaskExtensionClient } from './erc7715Types';\n\nexport type {\n GetGrantedExecutionPermissionsResult,\n GetSupportedExecutionPermissionsResult,\n MetaMaskExtensionClient,\n MetaMaskExtensionSchema,\n SupportedPermissionInfo,\n} from './erc7715Types';\n\ntype PermissionParameter = {\n type: string;\n data: Record<string, unknown>;\n};\n\n/**\n * Represents a native token stream permission.\n * This allows for continuous token streaming with defined parameters.\n */\nexport type NativeTokenStreamPermissionParameter = PermissionParameter & {\n type: 'native-token-stream';\n data: {\n amountPerSecond: bigint;\n initialAmount?: bigint;\n maxAmount?: bigint;\n startTime?: number;\n justification?: string;\n };\n};\n\n/**\n * Represents an ERC-20 token stream permission.\n * This allows for continuous ERC-20 token streaming with defined parameters.\n */\nexport type Erc20TokenStreamPermissionParameter = PermissionParameter & {\n type: 'erc20-token-stream';\n data: {\n tokenAddress: Address;\n amountPerSecond: bigint;\n initialAmount?: bigint;\n maxAmount?: bigint;\n startTime?: number;\n justification?: string;\n };\n};\n\n/**\n * Represents a native token periodic permission.\n * This allows for periodic native token transfers with defined parameters.\n */\nexport type NativeTokenPeriodicPermissionParameter = PermissionParameter & {\n type: 'native-token-periodic';\n data: {\n periodAmount: bigint;\n periodDuration: number;\n startTime?: number;\n justification?: string;\n };\n};\n\n/**\n * Represents an ERC-20 token periodic permission.\n * This allows for periodic ERC-20 token transfers with defined parameters.\n */\nexport type Erc20TokenPeriodicPermissionParameter = PermissionParameter & {\n type: 'erc20-token-periodic';\n data: {\n tokenAddress: Address;\n periodAmount: bigint;\n periodDuration: number;\n startTime?: number;\n justification?: string;\n };\n};\n\n/**\n * Represents an ERC-20 token revocation permission.\n * This allows for revoking an ERC-20 token allowance.\n */\nexport type Erc20TokenRevocationPermissionParameter = PermissionParameter & {\n type: 'erc20-token-revocation';\n data: {\n justification?: string;\n };\n};\n\nexport type SupportedPermissionParams =\n | NativeTokenStreamPermissionParameter\n | Erc20TokenStreamPermissionParameter\n | NativeTokenPeriodicPermissionParameter\n | Erc20TokenPeriodicPermissionParameter\n | Erc20TokenRevocationPermissionParameter;\n\n/**\n * Represents a single permission request.\n */\nexport type PermissionRequestParameter = {\n chainId: number;\n // The permission to grant to the user.\n permission: SupportedPermissionParams;\n // Whether the caller allows the permission to be adjusted.\n isAdjustmentAllowed: boolean;\n // Account to assign the permission to.\n to: Hex;\n // address from which the permission should be granted.\n from?: Address | undefined | null;\n // Timestamp (in seconds) that specifies the time by which this permission MUST expire.\n expiry?: number | undefined | null;\n};\n\n/**\n * Parameters for the RequestExecutionPermissions action.\n *\n * @template Signer - The type of the signer, either an Address or Account.\n */\nexport type RequestExecutionPermissionsParameters =\n PermissionRequestParameter[];\n\n/**\n * Return type for the request execution permissions action.\n */\nexport type RequestExecutionPermissionsReturnType =\n PermissionResponse<PermissionTypes>[];\n\n/**\n * Grants permissions according to EIP-7715 specification.\n *\n * @template Signer - The type of the signer, either an Address or Account.\n * @param client - The client to use for the request.\n * @param parameters - The permissions requests to grant.\n * @returns A promise that resolves to the permission responses.\n * @description\n * This function formats the permissions requests and invokes the wallet method to grant permissions.\n * It will throw an error if the permissions could not be granted.\n */\nexport async function erc7715RequestExecutionPermissionsAction(\n client: MetaMaskExtensionClient,\n parameters: RequestExecutionPermissionsParameters,\n): Promise<RequestExecutionPermissionsReturnType> {\n const formattedPermissionRequest = parameters.map(formatPermissionsRequest);\n\n const result = await client.request(\n {\n method: 'wallet_requestExecutionPermissions',\n params: formattedPermissionRequest,\n },\n { retryCount: 0 },\n );\n\n if (!result) {\n throw new Error('Failed to grant permissions');\n }\n\n return result;\n}\n\n/**\n * Formats a permissions request for submission to the wallet.\n *\n * @param parameters - The permissions request to format.\n * @returns The formatted permissions request.\n * @internal\n */\nfunction formatPermissionsRequest(\n parameters: PermissionRequestParameter,\n): PermissionRequest<PermissionTypes> {\n const { chainId, from, expiry, isAdjustmentAllowed } = parameters;\n\n const permissionFormatter = getPermissionFormatter(\n parameters.permission.type,\n );\n\n const rules: Rule[] = isDefined(expiry)\n ? [\n {\n type: 'expiry',\n data: {\n timestamp: expiry,\n },\n },\n ]\n : [];\n\n const optionalFields = {\n ...(from ? { from } : {}),\n };\n\n return {\n ...optionalFields,\n chainId: toHex(chainId),\n permission: permissionFormatter({\n permission: parameters.permission,\n isAdjustmentAllowed,\n }),\n to: parameters.to,\n rules,\n };\n}\n\ntype PermissionFormatter = (params: {\n permission: PermissionParameter;\n isAdjustmentAllowed: boolean;\n}) => PermissionTypes;\n\n/**\n * Gets the appropriate formatter function for a specific permission type.\n *\n * @param permissionType - The type of permission to format.\n * @returns A formatter function for the specified permission type.\n */\nfunction getPermissionFormatter(permissionType: string): PermissionFormatter {\n switch (permissionType) {\n case 'native-token-stream':\n return ({ permission, isAdjustmentAllowed }) =>\n formatNativeTokenStreamPermission({\n permission: permission as NativeTokenStreamPermissionParameter,\n isAdjustmentAllowed,\n });\n case 'erc20-token-stream':\n return ({ permission, isAdjustmentAllowed }) =>\n formatErc20TokenStreamPermission({\n permission: permission as Erc20TokenStreamPermissionParameter,\n isAdjustmentAllowed,\n });\n\n case 'native-token-periodic':\n return ({ permission, isAdjustmentAllowed }) =>\n formatNativeTokenPeriodicPermission({\n permission: permission as NativeTokenPeriodicPermissionParameter,\n isAdjustmentAllowed,\n });\n case 'erc20-token-periodic':\n return ({ permission, isAdjustmentAllowed }) =>\n formatErc20TokenPeriodicPermission({\n permission: permission as Erc20TokenPeriodicPermissionParameter,\n isAdjustmentAllowed,\n });\n case 'erc20-token-revocation':\n return ({ permission, isAdjustmentAllowed }) =>\n formatErc20TokenRevocationPermission({\n permission: permission as Erc20TokenRevocationPermissionParameter,\n isAdjustmentAllowed,\n });\n default:\n throw new Error(`Unsupported permission type: ${permissionType}`);\n }\n}\n\n/**\n * Formats a native token stream permission for the wallet.\n *\n * @param permission - The native token stream permission to format.\n * @param permission.permission - The native token stream permission to format.\n * @param permission.isAdjustmentAllowed - Whether the permission is allowed to be adjusted.\n * @returns The formatted permission object.\n */\nfunction formatNativeTokenStreamPermission({\n permission,\n isAdjustmentAllowed,\n}: {\n permission: NativeTokenStreamPermissionParameter;\n isAdjustmentAllowed: boolean;\n}): NativeTokenStreamPermission {\n const {\n data: {\n initialAmount,\n justification,\n maxAmount,\n startTime,\n amountPerSecond,\n },\n } = permission;\n\n const optionalFields = {\n ...(isDefined(initialAmount) && {\n initialAmount: toHexOrThrow(initialAmount, 'initialAmount'),\n }),\n ...(isDefined(maxAmount) && {\n maxAmount: toHexOrThrow(maxAmount, 'maxAmount'),\n }),\n ...(isDefined(startTime) && {\n startTime: Number(startTime),\n }),\n ...(justification ? { justification } : {}),\n };\n\n return {\n type: 'native-token-stream',\n data: {\n amountPerSecond: toHexOrThrow(amountPerSecond, 'amountPerSecond'),\n ...optionalFields,\n },\n isAdjustmentAllowed,\n };\n}\n\n/**\n * Formats an ERC-20 token stream permission parameter into the required\n * Erc20TokenStreamPermission object, converting numeric values to hex strings\n * and including only specified optional fields.\n *\n * @param params - The parameters for formatting the ERC-20 token stream permission.\n * @param params.permission - The ERC-20 token stream permission parameter to format.\n * @param params.isAdjustmentAllowed - Whether adjustment of the stream is allowed.\n * @returns The formatted Erc20TokenStreamPermission object.\n */\nfunction formatErc20TokenStreamPermission({\n permission,\n isAdjustmentAllowed,\n}: {\n permission: Erc20TokenStreamPermissionParameter;\n isAdjustmentAllowed: boolean;\n}): Erc20TokenStreamPermission {\n const {\n data: {\n tokenAddress,\n amountPerSecond,\n initialAmount,\n startTime,\n maxAmount,\n justification,\n },\n } = permission;\n\n const optionalFields = {\n ...(isDefined(initialAmount) && {\n initialAmount: toHexOrThrow(initialAmount, 'initialAmount'),\n }),\n ...(isDefined(maxAmount) && {\n maxAmount: toHexOrThrow(maxAmount, 'maxAmount'),\n }),\n ...(isDefined(startTime) && {\n startTime: Number(startTime),\n }),\n ...(justification ? { justification } : {}),\n };\n\n return {\n type: 'erc20-token-stream',\n data: {\n tokenAddress: toHexOrThrow(tokenAddress, 'tokenAddress'),\n amountPerSecond: toHexOrThrow(amountPerSecond, 'amountPerSecond'),\n ...optionalFields,\n },\n isAdjustmentAllowed,\n };\n}\n\n/**\n * Formats a native token periodic permission for submission to the wallet.\n *\n * @param params - The parameters for formatting the native token periodic permission.\n * @param params.permission - The native token periodic permission parameter to format.\n * @param params.isAdjustmentAllowed - Whether the permission is allowed to be adjusted.\n * @returns The formatted NativeTokenPeriodicPermission object.\n */\nfunction formatNativeTokenPeriodicPermission({\n permission,\n isAdjustmentAllowed,\n}: {\n permission: NativeTokenPeriodicPermissionParameter;\n isAdjustmentAllowed: boolean;\n}): NativeTokenPeriodicPermission {\n const {\n data: { periodAmount, periodDuration, startTime, justification },\n } = permission;\n\n const optionalFields = {\n ...(isDefined(startTime) && {\n startTime: Number(startTime),\n }),\n ...(justification ? { justification } : {}),\n };\n\n return {\n type: 'native-token-periodic',\n data: {\n periodAmount: toHexOrThrow(periodAmount, 'periodAmount'),\n periodDuration: Number(periodDuration),\n ...optionalFields,\n },\n isAdjustmentAllowed,\n };\n}\n\n/**\n * Formats an ERC20 token periodic permission for submission to the wallet.\n *\n * @param params - The parameters for formatting the ERC20 token periodic permission.\n * @param params.permission - The ERC20 token periodic permission parameter to format.\n * @param params.isAdjustmentAllowed - Whether the permission is allowed to be adjusted.\n * @returns The formatted Erc20TokenPeriodicPermission object.\n */\nfunction formatErc20TokenPeriodicPermission({\n permission,\n isAdjustmentAllowed,\n}: {\n permission: Erc20TokenPeriodicPermissionParameter;\n isAdjustmentAllowed: boolean;\n}): Erc20TokenPeriodicPermission {\n const {\n data: {\n tokenAddress,\n periodAmount,\n periodDuration,\n startTime,\n justification,\n },\n } = permission;\n\n const optionalFields = {\n ...(isDefined(startTime) && {\n startTime: Number(startTime),\n }),\n ...(justification ? { justification } : {}),\n };\n\n return {\n type: 'erc20-token-periodic',\n data: {\n tokenAddress: toHexOrThrow(tokenAddress, 'tokenAddress'),\n periodAmount: toHexOrThrow(periodAmount, 'periodAmount'),\n periodDuration: Number(periodDuration),\n ...optionalFields,\n },\n isAdjustmentAllowed,\n };\n}\n\n/**\n * Formats an ERC-20 token revocation permission for submission to the wallet.\n *\n * @param params - The parameters for formatting the ERC-20 token revocation permission.\n * @param params.permission - The ERC-20 token revocation permission parameter to format.\n * @param params.isAdjustmentAllowed - Whether the permission is allowed to be adjusted.\n * @returns The formatted Erc20TokenRevocationPermission object.\n */\nfunction formatErc20TokenRevocationPermission({\n permission,\n isAdjustmentAllowed,\n}: {\n permission: Erc20TokenRevocationPermissionParameter;\n isAdjustmentAllowed: boolean;\n}): Erc20TokenRevocationPermission {\n const {\n data: { justification },\n } = permission;\n\n const data = {\n ...(justification ? { justification } : {}),\n };\n return {\n type: 'erc20-token-revocation',\n data,\n isAdjustmentAllowed,\n };\n}\n","import type { Address, Hex, Client } from 'viem';\n\nimport { getDelegationHashOffchain } from '../delegation';\nimport * as ERC20PeriodTransferEnforcer from '../DelegationFramework/ERC20PeriodTransferEnforcer';\nimport * as ERC20StreamingEnforcer from '../DelegationFramework/ERC20StreamingEnforcer';\nimport * as MultiTokenPeriodEnforcer from '../DelegationFramework/MultiTokenPeriodEnforcer';\nimport * as NativeTokenPeriodTransferEnforcer from '../DelegationFramework/NativeTokenPeriodTransferEnforcer';\nimport * as NativeTokenStreamingEnforcer from '../DelegationFramework/NativeTokenStreamingEnforcer';\nimport type { SmartAccountsEnvironment, Delegation } from '../types';\n\n/**\n * Parameters for all caveat enforcer actions.\n */\nexport type CaveatEnforcerParams = {\n delegation: Delegation;\n};\n\n/**\n * Return type for period-based transfer enforcers\n */\nexport type PeriodTransferResult = {\n availableAmount: bigint;\n isNewPeriod: boolean;\n currentPeriod: bigint;\n};\n\n/**\n * Return type for streaming enforcers\n */\nexport type StreamingResult = {\n availableAmount: bigint;\n};\n\n/**\n * Finds a caveat that matches the specified enforcer address.\n *\n * @param config - The configuration object.\n * @param config.delegation - The delegation to search.\n * @param config.enforcerAddress - The enforcer address to match.\n * @param config.enforcerName - The name of the enforcer.\n * @returns The matching caveat.\n * @throws Error if no matching caveat is found.\n * @throws Error if multiple matching caveats are found.\n */\nfunction findMatchingCaveat({\n delegation,\n enforcerAddress,\n enforcerName,\n}: {\n delegation: Delegation;\n enforcerAddress: Address;\n enforcerName: keyof SmartAccountsEnvironment['caveatEnforcers'];\n}): { terms: Hex; args: Hex } {\n const matchingCaveats = delegation.caveats.filter(\n (caveat) => caveat.enforcer.toLowerCase() === enforcerAddress.toLowerCase(),\n );\n\n if (matchingCaveats.length === 0) {\n throw new Error(`No caveat found with enforcer matching ${enforcerName}`);\n }\n\n if (matchingCaveats.length > 1) {\n throw new Error(\n `Multiple caveats found with enforcer matching ${enforcerName}`,\n );\n }\n\n const [{ terms, args }] = matchingCaveats as unknown as [\n { terms: Hex; args: Hex },\n ];\n\n return {\n terms,\n args,\n };\n}\n\n/**\n * Gets the delegation manager address from environment.\n *\n * @param environment - The SmartAccountsEnvironment.\n * @returns The delegation manager address.\n */\nfunction getDelegationManager(environment: SmartAccountsEnvironment): Address {\n if (!environment.DelegationManager) {\n throw new Error('Delegation manager address not found');\n }\n\n return environment.DelegationManager;\n}\n\n/**\n * Gets the enforcer address from environment.\n *\n * @param config - The configuration object.\n * @param config.enforcerName - The name of the enforcer.\n * @param config.environment - The SmartAccountsEnvironment.\n * @returns The enforcer address.\n */\nfunction getEnforcerAddress({\n enforcerName,\n environment,\n}: {\n enforcerName: keyof SmartAccountsEnvironment['caveatEnforcers'];\n environment: SmartAccountsEnvironment;\n}): Address {\n const enforcerAddress = environment.caveatEnforcers[enforcerName];\n if (!enforcerAddress) {\n throw new Error(`${enforcerName} not found in environment`);\n }\n\n return enforcerAddress;\n}\n\n/**\n * Get available amount for ERC20 period transfer enforcer.\n *\n * @param client - The viem client.\n * @param environment - The SmartAccountsEnvironment.\n * @param params - The parameters for the ERC20 period transfer enforcer.\n * @returns Promise resolving to the period transfer result.\n */\nexport async function getErc20PeriodTransferEnforcerAvailableAmount(\n client: Client,\n environment: SmartAccountsEnvironment,\n params: CaveatEnforcerParams,\n): Promise<PeriodTransferResult> {\n const enforcerName = 'ERC20PeriodTransferEnforcer';\n\n const delegationManager = getDelegationManager(environment);\n const enforcerAddress = getEnforcerAddress({\n enforcerName,\n environment,\n });\n\n const delegationHash = getDelegationHashOffchain(params.delegation);\n const { terms } = findMatchingCaveat({\n delegation: params.delegation,\n enforcerAddress,\n enforcerName,\n });\n\n return ERC20PeriodTransferEnforcer.read.getAvailableAmount({\n client,\n contractAddress: enforcerAddress,\n delegationHash,\n delegationManager,\n terms,\n });\n}\n\n/**\n * Get available amount for ERC20 streaming enforcer.\n *\n * @param client - The viem client.\n * @param environment - The SmartAccountsEnvironment.\n * @param params - The parameters for the ERC20 streaming enforcer.\n * @returns Promise resolving to the streaming result.\n */\nexport async function getErc20StreamingEnforcerAvailableAmount(\n client: Client,\n environment: SmartAccountsEnvironment,\n params: CaveatEnforcerParams,\n): Promise<StreamingResult> {\n const enforcerName = 'ERC20StreamingEnforcer';\n const delegationManager = getDelegationManager(environment);\n const enforcerAddress = getEnforcerAddress({\n enforcerName,\n environment,\n });\n\n const delegationHash = getDelegationHashOffchain(params.delegation);\n const { terms } = findMatchingCaveat({\n delegation: params.delegation,\n enforcerAddress,\n enforcerName,\n });\n\n return ERC20StreamingEnforcer.read.getAvailableAmount({\n client,\n contractAddress: enforcerAddress,\n delegationManager,\n delegationHash,\n terms,\n });\n}\n\n/**\n * Get available amount for multi-token period enforcer.\n *\n * @param client - The viem client.\n * @param environment - The SmartAccountsEnvironment.\n * @param params - The parameters for the multi-token period enforcer.\n * @returns Promise resolving to the period transfer result.\n */\nexport async function getMultiTokenPeriodEnforcerAvailableAmount(\n client: Client,\n environment: SmartAccountsEnvironment,\n params: CaveatEnforcerParams,\n): Promise<PeriodTransferResult> {\n const enforcerName = 'MultiTokenPeriodEnforcer';\n const delegationManager = getDelegationManager(environment);\n const enforcerAddress = getEnforcerAddress({\n enforcerName,\n environment,\n });\n\n const delegationHash = getDelegationHashOffchain(params.delegation);\n const { terms, args } = findMatchingCaveat({\n delegation: params.delegation,\n enforcerAddress,\n enforcerName,\n });\n\n return MultiTokenPeriodEnforcer.read.getAvailableAmount({\n client,\n contractAddress: enforcerAddress,\n delegationHash,\n delegationManager,\n terms,\n args,\n });\n}\n\n/**\n * Get available amount for native token period transfer enforcer.\n *\n * @param client - The viem client.\n * @param environment - The SmartAccountsEnvironment.\n * @param params - The parameters for the native token period transfer enforcer.\n * @returns Promise resolving to the period transfer result.\n */\nexport async function getNativeTokenPeriodTransferEnforcerAvailableAmount(\n client: Client,\n environment: SmartAccountsEnvironment,\n params: CaveatEnforcerParams,\n): Promise<PeriodTransferResult> {\n const enforcerName = 'NativeTokenPeriodTransferEnforcer';\n const delegationManager = getDelegationManager(environment);\n const enforcerAddress = getEnforcerAddress({\n enforcerName,\n environment,\n });\n\n const delegationHash = getDelegationHashOffchain(params.delegation);\n const { terms } = findMatchingCaveat({\n delegation: params.delegation,\n enforcerAddress,\n enforcerName,\n });\n\n return NativeTokenPeriodTransferEnforcer.read.getAvailableAmount({\n client,\n contractAddress: enforcerAddress,\n delegationHash,\n delegationManager,\n terms,\n });\n}\n\n/**\n * Get available amount for native token streaming enforcer.\n *\n * @param client - The viem client.\n * @param environment - The SmartAccountsEnvironment.\n * @param params - The parameters for the native token streaming enforcer.\n * @returns Promise resolving to the streaming result.\n */\nexport async function getNativeTokenStreamingEnforcerAvailableAmount(\n client: Client,\n environment: SmartAccountsEnvironment,\n params: CaveatEnforcerParams,\n): Promise<StreamingResult> {\n const enforcerName = 'NativeTokenStreamingEnforcer';\n const delegationManager = getDelegationManager(environment);\n const enforcerAddress = getEnforcerAddress({\n enforcerName,\n environment,\n });\n\n const delegationHash = getDelegationHashOffchain(params.delegation);\n const { terms } = findMatchingCaveat({\n delegation: params.delegation,\n enforcerAddress,\n enforcerName,\n });\n\n return NativeTokenStreamingEnforcer.read.getAvailableAmount({\n client,\n contractAddress: enforcerAddress,\n delegationManager,\n delegationHash,\n terms,\n });\n}\n\n/**\n * Caveat enforcer actions for extending viem clients.\n *\n * @param params - The parameters object.\n * @param params.environment - The SmartAccountsEnvironment.\n * @returns A function that takes a client and returns the client extension with caveat enforcer actions.\n */\nexport const caveatEnforcerActions =\n ({ environment }: { environment: SmartAccountsEnvironment }) =>\n (client: Client) => ({\n /**\n * Get available amount for ERC20 period transfer enforcer.\n *\n * @param params - The parameters for the ERC20 period transfer enforcer.\n * @returns Promise resolving to the period transfer result.\n */\n getErc20PeriodTransferEnforcerAvailableAmount: async (\n params: CaveatEnforcerParams,\n ): Promise<PeriodTransferResult> => {\n return getErc20PeriodTransferEnforcerAvailableAmount(\n client,\n environment,\n params,\n );\n },\n\n /**\n * Get available amount for ERC20 streaming enforcer.\n *\n * @param params - The parameters for the ERC20 streaming enforcer.\n * @returns Promise resolving to the streaming result.\n */\n getErc20StreamingEnforcerAvailableAmount: async (\n params: CaveatEnforcerParams,\n ): Promise<StreamingResult> => {\n return getErc20StreamingEnforcerAvailableAmount(\n client,\n environment,\n params,\n );\n },\n\n /**\n * Get available amount for multi-token period enforcer.\n *\n * @param params - The parameters for the multi-token period enforcer.\n * @returns Promise resolving to the period transfer result.\n */\n getMultiTokenPeriodEnforcerAvailableAmount: async (\n params: CaveatEnforcerParams,\n ): Promise<PeriodTransferResult> => {\n return getMultiTokenPeriodEnforcerAvailableAmount(\n client,\n environment,\n params,\n );\n },\n\n /**\n * Get available amount for native token period transfer enforcer.\n *\n * @param params - The parameters for the native token period transfer enforcer.\n * @returns Promise resolving to the period transfer result.\n */\n getNativeTokenPeriodTransferEnforcerAvailableAmount: async (\n params: CaveatEnforcerParams,\n ): Promise<PeriodTransferResult> => {\n return getNativeTokenPeriodTransferEnforcerAvailableAmount(\n client,\n environment,\n params,\n );\n },\n\n /**\n * Get available amount for native token streaming enforcer.\n *\n * @param params - The parameters for the native token streaming enforcer.\n * @returns Promise resolving to the streaming result.\n */\n getNativeTokenStreamingEnforcerAvailableAmount: async (\n params: CaveatEnforcerParams,\n ): Promise<StreamingResult> => {\n return getNativeTokenStreamingEnforcerAvailableAmount(\n client,\n environment,\n params,\n );\n },\n });\n","import type { Client, Address, Hex } from 'viem';\nimport { isAddressEqual } from 'viem';\nimport { getCode } from 'viem/actions';\n\nimport type { SmartAccountsEnvironment } from '../types';\n\n// EIP-7702 delegation prefix (0xef0100)\nconst DELEGATION_PREFIX = '0xef0100' as const;\n\n/**\n * Parameters for checking if an account is delegated to the EIP-7702 implementation.\n */\nexport type IsValid7702ImplementationParameters = {\n /** The client to use for the query. */\n client: Client;\n /** The address to check for proper delegation. */\n accountAddress: Address;\n /** The SmartAccountsEnvironment containing contract addresses. */\n environment: SmartAccountsEnvironment;\n};\n\n/**\n * Extracts the delegated contract address from EIP-7702 delegation code.\n *\n * @param code - The code returned from getCode for a delegated account.\n * @returns The delegated contract address or null if not a valid delegation.\n */\nfunction extractDelegatedAddress(code: Hex | undefined): Address | null {\n if (code?.length !== 48) {\n // 0x (2 chars) + ef0100 (6 chars) + address (40 chars) = 48 chars\n return null;\n }\n\n if (!code.toLowerCase().startsWith(DELEGATION_PREFIX.toLowerCase())) {\n return null;\n }\n\n // Extract the 20-byte address after the delegation prefix\n const addressHex = code.slice(8); // Remove '0xef0100' prefix (8 chars)\n return `0x${addressHex}`;\n}\n\n/**\n * Checks if an account is properly delegated to the EIP-7702 implementation.\n *\n * This function validates EIP-7702 delegations by checking if the EOA has a 7702\n * contract assigned to it and comparing the delegated address against the 7702\n * implementation found in the environment.\n *\n * @param params - The parameters for checking the delegation.\n * @param params.client - The client to use for the query.\n * @param params.accountAddress - The address to check for proper delegation.\n * @param params.environment - The SmartAccountsEnvironment containing contract addresses.\n * @returns A promise that resolves to true if the account is properly delegated to the 7702 implementation, false otherwise.\n * @example\n * ```typescript\n * const isValid = await isValid7702Implementation({\n * client: publicClient,\n * accountAddress: '0x...',\n * environment: smartAccountEnvironment,\n * });\n *\n * if (isValid) {\n * console.log('Account is properly delegated to EIP-7702 implementation');\n * } else {\n * console.log('Account is not properly delegated');\n * }\n * ```\n */\nexport async function isValid7702Implementation({\n client,\n accountAddress,\n environment,\n}: IsValid7702ImplementationParameters): Promise<boolean> {\n try {\n // Get the code at the account address\n const code = await getCode(client, {\n address: accountAddress,\n });\n\n // Extract the delegated contract address from the EIP-7702 delegation code\n const delegatedAddress = extractDelegatedAddress(code);\n\n // If no valid delegation found, return false\n if (!delegatedAddress) {\n return false;\n }\n\n // Compare the delegated address with the 7702 implementation in the environment\n const expectedImplementation =\n environment.implementations.EIP7702StatelessDeleGatorImpl;\n if (!expectedImplementation) {\n return false;\n }\n\n return isAddressEqual(delegatedAddress, expectedImplementation);\n } catch {\n // If the call fails (e.g., no code at address, network error),\n // then it's not properly delegated to our implementation\n return false;\n }\n}\n","import type {\n Account,\n Address,\n Chain,\n Client,\n Hex,\n Transport,\n WalletClient,\n} from 'viem';\nimport { BaseError } from 'viem';\nimport { parseAccount } from 'viem/accounts';\n\nimport { prepareSignDelegationTypedData } from '../delegation';\nimport type { Delegation } from '../types';\n\nexport type SignDelegationParameters = {\n /** Account to sign with */\n account?: Account | Address;\n /** The delegation to sign */\n delegation: Omit<Delegation, 'signature'>;\n /** The address of the delegation manager contract */\n delegationManager: Address;\n /** The chain ID for the signature */\n chainId: number;\n /** The name of the contract */\n name?: string;\n /** The version of the contract */\n version?: string;\n /** Whether to allow insecure unrestricted delegation */\n allowInsecureUnrestrictedDelegation?: boolean;\n};\n\nexport type SignDelegationReturnType = Hex;\n\n/**\n * Signs a delegation using a wallet client.\n *\n * @param client - The wallet client to use for signing.\n * @param parameters - The parameters for signing the delegation.\n * @returns The signature of the delegation.\n * @example\n * ```ts\n * const signature = await signDelegation(walletClient, {\n * delegation: {\n * delegate: '0x...',\n * delegator: '0x...',\n * authority: '0x...',\n * caveats: [],\n * salt: '0x'\n * },\n * delegationManager: '0x...',\n * chainId: 1\n * });\n * ```\n */\nexport async function signDelegation<\n TChain extends Chain | undefined,\n TAccount extends Account | undefined,\n>(\n client: Client<Transport, TChain, TAccount> & {\n signTypedData: WalletClient['signTypedData'];\n },\n parameters: SignDelegationParameters,\n): Promise<SignDelegationReturnType> {\n const {\n account: accountParam = client.account,\n delegation,\n delegationManager,\n chainId,\n name = 'DelegationManager',\n version = '1',\n allowInsecureUnrestrictedDelegation = false,\n } = parameters;\n\n if (!accountParam) {\n throw new BaseError('Account not found. Please provide an account.');\n }\n\n const account = parseAccount(accountParam);\n\n const typedData = prepareSignDelegationTypedData({\n delegation,\n delegationManager,\n chainId,\n name,\n version,\n allowInsecureUnrestrictedDelegation,\n });\n\n return client.signTypedData({\n account,\n ...typedData,\n });\n}\n\n/**\n * Creates a sign delegation action that can be used to extend a wallet client.\n *\n * @returns A function that can be used with wallet client extend method.\n * @example\n * ```ts\n * const walletClient = createWalletClient({\n * chain: mainnet,\n * transport: http()\n * }).extend(signDelegationActions());\n * ```\n */\nexport function signDelegationActions() {\n return <\n TChain extends Chain | undefined,\n TAccount extends Account | undefined,\n >(\n client: Client<Transport, TChain, TAccount> & {\n signTypedData: WalletClient['signTypedData'];\n },\n ) => ({\n signDelegation: async (\n parameters: Omit<SignDelegationParameters, 'chainId'> & {\n chainId?: number;\n },\n ) =>\n signDelegation(client, {\n chainId:\n parameters.chainId ??\n (() => {\n if (!client.chain?.id) {\n throw new BaseError(\n 'Chain ID is required. Either provide it in parameters or configure the client with a chain.',\n );\n }\n return client.chain.id;\n })(),\n ...parameters,\n }),\n });\n}\n","import type {\n Account,\n Address,\n Chain,\n Client,\n Hex,\n Transport,\n WalletClient,\n} from 'viem';\nimport { BaseError } from 'viem';\nimport { parseAccount } from 'viem/accounts';\n\nimport { prepareSignUserOperationTypedData } from '../userOp';\nimport type { UserOperationV07 } from '../userOp';\n\nexport type SignUserOperationParameters = {\n /** Account to sign with */\n account?: Account | Address;\n /** The user operation to sign */\n userOperation: Omit<UserOperationV07, 'signature'>;\n /** The entry point contract address */\n entryPoint: { address: Address };\n /** The chain ID that the entry point is deployed on */\n chainId: number;\n /** The address of the smart account */\n address: Address;\n /** The name of the domain of the implementation contract */\n name: 'HybridDeleGator' | 'MultiSigDeleGator';\n /** The version of the domain of the implementation contract */\n version?: string;\n};\n\nexport type SignUserOperationReturnType = Hex;\n\n/**\n * Signs a user operation using a wallet client.\n *\n * @param client - The wallet client to use for signing.\n * @param parameters - The parameters for signing the user operation.\n * @returns The signature of the user operation.\n * @example\n * ```ts\n * const signature = await signUserOperation(walletClient, {\n * userOperation: {\n * sender: '0x...',\n * nonce: 0n,\n * callData: '0x',\n * callGasLimit: 1000000n,\n * verificationGasLimit: 1000000n,\n * preVerificationGas: 21000n,\n * maxFeePerGas: 1000000000n,\n * maxPriorityFeePerGas: 1000000000n\n * },\n * entryPoint: { address: '0x...' },\n * chainId: 1,\n * address: '0x...',\n * name: 'HybridDeleGator'\n * });\n * ```\n */\nexport async function signUserOperation<\n TChain extends Chain | undefined,\n TAccount extends Account | undefined,\n>(\n client: Client<Transport, TChain, TAccount> & {\n signTypedData: WalletClient['signTypedData'];\n },\n parameters: SignUserOperationParameters,\n): Promise<SignUserOperationReturnType> {\n const {\n account: accountParam = client.account,\n userOperation,\n entryPoint,\n chainId,\n name,\n address,\n version = '1',\n } = parameters;\n\n if (!accountParam) {\n throw new BaseError('Account not found. Please provide an account.');\n }\n\n const account = parseAccount(accountParam);\n\n const typedData = prepareSignUserOperationTypedData({\n userOperation,\n entryPoint,\n chainId,\n name,\n address,\n version,\n });\n\n return client.signTypedData({\n account,\n ...typedData,\n });\n}\n\n/**\n * Creates a sign user operation action that can be used to extend a wallet client.\n *\n * @returns A function that can be used with wallet client extend method.\n * @example\n * ```ts\n * const walletClient = createWalletClient({\n * chain: mainnet,\n * transport: http()\n * }).extend(signUserOperationActions());\n * ```\n */\nexport function signUserOperationActions() {\n return <\n TChain extends Chain | undefined,\n TAccount extends Account | undefined,\n >(\n client: Client<Transport, TChain, TAccount> & {\n signTypedData: WalletClient['signTypedData'];\n },\n ) => ({\n signUserOperation: async (\n parameters: Omit<SignUserOperationParameters, 'chainId'> & {\n chainId?: number;\n },\n ) =>\n signUserOperation(client, {\n chainId:\n parameters.chainId ??\n (() => {\n if (!client.chain?.id) {\n throw new BaseError(\n 'Chain ID is required. Either provide it in parameters or configure the client with a chain.',\n );\n }\n return client.chain.id;\n })(),\n ...parameters,\n }),\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,SAAS,yBAAyB;AAYlC,SAAS,QAAQ,oBAAoB,sBAAsB;AAoC3D,eAAsB,oCAIpB,QACA,MACA;AACA,MAAI,CAAC,KAAK,IAAI;AACZ,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,aAAa;AAAA,IACjB,gBAAgB;AAAA,MACd,QAAQ,KAAK;AAAA,MACb,OAAO,KAAK;AAAA,MACZ,UAAU,KAAK;AAAA,IACjB,CAAC;AAAA,EACH;AAEA,QAAM,WAAW,mBAAmB;AAAA,IAClC,KAAK,kBAAkB;AAAA,IACvB,cAAc;AAAA,IACd,MAAM;AAAA,MACJ,CAAC,KAAK,kBAAkB;AAAA,MACxB,yFAA4B;AAAA,MAC5B,yBAAyB,CAAC,UAAU,CAAC;AAAA,IACvC;AAAA,EACF,CAAC;AAED,QAAM;AAAA,IACJ,OAAO;AAAA,IACP,oBAAoB;AAAA,IACpB,mBAAmB;AAAA,IACnB,GAAG;AAAA,EACL,IAAI;AAEJ,QAAM,OAAO,MAAM,OAAO,gBAAgB;AAAA,IACxC,GAAG;AAAA,IACH,IAAI,KAAK;AAAA,IACT,MAAM;AAAA,EACR,CAAyC;AAEzC,SAAO;AACT;AA2CA,eAAsB,sCAIpB,Q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ount","BaseError","parseAccount"]}
|
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
encode4,
|
|
6
6
|
encode5,
|
|
7
7
|
encodeProxyCreationCode
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-4A5RMDDC.mjs";
|
|
9
9
|
import {
|
|
10
10
|
createExecution,
|
|
11
11
|
encodeExecutionCalldatas
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-TPBFVDVM.mjs";
|
|
13
13
|
|
|
14
14
|
// src/constants.ts
|
|
15
15
|
var Implementation = /* @__PURE__ */ ((Implementation2) => {
|
|
@@ -77,6 +77,7 @@ var getCounterfactualAccountData = async ({
|
|
|
77
77
|
initcode = encode2({ owners, threshold });
|
|
78
78
|
break;
|
|
79
79
|
}
|
|
80
|
+
case "Stateless7702" /* Stateless7702 */:
|
|
80
81
|
default:
|
|
81
82
|
throw new Error(`Implementation type '${implementation}' not supported`);
|
|
82
83
|
}
|
|
@@ -152,7 +153,7 @@ var encodeCalls = (calls) => {
|
|
|
152
153
|
var encodeCallsForCaller = async (caller, calls) => {
|
|
153
154
|
if (calls.length === 1) {
|
|
154
155
|
const call = calls[0];
|
|
155
|
-
if (call
|
|
156
|
+
if (call?.to === caller && !isDelegatedCall(call)) {
|
|
156
157
|
return call.data ?? "0x";
|
|
157
158
|
}
|
|
158
159
|
}
|
|
@@ -271,4 +272,4 @@ export {
|
|
|
271
272
|
encodeDeleGatorSignature,
|
|
272
273
|
createDummyWebAuthnSignature
|
|
273
274
|
};
|
|
274
|
-
//# sourceMappingURL=chunk-
|
|
275
|
+
//# sourceMappingURL=chunk-AUCZDOTJ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/constants.ts","../src/counterfactualAccountData.ts","../src/encodeCalls.ts","../src/webAuthn.ts"],"sourcesContent":["/**\n * To be used in sdk methods to call Implementation specific code\n *\n */\nexport enum Implementation {\n MultiSig = 'MultiSig',\n Hybrid = 'Hybrid',\n Stateless7702 = 'Stateless7702',\n}\n\n/**\n * Represents predefined time intervals (in seconds) for transfer windows.\n * These values are commonly used to specify the duration of transfer periods,\n * such as hourly, daily, weekly, etc., where each enum member's value is the\n * number of seconds in that interval.\n *\n * Hourly - 1 hour (3600 seconds)\n *\n * Daily - 1 day (86400 seconds)\n *\n * Weekly - 1 week (604800 seconds)\n *\n * BiWeekly - 2 weeks (1209600 seconds)\n *\n * Monthly - 1 month (30 days, 2592000 seconds)\n *\n * Quarterly - 1 quarter (90 days, 7776000 seconds)\n *\n * Yearly - 1 year (365 days, 31536000 seconds)\n */\nexport enum TransferWindow {\n Hourly = 3600, // 60 * 60 (seconds)\n Daily = 86400, // 60 * 60 * 24 (seconds)\n Weekly = 604800, // 60 * 60 * 24 * 7 (seconds)\n BiWeekly = 1209600, // 60 * 60 * 24 * 14 (seconds)\n Monthly = 2592000, // 60 * 60 * 24 * 30 (seconds)\n Quarterly = 7776000, // 60 * 60 * 24 * 90 (seconds)\n Yearly = 31536000, // 60 * 60 * 24 * 365 (seconds)\n}\n","import type { Address, Hex } from 'viem';\nimport { getContractAddress, pad } from 'viem';\n\nimport { Implementation } from './constants';\nimport { initializeHybridDeleGator } from './DelegationFramework/HybridDeleGator/encode';\nimport { initializeMultiSigDeleGator } from './DelegationFramework/MultiSigDeleGator/encode';\nimport { create2Deploy as encodeCreate2Deploy } from './DelegationFramework/SimpleFactory/encode';\nimport { encodeProxyCreationCode } from './DelegationFramework/utils';\nimport type {\n SmartAccountsEnvironment,\n HybridDeleGatorDeployParams,\n MultiSigDeleGatorDeployParams,\n DeployParams,\n} from './types';\n\n/**\n * Infers counterfactual account data for a DeleGator smart account.\n *\n * @template TImplementation - The type of implementation, extending Implementation.\n * @template TDeployParams - The type of deployment parameters, defaults to DeployParams<Implementation>.\n * @param options - The options for generating counterfactual account data.\n * @param options.factory - The address of the SimpleFactory contract.\n * @param options.implementations - The DeleGator implementation contracts.\n * @param options.implementation - The implementation type to use.\n * @param options.deployParams - The deployment parameters for the specified implementation.\n * @param options.deploySalt - The salt to use for CREATE2 address computation.\n * @returns An object containing the counterfactual address and factory calldata.\n * @description This function calculates the address a DeleGator contract would have if deployed,\n * and provides the calldata needed to deploy it.\n */\nexport const getCounterfactualAccountData = async <\n TImplementation extends Implementation,\n>({\n factory,\n implementations,\n implementation,\n deployParams,\n deploySalt,\n}: {\n factory: Address;\n implementations: SmartAccountsEnvironment['implementations'];\n implementation: TImplementation;\n deployParams: DeployParams<TImplementation>;\n deploySalt: Hex;\n}): Promise<{ factoryData: Hex; address: Address }> => {\n let implementationAddress: Address;\n let initcode: Hex;\n\n switch (implementation) {\n case Implementation.Hybrid: {\n const [owner, keyIds, xValues, yValues] =\n deployParams as HybridDeleGatorDeployParams;\n\n if (!implementations.HybridDeleGatorImpl) {\n throw new Error(\n 'HybridDeleGatorImpl address not provided in environment',\n );\n }\n\n implementationAddress = implementations.HybridDeleGatorImpl;\n\n const p256Owners = keyIds.map((keyId, index) => {\n const xValue = xValues[index];\n const yValue = yValues[index];\n\n if (!xValue || !yValue) {\n throw new Error(\n `Missing X or Y value for keyId ${keyId} at index ${index}`,\n );\n }\n\n return {\n keyId,\n x: xValue,\n y: yValue,\n };\n });\n\n initcode = initializeHybridDeleGator({ eoaOwner: owner, p256Owners });\n break;\n }\n case Implementation.MultiSig: {\n const [owners, threshold] = deployParams as MultiSigDeleGatorDeployParams;\n\n if (!implementations.MultiSigDeleGatorImpl) {\n throw new Error(\n 'MultiSigDeleGatorImpl address not provided in environment',\n );\n }\n\n implementationAddress = implementations.MultiSigDeleGatorImpl;\n initcode = initializeMultiSigDeleGator({ owners, threshold });\n break;\n }\n case Implementation.Stateless7702:\n default:\n throw new Error(`Implementation type '${implementation}' not supported`);\n }\n\n const salt = pad(deploySalt, { dir: 'left', size: 32 });\n\n const proxyCreationCode = encodeProxyCreationCode({\n implementationAddress,\n initcode,\n });\n\n const address = getContractAddress({\n bytecode: proxyCreationCode,\n from: factory,\n opcode: 'CREATE2',\n salt,\n });\n\n const factoryData = encodeCreate2Deploy(proxyCreationCode, salt);\n\n return {\n factoryData,\n address,\n };\n};\n","import { DelegationManager } from '@metamask/delegation-abis';\nimport { encodeFunctionData } from 'viem';\nimport type { Address, Hex } from 'viem';\n\nimport type { DelegatedCall } from './actions/erc7710RedeemDelegationAction';\nimport {\n execute,\n executeWithMode,\n} from './DelegationFramework/DeleGatorCore/encode';\nimport {\n ExecutionMode,\n createExecution,\n encodeExecutionCalldatas,\n} from './executions';\nimport type { Call } from './types';\n\n/**\n * Checks if a call is a delegated call by checking for the presence of permissionsContext and delegationManager.\n *\n * @param call - The call to check.\n * @returns True if the call is a delegated call, false otherwise.\n */\nconst isDelegatedCall = (call: Call): call is DelegatedCall => {\n return 'permissionsContext' in call && 'delegationManager' in call;\n};\n\n/**\n * If there's a single call with permissionsContext and delegationManager,\n * processes it as a delegated call.\n *\n * @param call - The call to process.\n * @returns The execution object for the delegated call.\n * @description\n * This function creates an execution that calls redeemDelegations on the delegation manager.\n */\nconst processDelegatedCall = (call: DelegatedCall) => {\n const {\n permissionsContext,\n delegationManager,\n to: target,\n value,\n data: callData,\n } = call;\n\n const callAsExecution = createExecution({ target, value, callData });\n\n if (!permissionsContext) {\n return callAsExecution;\n }\n\n const redeemCalldata = encodeFunctionData({\n abi: DelegationManager.abi,\n functionName: 'redeemDelegations',\n args: [\n [permissionsContext],\n [ExecutionMode.SingleDefault],\n encodeExecutionCalldatas([[callAsExecution]]),\n ],\n });\n\n return createExecution({\n target: delegationManager,\n callData: redeemCalldata,\n });\n};\n\n/**\n * If there's a single call, encode the shorthand `execute` function. Otherwise, encode the `executeWithMode` function. Execution type will always be \"default\".\n *\n * @param calls - The calls to execute.\n * @returns The encoded calldata for the DeleGator to execute the calls.\n * @description\n * This function supports both single and batch execution modes.\n * For single calls, it uses the gas-efficient execute function.\n */\nexport const encodeCalls = (calls: readonly Call[]) => {\n if (calls.length === 1) {\n const call = calls[0];\n if (call && !isDelegatedCall(call)) {\n const { to: target, value, data: callData } = call;\n const execution = createExecution({ target, value, callData });\n return execute({ execution });\n }\n }\n\n const executions = calls.map((call) => {\n if (isDelegatedCall(call)) {\n return processDelegatedCall(call);\n }\n const { to: target, value, data: callData } = call;\n return createExecution({ target, value, callData });\n });\n\n const mode =\n calls.length === 1\n ? ExecutionMode.SingleDefault\n : ExecutionMode.BatchDefault;\n return executeWithMode({ mode, executions });\n};\n\n/**\n * Encodes calls for execution by a DeleGator smart contract.\n *\n * @param caller - The address of the DeleGator contract.\n * @param calls - An array of Call objects, each containing 'to', optional 'data', and optional 'value'.\n * @returns A promise that resolves to the encoded function data as a hexadecimal string.\n * @description\n * - If there's a single call directly to the delegator, it returns the call data directly.\n * - For multiple calls or calls to other addresses, it creates executions and encodes them for the DeleGator's execute function.\n * - The execution mode is set to ExecutionMode.SingleDefault for a single call, or ExecutionMode.BatchDefault for multiple calls.\n *\n * todo: This doesn't fully expose the flexibility of the DeleGator's execute function, but it's a start.\n * maybe we add a mechanism where individual calls passed to this function can be encoded batches.\n */\nexport const encodeCallsForCaller = async (\n caller: Address,\n calls: readonly Call[],\n): Promise<Hex> => {\n if (calls.length === 1) {\n const call = calls[0];\n if (call?.to === caller && !isDelegatedCall(call)) {\n // if there's a single call, and it's to the delegator, we can just return the calldata directly.\n return call.data ?? '0x';\n }\n }\n return encodeCalls(calls);\n};\n","import {\n parseAbiParameters,\n encodeAbiParameters,\n type Hex,\n encodePacked,\n keccak256,\n concat,\n hexToBytes,\n} from 'viem';\nimport { parseSignature } from 'webauthn-p256';\n\nexport const FIELD_MODULUS =\n 115792089210356248762697446949407573529996955224135760342422259061068512044369n;\nexport const MALLEABILITY_THRESHOLD = FIELD_MODULUS / 2n;\n\nexport const SIGNATURE_ABI_PARAMS = parseAbiParameters(\n 'bytes32, uint256, uint256, bytes, bool, string, string, uint256',\n);\n\n/**\n * This function is used to convert the client data returned from the\n * credentials API into a format that can be consumed by the DeleGator\n * contracts. We need the flattend JSON strings before and after the\n * userOpHash/challenge. This function provides those two client data string\n * slices.\n *\n * @param clientDataJson - The client data JSON string.\n * @returns Returns [clientDataJSONPrefix and clientDataJSONSuffix]\n * ClientDataJSONPrefix contains the client data till the challengeHash\n * ClientDataJSONSuffix contains the client data after the challengeHash.\n */\nexport const splitOnChallenge = (\n clientDataJson: string,\n): [clientDataJSONPrefix: string, clientDataJSONSuffix: string] => {\n /*\n CientData looks like this:\n {\n \"type\": \"webauthn.create\" | \"webauthn.get\",\n \"challenge\": \"{userOpHash}\",\n \"origin\": \"{Domain}\",\n \"crossOrigin\": boolean\n }\n */\n try {\n const { challenge } = JSON.parse(clientDataJson);\n if (challenge === undefined) {\n throw new Error('No \"challenge\" found in the input string');\n }\n return clientDataJson.split(challenge) as [string, string];\n } catch (error) {\n throw new Error('No \"challenge\" found in the input string', {\n cause: error,\n });\n }\n};\n\n/**\n * Returns the index of '\"type\":' in the ClientData.\n *\n * @param clientDataJson - Stringified ClientDataJSON.\n * @returns The index of '\"type\":' in the ClientData.\n */\nexport const getResponseTypeLocation = (clientDataJson: string): bigint => {\n try {\n // Find the index of the `\"type\":` key in the JSON string directly\n const typeIndex = clientDataJson.indexOf('\"type\":');\n\n if (typeIndex === -1) {\n throw new Error('No \"type\" found in the input string');\n }\n // Return the index of the `\"type\":` key\n return BigInt(typeIndex);\n } catch (error) {\n // Handle any errors that occur during the search\n throw new Error('No \"type\" found in the input string', {\n cause: error,\n });\n }\n};\n\n/**\n * Encodes a signature to a hexadecimal signature that will be accepted\n * by the DeleGator contracts.\n *\n * @param keyId - The key used for the signature, represented as a hexadecimal string.\n * @param signature - The signature to convert, as Hex.\n * @param clientDataJSON - The client data used in the creation of the signature.\n * @param authenticatorData - The authenticator data used in the creation of the signature.\n * @returns The signature as a valid DeleGator signature encoded as Hexadecimal string.\n */\nexport function encodeDeleGatorSignature(\n keyId: string,\n signature: Hex,\n clientDataJSON: string,\n authenticatorData: Hex,\n): Hex {\n const keyIdHash = keccak256(encodePacked(['string'], [keyId]));\n\n const parsedSignature = parseSignature(signature);\n\n let { s } = parsedSignature;\n\n while (s > MALLEABILITY_THRESHOLD) {\n s = FIELD_MODULUS - s;\n }\n\n const { r } = parsedSignature;\n\n const [clientDataComponent1, clientDataComponent2] =\n splitOnChallenge(clientDataJSON);\n\n const { userVerified } = parseAuthenticatorFlags(authenticatorData);\n\n const responseTypeLocation = getResponseTypeLocation(clientDataJSON);\n\n const encodedSignature = encodeAbiParameters(SIGNATURE_ABI_PARAMS, [\n keyIdHash,\n r,\n s,\n authenticatorData,\n userVerified,\n clientDataComponent1,\n clientDataComponent2,\n responseTypeLocation,\n ]);\n return encodedSignature;\n}\n\nconst AUTHENTICATOR_DATA_FLAGS_OFFSET = 32;\n// We have all of the flag bits defined here for completeness, even though we only extract the userVerified flag.\nenum AuthenticatorDataFlagBitIndex {\n UserPresence = 0,\n UserVerified = 2,\n BackupEligibility = 3,\n BackupState = 4,\n AttestedCredentialData = 6,\n ExtensionData = 7,\n}\n\nexport type AuthenticatorFlags = {\n userVerified: boolean;\n};\n\n/**\n * Parses the authenticator data and returns an authenticator flags object with the `userVerified` flag.\n * See https://developer.mozilla.org/en-US/docs/Web/API/Web_Authentication_API/Authenticator_data.\n *\n * @param authenticatorData - The authenticator data to parse.\n * @returns An object representing the parsed authenticator flags.\n */\nexport function parseAuthenticatorFlags(\n authenticatorData: Hex,\n): AuthenticatorFlags {\n const authenticatorDataBuffer = hexToBytes(authenticatorData);\n const dataBufferUint8 = new Uint8Array(authenticatorDataBuffer);\n const flags = dataBufferUint8[AUTHENTICATOR_DATA_FLAGS_OFFSET];\n if (flags === undefined) {\n throw new Error('Authenticator flags not found in authenticator data');\n }\n\n // Bit 0 is the least significant bit in the flags byte, so we left shift 0b1 by the bit index\n // eslint-disable-next-line no-bitwise\n const bitMask = 0b1 << AuthenticatorDataFlagBitIndex.UserVerified;\n\n return {\n // eslint-disable-next-line no-bitwise\n userVerified: (flags & bitMask) !== 0x0,\n };\n}\n\n/**\n * Creates a dummy signature.\n * This must meet all early-failure conditions of the real signature, but does not need to be a valid signature.\n *\n * @param keyId - The key ID to use for the dummy signature.\n * @returns The encoded signature.\n */\nexport const createDummyWebAuthnSignature = (keyId: Hex) => {\n // https://developer.mozilla.org/en-US/docs/Web/API/Web_Authentication_API/Authenticator_data#data_structure\n const rpIdHash = keccak256(encodePacked(['string'], ['AuthenticatorData']));\n const flags = '0x05';\n const signCount = '0x00000000';\n const authenticatorData = concat([rpIdHash, flags, signCount]);\n\n const keyIdHash = keccak256(encodePacked(['string'], [keyId]));\n const rs =\n 57896044605178124381348723474703786764998477612067880171211129530534256022184n;\n const userVerification = true;\n const clientDataPrefix = '{\"type\":\"webauthn.get\",\"challenge\":\"';\n const clientDataSuffix = '\",\"origin\":\"passkey-domain\",\"crossOrigin\":false}';\n const responseTypeLocation = 1n;\n\n const encodedSignature = encodeAbiParameters(SIGNATURE_ABI_PARAMS, [\n keyIdHash,\n rs,\n rs,\n authenticatorData,\n userVerification,\n clientDataPrefix,\n clientDataSuffix,\n responseTypeLocation,\n ]);\n\n return encodedSignature;\n};\n"],"mappings":";;;;;;;;;;;;;;AAIO,IAAK,iBAAL,kBAAKA,oBAAL;AACL,EAAAA,gBAAA,cAAW;AACX,EAAAA,gBAAA,YAAS;AACT,EAAAA,gBAAA,mBAAgB;AAHN,SAAAA;AAAA,GAAA;AA0BL,IAAK,iBAAL,kBAAKC,oBAAL;AACL,EAAAA,gCAAA,YAAS,QAAT;AACA,EAAAA,gCAAA,WAAQ,SAAR;AACA,EAAAA,gCAAA,YAAS,UAAT;AACA,EAAAA,gCAAA,cAAW,WAAX;AACA,EAAAA,gCAAA,aAAU,UAAV;AACA,EAAAA,gCAAA,eAAY,UAAZ;AACA,EAAAA,gCAAA,YAAS,WAAT;AAPU,SAAAA;AAAA,GAAA;;;AC7BZ,SAAS,oBAAoB,WAAW;AA6BjC,IAAM,+BAA+B,OAE1C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,M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IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,SAAO;AACT;","names":["Implementation","TransferWindow","encode","encode"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__export
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-TEH426Y4.mjs";
|
|
4
4
|
|
|
5
5
|
// src/DelegationFramework/ERC20PeriodTransferEnforcer/index.ts
|
|
6
6
|
var ERC20PeriodTransferEnforcer_exports = {};
|
|
@@ -296,4 +296,4 @@ export {
|
|
|
296
296
|
read_exports5,
|
|
297
297
|
NativeTokenStreamingEnforcer_exports
|
|
298
298
|
};
|
|
299
|
-
//# sourceMappingURL=chunk-
|
|
299
|
+
//# sourceMappingURL=chunk-DPWYECSV.mjs.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
encodeExecutionCalldatas
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-TPBFVDVM.mjs";
|
|
4
4
|
import {
|
|
5
5
|
encodePermissionContexts
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-TEH426Y4.mjs";
|
|
7
7
|
|
|
8
8
|
// src/write.ts
|
|
9
9
|
import { SimpleFactory, DelegationManager } from "@metamask/delegation-abis";
|
|
@@ -333,4 +333,4 @@ export {
|
|
|
333
333
|
prepareSignUserOperationTypedData,
|
|
334
334
|
signUserOperation
|
|
335
335
|
};
|
|
336
|
-
//# sourceMappingURL=chunk-
|
|
336
|
+
//# sourceMappingURL=chunk-EHIZB5U7.mjs.map
|