@invisible-labs/sdk 0.6.0-devnet.3 → 0.6.0-devnet.5

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 (45) hide show
  1. package/README.md +129 -15
  2. package/dist/.invisible-sdk-build-target.json +7 -0
  3. package/dist/{chunk-QQSI3ZD7.js → chunk-3MDHAS4D.js} +109 -17
  4. package/dist/chunk-3MDHAS4D.js.map +1 -0
  5. package/dist/{chunk-NKRVQXRP.js → chunk-3TGQ4CZ3.js} +297 -11
  6. package/dist/chunk-3TGQ4CZ3.js.map +1 -0
  7. package/dist/chunk-DCTYBUY3.js +258 -0
  8. package/dist/chunk-DCTYBUY3.js.map +1 -0
  9. package/dist/{chunk-NHEHCUS5.js → chunk-EBWTAXNT.js} +3 -3
  10. package/dist/{chunk-NHEHCUS5.js.map → chunk-EBWTAXNT.js.map} +1 -1
  11. package/dist/{chunk-V5HXJRBW.js → chunk-HJFMDMPY.js} +3 -3
  12. package/dist/chunk-HJFMDMPY.js.map +1 -0
  13. package/dist/{chunk-GHBQF3A7.js → chunk-QRN46R3F.js} +5 -2
  14. package/dist/chunk-QRN46R3F.js.map +1 -0
  15. package/dist/chunk-Y7AK6RBV.js +4189 -0
  16. package/dist/chunk-Y7AK6RBV.js.map +1 -0
  17. package/dist/{coordinator-VVJ33WF2.js → coordinator-PEWHNZ7I.js} +3 -3
  18. package/dist/{coordinator-VVJ33WF2.js.map → coordinator-PEWHNZ7I.js.map} +1 -1
  19. package/dist/events.js +3 -3
  20. package/dist/index.d.ts +69 -353
  21. package/dist/index.js +161 -43
  22. package/dist/index.js.map +1 -1
  23. package/dist/lp.d.ts +76 -18
  24. package/dist/lp.js +511 -111
  25. package/dist/lp.js.map +1 -1
  26. package/dist/presets.d.ts +7 -40
  27. package/dist/presets.js +10 -68
  28. package/dist/presets.js.map +1 -1
  29. package/dist/stats.js +1 -1
  30. package/dist/storage.js +2 -243
  31. package/dist/storage.js.map +1 -1
  32. package/dist/{errors-N2touVm4.d.ts → types.generated-YhFu9ZBR.d.ts} +65 -4
  33. package/dist/user.d.ts +134 -8
  34. package/dist/user.js +991 -250
  35. package/dist/user.js.map +1 -1
  36. package/package.json +5 -31
  37. package/dist/chunk-BWCGNTN5.js +0 -1153
  38. package/dist/chunk-BWCGNTN5.js.map +0 -1
  39. package/dist/chunk-DIA6U2CV.js +0 -1927
  40. package/dist/chunk-DIA6U2CV.js.map +0 -1
  41. package/dist/chunk-GHBQF3A7.js.map +0 -1
  42. package/dist/chunk-NKRVQXRP.js.map +0 -1
  43. package/dist/chunk-QQSI3ZD7.js.map +0 -1
  44. package/dist/chunk-V5HXJRBW.js.map +0 -1
  45. package/dist/types.generated-BSEBz4jR.d.ts +0 -68
