@metamask-previews/gator-permissions-controller 0.0.0-preview-2a00636 → 0.1.0-preview-d71561e3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"mocks.d.mts","sourceRoot":"","sources":["../../src/test/mocks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,4BAA4B,EAC5B,0BAA0B,EAC1B,6BAA6B,EAC7B,2BAA2B,EAC3B,eAAe,EACf,qBAAqB,EACtB,qBAAiB;AAElB,eAAO,MAAM,iCAAiC,YACnC,GAAG,KACX,sBAAsB,aAAa,EAAE,2BAA2B,CAkCjE,CAAC;AAEH,eAAO,MAAM,mCAAmC,YACrC,GAAG,KACX,sBAAsB,aAAa,EAAE,6BAA6B,CAiCnE,CAAC;AAEH,eAAO,MAAM,gCAAgC,YAClC,GAAG,KACX,sBAAsB,aAAa,EAAE,0BAA0B,CAmChE,CAAC;AAEH,eAAO,MAAM,kCAAkC,YACpC,GAAG,KACX,sBAAsB,aAAa,EAAE,4BAA4B,CAkClE,CAAC;AAEH,eAAO,MAAM,gCAAgC,YAClC,GAAG,QACN,OAAO,MAAM,EAAE,OAAO,CAAC,KAC5B,sBAAsB,aAAa,EAAE,gBAAgB,CA+BtD,CAAC;AAEH,MAAM,MAAM,wCAAwC,GAAG;IACrD,CAAC,OAAO,EAAE,MAAM,GAAG;QACjB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,mBAAmB,EAAE,MAAM,CAAC;QAC5B,gBAAgB,EAAE,MAAM,CAAC;QACzB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,MAAM,EAAE;YACN,KAAK,EAAE,MAAM,CAAC;YACd,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;SACjC,CAAC;KACH,CAAC;CACH,CAA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CAAC;KACH,CAAC;CACH,CAAC;AAEF;;;;;GAKG;AACH;;;;;GAKG;AACH,wBAAgB,yCAAyC,CACvD,MAAM,EAAE,wCAAwC,GAC/C,qBAAqB,CAAC,aAAa,EAAE,yBAAyB,CAAC,EAAE,CAyDnE"}
@@ -2,14 +2,13 @@ export const mockNativeTokenStreamStorageEntry = (chainId) => ({
2
2
  permissionResponse: {
3
3
  chainId: chainId,
4
4
  address: '0xB68c70159E9892DdF5659ec42ff9BD2bbC23e778',
5
- expiry: 1750291201,
6
- isAdjustmentAllowed: true,
7
5
  signer: {
8
6
  type: 'account',
9
7
  data: { address: '0x4f71DA06987BfeDE90aF0b33E1e3e4ffDCEE7a63' },
10
8
  },
11
9
  permission: {
12
10
  type: 'native-token-stream',
11
+ isAdjustmentAllowed: true,
13
12
  data: {
14
13
  maxAmount: '0x22b1c8c1227a0000',
15
14
  initialAmount: '0x6f05b59d3b20000',
@@ -17,10 +16,9 @@ export const mockNativeTokenStreamStorageEntry = (chainId) => ({
17
16
  startTime: 1747699200,
18
17
  justification: 'This is a very important request for streaming allowance for some very important thing',
19
18
  },
20
- rules: {},
21
19
  },
22
20
  context: '0x00000000',
23
- accountMeta: [
21
+ dependencyInfo: [
24
22
  {
25
23
  factory: '0x69Aa2f9fe1572F1B640E1bbc512f5c3a734fc77c',
26
24
  factoryData: '0x0000000',
@@ -36,24 +34,22 @@ export const mockNativeTokenPeriodicStorageEntry = (chainId) => ({
36
34
  permissionResponse: {
37
35
  chainId: chainId,
38
36
  address: '0xB68c70159E9892DdF5659ec42ff9BD2bbC23e778',
39
- expiry: 1850291200,
40
- isAdjustmentAllowed: true,
41
37
  signer: {
42
38
  type: 'account',
43
39
  data: { address: '0x4f71DA06987BfeDE90aF0b33E1e3e4ffDCEE7a63' },
44
40
  },
45
41
  permission: {
46
42
  type: 'native-token-periodic',
43
+ isAdjustmentAllowed: true,
47
44
  data: {
48
45
  periodAmount: '0x22b1c8c1227a0000',
49
46
  periodDuration: 1747699200,
50
47
  startTime: 1747699200,
51
48
  justification: 'This is a very important request for streaming allowance for some very important thing',
52
49
  },
53
- rules: {},
54
50
  },
55
51
  context: '0x00000000',
56
- accountMeta: [
52
+ dependencyInfo: [
57
53
  {
58
54
  factory: '0x69Aa2f9fe1572F1B640E1bbc512f5c3a734fc77c',
59
55
  factoryData: '0x0000000',
@@ -69,14 +65,13 @@ export const mockErc20TokenStreamStorageEntry = (chainId) => ({
69
65
  permissionResponse: {
70
66
  chainId: chainId,
71
67
  address: '0xB68c70159E9892DdF5659ec42ff9BD2bbC23e778',
72
- expiry: 1750298200,
73
- isAdjustmentAllowed: true,
74
68
  signer: {
75
69
  type: 'account',
76
70
  data: { address: '0x4f71DA06987BfeDE90aF0b33E1e3e4ffDCEE7a63' },
77
71
  },
78
72
  permission: {
79
73
  type: 'erc20-token-stream',
74
+ isAdjustmentAllowed: true,
80
75
  data: {
81
76
  initialAmount: '0x22b1c8c1227a0000',
82
77
  maxAmount: '0x6f05b59d3b20000',
@@ -85,10 +80,9 @@ export const mockErc20TokenStreamStorageEntry = (chainId) => ({
85
80
  tokenAddress: '0xB68c70159E9892DdF5659ec42ff9BD2bbC23e778',
86
81
  justification: 'This is a very important request for streaming allowance for some very important thing',
87
82
  },
88
- rules: {},
89
83
  },
90
84
  context: '0x00000000',
91
- accountMeta: [
85
+ dependencyInfo: [
92
86
  {
93
87
  factory: '0x69Aa2f9fe1572F1B640E1bbc512f5c3a734fc77c',
94
88
  factoryData: '0x0000000',
@@ -104,14 +98,13 @@ export const mockErc20TokenPeriodicStorageEntry = (chainId) => ({
104
98
  permissionResponse: {
105
99
  chainId: chainId,
106
100
  address: '0xB68c70159E9892DdF5659ec42ff9BD2bbC23e778',
107
- expiry: 1750291600,
108
- isAdjustmentAllowed: true,
109
101
  signer: {
110
102
  type: 'account',
111
103
  data: { address: '0x4f71DA06987BfeDE90aF0b33E1e3e4ffDCEE7a63' },
112
104
  },
113
105
  permission: {
114
106
  type: 'erc20-token-periodic',
107
+ isAdjustmentAllowed: true,
115
108
  data: {
116
109
  periodAmount: '0x22b1c8c1227a0000',
117
110
  periodDuration: 1747699200,
@@ -119,10 +112,9 @@ export const mockErc20TokenPeriodicStorageEntry = (chainId) => ({
119
112
  tokenAddress: '0xB68c70159E9892DdF5659ec42ff9BD2bbC23e778',
120
113
  justification: 'This is a very important request for streaming allowance for some very important thing',
121
114
  },
122
- rules: {},
123
115
  },
124
116
  context: '0x00000000',
125
- accountMeta: [
117
+ dependencyInfo: [
126
118
  {
127
119
  factory: '0x69Aa2f9fe1572F1B640E1bbc512f5c3a734fc77c',
128
120
  factoryData: '0x0000000',
@@ -138,22 +130,20 @@ export const mockCustomPermissionStorageEntry = (chainId, data) => ({
138
130
  permissionResponse: {
139
131
  chainId: chainId,
140
132
  address: '0xB68c70159E9892DdF5659ec42ff9BD2bbC23e778',
141
- expiry: 1750291200,
142
- isAdjustmentAllowed: true,
143
133
  signer: {
144
134
  type: 'account',
145
135
  data: { address: '0x4f71DA06987BfeDE90aF0b33E1e3e4ffDCEE7a63' },
146
136
  },
147
137
  permission: {
148
138
  type: 'custom',
139
+ isAdjustmentAllowed: true,
149
140
  data: {
150
141
  justification: 'This is a very important request for streaming allowance for some very important thing',
151
142
  ...data,
152
143
  },
153
- rules: {},
154
144
  },
155
145
  context: '0x00000000',
156
- accountMeta: [
146
+ dependencyInfo: [
157
147
  {
158
148
  factory: '0x69Aa2f9fe1572F1B640E1bbc512f5c3a734fc77c',
159
149
  factoryData: '0x0000000',
@@ -179,7 +169,6 @@ export const mockCustomPermissionStorageEntry = (chainId, data) => ({
179
169
  */
180
170
  export function mockGatorPermissionsStorageEntriesFactory(config) {
181
171
  const result = [];
182
- let globalIndex = 0;
183
172
  Object.entries(config).forEach(([chainId, counts]) => {
184
173
  if (counts.custom.count !== counts.custom.data.length) {
185
174
  throw new Error('Custom permission count and data length mismatch');
@@ -193,9 +182,7 @@ export function mockGatorPermissionsStorageEntriesFactory(config) {
193
182
  const createEntries = (count, createEntry) => {
194
183
  for (let i = 0; i < count; i++) {
195
184
  const entry = createEntry();
196
- entry.permissionResponse.expiry += globalIndex;
197
185
  result.push(entry);
198
- globalIndex += 1;
199
186
  }
200
187
  };
201
188
  createEntries(counts.nativeTokenStream, () => mockNativeTokenStreamStorageEntry(chainId));
@@ -205,9 +192,7 @@ export function mockGatorPermissionsStorageEntriesFactory(config) {
205
192
  // Create custom entries
206
193
  for (let i = 0; i < counts.custom.count; i++) {
207
194
  const entry = mockCustomPermissionStorageEntry(chainId, counts.custom.data[i]);
208
- entry.permissionResponse.expiry += globalIndex;
209
195
  result.push(entry);
210
- globalIndex += 1;
211
196
  }
212
197
  });
213
198
  return result;
@@ -1 +1 @@
1
- {"version":3,"file":"mocks.mjs","sourceRoot":"","sources":["../../src/test/mocks.ts"],"names":[],"mappings":"AAaA,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAC/C,OAAY,EACuD,EAAE,CAAC,CAAC;IACvE,kBAAkB,EAAE;QAClB,OAAO,EAAE,OAAc;QACvB,OAAO,EAAE,4CAA4C;QACrD,MAAM,EAAE,UAAU;QAClB,mBAAmB,EAAE,IAAI;QACzB,MAAM,EAAE;YACN,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,EAAE,OAAO,EAAE,4CAA4C,EAAE;SAChE;QACD,UAAU,EAAE;YACV,IAAI,EAAE,qBAAqB;YAC3B,IAAI,EAAE;gBACJ,SAAS,EAAE,oBAAoB;gBAC/B,aAAa,EAAE,mBAAmB;gBAClC,eAAe,EAAE,mBAAmB;gBACpC,SAAS,EAAE,UAAU;gBACrB,aAAa,EACX,wFAAwF;aAC3F;YACD,KAAK,EAAE,EAAE;SACV;QACD,OAAO,EAAE,YAAY;QACrB,WAAW,EAAE;YACX;gBACE,OAAO,EAAE,4CAA4C;gBACrD,WAAW,EAAE,WAAW;aACzB;SACF;QACD,UAAU,EAAE;YACV,iBAAiB,EAAE,4CAA4C;SAChE;KACF;IACD,UAAU,EAAE,uBAAuB;CACpC,CAA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AAiC,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;YAC5C,MAAM,KAAK,GAAG,gCAAgC,CAC5C,OAAc,EACd,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CACtB,CAAC;YACF,KAAK,CAAC,kBAAkB,CAAC,MAAM,IAAI,WAAW,CAAC;YAC/C,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACnB,WAAW,IAAI,CAAC,CAAC;SAClB;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { Hex } from '@metamask/utils';\n\nimport type {\n AccountSigner,\n CustomPermission,\n Erc20TokenPeriodicPermission,\n Erc20TokenStreamPermission,\n NativeTokenPeriodicPermission,\n NativeTokenStreamPermission,\n PermissionTypes,\n StoredGatorPermission,\n} from '../types';\n\nexport const mockNativeTokenStreamStorageEntry = (\n chainId: Hex,\n): StoredGatorPermission<AccountSigner, NativeTokenStreamPermission> => ({\n permissionResponse: {\n chainId: chainId as Hex,\n address: '0xB68c70159E9892DdF5659ec42ff9BD2bbC23e778',\n expiry: 1750291201,\n isAdjustmentAllowed: true,\n signer: {\n type: 'account',\n data: { address: '0x4f71DA06987BfeDE90aF0b33E1e3e4ffDCEE7a63' },\n },\n permission: {\n type: 'native-token-stream',\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 rules: {},\n },\n context: '0x00000000',\n accountMeta: [\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: chainId as Hex,\n address: '0xB68c70159E9892DdF5659ec42ff9BD2bbC23e778',\n expiry: 1850291200,\n isAdjustmentAllowed: true,\n signer: {\n type: 'account',\n data: { address: '0x4f71DA06987BfeDE90aF0b33E1e3e4ffDCEE7a63' },\n },\n permission: {\n type: 'native-token-periodic',\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 rules: {},\n },\n context: '0x00000000',\n accountMeta: [\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: chainId as Hex,\n address: '0xB68c70159E9892DdF5659ec42ff9BD2bbC23e778',\n expiry: 1750298200,\n isAdjustmentAllowed: true,\n signer: {\n type: 'account',\n data: { address: '0x4f71DA06987BfeDE90aF0b33E1e3e4ffDCEE7a63' },\n },\n permission: {\n type: 'erc20-token-stream',\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 rules: {},\n },\n context: '0x00000000',\n accountMeta: [\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: chainId as Hex,\n address: '0xB68c70159E9892DdF5659ec42ff9BD2bbC23e778',\n expiry: 1750291600,\n isAdjustmentAllowed: true,\n signer: {\n type: 'account',\n data: { address: '0x4f71DA06987BfeDE90aF0b33E1e3e4ffDCEE7a63' },\n },\n permission: {\n type: 'erc20-token-periodic',\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 rules: {},\n },\n context: '0x00000000',\n accountMeta: [\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: chainId as Hex,\n address: '0xB68c70159E9892DdF5659ec42ff9BD2bbC23e778',\n expiry: 1750291200,\n isAdjustmentAllowed: true,\n signer: {\n type: 'account',\n data: { address: '0x4f71DA06987BfeDE90aF0b33E1e3e4ffDCEE7a63' },\n },\n permission: {\n type: 'custom',\n data: {\n justification:\n 'This is a very important request for streaming allowance for some very important thing',\n ...data,\n },\n rules: {},\n },\n context: '0x00000000',\n accountMeta: [\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, PermissionTypes>[] {\n const result: StoredGatorPermission<AccountSigner, PermissionTypes>[] = [];\n let globalIndex = 0;\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<AccountSigner, PermissionTypes>,\n ) => {\n for (let i = 0; i < count; i++) {\n const entry = createEntry();\n entry.permissionResponse.expiry += globalIndex;\n result.push(entry);\n globalIndex += 1;\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 entry.permissionResponse.expiry += globalIndex;\n result.push(entry);\n globalIndex += 1;\n }\n });\n\n return result;\n}\n"]}
1
+ {"version":3,"file":"mocks.mjs","sourceRoot":"","sources":["../../src/test/mocks.ts"],"names":[],"mappings":"AAeA,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAC/C,OAAY,EACuD,EAAE,CAAC,CAAC;IACvE,kBAAkB,EAAE;QAClB,OAAO,EAAE,OAAc;QACvB,OAAO,EAAE,4CAA4C;QACrD,MAAM,EAAE;YACN,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,EAAE,OAAO,EAAE,4CAA4C,EAAE;SAChE;QACD,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,cAAc,EAAE;YACd;gBACE,OAAO,EAAE,4CAA4C;gBACrD,WAAW,EAAE,WAAW;aACzB;SACF;QACD,UAAU,EAAE;YACV,iBAAiB,EAAE,4CAA4C;SAChE;KACF;IACD,UAAU,EAAE,uBAAuB;CACpC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mCAA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ACxB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;YAC5C,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;SACpB;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: chainId as Hex,\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: chainId as Hex,\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: chainId as Hex,\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: chainId as Hex,\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: chainId as Hex,\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 +1 @@
1
- {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,IAAY,mCAKX;AALD,WAAY,mCAAmC;IAC7C,mGAA4D,CAAA;IAC5D,mGAA4D,CAAA;IAC5D,yGAAkE,CAAA;IAClE,0HAAmF,CAAA;AACrF,CAAC,EALW,mCAAmC,mDAAnC,mCAAmC,QAK9C;AAED;;GAEG;AACH,IAAY,6BAKX;AALD,WAAY,6BAA6B;IACvC;;OAEG;IACH,sHAAqF,CAAA;AACvF,CAAC,EALW,6BAA6B,6CAA7B,6BAA6B,QAKxC","sourcesContent":["import 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}\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\ntype BasePermission = {\n type: string;\n\n /**\n * Data structure varies by permission type.\n */\n data: Record<string, unknown>;\n\n /**\n * set of restrictions or conditions that a signer must abide by when redeeming a Permission.\n */\n rules?: Record<string, unknown>;\n};\n\nexport type MetaMaskBasePermissionData = {\n /**\n * A human-readable explanation of why the permission is being requested.\n */\n justification: string;\n};\n\nexport type NativeTokenStreamPermission = BasePermission & {\n type: 'native-token-stream';\n data: MetaMaskBasePermissionData & {\n initialAmount?: Hex;\n maxAmount?: Hex;\n amountPerSecond: Hex;\n startTime: number;\n };\n};\n\nexport type NativeTokenPeriodicPermission = BasePermission & {\n type: 'native-token-periodic';\n data: MetaMaskBasePermissionData & {\n periodAmount: Hex;\n periodDuration: number;\n startTime: number;\n };\n};\n\nexport type Erc20TokenStreamPermission = BasePermission & {\n type: 'erc20-token-stream';\n data: MetaMaskBasePermissionData & {\n initialAmount?: Hex;\n maxAmount?: Hex;\n amountPerSecond: Hex;\n startTime: number;\n tokenAddress: Hex;\n };\n};\n\nexport type Erc20TokenPeriodicPermission = BasePermission & {\n type: 'erc20-token-periodic';\n data: MetaMaskBasePermissionData & {\n periodAmount: Hex;\n periodDuration: number;\n startTime: number;\n tokenAddress: Hex;\n };\n};\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.\n */\nexport type PermissionTypes =\n | NativeTokenStreamPermission\n | NativeTokenPeriodicPermission\n | Erc20TokenStreamPermission\n | Erc20TokenPeriodicPermission\n | CustomPermission;\n\n/**\n * Represents an ERC-7715 account signer type.\n */\nexport type AccountSigner = {\n type: 'account';\n data: {\n address: Hex;\n };\n};\n\n/**\n * Represents an ERC-7715 wallet signer type.\n *\n */\nexport type WalletSigner = {\n type: 'wallet';\n data: Record<string, unknown>;\n};\n\nexport type SignerParam = AccountSigner | WalletSigner;\n\n/**\n * Represents a ERC-7715 permission request.\n *\n * @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.\n * @template Permission - The type of the permission provided.\n */\nexport type PermissionRequest<\n TSigner extends SignerParam,\n TPermission extends PermissionTypes,\n> = {\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 address?: Hex;\n\n /**\n * unix timestamp in seconds\n */\n expiry: number;\n\n /**\n * Boolean value that allows DApp to define whether the permission can be attenuated–adjusted to meet the user’s terms.\n */\n isAdjustmentAllowed: boolean;\n\n /**\n * An account that is associated with the recipient of the granted 7715 permission or alternatively the wallet will manage the session.\n */\n signer: TSigner;\n\n /**\n * Defines the allowed behavior the signer can do on behalf of the account.\n */\n permission: TPermission;\n};\n\n/**\n * Represents a ERC-7715 permission response.\n *\n * @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.\n * @template Permission - The type of the permission provided.\n */\nexport type PermissionResponse<\n TSigner extends SignerParam,\n TPermission extends PermissionTypes,\n> = PermissionRequest<TSigner, 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 accountMeta 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 accountMeta: {\n factory: Hex;\n factoryData: Hex;\n }[];\n\n /**\n * If the signer type is account then delegationManager is required as defined in ERC-7710.\n */\n signerMeta: {\n delegationManager: Hex;\n };\n};\n\n/**\n * Represents a sanitized version of the PermissionResponse type.\n * Some fields have been removed but the fields are still present in profile sync.\n *\n * @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.\n * @template Permission - The type of the permission provided.\n */\nexport type PermissionResponseSanitized<\n TSigner extends SignerParam,\n TPermission extends PermissionTypes,\n> = Omit<\n PermissionResponse<TSigner, TPermission>,\n 'isAdjustmentAllowed' | 'accountMeta' | 'signer'\n>;\n\n/**\n * Represents a gator ERC-7715 granted(ie. signed by an user account) permission entry that is stored in profile sync.\n *\n * @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.\n * @template Permission - The type of the permission provided\n */\nexport type StoredGatorPermission<\n TSigner extends SignerParam,\n TPermission extends PermissionTypes,\n> = {\n permissionResponse: PermissionResponse<TSigner, TPermission>;\n siteOrigin: string;\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 Signer - The type of the signer provided, either an AccountSigner or WalletSigner.\n * @template Permission - The type of the permission provided.\n */\nexport type StoredGatorPermissionSanitized<\n TSigner extends SignerParam,\n TPermission extends PermissionTypes,\n> = {\n permissionResponse: PermissionResponseSanitized<TSigner, TPermission>;\n siteOrigin: string;\n};\n\n/**\n * Represents a map of gator permissions by chainId and permission type.\n */\nexport type GatorPermissionsMap = {\n 'native-token-stream': {\n [chainId: Hex]: StoredGatorPermissionSanitized<\n SignerParam,\n NativeTokenStreamPermission\n >[];\n };\n 'native-token-periodic': {\n [chainId: Hex]: StoredGatorPermissionSanitized<\n SignerParam,\n NativeTokenPeriodicPermission\n >[];\n };\n 'erc20-token-stream': {\n [chainId: Hex]: StoredGatorPermissionSanitized<\n SignerParam,\n Erc20TokenStreamPermission\n >[];\n };\n 'erc20-token-periodic': {\n [chainId: Hex]: StoredGatorPermissionSanitized<\n SignerParam,\n Erc20TokenPeriodicPermission\n >[];\n };\n other: {\n [chainId: Hex]: StoredGatorPermissionSanitized<\n SignerParam,\n CustomPermission\n >[];\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"]}
1
+ {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAaA;;GAEG;AACH,IAAY,mCAKX;AALD,WAAY,mCAAmC;IAC7C,mGAA4D,CAAA;IAC5D,mGAA4D,CAAA;IAC5D,yGAAkE,CAAA;IAClE,0HAAmF,CAAA;AACrF,CAAC,EALW,mCAAmC,mDAAnC,mCAAmC,QAK9C;AAED;;GAEG;AACH,IAAY,6BAKX;AALD,WAAY,6BAA6B;IACvC;;OAEG;IACH,sHAAqF,CAAA;AACvF,CAAC,EALW,6BAA6B,6CAA7B,6BAA6B,QAKxC","sourcesContent":["import type {\n PermissionTypes,\n Signer,\n BasePermission,\n NativeTokenStreamPermission,\n NativeTokenPeriodicPermission,\n Erc20TokenStreamPermission,\n Erc20TokenPeriodicPermission,\n Rule,\n MetaMaskBasePermissionData,\n} from '@metamask/7715-permission-types';\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}\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\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 Signer - The type of the signer provided, either an AccountSigner or WalletSigner.\n * @template Permission - The type of the permission provided.\n */\nexport type PermissionRequest<\n TSigner extends Signer,\n TPermission extends PermissionTypesWithCustom,\n> = {\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 address?: Hex;\n\n /**\n * An account that is associated with the recipient of the granted 7715 permission or alternatively the wallet will manage the session.\n */\n signer: TSigner;\n\n /**\n * Defines the allowed behavior the signer can do on behalf of the account.\n */\n permission: TPermission;\n\n rules?: Rule[] | null;\n};\n\n/**\n * Represents a ERC-7715 permission response.\n *\n * @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.\n * @template Permission - The type of the permission provided.\n */\nexport type PermissionResponse<\n TSigner extends Signer,\n TPermission extends PermissionTypesWithCustom,\n> = PermissionRequest<TSigner, 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 dependencyInfo: {\n factory: Hex;\n factoryData: Hex;\n }[];\n\n /**\n * If the signer type is account then delegationManager is required as defined in ERC-7710.\n */\n signerMeta: {\n delegationManager: Hex;\n };\n};\n\n/**\n * Represents a sanitized version of the PermissionResponse type.\n * Some fields have been removed but the fields are still present in profile sync.\n *\n * @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.\n * @template Permission - The type of the permission provided.\n */\nexport type PermissionResponseSanitized<\n TSigner extends Signer,\n TPermission extends PermissionTypesWithCustom,\n> = Omit<\n PermissionResponse<TSigner, TPermission>,\n 'dependencyInfo' | 'signer' | 'rules'\n>;\n\n/**\n * Represents a gator ERC-7715 granted(ie. signed by an user account) permission entry that is stored in profile sync.\n *\n * @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.\n * @template Permission - The type of the permission provided\n */\nexport type StoredGatorPermission<\n TSigner extends Signer,\n TPermission extends PermissionTypesWithCustom,\n> = {\n permissionResponse: PermissionResponse<TSigner, TPermission>;\n siteOrigin: string;\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 Signer - The type of the signer provided, either an AccountSigner or WalletSigner.\n * @template Permission - The type of the permission provided.\n */\nexport type StoredGatorPermissionSanitized<\n TSigner extends Signer,\n TPermission extends PermissionTypesWithCustom,\n> = {\n permissionResponse: PermissionResponseSanitized<TSigner, TPermission>;\n siteOrigin: string;\n};\n\n/**\n * Represents a map of gator permissions by chainId and permission type.\n */\nexport type GatorPermissionsMap = {\n 'native-token-stream': {\n [chainId: Hex]: StoredGatorPermissionSanitized<\n Signer,\n NativeTokenStreamPermission\n >[];\n };\n 'native-token-periodic': {\n [chainId: Hex]: StoredGatorPermissionSanitized<\n Signer,\n NativeTokenPeriodicPermission\n >[];\n };\n 'erc20-token-stream': {\n [chainId: Hex]: StoredGatorPermissionSanitized<\n Signer,\n Erc20TokenStreamPermission\n >[];\n };\n 'erc20-token-periodic': {\n [chainId: Hex]: StoredGatorPermissionSanitized<\n Signer,\n Erc20TokenPeriodicPermission\n >[];\n };\n other: {\n [chainId: Hex]: StoredGatorPermissionSanitized<Signer, 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"]}
package/dist/types.d.cts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { PermissionTypes, Signer, BasePermission, NativeTokenStreamPermission, NativeTokenPeriodicPermission, Erc20TokenStreamPermission, Erc20TokenPeriodicPermission, Rule, MetaMaskBasePermissionData } from "@metamask/7715-permission-types";
1
2
  import type { Hex } from "@metamask/utils";
2
3
  /**
3
4
  * Enum for the error codes of the gator permissions controller.
@@ -17,92 +18,24 @@ export declare enum GatorPermissionsSnapRpcMethod {
17
18
  */
18
19
  PermissionProviderGetGrantedPermissions = "permissionsProvider_getGrantedPermissions"
19
20
  }
20
- type BasePermission = {
21
- type: string;
22
- /**
23
- * Data structure varies by permission type.
24
- */
25
- data: Record<string, unknown>;
26
- /**
27
- * set of restrictions or conditions that a signer must abide by when redeeming a Permission.
28
- */
29
- rules?: Record<string, unknown>;
30
- };
31
- export type MetaMaskBasePermissionData = {
32
- /**
33
- * A human-readable explanation of why the permission is being requested.
34
- */
35
- justification: string;
36
- };
37
- export type NativeTokenStreamPermission = BasePermission & {
38
- type: 'native-token-stream';
39
- data: MetaMaskBasePermissionData & {
40
- initialAmount?: Hex;
41
- maxAmount?: Hex;
42
- amountPerSecond: Hex;
43
- startTime: number;
44
- };
45
- };
46
- export type NativeTokenPeriodicPermission = BasePermission & {
47
- type: 'native-token-periodic';
48
- data: MetaMaskBasePermissionData & {
49
- periodAmount: Hex;
50
- periodDuration: number;
51
- startTime: number;
52
- };
53
- };
54
- export type Erc20TokenStreamPermission = BasePermission & {
55
- type: 'erc20-token-stream';
56
- data: MetaMaskBasePermissionData & {
57
- initialAmount?: Hex;
58
- maxAmount?: Hex;
59
- amountPerSecond: Hex;
60
- startTime: number;
61
- tokenAddress: Hex;
62
- };
63
- };
64
- export type Erc20TokenPeriodicPermission = BasePermission & {
65
- type: 'erc20-token-periodic';
66
- data: MetaMaskBasePermissionData & {
67
- periodAmount: Hex;
68
- periodDuration: number;
69
- startTime: number;
70
- tokenAddress: Hex;
71
- };
72
- };
21
+ /**
22
+ * Represents a custom permission that are not of the standard ERC-7715 permission types.
23
+ */
73
24
  export type CustomPermission = BasePermission & {
74
25
  type: 'custom';
75
26
  data: MetaMaskBasePermissionData & Record<string, unknown>;
76
27
  };
77
28
  /**
78
- * Represents the type of the ERC-7715 permissions that can be granted.
79
- */
80
- export type PermissionTypes = NativeTokenStreamPermission | NativeTokenPeriodicPermission | Erc20TokenStreamPermission | Erc20TokenPeriodicPermission | CustomPermission;
81
- /**
82
- * Represents an ERC-7715 account signer type.
29
+ * Represents the type of the ERC-7715 permissions that can be granted including custom permissions.
83
30
  */
84
- export type AccountSigner = {
85
- type: 'account';
86
- data: {
87
- address: Hex;
88
- };
89
- };
90
- /**
91
- * Represents an ERC-7715 wallet signer type.
92
- *
93
- */
94
- export type WalletSigner = {
95
- type: 'wallet';
96
- data: Record<string, unknown>;
97
- };
98
- export type SignerParam = AccountSigner | WalletSigner;
31
+ export type PermissionTypesWithCustom = PermissionTypes | CustomPermission;
99
32
  /**
100
33
  * Represents a ERC-7715 permission request.
101
34
  *
102
35
  * @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.
103
36
  * @template Permission - The type of the permission provided.
104
37
  */
105
- export type PermissionRequest<TSigner extends SignerParam, TPermission extends PermissionTypes> = {
38
+ export type PermissionRequest<TSigner extends Signer, TPermission extends PermissionTypesWithCustom> = {
106
39
  /**
107
40
  * hex-encoding of uint256 defined the chain with EIP-155
108
41
  */
@@ -113,14 +46,6 @@ export type PermissionRequest<TSigner extends SignerParam, TPermission extends P
113
46
  * It is optional to let the user choose which account to grant permission from.
114
47
  */
115
48
  address?: Hex;
116
- /**
117
- * unix timestamp in seconds
118
- */
119
- expiry: number;
120
- /**
121
- * Boolean value that allows DApp to define whether the permission can be attenuated–adjusted to meet the user’s terms.
122
- */
123
- isAdjustmentAllowed: boolean;
124
49
  /**
125
50
  * An account that is associated with the recipient of the granted 7715 permission or alternatively the wallet will manage the session.
126
51
  */
@@ -129,6 +54,7 @@ export type PermissionRequest<TSigner extends SignerParam, TPermission extends P
129
54
  * Defines the allowed behavior the signer can do on behalf of the account.
130
55
  */
131
56
  permission: TPermission;
57
+ rules?: Rule[] | null;
132
58
  };
133
59
  /**
134
60
  * Represents a ERC-7715 permission response.
@@ -136,20 +62,20 @@ export type PermissionRequest<TSigner extends SignerParam, TPermission extends P
136
62
  * @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.
137
63
  * @template Permission - The type of the permission provided.
138
64
  */
139
- export type PermissionResponse<TSigner extends SignerParam, TPermission extends PermissionTypes> = PermissionRequest<TSigner, TPermission> & {
65
+ export type PermissionResponse<TSigner extends Signer, TPermission extends PermissionTypesWithCustom> = PermissionRequest<TSigner, TPermission> & {
140
66
  /**
141
67
  * Is a catch-all to identify a permission for revoking permissions or submitting
142
68
  * Defined in ERC-7710.
143
69
  */
144
70
  context: Hex;
145
71
  /**
146
- * The accountMeta field is required and contains information needed to deploy accounts.
72
+ * The dependencyInfo field is required and contains information needed to deploy accounts.
147
73
  * Each entry specifies a factory contract and its associated deployment data.
148
74
  * If no account deployment is needed when redeeming the permission, this array must be empty.
149
75
  * When non-empty, DApps MUST deploy the accounts by calling the factory contract with factoryData as the calldata.
150
76
  * Defined in ERC-4337.
151
77
  */
152
- accountMeta: {
78
+ dependencyInfo: {
153
79
  factory: Hex;
154
80
  factoryData: Hex;
155
81
  }[];
@@ -167,14 +93,14 @@ export type PermissionResponse<TSigner extends SignerParam, TPermission extends
167
93
  * @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.
168
94
  * @template Permission - The type of the permission provided.
169
95
  */
170
- export type PermissionResponseSanitized<TSigner extends SignerParam, TPermission extends PermissionTypes> = Omit<PermissionResponse<TSigner, TPermission>, 'isAdjustmentAllowed' | 'accountMeta' | 'signer'>;
96
+ export type PermissionResponseSanitized<TSigner extends Signer, TPermission extends PermissionTypesWithCustom> = Omit<PermissionResponse<TSigner, TPermission>, 'dependencyInfo' | 'signer' | 'rules'>;
171
97
  /**
172
98
  * Represents a gator ERC-7715 granted(ie. signed by an user account) permission entry that is stored in profile sync.
173
99
  *
174
100
  * @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.
175
101
  * @template Permission - The type of the permission provided
176
102
  */
177
- export type StoredGatorPermission<TSigner extends SignerParam, TPermission extends PermissionTypes> = {
103
+ export type StoredGatorPermission<TSigner extends Signer, TPermission extends PermissionTypesWithCustom> = {
178
104
  permissionResponse: PermissionResponse<TSigner, TPermission>;
179
105
  siteOrigin: string;
180
106
  };
@@ -184,7 +110,7 @@ export type StoredGatorPermission<TSigner extends SignerParam, TPermission exten
184
110
  * @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.
185
111
  * @template Permission - The type of the permission provided.
186
112
  */
187
- export type StoredGatorPermissionSanitized<TSigner extends SignerParam, TPermission extends PermissionTypes> = {
113
+ export type StoredGatorPermissionSanitized<TSigner extends Signer, TPermission extends PermissionTypesWithCustom> = {
188
114
  permissionResponse: PermissionResponseSanitized<TSigner, TPermission>;
189
115
  siteOrigin: string;
190
116
  };
@@ -193,19 +119,19 @@ export type StoredGatorPermissionSanitized<TSigner extends SignerParam, TPermiss
193
119
  */
194
120
  export type GatorPermissionsMap = {
195
121
  'native-token-stream': {
196
- [chainId: Hex]: StoredGatorPermissionSanitized<SignerParam, NativeTokenStreamPermission>[];
122
+ [chainId: Hex]: StoredGatorPermissionSanitized<Signer, NativeTokenStreamPermission>[];
197
123
  };
198
124
  'native-token-periodic': {
199
- [chainId: Hex]: StoredGatorPermissionSanitized<SignerParam, NativeTokenPeriodicPermission>[];
125
+ [chainId: Hex]: StoredGatorPermissionSanitized<Signer, NativeTokenPeriodicPermission>[];
200
126
  };
201
127
  'erc20-token-stream': {
202
- [chainId: Hex]: StoredGatorPermissionSanitized<SignerParam, Erc20TokenStreamPermission>[];
128
+ [chainId: Hex]: StoredGatorPermissionSanitized<Signer, Erc20TokenStreamPermission>[];
203
129
  };
204
130
  'erc20-token-periodic': {
205
- [chainId: Hex]: StoredGatorPermissionSanitized<SignerParam, Erc20TokenPeriodicPermission>[];
131
+ [chainId: Hex]: StoredGatorPermissionSanitized<Signer, Erc20TokenPeriodicPermission>[];
206
132
  };
207
133
  other: {
208
- [chainId: Hex]: StoredGatorPermissionSanitized<SignerParam, CustomPermission>[];
134
+ [chainId: Hex]: StoredGatorPermissionSanitized<Signer, CustomPermission>[];
209
135
  };
210
136
  };
211
137
  /**
@@ -220,5 +146,4 @@ export type GatorPermissionsMapByPermissionType<TPermissionType extends Supporte
220
146
  * Represents an array of gator permissions for a given permission type and chainId.
221
147
  */
222
148
  export type GatorPermissionsListByPermissionTypeAndChainId<TPermissionType extends SupportedGatorPermissionType> = GatorPermissionsMap[TPermissionType][Hex];
223
- export {};
224
149
  //# sourceMappingURL=types.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C;;GAEG;AACH,oBAAY,mCAAmC;IAC7C,0BAA0B,kCAAkC;IAC5D,0BAA0B,kCAAkC;IAC5D,6BAA6B,qCAAqC;IAClE,qCAAqC,8CAA8C;CACpF;AAED;;GAEG;AACH,oBAAY,6BAA6B;IACvC;;OAEG;IACH,uCAAuC,8CAA8C;CACtF;AAED,KAAK,cAAc,GAAG;IACpB,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE9B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG,cAAc,GAAG;IACzD,IAAI,EAAE,qBAAqB,CAAC;IAC5B,IAAI,EAAE,0BAA0B,GAAG;QACjC,aAAa,CAAC,EAAE,GAAG,CAAC;QACpB,SAAS,CAAC,EAAE,GAAG,CAAC;QAChB,eAAe,EAAE,GAAG,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG,cAAc,GAAG;IAC3D,IAAI,EAAE,uBAAuB,CAAC;IAC9B,IAAI,EAAE,0BAA0B,GAAG;QACjC,YAAY,EAAE,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