@crediolabs/policy-synth 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/README.md +4 -4
  2. package/dist/adapters/interpreter/adapter.d.ts +19 -25
  3. package/dist/adapters/interpreter/adapter.js +54 -487
  4. package/dist/adapters/interpreter/index.d.ts +1 -1
  5. package/dist/adapters/interpreter/index.js +1 -1
  6. package/dist/adapters/oz/adapter.js +1 -15
  7. package/dist/errors.d.ts +1 -1
  8. package/dist/index.d.ts +1 -4
  9. package/dist/index.js +1 -4
  10. package/dist/install/build-add-context-rule.d.ts +3 -19
  11. package/dist/install/build-add-context-rule.js +3 -98
  12. package/dist/install/build-install-policy.d.ts +4 -53
  13. package/dist/install/build-install-policy.js +44 -123
  14. package/dist/install/index.d.ts +0 -2
  15. package/dist/install/index.js +0 -7
  16. package/dist/ir/index.d.ts +1 -1
  17. package/dist/ir/types.d.ts +7 -76
  18. package/dist/ir/types.js +0 -2
  19. package/dist/predicate/decode.d.ts +1 -1
  20. package/dist/predicate/decode.js +2 -70
  21. package/dist/predicate/encode.js +45 -229
  22. package/dist/predicate/from-json.js +1 -42
  23. package/dist/record/decode.js +3 -8
  24. package/dist/review-card/builder.d.ts +4 -3
  25. package/dist/review-card/builder.js +18 -162
  26. package/dist/review-card/cross-check.js +2 -105
  27. package/dist/review-card/render-leaf.d.ts +4 -0
  28. package/dist/review-card/render-leaf.js +47 -0
  29. package/dist/run/index.d.ts +36 -139
  30. package/dist/run/index.js +125 -437
  31. package/dist/run/schemas.d.ts +168 -1929
  32. package/dist/run/schemas.js +40 -269
  33. package/dist/seams/types.d.ts +0 -2
  34. package/dist/simulate/deny-cases.d.ts +26 -0
  35. package/dist/simulate/deny-cases.js +282 -0
  36. package/dist/simulate/evaluate.d.ts +18 -0
  37. package/dist/simulate/evaluate.js +271 -0
  38. package/dist/simulate/index.d.ts +4 -0
  39. package/dist/simulate/index.js +8 -0
  40. package/dist/synth/compose-from-recording.d.ts +24 -51
  41. package/dist/synth/compose-from-recording.js +120 -282
  42. package/dist/synth/deny-cases.d.ts +5 -7
  43. package/dist/synth/deny-cases.js +23 -373
  44. package/dist/synth/evaluate.d.ts +0 -21
  45. package/dist/synth/evaluate.js +56 -336
  46. package/dist/synth/index.d.ts +0 -5
  47. package/dist/synth/index.js +0 -5
  48. package/dist/synth/permit-context.d.ts +2 -9
  49. package/dist/synth/permit-context.js +1 -82
  50. package/dist/synth/synthesize-from-recording.d.ts +1 -29
  51. package/dist/synth/synthesize-from-recording.js +41 -356
  52. package/dist/types.d.ts +8 -60
  53. package/dist/types.js +5 -2
  54. package/dist/verify/simulate.d.ts +1 -14
  55. package/dist/verify/simulate.js +2 -88
  56. package/dist/verify/verify.d.ts +1 -7
  57. package/dist/verify/verify.js +0 -8
  58. package/dist-cjs/adapters/interpreter/adapter.d.ts +19 -25
  59. package/dist-cjs/adapters/interpreter/adapter.js +56 -489
  60. package/dist-cjs/adapters/interpreter/index.d.ts +1 -1
  61. package/dist-cjs/adapters/interpreter/index.js +1 -2
  62. package/dist-cjs/adapters/oz/adapter.js +1 -15
  63. package/dist-cjs/errors.d.ts +1 -1
  64. package/dist-cjs/index.d.ts +1 -4
  65. package/dist-cjs/index.js +1 -4
  66. package/dist-cjs/install/build-add-context-rule.d.ts +3 -19
  67. package/dist-cjs/install/build-add-context-rule.js +1 -97
  68. package/dist-cjs/install/build-install-policy.d.ts +4 -53
  69. package/dist-cjs/install/build-install-policy.js +44 -122
  70. package/dist-cjs/install/index.d.ts +0 -2
  71. package/dist-cjs/install/index.js +2 -23
  72. package/dist-cjs/ir/index.d.ts +1 -1
  73. package/dist-cjs/ir/types.d.ts +7 -76
  74. package/dist-cjs/ir/types.js +0 -2
  75. package/dist-cjs/predicate/decode.d.ts +1 -1
  76. package/dist-cjs/predicate/decode.js +2 -70
  77. package/dist-cjs/predicate/encode.js +45 -229
  78. package/dist-cjs/predicate/from-json.js +1 -42
  79. package/dist-cjs/record/decode.js +3 -8
  80. package/dist-cjs/review-card/builder.d.ts +4 -3
  81. package/dist-cjs/review-card/builder.js +23 -167
  82. package/dist-cjs/review-card/cross-check.js +7 -110
  83. package/dist-cjs/review-card/render-leaf.d.ts +4 -0
  84. package/dist-cjs/review-card/render-leaf.js +52 -0
  85. package/dist-cjs/run/index.d.ts +36 -139
  86. package/dist-cjs/run/index.js +125 -444
  87. package/dist-cjs/run/schemas.d.ts +168 -1929
  88. package/dist-cjs/run/schemas.js +41 -270
  89. package/dist-cjs/seams/types.d.ts +0 -2
  90. package/dist-cjs/simulate/deny-cases.d.ts +26 -0
  91. package/dist-cjs/simulate/deny-cases.js +286 -0
  92. package/dist-cjs/simulate/evaluate.d.ts +18 -0
  93. package/dist-cjs/simulate/evaluate.js +274 -0
  94. package/dist-cjs/simulate/index.d.ts +4 -0
  95. package/dist-cjs/simulate/index.js +13 -0
  96. package/dist-cjs/synth/compose-from-recording.d.ts +24 -51
  97. package/dist-cjs/synth/compose-from-recording.js +120 -282
  98. package/dist-cjs/synth/deny-cases.d.ts +5 -7
  99. package/dist-cjs/synth/deny-cases.js +23 -374
  100. package/dist-cjs/synth/evaluate.d.ts +0 -21
  101. package/dist-cjs/synth/evaluate.js +57 -337
  102. package/dist-cjs/synth/index.d.ts +0 -5
  103. package/dist-cjs/synth/index.js +1 -11
  104. package/dist-cjs/synth/permit-context.d.ts +2 -9
  105. package/dist-cjs/synth/permit-context.js +1 -82
  106. package/dist-cjs/synth/synthesize-from-recording.d.ts +1 -29
  107. package/dist-cjs/synth/synthesize-from-recording.js +39 -354
  108. package/dist-cjs/types.d.ts +8 -60
  109. package/dist-cjs/types.js +6 -3
  110. package/dist-cjs/verify/simulate.d.ts +1 -14
  111. package/dist-cjs/verify/simulate.js +2 -88
  112. package/dist-cjs/verify/verify.d.ts +1 -7
  113. package/dist-cjs/verify/verify.js +0 -8
  114. package/package.json +4 -4
  115. package/src/adapters/interpreter/adapter.ts +76 -572
  116. package/src/errors.ts +0 -19
  117. package/src/index.ts +1 -4
  118. package/src/install/build-add-context-rule.ts +5 -139
  119. package/src/install/build-install-policy.ts +93 -214
  120. package/src/install/index.ts +0 -34
  121. package/src/predicate/decode.ts +2 -70
  122. package/src/predicate/encode.ts +49 -261
  123. package/src/predicate/from-json.ts +1 -43
  124. package/src/record/decode.ts +3 -8
  125. package/src/review-card/builder.ts +19 -168
  126. package/src/review-card/cross-check.ts +3 -105
  127. package/src/review-card/render-leaf.ts +48 -0
  128. package/src/run/index.ts +144 -572
  129. package/src/run/schemas.ts +42 -291
  130. package/src/simulate/deny-cases.ts +334 -0
  131. package/src/simulate/evaluate.ts +284 -0
  132. package/src/simulate/index.ts +11 -0
  133. package/src/synth/compose-from-recording.ts +148 -347
  134. package/src/synth/index.ts +0 -13
  135. package/src/synth/synthesize-from-recording.ts +43 -456
  136. package/src/types.ts +13 -49
  137. package/dist/install/authority-overlap.d.ts +0 -134
  138. package/dist/install/authority-overlap.js +0 -0
  139. package/dist/install/build-install-predicate.d.ts +0 -96
  140. package/dist/install/build-install-predicate.js +0 -444
  141. package/dist/install/build-merge-policy.d.ts +0 -70
  142. package/dist/install/build-merge-policy.js +0 -130
  143. package/dist/install/plan-merge-policy.d.ts +0 -49
  144. package/dist/install/plan-merge-policy.js +0 -86
  145. package/dist/install/read-account-rules.d.ts +0 -100
  146. package/dist/install/read-account-rules.js +0 -283
  147. package/dist-cjs/install/authority-overlap.d.ts +0 -134
  148. package/dist-cjs/install/authority-overlap.js +0 -0
  149. package/dist-cjs/install/build-install-predicate.d.ts +0 -96
  150. package/dist-cjs/install/build-install-predicate.js +0 -479
  151. package/dist-cjs/install/build-merge-policy.d.ts +0 -70
  152. package/dist-cjs/install/build-merge-policy.js +0 -134
  153. package/dist-cjs/install/plan-merge-policy.d.ts +0 -49
  154. package/dist-cjs/install/plan-merge-policy.js +0 -90
  155. package/dist-cjs/install/read-account-rules.d.ts +0 -100
  156. package/dist-cjs/install/read-account-rules.js +0 -296
  157. package/src/adapters/interpreter/index.ts +0 -8
  158. package/src/adapters/oz/adapter.ts +0 -376
  159. package/src/adapters/oz/index.ts +0 -9
  160. package/src/codegen/compile-gate.ts +0 -167
  161. package/src/codegen/index.ts +0 -17
  162. package/src/codegen/template.ts +0 -165
  163. package/src/install/authority-overlap.ts +0 -0
  164. package/src/install/build-merge-policy.ts +0 -219
  165. package/src/install/plan-merge-policy.ts +0 -133
  166. package/src/install/read-account-rules.ts +0 -376
  167. package/src/ir/index.ts +0 -13
  168. package/src/ir/types.ts +0 -132
  169. package/src/mandate/index.ts +0 -4
  170. package/src/mandate/to-ir.ts +0 -71
  171. package/src/mandate/types.ts +0 -21
  172. package/src/seams/index.ts +0 -11
  173. package/src/seams/types.ts +0 -81
  174. package/src/synth/deny-cases.ts +0 -663
  175. package/src/synth/evaluate.ts +0 -613
  176. package/src/synth/harness.ts +0 -68
  177. package/src/synth/minimize.ts +0 -48
  178. package/src/synth/permit-context.ts +0 -136
  179. package/src/synth/predicate-literals.ts +0 -27
  180. package/src/synth/synthesize-from-mandate.ts +0 -82
  181. package/src/verify/envelope.ts +0 -28
  182. package/src/verify/index.ts +0 -5
  183. package/src/verify/simulate.ts +0 -311
  184. package/src/verify/verify.ts +0 -243
