@metamask/gator-permissions-controller 0.8.0 → 1.1.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 +26 -1
- package/dist/GatorPermissionsController.cjs +23 -3
- package/dist/GatorPermissionsController.cjs.map +1 -1
- package/dist/GatorPermissionsController.d.cts +1 -1
- package/dist/GatorPermissionsController.d.cts.map +1 -1
- package/dist/GatorPermissionsController.d.mts +1 -1
- package/dist/GatorPermissionsController.d.mts.map +1 -1
- package/dist/GatorPermissionsController.mjs +23 -3
- package/dist/GatorPermissionsController.mjs.map +1 -1
- package/dist/decodePermission/decodePermission.cjs +2 -2
- package/dist/decodePermission/decodePermission.cjs.map +1 -1
- package/dist/decodePermission/decodePermission.d.cts.map +1 -1
- package/dist/decodePermission/decodePermission.d.mts.map +1 -1
- package/dist/decodePermission/decodePermission.mjs +2 -2
- package/dist/decodePermission/decodePermission.mjs.map +1 -1
- package/dist/decodePermission/types.cjs.map +1 -1
- package/dist/decodePermission/types.d.cts +3 -3
- package/dist/decodePermission/types.d.cts.map +1 -1
- package/dist/decodePermission/types.d.mts +3 -3
- package/dist/decodePermission/types.d.mts.map +1 -1
- package/dist/decodePermission/types.mjs.map +1 -1
- package/dist/decodePermission/utils.cjs +2 -2
- package/dist/decodePermission/utils.cjs.map +1 -1
- package/dist/decodePermission/utils.d.cts +10 -10
- package/dist/decodePermission/utils.d.cts.map +1 -1
- package/dist/decodePermission/utils.d.mts +10 -10
- package/dist/decodePermission/utils.d.mts.map +1 -1
- package/dist/decodePermission/utils.mjs +2 -2
- package/dist/decodePermission/utils.mjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/test/mocks.cjs +20 -45
- package/dist/test/mocks.cjs.map +1 -1
- package/dist/test/mocks.d.cts +7 -7
- package/dist/test/mocks.d.cts.map +1 -1
- package/dist/test/mocks.d.mts +7 -7
- package/dist/test/mocks.d.mts.map +1 -1
- package/dist/test/mocks.mjs +20 -45
- package/dist/test/mocks.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +38 -39
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +38 -39
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +7 -7
package/dist/test/mocks.mjs
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
export const mockNativeTokenStreamStorageEntry = (chainId) => ({
|
|
2
2
|
permissionResponse: {
|
|
3
3
|
chainId,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
type: 'account',
|
|
7
|
-
data: { address: '0x4f71DA06987BfeDE90aF0b33E1e3e4ffDCEE7a63' },
|
|
8
|
-
},
|
|
4
|
+
from: '0xB68c70159E9892DdF5659ec42ff9BD2bbC23e778',
|
|
5
|
+
to: '0x4f71DA06987BfeDE90aF0b33E1e3e4ffDCEE7a63',
|
|
9
6
|
permission: {
|
|
10
7
|
type: 'native-token-stream',
|
|
11
8
|
isAdjustmentAllowed: true,
|
|
@@ -18,26 +15,21 @@ export const mockNativeTokenStreamStorageEntry = (chainId) => ({
|
|
|
18
15
|
},
|
|
19
16
|
},
|
|
20
17
|
context: '0x00000000',
|
|
21
|
-
|
|
18
|
+
dependencies: [
|
|
22
19
|
{
|
|
23
20
|
factory: '0x69Aa2f9fe1572F1B640E1bbc512f5c3a734fc77c',
|
|
24
21
|
factoryData: '0x0000000',
|
|
25
22
|
},
|
|
26
23
|
],
|
|
27
|
-
|
|
28
|
-
delegationManager: '0xdb9B1e94B5b69Df7e401DDbedE43491141047dB3',
|
|
29
|
-
},
|
|
24
|
+
delegationManager: '0xdb9B1e94B5b69Df7e401DDbedE43491141047dB3',
|
|
30
25
|
},
|
|
31
26
|
siteOrigin: 'http://localhost:8000',
|
|
32
27
|
});
|
|
33
28
|
export const mockNativeTokenPeriodicStorageEntry = (chainId) => ({
|
|
34
29
|
permissionResponse: {
|
|
35
30
|
chainId,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
type: 'account',
|
|
39
|
-
data: { address: '0x4f71DA06987BfeDE90aF0b33E1e3e4ffDCEE7a63' },
|
|
40
|
-
},
|
|
31
|
+
from: '0xB68c70159E9892DdF5659ec42ff9BD2bbC23e778',
|
|
32
|
+
to: '0x4f71DA06987BfeDE90aF0b33E1e3e4ffDCEE7a63',
|
|
41
33
|
permission: {
|
|
42
34
|
type: 'native-token-periodic',
|
|
43
35
|
isAdjustmentAllowed: true,
|
|
@@ -49,26 +41,21 @@ export const mockNativeTokenPeriodicStorageEntry = (chainId) => ({
|
|
|
49
41
|
},
|
|
50
42
|
},
|
|
51
43
|
context: '0x00000000',
|
|
52
|
-
|
|
44
|
+
dependencies: [
|
|
53
45
|
{
|
|
54
46
|
factory: '0x69Aa2f9fe1572F1B640E1bbc512f5c3a734fc77c',
|
|
55
47
|
factoryData: '0x0000000',
|
|
56
48
|
},
|
|
57
49
|
],
|
|
58
|
-
|
|
59
|
-
delegationManager: '0xdb9B1e94B5b69Df7e401DDbedE43491141047dB3',
|
|
60
|
-
},
|
|
50
|
+
delegationManager: '0xdb9B1e94B5b69Df7e401DDbedE43491141047dB3',
|
|
61
51
|
},
|
|
62
52
|
siteOrigin: 'http://localhost:8000',
|
|
63
53
|
});
|
|
64
54
|
export const mockErc20TokenStreamStorageEntry = (chainId) => ({
|
|
65
55
|
permissionResponse: {
|
|
66
56
|
chainId,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
type: 'account',
|
|
70
|
-
data: { address: '0x4f71DA06987BfeDE90aF0b33E1e3e4ffDCEE7a63' },
|
|
71
|
-
},
|
|
57
|
+
from: '0xB68c70159E9892DdF5659ec42ff9BD2bbC23e778',
|
|
58
|
+
to: '0x4f71DA06987BfeDE90aF0b33E1e3e4ffDCEE7a63',
|
|
72
59
|
permission: {
|
|
73
60
|
type: 'erc20-token-stream',
|
|
74
61
|
isAdjustmentAllowed: true,
|
|
@@ -82,26 +69,21 @@ export const mockErc20TokenStreamStorageEntry = (chainId) => ({
|
|
|
82
69
|
},
|
|
83
70
|
},
|
|
84
71
|
context: '0x00000000',
|
|
85
|
-
|
|
72
|
+
dependencies: [
|
|
86
73
|
{
|
|
87
74
|
factory: '0x69Aa2f9fe1572F1B640E1bbc512f5c3a734fc77c',
|
|
88
75
|
factoryData: '0x0000000',
|
|
89
76
|
},
|
|
90
77
|
],
|
|
91
|
-
|
|
92
|
-
delegationManager: '0xdb9B1e94B5b69Df7e401DDbedE43491141047dB3',
|
|
93
|
-
},
|
|
78
|
+
delegationManager: '0xdb9B1e94B5b69Df7e401DDbedE43491141047dB3',
|
|
94
79
|
},
|
|
95
80
|
siteOrigin: 'http://localhost:8000',
|
|
96
81
|
});
|
|
97
82
|
export const mockErc20TokenPeriodicStorageEntry = (chainId) => ({
|
|
98
83
|
permissionResponse: {
|
|
99
84
|
chainId,
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
type: 'account',
|
|
103
|
-
data: { address: '0x4f71DA06987BfeDE90aF0b33E1e3e4ffDCEE7a63' },
|
|
104
|
-
},
|
|
85
|
+
from: '0xB68c70159E9892DdF5659ec42ff9BD2bbC23e778',
|
|
86
|
+
to: '0x4f71DA06987BfeDE90aF0b33E1e3e4ffDCEE7a63',
|
|
105
87
|
permission: {
|
|
106
88
|
type: 'erc20-token-periodic',
|
|
107
89
|
isAdjustmentAllowed: true,
|
|
@@ -114,26 +96,21 @@ export const mockErc20TokenPeriodicStorageEntry = (chainId) => ({
|
|
|
114
96
|
},
|
|
115
97
|
},
|
|
116
98
|
context: '0x00000000',
|
|
117
|
-
|
|
99
|
+
dependencies: [
|
|
118
100
|
{
|
|
119
101
|
factory: '0x69Aa2f9fe1572F1B640E1bbc512f5c3a734fc77c',
|
|
120
102
|
factoryData: '0x0000000',
|
|
121
103
|
},
|
|
122
104
|
],
|
|
123
|
-
|
|
124
|
-
delegationManager: '0xdb9B1e94B5b69Df7e401DDbedE43491141047dB3',
|
|
125
|
-
},
|
|
105
|
+
delegationManager: '0xdb9B1e94B5b69Df7e401DDbedE43491141047dB3',
|
|
126
106
|
},
|
|
127
107
|
siteOrigin: 'http://localhost:8000',
|
|
128
108
|
});
|
|
129
109
|
export const mockCustomPermissionStorageEntry = (chainId, data) => ({
|
|
130
110
|
permissionResponse: {
|
|
131
111
|
chainId,
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
type: 'account',
|
|
135
|
-
data: { address: '0x4f71DA06987BfeDE90aF0b33E1e3e4ffDCEE7a63' },
|
|
136
|
-
},
|
|
112
|
+
from: '0xB68c70159E9892DdF5659ec42ff9BD2bbC23e778',
|
|
113
|
+
to: '0x4f71DA06987BfeDE90aF0b33E1e3e4ffDCEE7a63',
|
|
137
114
|
permission: {
|
|
138
115
|
type: 'custom',
|
|
139
116
|
isAdjustmentAllowed: true,
|
|
@@ -143,15 +120,13 @@ export const mockCustomPermissionStorageEntry = (chainId, data) => ({
|
|
|
143
120
|
},
|
|
144
121
|
},
|
|
145
122
|
context: '0x00000000',
|
|
146
|
-
|
|
123
|
+
dependencies: [
|
|
147
124
|
{
|
|
148
125
|
factory: '0x69Aa2f9fe1572F1B640E1bbc512f5c3a734fc77c',
|
|
149
126
|
factoryData: '0x0000000',
|
|
150
127
|
},
|
|
151
128
|
],
|
|
152
|
-
|
|
153
|
-
delegationManager: '0xdb9B1e94B5b69Df7e401DDbedE43491141047dB3',
|
|
154
|
-
},
|
|
129
|
+
delegationManager: '0xdb9B1e94B5b69Df7e401DDbedE43491141047dB3',
|
|
155
130
|
},
|
|
156
131
|
siteOrigin: 'http://localhost:8000',
|
|
157
132
|
});
|
package/dist/test/mocks.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mocks.mjs","sourceRoot":"","sources":["../../src/test/mocks.ts"],"names":[],"mappings":"AAeA,MAA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Aa,EACb,WAGC,EACD,EAAE;YACF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC/B,MAAM,KAAK,GAAG,WAAW,EAAE,CAAC;gBAC5B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACrB,CAAC;QACH,CAAC,CAAC;QAEF,aAAa,CAAC,MAAM,CAAC,iBAAiB,EAAE,GAAG,EAAE,CAC3C,iCAAiC,CAAC,OAAc,CAAC,CAClD,CAAC;QAEF,aAAa,CAAC,MAAM,CAAC,mBAAmB,EAAE,GAAG,EAAE,CAC7C,mCAAmC,CAAC,OAAc,CAAC,CACpD,CAAC;QAEF,aAAa,CAAC,MAAM,CAAC,gBAAgB,EAAE,GAAG,EAAE,CAC1C,gCAAgC,CAAC,OAAc,CAAC,CACjD,CAAC;QAEF,aAAa,CAAC,MAAM,CAAC,kBAAkB,EAAE,GAAG,EAAE,CAC5C,kCAAkC,CAAC,OAAc,CAAC,CACnD,CAAC;QAEF,wBAAwB;QACxB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;YAC7C,MAAM,KAAK,GAAG,gCAAgC,CAC5C,OAAc,EACd,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CACtB,CAAC;YACF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type {\n AccountSigner,\n Erc20TokenPeriodicPermission,\n Erc20TokenStreamPermission,\n NativeTokenPeriodicPermission,\n NativeTokenStreamPermission,\n} from '@metamask/7715-permission-types';\nimport type { Hex } from '@metamask/utils';\n\nimport type {\n CustomPermission,\n PermissionTypesWithCustom,\n StoredGatorPermission,\n} from '../types';\n\nexport const mockNativeTokenStreamStorageEntry = (\n chainId: Hex,\n): StoredGatorPermission<AccountSigner, NativeTokenStreamPermission> => ({\n permissionResponse: {\n chainId,\n address: '0xB68c70159E9892DdF5659ec42ff9BD2bbC23e778',\n signer: {\n type: 'account',\n data: { address: '0x4f71DA06987BfeDE90aF0b33E1e3e4ffDCEE7a63' },\n },\n permission: {\n type: 'native-token-stream',\n isAdjustmentAllowed: true,\n data: {\n maxAmount: '0x22b1c8c1227a0000',\n initialAmount: '0x6f05b59d3b20000',\n amountPerSecond: '0x6f05b59d3b20000',\n startTime: 1747699200,\n justification:\n 'This is a very important request for streaming allowance for some very important thing',\n },\n },\n context: '0x00000000',\n dependencyInfo: [\n {\n factory: '0x69Aa2f9fe1572F1B640E1bbc512f5c3a734fc77c',\n factoryData: '0x0000000',\n },\n ],\n signerMeta: {\n delegationManager: '0xdb9B1e94B5b69Df7e401DDbedE43491141047dB3',\n },\n },\n siteOrigin: 'http://localhost:8000',\n});\n\nexport const mockNativeTokenPeriodicStorageEntry = (\n chainId: Hex,\n): StoredGatorPermission<AccountSigner, NativeTokenPeriodicPermission> => ({\n permissionResponse: {\n chainId,\n address: '0xB68c70159E9892DdF5659ec42ff9BD2bbC23e778',\n signer: {\n type: 'account',\n data: { address: '0x4f71DA06987BfeDE90aF0b33E1e3e4ffDCEE7a63' },\n },\n permission: {\n type: 'native-token-periodic',\n isAdjustmentAllowed: true,\n data: {\n periodAmount: '0x22b1c8c1227a0000',\n periodDuration: 1747699200,\n startTime: 1747699200,\n justification:\n 'This is a very important request for streaming allowance for some very important thing',\n },\n },\n context: '0x00000000',\n dependencyInfo: [\n {\n factory: '0x69Aa2f9fe1572F1B640E1bbc512f5c3a734fc77c',\n factoryData: '0x0000000',\n },\n ],\n signerMeta: {\n delegationManager: '0xdb9B1e94B5b69Df7e401DDbedE43491141047dB3',\n },\n },\n siteOrigin: 'http://localhost:8000',\n});\n\nexport const mockErc20TokenStreamStorageEntry = (\n chainId: Hex,\n): StoredGatorPermission<AccountSigner, Erc20TokenStreamPermission> => ({\n permissionResponse: {\n chainId,\n address: '0xB68c70159E9892DdF5659ec42ff9BD2bbC23e778',\n signer: {\n type: 'account',\n data: { address: '0x4f71DA06987BfeDE90aF0b33E1e3e4ffDCEE7a63' },\n },\n permission: {\n type: 'erc20-token-stream',\n isAdjustmentAllowed: true,\n data: {\n initialAmount: '0x22b1c8c1227a0000',\n maxAmount: '0x6f05b59d3b20000',\n amountPerSecond: '0x6f05b59d3b20000',\n startTime: 1747699200,\n tokenAddress: '0xB68c70159E9892DdF5659ec42ff9BD2bbC23e778',\n justification:\n 'This is a very important request for streaming allowance for some very important thing',\n },\n },\n context: '0x00000000',\n dependencyInfo: [\n {\n factory: '0x69Aa2f9fe1572F1B640E1bbc512f5c3a734fc77c',\n factoryData: '0x0000000',\n },\n ],\n signerMeta: {\n delegationManager: '0xdb9B1e94B5b69Df7e401DDbedE43491141047dB3',\n },\n },\n siteOrigin: 'http://localhost:8000',\n});\n\nexport const mockErc20TokenPeriodicStorageEntry = (\n chainId: Hex,\n): StoredGatorPermission<AccountSigner, Erc20TokenPeriodicPermission> => ({\n permissionResponse: {\n chainId,\n address: '0xB68c70159E9892DdF5659ec42ff9BD2bbC23e778',\n signer: {\n type: 'account',\n data: { address: '0x4f71DA06987BfeDE90aF0b33E1e3e4ffDCEE7a63' },\n },\n permission: {\n type: 'erc20-token-periodic',\n isAdjustmentAllowed: true,\n data: {\n periodAmount: '0x22b1c8c1227a0000',\n periodDuration: 1747699200,\n startTime: 1747699200,\n tokenAddress: '0xB68c70159E9892DdF5659ec42ff9BD2bbC23e778',\n justification:\n 'This is a very important request for streaming allowance for some very important thing',\n },\n },\n context: '0x00000000',\n dependencyInfo: [\n {\n factory: '0x69Aa2f9fe1572F1B640E1bbc512f5c3a734fc77c',\n factoryData: '0x0000000',\n },\n ],\n signerMeta: {\n delegationManager: '0xdb9B1e94B5b69Df7e401DDbedE43491141047dB3',\n },\n },\n siteOrigin: 'http://localhost:8000',\n});\n\nexport const mockCustomPermissionStorageEntry = (\n chainId: Hex,\n data: Record<string, unknown>,\n): StoredGatorPermission<AccountSigner, CustomPermission> => ({\n permissionResponse: {\n chainId,\n address: '0xB68c70159E9892DdF5659ec42ff9BD2bbC23e778',\n signer: {\n type: 'account',\n data: { address: '0x4f71DA06987BfeDE90aF0b33E1e3e4ffDCEE7a63' },\n },\n permission: {\n type: 'custom',\n isAdjustmentAllowed: true,\n data: {\n justification:\n 'This is a very important request for streaming allowance for some very important thing',\n ...data,\n },\n },\n context: '0x00000000',\n dependencyInfo: [\n {\n factory: '0x69Aa2f9fe1572F1B640E1bbc512f5c3a734fc77c',\n factoryData: '0x0000000',\n },\n ],\n signerMeta: {\n delegationManager: '0xdb9B1e94B5b69Df7e401DDbedE43491141047dB3',\n },\n },\n siteOrigin: 'http://localhost:8000',\n});\n\nexport type MockGatorPermissionsStorageEntriesConfig = {\n [chainId: string]: {\n nativeTokenStream: number;\n nativeTokenPeriodic: number;\n erc20TokenStream: number;\n erc20TokenPeriodic: number;\n custom: {\n count: number;\n data: Record<string, unknown>[];\n };\n };\n};\n\n/**\n * Creates a mock gator permissions storage entry\n *\n * @param config - The config for the mock gator permissions storage entries.\n * @returns Mock gator permissions storage entry\n */\n/**\n * Creates mock gator permissions storage entries with unique expiry times\n *\n * @param config - The config for the mock gator permissions storage entries.\n * @returns Mock gator permissions storage entries\n */\nexport function mockGatorPermissionsStorageEntriesFactory(\n config: MockGatorPermissionsStorageEntriesConfig,\n): StoredGatorPermission<AccountSigner, PermissionTypesWithCustom>[] {\n const result: StoredGatorPermission<\n AccountSigner,\n PermissionTypesWithCustom\n >[] = [];\n\n Object.entries(config).forEach(([chainId, counts]) => {\n if (counts.custom.count !== counts.custom.data.length) {\n throw new Error('Custom permission count and data length mismatch');\n }\n\n /**\n * Creates a number of entries with unique expiry times\n *\n * @param count - The number of entries to create.\n * @param createEntry - The function to create an entry.\n */\n const createEntries = (\n count: number,\n createEntry: () => StoredGatorPermission<\n AccountSigner,\n PermissionTypesWithCustom\n >,\n ) => {\n for (let i = 0; i < count; i++) {\n const entry = createEntry();\n result.push(entry);\n }\n };\n\n createEntries(counts.nativeTokenStream, () =>\n mockNativeTokenStreamStorageEntry(chainId as Hex),\n );\n\n createEntries(counts.nativeTokenPeriodic, () =>\n mockNativeTokenPeriodicStorageEntry(chainId as Hex),\n );\n\n createEntries(counts.erc20TokenStream, () =>\n mockErc20TokenStreamStorageEntry(chainId as Hex),\n );\n\n createEntries(counts.erc20TokenPeriodic, () =>\n mockErc20TokenPeriodicStorageEntry(chainId as Hex),\n );\n\n // Create custom entries\n for (let i = 0; i < counts.custom.count; i++) {\n const entry = mockCustomPermissionStorageEntry(\n chainId as Hex,\n counts.custom.data[i],\n );\n result.push(entry);\n }\n });\n\n return result;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mocks.mjs","sourceRoot":"","sources":["../../src/test/mocks.ts"],"names":[],"mappings":"AAcA,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAC/C,OAAY,EACwC,EAAE,CAAC,CAAC;IACxD,kBAAkB,EAAE;QAClB,OAAO;QACP,IAAI,EAAE,4CAA4C;QAClD,EAAE,EAAE,4CAA4C;QAChD,UAAU,EAAE;YACV,IAAI,EAAE,qBAAqB;YAC3B,mBAAmB,EAAE,IAAI;YACzB,IAAI,EAAE;gBACJ,SAAS,EAAE,oBAAoB;gBAC/B,aAAa,EAAE,mBAAmB;gBAClC,eAAe,EAAE,mBAAmB;gBACpC,SAAS,EAAE,UAAU;gBACrB,aAAa,EACX,wFAAwF;aAC3F;SACF;QACD,OAAO,EAAE,YAAY;QACrB,YAAY,EAAE;YACZ;gBACE,OAAO,EAAE,4CAA4C;gBACrD,WAAW,EAAE,WAAW;aACzB;SACF;QACD,iBAAiB,EAAE,4CAA4C;KAChE;IACD,UAAU,EAAE,uBAAuB;CACpC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mCAAmC,GAAG,CACjD,OAAY,EAC0C,EAAE,CAAC,CA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ativeTokenStreamPermission,\n} from '@metamask/7715-permission-types';\nimport type { Hex } from '@metamask/utils';\n\nimport type {\n CustomPermission,\n PermissionTypesWithCustom,\n StoredGatorPermission,\n} from '../types';\n\nexport const mockNativeTokenStreamStorageEntry = (\n chainId: Hex,\n): StoredGatorPermission<NativeTokenStreamPermission> => ({\n permissionResponse: {\n chainId,\n from: '0xB68c70159E9892DdF5659ec42ff9BD2bbC23e778',\n to: '0x4f71DA06987BfeDE90aF0b33E1e3e4ffDCEE7a63',\n permission: {\n type: 'native-token-stream',\n isAdjustmentAllowed: true,\n data: {\n maxAmount: '0x22b1c8c1227a0000',\n initialAmount: '0x6f05b59d3b20000',\n amountPerSecond: '0x6f05b59d3b20000',\n startTime: 1747699200,\n justification:\n 'This is a very important request for streaming allowance for some very important thing',\n },\n },\n context: '0x00000000',\n dependencies: [\n {\n factory: '0x69Aa2f9fe1572F1B640E1bbc512f5c3a734fc77c',\n factoryData: '0x0000000',\n },\n ],\n delegationManager: '0xdb9B1e94B5b69Df7e401DDbedE43491141047dB3',\n },\n siteOrigin: 'http://localhost:8000',\n});\n\nexport const mockNativeTokenPeriodicStorageEntry = (\n chainId: Hex,\n): StoredGatorPermission<NativeTokenPeriodicPermission> => ({\n permissionResponse: {\n chainId,\n from: '0xB68c70159E9892DdF5659ec42ff9BD2bbC23e778',\n to: '0x4f71DA06987BfeDE90aF0b33E1e3e4ffDCEE7a63',\n permission: {\n type: 'native-token-periodic',\n isAdjustmentAllowed: true,\n data: {\n periodAmount: '0x22b1c8c1227a0000',\n periodDuration: 1747699200,\n startTime: 1747699200,\n justification:\n 'This is a very important request for streaming allowance for some very important thing',\n },\n },\n context: '0x00000000',\n dependencies: [\n {\n factory: '0x69Aa2f9fe1572F1B640E1bbc512f5c3a734fc77c',\n factoryData: '0x0000000',\n },\n ],\n delegationManager: '0xdb9B1e94B5b69Df7e401DDbedE43491141047dB3',\n },\n siteOrigin: 'http://localhost:8000',\n});\n\nexport const mockErc20TokenStreamStorageEntry = (\n chainId: Hex,\n): StoredGatorPermission<Erc20TokenStreamPermission> => ({\n permissionResponse: {\n chainId,\n from: '0xB68c70159E9892DdF5659ec42ff9BD2bbC23e778',\n to: '0x4f71DA06987BfeDE90aF0b33E1e3e4ffDCEE7a63',\n permission: {\n type: 'erc20-token-stream',\n isAdjustmentAllowed: true,\n data: {\n initialAmount: '0x22b1c8c1227a0000',\n maxAmount: '0x6f05b59d3b20000',\n amountPerSecond: '0x6f05b59d3b20000',\n startTime: 1747699200,\n tokenAddress: '0xB68c70159E9892DdF5659ec42ff9BD2bbC23e778',\n justification:\n 'This is a very important request for streaming allowance for some very important thing',\n },\n },\n context: '0x00000000',\n dependencies: [\n {\n factory: '0x69Aa2f9fe1572F1B640E1bbc512f5c3a734fc77c',\n factoryData: '0x0000000',\n },\n ],\n delegationManager: '0xdb9B1e94B5b69Df7e401DDbedE43491141047dB3',\n },\n siteOrigin: 'http://localhost:8000',\n});\n\nexport const mockErc20TokenPeriodicStorageEntry = (\n chainId: Hex,\n): StoredGatorPermission<Erc20TokenPeriodicPermission> => ({\n permissionResponse: {\n chainId,\n from: '0xB68c70159E9892DdF5659ec42ff9BD2bbC23e778',\n to: '0x4f71DA06987BfeDE90aF0b33E1e3e4ffDCEE7a63',\n permission: {\n type: 'erc20-token-periodic',\n isAdjustmentAllowed: true,\n data: {\n periodAmount: '0x22b1c8c1227a0000',\n periodDuration: 1747699200,\n startTime: 1747699200,\n tokenAddress: '0xB68c70159E9892DdF5659ec42ff9BD2bbC23e778',\n justification:\n 'This is a very important request for streaming allowance for some very important thing',\n },\n },\n context: '0x00000000',\n dependencies: [\n {\n factory: '0x69Aa2f9fe1572F1B640E1bbc512f5c3a734fc77c',\n factoryData: '0x0000000',\n },\n ],\n delegationManager: '0xdb9B1e94B5b69Df7e401DDbedE43491141047dB3',\n },\n siteOrigin: 'http://localhost:8000',\n});\n\nexport const mockCustomPermissionStorageEntry = (\n chainId: Hex,\n data: Record<string, unknown>,\n): StoredGatorPermission<CustomPermission> => ({\n permissionResponse: {\n chainId,\n from: '0xB68c70159E9892DdF5659ec42ff9BD2bbC23e778',\n to: '0x4f71DA06987BfeDE90aF0b33E1e3e4ffDCEE7a63',\n permission: {\n type: 'custom',\n isAdjustmentAllowed: true,\n data: {\n justification:\n 'This is a very important request for streaming allowance for some very important thing',\n ...data,\n },\n },\n context: '0x00000000',\n dependencies: [\n {\n factory: '0x69Aa2f9fe1572F1B640E1bbc512f5c3a734fc77c',\n factoryData: '0x0000000',\n },\n ],\n delegationManager: '0xdb9B1e94B5b69Df7e401DDbedE43491141047dB3',\n },\n siteOrigin: 'http://localhost:8000',\n});\n\nexport type MockGatorPermissionsStorageEntriesConfig = {\n [chainId: string]: {\n nativeTokenStream: number;\n nativeTokenPeriodic: number;\n erc20TokenStream: number;\n erc20TokenPeriodic: number;\n custom: {\n count: number;\n data: Record<string, unknown>[];\n };\n };\n};\n\n/**\n * Creates a mock gator permissions storage entry\n *\n * @param config - The config for the mock gator permissions storage entries.\n * @returns Mock gator permissions storage entry\n */\n/**\n * Creates mock gator permissions storage entries with unique expiry times\n *\n * @param config - The config for the mock gator permissions storage entries.\n * @returns Mock gator permissions storage entries\n */\nexport function mockGatorPermissionsStorageEntriesFactory(\n config: MockGatorPermissionsStorageEntriesConfig,\n): StoredGatorPermission<PermissionTypesWithCustom>[] {\n const result: StoredGatorPermission<PermissionTypesWithCustom>[] = [];\n\n Object.entries(config).forEach(([chainId, counts]) => {\n if (counts.custom.count !== counts.custom.data.length) {\n throw new Error('Custom permission count and data length mismatch');\n }\n\n /**\n * Creates a number of entries with unique expiry times\n *\n * @param count - The number of entries to create.\n * @param createEntry - The function to create an entry.\n */\n const createEntries = (\n count: number,\n createEntry: () => StoredGatorPermission<PermissionTypesWithCustom>,\n ): void => {\n for (let i = 0; i < count; i++) {\n const entry = createEntry();\n result.push(entry);\n }\n };\n\n createEntries(counts.nativeTokenStream, () =>\n mockNativeTokenStreamStorageEntry(chainId as Hex),\n );\n\n createEntries(counts.nativeTokenPeriodic, () =>\n mockNativeTokenPeriodicStorageEntry(chainId as Hex),\n );\n\n createEntries(counts.erc20TokenStream, () =>\n mockErc20TokenStreamStorageEntry(chainId as Hex),\n );\n\n createEntries(counts.erc20TokenPeriodic, () =>\n mockErc20TokenPeriodicStorageEntry(chainId as Hex),\n );\n\n // Create custom entries\n for (let i = 0; i < counts.custom.count; i++) {\n const entry = mockCustomPermissionStorageEntry(\n chainId as Hex,\n counts.custom.data[i],\n );\n result.push(entry);\n }\n });\n\n return result;\n}\n"]}
|
package/dist/types.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAcA;;GAEG;AACH,IAAY,mCAOX;AAPD,WAAY,mCAAmC;IAC7C,mGAA4D,CAAA;IAC5D,mGAA4D,CAAA;IAC5D,yGAAkE,CAAA;IAClE,0HAAmF,CAAA;IACnF,4FAAqD,CAAA;IACrD,yFAAkD,CAAA;AACpD,CAAC,EAPW,mCAAmC,mDAAnC,mCAAmC,QAO9C;AAED;;GAEG;AACH,IAAY,6BASX;AATD,WAAY,6BAA6B;IACvC;;OAEG;IACH,sHAAqF,CAAA;IACrF;;OAEG;IACH,4GAA2E,CAAA;AAC7E,CAAC,EATW,6BAA6B,6CAA7B,6BAA6B,QASxC","sourcesContent":["import type {\n PermissionTypes,\n BasePermission,\n NativeTokenStreamPermission,\n NativeTokenPeriodicPermission,\n Erc20TokenStreamPermission,\n Erc20TokenPeriodicPermission,\n Rule,\n MetaMaskBasePermissionData,\n Erc20TokenRevocationPermission,\n} from '@metamask/7715-permission-types';\nimport type { Delegation } from '@metamask/delegation-core';\nimport type { Hex } from '@metamask/utils';\n\n/**\n * Enum for the error codes of the gator permissions controller.\n */\nexport enum GatorPermissionsControllerErrorCode {\n GatorPermissionsFetchError = 'gator-permissions-fetch-error',\n GatorPermissionsNotEnabled = 'gator-permissions-not-enabled',\n GatorPermissionsProviderError = 'gator-permissions-provider-error',\n GatorPermissionsMapSerializationError = 'gator-permissions-map-serialization-error',\n PermissionDecodingError = 'permission-decoding-error',\n OriginNotAllowedError = 'origin-not-allowed-error',\n}\n\n/**\n * Enum for the RPC methods of the gator permissions provider snap.\n */\nexport enum GatorPermissionsSnapRpcMethod {\n /**\n * This method is used by the metamask to request a permissions provider to get granted permissions for all sites.\n */\n PermissionProviderGetGrantedPermissions = 'permissionsProvider_getGrantedPermissions',\n /**\n * This method is used by the metamask to submit a revocation to the permissions provider.\n */\n PermissionProviderSubmitRevocation = 'permissionsProvider_submitRevocation',\n}\n\n/**\n * Represents a custom permission that are not of the standard ERC-7715 permission types.\n */\nexport type CustomPermission = BasePermission & {\n type: 'custom';\n data: MetaMaskBasePermissionData & Record<string, unknown>;\n};\n\n/**\n * Represents the type of the ERC-7715 permissions that can be granted including custom permissions.\n */\nexport type PermissionTypesWithCustom = PermissionTypes | CustomPermission;\n\n/**\n * Represents a ERC-7715 permission request.\n *\n * @template to - The type of the signer provided, either an AccountSigner or WalletSigner.\n * @template Permission - The type of the permission provided.\n */\nexport type PermissionRequest<TPermission extends PermissionTypesWithCustom> = {\n /**\n * hex-encoding of uint256 defined the chain with EIP-155\n */\n chainId: Hex;\n\n /**\n *\n * The account being targeted for this permission request.\n * It is optional to let the user choose which account to grant permission from.\n */\n from?: Hex;\n\n /**\n * A field that identifies the DApp session account associated with the permission\n */\n to: Hex;\n\n /**\n * Defines the allowed behavior the `to` account can do on behalf of the `from` account.\n */\n permission: TPermission;\n\n rules?: Rule[] | null;\n};\n\n/**\n * Represents a ERC-7715 permission response.\n *\n * @template Permission - The type of the permission provided.\n */\nexport type PermissionResponse<TPermission extends PermissionTypesWithCustom> =\n PermissionRequest<TPermission> & {\n /**\n * Is a catch-all to identify a permission for revoking permissions or submitting\n * Defined in ERC-7710.\n */\n context: Hex;\n\n /**\n * The dependencyInfo field is required and contains information needed to deploy accounts.\n * Each entry specifies a factory contract and its associated deployment data.\n * If no account deployment is needed when redeeming the permission, this array must be empty.\n * When non-empty, DApps MUST deploy the accounts by calling the factory contract with factoryData as the calldata.\n * Defined in ERC-4337.\n */\n dependencies: {\n factory: Hex;\n factoryData: Hex;\n }[];\n\n /**\n * Is required as defined in ERC-7710.\n */\n delegationManager: Hex;\n };\n\n/**\n * Represents a sanitized version of the PermissionResponse type.\n * Internal fields (dependencies, to) are removed\n *\n * @template Permission - The type of the permission provided.\n */\nexport type PermissionResponseSanitized<\n TPermission extends PermissionTypesWithCustom,\n> = Omit<PermissionResponse<TPermission>, 'dependencies' | 'to'>;\n\n/**\n * Represents a gator ERC-7715 granted(ie. signed by a user's account) permission entry that is stored in profile sync.\n *\n * @template Permission - The type of the permission provided\n */\nexport type StoredGatorPermission<\n TPermission extends PermissionTypesWithCustom,\n> = {\n permissionResponse: PermissionResponse<TPermission>;\n siteOrigin: string;\n revocationMetadata?: RevocationMetadata;\n};\n\n/**\n * Represents a sanitized version of the StoredGatorPermission type. Some fields have been removed but the fields are still present in profile sync.\n *\n * @template Permission - The type of the permission provided.\n */\nexport type StoredGatorPermissionSanitized<\n TPermission extends PermissionTypesWithCustom,\n> = {\n permissionResponse: PermissionResponseSanitized<TPermission>;\n siteOrigin: string;\n revocationMetadata?: RevocationMetadata;\n};\n\n/**\n * Represents a map of gator permissions by chainId and permission type.\n */\nexport type GatorPermissionsMap = {\n 'erc20-token-revocation': {\n [\n chainId: Hex\n ]: StoredGatorPermissionSanitized<Erc20TokenRevocationPermission>[];\n };\n 'native-token-stream': {\n [\n chainId: Hex\n ]: StoredGatorPermissionSanitized<NativeTokenStreamPermission>[];\n };\n 'native-token-periodic': {\n [\n chainId: Hex\n ]: StoredGatorPermissionSanitized<NativeTokenPeriodicPermission>[];\n };\n 'erc20-token-stream': {\n [\n chainId: Hex\n ]: StoredGatorPermissionSanitized<Erc20TokenStreamPermission>[];\n };\n 'erc20-token-periodic': {\n [\n chainId: Hex\n ]: StoredGatorPermissionSanitized<Erc20TokenPeriodicPermission>[];\n };\n other: {\n [chainId: Hex]: StoredGatorPermissionSanitized<CustomPermission>[];\n };\n};\n\n/**\n * Represents the supported permission type(e.g. 'native-token-stream', 'native-token-periodic', 'erc20-token-stream', 'erc20-token-periodic') of the gator permissions map.\n */\nexport type SupportedGatorPermissionType = keyof GatorPermissionsMap;\n\n/**\n * Represents a map of gator permissions for a given permission type with key of chainId. The value being an array of gator permissions for that chainId.\n */\nexport type GatorPermissionsMapByPermissionType<\n TPermissionType extends SupportedGatorPermissionType,\n> = GatorPermissionsMap[TPermissionType];\n\n/**\n * Represents an array of gator permissions for a given permission type and chainId.\n */\nexport type GatorPermissionsListByPermissionTypeAndChainId<\n TPermissionType extends SupportedGatorPermissionType,\n> = GatorPermissionsMap[TPermissionType][Hex];\n\n/**\n * Represents the details of a delegation, that are required to decode a permission.\n */\nexport type DelegationDetails = Pick<\n Delegation<Hex>,\n 'caveats' | 'delegator' | 'delegate' | 'authority'\n>;\n\n/**\n * Represents the metadata for confirmed transaction revocation.\n */\nexport type RevocationMetadata = {\n // The timestamp at which the revocation was recorded in storage.\n recordedAt: number;\n // The hash of the transaction that was used to revoke the permission. Optional because we might not have submitted the transaction ourselves.\n txHash?: Hex | undefined;\n};\n\n/**\n * Parameters for the `permissionsProvider_submitRevocation` method\n */\nexport type RevocationParams = {\n /**\n * The permission context as a hex string that identifies the permission to revoke.\n */\n permissionContext: Hex;\n\n /**\n * The hash of the transaction that was used to revoke the permission. Optional because we might not have submitted the transaction ourselves.\n */\n txHash: Hex | undefined;\n};\n\n/**\n * Represents the parameters for adding a pending revocation.\n */\nexport type PendingRevocationParams = {\n /**\n * The transaction metadata ID to monitor.\n */\n txId: string;\n /**\n * The permission context as a hex string that identifies the permission to revoke.\n */\n permissionContext: Hex;\n};\n"]}
|
package/dist/types.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PermissionTypes,
|
|
1
|
+
import type { PermissionTypes, BasePermission, NativeTokenStreamPermission, NativeTokenPeriodicPermission, Erc20TokenStreamPermission, Erc20TokenPeriodicPermission, Rule, MetaMaskBasePermissionData, Erc20TokenRevocationPermission } from "@metamask/7715-permission-types";
|
|
2
2
|
import type { Delegation } from "@metamask/delegation-core";
|
|
3
3
|
import type { Hex } from "@metamask/utils";
|
|
4
4
|
/**
|
|
@@ -39,10 +39,10 @@ export type PermissionTypesWithCustom = PermissionTypes | CustomPermission;
|
|
|
39
39
|
/**
|
|
40
40
|
* Represents a ERC-7715 permission request.
|
|
41
41
|
*
|
|
42
|
-
* @template
|
|
42
|
+
* @template to - The type of the signer provided, either an AccountSigner or WalletSigner.
|
|
43
43
|
* @template Permission - The type of the permission provided.
|
|
44
44
|
*/
|
|
45
|
-
export type PermissionRequest<
|
|
45
|
+
export type PermissionRequest<TPermission extends PermissionTypesWithCustom> = {
|
|
46
46
|
/**
|
|
47
47
|
* hex-encoding of uint256 defined the chain with EIP-155
|
|
48
48
|
*/
|
|
@@ -52,13 +52,13 @@ export type PermissionRequest<TSigner extends Signer, TPermission extends Permis
|
|
|
52
52
|
* The account being targeted for this permission request.
|
|
53
53
|
* It is optional to let the user choose which account to grant permission from.
|
|
54
54
|
*/
|
|
55
|
-
|
|
55
|
+
from?: Hex;
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
57
|
+
* A field that identifies the DApp session account associated with the permission
|
|
58
58
|
*/
|
|
59
|
-
|
|
59
|
+
to: Hex;
|
|
60
60
|
/**
|
|
61
|
-
* Defines the allowed behavior the
|
|
61
|
+
* Defines the allowed behavior the `to` account can do on behalf of the `from` account.
|
|
62
62
|
*/
|
|
63
63
|
permission: TPermission;
|
|
64
64
|
rules?: Rule[] | null;
|
|
@@ -66,10 +66,9 @@ export type PermissionRequest<TSigner extends Signer, TPermission extends Permis
|
|
|
66
66
|
/**
|
|
67
67
|
* Represents a ERC-7715 permission response.
|
|
68
68
|
*
|
|
69
|
-
* @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.
|
|
70
69
|
* @template Permission - The type of the permission provided.
|
|
71
70
|
*/
|
|
72
|
-
export type PermissionResponse<
|
|
71
|
+
export type PermissionResponse<TPermission extends PermissionTypesWithCustom> = PermissionRequest<TPermission> & {
|
|
73
72
|
/**
|
|
74
73
|
* Is a catch-all to identify a permission for revoking permissions or submitting
|
|
75
74
|
* Defined in ERC-7710.
|
|
@@ -82,74 +81,63 @@ export type PermissionResponse<TSigner extends Signer, TPermission extends Permi
|
|
|
82
81
|
* When non-empty, DApps MUST deploy the accounts by calling the factory contract with factoryData as the calldata.
|
|
83
82
|
* Defined in ERC-4337.
|
|
84
83
|
*/
|
|
85
|
-
|
|
84
|
+
dependencies: {
|
|
86
85
|
factory: Hex;
|
|
87
86
|
factoryData: Hex;
|
|
88
87
|
}[];
|
|
89
88
|
/**
|
|
90
|
-
*
|
|
89
|
+
* Is required as defined in ERC-7710.
|
|
91
90
|
*/
|
|
92
|
-
|
|
93
|
-
delegationManager: Hex;
|
|
94
|
-
};
|
|
91
|
+
delegationManager: Hex;
|
|
95
92
|
};
|
|
96
93
|
/**
|
|
97
94
|
* Represents a sanitized version of the PermissionResponse type.
|
|
98
|
-
* Internal fields (
|
|
95
|
+
* Internal fields (dependencies, to) are removed
|
|
99
96
|
*
|
|
100
|
-
* @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.
|
|
101
97
|
* @template Permission - The type of the permission provided.
|
|
102
98
|
*/
|
|
103
|
-
export type PermissionResponseSanitized<
|
|
99
|
+
export type PermissionResponseSanitized<TPermission extends PermissionTypesWithCustom> = Omit<PermissionResponse<TPermission>, 'dependencies' | 'to'>;
|
|
104
100
|
/**
|
|
105
|
-
* Represents a gator ERC-7715 granted(ie. signed by
|
|
101
|
+
* Represents a gator ERC-7715 granted(ie. signed by a user's account) permission entry that is stored in profile sync.
|
|
106
102
|
*
|
|
107
|
-
* @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.
|
|
108
103
|
* @template Permission - The type of the permission provided
|
|
109
104
|
*/
|
|
110
|
-
export type StoredGatorPermission<
|
|
111
|
-
permissionResponse: PermissionResponse<
|
|
105
|
+
export type StoredGatorPermission<TPermission extends PermissionTypesWithCustom> = {
|
|
106
|
+
permissionResponse: PermissionResponse<TPermission>;
|
|
112
107
|
siteOrigin: string;
|
|
113
|
-
|
|
114
|
-
* Flag indicating whether this permission has been revoked.
|
|
115
|
-
*/
|
|
116
|
-
isRevoked?: boolean;
|
|
108
|
+
revocationMetadata?: RevocationMetadata;
|
|
117
109
|
};
|
|
118
110
|
/**
|
|
119
111
|
* Represents a sanitized version of the StoredGatorPermission type. Some fields have been removed but the fields are still present in profile sync.
|
|
120
112
|
*
|
|
121
|
-
* @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.
|
|
122
113
|
* @template Permission - The type of the permission provided.
|
|
123
114
|
*/
|
|
124
|
-
export type StoredGatorPermissionSanitized<
|
|
125
|
-
permissionResponse: PermissionResponseSanitized<
|
|
115
|
+
export type StoredGatorPermissionSanitized<TPermission extends PermissionTypesWithCustom> = {
|
|
116
|
+
permissionResponse: PermissionResponseSanitized<TPermission>;
|
|
126
117
|
siteOrigin: string;
|
|
127
|
-
|
|
128
|
-
* Flag indicating whether this permission has been revoked.
|
|
129
|
-
*/
|
|
130
|
-
isRevoked?: boolean;
|
|
118
|
+
revocationMetadata?: RevocationMetadata;
|
|
131
119
|
};
|
|
132
120
|
/**
|
|
133
121
|
* Represents a map of gator permissions by chainId and permission type.
|
|
134
122
|
*/
|
|
135
123
|
export type GatorPermissionsMap = {
|
|
136
124
|
'erc20-token-revocation': {
|
|
137
|
-
[chainId: Hex]: StoredGatorPermissionSanitized<
|
|
125
|
+
[chainId: Hex]: StoredGatorPermissionSanitized<Erc20TokenRevocationPermission>[];
|
|
138
126
|
};
|
|
139
127
|
'native-token-stream': {
|
|
140
|
-
[chainId: Hex]: StoredGatorPermissionSanitized<
|
|
128
|
+
[chainId: Hex]: StoredGatorPermissionSanitized<NativeTokenStreamPermission>[];
|
|
141
129
|
};
|
|
142
130
|
'native-token-periodic': {
|
|
143
|
-
[chainId: Hex]: StoredGatorPermissionSanitized<
|
|
131
|
+
[chainId: Hex]: StoredGatorPermissionSanitized<NativeTokenPeriodicPermission>[];
|
|
144
132
|
};
|
|
145
133
|
'erc20-token-stream': {
|
|
146
|
-
[chainId: Hex]: StoredGatorPermissionSanitized<
|
|
134
|
+
[chainId: Hex]: StoredGatorPermissionSanitized<Erc20TokenStreamPermission>[];
|
|
147
135
|
};
|
|
148
136
|
'erc20-token-periodic': {
|
|
149
|
-
[chainId: Hex]: StoredGatorPermissionSanitized<
|
|
137
|
+
[chainId: Hex]: StoredGatorPermissionSanitized<Erc20TokenPeriodicPermission>[];
|
|
150
138
|
};
|
|
151
139
|
other: {
|
|
152
|
-
[chainId: Hex]: StoredGatorPermissionSanitized<
|
|
140
|
+
[chainId: Hex]: StoredGatorPermissionSanitized<CustomPermission>[];
|
|
153
141
|
};
|
|
154
142
|
};
|
|
155
143
|
/**
|
|
@@ -169,13 +157,24 @@ export type GatorPermissionsListByPermissionTypeAndChainId<TPermissionType exten
|
|
|
169
157
|
*/
|
|
170
158
|
export type DelegationDetails = Pick<Delegation<Hex>, 'caveats' | 'delegator' | 'delegate' | 'authority'>;
|
|
171
159
|
/**
|
|
172
|
-
* Represents the
|
|
160
|
+
* Represents the metadata for confirmed transaction revocation.
|
|
161
|
+
*/
|
|
162
|
+
export type RevocationMetadata = {
|
|
163
|
+
recordedAt: number;
|
|
164
|
+
txHash?: Hex | undefined;
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Parameters for the `permissionsProvider_submitRevocation` method
|
|
173
168
|
*/
|
|
174
169
|
export type RevocationParams = {
|
|
175
170
|
/**
|
|
176
171
|
* The permission context as a hex string that identifies the permission to revoke.
|
|
177
172
|
*/
|
|
178
173
|
permissionContext: Hex;
|
|
174
|
+
/**
|
|
175
|
+
* The hash of the transaction that was used to revoke the permission. Optional because we might not have submitted the transaction ourselves.
|
|
176
|
+
*/
|
|
177
|
+
txHash: Hex | undefined;
|
|
179
178
|
};
|
|
180
179
|
/**
|
|
181
180
|
* Represents the parameters for adding a pending revocation.
|
package/dist/types.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,
|
|
1
|
+
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,2BAA2B,EAC3B,6BAA6B,EAC7B,0BAA0B,EAC1B,4BAA4B,EAC5B,IAAI,EACJ,0BAA0B,EAC1B,8BAA8B,EAC/B,wCAAwC;AACzC,OAAO,KAAK,EAAE,UAAU,EAAE,kCAAkC;AAC5D,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C;;GAEG;AACH,oBAAY,mCAAmC;IAC7C,0BAA0B,kCAAkC;IAC5D,0BAA0B,kCAAkC;IAC5D,6BAA6B,qCAAqC;IAClE,qCAAqC,8CAA8C;IACnF,uBAAuB,8BAA8B;IACrD,qBAAqB,6BAA6B;CACnD;AAED;;GAEG;AACH,oBAAY,6BAA6B;IACvC;;OAEG;IACH,uCAAuC,8CAA8C;IACrF;;OAEG;IACH,kCAAkC,yCAAyC;CAC5E;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,cAAc,GAAG;IAC9C,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,0BAA0B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC5D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,eAAe,GAAG,gBAAgB,CAAC;AAE3E;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,CAAC,WAAW,SAAS,yBAAyB,IAA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H,iBAAiB,EAAE,GAAG,CAAC;IAEvB;;OAEG;IACH,MAAM,EAAE,GAAG,GAAG,SAAS,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,iBAAiB,EAAE,GAAG,CAAC;CACxB,CAAC"}
|
package/dist/types.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PermissionTypes,
|
|
1
|
+
import type { PermissionTypes, BasePermission, NativeTokenStreamPermission, NativeTokenPeriodicPermission, Erc20TokenStreamPermission, Erc20TokenPeriodicPermission, Rule, MetaMaskBasePermissionData, Erc20TokenRevocationPermission } from "@metamask/7715-permission-types";
|
|
2
2
|
import type { Delegation } from "@metamask/delegation-core";
|
|
3
3
|
import type { Hex } from "@metamask/utils";
|
|
4
4
|
/**
|
|
@@ -39,10 +39,10 @@ export type PermissionTypesWithCustom = PermissionTypes | CustomPermission;
|
|
|
39
39
|
/**
|
|
40
40
|
* Represents a ERC-7715 permission request.
|
|
41
41
|
*
|
|
42
|
-
* @template
|
|
42
|
+
* @template to - The type of the signer provided, either an AccountSigner or WalletSigner.
|
|
43
43
|
* @template Permission - The type of the permission provided.
|
|
44
44
|
*/
|
|
45
|
-
export type PermissionRequest<
|
|
45
|
+
export type PermissionRequest<TPermission extends PermissionTypesWithCustom> = {
|
|
46
46
|
/**
|
|
47
47
|
* hex-encoding of uint256 defined the chain with EIP-155
|
|
48
48
|
*/
|
|
@@ -52,13 +52,13 @@ export type PermissionRequest<TSigner extends Signer, TPermission extends Permis
|
|
|
52
52
|
* The account being targeted for this permission request.
|
|
53
53
|
* It is optional to let the user choose which account to grant permission from.
|
|
54
54
|
*/
|
|
55
|
-
|
|
55
|
+
from?: Hex;
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
57
|
+
* A field that identifies the DApp session account associated with the permission
|
|
58
58
|
*/
|
|
59
|
-
|
|
59
|
+
to: Hex;
|
|
60
60
|
/**
|
|
61
|
-
* Defines the allowed behavior the
|
|
61
|
+
* Defines the allowed behavior the `to` account can do on behalf of the `from` account.
|
|
62
62
|
*/
|
|
63
63
|
permission: TPermission;
|
|
64
64
|
rules?: Rule[] | null;
|
|
@@ -66,10 +66,9 @@ export type PermissionRequest<TSigner extends Signer, TPermission extends Permis
|
|
|
66
66
|
/**
|
|
67
67
|
* Represents a ERC-7715 permission response.
|
|
68
68
|
*
|
|
69
|
-
* @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.
|
|
70
69
|
* @template Permission - The type of the permission provided.
|
|
71
70
|
*/
|
|
72
|
-
export type PermissionResponse<
|
|
71
|
+
export type PermissionResponse<TPermission extends PermissionTypesWithCustom> = PermissionRequest<TPermission> & {
|
|
73
72
|
/**
|
|
74
73
|
* Is a catch-all to identify a permission for revoking permissions or submitting
|
|
75
74
|
* Defined in ERC-7710.
|
|
@@ -82,74 +81,63 @@ export type PermissionResponse<TSigner extends Signer, TPermission extends Permi
|
|
|
82
81
|
* When non-empty, DApps MUST deploy the accounts by calling the factory contract with factoryData as the calldata.
|
|
83
82
|
* Defined in ERC-4337.
|
|
84
83
|
*/
|
|
85
|
-
|
|
84
|
+
dependencies: {
|
|
86
85
|
factory: Hex;
|
|
87
86
|
factoryData: Hex;
|
|
88
87
|
}[];
|
|
89
88
|
/**
|
|
90
|
-
*
|
|
89
|
+
* Is required as defined in ERC-7710.
|
|
91
90
|
*/
|
|
92
|
-
|
|
93
|
-
delegationManager: Hex;
|
|
94
|
-
};
|
|
91
|
+
delegationManager: Hex;
|
|
95
92
|
};
|
|
96
93
|
/**
|
|
97
94
|
* Represents a sanitized version of the PermissionResponse type.
|
|
98
|
-
* Internal fields (
|
|
95
|
+
* Internal fields (dependencies, to) are removed
|
|
99
96
|
*
|
|
100
|
-
* @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.
|
|
101
97
|
* @template Permission - The type of the permission provided.
|
|
102
98
|
*/
|
|
103
|
-
export type PermissionResponseSanitized<
|
|
99
|
+
export type PermissionResponseSanitized<TPermission extends PermissionTypesWithCustom> = Omit<PermissionResponse<TPermission>, 'dependencies' | 'to'>;
|
|
104
100
|
/**
|
|
105
|
-
* Represents a gator ERC-7715 granted(ie. signed by
|
|
101
|
+
* Represents a gator ERC-7715 granted(ie. signed by a user's account) permission entry that is stored in profile sync.
|
|
106
102
|
*
|
|
107
|
-
* @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.
|
|
108
103
|
* @template Permission - The type of the permission provided
|
|
109
104
|
*/
|
|
110
|
-
export type StoredGatorPermission<
|
|
111
|
-
permissionResponse: PermissionResponse<
|
|
105
|
+
export type StoredGatorPermission<TPermission extends PermissionTypesWithCustom> = {
|
|
106
|
+
permissionResponse: PermissionResponse<TPermission>;
|
|
112
107
|
siteOrigin: string;
|
|
113
|
-
|
|
114
|
-
* Flag indicating whether this permission has been revoked.
|
|
115
|
-
*/
|
|
116
|
-
isRevoked?: boolean;
|
|
108
|
+
revocationMetadata?: RevocationMetadata;
|
|
117
109
|
};
|
|
118
110
|
/**
|
|
119
111
|
* Represents a sanitized version of the StoredGatorPermission type. Some fields have been removed but the fields are still present in profile sync.
|
|
120
112
|
*
|
|
121
|
-
* @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.
|
|
122
113
|
* @template Permission - The type of the permission provided.
|
|
123
114
|
*/
|
|
124
|
-
export type StoredGatorPermissionSanitized<
|
|
125
|
-
permissionResponse: PermissionResponseSanitized<
|
|
115
|
+
export type StoredGatorPermissionSanitized<TPermission extends PermissionTypesWithCustom> = {
|
|
116
|
+
permissionResponse: PermissionResponseSanitized<TPermission>;
|
|
126
117
|
siteOrigin: string;
|
|
127
|
-
|
|
128
|
-
* Flag indicating whether this permission has been revoked.
|
|
129
|
-
*/
|
|
130
|
-
isRevoked?: boolean;
|
|
118
|
+
revocationMetadata?: RevocationMetadata;
|
|
131
119
|
};
|
|
132
120
|
/**
|
|
133
121
|
* Represents a map of gator permissions by chainId and permission type.
|
|
134
122
|
*/
|
|
135
123
|
export type GatorPermissionsMap = {
|
|
136
124
|
'erc20-token-revocation': {
|
|
137
|
-
[chainId: Hex]: StoredGatorPermissionSanitized<
|
|
125
|
+
[chainId: Hex]: StoredGatorPermissionSanitized<Erc20TokenRevocationPermission>[];
|
|
138
126
|
};
|
|
139
127
|
'native-token-stream': {
|
|
140
|
-
[chainId: Hex]: StoredGatorPermissionSanitized<
|
|
128
|
+
[chainId: Hex]: StoredGatorPermissionSanitized<NativeTokenStreamPermission>[];
|
|
141
129
|
};
|
|
142
130
|
'native-token-periodic': {
|
|
143
|
-
[chainId: Hex]: StoredGatorPermissionSanitized<
|
|
131
|
+
[chainId: Hex]: StoredGatorPermissionSanitized<NativeTokenPeriodicPermission>[];
|
|
144
132
|
};
|
|
145
133
|
'erc20-token-stream': {
|
|
146
|
-
[chainId: Hex]: StoredGatorPermissionSanitized<
|
|
134
|
+
[chainId: Hex]: StoredGatorPermissionSanitized<Erc20TokenStreamPermission>[];
|
|
147
135
|
};
|
|
148
136
|
'erc20-token-periodic': {
|
|
149
|
-
[chainId: Hex]: StoredGatorPermissionSanitized<
|
|
137
|
+
[chainId: Hex]: StoredGatorPermissionSanitized<Erc20TokenPeriodicPermission>[];
|
|
150
138
|
};
|
|
151
139
|
other: {
|
|
152
|
-
[chainId: Hex]: StoredGatorPermissionSanitized<
|
|
140
|
+
[chainId: Hex]: StoredGatorPermissionSanitized<CustomPermission>[];
|
|
153
141
|
};
|
|
154
142
|
};
|
|
155
143
|
/**
|
|
@@ -169,13 +157,24 @@ export type GatorPermissionsListByPermissionTypeAndChainId<TPermissionType exten
|
|
|
169
157
|
*/
|
|
170
158
|
export type DelegationDetails = Pick<Delegation<Hex>, 'caveats' | 'delegator' | 'delegate' | 'authority'>;
|
|
171
159
|
/**
|
|
172
|
-
* Represents the
|
|
160
|
+
* Represents the metadata for confirmed transaction revocation.
|
|
161
|
+
*/
|
|
162
|
+
export type RevocationMetadata = {
|
|
163
|
+
recordedAt: number;
|
|
164
|
+
txHash?: Hex | undefined;
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Parameters for the `permissionsProvider_submitRevocation` method
|
|
173
168
|
*/
|
|
174
169
|
export type RevocationParams = {
|
|
175
170
|
/**
|
|
176
171
|
* The permission context as a hex string that identifies the permission to revoke.
|
|
177
172
|
*/
|
|
178
173
|
permissionContext: Hex;
|
|
174
|
+
/**
|
|
175
|
+
* The hash of the transaction that was used to revoke the permission. Optional because we might not have submitted the transaction ourselves.
|
|
176
|
+
*/
|
|
177
|
+
txHash: Hex | undefined;
|
|
179
178
|
};
|
|
180
179
|
/**
|
|
181
180
|
* Represents the parameters for adding a pending revocation.
|