@@ -57,6 +57,8 @@ function isValidEnvelopeKind(value) {
57
57
  var CoordinatorMessageType = {
58
58
  // Phase A: Swap/contract setup — unified user swap-open + LP position-open (JW-372 step 8).
59
59
  ContractRequest: "ContractRequest",
60
+ // V0 LP creation admission over the attested Noise session.
61
+ LpCreateAuthorization: "LpCreateAuthorization",
60
62
  // Phase B: DKG (Alice ↔ TEE)
61
63
  DkgInit: "DkgInit",
62
64
  DkgRound1: "DkgRound1",
@@ -93,6 +95,7 @@ function isValidMessageType(value) {
93
95
  var KIND_BY_TYPE = {
94
96
  // Pure request/response
95
97
  ContractRequest: /* @__PURE__ */ new Set([EnvelopeKind.REQUEST, EnvelopeKind.RESPONSE]),
98
+ LpCreateAuthorization: /* @__PURE__ */ new Set([EnvelopeKind.REQUEST, EnvelopeKind.RESPONSE]),
96
99
  DkgInit: /* @__PURE__ */ new Set([EnvelopeKind.REQUEST, EnvelopeKind.RESPONSE]),
97
100
  DkgRound1: /* @__PURE__ */ new Set([EnvelopeKind.REQUEST, EnvelopeKind.RESPONSE]),
98
101
  DkgRound2: /* @__PURE__ */ new Set([EnvelopeKind.REQUEST, EnvelopeKind.RESPONSE]),
@@ -127,6 +130,7 @@ var DIRECTION_BY_TYPE = {
127
130
  // Client-initiated
128
131
  ContractRequest: MessageDirection.BIDIRECTIONAL,
129
132
  // request c→co, response co→c
133
+ LpCreateAuthorization: MessageDirection.BIDIRECTIONAL,
130
134
  DkgInit: MessageDirection.BIDIRECTIONAL,
131
135
  DkgRound1: MessageDirection.BIDIRECTIONAL,
132
136
  DkgRound2: MessageDirection.BIDIRECTIONAL,
@@ -162,6 +166,8 @@ var COORDINATOR_BINARY_FIELD_NAMES = [
162
166
  "recovery_commitment",
163
167
  "redemption_commitment",
164
168
  "refill_public_key",
169
+ "resume_commitment",
170
+ "resume_secret",
165
171
  "round2_for_alice",
166
172
  "round2_for_lp",
167
173
  "share",
@@ -172,6 +178,8 @@ var COORDINATOR_BINARY_FIELD_NAMES = [
172
178
  var COORDINATOR_SCHEMA_PAYLOAD_CATEGORIES = {
173
179
  "request:ContractRequest": "request",
174
180
  "response:ContractRequest": "response",
181
+ "request:LpCreateAuthorization": "request",
182
+ "response:LpCreateAuthorization": "response",
175
183
  "request:DkgInit": "request",
176
184
  "response:DkgInit": "response",
177
185
  "request:DkgRound1": "request",
@@ -428,6 +436,7 @@ var coordinator_envelope_schema_default = {
428
436
  type: {
429
437
  enum: [
430
438
  "ContractRequest",
439
+ "LpCreateAuthorization",
431
440
  "DkgInit",
432
441
  "DkgRound1",
433
442
  "DkgRound2",
@@ -499,6 +508,24 @@ var coordinator_envelope_schema_default = {
499
508
  }
500
509
  }
501
510
  },
511
+ {
512
+ title: "LpCreateAuthorization request",
513
+ properties: {
514
+ kind: { const: "request" },
515
+ type: { const: "LpCreateAuthorization" },
516
+ swap_id: { type: "null" },
517
+ payload: { $ref: "#/$defs/lpCreateAuthorizationRequest" }
518
+ }
519
+ },
520
+ {
521
+ title: "LpCreateAuthorization response",
522
+ properties: {
523
+ kind: { const: "response" },
524
+ type: { const: "LpCreateAuthorization" },
525
+ swap_id: { type: "null" },
526
+ payload: { $ref: "#/$defs/lpCreateAuthorizationResponse" }
527
+ }
528
+ },
502
529
  {
503
530
  title: "DkgInit request",
504
531
  properties: {
@@ -509,7 +536,7 @@ var coordinator_envelope_schema_default = {
509
536
  const: "DkgInit"
510
537
  },
511
538
  payload: {
512
- $ref: "#/$defs/emptyObject"
539
+ $ref: "#/$defs/dkgInitRequest"
513
540
  }
514
541
  }
515
542
  },
@@ -537,7 +564,7 @@ var coordinator_envelope_schema_default = {
537
564
  const: "DkgRound1"
538
565
  },
539
566
  payload: {
540
- $ref: "#/$defs/dkgRoundPackage"
567
+ $ref: "#/$defs/dkgRoundRequestPackage"
541
568
  }
542
569
  }
543
570
  },
@@ -565,7 +592,7 @@ var coordinator_envelope_schema_default = {
565
592
  const: "DkgRound2"
566
593
  },
567
594
  payload: {
568
- $ref: "#/$defs/dkgRoundPackage"
595
+ $ref: "#/$defs/dkgRoundRequestPackage"
569
596
  }
570
597
  }
571
598
  },
@@ -957,6 +984,15 @@ var coordinator_envelope_schema_default = {
957
984
  additionalProperties: false,
958
985
  properties: {}
959
986
  },
987
+ dkgInitRequest: {
988
+ type: "object",
989
+ additionalProperties: false,
990
+ properties: {
991
+ resume_secret: {
992
+ $ref: "#/$defs/base64url32Bytes"
993
+ }
994
+ }
995
+ },
960
996
  syncRequest: {
961
997
  oneOf: [
962
998
  {
@@ -1065,6 +1101,9 @@ var coordinator_envelope_schema_default = {
1065
1101
  },
1066
1102
  sync_commitment: {
1067
1103
  $ref: "#/$defs/base64url32Bytes"
1104
+ },
1105
+ resume_commitment: {
1106
+ $ref: "#/$defs/base64url32Bytes"
1068
1107
  }
1069
1108
  }
1070
1109
  },
@@ -1120,6 +1159,114 @@ var coordinator_envelope_schema_default = {
1120
1159
  }
1121
1160
  ]
1122
1161
  },
1162
+ lpCreateAuthorizationRequest: {
1163
+ oneOf: [
1164
+ { $ref: "#/$defs/lpCreateAuthorizationChallengeRequest" },
1165
+ { $ref: "#/$defs/lpCreateAuthorizationProofRequest" }
1166
+ ]
1167
+ },
1168
+ lpCreateAuthorizationResponse: {
1169
+ oneOf: [
1170
+ { $ref: "#/$defs/lpCreateAuthorizationChallengeResponse" },
1171
+ { $ref: "#/$defs/lpCreateAuthorizationAuthorizedResponse" }
1172
+ ]
1173
+ },
1174
+ lpCreateAuthorizationChallengeRequest: {
1175
+ type: "object",
1176
+ additionalProperties: false,
1177
+ required: ["case", "value"],
1178
+ properties: {
1179
+ case: { const: "challenge" },
1180
+ value: { $ref: "#/$defs/lpCreateAuthorizationChallenge" }
1181
+ }
1182
+ },
1183
+ lpCreateAuthorizationProofRequest: {
1184
+ type: "object",
1185
+ additionalProperties: false,
1186
+ required: ["case", "value"],
1187
+ properties: {
1188
+ case: { const: "proof" },
1189
+ value: { $ref: "#/$defs/lpCreateAuthorizationProof" }
1190
+ }
1191
+ },
1192
+ lpCreateAuthorizationChallengeResponse: {
1193
+ type: "object",
1194
+ additionalProperties: false,
1195
+ required: ["case", "value"],
1196
+ properties: {
1197
+ case: { const: "challenge" },
1198
+ value: { $ref: "#/$defs/lpCreateAuthorizationChallengeResponseValue" }
1199
+ }
1200
+ },
1201
+ lpCreateAuthorizationAuthorizedResponse: {
1202
+ type: "object",
1203
+ additionalProperties: false,
1204
+ required: ["case", "value"],
1205
+ properties: {
1206
+ case: { const: "authorized" },
1207
+ value: { $ref: "#/$defs/lpCreateAuthorizationAuthorized" }
1208
+ }
1209
+ },
1210
+ lpCreateAuthorizationChallenge: {
1211
+ type: "object",
1212
+ additionalProperties: false,
1213
+ required: ["public_key", "intent"],
1214
+ properties: {
1215
+ public_key: { $ref: "#/$defs/lpSolanaAddress" },
1216
+ intent: { $ref: "#/$defs/lpCreatePositionIntent" }
1217
+ }
1218
+ },
1219
+ lpCreateAuthorizationProof: {
1220
+ type: "object",
1221
+ additionalProperties: false,
1222
+ required: ["authorization_id", "public_key", "message", "signature"],
1223
+ properties: {
1224
+ authorization_id: { $ref: "#/$defs/lpAuthorizationId" },
1225
+ public_key: { $ref: "#/$defs/lpSolanaAddress" },
1226
+ message: { $ref: "#/$defs/lpSiwsMessage" },
1227
+ signature: { $ref: "#/$defs/base64url64Bytes" }
1228
+ }
1229
+ },
1230
+ lpCreateAuthorizationChallengeResponseValue: {
1231
+ type: "object",
1232
+ additionalProperties: false,
1233
+ required: ["authorization_id", "message", "expires_at_ms", "valid_for_ms"],
1234
+ properties: {
1235
+ authorization_id: { $ref: "#/$defs/lpAuthorizationId" },
1236
+ message: { $ref: "#/$defs/lpSiwsMessage" },
1237
+ expires_at_ms: { $ref: "#/$defs/positiveSafeUInt" },
1238
+ valid_for_ms: { $ref: "#/$defs/positiveSafeUInt" }
1239
+ }
1240
+ },
1241
+ lpCreateAuthorizationAuthorized: {
1242
+ type: "object",
1243
+ additionalProperties: false,
1244
+ required: ["authorization_id"],
1245
+ properties: {
1246
+ authorization_id: { $ref: "#/$defs/lpAuthorizationId" }
1247
+ }
1248
+ },
1249
+ lpCreatePositionIntent: {
1250
+ type: "object",
1251
+ additionalProperties: false,
1252
+ required: [
1253
+ "committed_lamports",
1254
+ "shard_count",
1255
+ "shard_amount_lamports",
1256
+ "refill_threshold"
1257
+ ],
1258
+ properties: {
1259
+ committed_lamports: { $ref: "#/$defs/positiveSafeUInt" },
1260
+ shard_count: { $ref: "#/$defs/lpShardCount" },
1261
+ shard_amount_lamports: { $ref: "#/$defs/positiveSafeUInt" },
1262
+ refill_threshold: { $ref: "#/$defs/lpCreationRefillThreshold" }
1263
+ }
1264
+ },
1265
+ lpCreationRefillThreshold: {
1266
+ type: "integer",
1267
+ minimum: 0,
1268
+ maximum: 300
1269
+ },
1123
1270
  payoutSpec: {
1124
1271
  oneOf: [
1125
1272
  {
@@ -1315,6 +1462,19 @@ var coordinator_envelope_schema_default = {
1315
1462
  }
1316
1463
  }
1317
1464
  },
1465
+ dkgRoundRequestPackage: {
1466
+ type: "object",
1467
+ additionalProperties: false,
1468
+ required: ["package"],
1469
+ properties: {
1470
+ package: {
1471
+ $ref: "#/$defs/base64urlBytes"
1472
+ },
1473
+ resume_secret: {
1474
+ $ref: "#/$defs/base64url32Bytes"
1475
+ }
1476
+ }
1477
+ },
1318
1478
  dkgRound1Response: {
1319
1479
  type: "object",
1320
1480
  additionalProperties: false,
@@ -1351,6 +1511,9 @@ var coordinator_envelope_schema_default = {
1351
1511
  },
1352
1512
  recovery_commitment: {
1353
1513
  $ref: "#/$defs/base64url32Bytes"
1514
+ },
1515
+ resume_secret: {
1516
+ $ref: "#/$defs/base64url32Bytes"
1354
1517
  }
1355
1518
  }
1356
1519
  },
@@ -1476,6 +1639,8 @@ var coordinator_envelope_schema_default = {
1476
1639
  "locked_pending_payout",
1477
1640
  "submitted",
1478
1641
  "confirming",
1642
+ "retry_delayed",
1643
+ "recovery_required",
1479
1644
  "completed",
1480
1645
  "refund_pending",
1481
1646
  "refunded",
@@ -1485,6 +1650,19 @@ var coordinator_envelope_schema_default = {
1485
1650
  normalUserRefundability: {
1486
1651
  enum: ["available_now", "request_pending", "blocked_by_lock", "stale", "unavailable"]
1487
1652
  },
1653
+ normalUserRefundStatus: {
1654
+ enum: [
1655
+ "queued",
1656
+ "reserved",
1657
+ "submitted",
1658
+ "confirming",
1659
+ "retrying",
1660
+ "finalized",
1661
+ "failed",
1662
+ "partial",
1663
+ "canceled"
1664
+ ]
1665
+ },
1488
1666
  sourceLiquidityUse: {
1489
1667
  enum: [
1490
1668
  "not_materialized",
@@ -1543,6 +1721,7 @@ var coordinator_envelope_schema_default = {
1543
1721
  "status",
1544
1722
  "settlement_phase",
1545
1723
  "refundability",
1724
+ "refund_status",
1546
1725
  "source_liquidity_use",
1547
1726
  "destination_wallet",
1548
1727
  "deposit_amount_lamports",
@@ -1552,6 +1731,7 @@ var coordinator_envelope_schema_default = {
1552
1731
  "settled_amount_lamports",
1553
1732
  "protocol_fee_lamports",
1554
1733
  "network_fee_lost_lamports",
1734
+ "recovery_refund_remaining_lamports",
1555
1735
  "withdrawal_requested_lamports",
1556
1736
  "withdrawal_landed_lamports",
1557
1737
  "withdrawal_landed_fee_lamports",
@@ -1575,6 +1755,16 @@ var coordinator_envelope_schema_default = {
1575
1755
  refundability: {
1576
1756
  $ref: "#/$defs/normalUserRefundability"
1577
1757
  },
1758
+ refund_status: {
1759
+ anyOf: [
1760
+ {
1761
+ type: "null"
1762
+ },
1763
+ {
1764
+ $ref: "#/$defs/normalUserRefundStatus"
1765
+ }
1766
+ ]
1767
+ },
1578
1768
  source_liquidity_use: {
1579
1769
  $ref: "#/$defs/sourceLiquidityUse"
1580
1770
  },
@@ -1617,6 +1807,9 @@ var coordinator_envelope_schema_default = {
1617
1807
  $ref: "#/$defs/safeUInt"
1618
1808
  }
1619
1809
  },
1810
+ recovery_refund_remaining_lamports: {
1811
+ $ref: "#/$defs/safeUInt"
1812
+ },
1620
1813
  withdrawal_requested_lamports: {
1621
1814
  $ref: "#/$defs/safeUInt"
1622
1815
  },
@@ -1978,6 +2171,23 @@ var coordinator_envelope_schema_default = {
1978
2171
  maxLength: 96,
1979
2172
  pattern: "^[A-Za-z0-9_-]+$"
1980
2173
  },
2174
+ lpAuthorizationId: {
2175
+ type: "string",
2176
+ minLength: 16,
2177
+ maxLength: 128,
2178
+ pattern: "^[A-Za-z0-9_-]+$"
2179
+ },
2180
+ lpSolanaAddress: {
2181
+ type: "string",
2182
+ minLength: 32,
2183
+ maxLength: 44,
2184
+ pattern: "^[1-9A-HJ-NP-Za-km-z]+$"
2185
+ },
2186
+ lpSiwsMessage: {
2187
+ type: "string",
2188
+ minLength: 1,
2189
+ maxLength: 4096
2190
+ },
1981
2191
  lpRedemptionId: {
1982
2192
  type: "string",
1983
2193
  minLength: 1,
@@ -2470,6 +2680,7 @@ var coordinator_envelope_schema_default = {
2470
2680
  type: "object",
2471
2681
  additionalProperties: false,
2472
2682
  required: [
2683
+ "creation_authorization_id",
2473
2684
  "auth_public_key",
2474
2685
  "refill_public_key",
2475
2686
  "redemption_commitment",
@@ -2481,6 +2692,9 @@ var coordinator_envelope_schema_default = {
2481
2692
  "created_at_ms"
2482
2693
  ],
2483
2694
  properties: {
2695
+ creation_authorization_id: {
2696
+ $ref: "#/$defs/lpAuthorizationId"
2697
+ },
2484
2698
  auth_public_key: {
2485
2699
  $ref: "#/$defs/base64url32Bytes"
2486
2700
  },
@@ -2919,11 +3133,30 @@ var coordinator_envelope_schema_default = {
2919
3133
  created_at_ms: {
2920
3134
  $ref: "#/$defs/positiveSafeUInt"
2921
3135
  },
3136
+ redemption_permission: {
3137
+ $ref: "#/$defs/lpRedemptionPermission"
3138
+ },
2922
3139
  actor_sync: {
2923
3140
  $ref: "#/$defs/lpActorSyncView"
2924
3141
  }
2925
3142
  }
2926
3143
  },
3144
+ lpRedemptionPermission: {
3145
+ type: "object",
3146
+ additionalProperties: false,
3147
+ required: ["state", "grant_revision", "observed_at_ms"],
3148
+ properties: {
3149
+ state: {
3150
+ enum: ["unknown", "locked", "enabled"]
3151
+ },
3152
+ grant_revision: {
3153
+ $ref: "#/$defs/safeUInt"
3154
+ },
3155
+ observed_at_ms: {
3156
+ $ref: "#/$defs/positiveSafeUInt"
3157
+ }
3158
+ }
3159
+ },
2927
3160
  lpActorSyncView: {
2928
3161
  type: "object",
2929
3162
  additionalProperties: false,
@@ -3004,6 +3237,9 @@ var coordinator_envelope_schema_default = {
3004
3237
  redeemable_fee_source_count: {
3005
3238
  $ref: "#/$defs/safeUInt"
3006
3239
  },
3240
+ redeemable_source_count: {
3241
+ $ref: "#/$defs/safeUInt"
3242
+ },
3007
3243
  pending_reservation_count: {
3008
3244
  $ref: "#/$defs/safeUInt"
3009
3245
  },
@@ -3102,6 +3338,9 @@ var coordinator_envelope_schema_default = {
3102
3338
  state: {
3103
3339
  enum: ["requested", "match_requested", "reserved", "pending", "confirmed", "rejected"]
3104
3340
  },
3341
+ withdrawal_mode: {
3342
+ enum: ["exact", "max_available"]
3343
+ },
3105
3344
  accepted_lamports: {
3106
3345
  $ref: "#/$defs/positiveSafeUInt"
3107
3346
  },
@@ -3244,6 +3483,7 @@ var coordinator_envelope_schema_default = {
3244
3483
  "destination_addresses",
3245
3484
  "deposit_principal_lamports",
3246
3485
  "earned_fee_lamports",
3486
+ "withdrawal_mode",
3247
3487
  "requested_at_ms"
3248
3488
  ],
3249
3489
  properties: {
@@ -3262,6 +3502,9 @@ var coordinator_envelope_schema_default = {
3262
3502
  earned_fee_lamports: {
3263
3503
  $ref: "#/$defs/safeUInt"
3264
3504
  },
3505
+ withdrawal_mode: {
3506
+ enum: ["exact", "max_available"]
3507
+ },
3265
3508
  requested_at_ms: {
3266
3509
  $ref: "#/$defs/positiveSafeUInt"
3267
3510
  }
@@ -3270,7 +3513,13 @@ var coordinator_envelope_schema_default = {
3270
3513
  lpWithdrawalExecutionView: {
3271
3514
  type: "object",
3272
3515
  additionalProperties: false,
3273
- required: ["withdrawal_id", "tx_signatures"],
3516
+ required: [
3517
+ "withdrawal_id",
3518
+ "tx_signatures",
3519
+ "accepted_lamports",
3520
+ "accepted_deposit_principal_lamports",
3521
+ "accepted_earned_fee_lamports"
3522
+ ],
3274
3523
  properties: {
3275
3524
  withdrawal_id: {
3276
3525
  type: "string",
@@ -3283,6 +3532,15 @@ var coordinator_envelope_schema_default = {
3283
3532
  items: {
3284
3533
  $ref: "#/$defs/lpTxSignature"
3285
3534
  }
3535
+ },
3536
+ accepted_lamports: {
3537
+ $ref: "#/$defs/positiveSafeUInt"
3538
+ },
3539
+ accepted_deposit_principal_lamports: {
3540
+ $ref: "#/$defs/safeUInt"
3541
+ },
3542
+ accepted_earned_fee_lamports: {
3543
+ $ref: "#/$defs/safeUInt"
3286
3544
  }
3287
3545
  }
3288
3546
  }
@@ -3295,6 +3553,7 @@ var MAX_FRAME_SIZE = 256 * 1024;
3295
3553
  var COORDINATOR_ENVELOPE_SCHEMA = coordinator_envelope_schema_default;
3296
3554
  var LP_MAX_TARGET_SHARDS = 300;
3297
3555
  var LP_WITHDRAW_REQUEST_PATH = "lp_command.withdrawRequest";
3556
+ var UNKNOWN_SWAP_ID = "<unknown>";
3298
3557
  var binaryFieldNames = new Set(COORDINATOR_BINARY_FIELD_NAMES);
3299
3558
  var ajv = new Ajv2020({
3300
3559
  allErrors: true,
@@ -3413,14 +3672,25 @@ function validateLpCommandSemanticsForSigning(command) {
3413
3672
  return;
3414
3673
  }
3415
3674
  case "withdrawRequest": {
3416
- const { deposit_principal_lamports, earned_fee_lamports, destination_addresses } = command.payload.value;
3675
+ const {
3676
+ deposit_principal_lamports,
3677
+ earned_fee_lamports,
3678
+ destination_addresses,
3679
+ withdrawal_mode
3680
+ } = command.payload.value;
3417
3681
  const bucketTotal = deposit_principal_lamports + earned_fee_lamports;
3418
- if (!Number.isSafeInteger(bucketTotal) || bucketTotal <= 0) {
3682
+ if (withdrawal_mode === "exact" && (!Number.isSafeInteger(bucketTotal) || bucketTotal <= 0)) {
3419
3683
  throw new CoordinatorError(
3420
3684
  ErrorCode.ERR_INVALID_PAYLOAD,
3421
3685
  `${LP_WITHDRAW_REQUEST_PATH} bucket claim must be positive`
3422
3686
  );
3423
3687
  }
3688
+ if (withdrawal_mode === "max_available" && bucketTotal !== 0) {
3689
+ throw new CoordinatorError(
3690
+ ErrorCode.ERR_INVALID_PAYLOAD,
3691
+ `${LP_WITHDRAW_REQUEST_PATH} max_available must not carry bucket claims`
3692
+ );
3693
+ }
3424
3694
  validateUniqueLpAddresses(LP_WITHDRAW_REQUEST_PATH, destination_addresses);
3425
3695
  return;
3426
3696
  }
@@ -3523,10 +3793,11 @@ function fromWireEnvelope(value) {
3523
3793
  const type = value.type;
3524
3794
  const swapId = value.swap_id;
3525
3795
  const payload = fromWireValue(value.payload);
3526
- if (kind === EnvelopeKind.RESPONSE && type === CoordinatorMessageType.ContractRequest && swapId !== null && isRecord2(payload) && typeof payload.swap_id === "string" && payload.swap_id !== swapId) {
3796
+ if (kind === EnvelopeKind.RESPONSE && type === CoordinatorMessageType.ContractRequest && isSwapRequestResponsePayload(payload) && (!swapId || payload.swap_id !== swapId)) {
3797
+ const payloadSwapId = isRecord2(payload) ? String(payload.swap_id) : UNKNOWN_SWAP_ID;
3527
3798
  throw new CoordinatorError(
3528
3799
  ErrorCode.ERR_INVALID_PAYLOAD,
3529
- `ContractRequest response: envelope.swap_id (${swapId}) does not match payload.swap_id (${payload.swap_id})`
3800
+ `ContractRequest response requires matching non-null swap_id: envelope.swap_id (${swapId ?? "null"}), payload.swap_id (${payloadSwapId})`
3530
3801
  );
3531
3802
  }
3532
3803
  return {
@@ -3614,6 +3885,9 @@ function requiredPayloadFields(kind, type) {
3614
3885
  return ["actor", "amount_lamports", "payout_spec", "sync_commitment"];
3615
3886
  case "response:ContractRequest":
3616
3887
  return ["swap_id", "accepted", "policy_snapshot"];
3888
+ case "request:LpCreateAuthorization":
3889
+ case "response:LpCreateAuthorization":
3890
+ return ["case", "value"];
3617
3891
  case "response:DkgInit":
3618
3892
  return ["ready"];
3619
3893
  case "request:DkgRound1":
@@ -3759,6 +4033,9 @@ function uniqueStrings(value, index, all) {
3759
4033
  function isRecord2(value) {
3760
4034
  return typeof value === "object" && value !== null && !Array.isArray(value);
3761
4035
  }
4036
+ function isSwapRequestResponsePayload(value) {
4037
+ return isRecord2(value) && value.accepted === true && typeof value.swap_id === "string";
4038
+ }
3762
4039
  function stripUndefined(value) {
3763
4040
  const out = {};
3764
4041
  for (const [key, item] of Object.entries(value)) {
@@ -3802,7 +4079,16 @@ function base64UrlToBytes(value, field) {
3802
4079
  return out;
3803
4080
  }
3804
4081
  var asSwapRequestPayload = (e) => e.payload;
3805
- var asSwapRequestResponsePayload = (e) => e.payload;
4082
+ var asSwapRequestResponsePayload = (e) => {
4083
+ if (e.kind !== EnvelopeKind.RESPONSE || e.type !== CoordinatorMessageType.ContractRequest || e.swap_id === null || !isSwapRequestResponsePayload(e.payload) || e.payload.swap_id !== e.swap_id) {
4084
+ const payloadSwapId = isRecord2(e.payload) ? String(e.payload.swap_id) : UNKNOWN_SWAP_ID;
4085
+ throw new CoordinatorError(
4086
+ ErrorCode.ERR_INVALID_PAYLOAD,
4087
+ `ContractRequest response: envelope.swap_id (${e.swap_id}) does not match payload.swap_id (${payloadSwapId})`
4088
+ );
4089
+ }
4090
+ return e.payload;
4091
+ };
3806
4092
  var asDkgInitPayload = (e) => e.payload;
3807
4093
  var asDkgInitResponsePayload = (e) => e.payload;
3808
4094
  var asDkgRound1Payload = (e) => e.payload;
@@ -3834,5 +4120,5 @@ var asErrorPayload = (e) => {
3834
4120
  };
3835
4121
 
3836
4122
  export { COORDINATOR_BINARY_FIELD_NAMES, COORDINATOR_ENVELOPE_SCHEMA, COORDINATOR_SCHEMA_PAYLOAD_CATEGORIES, CoordinatorError, CoordinatorMessageType, DEFAULT_PAYOUT_WINDOW_ID, DIRECTION_BY_TYPE, ENVELOPE_VERSION, EnvelopeKind, ErrorCode, INITIAL_STATE, MAX_FRAME_SIZE, MessageDirection, PAYOUT_WINDOW_OPTIONS, TERMINAL_STATES, TRANSITIONS, VALID_SWAP_STATES, asDelegateAckPayload, asDelegateSharePayload, asDelegateShareResponsePayload, asDepositConfirmedPayload, asDkgCompletePayload, asDkgInitPayload, asDkgInitResponsePayload, asDkgRound1Payload, asDkgRound1ResponsePayload, asDkgRound2Payload, asDkgRound2ResponsePayload, asErrorPayload, asLpCommandResponsePayload, asPayoutExecutedPayload, asSwapRequestPayload, asSwapRequestResponsePayload, asSyncRequiredPayload, asSyncUserRequestPayload, asSyncUserResponsePayload, asWithdrawAcceptedPayload, asWithdrawExecutedPayload, asWithdrawRequestPayload, decode, encode, encodeLpCommandForSigning, encodeValidated, isAllowedInState, isAllowedKindForType, isPayoutWindowId, isValidEnvelopeKind, isValidErrorCode, isValidMessageType, isValidSwapState, lpSignedCommandEnvelope, nextState, payloadCategory, payoutWindowLabelForId, payoutWindowOptionById, safeEncode, scheduledPayoutWindowOptions, scheduledPayoutWindowSeconds };
3837
- //# sourceMappingURL=chunk-NKRVQXRP.js.map
3838
- //# sourceMappingURL=chunk-NKRVQXRP.js.map
4123
+ //# sourceMappingURL=chunk-3TGQ4CZ3.js.map
4124
+ //# sourceMappingURL=chunk-3TGQ4CZ3.js.map