package/src/errors.ts CHANGED
@@ -28,7 +28,6 @@ export type ErrorCode =
28
28
  | 'PREDICATE_TOO_DEEP'
29
29
  | 'TOO_MANY_LEAVES'
30
30
  | 'IN_OPERAND_LIMIT'
31
- | 'PREDICATE_ORACLE_OVER_LIMIT'
32
31
  | 'POLICY_CAP_EXCEEDED'
33
32
  | 'WASM_TOO_LARGE'
34
33
  // --- interpreter-side denies (canonical names; matches Rust DenyCode) ---
@@ -44,24 +43,6 @@ export type ErrorCode =
44
43
  | 'UNSUPPORTED_NODE'
45
44
  | 'STATEFUL_BOUND'
46
45
  | 'NOT_IN_ALLOWLIST'
47
- | 'FREQUENCY'
48
- // A `call_arg >= call_arg_scaled(..)` slippage floor was not met. Distinct
49
- // from the generic ARG_MISMATCH/STATEFUL_BOUND so a violated swap floor
50
- // reads as itself on the review card.
51
- | 'SLIPPAGE_FLOOR'
52
- // --- oracle denies (fatal evaluator errors) ---
53
- | 'ORACLE_STALE'
54
- | 'ORACLE_MISSING'
55
- | 'ORACLE_NO_CONFIRMATION'
56
- | 'ORACLE_DEVIATION_EXCEEDED'
57
- | 'ORACLE_MALFORMED_HISTORY'
58
- | 'ORACLE_FINGERPRINT_DRIFT'
59
- | 'ORACLE_PAUSED'
60
- | 'ORACLE_LEAF_INVALID_POSITION'
61
- | 'ORACLE_PARAMS_OUT_OF_RANGE'
62
- | 'ORACLE_DECIMALS_MISMATCH'
63
- | 'ORACLE_THRESHOLD_DECIMALS_OUT_OF_RANGE'
64
- | 'ORACLE_THRESHOLD_BASIS_REQUIRED'
65
46
  // --- escape-hatch compile gate ---
