@fepvenancio/stela-sdk 0.2.3 → 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.
- package/README.md +2 -2
- package/dist/index.cjs +549 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +165 -2
- package/dist/index.d.ts +165 -2
- package/dist/index.js +546 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/abi/erc20 2.json +54 -0
- package/src/abi/erc20 3.json +54 -0
- package/src/abi/locker 2.json +50 -0
- package/src/abi/locker 3.json +50 -0
- package/src/abi/stela 2.json +1381 -0
- package/src/abi/stela 3.json +1714 -0
- 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: "0x00c667d12113011a05f6271cc4bd9e7f4c3c5b90a093708801955af5a5b1e6d5",
|
|
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
|
}
|
|
@@ -451,7 +497,8 @@ function getLendOfferTypedData(params) {
|
|
|
451
497
|
{ name: "order_hash", type: "felt" },
|
|
452
498
|
{ name: "lender", type: "ContractAddress" },
|
|
453
499
|
{ name: "issued_debt_percentage", type: "u256" },
|
|
454
|
-
{ name: "nonce", type: "felt" }
|
|
500
|
+
{ name: "nonce", type: "felt" },
|
|
501
|
+
{ name: "lender_commitment", type: "felt" }
|
|
455
502
|
],
|
|
456
503
|
u256: [
|
|
457
504
|
{ name: "low", type: "u128" },
|
|
@@ -470,7 +517,8 @@ function getLendOfferTypedData(params) {
|
|
|
470
517
|
low: (params.issuedDebtPercentage & (1n << 128n) - 1n).toString(),
|
|
471
518
|
high: (params.issuedDebtPercentage >> 128n).toString()
|
|
472
519
|
},
|
|
473
|
-
nonce: params.nonce.toString()
|
|
520
|
+
nonce: params.nonce.toString(),
|
|
521
|
+
lender_commitment: params.lenderCommitment ?? "0"
|
|
474
522
|
}
|
|
475
523
|
};
|
|
476
524
|
}
|
|
@@ -482,6 +530,43 @@ function serializeSignature(sig) {
|
|
|
482
530
|
function deserializeSignature(stored) {
|
|
483
531
|
return [stored.r, stored.s];
|
|
484
532
|
}
|
|
533
|
+
var COMMITMENT_DOMAIN = starknet.shortString.encodeShortString("STELA_COMMITMENT_V1");
|
|
534
|
+
var NULLIFIER_DOMAIN = starknet.shortString.encodeShortString("STELA_NULLIFIER_V1");
|
|
535
|
+
function computeCommitment(owner, inscriptionId, shares, salt) {
|
|
536
|
+
const [idLow, idHigh] = toU256(inscriptionId);
|
|
537
|
+
const [sharesLow, sharesHigh] = toU256(shares);
|
|
538
|
+
return starknet.hash.computePoseidonHashOnElements([
|
|
539
|
+
COMMITMENT_DOMAIN,
|
|
540
|
+
owner,
|
|
541
|
+
idLow,
|
|
542
|
+
idHigh,
|
|
543
|
+
sharesLow,
|
|
544
|
+
sharesHigh,
|
|
545
|
+
salt
|
|
546
|
+
]);
|
|
547
|
+
}
|
|
548
|
+
function computeNullifier(commitment, ownerSecret) {
|
|
549
|
+
return starknet.hash.computePoseidonHashOnElements([NULLIFIER_DOMAIN, commitment, ownerSecret]);
|
|
550
|
+
}
|
|
551
|
+
function hashPair(left, right) {
|
|
552
|
+
return starknet.hash.computePoseidonHashOnElements([left, right]);
|
|
553
|
+
}
|
|
554
|
+
function generateSalt() {
|
|
555
|
+
const bytes = new Uint8Array(31);
|
|
556
|
+
crypto.getRandomValues(bytes);
|
|
557
|
+
return "0x" + Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
558
|
+
}
|
|
559
|
+
function createPrivateNote(owner, inscriptionId, shares, salt) {
|
|
560
|
+
const noteSalt = salt ?? generateSalt();
|
|
561
|
+
const commitment = computeCommitment(owner, inscriptionId, shares, noteSalt);
|
|
562
|
+
return {
|
|
563
|
+
owner,
|
|
564
|
+
inscriptionId,
|
|
565
|
+
shares,
|
|
566
|
+
salt: noteSalt,
|
|
567
|
+
commitment
|
|
568
|
+
};
|
|
569
|
+
}
|
|
485
570
|
|
|
486
571
|
// src/abi/stela.json
|
|
487
572
|
var stela_default = [
|
|
@@ -596,6 +681,46 @@ var stela_default = [
|
|
|
596
681
|
}
|
|
597
682
|
]
|
|
598
683
|
},
|
|
684
|
+
{
|
|
685
|
+
type: "struct",
|
|
686
|
+
name: "stela::types::private_redeem::PrivateRedeemRequest",
|
|
687
|
+
members: [
|
|
688
|
+
{
|
|
689
|
+
name: "root",
|
|
690
|
+
type: "core::felt252"
|
|
691
|
+
},
|
|
692
|
+
{
|
|
693
|
+
name: "inscription_id",
|
|
694
|
+
type: "core::integer::u256"
|
|
695
|
+
},
|
|
696
|
+
{
|
|
697
|
+
name: "shares",
|
|
698
|
+
type: "core::integer::u256"
|
|
699
|
+
},
|
|
700
|
+
{
|
|
701
|
+
name: "nullifier",
|
|
702
|
+
type: "core::felt252"
|
|
703
|
+
},
|
|
704
|
+
{
|
|
705
|
+
name: "change_commitment",
|
|
706
|
+
type: "core::felt252"
|
|
707
|
+
},
|
|
708
|
+
{
|
|
709
|
+
name: "recipient",
|
|
710
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
711
|
+
}
|
|
712
|
+
]
|
|
713
|
+
},
|
|
714
|
+
{
|
|
715
|
+
type: "struct",
|
|
716
|
+
name: "core::array::Span::<core::felt252>",
|
|
717
|
+
members: [
|
|
718
|
+
{
|
|
719
|
+
name: "snapshot",
|
|
720
|
+
type: "@core::array::Array::<core::felt252>"
|
|
721
|
+
}
|
|
722
|
+
]
|
|
723
|
+
},
|
|
599
724
|
{
|
|
600
725
|
type: "struct",
|
|
601
726
|
name: "stela::snip12::InscriptionOrder",
|
|
@@ -665,6 +790,44 @@ var stela_default = [
|
|
|
665
790
|
{
|
|
666
791
|
name: "nonce",
|
|
667
792
|
type: "core::felt252"
|
|
793
|
+
},
|
|
794
|
+
{
|
|
795
|
+
name: "lender_commitment",
|
|
796
|
+
type: "core::felt252"
|
|
797
|
+
}
|
|
798
|
+
]
|
|
799
|
+
},
|
|
800
|
+
{
|
|
801
|
+
type: "struct",
|
|
802
|
+
name: "stela::types::signed_order::SignedOrder",
|
|
803
|
+
members: [
|
|
804
|
+
{
|
|
805
|
+
name: "maker",
|
|
806
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
807
|
+
},
|
|
808
|
+
{
|
|
809
|
+
name: "allowed_taker",
|
|
810
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
811
|
+
},
|
|
812
|
+
{
|
|
813
|
+
name: "inscription_id",
|
|
814
|
+
type: "core::integer::u256"
|
|
815
|
+
},
|
|
816
|
+
{
|
|
817
|
+
name: "bps",
|
|
818
|
+
type: "core::integer::u256"
|
|
819
|
+
},
|
|
820
|
+
{
|
|
821
|
+
name: "deadline",
|
|
822
|
+
type: "core::integer::u64"
|
|
823
|
+
},
|
|
824
|
+
{
|
|
825
|
+
name: "nonce",
|
|
826
|
+
type: "core::felt252"
|
|
827
|
+
},
|
|
828
|
+
{
|
|
829
|
+
name: "min_fill_bps",
|
|
830
|
+
type: "core::integer::u256"
|
|
668
831
|
}
|
|
669
832
|
]
|
|
670
833
|
},
|
|
@@ -810,6 +973,22 @@ var stela_default = [
|
|
|
810
973
|
outputs: [],
|
|
811
974
|
state_mutability: "external"
|
|
812
975
|
},
|
|
976
|
+
{
|
|
977
|
+
type: "function",
|
|
978
|
+
name: "private_redeem",
|
|
979
|
+
inputs: [
|
|
980
|
+
{
|
|
981
|
+
name: "request",
|
|
982
|
+
type: "stela::types::private_redeem::PrivateRedeemRequest"
|
|
983
|
+
},
|
|
984
|
+
{
|
|
985
|
+
name: "proof",
|
|
986
|
+
type: "core::array::Span::<core::felt252>"
|
|
987
|
+
}
|
|
988
|
+
],
|
|
989
|
+
outputs: [],
|
|
990
|
+
state_mutability: "external"
|
|
991
|
+
},
|
|
813
992
|
{
|
|
814
993
|
type: "function",
|
|
815
994
|
name: "settle",
|
|
@@ -846,6 +1025,50 @@ var stela_default = [
|
|
|
846
1025
|
outputs: [],
|
|
847
1026
|
state_mutability: "external"
|
|
848
1027
|
},
|
|
1028
|
+
{
|
|
1029
|
+
type: "function",
|
|
1030
|
+
name: "fill_signed_order",
|
|
1031
|
+
inputs: [
|
|
1032
|
+
{
|
|
1033
|
+
name: "order",
|
|
1034
|
+
type: "stela::types::signed_order::SignedOrder"
|
|
1035
|
+
},
|
|
1036
|
+
{
|
|
1037
|
+
name: "signature",
|
|
1038
|
+
type: "core::array::Array::<core::felt252>"
|
|
1039
|
+
},
|
|
1040
|
+
{
|
|
1041
|
+
name: "fill_bps",
|
|
1042
|
+
type: "core::integer::u256"
|
|
1043
|
+
}
|
|
1044
|
+
],
|
|
1045
|
+
outputs: [],
|
|
1046
|
+
state_mutability: "external"
|
|
1047
|
+
},
|
|
1048
|
+
{
|
|
1049
|
+
type: "function",
|
|
1050
|
+
name: "cancel_order",
|
|
1051
|
+
inputs: [
|
|
1052
|
+
{
|
|
1053
|
+
name: "order",
|
|
1054
|
+
type: "stela::types::signed_order::SignedOrder"
|
|
1055
|
+
}
|
|
1056
|
+
],
|
|
1057
|
+
outputs: [],
|
|
1058
|
+
state_mutability: "external"
|
|
1059
|
+
},
|
|
1060
|
+
{
|
|
1061
|
+
type: "function",
|
|
1062
|
+
name: "cancel_orders_by_nonce",
|
|
1063
|
+
inputs: [
|
|
1064
|
+
{
|
|
1065
|
+
name: "min_nonce",
|
|
1066
|
+
type: "core::felt252"
|
|
1067
|
+
}
|
|
1068
|
+
],
|
|
1069
|
+
outputs: [],
|
|
1070
|
+
state_mutability: "external"
|
|
1071
|
+
},
|
|
849
1072
|
{
|
|
850
1073
|
type: "function",
|
|
851
1074
|
name: "get_inscription",
|
|
@@ -958,6 +1181,81 @@ var stela_default = [
|
|
|
958
1181
|
],
|
|
959
1182
|
state_mutability: "view"
|
|
960
1183
|
},
|
|
1184
|
+
{
|
|
1185
|
+
type: "function",
|
|
1186
|
+
name: "is_order_registered",
|
|
1187
|
+
inputs: [
|
|
1188
|
+
{
|
|
1189
|
+
name: "order_hash",
|
|
1190
|
+
type: "core::felt252"
|
|
1191
|
+
}
|
|
1192
|
+
],
|
|
1193
|
+
outputs: [
|
|
1194
|
+
{
|
|
1195
|
+
type: "core::bool"
|
|
1196
|
+
}
|
|
1197
|
+
],
|
|
1198
|
+
state_mutability: "view"
|
|
1199
|
+
},
|
|
1200
|
+
{
|
|
1201
|
+
type: "function",
|
|
1202
|
+
name: "is_order_cancelled",
|
|
1203
|
+
inputs: [
|
|
1204
|
+
{
|
|
1205
|
+
name: "order_hash",
|
|
1206
|
+
type: "core::felt252"
|
|
1207
|
+
}
|
|
1208
|
+
],
|
|
1209
|
+
outputs: [
|
|
1210
|
+
{
|
|
1211
|
+
type: "core::bool"
|
|
1212
|
+
}
|
|
1213
|
+
],
|
|
1214
|
+
state_mutability: "view"
|
|
1215
|
+
},
|
|
1216
|
+
{
|
|
1217
|
+
type: "function",
|
|
1218
|
+
name: "get_filled_bps",
|
|
1219
|
+
inputs: [
|
|
1220
|
+
{
|
|
1221
|
+
name: "order_hash",
|
|
1222
|
+
type: "core::felt252"
|
|
1223
|
+
}
|
|
1224
|
+
],
|
|
1225
|
+
outputs: [
|
|
1226
|
+
{
|
|
1227
|
+
type: "core::integer::u256"
|
|
1228
|
+
}
|
|
1229
|
+
],
|
|
1230
|
+
state_mutability: "view"
|
|
1231
|
+
},
|
|
1232
|
+
{
|
|
1233
|
+
type: "function",
|
|
1234
|
+
name: "get_maker_min_nonce",
|
|
1235
|
+
inputs: [
|
|
1236
|
+
{
|
|
1237
|
+
name: "maker",
|
|
1238
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1239
|
+
}
|
|
1240
|
+
],
|
|
1241
|
+
outputs: [
|
|
1242
|
+
{
|
|
1243
|
+
type: "core::felt252"
|
|
1244
|
+
}
|
|
1245
|
+
],
|
|
1246
|
+
state_mutability: "view"
|
|
1247
|
+
},
|
|
1248
|
+
{
|
|
1249
|
+
type: "function",
|
|
1250
|
+
name: "get_privacy_pool",
|
|
1251
|
+
inputs: [],
|
|
1252
|
+
outputs: [
|
|
1253
|
+
{
|
|
1254
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1255
|
+
}
|
|
1256
|
+
],
|
|
1257
|
+
state_mutability: "view"
|
|
1258
|
+
},
|
|
961
1259
|
{
|
|
962
1260
|
type: "function",
|
|
963
1261
|
name: "set_inscription_fee",
|
|
@@ -1030,6 +1328,18 @@ var stela_default = [
|
|
|
1030
1328
|
outputs: [],
|
|
1031
1329
|
state_mutability: "external"
|
|
1032
1330
|
},
|
|
1331
|
+
{
|
|
1332
|
+
type: "function",
|
|
1333
|
+
name: "set_privacy_pool",
|
|
1334
|
+
inputs: [
|
|
1335
|
+
{
|
|
1336
|
+
name: "privacy_pool",
|
|
1337
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1338
|
+
}
|
|
1339
|
+
],
|
|
1340
|
+
outputs: [],
|
|
1341
|
+
state_mutability: "external"
|
|
1342
|
+
},
|
|
1033
1343
|
{
|
|
1034
1344
|
type: "function",
|
|
1035
1345
|
name: "pause",
|
|
@@ -1091,16 +1401,6 @@ var stela_default = [
|
|
|
1091
1401
|
}
|
|
1092
1402
|
]
|
|
1093
1403
|
},
|
|
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
1404
|
{
|
|
1105
1405
|
type: "struct",
|
|
1106
1406
|
name: "core::byte_array::ByteArray",
|
|
@@ -1902,6 +2202,121 @@ var stela_default = [
|
|
|
1902
2202
|
}
|
|
1903
2203
|
]
|
|
1904
2204
|
},
|
|
2205
|
+
{
|
|
2206
|
+
type: "event",
|
|
2207
|
+
name: "stela::stela::StelaProtocol::OrderFilled",
|
|
2208
|
+
kind: "struct",
|
|
2209
|
+
members: [
|
|
2210
|
+
{
|
|
2211
|
+
name: "inscription_id",
|
|
2212
|
+
type: "core::integer::u256",
|
|
2213
|
+
kind: "key"
|
|
2214
|
+
},
|
|
2215
|
+
{
|
|
2216
|
+
name: "order_hash",
|
|
2217
|
+
type: "core::felt252",
|
|
2218
|
+
kind: "key"
|
|
2219
|
+
},
|
|
2220
|
+
{
|
|
2221
|
+
name: "taker",
|
|
2222
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
2223
|
+
kind: "key"
|
|
2224
|
+
},
|
|
2225
|
+
{
|
|
2226
|
+
name: "fill_bps",
|
|
2227
|
+
type: "core::integer::u256",
|
|
2228
|
+
kind: "data"
|
|
2229
|
+
},
|
|
2230
|
+
{
|
|
2231
|
+
name: "total_filled_bps",
|
|
2232
|
+
type: "core::integer::u256",
|
|
2233
|
+
kind: "data"
|
|
2234
|
+
}
|
|
2235
|
+
]
|
|
2236
|
+
},
|
|
2237
|
+
{
|
|
2238
|
+
type: "event",
|
|
2239
|
+
name: "stela::stela::StelaProtocol::OrderCancelled",
|
|
2240
|
+
kind: "struct",
|
|
2241
|
+
members: [
|
|
2242
|
+
{
|
|
2243
|
+
name: "order_hash",
|
|
2244
|
+
type: "core::felt252",
|
|
2245
|
+
kind: "key"
|
|
2246
|
+
},
|
|
2247
|
+
{
|
|
2248
|
+
name: "maker",
|
|
2249
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
2250
|
+
kind: "data"
|
|
2251
|
+
}
|
|
2252
|
+
]
|
|
2253
|
+
},
|
|
2254
|
+
{
|
|
2255
|
+
type: "event",
|
|
2256
|
+
name: "stela::stela::StelaProtocol::OrdersBulkCancelled",
|
|
2257
|
+
kind: "struct",
|
|
2258
|
+
members: [
|
|
2259
|
+
{
|
|
2260
|
+
name: "maker",
|
|
2261
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
2262
|
+
kind: "key"
|
|
2263
|
+
},
|
|
2264
|
+
{
|
|
2265
|
+
name: "new_min_nonce",
|
|
2266
|
+
type: "core::felt252",
|
|
2267
|
+
kind: "data"
|
|
2268
|
+
}
|
|
2269
|
+
]
|
|
2270
|
+
},
|
|
2271
|
+
{
|
|
2272
|
+
type: "event",
|
|
2273
|
+
name: "stela::stela::StelaProtocol::PrivateSettled",
|
|
2274
|
+
kind: "struct",
|
|
2275
|
+
members: [
|
|
2276
|
+
{
|
|
2277
|
+
name: "inscription_id",
|
|
2278
|
+
type: "core::integer::u256",
|
|
2279
|
+
kind: "key"
|
|
2280
|
+
},
|
|
2281
|
+
{
|
|
2282
|
+
name: "lender_commitment",
|
|
2283
|
+
type: "core::felt252",
|
|
2284
|
+
kind: "key"
|
|
2285
|
+
},
|
|
2286
|
+
{
|
|
2287
|
+
name: "shares_committed",
|
|
2288
|
+
type: "core::integer::u256",
|
|
2289
|
+
kind: "data"
|
|
2290
|
+
}
|
|
2291
|
+
]
|
|
2292
|
+
},
|
|
2293
|
+
{
|
|
2294
|
+
type: "event",
|
|
2295
|
+
name: "stela::stela::StelaProtocol::PrivateSharesRedeemed",
|
|
2296
|
+
kind: "struct",
|
|
2297
|
+
members: [
|
|
2298
|
+
{
|
|
2299
|
+
name: "inscription_id",
|
|
2300
|
+
type: "core::integer::u256",
|
|
2301
|
+
kind: "key"
|
|
2302
|
+
},
|
|
2303
|
+
{
|
|
2304
|
+
name: "nullifier",
|
|
2305
|
+
type: "core::felt252",
|
|
2306
|
+
kind: "key"
|
|
2307
|
+
},
|
|
2308
|
+
{
|
|
2309
|
+
name: "shares",
|
|
2310
|
+
type: "core::integer::u256",
|
|
2311
|
+
kind: "data"
|
|
2312
|
+
},
|
|
2313
|
+
{
|
|
2314
|
+
name: "recipient",
|
|
2315
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
2316
|
+
kind: "data"
|
|
2317
|
+
}
|
|
2318
|
+
]
|
|
2319
|
+
},
|
|
1905
2320
|
{
|
|
1906
2321
|
type: "event",
|
|
1907
2322
|
name: "stela::stela::StelaProtocol::Event",
|
|
@@ -1971,6 +2386,31 @@ var stela_default = [
|
|
|
1971
2386
|
name: "OrderSettled",
|
|
1972
2387
|
type: "stela::stela::StelaProtocol::OrderSettled",
|
|
1973
2388
|
kind: "nested"
|
|
2389
|
+
},
|
|
2390
|
+
{
|
|
2391
|
+
name: "OrderFilled",
|
|
2392
|
+
type: "stela::stela::StelaProtocol::OrderFilled",
|
|
2393
|
+
kind: "nested"
|
|
2394
|
+
},
|
|
2395
|
+
{
|
|
2396
|
+
name: "OrderCancelled",
|
|
2397
|
+
type: "stela::stela::StelaProtocol::OrderCancelled",
|
|
2398
|
+
kind: "nested"
|
|
2399
|
+
},
|
|
2400
|
+
{
|
|
2401
|
+
name: "OrdersBulkCancelled",
|
|
2402
|
+
type: "stela::stela::StelaProtocol::OrdersBulkCancelled",
|
|
2403
|
+
kind: "nested"
|
|
2404
|
+
},
|
|
2405
|
+
{
|
|
2406
|
+
name: "PrivateSettled",
|
|
2407
|
+
type: "stela::stela::StelaProtocol::PrivateSettled",
|
|
2408
|
+
kind: "nested"
|
|
2409
|
+
},
|
|
2410
|
+
{
|
|
2411
|
+
name: "PrivateSharesRedeemed",
|
|
2412
|
+
type: "stela::stela::StelaProtocol::PrivateSharesRedeemed",
|
|
2413
|
+
kind: "nested"
|
|
1974
2414
|
}
|
|
1975
2415
|
]
|
|
1976
2416
|
}
|
|
@@ -2014,6 +2454,30 @@ var InscriptionClient = class {
|
|
|
2014
2454
|
const result = await this.contract.call("get_relayer_fee");
|
|
2015
2455
|
return extractU256(result);
|
|
2016
2456
|
}
|
|
2457
|
+
async getTreasury() {
|
|
2458
|
+
const result = await this.contract.call("get_treasury");
|
|
2459
|
+
return String(result[0]);
|
|
2460
|
+
}
|
|
2461
|
+
async isPaused() {
|
|
2462
|
+
const result = await this.contract.call("is_paused");
|
|
2463
|
+
return Boolean(result[0]);
|
|
2464
|
+
}
|
|
2465
|
+
async isOrderRegistered(orderHash) {
|
|
2466
|
+
const result = await this.contract.call("is_order_registered", [orderHash]);
|
|
2467
|
+
return Boolean(result[0]);
|
|
2468
|
+
}
|
|
2469
|
+
async isOrderCancelled(orderHash) {
|
|
2470
|
+
const result = await this.contract.call("is_order_cancelled", [orderHash]);
|
|
2471
|
+
return Boolean(result[0]);
|
|
2472
|
+
}
|
|
2473
|
+
async getFilledBps(orderHash) {
|
|
2474
|
+
const result = await this.contract.call("get_filled_bps", [orderHash]);
|
|
2475
|
+
return extractU256(result);
|
|
2476
|
+
}
|
|
2477
|
+
async getMakerMinNonce(maker) {
|
|
2478
|
+
const result = await this.contract.call("get_maker_min_nonce", [maker]);
|
|
2479
|
+
return String(result[0] ?? "0");
|
|
2480
|
+
}
|
|
2017
2481
|
// ── Call Builders ──────────────────────────────────────────────────
|
|
2018
2482
|
buildCreateInscription(params) {
|
|
2019
2483
|
const calldata = [
|
|
@@ -2062,6 +2526,21 @@ var InscriptionClient = class {
|
|
|
2062
2526
|
calldata: [...toU256(inscriptionId), ...toU256(shares)]
|
|
2063
2527
|
};
|
|
2064
2528
|
}
|
|
2529
|
+
buildPrivateRedeem(request, proof) {
|
|
2530
|
+
const calldata = [
|
|
2531
|
+
// PrivateRedeemRequest struct fields (must match Cairo Serde order)
|
|
2532
|
+
request.root,
|
|
2533
|
+
...toU256(request.inscriptionId),
|
|
2534
|
+
...toU256(request.shares),
|
|
2535
|
+
request.nullifier,
|
|
2536
|
+
request.changeCommitment,
|
|
2537
|
+
request.recipient,
|
|
2538
|
+
// proof array
|
|
2539
|
+
String(proof.length),
|
|
2540
|
+
...proof
|
|
2541
|
+
];
|
|
2542
|
+
return { contractAddress: this.address, entrypoint: "private_redeem", calldata };
|
|
2543
|
+
}
|
|
2065
2544
|
buildSettle(params) {
|
|
2066
2545
|
const calldata = [
|
|
2067
2546
|
// Order struct fields
|
|
@@ -2090,12 +2569,50 @@ var InscriptionClient = class {
|
|
|
2090
2569
|
params.offer.lender,
|
|
2091
2570
|
...toU256(params.offer.issuedDebtPercentage),
|
|
2092
2571
|
params.offer.nonce.toString(),
|
|
2572
|
+
params.offer.lenderCommitment ?? "0",
|
|
2093
2573
|
// lender_sig array
|
|
2094
2574
|
String(params.lenderSig.length),
|
|
2095
2575
|
...params.lenderSig
|
|
2096
2576
|
];
|
|
2097
2577
|
return { contractAddress: this.address, entrypoint: "settle", calldata };
|
|
2098
2578
|
}
|
|
2579
|
+
buildFillSignedOrder(order, signature, fillBps) {
|
|
2580
|
+
const calldata = [
|
|
2581
|
+
// SignedOrder struct fields
|
|
2582
|
+
order.maker,
|
|
2583
|
+
order.allowed_taker,
|
|
2584
|
+
...toU256(order.inscription_id),
|
|
2585
|
+
...toU256(order.bps),
|
|
2586
|
+
order.deadline.toString(),
|
|
2587
|
+
order.nonce,
|
|
2588
|
+
...toU256(order.min_fill_bps),
|
|
2589
|
+
// signature array
|
|
2590
|
+
String(signature.length),
|
|
2591
|
+
...signature,
|
|
2592
|
+
// fill_bps
|
|
2593
|
+
...toU256(fillBps)
|
|
2594
|
+
];
|
|
2595
|
+
return { contractAddress: this.address, entrypoint: "fill_signed_order", calldata };
|
|
2596
|
+
}
|
|
2597
|
+
buildCancelOrder(order) {
|
|
2598
|
+
const calldata = [
|
|
2599
|
+
order.maker,
|
|
2600
|
+
order.allowed_taker,
|
|
2601
|
+
...toU256(order.inscription_id),
|
|
2602
|
+
...toU256(order.bps),
|
|
2603
|
+
order.deadline.toString(),
|
|
2604
|
+
order.nonce,
|
|
2605
|
+
...toU256(order.min_fill_bps)
|
|
2606
|
+
];
|
|
2607
|
+
return { contractAddress: this.address, entrypoint: "cancel_order", calldata };
|
|
2608
|
+
}
|
|
2609
|
+
buildCancelOrdersByNonce(minNonce) {
|
|
2610
|
+
return {
|
|
2611
|
+
contractAddress: this.address,
|
|
2612
|
+
entrypoint: "cancel_orders_by_nonce",
|
|
2613
|
+
calldata: [minNonce]
|
|
2614
|
+
};
|
|
2615
|
+
}
|
|
2099
2616
|
// ── Execute Methods ────────────────────────────────────────────────
|
|
2100
2617
|
/**
|
|
2101
2618
|
* Execute one or more calls via the connected account.
|
|
@@ -2127,6 +2644,19 @@ var InscriptionClient = class {
|
|
|
2127
2644
|
async redeem(inscriptionId, shares) {
|
|
2128
2645
|
return this.execute([this.buildRedeem(inscriptionId, shares)]);
|
|
2129
2646
|
}
|
|
2647
|
+
async privateRedeem(request, proof) {
|
|
2648
|
+
return this.execute([this.buildPrivateRedeem(request, proof)]);
|
|
2649
|
+
}
|
|
2650
|
+
async fillSignedOrder(order, signature, fillBps, approvals) {
|
|
2651
|
+
const calls = [...approvals ?? [], this.buildFillSignedOrder(order, signature, fillBps)];
|
|
2652
|
+
return this.execute(calls);
|
|
2653
|
+
}
|
|
2654
|
+
async cancelOrder(order) {
|
|
2655
|
+
return this.execute([this.buildCancelOrder(order)]);
|
|
2656
|
+
}
|
|
2657
|
+
async cancelOrdersByNonce(minNonce) {
|
|
2658
|
+
return this.execute([this.buildCancelOrdersByNonce(minNonce)]);
|
|
2659
|
+
}
|
|
2130
2660
|
};
|
|
2131
2661
|
function serializeAssets(assets) {
|
|
2132
2662
|
const calldata = [String(assets.length)];
|
|
@@ -2512,8 +3042,11 @@ exports.VALID_STATUSES = VALID_STATUSES;
|
|
|
2512
3042
|
exports.VIRTUAL_SHARE_OFFSET = VIRTUAL_SHARE_OFFSET;
|
|
2513
3043
|
exports.addressesEqual = addressesEqual;
|
|
2514
3044
|
exports.calculateFeeShares = calculateFeeShares;
|
|
3045
|
+
exports.computeCommitment = computeCommitment;
|
|
3046
|
+
exports.computeNullifier = computeNullifier;
|
|
2515
3047
|
exports.computeStatus = computeStatus;
|
|
2516
3048
|
exports.convertToShares = convertToShares;
|
|
3049
|
+
exports.createPrivateNote = createPrivateNote;
|
|
2517
3050
|
exports.deserializeSignature = deserializeSignature;
|
|
2518
3051
|
exports.findTokenByAddress = findTokenByAddress;
|
|
2519
3052
|
exports.formatAddress = formatAddress;
|
|
@@ -2521,10 +3054,12 @@ exports.formatDuration = formatDuration;
|
|
|
2521
3054
|
exports.formatTimestamp = formatTimestamp;
|
|
2522
3055
|
exports.formatTokenValue = formatTokenValue;
|
|
2523
3056
|
exports.fromU256 = fromU256;
|
|
3057
|
+
exports.generateSalt = generateSalt;
|
|
2524
3058
|
exports.getInscriptionOrderTypedData = getInscriptionOrderTypedData;
|
|
2525
3059
|
exports.getLendOfferTypedData = getLendOfferTypedData;
|
|
2526
3060
|
exports.getTokensForNetwork = getTokensForNetwork;
|
|
2527
3061
|
exports.hashAssets = hashAssets;
|
|
3062
|
+
exports.hashPair = hashPair;
|
|
2528
3063
|
exports.inscriptionIdToHex = inscriptionIdToHex;
|
|
2529
3064
|
exports.normalizeAddress = normalizeAddress;
|
|
2530
3065
|
exports.parseAmount = parseAmount;
|