@fepvenancio/stela-sdk 0.2.3 → 0.4.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.
- package/README.md +347 -79
- package/dist/index.cjs +605 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +235 -2
- package/dist/index.d.ts +235 -2
- package/dist/index.js +600 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/abi/stela.json +365 -10
package/dist/index.cjs
CHANGED
|
@@ -24,7 +24,7 @@ var STATUS_LABELS = {
|
|
|
24
24
|
|
|
25
25
|
// src/constants/addresses.ts
|
|
26
26
|
var STELA_ADDRESS = {
|
|
27
|
-
sepolia: "
|
|
27
|
+
sepolia: "0x00b7deedb4ab03d94f54da2e7c911c2336b19c2a4610eb98f55cd7be5a53ece0",
|
|
28
28
|
mainnet: "0x0"
|
|
29
29
|
};
|
|
30
30
|
var VALID_NETWORKS = ["sepolia", "mainnet"];
|
|
@@ -283,7 +283,11 @@ var SELECTORS = {
|
|
|
283
283
|
InscriptionRepaid: starknet.hash.getSelectorFromName("InscriptionRepaid"),
|
|
284
284
|
InscriptionLiquidated: starknet.hash.getSelectorFromName("InscriptionLiquidated"),
|
|
285
285
|
SharesRedeemed: starknet.hash.getSelectorFromName("SharesRedeemed"),
|
|
286
|
-
TransferSingle: starknet.hash.getSelectorFromName("TransferSingle")
|
|
286
|
+
TransferSingle: starknet.hash.getSelectorFromName("TransferSingle"),
|
|
287
|
+
OrderSettled: starknet.hash.getSelectorFromName("OrderSettled"),
|
|
288
|
+
OrderFilled: starknet.hash.getSelectorFromName("OrderFilled"),
|
|
289
|
+
OrderCancelled: starknet.hash.getSelectorFromName("OrderCancelled"),
|
|
290
|
+
OrdersBulkCancelled: starknet.hash.getSelectorFromName("OrdersBulkCancelled")
|
|
287
291
|
};
|
|
288
292
|
function feltsToU256(low, high) {
|
|
289
293
|
return starknet.uint256.uint256ToBN({ low: BigInt(low), high: BigInt(high) });
|
|
@@ -362,6 +366,48 @@ function parseEvent(raw) {
|
|
|
362
366
|
block_number: raw.block_number
|
|
363
367
|
};
|
|
364
368
|
}
|
|
369
|
+
case SELECTORS.OrderSettled: {
|
|
370
|
+
return {
|
|
371
|
+
type: "OrderSettled",
|
|
372
|
+
inscription_id: feltsToU256(raw.keys[1], raw.keys[2]),
|
|
373
|
+
borrower: raw.keys[3],
|
|
374
|
+
lender: raw.keys[4],
|
|
375
|
+
relayer: raw.data[0],
|
|
376
|
+
relayer_fee_amount: feltsToU256(raw.data[1], raw.data[2]),
|
|
377
|
+
transaction_hash: raw.transaction_hash,
|
|
378
|
+
block_number: raw.block_number
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
case SELECTORS.OrderFilled: {
|
|
382
|
+
return {
|
|
383
|
+
type: "OrderFilled",
|
|
384
|
+
inscription_id: feltsToU256(raw.keys[1], raw.keys[2]),
|
|
385
|
+
order_hash: raw.keys[3],
|
|
386
|
+
taker: raw.keys[4],
|
|
387
|
+
fill_bps: feltsToU256(raw.data[0], raw.data[1]),
|
|
388
|
+
total_filled_bps: feltsToU256(raw.data[2], raw.data[3]),
|
|
389
|
+
transaction_hash: raw.transaction_hash,
|
|
390
|
+
block_number: raw.block_number
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
case SELECTORS.OrderCancelled: {
|
|
394
|
+
return {
|
|
395
|
+
type: "OrderCancelled",
|
|
396
|
+
order_hash: raw.keys[1],
|
|
397
|
+
maker: raw.data[0],
|
|
398
|
+
transaction_hash: raw.transaction_hash,
|
|
399
|
+
block_number: raw.block_number
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
case SELECTORS.OrdersBulkCancelled: {
|
|
403
|
+
return {
|
|
404
|
+
type: "OrdersBulkCancelled",
|
|
405
|
+
maker: raw.keys[1],
|
|
406
|
+
new_min_nonce: raw.data[0],
|
|
407
|
+
transaction_hash: raw.transaction_hash,
|
|
408
|
+
block_number: raw.block_number
|
|
409
|
+
};
|
|
410
|
+
}
|
|
365
411
|
default:
|
|
366
412
|
return null;
|
|
367
413
|
}
|
|
@@ -438,6 +484,16 @@ function getInscriptionOrderTypedData(params) {
|
|
|
438
484
|
}
|
|
439
485
|
};
|
|
440
486
|
}
|
|
487
|
+
function getPrivateLendOfferTypedData(params) {
|
|
488
|
+
return getLendOfferTypedData({
|
|
489
|
+
orderHash: params.orderHash,
|
|
490
|
+
lender: "0x0",
|
|
491
|
+
issuedDebtPercentage: params.issuedDebtPercentage,
|
|
492
|
+
nonce: params.nonce,
|
|
493
|
+
chainId: params.chainId,
|
|
494
|
+
lenderCommitment: params.depositCommitment
|
|
495
|
+
});
|
|
496
|
+
}
|
|
441
497
|
function getLendOfferTypedData(params) {
|
|
442
498
|
return {
|
|
443
499
|
types: {
|
|
@@ -451,7 +507,8 @@ function getLendOfferTypedData(params) {
|
|
|
451
507
|
{ name: "order_hash", type: "felt" },
|
|
452
508
|
{ name: "lender", type: "ContractAddress" },
|
|
453
509
|
{ name: "issued_debt_percentage", type: "u256" },
|
|
454
|
-
{ name: "nonce", type: "felt" }
|
|
510
|
+
{ name: "nonce", type: "felt" },
|
|
511
|
+
{ name: "lender_commitment", type: "felt" }
|
|
455
512
|
],
|
|
456
513
|
u256: [
|
|
457
514
|
{ name: "low", type: "u128" },
|
|
@@ -470,7 +527,8 @@ function getLendOfferTypedData(params) {
|
|
|
470
527
|
low: (params.issuedDebtPercentage & (1n << 128n) - 1n).toString(),
|
|
471
528
|
high: (params.issuedDebtPercentage >> 128n).toString()
|
|
472
529
|
},
|
|
473
|
-
nonce: params.nonce.toString()
|
|
530
|
+
nonce: params.nonce.toString(),
|
|
531
|
+
lender_commitment: params.lenderCommitment ?? "0"
|
|
474
532
|
}
|
|
475
533
|
};
|
|
476
534
|
}
|
|
@@ -482,6 +540,54 @@ function serializeSignature(sig) {
|
|
|
482
540
|
function deserializeSignature(stored) {
|
|
483
541
|
return [stored.r, stored.s];
|
|
484
542
|
}
|
|
543
|
+
var COMMITMENT_DOMAIN = starknet.shortString.encodeShortString("STELA_COMMITMENT_V1");
|
|
544
|
+
var NULLIFIER_DOMAIN = starknet.shortString.encodeShortString("STELA_NULLIFIER_V1");
|
|
545
|
+
function computeCommitment(owner, inscriptionId, shares, salt) {
|
|
546
|
+
const [idLow, idHigh] = toU256(inscriptionId);
|
|
547
|
+
const [sharesLow, sharesHigh] = toU256(shares);
|
|
548
|
+
return starknet.hash.computePoseidonHashOnElements([
|
|
549
|
+
COMMITMENT_DOMAIN,
|
|
550
|
+
owner,
|
|
551
|
+
idLow,
|
|
552
|
+
idHigh,
|
|
553
|
+
sharesLow,
|
|
554
|
+
sharesHigh,
|
|
555
|
+
salt
|
|
556
|
+
]);
|
|
557
|
+
}
|
|
558
|
+
function computeNullifier(commitment, ownerSecret) {
|
|
559
|
+
return starknet.hash.computePoseidonHashOnElements([NULLIFIER_DOMAIN, commitment, ownerSecret]);
|
|
560
|
+
}
|
|
561
|
+
function hashPair(left, right) {
|
|
562
|
+
return starknet.hash.computePoseidonHashOnElements([left, right]);
|
|
563
|
+
}
|
|
564
|
+
function generateSalt() {
|
|
565
|
+
const bytes = new Uint8Array(31);
|
|
566
|
+
crypto.getRandomValues(bytes);
|
|
567
|
+
return "0x" + Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
568
|
+
}
|
|
569
|
+
function computeDepositCommitment(depositor, token, amount, salt) {
|
|
570
|
+
const [amountLow, amountHigh] = toU256(amount);
|
|
571
|
+
return starknet.hash.computePoseidonHashOnElements([
|
|
572
|
+
COMMITMENT_DOMAIN,
|
|
573
|
+
depositor,
|
|
574
|
+
token,
|
|
575
|
+
amountLow,
|
|
576
|
+
amountHigh,
|
|
577
|
+
"0x" + salt.toString(16)
|
|
578
|
+
]);
|
|
579
|
+
}
|
|
580
|
+
function createPrivateNote(owner, inscriptionId, shares, salt) {
|
|
581
|
+
const noteSalt = salt ?? generateSalt();
|
|
582
|
+
const commitment = computeCommitment(owner, inscriptionId, shares, noteSalt);
|
|
583
|
+
return {
|
|
584
|
+
owner,
|
|
585
|
+
inscriptionId,
|
|
586
|
+
shares,
|
|
587
|
+
salt: noteSalt,
|
|
588
|
+
commitment
|
|
589
|
+
};
|
|
590
|
+
}
|
|
485
591
|
|
|
486
592
|
// src/abi/stela.json
|
|
487
593
|
var stela_default = [
|
|
@@ -596,6 +702,46 @@ var stela_default = [
|
|
|
596
702
|
}
|
|
597
703
|
]
|
|
598
704
|
},
|
|
705
|
+
{
|
|
706
|
+
type: "struct",
|
|
707
|
+
name: "stela::types::private_redeem::PrivateRedeemRequest",
|
|
708
|
+
members: [
|
|
709
|
+
{
|
|
710
|
+
name: "root",
|
|
711
|
+
type: "core::felt252"
|
|
712
|
+
},
|
|
713
|
+
{
|
|
714
|
+
name: "inscription_id",
|
|
715
|
+
type: "core::integer::u256"
|
|
716
|
+
},
|
|
717
|
+
{
|
|
718
|
+
name: "shares",
|
|
719
|
+
type: "core::integer::u256"
|
|
720
|
+
},
|
|
721
|
+
{
|
|
722
|
+
name: "nullifier",
|
|
723
|
+
type: "core::felt252"
|
|
724
|
+
},
|
|
725
|
+
{
|
|
726
|
+
name: "change_commitment",
|
|
727
|
+
type: "core::felt252"
|
|
728
|
+
},
|
|
729
|
+
{
|
|
730
|
+
name: "recipient",
|
|
731
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
732
|
+
}
|
|
733
|
+
]
|
|
734
|
+
},
|
|
735
|
+
{
|
|
736
|
+
type: "struct",
|
|
737
|
+
name: "core::array::Span::<core::felt252>",
|
|
738
|
+
members: [
|
|
739
|
+
{
|
|
740
|
+
name: "snapshot",
|
|
741
|
+
type: "@core::array::Array::<core::felt252>"
|
|
742
|
+
}
|
|
743
|
+
]
|
|
744
|
+
},
|
|
599
745
|
{
|
|
600
746
|
type: "struct",
|
|
601
747
|
name: "stela::snip12::InscriptionOrder",
|
|
@@ -665,6 +811,44 @@ var stela_default = [
|
|
|
665
811
|
{
|
|
666
812
|
name: "nonce",
|
|
667
813
|
type: "core::felt252"
|
|
814
|
+
},
|
|
815
|
+
{
|
|
816
|
+
name: "lender_commitment",
|
|
817
|
+
type: "core::felt252"
|
|
818
|
+
}
|
|
819
|
+
]
|
|
820
|
+
},
|
|
821
|
+
{
|
|
822
|
+
type: "struct",
|
|
823
|
+
name: "stela::types::signed_order::SignedOrder",
|
|
824
|
+
members: [
|
|
825
|
+
{
|
|
826
|
+
name: "maker",
|
|
827
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
828
|
+
},
|
|
829
|
+
{
|
|
830
|
+
name: "allowed_taker",
|
|
831
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
832
|
+
},
|
|
833
|
+
{
|
|
834
|
+
name: "inscription_id",
|
|
835
|
+
type: "core::integer::u256"
|
|
836
|
+
},
|
|
837
|
+
{
|
|
838
|
+
name: "bps",
|
|
839
|
+
type: "core::integer::u256"
|
|
840
|
+
},
|
|
841
|
+
{
|
|
842
|
+
name: "deadline",
|
|
843
|
+
type: "core::integer::u64"
|
|
844
|
+
},
|
|
845
|
+
{
|
|
846
|
+
name: "nonce",
|
|
847
|
+
type: "core::felt252"
|
|
848
|
+
},
|
|
849
|
+
{
|
|
850
|
+
name: "min_fill_bps",
|
|
851
|
+
type: "core::integer::u256"
|
|
668
852
|
}
|
|
669
853
|
]
|
|
670
854
|
},
|
|
@@ -810,6 +994,22 @@ var stela_default = [
|
|
|
810
994
|
outputs: [],
|
|
811
995
|
state_mutability: "external"
|
|
812
996
|
},
|
|
997
|
+
{
|
|
998
|
+
type: "function",
|
|
999
|
+
name: "private_redeem",
|
|
1000
|
+
inputs: [
|
|
1001
|
+
{
|
|
1002
|
+
name: "request",
|
|
1003
|
+
type: "stela::types::private_redeem::PrivateRedeemRequest"
|
|
1004
|
+
},
|
|
1005
|
+
{
|
|
1006
|
+
name: "proof",
|
|
1007
|
+
type: "core::array::Span::<core::felt252>"
|
|
1008
|
+
}
|
|
1009
|
+
],
|
|
1010
|
+
outputs: [],
|
|
1011
|
+
state_mutability: "external"
|
|
1012
|
+
},
|
|
813
1013
|
{
|
|
814
1014
|
type: "function",
|
|
815
1015
|
name: "settle",
|
|
@@ -846,6 +1046,50 @@ var stela_default = [
|
|
|
846
1046
|
outputs: [],
|
|
847
1047
|
state_mutability: "external"
|
|
848
1048
|
},
|
|
1049
|
+
{
|
|
1050
|
+
type: "function",
|
|
1051
|
+
name: "fill_signed_order",
|
|
1052
|
+
inputs: [
|
|
1053
|
+
{
|
|
1054
|
+
name: "order",
|
|
1055
|
+
type: "stela::types::signed_order::SignedOrder"
|
|
1056
|
+
},
|
|
1057
|
+
{
|
|
1058
|
+
name: "signature",
|
|
1059
|
+
type: "core::array::Array::<core::felt252>"
|
|
1060
|
+
},
|
|
1061
|
+
{
|
|
1062
|
+
name: "fill_bps",
|
|
1063
|
+
type: "core::integer::u256"
|
|
1064
|
+
}
|
|
1065
|
+
],
|
|
1066
|
+
outputs: [],
|
|
1067
|
+
state_mutability: "external"
|
|
1068
|
+
},
|
|
1069
|
+
{
|
|
1070
|
+
type: "function",
|
|
1071
|
+
name: "cancel_order",
|
|
1072
|
+
inputs: [
|
|
1073
|
+
{
|
|
1074
|
+
name: "order",
|
|
1075
|
+
type: "stela::types::signed_order::SignedOrder"
|
|
1076
|
+
}
|
|
1077
|
+
],
|
|
1078
|
+
outputs: [],
|
|
1079
|
+
state_mutability: "external"
|
|
1080
|
+
},
|
|
1081
|
+
{
|
|
1082
|
+
type: "function",
|
|
1083
|
+
name: "cancel_orders_by_nonce",
|
|
1084
|
+
inputs: [
|
|
1085
|
+
{
|
|
1086
|
+
name: "min_nonce",
|
|
1087
|
+
type: "core::felt252"
|
|
1088
|
+
}
|
|
1089
|
+
],
|
|
1090
|
+
outputs: [],
|
|
1091
|
+
state_mutability: "external"
|
|
1092
|
+
},
|
|
849
1093
|
{
|
|
850
1094
|
type: "function",
|
|
851
1095
|
name: "get_inscription",
|
|
@@ -958,6 +1202,81 @@ var stela_default = [
|
|
|
958
1202
|
],
|
|
959
1203
|
state_mutability: "view"
|
|
960
1204
|
},
|
|
1205
|
+
{
|
|
1206
|
+
type: "function",
|
|
1207
|
+
name: "is_order_registered",
|
|
1208
|
+
inputs: [
|
|
1209
|
+
{
|
|
1210
|
+
name: "order_hash",
|
|
1211
|
+
type: "core::felt252"
|
|
1212
|
+
}
|
|
1213
|
+
],
|
|
1214
|
+
outputs: [
|
|
1215
|
+
{
|
|
1216
|
+
type: "core::bool"
|
|
1217
|
+
}
|
|
1218
|
+
],
|
|
1219
|
+
state_mutability: "view"
|
|
1220
|
+
},
|
|
1221
|
+
{
|
|
1222
|
+
type: "function",
|
|
1223
|
+
name: "is_order_cancelled",
|
|
1224
|
+
inputs: [
|
|
1225
|
+
{
|
|
1226
|
+
name: "order_hash",
|
|
1227
|
+
type: "core::felt252"
|
|
1228
|
+
}
|
|
1229
|
+
],
|
|
1230
|
+
outputs: [
|
|
1231
|
+
{
|
|
1232
|
+
type: "core::bool"
|
|
1233
|
+
}
|
|
1234
|
+
],
|
|
1235
|
+
state_mutability: "view"
|
|
1236
|
+
},
|
|
1237
|
+
{
|
|
1238
|
+
type: "function",
|
|
1239
|
+
name: "get_filled_bps",
|
|
1240
|
+
inputs: [
|
|
1241
|
+
{
|
|
1242
|
+
name: "order_hash",
|
|
1243
|
+
type: "core::felt252"
|
|
1244
|
+
}
|
|
1245
|
+
],
|
|
1246
|
+
outputs: [
|
|
1247
|
+
{
|
|
1248
|
+
type: "core::integer::u256"
|
|
1249
|
+
}
|
|
1250
|
+
],
|
|
1251
|
+
state_mutability: "view"
|
|
1252
|
+
},
|
|
1253
|
+
{
|
|
1254
|
+
type: "function",
|
|
1255
|
+
name: "get_maker_min_nonce",
|
|
1256
|
+
inputs: [
|
|
1257
|
+
{
|
|
1258
|
+
name: "maker",
|
|
1259
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1260
|
+
}
|
|
1261
|
+
],
|
|
1262
|
+
outputs: [
|
|
1263
|
+
{
|
|
1264
|
+
type: "core::felt252"
|
|
1265
|
+
}
|
|
1266
|
+
],
|
|
1267
|
+
state_mutability: "view"
|
|
1268
|
+
},
|
|
1269
|
+
{
|
|
1270
|
+
type: "function",
|
|
1271
|
+
name: "get_privacy_pool",
|
|
1272
|
+
inputs: [],
|
|
1273
|
+
outputs: [
|
|
1274
|
+
{
|
|
1275
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1276
|
+
}
|
|
1277
|
+
],
|
|
1278
|
+
state_mutability: "view"
|
|
1279
|
+
},
|
|
961
1280
|
{
|
|
962
1281
|
type: "function",
|
|
963
1282
|
name: "set_inscription_fee",
|
|
@@ -1030,6 +1349,18 @@ var stela_default = [
|
|
|
1030
1349
|
outputs: [],
|
|
1031
1350
|
state_mutability: "external"
|
|
1032
1351
|
},
|
|
1352
|
+
{
|
|
1353
|
+
type: "function",
|
|
1354
|
+
name: "set_privacy_pool",
|
|
1355
|
+
inputs: [
|
|
1356
|
+
{
|
|
1357
|
+
name: "privacy_pool",
|
|
1358
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1359
|
+
}
|
|
1360
|
+
],
|
|
1361
|
+
outputs: [],
|
|
1362
|
+
state_mutability: "external"
|
|
1363
|
+
},
|
|
1033
1364
|
{
|
|
1034
1365
|
type: "function",
|
|
1035
1366
|
name: "pause",
|
|
@@ -1091,16 +1422,6 @@ var stela_default = [
|
|
|
1091
1422
|
}
|
|
1092
1423
|
]
|
|
1093
1424
|
},
|
|
1094
|
-
{
|
|
1095
|
-
type: "struct",
|
|
1096
|
-
name: "core::array::Span::<core::felt252>",
|
|
1097
|
-
members: [
|
|
1098
|
-
{
|
|
1099
|
-
name: "snapshot",
|
|
1100
|
-
type: "@core::array::Array::<core::felt252>"
|
|
1101
|
-
}
|
|
1102
|
-
]
|
|
1103
|
-
},
|
|
1104
1425
|
{
|
|
1105
1426
|
type: "struct",
|
|
1106
1427
|
name: "core::byte_array::ByteArray",
|
|
@@ -1902,6 +2223,121 @@ var stela_default = [
|
|
|
1902
2223
|
}
|
|
1903
2224
|
]
|
|
1904
2225
|
},
|
|
2226
|
+
{
|
|
2227
|
+
type: "event",
|
|
2228
|
+
name: "stela::stela::StelaProtocol::OrderFilled",
|
|
2229
|
+
kind: "struct",
|
|
2230
|
+
members: [
|
|
2231
|
+
{
|
|
2232
|
+
name: "inscription_id",
|
|
2233
|
+
type: "core::integer::u256",
|
|
2234
|
+
kind: "key"
|
|
2235
|
+
},
|
|
2236
|
+
{
|
|
2237
|
+
name: "order_hash",
|
|
2238
|
+
type: "core::felt252",
|
|
2239
|
+
kind: "key"
|
|
2240
|
+
},
|
|
2241
|
+
{
|
|
2242
|
+
name: "taker",
|
|
2243
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
2244
|
+
kind: "key"
|
|
2245
|
+
},
|
|
2246
|
+
{
|
|
2247
|
+
name: "fill_bps",
|
|
2248
|
+
type: "core::integer::u256",
|
|
2249
|
+
kind: "data"
|
|
2250
|
+
},
|
|
2251
|
+
{
|
|
2252
|
+
name: "total_filled_bps",
|
|
2253
|
+
type: "core::integer::u256",
|
|
2254
|
+
kind: "data"
|
|
2255
|
+
}
|
|
2256
|
+
]
|
|
2257
|
+
},
|
|
2258
|
+
{
|
|
2259
|
+
type: "event",
|
|
2260
|
+
name: "stela::stela::StelaProtocol::OrderCancelled",
|
|
2261
|
+
kind: "struct",
|
|
2262
|
+
members: [
|
|
2263
|
+
{
|
|
2264
|
+
name: "order_hash",
|
|
2265
|
+
type: "core::felt252",
|
|
2266
|
+
kind: "key"
|
|
2267
|
+
},
|
|
2268
|
+
{
|
|
2269
|
+
name: "maker",
|
|
2270
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
2271
|
+
kind: "data"
|
|
2272
|
+
}
|
|
2273
|
+
]
|
|
2274
|
+
},
|
|
2275
|
+
{
|
|
2276
|
+
type: "event",
|
|
2277
|
+
name: "stela::stela::StelaProtocol::OrdersBulkCancelled",
|
|
2278
|
+
kind: "struct",
|
|
2279
|
+
members: [
|
|
2280
|
+
{
|
|
2281
|
+
name: "maker",
|
|
2282
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
2283
|
+
kind: "key"
|
|
2284
|
+
},
|
|
2285
|
+
{
|
|
2286
|
+
name: "new_min_nonce",
|
|
2287
|
+
type: "core::felt252",
|
|
2288
|
+
kind: "data"
|
|
2289
|
+
}
|
|
2290
|
+
]
|
|
2291
|
+
},
|
|
2292
|
+
{
|
|
2293
|
+
type: "event",
|
|
2294
|
+
name: "stela::stela::StelaProtocol::PrivateSettled",
|
|
2295
|
+
kind: "struct",
|
|
2296
|
+
members: [
|
|
2297
|
+
{
|
|
2298
|
+
name: "inscription_id",
|
|
2299
|
+
type: "core::integer::u256",
|
|
2300
|
+
kind: "key"
|
|
2301
|
+
},
|
|
2302
|
+
{
|
|
2303
|
+
name: "lender_commitment",
|
|
2304
|
+
type: "core::felt252",
|
|
2305
|
+
kind: "key"
|
|
2306
|
+
},
|
|
2307
|
+
{
|
|
2308
|
+
name: "shares_committed",
|
|
2309
|
+
type: "core::integer::u256",
|
|
2310
|
+
kind: "data"
|
|
2311
|
+
}
|
|
2312
|
+
]
|
|
2313
|
+
},
|
|
2314
|
+
{
|
|
2315
|
+
type: "event",
|
|
2316
|
+
name: "stela::stela::StelaProtocol::PrivateSharesRedeemed",
|
|
2317
|
+
kind: "struct",
|
|
2318
|
+
members: [
|
|
2319
|
+
{
|
|
2320
|
+
name: "inscription_id",
|
|
2321
|
+
type: "core::integer::u256",
|
|
2322
|
+
kind: "key"
|
|
2323
|
+
},
|
|
2324
|
+
{
|
|
2325
|
+
name: "nullifier",
|
|
2326
|
+
type: "core::felt252",
|
|
2327
|
+
kind: "key"
|
|
2328
|
+
},
|
|
2329
|
+
{
|
|
2330
|
+
name: "shares",
|
|
2331
|
+
type: "core::integer::u256",
|
|
2332
|
+
kind: "data"
|
|
2333
|
+
},
|
|
2334
|
+
{
|
|
2335
|
+
name: "recipient",
|
|
2336
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
2337
|
+
kind: "data"
|
|
2338
|
+
}
|
|
2339
|
+
]
|
|
2340
|
+
},
|
|
1905
2341
|
{
|
|
1906
2342
|
type: "event",
|
|
1907
2343
|
name: "stela::stela::StelaProtocol::Event",
|
|
@@ -1971,6 +2407,31 @@ var stela_default = [
|
|
|
1971
2407
|
name: "OrderSettled",
|
|
1972
2408
|
type: "stela::stela::StelaProtocol::OrderSettled",
|
|
1973
2409
|
kind: "nested"
|
|
2410
|
+
},
|
|
2411
|
+
{
|
|
2412
|
+
name: "OrderFilled",
|
|
2413
|
+
type: "stela::stela::StelaProtocol::OrderFilled",
|
|
2414
|
+
kind: "nested"
|
|
2415
|
+
},
|
|
2416
|
+
{
|
|
2417
|
+
name: "OrderCancelled",
|
|
2418
|
+
type: "stela::stela::StelaProtocol::OrderCancelled",
|
|
2419
|
+
kind: "nested"
|
|
2420
|
+
},
|
|
2421
|
+
{
|
|
2422
|
+
name: "OrdersBulkCancelled",
|
|
2423
|
+
type: "stela::stela::StelaProtocol::OrdersBulkCancelled",
|
|
2424
|
+
kind: "nested"
|
|
2425
|
+
},
|
|
2426
|
+
{
|
|
2427
|
+
name: "PrivateSettled",
|
|
2428
|
+
type: "stela::stela::StelaProtocol::PrivateSettled",
|
|
2429
|
+
kind: "nested"
|
|
2430
|
+
},
|
|
2431
|
+
{
|
|
2432
|
+
name: "PrivateSharesRedeemed",
|
|
2433
|
+
type: "stela::stela::StelaProtocol::PrivateSharesRedeemed",
|
|
2434
|
+
kind: "nested"
|
|
1974
2435
|
}
|
|
1975
2436
|
]
|
|
1976
2437
|
}
|
|
@@ -2007,13 +2468,37 @@ var InscriptionClient = class {
|
|
|
2007
2468
|
return extractU256(result);
|
|
2008
2469
|
}
|
|
2009
2470
|
async getNonce(address) {
|
|
2010
|
-
const result = await this.contract.call("nonces", [address]);
|
|
2471
|
+
const result = await this.contract.call("nonces", [address], { blockIdentifier: "latest" });
|
|
2011
2472
|
return BigInt(String(result[0] ?? "0"));
|
|
2012
2473
|
}
|
|
2013
2474
|
async getRelayerFee() {
|
|
2014
2475
|
const result = await this.contract.call("get_relayer_fee");
|
|
2015
2476
|
return extractU256(result);
|
|
2016
2477
|
}
|
|
2478
|
+
async getTreasury() {
|
|
2479
|
+
const result = await this.contract.call("get_treasury");
|
|
2480
|
+
return String(result[0]);
|
|
2481
|
+
}
|
|
2482
|
+
async isPaused() {
|
|
2483
|
+
const result = await this.contract.call("is_paused");
|
|
2484
|
+
return Boolean(result[0]);
|
|
2485
|
+
}
|
|
2486
|
+
async isOrderRegistered(orderHash) {
|
|
2487
|
+
const result = await this.contract.call("is_order_registered", [orderHash]);
|
|
2488
|
+
return Boolean(result[0]);
|
|
2489
|
+
}
|
|
2490
|
+
async isOrderCancelled(orderHash) {
|
|
2491
|
+
const result = await this.contract.call("is_order_cancelled", [orderHash]);
|
|
2492
|
+
return Boolean(result[0]);
|
|
2493
|
+
}
|
|
2494
|
+
async getFilledBps(orderHash) {
|
|
2495
|
+
const result = await this.contract.call("get_filled_bps", [orderHash]);
|
|
2496
|
+
return extractU256(result);
|
|
2497
|
+
}
|
|
2498
|
+
async getMakerMinNonce(maker) {
|
|
2499
|
+
const result = await this.contract.call("get_maker_min_nonce", [maker], { blockIdentifier: "latest" });
|
|
2500
|
+
return String(result[0] ?? "0");
|
|
2501
|
+
}
|
|
2017
2502
|
// ── Call Builders ──────────────────────────────────────────────────
|
|
2018
2503
|
buildCreateInscription(params) {
|
|
2019
2504
|
const calldata = [
|
|
@@ -2062,6 +2547,53 @@ var InscriptionClient = class {
|
|
|
2062
2547
|
calldata: [...toU256(inscriptionId), ...toU256(shares)]
|
|
2063
2548
|
};
|
|
2064
2549
|
}
|
|
2550
|
+
buildPrivateRedeem(request, proof) {
|
|
2551
|
+
const calldata = [
|
|
2552
|
+
// PrivateRedeemRequest struct fields (must match Cairo Serde order)
|
|
2553
|
+
request.root,
|
|
2554
|
+
...toU256(request.inscriptionId),
|
|
2555
|
+
...toU256(request.shares),
|
|
2556
|
+
request.nullifier,
|
|
2557
|
+
request.changeCommitment,
|
|
2558
|
+
request.recipient,
|
|
2559
|
+
// proof array
|
|
2560
|
+
String(proof.length),
|
|
2561
|
+
...proof
|
|
2562
|
+
];
|
|
2563
|
+
return { contractAddress: this.address, entrypoint: "private_redeem", calldata };
|
|
2564
|
+
}
|
|
2565
|
+
/**
|
|
2566
|
+
* Build a shield() call on the privacy pool contract.
|
|
2567
|
+
* The depositor shields tokens into the pool, creating a commitment that can
|
|
2568
|
+
* later be consumed during private settlement.
|
|
2569
|
+
*/
|
|
2570
|
+
buildShieldDeposit(params) {
|
|
2571
|
+
return {
|
|
2572
|
+
contractAddress: params.privacyPoolAddress,
|
|
2573
|
+
entrypoint: "shield",
|
|
2574
|
+
calldata: [
|
|
2575
|
+
params.token,
|
|
2576
|
+
...toU256(params.amount),
|
|
2577
|
+
params.commitment
|
|
2578
|
+
]
|
|
2579
|
+
};
|
|
2580
|
+
}
|
|
2581
|
+
/**
|
|
2582
|
+
* Build a settle() call for private settlement.
|
|
2583
|
+
*
|
|
2584
|
+
* In a private settlement, the lender is zero address and the lender_commitment
|
|
2585
|
+
* is the deposit commitment from the privacy pool. The contract skips lender
|
|
2586
|
+
* signature verification and instead consumes the deposit from the privacy pool.
|
|
2587
|
+
*/
|
|
2588
|
+
buildSettlePrivate(params) {
|
|
2589
|
+
return this.buildSettle({
|
|
2590
|
+
...params,
|
|
2591
|
+
offer: {
|
|
2592
|
+
...params.offer,
|
|
2593
|
+
lender: "0x0"
|
|
2594
|
+
}
|
|
2595
|
+
});
|
|
2596
|
+
}
|
|
2065
2597
|
buildSettle(params) {
|
|
2066
2598
|
const calldata = [
|
|
2067
2599
|
// Order struct fields
|
|
@@ -2090,12 +2622,50 @@ var InscriptionClient = class {
|
|
|
2090
2622
|
params.offer.lender,
|
|
2091
2623
|
...toU256(params.offer.issuedDebtPercentage),
|
|
2092
2624
|
params.offer.nonce.toString(),
|
|
2625
|
+
params.offer.lenderCommitment ?? "0",
|
|
2093
2626
|
// lender_sig array
|
|
2094
2627
|
String(params.lenderSig.length),
|
|
2095
2628
|
...params.lenderSig
|
|
2096
2629
|
];
|
|
2097
2630
|
return { contractAddress: this.address, entrypoint: "settle", calldata };
|
|
2098
2631
|
}
|
|
2632
|
+
buildFillSignedOrder(order, signature, fillBps) {
|
|
2633
|
+
const calldata = [
|
|
2634
|
+
// SignedOrder struct fields
|
|
2635
|
+
order.maker,
|
|
2636
|
+
order.allowed_taker,
|
|
2637
|
+
...toU256(order.inscription_id),
|
|
2638
|
+
...toU256(order.bps),
|
|
2639
|
+
order.deadline.toString(),
|
|
2640
|
+
order.nonce,
|
|
2641
|
+
...toU256(order.min_fill_bps),
|
|
2642
|
+
// signature array
|
|
2643
|
+
String(signature.length),
|
|
2644
|
+
...signature,
|
|
2645
|
+
// fill_bps
|
|
2646
|
+
...toU256(fillBps)
|
|
2647
|
+
];
|
|
2648
|
+
return { contractAddress: this.address, entrypoint: "fill_signed_order", calldata };
|
|
2649
|
+
}
|
|
2650
|
+
buildCancelOrder(order) {
|
|
2651
|
+
const calldata = [
|
|
2652
|
+
order.maker,
|
|
2653
|
+
order.allowed_taker,
|
|
2654
|
+
...toU256(order.inscription_id),
|
|
2655
|
+
...toU256(order.bps),
|
|
2656
|
+
order.deadline.toString(),
|
|
2657
|
+
order.nonce,
|
|
2658
|
+
...toU256(order.min_fill_bps)
|
|
2659
|
+
];
|
|
2660
|
+
return { contractAddress: this.address, entrypoint: "cancel_order", calldata };
|
|
2661
|
+
}
|
|
2662
|
+
buildCancelOrdersByNonce(minNonce) {
|
|
2663
|
+
return {
|
|
2664
|
+
contractAddress: this.address,
|
|
2665
|
+
entrypoint: "cancel_orders_by_nonce",
|
|
2666
|
+
calldata: [minNonce]
|
|
2667
|
+
};
|
|
2668
|
+
}
|
|
2099
2669
|
// ── Execute Methods ────────────────────────────────────────────────
|
|
2100
2670
|
/**
|
|
2101
2671
|
* Execute one or more calls via the connected account.
|
|
@@ -2127,6 +2697,19 @@ var InscriptionClient = class {
|
|
|
2127
2697
|
async redeem(inscriptionId, shares) {
|
|
2128
2698
|
return this.execute([this.buildRedeem(inscriptionId, shares)]);
|
|
2129
2699
|
}
|
|
2700
|
+
async privateRedeem(request, proof) {
|
|
2701
|
+
return this.execute([this.buildPrivateRedeem(request, proof)]);
|
|
2702
|
+
}
|
|
2703
|
+
async fillSignedOrder(order, signature, fillBps, approvals) {
|
|
2704
|
+
const calls = [...approvals ?? [], this.buildFillSignedOrder(order, signature, fillBps)];
|
|
2705
|
+
return this.execute(calls);
|
|
2706
|
+
}
|
|
2707
|
+
async cancelOrder(order) {
|
|
2708
|
+
return this.execute([this.buildCancelOrder(order)]);
|
|
2709
|
+
}
|
|
2710
|
+
async cancelOrdersByNonce(minNonce) {
|
|
2711
|
+
return this.execute([this.buildCancelOrdersByNonce(minNonce)]);
|
|
2712
|
+
}
|
|
2130
2713
|
};
|
|
2131
2714
|
function serializeAssets(assets) {
|
|
2132
2715
|
const calldata = [String(assets.length)];
|
|
@@ -2512,8 +3095,12 @@ exports.VALID_STATUSES = VALID_STATUSES;
|
|
|
2512
3095
|
exports.VIRTUAL_SHARE_OFFSET = VIRTUAL_SHARE_OFFSET;
|
|
2513
3096
|
exports.addressesEqual = addressesEqual;
|
|
2514
3097
|
exports.calculateFeeShares = calculateFeeShares;
|
|
3098
|
+
exports.computeCommitment = computeCommitment;
|
|
3099
|
+
exports.computeDepositCommitment = computeDepositCommitment;
|
|
3100
|
+
exports.computeNullifier = computeNullifier;
|
|
2515
3101
|
exports.computeStatus = computeStatus;
|
|
2516
3102
|
exports.convertToShares = convertToShares;
|
|
3103
|
+
exports.createPrivateNote = createPrivateNote;
|
|
2517
3104
|
exports.deserializeSignature = deserializeSignature;
|
|
2518
3105
|
exports.findTokenByAddress = findTokenByAddress;
|
|
2519
3106
|
exports.formatAddress = formatAddress;
|
|
@@ -2521,10 +3108,13 @@ exports.formatDuration = formatDuration;
|
|
|
2521
3108
|
exports.formatTimestamp = formatTimestamp;
|
|
2522
3109
|
exports.formatTokenValue = formatTokenValue;
|
|
2523
3110
|
exports.fromU256 = fromU256;
|
|
3111
|
+
exports.generateSalt = generateSalt;
|
|
2524
3112
|
exports.getInscriptionOrderTypedData = getInscriptionOrderTypedData;
|
|
2525
3113
|
exports.getLendOfferTypedData = getLendOfferTypedData;
|
|
3114
|
+
exports.getPrivateLendOfferTypedData = getPrivateLendOfferTypedData;
|
|
2526
3115
|
exports.getTokensForNetwork = getTokensForNetwork;
|
|
2527
3116
|
exports.hashAssets = hashAssets;
|
|
3117
|
+
exports.hashPair = hashPair;
|
|
2528
3118
|
exports.inscriptionIdToHex = inscriptionIdToHex;
|
|
2529
3119
|
exports.normalizeAddress = normalizeAddress;
|
|
2530
3120
|
exports.parseAmount = parseAmount;
|