66
47
  | 'COMPILE_OK'
67
48
  | 'COMPILE_GATE_FAILED'
package/src/index.ts CHANGED
@@ -1,11 +1,8 @@
1
- export * from './adapters/oz/index.ts'
2
1
  export * from './errors.ts'
3
- export * from './ir/index.ts'
4
- export * from './mandate/index.ts'
5
2
  export * from './predicate/index.ts'
6
3
  export * from './record/index.ts'
7
4
  export * from './registry/index.ts'
8
5
  export * from './review-card/index.ts'
9
- export * from './seams/index.ts'
6
+ export * from './simulate/index.ts'
10
7
  export * from './synth/index.ts'
11
8
  export * from './types.ts'
@@ -52,8 +52,8 @@ import { Address, xdr } from '@stellar/stellar-sdk'
52
52
  import type { ToolError } from '../errors.ts'
53
53
  import {
54
54
  type ContextRuleDraft,
55
+ GRAMMAR_VERSION,
55
56
  OZ_LIMITS,
56
- type OZPrimitiveConfig,
57
57
  type PolicyRef,
58
58
  type SignerDraft,
59
59
  } from '../types.ts'
@@ -66,8 +66,8 @@ export interface BuildAddContextRuleArgs {
66
66
  * admin session. The deployer signs the install call via the admin rule
67
67
  * already on the account, which is separate from this list. */
68
68
  signers: SignerDraft[]
69
- /** The policy(ies) to attach to the new rule. Only `interpreter` refs
70
- * reach the wire today; `oz_builtin` is reserved for Phase 06 follow-ups. */
69
+ /** The policy(ies) to attach to the new rule. `interpreter` is the only
70
+ * kind: the OpenZeppelin built-in backend was removed. */
71
71
  policies: PolicyRef[]
72
72
  /** Per-policy install nonce; 1 for a fresh install. */
73
73
  installNonce: number
@@ -77,20 +77,12 @@ export interface BuildAddContextRuleArgs {
77
77
  encodedPredicate: string
78
78
  /** Hex sha256 of the canonical predicate XDR bytes. */
79
79
  predicateHash: string
80
- /** Per-policy oracle overrides. Absent on any key uses the wasm default. */
81
- oracleParams?: {
82
- maxStalenessSeconds?: number
83
- maxDeviationBps?: number
84
- /** Bound between the primary and secondary feeds. Tighten-only against
85
- * the wasm default, like the other two. */
86
- maxCrossFeedDeviationBps?: number
87
- }
88
80
  /** Hard pin to the interpreter's wasm grammar. Refusing here fails closed
89
81
  * before the chain does; the contract will refuse a mismatch again. */
90
82
  grammarVersion?: number
91
83
  }
92
84
 
93
- export const DEFAULT_GRAMMAR_VERSION = 1 as const
85
+ export const DEFAULT_GRAMMAR_VERSION = GRAMMAR_VERSION
94
86
 
95
87
  /** The verb `add_context_rule` takes on the wire. */
96
88
  export const ADD_CONTEXT_RULE_SYMBOL = 'add_context_rule' as const
@@ -130,20 +122,6 @@ export function buildAddContextRuleArgs(
130
122
  'a rule with no signers and no policies is refused at install (NoSignersAndPolicies)'
131
123
  )
132
124
  }
