@universal-everything/sdk-core-lukso 1.0.0 → 1.1.0-dev.16b651c

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/dist/index.d.ts CHANGED
@@ -152,5 +152,32 @@ type BuildDeploymentResult = {
152
152
  * MUST be sent unchanged.
153
153
  */
154
154
  declare function buildLsp23Deployment(opts: BuildDeploymentOpts): BuildDeploymentResult;
155
+ /**
156
+ * The GENERATING controller of an LSP23 deployment: the controller the
157
+ * post-deployment calldata grants on the fresh UP. Because the factory's
158
+ * CREATE2 salt commits to `postDeploymentModuleCalldata`, the key granted
159
+ * here is the one that ends up controlling a redeploy of the same address on
160
+ * another chain — every other controller is added later (a `setDataBatch` on
161
+ * the live UP, e.g. a daily-use key added after deployment) and is not part
162
+ * of the address.
163
+ *
164
+ * Identified by STRUCTURE, not by permission bits: decode the
165
+ * `(bytes32[] keys, bytes[] values)` setDataBatch payload, take the
166
+ * `AddressPermissions:Permissions:<address>` entries, and drop the Universal
167
+ * Receiver Delegate (the address the same calldata sets under the
168
+ * `LSP1UniversalReceiverDelegate` key; the canonical LUKSO URD as fallback).
169
+ * Exactly one controller must remain — that is the generating key,
170
+ * lowercased. `null` = unknown, never "none": the calldata does not decode,
171
+ * grants no controller besides the URD, or grants MORE THAN ONE (ambiguous —
172
+ * the entry order is chosen by whoever built the calldata, so picking "the
173
+ * first" would let a hostile dapp choose which key we record; refusing to
174
+ * pick means it can only make the value unknown). Every producer we know of
175
+ * (extension, mobile app, our own builder) grants exactly one controller plus
176
+ * the URD. Not tied to the permission mask the producer chose, so a future
177
+ * deploy granting the generating key a narrower mask still resolves. Only
178
+ * meaningful on LSP23 post-deployment calldata — a plain `setDataBatch` on a
179
+ * live UP may legitimately grant many.
180
+ */
181
+ declare function extractLsp23GeneratingController(postDeploymentModuleCalldata: Hex): Hex | null;
155
182
 
156
- export { type BuildDeploymentOpts, type BuildDeploymentResult, DEPLOY_ERC1167_PROXIES_ABI, LUKSO_LSP23_CONSTANTS, type LuksoLsp23Constants, buildLsp23Deployment, deriveLsp23ProxyAddress, generateLsp23Salt };
183
+ export { type BuildDeploymentOpts, type BuildDeploymentResult, DEPLOY_ERC1167_PROXIES_ABI, LUKSO_LSP23_CONSTANTS, type LuksoLsp23Constants, buildLsp23Deployment, deriveLsp23ProxyAddress, extractLsp23GeneratingController, generateLsp23Salt };
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // src/lsp23.ts
2
2
  import {
3
+ decodeAbiParameters,
3
4
  decodeFunctionData,
4
5
  encodeAbiParameters,
5
6
  encodeFunctionData,
@@ -192,10 +193,42 @@ function buildLsp23Deployment(opts) {
192
193
  deploymentCalldata: calldata
193
194
  };
194
195
  }
196
+ function extractLsp23GeneratingController(postDeploymentModuleCalldata) {
197
+ let keys;
198
+ let values;
199
+ try {
200
+ [keys, values] = decodeAbiParameters(
201
+ [{ type: "bytes32[]" }, { type: "bytes[]" }],
202
+ postDeploymentModuleCalldata
203
+ );
204
+ } catch {
205
+ return null;
206
+ }
207
+ const prefix = LSP6_PERMISSIONS_PREFIX.toLowerCase();
208
+ const urd = /* @__PURE__ */ new Set([
209
+ LUKSO_LSP23_CONSTANTS.universalReceiverDelegate.toLowerCase()
210
+ ]);
211
+ const granted = /* @__PURE__ */ new Set();
212
+ for (let i = 0; i < keys.length; i++) {
213
+ const key = keys[i].toLowerCase();
214
+ const value = values[i];
215
+ if (key === LSP1_URD_KEY && value?.length === 42) {
216
+ urd.add(value.toLowerCase());
217
+ continue;
218
+ }
219
+ if (!key.startsWith(prefix) || key.length !== 66) continue;
220
+ if (value?.length !== 66) continue;
221
+ granted.add(`0x${key.slice(prefix.length)}`);
222
+ }
223
+ const controllers = [...granted].filter((a) => !urd.has(a));
224
+ if (controllers.length !== 1) return null;
225
+ return controllers[0];
226
+ }
195
227
  export {
196
228
  DEPLOY_ERC1167_PROXIES_ABI,
197
229
  LUKSO_LSP23_CONSTANTS,
198
230
  buildLsp23Deployment,
199
231
  deriveLsp23ProxyAddress,
232
+ extractLsp23GeneratingController,
200
233
  generateLsp23Salt
201
234
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@universal-everything/sdk-core-lukso",
3
- "version": "1.0.0",
3
+ "version": "1.1.0-dev.16b651c",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/universal-everything/universal-relayer.git",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "viem": "^2.21.0",
26
- "@universal-everything/sdk-core": "1.1.0"
26
+ "@universal-everything/sdk-core": "1.2.0-dev.16b651c"
27
27
  },
28
28
  "devDependencies": {
29
29
  "typescript": "^5.7.0",