@invisible-labs/sdk 0.6.0-devnet.3 → 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 +67 -10
- package/dist/.invisible-sdk-build-target.json +7 -0
- package/dist/{chunk-BWCGNTN5.js → chunk-5NNEO7IK.js} +31 -34
- 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-NKRVQXRP.js → chunk-E4DCEDAG.js} +121 -11
- package/dist/chunk-E4DCEDAG.js.map +1 -0
- package/dist/{chunk-QQSI3ZD7.js → chunk-UADJCUPK.js} +106 -15
- package/dist/chunk-UADJCUPK.js.map +1 -0
- package/dist/{coordinator-VVJ33WF2.js → coordinator-ZNLGAYXD.js} +3 -3
- package/dist/{coordinator-VVJ33WF2.js.map → coordinator-ZNLGAYXD.js.map} +1 -1
- package/dist/events.js +1 -1
- package/dist/index.d.ts +59 -353
- package/dist/index.js +94 -39
- package/dist/index.js.map +1 -1
- package/dist/lp.d.ts +44 -10
- package/dist/lp.js +211 -71
- package/dist/lp.js.map +1 -1
- package/dist/presets.d.ts +5 -42
- package/dist/presets.js +10 -68
- package/dist/presets.js.map +1 -1
- package/dist/{errors-N2touVm4.d.ts → types.generated-DJBTjLpP.d.ts} +37 -1
- package/dist/user.d.ts +107 -8
- package/dist/user.js +613 -224
- package/dist/user.js.map +1 -1
- package/package.json +2 -31
- package/dist/chunk-BWCGNTN5.js.map +0 -1
- package/dist/chunk-NKRVQXRP.js.map +0 -1
- package/dist/chunk-QQSI3ZD7.js.map +0 -1
- package/dist/types.generated-BSEBz4jR.d.ts +0 -68
|
@@ -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
|
},
|
|
@@ -957,6 +959,15 @@ var coordinator_envelope_schema_default = {
|
|
|
957
959
|
additionalProperties: false,
|
|
958
960
|
properties: {}
|
|
959
961
|
},
|
|
962
|
+
dkgInitRequest: {
|
|
963
|
+
type: "object",
|
|
964
|
+
additionalProperties: false,
|
|
965
|
+
properties: {
|
|
966
|
+
resume_secret: {
|
|
967
|
+
$ref: "#/$defs/base64url32Bytes"
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
},
|
|
960
971
|
syncRequest: {
|
|
961
972
|
oneOf: [
|
|
962
973
|
{
|
|
@@ -1065,6 +1076,9 @@ var coordinator_envelope_schema_default = {
|
|
|
1065
1076
|
},
|
|
1066
1077
|
sync_commitment: {
|
|
1067
1078
|
$ref: "#/$defs/base64url32Bytes"
|
|
1079
|
+
},
|
|
1080
|
+
resume_commitment: {
|
|
1081
|
+
$ref: "#/$defs/base64url32Bytes"
|
|
1068
1082
|
}
|
|
1069
1083
|
}
|
|
1070
1084
|
},
|
|
@@ -1315,6 +1329,19 @@ var coordinator_envelope_schema_default = {
|
|
|
1315
1329
|
}
|
|
1316
1330
|
}
|
|
1317
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
|
+
},
|
|
1318
1345
|
dkgRound1Response: {
|
|
1319
1346
|
type: "object",
|
|
1320
1347
|
additionalProperties: false,
|
|
@@ -1351,6 +1378,9 @@ var coordinator_envelope_schema_default = {
|
|
|
1351
1378
|
},
|
|
1352
1379
|
recovery_commitment: {
|
|
1353
1380
|
$ref: "#/$defs/base64url32Bytes"
|
|
1381
|
+
},
|
|
1382
|
+
resume_secret: {
|
|
1383
|
+
$ref: "#/$defs/base64url32Bytes"
|
|
1354
1384
|
}
|
|
1355
1385
|
}
|
|
1356
1386
|
},
|
|
@@ -1476,6 +1506,8 @@ var coordinator_envelope_schema_default = {
|
|
|
1476
1506
|
"locked_pending_payout",
|
|
1477
1507
|
"submitted",
|
|
1478
1508
|
"confirming",
|
|
1509
|
+
"retry_delayed",
|
|
1510
|
+
"recovery_required",
|
|
1479
1511
|
"completed",
|
|
1480
1512
|
"refund_pending",
|
|
1481
1513
|
"refunded",
|
|
@@ -1485,6 +1517,19 @@ var coordinator_envelope_schema_default = {
|
|
|
1485
1517
|
normalUserRefundability: {
|
|
1486
1518
|
enum: ["available_now", "request_pending", "blocked_by_lock", "stale", "unavailable"]
|
|
1487
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
|
+
},
|
|
1488
1533
|
sourceLiquidityUse: {
|
|
1489
1534
|
enum: [
|
|
1490
1535
|
"not_materialized",
|
|
@@ -1543,6 +1588,7 @@ var coordinator_envelope_schema_default = {
|
|
|
1543
1588
|
"status",
|
|
1544
1589
|
"settlement_phase",
|
|
1545
1590
|
"refundability",
|
|
1591
|
+
"refund_status",
|
|
1546
1592
|
"source_liquidity_use",
|
|
1547
1593
|
"destination_wallet",
|
|
1548
1594
|
"deposit_amount_lamports",
|
|
@@ -1552,6 +1598,7 @@ var coordinator_envelope_schema_default = {
|
|
|
1552
1598
|
"settled_amount_lamports",
|
|
1553
1599
|
"protocol_fee_lamports",
|
|
1554
1600
|
"network_fee_lost_lamports",
|
|
1601
|
+
"recovery_refund_remaining_lamports",
|
|
1555
1602
|
"withdrawal_requested_lamports",
|
|
1556
1603
|
"withdrawal_landed_lamports",
|
|
1557
1604
|
"withdrawal_landed_fee_lamports",
|
|
@@ -1575,6 +1622,16 @@ var coordinator_envelope_schema_default = {
|
|
|
1575
1622
|
refundability: {
|
|
1576
1623
|
$ref: "#/$defs/normalUserRefundability"
|
|
1577
1624
|
},
|
|
1625
|
+
refund_status: {
|
|
1626
|
+
anyOf: [
|
|
1627
|
+
{
|
|
1628
|
+
type: "null"
|
|
1629
|
+
},
|
|
1630
|
+
{
|
|
1631
|
+
$ref: "#/$defs/normalUserRefundStatus"
|
|
1632
|
+
}
|
|
1633
|
+
]
|
|
1634
|
+
},
|
|
1578
1635
|
source_liquidity_use: {
|
|
1579
1636
|
$ref: "#/$defs/sourceLiquidityUse"
|
|
1580
1637
|
},
|
|
@@ -1617,6 +1674,9 @@ var coordinator_envelope_schema_default = {
|
|
|
1617
1674
|
$ref: "#/$defs/safeUInt"
|
|
1618
1675
|
}
|
|
1619
1676
|
},
|
|
1677
|
+
recovery_refund_remaining_lamports: {
|
|
1678
|
+
$ref: "#/$defs/safeUInt"
|
|
1679
|
+
},
|
|
1620
1680
|
withdrawal_requested_lamports: {
|
|
1621
1681
|
$ref: "#/$defs/safeUInt"
|
|
1622
1682
|
},
|
|
@@ -3004,6 +3064,9 @@ var coordinator_envelope_schema_default = {
|
|
|
3004
3064
|
redeemable_fee_source_count: {
|
|
3005
3065
|
$ref: "#/$defs/safeUInt"
|
|
3006
3066
|
},
|
|
3067
|
+
redeemable_source_count: {
|
|
3068
|
+
$ref: "#/$defs/safeUInt"
|
|
3069
|
+
},
|
|
3007
3070
|
pending_reservation_count: {
|
|
3008
3071
|
$ref: "#/$defs/safeUInt"
|
|
3009
3072
|
},
|
|
@@ -3102,6 +3165,9 @@ var coordinator_envelope_schema_default = {
|
|
|
3102
3165
|
state: {
|
|
3103
3166
|
enum: ["requested", "match_requested", "reserved", "pending", "confirmed", "rejected"]
|
|
3104
3167
|
},
|
|
3168
|
+
withdrawal_mode: {
|
|
3169
|
+
enum: ["exact", "max_available"]
|
|
3170
|
+
},
|
|
3105
3171
|
accepted_lamports: {
|
|
3106
3172
|
$ref: "#/$defs/positiveSafeUInt"
|
|
3107
3173
|
},
|
|
@@ -3244,6 +3310,7 @@ var coordinator_envelope_schema_default = {
|
|
|
3244
3310
|
"destination_addresses",
|
|
3245
3311
|
"deposit_principal_lamports",
|
|
3246
3312
|
"earned_fee_lamports",
|
|
3313
|
+
"withdrawal_mode",
|
|
3247
3314
|
"requested_at_ms"
|
|
3248
3315
|
],
|
|
3249
3316
|
properties: {
|
|
@@ -3262,6 +3329,9 @@ var coordinator_envelope_schema_default = {
|
|
|
3262
3329
|
earned_fee_lamports: {
|
|
3263
3330
|
$ref: "#/$defs/safeUInt"
|
|
3264
3331
|
},
|
|
3332
|
+
withdrawal_mode: {
|
|
3333
|
+
enum: ["exact", "max_available"]
|
|
3334
|
+
},
|
|
3265
3335
|
requested_at_ms: {
|
|
3266
3336
|
$ref: "#/$defs/positiveSafeUInt"
|
|
3267
3337
|
}
|
|
@@ -3270,7 +3340,13 @@ var coordinator_envelope_schema_default = {
|
|
|
3270
3340
|
lpWithdrawalExecutionView: {
|
|
3271
3341
|
type: "object",
|
|
3272
3342
|
additionalProperties: false,
|
|
3273
|
-
required: [
|
|
3343
|
+
required: [
|
|
3344
|
+
"withdrawal_id",
|
|
3345
|
+
"tx_signatures",
|
|
3346
|
+
"accepted_lamports",
|
|
3347
|
+
"accepted_deposit_principal_lamports",
|
|
3348
|
+
"accepted_earned_fee_lamports"
|
|
3349
|
+
],
|
|
3274
3350
|
properties: {
|
|
3275
3351
|
withdrawal_id: {
|
|
3276
3352
|
type: "string",
|
|
@@ -3283,6 +3359,15 @@ var coordinator_envelope_schema_default = {
|
|
|
3283
3359
|
items: {
|
|
3284
3360
|
$ref: "#/$defs/lpTxSignature"
|
|
3285
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"
|
|
3286
3371
|
}
|
|
3287
3372
|
}
|
|
3288
3373
|
}
|
|
@@ -3295,6 +3380,7 @@ var MAX_FRAME_SIZE = 256 * 1024;
|
|
|
3295
3380
|
var COORDINATOR_ENVELOPE_SCHEMA = coordinator_envelope_schema_default;
|
|
3296
3381
|
var LP_MAX_TARGET_SHARDS = 300;
|
|
3297
3382
|
var LP_WITHDRAW_REQUEST_PATH = "lp_command.withdrawRequest";
|
|
3383
|
+
var UNKNOWN_SWAP_ID = "<unknown>";
|
|
3298
3384
|
var binaryFieldNames = new Set(COORDINATOR_BINARY_FIELD_NAMES);
|
|
3299
3385
|
var ajv = new Ajv2020({
|
|
3300
3386
|
allErrors: true,
|
|
@@ -3413,14 +3499,25 @@ function validateLpCommandSemanticsForSigning(command) {
|
|
|
3413
3499
|
return;
|
|
3414
3500
|
}
|
|
3415
3501
|
case "withdrawRequest": {
|
|
3416
|
-
const {
|
|
3502
|
+
const {
|
|
3503
|
+
deposit_principal_lamports,
|
|
3504
|
+
earned_fee_lamports,
|
|
3505
|
+
destination_addresses,
|
|
3506
|
+
withdrawal_mode
|
|
3507
|
+
} = command.payload.value;
|
|
3417
3508
|
const bucketTotal = deposit_principal_lamports + earned_fee_lamports;
|
|
3418
|
-
if (!Number.isSafeInteger(bucketTotal) || bucketTotal <= 0) {
|
|
3509
|
+
if (withdrawal_mode === "exact" && (!Number.isSafeInteger(bucketTotal) || bucketTotal <= 0)) {
|
|
3419
3510
|
throw new CoordinatorError(
|
|
3420
3511
|
ErrorCode.ERR_INVALID_PAYLOAD,
|
|
3421
3512
|
`${LP_WITHDRAW_REQUEST_PATH} bucket claim must be positive`
|
|
3422
3513
|
);
|
|
3423
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
|
+
}
|
|
3424
3521
|
validateUniqueLpAddresses(LP_WITHDRAW_REQUEST_PATH, destination_addresses);
|
|
3425
3522
|
return;
|
|
3426
3523
|
}
|
|
@@ -3523,10 +3620,11 @@ function fromWireEnvelope(value) {
|
|
|
3523
3620
|
const type = value.type;
|
|
3524
3621
|
const swapId = value.swap_id;
|
|
3525
3622
|
const payload = fromWireValue(value.payload);
|
|
3526
|
-
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;
|
|
3527
3625
|
throw new CoordinatorError(
|
|
3528
3626
|
ErrorCode.ERR_INVALID_PAYLOAD,
|
|
3529
|
-
`ContractRequest response: envelope.swap_id (${swapId})
|
|
3627
|
+
`ContractRequest response requires matching non-null swap_id: envelope.swap_id (${swapId ?? "null"}), payload.swap_id (${payloadSwapId})`
|
|
3530
3628
|
);
|
|
3531
3629
|
}
|
|
3532
3630
|
return {
|
|
@@ -3759,6 +3857,9 @@ function uniqueStrings(value, index, all) {
|
|
|
3759
3857
|
function isRecord2(value) {
|
|
3760
3858
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3761
3859
|
}
|
|
3860
|
+
function isSwapRequestResponsePayload(value) {
|
|
3861
|
+
return isRecord2(value) && value.accepted === true && typeof value.swap_id === "string";
|
|
3862
|
+
}
|
|
3762
3863
|
function stripUndefined(value) {
|
|
3763
3864
|
const out = {};
|
|
3764
3865
|
for (const [key, item] of Object.entries(value)) {
|
|
@@ -3802,7 +3903,16 @@ function base64UrlToBytes(value, field) {
|
|
|
3802
3903
|
return out;
|
|
3803
3904
|
}
|
|
3804
3905
|
var asSwapRequestPayload = (e) => e.payload;
|
|
3805
|
-
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
|
+
};
|
|
3806
3916
|
var asDkgInitPayload = (e) => e.payload;
|
|
3807
3917
|
var asDkgInitResponsePayload = (e) => e.payload;
|
|
3808
3918
|
var asDkgRound1Payload = (e) => e.payload;
|
|
@@ -3834,5 +3944,5 @@ var asErrorPayload = (e) => {
|
|
|
3834
3944
|
};
|
|
3835
3945
|
|
|
3836
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 };
|
|
3837
|
-
//# sourceMappingURL=chunk-
|
|
3838
|
-
//# sourceMappingURL=chunk-
|
|
3947
|
+
//# sourceMappingURL=chunk-E4DCEDAG.js.map
|
|
3948
|
+
//# sourceMappingURL=chunk-E4DCEDAG.js.map
|