133
- // OZ's spending_limit caps spend on the CONTEXT CONTRACT - it takes no
134
- // token argument - so it refuses a Default rule on chain with a bare
135
- // #3227. Say which rule shape it needs here, before the encoding, rather
136
- // than letting the user read a numeric trap.
137
- if (
138
- args.policies.some((p) => p.kind === 'oz_builtin' && p.primitive.primitive === 'spending_limit')
139
- ) {
140
- if (draft.contextRuleType.kind !== 'call_contract') {
141
- throw limitError(
142
- 'INSTALL_BUILD_FAILED',
143
- `spending_limit caps spend on the rule's context contract, so the rule must be call_contract-scoped to that token - a "${draft.contextRuleType.kind}" rule is refused on chain (#3227)`
144
- )
145
- }
146
- }
147
125
 
148
126
  // ---- 2. context_type encoding ----
149
127
  const contextType = encodeContextRuleType(draft.contextRuleType)
@@ -173,15 +151,6 @@ const POLICY_INSTALL_PARAM_FIELDS = [
173
151
  'install_nonce',
174
152
  'predicate',
175
153
  'predicate_hash',
176
- 'oracle_max_staleness_seconds',
177
- 'oracle_max_deviation_bps',
178
- // Cross-feed divergence bound. A field added to the contract's
179
- // `PolicyInstallParams` changes the ABI: the host unpacks the map by field
180
- // count, so omitting one fails the entire install with
181
- // `Error(Object, UnexpectedSize)` and no indication of which field is
182
- // missing. The Rust tests build that struct in Rust and never cross this
183
- // boundary, so only a real install against a deployed contract catches it.
184
- 'oracle_max_xfeed_dev_bps',
185
154
  ] as const
