@bloxchain/sdk 1.0.0-alpha.2 → 1.0.0-alpha.20
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/README.md +376 -376
- package/abi/AccountBlox.abi.json +609 -2479
- package/abi/BareBlox.abi.json +94 -0
- package/abi/BaseStateMachine.abi.json +85 -45
- package/abi/CopyBlox.abi.json +1593 -0
- package/abi/EngineBlox.abi.json +73 -90
- package/abi/GuardController.abi.json +252 -806
- package/abi/GuardControllerDefinitions.abi.json +411 -0
- package/abi/IDefinition.abi.json +5 -0
- package/abi/RoleBlox.abi.json +375 -1590
- package/abi/RuntimeRBAC.abi.json +155 -218
- package/abi/RuntimeRBACDefinitions.abi.json +179 -0
- package/abi/SecureBlox.abi.json +436 -1511
- package/abi/SecureOwnable.abi.json +524 -1621
- package/abi/SecureOwnableDefinitions.abi.json +5 -0
- package/abi/SimpleRWA20.abi.json +478 -1756
- package/abi/SimpleRWA20Definitions.abi.json +5 -0
- package/abi/SimpleVault.abi.json +648 -2214
- package/abi/SimpleVaultDefinitions.abi.json +5 -0
- package/dist/abi/AccountBlox.abi.json +3929 -0
- package/dist/abi/BareBlox.abi.json +1378 -0
- package/dist/abi/BaseStateMachine.abi.json +1213 -1173
- package/dist/abi/CopyBlox.abi.json +1593 -0
- package/dist/abi/EngineBlox.abi.json +855 -0
- package/dist/abi/GuardController.abi.json +2222 -2776
- package/dist/abi/GuardControllerDefinitions.abi.json +411 -0
- package/dist/abi/IDefinition.abi.json +113 -108
- package/dist/abi/RoleBlox.abi.json +2994 -0
- package/dist/abi/RuntimeRBAC.abi.json +1540 -1603
- package/dist/abi/RuntimeRBACDefinitions.abi.json +381 -0
- package/dist/abi/SecureBlox.abi.json +2753 -0
- package/dist/abi/SecureOwnable.abi.json +2585 -3682
- package/dist/abi/SecureOwnableDefinitions.abi.json +416 -0
- package/dist/abi/SimpleRWA20.abi.json +4010 -0
- package/dist/abi/SimpleRWA20Definitions.abi.json +196 -0
- package/dist/abi/SimpleVault.abi.json +3385 -0
- package/dist/abi/SimpleVaultDefinitions.abi.json +274 -0
- package/dist/abi.d.ts +11 -0
- package/dist/abi.d.ts.map +1 -0
- package/dist/abi.js +10 -0
- package/dist/abi.js.map +1 -0
- package/dist/contracts/{BaseStateMachine.d.ts → core/BaseStateMachine.d.ts} +20 -6
- package/dist/contracts/core/BaseStateMachine.d.ts.map +1 -0
- package/dist/contracts/{BaseStateMachine.js → core/BaseStateMachine.js} +88 -38
- package/dist/contracts/core/BaseStateMachine.js.map +1 -0
- package/dist/contracts/{GuardController.d.ts → core/GuardController.d.ts} +22 -15
- package/dist/contracts/core/GuardController.d.ts.map +1 -0
- package/dist/contracts/{GuardController.js → core/GuardController.js} +19 -21
- package/dist/contracts/core/GuardController.js.map +1 -0
- package/dist/contracts/core/RuntimeRBAC.d.ts +27 -0
- package/dist/contracts/core/RuntimeRBAC.d.ts.map +1 -0
- package/dist/contracts/core/RuntimeRBAC.js +33 -0
- package/dist/contracts/core/RuntimeRBAC.js.map +1 -0
- package/dist/contracts/{SecureOwnable.d.ts → core/SecureOwnable.d.ts} +5 -15
- package/dist/contracts/core/SecureOwnable.d.ts.map +1 -0
- package/dist/contracts/{SecureOwnable.js → core/SecureOwnable.js} +4 -23
- package/dist/contracts/core/SecureOwnable.js.map +1 -0
- package/dist/index.d.ts +8 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/interfaces/base.index.d.ts +10 -2
- package/dist/interfaces/base.index.d.ts.map +1 -1
- package/dist/interfaces/base.state.machine.index.d.ts +3 -2
- package/dist/interfaces/base.state.machine.index.d.ts.map +1 -1
- package/dist/interfaces/core.access.index.d.ts +2 -16
- package/dist/interfaces/core.access.index.d.ts.map +1 -1
- package/dist/interfaces/core.execution.index.d.ts +8 -11
- package/dist/interfaces/core.execution.index.d.ts.map +1 -1
- package/dist/interfaces/core.security.index.d.ts +1 -4
- package/dist/interfaces/core.security.index.d.ts.map +1 -1
- package/dist/lib/Definition.d.ts.map +1 -1
- package/dist/lib/Definition.js +1 -0
- package/dist/lib/Definition.js.map +1 -1
- package/dist/lib/EngineBlox.d.ts +16 -49
- package/dist/lib/EngineBlox.d.ts.map +1 -1
- package/dist/lib/EngineBlox.js +20 -108
- package/dist/lib/EngineBlox.js.map +1 -1
- package/dist/lib/definitions/GuardControllerDefinitions.d.ts +34 -7
- package/dist/lib/definitions/GuardControllerDefinitions.d.ts.map +1 -1
- package/dist/lib/definitions/GuardControllerDefinitions.js +62 -10
- package/dist/lib/definitions/GuardControllerDefinitions.js.map +1 -1
- package/dist/lib/definitions/RuntimeRBACDefinitions.d.ts +48 -7
- package/dist/lib/definitions/RuntimeRBACDefinitions.d.ts.map +1 -1
- package/dist/lib/definitions/RuntimeRBACDefinitions.js +73 -10
- package/dist/lib/definitions/RuntimeRBACDefinitions.js.map +1 -1
- package/dist/lib/definitions/SecureOwnableDefinitions.d.ts +12 -7
- package/dist/lib/definitions/SecureOwnableDefinitions.d.ts.map +1 -1
- package/dist/lib/definitions/SecureOwnableDefinitions.js +25 -9
- package/dist/lib/definitions/SecureOwnableDefinitions.js.map +1 -1
- package/dist/lib/definitions/index.d.ts +6 -4
- package/dist/lib/definitions/index.d.ts.map +1 -1
- package/dist/lib/definitions/index.js +5 -4
- package/dist/lib/definitions/index.js.map +1 -1
- package/dist/types/base.state.machine.index.d.ts +0 -2
- package/dist/types/base.state.machine.index.d.ts.map +1 -1
- package/dist/types/base.state.machine.index.js +1 -3
- package/dist/types/base.state.machine.index.js.map +1 -1
- package/dist/types/core.execution.index.d.ts +1 -0
- package/dist/types/core.execution.index.d.ts.map +1 -1
- package/dist/types/core.execution.index.js +1 -0
- package/dist/types/core.execution.index.js.map +1 -1
- package/dist/types/core.security.index.d.ts.map +1 -1
- package/dist/types/core.security.index.js +2 -2
- package/dist/types/core.security.index.js.map +1 -1
- package/dist/types/definition.index.d.ts +2 -0
- package/dist/types/definition.index.d.ts.map +1 -1
- package/dist/types/definition.index.js.map +1 -1
- package/dist/utils/contract-errors.d.ts +125 -6
- package/dist/utils/contract-errors.d.ts.map +1 -1
- package/dist/utils/contract-errors.js +375 -107
- package/dist/utils/contract-errors.js.map +1 -1
- package/dist/utils/interface-ids.js +8 -8
- package/dist/utils/interface-ids.js.map +1 -1
- package/dist/utils/metaTx/metaTransaction.d.ts +103 -7
- package/dist/utils/metaTx/metaTransaction.d.ts.map +1 -1
- package/dist/utils/metaTx/metaTransaction.js +136 -25
- package/dist/utils/metaTx/metaTransaction.js.map +1 -1
- package/package.json +10 -6
- package/dist/contracts/BaseStateMachine.d.ts.map +0 -1
- package/dist/contracts/BaseStateMachine.js.map +0 -1
- package/dist/contracts/GuardController.d.ts.map +0 -1
- package/dist/contracts/GuardController.js.map +0 -1
- package/dist/contracts/RuntimeRBAC.d.ts +0 -54
- package/dist/contracts/RuntimeRBAC.d.ts.map +0 -1
- package/dist/contracts/RuntimeRBAC.js +0 -58
- package/dist/contracts/RuntimeRBAC.js.map +0 -1
- package/dist/contracts/SecureOwnable.d.ts.map +0 -1
- package/dist/contracts/SecureOwnable.js.map +0 -1
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"inputs": [],
|
|
4
|
+
"name": "APPROVE_WITHDRAWAL_DELAYED_SELECTOR",
|
|
5
|
+
"outputs": [
|
|
6
|
+
{
|
|
7
|
+
"internalType": "bytes4",
|
|
8
|
+
"name": "",
|
|
9
|
+
"type": "bytes4"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"stateMutability": "view",
|
|
13
|
+
"type": "function"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"inputs": [],
|
|
17
|
+
"name": "APPROVE_WITHDRAWAL_META_SELECTOR",
|
|
18
|
+
"outputs": [
|
|
19
|
+
{
|
|
20
|
+
"internalType": "bytes4",
|
|
21
|
+
"name": "",
|
|
22
|
+
"type": "bytes4"
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"stateMutability": "view",
|
|
26
|
+
"type": "function"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"inputs": [],
|
|
30
|
+
"name": "CANCEL_WITHDRAWAL_SELECTOR",
|
|
31
|
+
"outputs": [
|
|
32
|
+
{
|
|
33
|
+
"internalType": "bytes4",
|
|
34
|
+
"name": "",
|
|
35
|
+
"type": "bytes4"
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"stateMutability": "view",
|
|
39
|
+
"type": "function"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"inputs": [],
|
|
43
|
+
"name": "GENERIC_APPROVAL",
|
|
44
|
+
"outputs": [
|
|
45
|
+
{
|
|
46
|
+
"internalType": "bytes32",
|
|
47
|
+
"name": "",
|
|
48
|
+
"type": "bytes32"
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
"stateMutability": "view",
|
|
52
|
+
"type": "function"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"inputs": [],
|
|
56
|
+
"name": "GENERIC_CANCELLATION",
|
|
57
|
+
"outputs": [
|
|
58
|
+
{
|
|
59
|
+
"internalType": "bytes32",
|
|
60
|
+
"name": "",
|
|
61
|
+
"type": "bytes32"
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
"stateMutability": "view",
|
|
65
|
+
"type": "function"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"inputs": [],
|
|
69
|
+
"name": "GENERIC_META_APPROVAL",
|
|
70
|
+
"outputs": [
|
|
71
|
+
{
|
|
72
|
+
"internalType": "bytes32",
|
|
73
|
+
"name": "",
|
|
74
|
+
"type": "bytes32"
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
"stateMutability": "view",
|
|
78
|
+
"type": "function"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"inputs": [],
|
|
82
|
+
"name": "WITHDRAW_ETH",
|
|
83
|
+
"outputs": [
|
|
84
|
+
{
|
|
85
|
+
"internalType": "bytes32",
|
|
86
|
+
"name": "",
|
|
87
|
+
"type": "bytes32"
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
"stateMutability": "view",
|
|
91
|
+
"type": "function"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"inputs": [],
|
|
95
|
+
"name": "WITHDRAW_ETH_REQUEST_SELECTOR",
|
|
96
|
+
"outputs": [
|
|
97
|
+
{
|
|
98
|
+
"internalType": "bytes4",
|
|
99
|
+
"name": "",
|
|
100
|
+
"type": "bytes4"
|
|
101
|
+
}
|
|
102
|
+
],
|
|
103
|
+
"stateMutability": "view",
|
|
104
|
+
"type": "function"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"inputs": [],
|
|
108
|
+
"name": "WITHDRAW_ETH_SELECTOR",
|
|
109
|
+
"outputs": [
|
|
110
|
+
{
|
|
111
|
+
"internalType": "bytes4",
|
|
112
|
+
"name": "",
|
|
113
|
+
"type": "bytes4"
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
"stateMutability": "view",
|
|
117
|
+
"type": "function"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"inputs": [],
|
|
121
|
+
"name": "WITHDRAW_TOKEN",
|
|
122
|
+
"outputs": [
|
|
123
|
+
{
|
|
124
|
+
"internalType": "bytes32",
|
|
125
|
+
"name": "",
|
|
126
|
+
"type": "bytes32"
|
|
127
|
+
}
|
|
128
|
+
],
|
|
129
|
+
"stateMutability": "view",
|
|
130
|
+
"type": "function"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"inputs": [],
|
|
134
|
+
"name": "WITHDRAW_TOKEN_REQUEST_SELECTOR",
|
|
135
|
+
"outputs": [
|
|
136
|
+
{
|
|
137
|
+
"internalType": "bytes4",
|
|
138
|
+
"name": "",
|
|
139
|
+
"type": "bytes4"
|
|
140
|
+
}
|
|
141
|
+
],
|
|
142
|
+
"stateMutability": "view",
|
|
143
|
+
"type": "function"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"inputs": [],
|
|
147
|
+
"name": "WITHDRAW_TOKEN_SELECTOR",
|
|
148
|
+
"outputs": [
|
|
149
|
+
{
|
|
150
|
+
"internalType": "bytes4",
|
|
151
|
+
"name": "",
|
|
152
|
+
"type": "bytes4"
|
|
153
|
+
}
|
|
154
|
+
],
|
|
155
|
+
"stateMutability": "view",
|
|
156
|
+
"type": "function"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"inputs": [],
|
|
160
|
+
"name": "getFunctionSchemas",
|
|
161
|
+
"outputs": [
|
|
162
|
+
{
|
|
163
|
+
"components": [
|
|
164
|
+
{
|
|
165
|
+
"internalType": "string",
|
|
166
|
+
"name": "functionSignature",
|
|
167
|
+
"type": "string"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"internalType": "bytes4",
|
|
171
|
+
"name": "functionSelector",
|
|
172
|
+
"type": "bytes4"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"internalType": "bytes32",
|
|
176
|
+
"name": "operationType",
|
|
177
|
+
"type": "bytes32"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"internalType": "string",
|
|
181
|
+
"name": "operationName",
|
|
182
|
+
"type": "string"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"internalType": "uint16",
|
|
186
|
+
"name": "supportedActionsBitmap",
|
|
187
|
+
"type": "uint16"
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
"internalType": "bool",
|
|
191
|
+
"name": "enforceHandlerRelations",
|
|
192
|
+
"type": "bool"
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
"internalType": "bool",
|
|
196
|
+
"name": "isProtected",
|
|
197
|
+
"type": "bool"
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"internalType": "bytes4[]",
|
|
201
|
+
"name": "handlerForSelectors",
|
|
202
|
+
"type": "bytes4[]"
|
|
203
|
+
}
|
|
204
|
+
],
|
|
205
|
+
"internalType": "struct EngineBlox.FunctionSchema[]",
|
|
206
|
+
"name": "",
|
|
207
|
+
"type": "tuple[]"
|
|
208
|
+
}
|
|
209
|
+
],
|
|
210
|
+
"stateMutability": "pure",
|
|
211
|
+
"type": "function"
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
"inputs": [],
|
|
215
|
+
"name": "getRolePermissions",
|
|
216
|
+
"outputs": [
|
|
217
|
+
{
|
|
218
|
+
"components": [
|
|
219
|
+
{
|
|
220
|
+
"internalType": "bytes32[]",
|
|
221
|
+
"name": "roleHashes",
|
|
222
|
+
"type": "bytes32[]"
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
"components": [
|
|
226
|
+
{
|
|
227
|
+
"internalType": "bytes4",
|
|
228
|
+
"name": "functionSelector",
|
|
229
|
+
"type": "bytes4"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"internalType": "uint16",
|
|
233
|
+
"name": "grantedActionsBitmap",
|
|
234
|
+
"type": "uint16"
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
"internalType": "bytes4[]",
|
|
238
|
+
"name": "handlerForSelectors",
|
|
239
|
+
"type": "bytes4[]"
|
|
240
|
+
}
|
|
241
|
+
],
|
|
242
|
+
"internalType": "struct EngineBlox.FunctionPermission[]",
|
|
243
|
+
"name": "functionPermissions",
|
|
244
|
+
"type": "tuple[]"
|
|
245
|
+
}
|
|
246
|
+
],
|
|
247
|
+
"internalType": "struct IDefinition.RolePermission",
|
|
248
|
+
"name": "",
|
|
249
|
+
"type": "tuple"
|
|
250
|
+
}
|
|
251
|
+
],
|
|
252
|
+
"stateMutability": "pure",
|
|
253
|
+
"type": "function"
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
"inputs": [
|
|
257
|
+
{
|
|
258
|
+
"internalType": "bytes4",
|
|
259
|
+
"name": "interfaceId",
|
|
260
|
+
"type": "bytes4"
|
|
261
|
+
}
|
|
262
|
+
],
|
|
263
|
+
"name": "supportsInterface",
|
|
264
|
+
"outputs": [
|
|
265
|
+
{
|
|
266
|
+
"internalType": "bool",
|
|
267
|
+
"name": "",
|
|
268
|
+
"type": "bool"
|
|
269
|
+
}
|
|
270
|
+
],
|
|
271
|
+
"stateMutability": "pure",
|
|
272
|
+
"type": "function"
|
|
273
|
+
}
|
|
274
|
+
]
|
package/dist/abi.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-exports contract ABIs for use by consumers (e.g. error decoding).
|
|
3
|
+
* Import from '@bloxchain/sdk/abi'.
|
|
4
|
+
*/
|
|
5
|
+
/** EngineBlox contract ABI (full). */
|
|
6
|
+
export declare const engineBloxAbi: readonly unknown[];
|
|
7
|
+
/** EngineBlox ABI entries for custom errors only (for decodeErrorResult). */
|
|
8
|
+
export declare const engineBloxErrorAbi: {
|
|
9
|
+
type?: string;
|
|
10
|
+
}[];
|
|
11
|
+
//# sourceMappingURL=abi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abi.d.ts","sourceRoot":"","sources":["../abi.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,sCAAsC;AACtC,eAAO,MAAM,aAAa,EAAwB,SAAS,OAAO,EAAE,CAAC;AAErE,6EAA6E;AAC7E,eAAO,MAAM,kBAAkB;WAAoC,MAAM;GAExE,CAAC"}
|
package/dist/abi.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-exports contract ABIs for use by consumers (e.g. error decoding).
|
|
3
|
+
* Import from '@bloxchain/sdk/abi'.
|
|
4
|
+
*/
|
|
5
|
+
import engineBloxAbiJson from './abi/EngineBlox.abi.json';
|
|
6
|
+
/** EngineBlox contract ABI (full). */
|
|
7
|
+
export const engineBloxAbi = engineBloxAbiJson;
|
|
8
|
+
/** EngineBlox ABI entries for custom errors only (for decodeErrorResult). */
|
|
9
|
+
export const engineBloxErrorAbi = engineBloxAbi.filter((item) => item.type === 'error');
|
|
10
|
+
//# sourceMappingURL=abi.js.map
|
package/dist/abi.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abi.js","sourceRoot":"","sources":["../abi.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,iBAAiB,MAAM,2BAA2B,CAAC;AAE1D,sCAAsC;AACtC,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAuC,CAAC;AAErE,6EAA6E;AAC7E,MAAM,CAAC,MAAM,kBAAkB,GAAI,aAA0C,CAAC,MAAM,CAClF,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO,CAChC,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Address, PublicClient, WalletClient, Chain, Hex } from 'viem';
|
|
2
|
-
import { TransactionOptions, TransactionResult } from '
|
|
3
|
-
import { IBaseStateMachine } from '
|
|
4
|
-
import { TxRecord, MetaTransaction, MetaTxParams } from '
|
|
5
|
-
import { TxAction } from '
|
|
2
|
+
import { TransactionOptions, TransactionResult } from '../../interfaces/base.index';
|
|
3
|
+
import { IBaseStateMachine } from '../../interfaces/base.state.machine.index';
|
|
4
|
+
import { TxRecord, MetaTransaction, MetaTxParams } from '../../interfaces/lib.index';
|
|
5
|
+
import { TxAction } from '../../types/lib.index';
|
|
6
|
+
import { FunctionSchema } from '../../types/definition.index';
|
|
6
7
|
/**
|
|
7
8
|
* @title BaseStateMachine
|
|
8
9
|
* @notice TypeScript wrapper for BaseStateMachine smart contract with common utilities
|
|
@@ -29,6 +30,7 @@ export declare abstract class BaseStateMachine implements IBaseStateMachine {
|
|
|
29
30
|
createMetaTxParams(handlerContract: Address, handlerSelector: Hex, action: TxAction, deadline: bigint, maxGasPrice: bigint, signer: Address): Promise<MetaTxParams>;
|
|
30
31
|
generateUnsignedMetaTransactionForNew(requester: Address, target: Address, value: bigint, gasLimit: bigint, operationType: Hex, executionSelector: Hex, executionParams: Hex, metaTxParams: MetaTxParams): Promise<MetaTransaction>;
|
|
31
32
|
generateUnsignedMetaTransactionForExisting(txId: bigint, metaTxParams: MetaTxParams): Promise<MetaTransaction>;
|
|
33
|
+
/** Returns `[]` when there are no txs yet or the clamped id range does not overlap `1..txCounter`. */
|
|
32
34
|
getTransactionHistory(fromTxId: bigint, toTxId: bigint): Promise<TxRecord[]>;
|
|
33
35
|
getTransaction(txId: bigint): Promise<TxRecord>;
|
|
34
36
|
getPendingTransactions(): Promise<bigint[]>;
|
|
@@ -48,9 +50,15 @@ export declare abstract class BaseStateMachine implements IBaseStateMachine {
|
|
|
48
50
|
* @notice This function uses the reverse index for efficient lookup
|
|
49
51
|
*/
|
|
50
52
|
getWalletRoles(wallet: Address): Promise<Hex[]>;
|
|
51
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Gets all authorized wallets for a role
|
|
55
|
+
* @param roleHash The role hash to get wallets for
|
|
56
|
+
* @returns Array of authorized wallet addresses
|
|
57
|
+
* @notice Requires caller to have any role for privacy protection
|
|
58
|
+
*/
|
|
59
|
+
getAuthorizedWallets(roleHash: Hex): Promise<Address[]>;
|
|
52
60
|
getActiveRolePermissions(roleHash: Hex): Promise<any[]>;
|
|
53
|
-
|
|
61
|
+
getFunctionSchema(functionSelector: Hex): Promise<FunctionSchema>;
|
|
54
62
|
getSignerNonce(signer: Address): Promise<bigint>;
|
|
55
63
|
getSupportedOperationTypes(): Promise<Hex[]>;
|
|
56
64
|
getSupportedRoles(): Promise<Hex[]>;
|
|
@@ -72,6 +80,12 @@ export declare abstract class BaseStateMachine implements IBaseStateMachine {
|
|
|
72
80
|
* @return The recovery address
|
|
73
81
|
*/
|
|
74
82
|
getRecovery(): Promise<Address>;
|
|
83
|
+
/**
|
|
84
|
+
* @dev Returns all hook contracts registered for a function selector
|
|
85
|
+
* @param functionSelector The function selector to query hooks for
|
|
86
|
+
* @return Array of hook contract addresses
|
|
87
|
+
*/
|
|
88
|
+
getHooks(functionSelector: Hex): Promise<Address[]>;
|
|
75
89
|
supportsInterface(interfaceId: Hex): Promise<boolean>;
|
|
76
90
|
/**
|
|
77
91
|
* @dev Check if this contract supports IBaseStateMachine interface
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseStateMachine.d.ts","sourceRoot":"","sources":["../../../contracts/core/BaseStateMachine.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,EAAa,MAAM,MAAM,CAAC;AAClF,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAG9D;;;GAGG;AACH,8BAAsB,gBAAiB,YAAW,iBAAiB;IAE/D,SAAS,CAAC,MAAM,EAAE,YAAY;IAC9B,SAAS,CAAC,YAAY,EAAE,YAAY,GAAG,SAAS;IAChD,SAAS,CAAC,eAAe,EAAE,OAAO;IAClC,SAAS,CAAC,KAAK,EAAE,KAAK;IACtB,SAAS,CAAC,GAAG,EAAE,GAAG;gBAJR,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,YAAY,GAAG,SAAS,EACtC,eAAe,EAAE,OAAO,EACxB,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,GAAG;IAKpB;;OAEG;IACH,SAAS,CAAC,oBAAoB,IAAI,IAAI;IAMtC;;OAEG;cACa,oBAAoB,CAClC,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,GAAG,EAAE,EACX,OAAO,EAAE,kBAAkB,GAC1B,OAAO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TypeScript wrapper for BaseStateMachine smart contract with common utilities
|
|
@@ -30,29 +31,6 @@ export class BaseStateMachine {
|
|
|
30
31
|
// Otherwise, let Viem use the WalletClient's account automatically
|
|
31
32
|
const walletClientAccount = this.walletClient.account?.address;
|
|
32
33
|
const requestedAccount = options.from.toLowerCase();
|
|
33
|
-
// For meta-transaction functions, ensure the structure is correct
|
|
34
|
-
if (functionName.includes('RequestAndApprove') || functionName.includes('MetaTx')) {
|
|
35
|
-
if (args.length > 0 && args[0] && typeof args[0] === 'object' && 'txRecord' in args[0]) {
|
|
36
|
-
const metaTx = args[0];
|
|
37
|
-
// Ensure all nested structures are properly formatted
|
|
38
|
-
if (metaTx.txRecord && typeof metaTx.txRecord === 'object') {
|
|
39
|
-
// Ensure txRecord.params exists and is an object
|
|
40
|
-
if (!metaTx.txRecord.params || typeof metaTx.txRecord.params !== 'object') {
|
|
41
|
-
throw new Error('Invalid meta-transaction: txRecord.params must be an object');
|
|
42
|
-
}
|
|
43
|
-
// Ensure txRecord.payment exists and is an object
|
|
44
|
-
if (!metaTx.txRecord.payment || typeof metaTx.txRecord.payment !== 'object') {
|
|
45
|
-
throw new Error('Invalid meta-transaction: txRecord.payment must be an object');
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
if (metaTx.params && typeof metaTx.params === 'object') {
|
|
49
|
-
// Ensure params is properly formatted
|
|
50
|
-
if (typeof metaTx.params.action !== 'number') {
|
|
51
|
-
throw new Error('Invalid meta-transaction: params.action must be a number');
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
34
|
const writeContractParams = {
|
|
57
35
|
chain: this.chain,
|
|
58
36
|
address: this.contractAddress,
|
|
@@ -65,17 +43,74 @@ export class BaseStateMachine {
|
|
|
65
43
|
if (!walletClientAccount || walletClientAccount.toLowerCase() !== requestedAccount) {
|
|
66
44
|
writeContractParams.account = options.from;
|
|
67
45
|
}
|
|
46
|
+
// Determine how strictly to enforce pre-flight simulation.
|
|
47
|
+
const simulationMode = options.simulationMode ?? 'strict';
|
|
68
48
|
try {
|
|
69
|
-
//
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
49
|
+
// Simulate the contract call first for better error messages (no gas params for eth_call).
|
|
50
|
+
if (simulationMode !== 'skip') {
|
|
51
|
+
try {
|
|
52
|
+
await this.client.simulateContract({
|
|
53
|
+
...writeContractParams,
|
|
54
|
+
account: writeContractParams.account || this.walletClient.account
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
catch (simulateError) {
|
|
58
|
+
if (simulationMode === 'strict') {
|
|
59
|
+
throw simulateError;
|
|
60
|
+
}
|
|
61
|
+
const msg = simulateError?.shortMessage ??
|
|
62
|
+
simulateError?.message ??
|
|
63
|
+
simulateError?.cause?.shortMessage ??
|
|
64
|
+
simulateError?.cause?.message ??
|
|
65
|
+
String(simulateError);
|
|
66
|
+
// eslint-disable-next-line no-console
|
|
67
|
+
console.warn(`[BaseStateMachine] Pre-flight simulation failed for ${functionName} (mode=${simulationMode}); continuing to send tx: ${msg}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Forward explicit gas limit when provided so callers can bypass eth_estimateGas.
|
|
71
|
+
if (options.gas !== undefined) {
|
|
72
|
+
const rawGas = options.gas;
|
|
73
|
+
let gasLimit;
|
|
74
|
+
if (typeof rawGas === 'bigint') {
|
|
75
|
+
gasLimit = rawGas;
|
|
76
|
+
}
|
|
77
|
+
else if (typeof rawGas === 'number') {
|
|
78
|
+
if (!Number.isSafeInteger(rawGas) || rawGas < 0) {
|
|
79
|
+
throw new Error(`Invalid gas: number inputs must be non-negative safe integers (got "${rawGas}"). ` +
|
|
80
|
+
'Use a bigint or decimal string for larger values.');
|
|
81
|
+
}
|
|
82
|
+
gasLimit = BigInt(rawGas);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
const s = String(rawGas).trim();
|
|
86
|
+
if (!/^\d+$/.test(s)) {
|
|
87
|
+
throw new Error(`Invalid gas: must be a non-negative integer (got "${options.gas}"). Use a number-like value, decimal string, or bigint.`);
|
|
88
|
+
}
|
|
89
|
+
gasLimit = BigInt(s);
|
|
90
|
+
}
|
|
91
|
+
if (gasLimit < 0n) {
|
|
92
|
+
throw new Error(`Invalid gas: must be non-negative (got ${gasLimit.toString()})`);
|
|
93
|
+
}
|
|
94
|
+
writeContractParams.gas = gasLimit;
|
|
75
95
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
96
|
+
// Add gas price override for write only (EIP-1559); viem rejects mixing gasPrice with maxFeePerGas.
|
|
97
|
+
if (options.gasPrice !== undefined && options.gasPrice !== '') {
|
|
98
|
+
const raw = options.gasPrice;
|
|
99
|
+
let gasPriceWei;
|
|
100
|
+
if (typeof raw === 'bigint') {
|
|
101
|
+
gasPriceWei = raw;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
const s = String(raw).trim();
|
|
105
|
+
if (!/^\d+$/.test(s)) {
|
|
106
|
+
throw new Error(`Invalid gas price: must be a non-negative integer (got "${options.gasPrice}"). Use wei as a string or bigint.`);
|
|
107
|
+
}
|
|
108
|
+
gasPriceWei = BigInt(s);
|
|
109
|
+
}
|
|
110
|
+
writeContractParams.maxFeePerGas = gasPriceWei;
|
|
111
|
+
// Use a separate priority fee so when base fee is high the tip does not go to zero (avoids tx stalling).
|
|
112
|
+
const oneGwei = parseGwei('1');
|
|
113
|
+
writeContractParams.maxPriorityFeePerGas = gasPriceWei <= oneGwei ? gasPriceWei : oneGwei;
|
|
79
114
|
}
|
|
80
115
|
const hash = await this.walletClient.writeContract(writeContractParams);
|
|
81
116
|
return {
|
|
@@ -157,6 +192,7 @@ export class BaseStateMachine {
|
|
|
157
192
|
]);
|
|
158
193
|
}
|
|
159
194
|
// ============ STATE QUERIES ============
|
|
195
|
+
/** Returns `[]` when there are no txs yet or the clamped id range does not overlap `1..txCounter`. */
|
|
160
196
|
async getTransactionHistory(fromTxId, toTxId) {
|
|
161
197
|
return this.executeReadContract('getTransactionHistory', [fromTxId, toTxId]);
|
|
162
198
|
}
|
|
@@ -183,14 +219,20 @@ export class BaseStateMachine {
|
|
|
183
219
|
async getWalletRoles(wallet) {
|
|
184
220
|
return this.executeReadContract('getWalletRoles', [wallet]);
|
|
185
221
|
}
|
|
186
|
-
|
|
187
|
-
|
|
222
|
+
/**
|
|
223
|
+
* Gets all authorized wallets for a role
|
|
224
|
+
* @param roleHash The role hash to get wallets for
|
|
225
|
+
* @returns Array of authorized wallet addresses
|
|
226
|
+
* @notice Requires caller to have any role for privacy protection
|
|
227
|
+
*/
|
|
228
|
+
async getAuthorizedWallets(roleHash) {
|
|
229
|
+
return this.executeReadContract('getAuthorizedWallets', [roleHash]);
|
|
188
230
|
}
|
|
189
231
|
async getActiveRolePermissions(roleHash) {
|
|
190
232
|
return this.executeReadContract('getActiveRolePermissions', [roleHash]);
|
|
191
233
|
}
|
|
192
|
-
async
|
|
193
|
-
return this.executeReadContract('
|
|
234
|
+
async getFunctionSchema(functionSelector) {
|
|
235
|
+
return this.executeReadContract('getFunctionSchema', [functionSelector]);
|
|
194
236
|
}
|
|
195
237
|
async getSignerNonce(signer) {
|
|
196
238
|
return this.executeReadContract('getSignerNonce', [signer]);
|
|
@@ -233,6 +275,14 @@ export class BaseStateMachine {
|
|
|
233
275
|
async getRecovery() {
|
|
234
276
|
return this.executeReadContract('getRecovery');
|
|
235
277
|
}
|
|
278
|
+
/**
|
|
279
|
+
* @dev Returns all hook contracts registered for a function selector
|
|
280
|
+
* @param functionSelector The function selector to query hooks for
|
|
281
|
+
* @return Array of hook contract addresses
|
|
282
|
+
*/
|
|
283
|
+
async getHooks(functionSelector) {
|
|
284
|
+
return this.executeReadContract('getHooks', [functionSelector]);
|
|
285
|
+
}
|
|
236
286
|
// ============ INTERFACE SUPPORT ============
|
|
237
287
|
async supportsInterface(interfaceId) {
|
|
238
288
|
return this.executeReadContract('supportsInterface', [interfaceId]);
|
|
@@ -243,7 +293,7 @@ export class BaseStateMachine {
|
|
|
243
293
|
*/
|
|
244
294
|
async supportsBaseStateMachineInterface() {
|
|
245
295
|
// Import dynamically to avoid circular dependencies
|
|
246
|
-
const { INTERFACE_IDS } = await import('
|
|
296
|
+
const { INTERFACE_IDS } = await import('../../utils/interface-ids');
|
|
247
297
|
return this.supportsInterface(INTERFACE_IDS.IBaseStateMachine);
|
|
248
298
|
}
|
|
249
299
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseStateMachine.js","sourceRoot":"","sources":["../../../contracts/core/BaseStateMachine.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAmD,SAAS,EAAE,MAAM,MAAM,CAAC;AAMlF,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE;;;GAGG;AACH,MAAM,OAAgB,gBAAgB;IACpC,YACY,MAAoB,EACpB,YAAsC,EACtC,eAAwB,EACxB,KAAY,EACZ,GAAQ;QAJR,WAAM,GAAN,MAAM,CAAc;QACpB,iBAAY,GAAZ,YAAY,CAA0B;QACtC,oBAAe,GAAf,eAAe,CAAS;QACxB,UAAK,GAAL,KAAK,CAAO;QACZ,QAAG,GAAH,GAAG,CAAK;IACjB,CAAC;IAEJ,mDAAmD;IAEnD;;OAEG;IACO,oBAAoB;QAC5B,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IAED;;OAEG;IACO,KAAK,CAAC,oBAAoB,CAClC,YAAoB,EACpB,IAAW,EACX,OAA2B;QAE3B,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAE5B,wEAAwE;QACxE,yEAAyE;QACzE,mEAAmE;QACnE,MAAM,mBAAmB,GAAG,IAAI,CAAC,YAAa,CAAC,OAAO,EAAE,OAAO,CAAC;QAChE,MAAM,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,E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CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,eAAe;QACnB,OAAO,IAAI,CAAC,mBAAmB,CAAY,iBAAiB,CAAC,CAAC;IAChE,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,WAAW;QACf,OAAO,IAAI,CAAC,mBAAmB,CAAU,aAAa,CAAC,CAAC;IAC1D,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,QAAQ,CAAC,gBAAqB;QAClC,OAAO,IAAI,CAAC,mBAAmB,CAAY,UAAU,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAC7E,CAAC;IAED,8CAA8C;IAE9C,KAAK,CAAC,iBAAiB,CAAC,WAAgB;QACtC,OAAO,IAAI,CAAC,mBAAmB,CAAU,mBAAmB,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAC/E,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,iCAAiC;QACrC,oDAAoD;QACpD,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,MAAM,CAAC,2BAA2B,CAAC,CAAC;QACpE,OAAO,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;IACjE,CAAC;CACF;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Address, PublicClient, WalletClient, Chain, Hex } from 'viem';
|
|
2
|
-
import { TransactionOptions, TransactionResult } from '
|
|
3
|
-
import { IGuardController } from '
|
|
4
|
-
import { MetaTransaction } from '
|
|
2
|
+
import { TransactionOptions, TransactionResult } from '../../interfaces/base.index';
|
|
3
|
+
import { IGuardController } from '../../interfaces/core.execution.index';
|
|
4
|
+
import { MetaTransaction } from '../../interfaces/lib.index';
|
|
5
5
|
import { BaseStateMachine } from './BaseStateMachine';
|
|
6
6
|
/**
|
|
7
7
|
* @title GuardController
|
|
@@ -43,6 +43,23 @@ export declare class GuardController extends BaseStateMachine implements IGuardC
|
|
|
43
43
|
* @notice For simple ETH transfers: value>0, functionSelector=0x00000000, params=""
|
|
44
44
|
*/
|
|
45
45
|
executeWithTimeLock(target: Address, value: bigint, functionSelector: Hex, params: Hex, gasLimit: bigint, operationType: Hex, options: TransactionOptions): Promise<TransactionResult>;
|
|
46
|
+
/**
|
|
47
|
+
* @dev Requests a time-locked execution with payment details
|
|
48
|
+
* @param target The address of the target contract
|
|
49
|
+
* @param value The ETH value to send
|
|
50
|
+
* @param functionSelector The function selector to execute
|
|
51
|
+
* @param params The encoded parameters for the function
|
|
52
|
+
* @param gasLimit The gas limit for execution
|
|
53
|
+
* @param operationType The operation type hash
|
|
54
|
+
* @param paymentDetails Payment details (recipient, nativeTokenAmount, erc20TokenAddress, erc20TokenAmount)
|
|
55
|
+
* @param options Transaction options including from address
|
|
56
|
+
*/
|
|
57
|
+
executeWithPayment(target: Address, value: bigint, functionSelector: Hex, params: Hex, gasLimit: bigint, operationType: Hex, paymentDetails: {
|
|
58
|
+
recipient: Address;
|
|
59
|
+
nativeTokenAmount: bigint;
|
|
60
|
+
erc20TokenAddress: Address;
|
|
61
|
+
erc20TokenAmount: bigint;
|
|
62
|
+
}, options: TransactionOptions): Promise<TransactionResult>;
|
|
46
63
|
/**
|
|
47
64
|
* @dev Approves and executes a time-locked transaction
|
|
48
65
|
* @param txId The transaction ID
|
|
@@ -85,15 +102,6 @@ export declare class GuardController extends BaseStateMachine implements IGuardC
|
|
|
85
102
|
* @notice Requires EXECUTE_META_REQUEST_AND_APPROVE permission for the execution function selector
|
|
86
103
|
*/
|
|
87
104
|
requestAndApproveExecution(metaTx: MetaTransaction, options: TransactionOptions): Promise<TransactionResult>;
|
|
88
|
-
/**
|
|
89
|
-
* @dev Creates execution params for a guard configuration batch (definition helper; no contract call)
|
|
90
|
-
* @param actions Guard configuration actions
|
|
91
|
-
* @return Promise<Hex> The execution params to be used in a meta-transaction
|
|
92
|
-
*/
|
|
93
|
-
guardConfigBatchExecutionParams(actions: Array<{
|
|
94
|
-
actionType: number;
|
|
95
|
-
data: Hex;
|
|
96
|
-
}>): Promise<Hex>;
|
|
97
105
|
/**
|
|
98
106
|
* @dev Requests and approves a guard configuration batch using a meta-transaction
|
|
99
107
|
* @param metaTx The meta-transaction describing the guard configuration batch
|
|
@@ -104,12 +112,11 @@ export declare class GuardController extends BaseStateMachine implements IGuardC
|
|
|
104
112
|
*/
|
|
105
113
|
guardConfigBatchRequestAndApprove(metaTx: MetaTransaction, options: TransactionOptions): Promise<TransactionResult>;
|
|
106
114
|
/**
|
|
107
|
-
* @dev Gets all whitelisted targets for a function selector.
|
|
115
|
+
* @dev Gets all whitelisted targets for a function selector (from BaseStateMachine).
|
|
108
116
|
* @param functionSelector The function selector
|
|
109
117
|
* @return Promise<Address[]> Array of whitelisted target addresses
|
|
110
|
-
* @notice Requires caller to have any role (via _validateAnyRole) for privacy protection
|
|
111
118
|
*/
|
|
112
|
-
|
|
119
|
+
getFunctionWhitelistTargets(functionSelector: Hex): Promise<Address[]>;
|
|
113
120
|
/**
|
|
114
121
|
* @dev Check if this contract supports IGuardController interface
|
|
115
122
|
* @return Promise<boolean> indicating if IGuardController is supported
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GuardController.d.ts","sourceRoot":"","sources":["../../../contracts/core/GuardController.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEvE,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACpF,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD;;;;;;;;;;GAUG;AACH,qBAAa,eAAgB,SAAQ,gBAAiB,YAAW,gBAAgB;gBAE7E,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,YAAY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