@crediolabs/policy-synth 0.1.6 → 0.1.8
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/run/schemas.js
CHANGED
|
@@ -36,6 +36,13 @@ export const ScValSchema = z.lazy(() => z.union([
|
|
|
36
36
|
z.object({ type: z.literal('u32'), value: z.string().regex(/^[0-9]+$/) }),
|
|
37
37
|
z.object({ type: z.literal('symbol'), value: z.string() }),
|
|
38
38
|
z.object({ type: z.literal('vec'), value: z.array(ScValSchema) }),
|
|
39
|
+
// Map mirrors the core ScVal. Real Blend `submit` calls carry a vec of maps
|
|
40
|
+
// as the request argument, so omitting it here made the synthesizer reject a
|
|
41
|
+
// recording its own recorder had just produced at full confidence.
|
|
42
|
+
z.object({
|
|
43
|
+
type: z.literal('map'),
|
|
44
|
+
value: z.array(z.object({ key: z.string(), val: ScValSchema })),
|
|
45
|
+
}),
|
|
39
46
|
z.object({ type: z.literal('bytes'), value: z.string() }),
|
|
40
47
|
z.object({ type: z.literal('other'), value: z.string() }),
|
|
41
48
|
]));
|
|
@@ -250,6 +250,32 @@ function appendProtocolSpecificConstraints(ozConstraints, interpreterConstraints
|
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
|
+
// Blend submit / claim: the `to` arg is the beneficiary - it receives the
|
|
254
|
+
// resulting position shares on `submit` and the claimed tokens on `claim`.
|
|
255
|
+
// That is the same role as the SEP-41 recipient above and the SoroSwap swap
|
|
256
|
+
// recipient below, so it is pinned to the recorded address the same way:
|
|
257
|
+
// without it a policy scoped to a pool and method still lets an agent send
|
|
258
|
+
// the proceeds anywhere. `from` and `spender` are deliberately NOT pinned -
|
|
259
|
+
// the call already requires their authorisation, so binding them adds no
|
|
260
|
+
// restriction the chain is not already enforcing.
|
|
261
|
+
if (protocol.protocol === 'blend' && (protocol.fn === 'submit' || protocol.fn === 'claim')) {
|
|
262
|
+
// Index 2 in both signatures: submit(from, spender, to, requests) and
|
|
263
|
+
// claim(from, reserve_token_ids, to).
|
|
264
|
+
const toArg = topLevel.args[2];
|
|
265
|
+
if (toArg && toArg.type === 'address') {
|
|
266
|
+
const cond = {
|
|
267
|
+
op: 'in',
|
|
268
|
+
selector: { kind: 'arg', argIndex: 2, scalarType: 'address' },
|
|
269
|
+
values: [toArg.value],
|
|
270
|
+
};
|
|
271
|
+
if (interpreterEnabled) {
|
|
272
|
+
interpreterConstraints.push(cond);
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
ozConstraints.push(cond);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
253
279
|
// SoroSwap: the recorded hop path -> eq_seq on the path arg (call_arg[2]).
|
|
254
280
|
// The interpreter adapter is the ONLY way to express an exact ordered
|
|
255
281
|
// sequence (OZ built-ins cannot). Element order is preserved verbatim.
|
package/dist-cjs/run/schemas.js
CHANGED
|
@@ -39,6 +39,13 @@ exports.ScValSchema = zod_1.z.lazy(() => zod_1.z.union([
|
|
|
39
39
|
zod_1.z.object({ type: zod_1.z.literal('u32'), value: zod_1.z.string().regex(/^[0-9]+$/) }),
|
|
40
40
|
zod_1.z.object({ type: zod_1.z.literal('symbol'), value: zod_1.z.string() }),
|
|
41
41
|
zod_1.z.object({ type: zod_1.z.literal('vec'), value: zod_1.z.array(exports.ScValSchema) }),
|
|
42
|
+
// Map mirrors the core ScVal. Real Blend `submit` calls carry a vec of maps
|
|
43
|
+
// as the request argument, so omitting it here made the synthesizer reject a
|
|
44
|
+
// recording its own recorder had just produced at full confidence.
|
|
45
|
+
zod_1.z.object({
|
|
46
|
+
type: zod_1.z.literal('map'),
|
|
47
|
+
value: zod_1.z.array(zod_1.z.object({ key: zod_1.z.string(), val: exports.ScValSchema })),
|
|
48
|
+
}),
|
|
42
49
|
zod_1.z.object({ type: zod_1.z.literal('bytes'), value: zod_1.z.string() }),
|
|
43
50
|
zod_1.z.object({ type: zod_1.z.literal('other'), value: zod_1.z.string() }),
|
|
44
51
|
]));
|
|
@@ -253,6 +253,32 @@ function appendProtocolSpecificConstraints(ozConstraints, interpreterConstraints
|
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
|
+
// Blend submit / claim: the `to` arg is the beneficiary - it receives the
|
|
257
|
+
// resulting position shares on `submit` and the claimed tokens on `claim`.
|
|
258
|
+
// That is the same role as the SEP-41 recipient above and the SoroSwap swap
|
|
259
|
+
// recipient below, so it is pinned to the recorded address the same way:
|
|
260
|
+
// without it a policy scoped to a pool and method still lets an agent send
|
|
261
|
+
// the proceeds anywhere. `from` and `spender` are deliberately NOT pinned -
|
|
262
|
+
// the call already requires their authorisation, so binding them adds no
|
|
263
|
+
// restriction the chain is not already enforcing.
|
|
264
|
+
if (protocol.protocol === 'blend' && (protocol.fn === 'submit' || protocol.fn === 'claim')) {
|
|
265
|
+
// Index 2 in both signatures: submit(from, spender, to, requests) and
|
|
266
|
+
// claim(from, reserve_token_ids, to).
|
|
267
|
+
const toArg = topLevel.args[2];
|
|
268
|
+
if (toArg && toArg.type === 'address') {
|
|
269
|
+
const cond = {
|
|
270
|
+
op: 'in',
|
|
271
|
+
selector: { kind: 'arg', argIndex: 2, scalarType: 'address' },
|
|
272
|
+
values: [toArg.value],
|
|
273
|
+
};
|
|
274
|
+
if (interpreterEnabled) {
|
|
275
|
+
interpreterConstraints.push(cond);
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
ozConstraints.push(cond);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
256
282
|
// SoroSwap: the recorded hop path -> eq_seq on the path arg (call_arg[2]).
|
|
257
283
|
// The interpreter adapter is the ONLY way to express an exact ordered
|
|
258
284
|
// sequence (OZ built-ins cannot). Element order is preserved verbatim.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crediolabs/policy-synth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Off-chain TypeScript synthesis core for the OZ Accounts Policy Builder. Records Soroban transactions, synthesises the minimal policy that permits exactly that flow, verifies it, and returns an unsigned install transaction.",
|
|
6
6
|
"type": "module",
|
package/src/run/schemas.ts
CHANGED
|
@@ -42,6 +42,13 @@ export const ScValSchema: z.ZodType<unknown> = z.lazy(() =>
|
|
|
42
42
|
z.object({ type: z.literal('u32'), value: z.string().regex(/^[0-9]+$/) }),
|
|
43
43
|
z.object({ type: z.literal('symbol'), value: z.string() }),
|
|
44
44
|
z.object({ type: z.literal('vec'), value: z.array(ScValSchema) }),
|
|
45
|
+
// Map mirrors the core ScVal. Real Blend `submit` calls carry a vec of maps
|
|
46
|
+
// as the request argument, so omitting it here made the synthesizer reject a
|
|
47
|
+
// recording its own recorder had just produced at full confidence.
|
|
48
|
+
z.object({
|
|
49
|
+
type: z.literal('map'),
|
|
50
|
+
value: z.array(z.object({ key: z.string(), val: ScValSchema })),
|
|
51
|
+
}),
|
|
45
52
|
z.object({ type: z.literal('bytes'), value: z.string() }),
|
|
46
53
|
z.object({ type: z.literal('other'), value: z.string() }),
|
|
47
54
|
])
|
|
@@ -355,6 +355,32 @@ function appendProtocolSpecificConstraints(
|
|
|
355
355
|
}
|
|
356
356
|
}
|
|
357
357
|
|
|
358
|
+
// Blend submit / claim: the `to` arg is the beneficiary - it receives the
|
|
359
|
+
// resulting position shares on `submit` and the claimed tokens on `claim`.
|
|
360
|
+
// That is the same role as the SEP-41 recipient above and the SoroSwap swap
|
|
361
|
+
// recipient below, so it is pinned to the recorded address the same way:
|
|
362
|
+
// without it a policy scoped to a pool and method still lets an agent send
|
|
363
|
+
// the proceeds anywhere. `from` and `spender` are deliberately NOT pinned -
|
|
364
|
+
// the call already requires their authorisation, so binding them adds no
|
|
365
|
+
// restriction the chain is not already enforcing.
|
|
366
|
+
if (protocol.protocol === 'blend' && (protocol.fn === 'submit' || protocol.fn === 'claim')) {
|
|
367
|
+
// Index 2 in both signatures: submit(from, spender, to, requests) and
|
|
368
|
+
// claim(from, reserve_token_ids, to).
|
|
369
|
+
const toArg = topLevel.args[2]
|
|
370
|
+
if (toArg && toArg.type === 'address') {
|
|
371
|
+
const cond: IRCondition = {
|
|
372
|
+
op: 'in',
|
|
373
|
+
selector: { kind: 'arg', argIndex: 2, scalarType: 'address' },
|
|
374
|
+
values: [toArg.value],
|
|
375
|
+
}
|
|
376
|
+
if (interpreterEnabled) {
|
|
377
|
+
interpreterConstraints.push(cond)
|
|
378
|
+
} else {
|
|
379
|
+
ozConstraints.push(cond)
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
358
384
|
// SoroSwap: the recorded hop path -> eq_seq on the path arg (call_arg[2]).
|
|
359
385
|
// The interpreter adapter is the ONLY way to express an exact ordered
|
|
360
386
|
// sequence (OZ built-ins cannot). Element order is preserved verbatim.
|