186
155
 
187
156
  function encodeContextRuleType(
@@ -232,104 +201,13 @@ function encodePoliciesMap(args: BuildAddContextRuleArgs): xdr.ScVal {
232
201
  val: encodePolicyInstallParams(args),
233
202
  })
234
203
  )
235
- } else if (ref.kind === 'oz_builtin') {
236
- entries.push(
237
- new xdr.ScMapEntry({
238
- key: Address.fromString(ref.instanceAddress).toScVal(),
239
- val: encodeOzPrimitiveParams(ref.primitive),
240
- })
241
- )
242
204
  }
243
205
  }
244
206
  entries.sort(sortByScValSymbolString)
245
207
  return xdr.ScVal.scvMap(entries)
246
208
  }
247
209
 
248
- /** Encode the install params for one OZ built-in policy.
249
- *
250
- * Field names and types are read from the deployed contracts' own spec:
251
- * SpendingLimitAccountParams { period_ledgers: u32, spending_limit: i128 }
252
- * SimpleThresholdAccountParams { threshold: u32 }
253
- * WeightedThresholdAccountParams { signer_weights: map, threshold: u32 }
254
- * Entries are symbol-string ordered for the same reason the interpreter's
255
- * are: the host orders by symbol, not by XDR bytes.
256
- */
257
- function encodeOzPrimitiveParams(primitive: OZPrimitiveConfig): xdr.ScVal {
258
- const entries: xdr.ScMapEntry[] = []
259
- const push = (name: string, val: xdr.ScVal) =>
260
- entries.push(new xdr.ScMapEntry({ key: xdr.ScVal.scvSymbol(name), val }))
261
- const p = primitive.params as Record<string, unknown>
262
- switch (primitive.primitive) {
263
- case 'spending_limit': {
264
- const limit = p.spending_limit
265
- const period = p.period_ledgers
266
- if (typeof limit !== 'string' || typeof period !== 'number') {
267
- throw limitError(
268
- 'INSTALL_BUILD_FAILED',
269
- 'spending_limit needs { spending_limit: string; period_ledgers: number }'
270
- )
271
- }
272
- push('period_ledgers', xdr.ScVal.scvU32(period))
273
- push('spending_limit', encodeI128(limit))
274
- break
275
- }
276
- case 'simple_threshold': {
277
- const threshold = p.threshold
278
- if (typeof threshold !== 'number') {
279
- throw limitError('INSTALL_BUILD_FAILED', 'simple_threshold needs { threshold: number }')
280
- }
281
- push('threshold', xdr.ScVal.scvU32(threshold))
282
- break
283
- }
284
- case 'weighted_threshold': {
285
- const threshold = p.threshold
286
- const weights = p.weights as Record<string, number> | undefined
287
- if (typeof threshold !== 'number' || !weights) {
288
- throw limitError(
289
- 'INSTALL_BUILD_FAILED',
290
- 'weighted_threshold needs { threshold: number; weights: Record<address, number> }'
291
- )
292
- }
293
- const weightEntries = Object.entries(weights)
294
- .map(
295
- ([addr, w]) =>
296
- new xdr.ScMapEntry({
297
- key: Address.fromString(addr).toScVal(),
298
- val: xdr.ScVal.scvU32(w),
299
- })
300
- )
301
- .sort((a, b) => (a.key().toXDR('base64') < b.key().toXDR('base64') ? -1 : 1))
302
- push('signer_weights', xdr.ScVal.scvMap(weightEntries))
303
- push('threshold', xdr.ScVal.scvU32(threshold))
304
- break
305
- }
306
- }
307
- entries.sort((a, b) => sortBySymbolString(a.key(), b.key()))
308
- return xdr.ScVal.scvMap(entries)
309
- }
310
-
311
- function encodeI128(value: string): xdr.ScVal {
312
- const v = BigInt(value)
313
- return xdr.ScVal.scvI128(
314
- new xdr.Int128Parts({
315
- hi: new xdr.Int64(BigInt.asIntN(64, v >> 64n)),
316
- lo: new xdr.Uint64(BigInt.asUintN(64, v)),
317
- })
318
- )
319
- }
320
-
321
- /** The `PolicyInstallParams` ScVal an interpreter policy receives.
322
- *
323
- * Exported so the merge remedy can re-install a policy through `add_policy`
324
- * using the SAME encoder as a fresh install. Re-implementing it would risk
325
- * exactly the drift this file warns about: the field order is ABI-significant
326
- * and a differing encoding yields a rule that denies every call. */
327
- export type PolicyInstallParamArgs = Pick<
328
- BuildAddContextRuleArgs,
329
- 'encodedPredicate' | 'predicateHash' | 'installNonce' | 'oracleParams' | 'grammarVersion'
330
- >
331
-
332
- export function encodePolicyInstallParams(args: PolicyInstallParamArgs): xdr.ScVal {
210
+ function encodePolicyInstallParams(args: BuildAddContextRuleArgs): xdr.ScVal {
333
211
  const predicate = Buffer.from(args.encodedPredicate, 'base64')
334
212
  const computedHash = createHash('sha256').update(predicate).digest('hex')
335
213
  if (computedHash !== args.predicateHash) {
@@ -341,15 +219,11 @@ export function encodePolicyInstallParams(args: PolicyInstallParamArgs): xdr.ScV
341
219
  // Per-field value encoders. Each entry returns the ScVal to drop into the
342
220
  // map; the key symbol comes from the surrounding loop. Adding a field is
343
221
  // one row here plus the symbol in POLICY_INSTALL_PARAM_FIELDS.
344
- const oracleParams = args.oracleParams
345
222
  const valueFor: Record<(typeof POLICY_INSTALL_PARAM_FIELDS)[number], () => xdr.ScVal> = {
346
223
  grammar_version: () => xdr.ScVal.scvU32(args.grammarVersion ?? DEFAULT_GRAMMAR_VERSION),
347
224
  install_nonce: () => xdr.ScVal.scvU32(args.installNonce),
348
225
  predicate: () => xdr.ScVal.scvBytes(predicate),
349
226
  predicate_hash: () => xdr.ScVal.scvBytes(Buffer.from(args.predicateHash, 'hex')),
350
- oracle_max_staleness_seconds: () => encodeOptionU32(oracleParams?.maxStalenessSeconds),
351
- oracle_max_deviation_bps: () => encodeOptionU32(oracleParams?.maxDeviationBps),
352
- oracle_max_xfeed_dev_bps: () => encodeOptionU32(oracleParams?.maxCrossFeedDeviationBps),
353
227
  }
354
228
  const entries = POLICY_INSTALL_PARAM_FIELDS.map(
355
229
  (k) => new xdr.ScMapEntry({ key: xdr.ScVal.scvSymbol(k), val: valueFor[k]() })
@@ -362,14 +236,6 @@ export function encodePolicyInstallParams(args: PolicyInstallParamArgs): xdr.ScV
362
236
  return xdr.ScVal.scvMap(entries)
363
237
  }
364
238
 
365
- function encodeOptionU32(v: number | undefined): xdr.ScVal {
366
- if (v === undefined) return xdr.ScVal.scvVoid()
367
- if (!Number.isFinite(v) || v < 0 || v > 0xffffffff) {
368
- throw limitError('INSTALL_BUILD_FAILED', `oracle params value ${v} is outside u32 range`)
369
- }
370
- return xdr.ScVal.scvU32(v)
371
- }
372
-
373
239
  /** Sort host-map keys by their symbol-string form. The host orders map
374
240
  * entries by the SYMBOL STRING, not by the key's XDR bytes (a length
375
241
  * prefix in the encoding would otherwise put `amount` before `address`).