@invisible-labs/sdk 0.6.0-devnet.2 → 0.6.0-devnet.4
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 +186 -70
- package/dist/.invisible-sdk-build-target.json +7 -0
- package/dist/{chunk-TQNNTV5F.js → chunk-4X5OCCQW.js} +3 -3
- package/dist/{chunk-TQNNTV5F.js.map → chunk-4X5OCCQW.js.map} +1 -1
- package/dist/{chunk-7DSVN3MV.js → chunk-5NNEO7IK.js} +41 -36
- package/dist/chunk-5NNEO7IK.js.map +1 -0
- package/dist/chunk-BRDLLGCZ.js +59 -0
- package/dist/chunk-BRDLLGCZ.js.map +1 -0
- package/dist/{chunk-NCY4FCYU.js → chunk-DIA6U2CV.js} +19 -3
- package/dist/chunk-DIA6U2CV.js.map +1 -0
- package/dist/{chunk-LBC7ALYO.js → chunk-E4DCEDAG.js} +177 -12
- package/dist/chunk-E4DCEDAG.js.map +1 -0
- package/dist/{chunk-OHIM2YWU.js → chunk-GHBQF3A7.js} +2 -2
- package/dist/chunk-GHBQF3A7.js.map +1 -0
- package/dist/{chunk-SZAYO2L5.js → chunk-NHEHCUS5.js} +3 -3
- package/dist/{chunk-SZAYO2L5.js.map → chunk-NHEHCUS5.js.map} +1 -1
- package/dist/{chunk-XUWBGET5.js → chunk-UADJCUPK.js} +125 -18
- package/dist/chunk-UADJCUPK.js.map +1 -0
- package/dist/{chunk-JRMKCE3S.js → chunk-V5HXJRBW.js} +3 -3
- package/dist/{chunk-JRMKCE3S.js.map → chunk-V5HXJRBW.js.map} +1 -1
- package/dist/{coordinator-7Y45MCCZ.js → coordinator-ZNLGAYXD.js} +3 -3
- package/dist/{coordinator-7Y45MCCZ.js.map → coordinator-ZNLGAYXD.js.map} +1 -1
- package/dist/events.js +3 -3
- package/dist/index.d.ts +62 -300
- package/dist/index.js +98 -43
- package/dist/index.js.map +1 -1
- package/dist/lp.d.ts +51 -10
- package/dist/lp.js +313 -86
- package/dist/lp.js.map +1 -1
- package/dist/presets.d.ts +5 -42
- package/dist/presets.js +11 -62
- package/dist/presets.js.map +1 -1
- package/dist/stats.js +1 -1
- package/dist/storage.js +1 -1
- package/dist/{createSession-D3ym-Ira.d.ts → types.generated-DJBTjLpP.d.ts} +37 -53
- package/dist/user.d.ts +94 -112
- package/dist/user.js +649 -248
- package/dist/user.js.map +1 -1
- package/package.json +2 -28
- package/dist/chunk-7DSVN3MV.js.map +0 -1
- package/dist/chunk-LBC7ALYO.js.map +0 -1
- package/dist/chunk-NCY4FCYU.js.map +0 -1
- package/dist/chunk-OHIM2YWU.js.map +0 -1
- package/dist/chunk-XUWBGET5.js.map +0 -1
- package/dist/types.generated-CHGSbmLp.d.ts +0 -67
|
@@ -162,6 +162,8 @@ var COORDINATOR_BINARY_FIELD_NAMES = [
|
|
|
162
162
|
"recovery_commitment",
|
|
163
163
|
"redemption_commitment",
|
|
164
164
|
"refill_public_key",
|
|
165
|
+
"resume_commitment",
|
|
166
|
+
"resume_secret",
|
|
165
167
|
"round2_for_alice",
|
|
166
168
|
"round2_for_lp",
|
|
167
169
|
"share",
|
|
@@ -509,7 +511,7 @@ var coordinator_envelope_schema_default = {
|
|
|
509
511
|
const: "DkgInit"
|
|
510
512
|
},
|
|
511
513
|
payload: {
|
|
512
|
-
$ref: "#/$defs/
|
|
514
|
+
$ref: "#/$defs/dkgInitRequest"
|
|
513
515
|
}
|
|
514
516
|
}
|
|
515
517
|
},
|
|
@@ -537,7 +539,7 @@ var coordinator_envelope_schema_default = {
|
|
|
537
539
|
const: "DkgRound1"
|
|
538
540
|
},
|
|
539
541
|
payload: {
|
|
540
|
-
$ref: "#/$defs/
|
|
542
|
+
$ref: "#/$defs/dkgRoundRequestPackage"
|
|
541
543
|
}
|
|
542
544
|
}
|
|
543
545
|
},
|
|
@@ -565,7 +567,7 @@ var coordinator_envelope_schema_default = {
|
|
|
565
567
|
const: "DkgRound2"
|
|
566
568
|
},
|
|
567
569
|
payload: {
|
|
568
|
-
$ref: "#/$defs/
|
|
570
|
+
$ref: "#/$defs/dkgRoundRequestPackage"
|
|
569
571
|
}
|
|
570
572
|
}
|
|
571
573
|
},
|
|
@@ -849,6 +851,7 @@ var coordinator_envelope_schema_default = {
|
|
|
849
851
|
"dkg_init",
|
|
850
852
|
"dkg_round1",
|
|
851
853
|
"dkg_round2",
|
|
854
|
+
"dkg_abort",
|
|
852
855
|
"dkg_finalize",
|
|
853
856
|
"funding_plan",
|
|
854
857
|
"funding_confirmation",
|
|
@@ -913,7 +916,7 @@ var coordinator_envelope_schema_default = {
|
|
|
913
916
|
},
|
|
914
917
|
entryAmountLamports: {
|
|
915
918
|
type: "integer",
|
|
916
|
-
minimum:
|
|
919
|
+
minimum: 15e8,
|
|
917
920
|
maximum: 1e11
|
|
918
921
|
},
|
|
919
922
|
u32: {
|
|
@@ -956,6 +959,15 @@ var coordinator_envelope_schema_default = {
|
|
|
956
959
|
additionalProperties: false,
|
|
957
960
|
properties: {}
|
|
958
961
|
},
|
|
962
|
+
dkgInitRequest: {
|
|
963
|
+
type: "object",
|
|
964
|
+
additionalProperties: false,
|
|
965
|
+
properties: {
|
|
966
|
+
resume_secret: {
|
|
967
|
+
$ref: "#/$defs/base64url32Bytes"
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
},
|
|
959
971
|
syncRequest: {
|
|
960
972
|
oneOf: [
|
|
961
973
|
{
|
|
@@ -1064,6 +1076,9 @@ var coordinator_envelope_schema_default = {
|
|
|
1064
1076
|
},
|
|
1065
1077
|
sync_commitment: {
|
|
1066
1078
|
$ref: "#/$defs/base64url32Bytes"
|
|
1079
|
+
},
|
|
1080
|
+
resume_commitment: {
|
|
1081
|
+
$ref: "#/$defs/base64url32Bytes"
|
|
1067
1082
|
}
|
|
1068
1083
|
}
|
|
1069
1084
|
},
|
|
@@ -1314,6 +1329,19 @@ var coordinator_envelope_schema_default = {
|
|
|
1314
1329
|
}
|
|
1315
1330
|
}
|
|
1316
1331
|
},
|
|
1332
|
+
dkgRoundRequestPackage: {
|
|
1333
|
+
type: "object",
|
|
1334
|
+
additionalProperties: false,
|
|
1335
|
+
required: ["package"],
|
|
1336
|
+
properties: {
|
|
1337
|
+
package: {
|
|
1338
|
+
$ref: "#/$defs/base64urlBytes"
|
|
1339
|
+
},
|
|
1340
|
+
resume_secret: {
|
|
1341
|
+
$ref: "#/$defs/base64url32Bytes"
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
},
|
|
1317
1345
|
dkgRound1Response: {
|
|
1318
1346
|
type: "object",
|
|
1319
1347
|
additionalProperties: false,
|
|
@@ -1350,6 +1378,9 @@ var coordinator_envelope_schema_default = {
|
|
|
1350
1378
|
},
|
|
1351
1379
|
recovery_commitment: {
|
|
1352
1380
|
$ref: "#/$defs/base64url32Bytes"
|
|
1381
|
+
},
|
|
1382
|
+
resume_secret: {
|
|
1383
|
+
$ref: "#/$defs/base64url32Bytes"
|
|
1353
1384
|
}
|
|
1354
1385
|
}
|
|
1355
1386
|
},
|
|
@@ -1475,6 +1506,8 @@ var coordinator_envelope_schema_default = {
|
|
|
1475
1506
|
"locked_pending_payout",
|
|
1476
1507
|
"submitted",
|
|
1477
1508
|
"confirming",
|
|
1509
|
+
"retry_delayed",
|
|
1510
|
+
"recovery_required",
|
|
1478
1511
|
"completed",
|
|
1479
1512
|
"refund_pending",
|
|
1480
1513
|
"refunded",
|
|
@@ -1484,6 +1517,19 @@ var coordinator_envelope_schema_default = {
|
|
|
1484
1517
|
normalUserRefundability: {
|
|
1485
1518
|
enum: ["available_now", "request_pending", "blocked_by_lock", "stale", "unavailable"]
|
|
1486
1519
|
},
|
|
1520
|
+
normalUserRefundStatus: {
|
|
1521
|
+
enum: [
|
|
1522
|
+
"queued",
|
|
1523
|
+
"reserved",
|
|
1524
|
+
"submitted",
|
|
1525
|
+
"confirming",
|
|
1526
|
+
"retrying",
|
|
1527
|
+
"finalized",
|
|
1528
|
+
"failed",
|
|
1529
|
+
"partial",
|
|
1530
|
+
"canceled"
|
|
1531
|
+
]
|
|
1532
|
+
},
|
|
1487
1533
|
sourceLiquidityUse: {
|
|
1488
1534
|
enum: [
|
|
1489
1535
|
"not_materialized",
|
|
@@ -1542,6 +1588,7 @@ var coordinator_envelope_schema_default = {
|
|
|
1542
1588
|
"status",
|
|
1543
1589
|
"settlement_phase",
|
|
1544
1590
|
"refundability",
|
|
1591
|
+
"refund_status",
|
|
1545
1592
|
"source_liquidity_use",
|
|
1546
1593
|
"destination_wallet",
|
|
1547
1594
|
"deposit_amount_lamports",
|
|
@@ -1551,6 +1598,7 @@ var coordinator_envelope_schema_default = {
|
|
|
1551
1598
|
"settled_amount_lamports",
|
|
1552
1599
|
"protocol_fee_lamports",
|
|
1553
1600
|
"network_fee_lost_lamports",
|
|
1601
|
+
"recovery_refund_remaining_lamports",
|
|
1554
1602
|
"withdrawal_requested_lamports",
|
|
1555
1603
|
"withdrawal_landed_lamports",
|
|
1556
1604
|
"withdrawal_landed_fee_lamports",
|
|
@@ -1574,6 +1622,16 @@ var coordinator_envelope_schema_default = {
|
|
|
1574
1622
|
refundability: {
|
|
1575
1623
|
$ref: "#/$defs/normalUserRefundability"
|
|
1576
1624
|
},
|
|
1625
|
+
refund_status: {
|
|
1626
|
+
anyOf: [
|
|
1627
|
+
{
|
|
1628
|
+
type: "null"
|
|
1629
|
+
},
|
|
1630
|
+
{
|
|
1631
|
+
$ref: "#/$defs/normalUserRefundStatus"
|
|
1632
|
+
}
|
|
1633
|
+
]
|
|
1634
|
+
},
|
|
1577
1635
|
source_liquidity_use: {
|
|
1578
1636
|
$ref: "#/$defs/sourceLiquidityUse"
|
|
1579
1637
|
},
|
|
@@ -1616,6 +1674,9 @@ var coordinator_envelope_schema_default = {
|
|
|
1616
1674
|
$ref: "#/$defs/safeUInt"
|
|
1617
1675
|
}
|
|
1618
1676
|
},
|
|
1677
|
+
recovery_refund_remaining_lamports: {
|
|
1678
|
+
$ref: "#/$defs/safeUInt"
|
|
1679
|
+
},
|
|
1619
1680
|
withdrawal_requested_lamports: {
|
|
1620
1681
|
$ref: "#/$defs/safeUInt"
|
|
1621
1682
|
},
|
|
@@ -2033,6 +2094,7 @@ var coordinator_envelope_schema_default = {
|
|
|
2033
2094
|
"dkg_init",
|
|
2034
2095
|
"dkg_round1",
|
|
2035
2096
|
"dkg_round2",
|
|
2097
|
+
"dkg_abort",
|
|
2036
2098
|
"dkg_finalize",
|
|
2037
2099
|
"refill",
|
|
2038
2100
|
"funding_plan",
|
|
@@ -2110,6 +2172,16 @@ var coordinator_envelope_schema_default = {
|
|
|
2110
2172
|
}
|
|
2111
2173
|
}
|
|
2112
2174
|
},
|
|
2175
|
+
{
|
|
2176
|
+
properties: {
|
|
2177
|
+
action: {
|
|
2178
|
+
const: "dkg_abort"
|
|
2179
|
+
},
|
|
2180
|
+
payload: {
|
|
2181
|
+
$ref: "#/$defs/lpDkgAbortCase"
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
},
|
|
2113
2185
|
{
|
|
2114
2186
|
properties: {
|
|
2115
2187
|
action: {
|
|
@@ -2221,6 +2293,9 @@ var coordinator_envelope_schema_default = {
|
|
|
2221
2293
|
{
|
|
2222
2294
|
$ref: "#/$defs/lpDkgRound2Case"
|
|
2223
2295
|
},
|
|
2296
|
+
{
|
|
2297
|
+
$ref: "#/$defs/lpDkgAbortCase"
|
|
2298
|
+
},
|
|
2224
2299
|
{
|
|
2225
2300
|
$ref: "#/$defs/lpDkgFinalizeCase"
|
|
2226
2301
|
},
|
|
@@ -2315,6 +2390,19 @@ var coordinator_envelope_schema_default = {
|
|
|
2315
2390
|
}
|
|
2316
2391
|
}
|
|
2317
2392
|
},
|
|
2393
|
+
lpDkgAbortCase: {
|
|
2394
|
+
type: "object",
|
|
2395
|
+
additionalProperties: false,
|
|
2396
|
+
required: ["case", "value"],
|
|
2397
|
+
properties: {
|
|
2398
|
+
case: {
|
|
2399
|
+
const: "dkgAbort"
|
|
2400
|
+
},
|
|
2401
|
+
value: {
|
|
2402
|
+
$ref: "#/$defs/lpDkgAbort"
|
|
2403
|
+
}
|
|
2404
|
+
}
|
|
2405
|
+
},
|
|
2318
2406
|
lpDkgFinalizeCase: {
|
|
2319
2407
|
type: "object",
|
|
2320
2408
|
additionalProperties: false,
|
|
@@ -2529,6 +2617,10 @@ var coordinator_envelope_schema_default = {
|
|
|
2529
2617
|
}
|
|
2530
2618
|
}
|
|
2531
2619
|
},
|
|
2620
|
+
lpDkgAbort: {
|
|
2621
|
+
type: "object",
|
|
2622
|
+
additionalProperties: false
|
|
2623
|
+
},
|
|
2532
2624
|
lpDkgFinalize: {
|
|
2533
2625
|
type: "object",
|
|
2534
2626
|
additionalProperties: false,
|
|
@@ -2642,6 +2734,19 @@ var coordinator_envelope_schema_default = {
|
|
|
2642
2734
|
}
|
|
2643
2735
|
}
|
|
2644
2736
|
},
|
|
2737
|
+
{
|
|
2738
|
+
type: "object",
|
|
2739
|
+
additionalProperties: false,
|
|
2740
|
+
required: ["case", "value"],
|
|
2741
|
+
properties: {
|
|
2742
|
+
case: {
|
|
2743
|
+
const: "dkgAbort"
|
|
2744
|
+
},
|
|
2745
|
+
value: {
|
|
2746
|
+
$ref: "#/$defs/lpDkgAbortResponse"
|
|
2747
|
+
}
|
|
2748
|
+
}
|
|
2749
|
+
},
|
|
2645
2750
|
{
|
|
2646
2751
|
type: "object",
|
|
2647
2752
|
additionalProperties: false,
|
|
@@ -2806,6 +2911,16 @@ var coordinator_envelope_schema_default = {
|
|
|
2806
2911
|
}
|
|
2807
2912
|
}
|
|
2808
2913
|
},
|
|
2914
|
+
lpDkgAbortResponse: {
|
|
2915
|
+
type: "object",
|
|
2916
|
+
additionalProperties: false,
|
|
2917
|
+
required: ["aborted_session_count"],
|
|
2918
|
+
properties: {
|
|
2919
|
+
aborted_session_count: {
|
|
2920
|
+
$ref: "#/$defs/safeUInt"
|
|
2921
|
+
}
|
|
2922
|
+
}
|
|
2923
|
+
},
|
|
2809
2924
|
lpPositionView: {
|
|
2810
2925
|
type: "object",
|
|
2811
2926
|
additionalProperties: false,
|
|
@@ -2949,6 +3064,9 @@ var coordinator_envelope_schema_default = {
|
|
|
2949
3064
|
redeemable_fee_source_count: {
|
|
2950
3065
|
$ref: "#/$defs/safeUInt"
|
|
2951
3066
|
},
|
|
3067
|
+
redeemable_source_count: {
|
|
3068
|
+
$ref: "#/$defs/safeUInt"
|
|
3069
|
+
},
|
|
2952
3070
|
pending_reservation_count: {
|
|
2953
3071
|
$ref: "#/$defs/safeUInt"
|
|
2954
3072
|
},
|
|
@@ -3047,6 +3165,9 @@ var coordinator_envelope_schema_default = {
|
|
|
3047
3165
|
state: {
|
|
3048
3166
|
enum: ["requested", "match_requested", "reserved", "pending", "confirmed", "rejected"]
|
|
3049
3167
|
},
|
|
3168
|
+
withdrawal_mode: {
|
|
3169
|
+
enum: ["exact", "max_available"]
|
|
3170
|
+
},
|
|
3050
3171
|
accepted_lamports: {
|
|
3051
3172
|
$ref: "#/$defs/positiveSafeUInt"
|
|
3052
3173
|
},
|
|
@@ -3189,6 +3310,7 @@ var coordinator_envelope_schema_default = {
|
|
|
3189
3310
|
"destination_addresses",
|
|
3190
3311
|
"deposit_principal_lamports",
|
|
3191
3312
|
"earned_fee_lamports",
|
|
3313
|
+
"withdrawal_mode",
|
|
3192
3314
|
"requested_at_ms"
|
|
3193
3315
|
],
|
|
3194
3316
|
properties: {
|
|
@@ -3207,6 +3329,9 @@ var coordinator_envelope_schema_default = {
|
|
|
3207
3329
|
earned_fee_lamports: {
|
|
3208
3330
|
$ref: "#/$defs/safeUInt"
|
|
3209
3331
|
},
|
|
3332
|
+
withdrawal_mode: {
|
|
3333
|
+
enum: ["exact", "max_available"]
|
|
3334
|
+
},
|
|
3210
3335
|
requested_at_ms: {
|
|
3211
3336
|
$ref: "#/$defs/positiveSafeUInt"
|
|
3212
3337
|
}
|
|
@@ -3215,7 +3340,13 @@ var coordinator_envelope_schema_default = {
|
|
|
3215
3340
|
lpWithdrawalExecutionView: {
|
|
3216
3341
|
type: "object",
|
|
3217
3342
|
additionalProperties: false,
|
|
3218
|
-
required: [
|
|
3343
|
+
required: [
|
|
3344
|
+
"withdrawal_id",
|
|
3345
|
+
"tx_signatures",
|
|
3346
|
+
"accepted_lamports",
|
|
3347
|
+
"accepted_deposit_principal_lamports",
|
|
3348
|
+
"accepted_earned_fee_lamports"
|
|
3349
|
+
],
|
|
3219
3350
|
properties: {
|
|
3220
3351
|
withdrawal_id: {
|
|
3221
3352
|
type: "string",
|
|
@@ -3228,6 +3359,15 @@ var coordinator_envelope_schema_default = {
|
|
|
3228
3359
|
items: {
|
|
3229
3360
|
$ref: "#/$defs/lpTxSignature"
|
|
3230
3361
|
}
|
|
3362
|
+
},
|
|
3363
|
+
accepted_lamports: {
|
|
3364
|
+
$ref: "#/$defs/positiveSafeUInt"
|
|
3365
|
+
},
|
|
3366
|
+
accepted_deposit_principal_lamports: {
|
|
3367
|
+
$ref: "#/$defs/safeUInt"
|
|
3368
|
+
},
|
|
3369
|
+
accepted_earned_fee_lamports: {
|
|
3370
|
+
$ref: "#/$defs/safeUInt"
|
|
3231
3371
|
}
|
|
3232
3372
|
}
|
|
3233
3373
|
}
|
|
@@ -3240,6 +3380,7 @@ var MAX_FRAME_SIZE = 256 * 1024;
|
|
|
3240
3380
|
var COORDINATOR_ENVELOPE_SCHEMA = coordinator_envelope_schema_default;
|
|
3241
3381
|
var LP_MAX_TARGET_SHARDS = 300;
|
|
3242
3382
|
var LP_WITHDRAW_REQUEST_PATH = "lp_command.withdrawRequest";
|
|
3383
|
+
var UNKNOWN_SWAP_ID = "<unknown>";
|
|
3243
3384
|
var binaryFieldNames = new Set(COORDINATOR_BINARY_FIELD_NAMES);
|
|
3244
3385
|
var ajv = new Ajv2020({
|
|
3245
3386
|
allErrors: true,
|
|
@@ -3358,14 +3499,25 @@ function validateLpCommandSemanticsForSigning(command) {
|
|
|
3358
3499
|
return;
|
|
3359
3500
|
}
|
|
3360
3501
|
case "withdrawRequest": {
|
|
3361
|
-
const {
|
|
3502
|
+
const {
|
|
3503
|
+
deposit_principal_lamports,
|
|
3504
|
+
earned_fee_lamports,
|
|
3505
|
+
destination_addresses,
|
|
3506
|
+
withdrawal_mode
|
|
3507
|
+
} = command.payload.value;
|
|
3362
3508
|
const bucketTotal = deposit_principal_lamports + earned_fee_lamports;
|
|
3363
|
-
if (!Number.isSafeInteger(bucketTotal) || bucketTotal <= 0) {
|
|
3509
|
+
if (withdrawal_mode === "exact" && (!Number.isSafeInteger(bucketTotal) || bucketTotal <= 0)) {
|
|
3364
3510
|
throw new CoordinatorError(
|
|
3365
3511
|
ErrorCode.ERR_INVALID_PAYLOAD,
|
|
3366
3512
|
`${LP_WITHDRAW_REQUEST_PATH} bucket claim must be positive`
|
|
3367
3513
|
);
|
|
3368
3514
|
}
|
|
3515
|
+
if (withdrawal_mode === "max_available" && bucketTotal !== 0) {
|
|
3516
|
+
throw new CoordinatorError(
|
|
3517
|
+
ErrorCode.ERR_INVALID_PAYLOAD,
|
|
3518
|
+
`${LP_WITHDRAW_REQUEST_PATH} max_available must not carry bucket claims`
|
|
3519
|
+
);
|
|
3520
|
+
}
|
|
3369
3521
|
validateUniqueLpAddresses(LP_WITHDRAW_REQUEST_PATH, destination_addresses);
|
|
3370
3522
|
return;
|
|
3371
3523
|
}
|
|
@@ -3468,10 +3620,11 @@ function fromWireEnvelope(value) {
|
|
|
3468
3620
|
const type = value.type;
|
|
3469
3621
|
const swapId = value.swap_id;
|
|
3470
3622
|
const payload = fromWireValue(value.payload);
|
|
3471
|
-
if (kind === EnvelopeKind.RESPONSE && type === CoordinatorMessageType.ContractRequest &&
|
|
3623
|
+
if (kind === EnvelopeKind.RESPONSE && type === CoordinatorMessageType.ContractRequest && isSwapRequestResponsePayload(payload) && (!swapId || payload.swap_id !== swapId)) {
|
|
3624
|
+
const payloadSwapId = isRecord2(payload) ? String(payload.swap_id) : UNKNOWN_SWAP_ID;
|
|
3472
3625
|
throw new CoordinatorError(
|
|
3473
3626
|
ErrorCode.ERR_INVALID_PAYLOAD,
|
|
3474
|
-
`ContractRequest response: envelope.swap_id (${swapId})
|
|
3627
|
+
`ContractRequest response requires matching non-null swap_id: envelope.swap_id (${swapId ?? "null"}), payload.swap_id (${payloadSwapId})`
|
|
3475
3628
|
);
|
|
3476
3629
|
}
|
|
3477
3630
|
return {
|
|
@@ -3704,6 +3857,9 @@ function uniqueStrings(value, index, all) {
|
|
|
3704
3857
|
function isRecord2(value) {
|
|
3705
3858
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3706
3859
|
}
|
|
3860
|
+
function isSwapRequestResponsePayload(value) {
|
|
3861
|
+
return isRecord2(value) && value.accepted === true && typeof value.swap_id === "string";
|
|
3862
|
+
}
|
|
3707
3863
|
function stripUndefined(value) {
|
|
3708
3864
|
const out = {};
|
|
3709
3865
|
for (const [key, item] of Object.entries(value)) {
|
|
@@ -3747,7 +3903,16 @@ function base64UrlToBytes(value, field) {
|
|
|
3747
3903
|
return out;
|
|
3748
3904
|
}
|
|
3749
3905
|
var asSwapRequestPayload = (e) => e.payload;
|
|
3750
|
-
var asSwapRequestResponsePayload = (e) =>
|
|
3906
|
+
var asSwapRequestResponsePayload = (e) => {
|
|
3907
|
+
if (e.kind !== EnvelopeKind.RESPONSE || e.type !== CoordinatorMessageType.ContractRequest || e.swap_id === null || !isSwapRequestResponsePayload(e.payload) || e.payload.swap_id !== e.swap_id) {
|
|
3908
|
+
const payloadSwapId = isRecord2(e.payload) ? String(e.payload.swap_id) : UNKNOWN_SWAP_ID;
|
|
3909
|
+
throw new CoordinatorError(
|
|
3910
|
+
ErrorCode.ERR_INVALID_PAYLOAD,
|
|
3911
|
+
`ContractRequest response: envelope.swap_id (${e.swap_id}) does not match payload.swap_id (${payloadSwapId})`
|
|
3912
|
+
);
|
|
3913
|
+
}
|
|
3914
|
+
return e.payload;
|
|
3915
|
+
};
|
|
3751
3916
|
var asDkgInitPayload = (e) => e.payload;
|
|
3752
3917
|
var asDkgInitResponsePayload = (e) => e.payload;
|
|
3753
3918
|
var asDkgRound1Payload = (e) => e.payload;
|
|
@@ -3779,5 +3944,5 @@ var asErrorPayload = (e) => {
|
|
|
3779
3944
|
};
|
|
3780
3945
|
|
|
3781
3946
|
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 };
|
|
3782
|
-
//# sourceMappingURL=chunk-
|
|
3783
|
-
//# sourceMappingURL=chunk-
|
|
3947
|
+
//# sourceMappingURL=chunk-E4DCEDAG.js.map
|
|
3948
|
+
//# sourceMappingURL=chunk-E4DCEDAG.js.map
|