@fepvenancio/stela-sdk 0.2.2 → 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.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { hash, uint256, addAddressPadding, validateAndParseAddress, Contract } from 'starknet';
|
|
1
|
+
import { hash, shortString, uint256, addAddressPadding, validateAndParseAddress, Contract } from 'starknet';
|
|
2
2
|
|
|
3
3
|
// src/types/common.ts
|
|
4
4
|
var VALID_STATUSES = [
|
|
@@ -22,7 +22,7 @@ var STATUS_LABELS = {
|
|
|
22
22
|
|
|
23
23
|
// src/constants/addresses.ts
|
|
24
24
|
var STELA_ADDRESS = {
|
|
25
|
-
sepolia: "
|
|
25
|
+
sepolia: "0x00c667d12113011a05f6271cc4bd9e7f4c3c5b90a093708801955af5a5b1e6d5",
|
|
26
26
|
mainnet: "0x0"
|
|
27
27
|
};
|
|
28
28
|
var VALID_NETWORKS = ["sepolia", "mainnet"];
|
|
@@ -281,7 +281,11 @@ var SELECTORS = {
|
|
|
281
281
|
InscriptionRepaid: hash.getSelectorFromName("InscriptionRepaid"),
|
|
282
282
|
InscriptionLiquidated: hash.getSelectorFromName("InscriptionLiquidated"),
|
|
283
283
|
SharesRedeemed: hash.getSelectorFromName("SharesRedeemed"),
|
|
284
|
-
TransferSingle: hash.getSelectorFromName("TransferSingle")
|
|
284
|
+
TransferSingle: hash.getSelectorFromName("TransferSingle"),
|
|
285
|
+
OrderSettled: hash.getSelectorFromName("OrderSettled"),
|
|
286
|
+
OrderFilled: hash.getSelectorFromName("OrderFilled"),
|
|
287
|
+
OrderCancelled: hash.getSelectorFromName("OrderCancelled"),
|
|
288
|
+
OrdersBulkCancelled: hash.getSelectorFromName("OrdersBulkCancelled")
|
|
285
289
|
};
|
|
286
290
|
function feltsToU256(low, high) {
|
|
287
291
|
return uint256.uint256ToBN({ low: BigInt(low), high: BigInt(high) });
|
|
@@ -360,6 +364,48 @@ function parseEvent(raw) {
|
|
|
360
364
|
block_number: raw.block_number
|
|
361
365
|
};
|
|
362
366
|
}
|
|
367
|
+
case SELECTORS.OrderSettled: {
|
|
368
|
+
return {
|
|
369
|
+
type: "OrderSettled",
|
|
370
|
+
inscription_id: feltsToU256(raw.keys[1], raw.keys[2]),
|
|
371
|
+
borrower: raw.keys[3],
|
|
372
|
+
lender: raw.keys[4],
|
|
373
|
+
relayer: raw.data[0],
|
|
374
|
+
relayer_fee_amount: feltsToU256(raw.data[1], raw.data[2]),
|
|
375
|
+
transaction_hash: raw.transaction_hash,
|
|
376
|
+
block_number: raw.block_number
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
case SELECTORS.OrderFilled: {
|
|
380
|
+
return {
|
|
381
|
+
type: "OrderFilled",
|
|
382
|
+
inscription_id: feltsToU256(raw.keys[1], raw.keys[2]),
|
|
383
|
+
order_hash: raw.keys[3],
|
|
384
|
+
taker: raw.keys[4],
|
|
385
|
+
fill_bps: feltsToU256(raw.data[0], raw.data[1]),
|
|
386
|
+
total_filled_bps: feltsToU256(raw.data[2], raw.data[3]),
|
|
387
|
+
transaction_hash: raw.transaction_hash,
|
|
388
|
+
block_number: raw.block_number
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
case SELECTORS.OrderCancelled: {
|
|
392
|
+
return {
|
|
393
|
+
type: "OrderCancelled",
|
|
394
|
+
order_hash: raw.keys[1],
|
|
395
|
+
maker: raw.data[0],
|
|
396
|
+
transaction_hash: raw.transaction_hash,
|
|
397
|
+
block_number: raw.block_number
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
case SELECTORS.OrdersBulkCancelled: {
|
|
401
|
+
return {
|
|
402
|
+
type: "OrdersBulkCancelled",
|
|
403
|
+
maker: raw.keys[1],
|
|
404
|
+
new_min_nonce: raw.data[0],
|
|
405
|
+
transaction_hash: raw.transaction_hash,
|
|
406
|
+
block_number: raw.block_number
|
|
407
|
+
};
|
|
408
|
+
}
|
|
363
409
|
default:
|
|
364
410
|
return null;
|
|
365
411
|
}
|
|
@@ -449,7 +495,8 @@ function getLendOfferTypedData(params) {
|
|
|
449
495
|
{ name: "order_hash", type: "felt" },
|
|
450
496
|
{ name: "lender", type: "ContractAddress" },
|
|
451
497
|
{ name: "issued_debt_percentage", type: "u256" },
|
|
452
|
-
{ name: "nonce", type: "felt" }
|
|
498
|
+
{ name: "nonce", type: "felt" },
|
|
499
|
+
{ name: "lender_commitment", type: "felt" }
|
|
453
500
|
],
|
|
454
501
|
u256: [
|
|
455
502
|
{ name: "low", type: "u128" },
|
|
@@ -468,7 +515,8 @@ function getLendOfferTypedData(params) {
|
|
|
468
515
|
low: (params.issuedDebtPercentage & (1n << 128n) - 1n).toString(),
|
|
469
516
|
high: (params.issuedDebtPercentage >> 128n).toString()
|
|
470
517
|
},
|
|
471
|
-
nonce: params.nonce.toString()
|
|
518
|
+
nonce: params.nonce.toString(),
|
|
519
|
+
lender_commitment: params.lenderCommitment ?? "0"
|
|
472
520
|
}
|
|
473
521
|
};
|
|
474
522
|
}
|
|
@@ -480,6 +528,43 @@ function serializeSignature(sig) {
|
|
|
480
528
|
function deserializeSignature(stored) {
|
|
481
529
|
return [stored.r, stored.s];
|
|
482
530
|
}
|
|
531
|
+
var COMMITMENT_DOMAIN = shortString.encodeShortString("STELA_COMMITMENT_V1");
|
|
532
|
+
var NULLIFIER_DOMAIN = shortString.encodeShortString("STELA_NULLIFIER_V1");
|
|
533
|
+
function computeCommitment(owner, inscriptionId, shares, salt) {
|
|
534
|
+
const [idLow, idHigh] = toU256(inscriptionId);
|
|
535
|
+
const [sharesLow, sharesHigh] = toU256(shares);
|
|
536
|
+
return hash.computePoseidonHashOnElements([
|
|
537
|
+
COMMITMENT_DOMAIN,
|
|
538
|
+
owner,
|
|
539
|
+
idLow,
|
|
540
|
+
idHigh,
|
|
541
|
+
sharesLow,
|
|
542
|
+
sharesHigh,
|
|
543
|
+
salt
|
|
544
|
+
]);
|
|
545
|
+
}
|
|
546
|
+
function computeNullifier(commitment, ownerSecret) {
|
|
547
|
+
return hash.computePoseidonHashOnElements([NULLIFIER_DOMAIN, commitment, ownerSecret]);
|
|
548
|
+
}
|
|
549
|
+
function hashPair(left, right) {
|
|
550
|
+
return hash.computePoseidonHashOnElements([left, right]);
|
|
551
|
+
}
|
|
552
|
+
function generateSalt() {
|
|
553
|
+
const bytes = new Uint8Array(31);
|
|
554
|
+
crypto.getRandomValues(bytes);
|
|
555
|
+
return "0x" + Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
556
|
+
}
|
|
557
|
+
function createPrivateNote(owner, inscriptionId, shares, salt) {
|
|
558
|
+
const noteSalt = salt ?? generateSalt();
|
|
559
|
+
const commitment = computeCommitment(owner, inscriptionId, shares, noteSalt);
|
|
560
|
+
return {
|
|
561
|
+
owner,
|
|
562
|
+
inscriptionId,
|
|
563
|
+
shares,
|
|
564
|
+
salt: noteSalt,
|
|
565
|
+
commitment
|
|
566
|
+
};
|
|
567
|
+
}
|
|
483
568
|
|
|
484
569
|
// src/abi/stela.json
|
|
485
570
|
var stela_default = [
|
|
@@ -594,6 +679,46 @@ var stela_default = [
|
|
|
594
679
|
}
|
|
595
680
|
]
|
|
596
681
|
},
|
|
682
|
+
{
|
|
683
|
+
type: "struct",
|
|
684
|
+
name: "stela::types::private_redeem::PrivateRedeemRequest",
|
|
685
|
+
members: [
|
|
686
|
+
{
|
|
687
|
+
name: "root",
|
|
688
|
+
type: "core::felt252"
|
|
689
|
+
},
|
|
690
|
+
{
|
|
691
|
+
name: "inscription_id",
|
|
692
|
+
type: "core::integer::u256"
|
|
693
|
+
},
|
|
694
|
+
{
|
|
695
|
+
name: "shares",
|
|
696
|
+
type: "core::integer::u256"
|
|
697
|
+
},
|
|
698
|
+
{
|
|
699
|
+
name: "nullifier",
|
|
700
|
+
type: "core::felt252"
|
|
701
|
+
},
|
|
702
|
+
{
|
|
703
|
+
name: "change_commitment",
|
|
704
|
+
type: "core::felt252"
|
|
705
|
+
},
|
|
706
|
+
{
|
|
707
|
+
name: "recipient",
|
|
708
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
709
|
+
}
|
|
710
|
+
]
|
|
711
|
+
},
|
|
712
|
+
{
|
|
713
|
+
type: "struct",
|
|
714
|
+
name: "core::array::Span::<core::felt252>",
|
|
715
|
+
members: [
|
|
716
|
+
{
|
|
717
|
+
name: "snapshot",
|
|
718
|
+
type: "@core::array::Array::<core::felt252>"
|
|
719
|
+
}
|
|
720
|
+
]
|
|
721
|
+
},
|
|
597
722
|
{
|
|
598
723
|
type: "struct",
|
|
599
724
|
name: "stela::snip12::InscriptionOrder",
|
|
@@ -663,6 +788,44 @@ var stela_default = [
|
|
|
663
788
|
{
|
|
664
789
|
name: "nonce",
|
|
665
790
|
type: "core::felt252"
|
|
791
|
+
},
|
|
792
|
+
{
|
|
793
|
+
name: "lender_commitment",
|
|
794
|
+
type: "core::felt252"
|
|
795
|
+
}
|
|
796
|
+
]
|
|
797
|
+
},
|
|
798
|
+
{
|
|
799
|
+
type: "struct",
|
|
800
|
+
name: "stela::types::signed_order::SignedOrder",
|
|
801
|
+
members: [
|
|
802
|
+
{
|
|
803
|
+
name: "maker",
|
|
804
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
805
|
+
},
|
|
806
|
+
{
|
|
807
|
+
name: "allowed_taker",
|
|
808
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
809
|
+
},
|
|
810
|
+
{
|
|
811
|
+
name: "inscription_id",
|
|
812
|
+
type: "core::integer::u256"
|
|
813
|
+
},
|
|
814
|
+
{
|
|
815
|
+
name: "bps",
|
|
816
|
+
type: "core::integer::u256"
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
name: "deadline",
|
|
820
|
+
type: "core::integer::u64"
|
|
821
|
+
},
|
|
822
|
+
{
|
|
823
|
+
name: "nonce",
|
|
824
|
+
type: "core::felt252"
|
|
825
|
+
},
|
|
826
|
+
{
|
|
827
|
+
name: "min_fill_bps",
|
|
828
|
+
type: "core::integer::u256"
|
|
666
829
|
}
|
|
667
830
|
]
|
|
668
831
|
},
|
|
@@ -808,6 +971,22 @@ var stela_default = [
|
|
|
808
971
|
outputs: [],
|
|
809
972
|
state_mutability: "external"
|
|
810
973
|
},
|
|
974
|
+
{
|
|
975
|
+
type: "function",
|
|
976
|
+
name: "private_redeem",
|
|
977
|
+
inputs: [
|
|
978
|
+
{
|
|
979
|
+
name: "request",
|
|
980
|
+
type: "stela::types::private_redeem::PrivateRedeemRequest"
|
|
981
|
+
},
|
|
982
|
+
{
|
|
983
|
+
name: "proof",
|
|
984
|
+
type: "core::array::Span::<core::felt252>"
|
|
985
|
+
}
|
|
986
|
+
],
|
|
987
|
+
outputs: [],
|
|
988
|
+
state_mutability: "external"
|
|
989
|
+
},
|
|
811
990
|
{
|
|
812
991
|
type: "function",
|
|
813
992
|
name: "settle",
|
|
@@ -844,6 +1023,50 @@ var stela_default = [
|
|
|
844
1023
|
outputs: [],
|
|
845
1024
|
state_mutability: "external"
|
|
846
1025
|
},
|
|
1026
|
+
{
|
|
1027
|
+
type: "function",
|
|
1028
|
+
name: "fill_signed_order",
|
|
1029
|
+
inputs: [
|
|
1030
|
+
{
|
|
1031
|
+
name: "order",
|
|
1032
|
+
type: "stela::types::signed_order::SignedOrder"
|
|
1033
|
+
},
|
|
1034
|
+
{
|
|
1035
|
+
name: "signature",
|
|
1036
|
+
type: "core::array::Array::<core::felt252>"
|
|
1037
|
+
},
|
|
1038
|
+
{
|
|
1039
|
+
name: "fill_bps",
|
|
1040
|
+
type: "core::integer::u256"
|
|
1041
|
+
}
|
|
1042
|
+
],
|
|
1043
|
+
outputs: [],
|
|
1044
|
+
state_mutability: "external"
|
|
1045
|
+
},
|
|
1046
|
+
{
|
|
1047
|
+
type: "function",
|
|
1048
|
+
name: "cancel_order",
|
|
1049
|
+
inputs: [
|
|
1050
|
+
{
|
|
1051
|
+
name: "order",
|
|
1052
|
+
type: "stela::types::signed_order::SignedOrder"
|
|
1053
|
+
}
|
|
1054
|
+
],
|
|
1055
|
+
outputs: [],
|
|
1056
|
+
state_mutability: "external"
|
|
1057
|
+
},
|
|
1058
|
+
{
|
|
1059
|
+
type: "function",
|
|
1060
|
+
name: "cancel_orders_by_nonce",
|
|
1061
|
+
inputs: [
|
|
1062
|
+
{
|
|
1063
|
+
name: "min_nonce",
|
|
1064
|
+
type: "core::felt252"
|
|
1065
|
+
}
|
|
1066
|
+
],
|
|
1067
|
+
outputs: [],
|
|
1068
|
+
state_mutability: "external"
|
|
1069
|
+
},
|
|
847
1070
|
{
|
|
848
1071
|
type: "function",
|
|
849
1072
|
name: "get_inscription",
|
|
@@ -956,6 +1179,81 @@ var stela_default = [
|
|
|
956
1179
|
],
|
|
957
1180
|
state_mutability: "view"
|
|
958
1181
|
},
|
|
1182
|
+
{
|
|
1183
|
+
type: "function",
|
|
1184
|
+
name: "is_order_registered",
|
|
1185
|
+
inputs: [
|
|
1186
|
+
{
|
|
1187
|
+
name: "order_hash",
|
|
1188
|
+
type: "core::felt252"
|
|
1189
|
+
}
|
|
1190
|
+
],
|
|
1191
|
+
outputs: [
|
|
1192
|
+
{
|
|
1193
|
+
type: "core::bool"
|
|
1194
|
+
}
|
|
1195
|
+
],
|
|
1196
|
+
state_mutability: "view"
|
|
1197
|
+
},
|
|
1198
|
+
{
|
|
1199
|
+
type: "function",
|
|
1200
|
+
name: "is_order_cancelled",
|
|
1201
|
+
inputs: [
|
|
1202
|
+
{
|
|
1203
|
+
name: "order_hash",
|
|
1204
|
+
type: "core::felt252"
|
|
1205
|
+
}
|
|
1206
|
+
],
|
|
1207
|
+
outputs: [
|
|
1208
|
+
{
|
|
1209
|
+
type: "core::bool"
|
|
1210
|
+
}
|
|
1211
|
+
],
|
|
1212
|
+
state_mutability: "view"
|
|
1213
|
+
},
|
|
1214
|
+
{
|
|
1215
|
+
type: "function",
|
|
1216
|
+
name: "get_filled_bps",
|
|
1217
|
+
inputs: [
|
|
1218
|
+
{
|
|
1219
|
+
name: "order_hash",
|
|
1220
|
+
type: "core::felt252"
|
|
1221
|
+
}
|
|
1222
|
+
],
|
|
1223
|
+
outputs: [
|
|
1224
|
+
{
|
|
1225
|
+
type: "core::integer::u256"
|
|
1226
|
+
}
|
|
1227
|
+
],
|
|
1228
|
+
state_mutability: "view"
|
|
1229
|
+
},
|
|
1230
|
+
{
|
|
1231
|
+
type: "function",
|
|
1232
|
+
name: "get_maker_min_nonce",
|
|
1233
|
+
inputs: [
|
|
1234
|
+
{
|
|
1235
|
+
name: "maker",
|
|
1236
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1237
|
+
}
|
|
1238
|
+
],
|
|
1239
|
+
outputs: [
|
|
1240
|
+
{
|
|
1241
|
+
type: "core::felt252"
|
|
1242
|
+
}
|
|
1243
|
+
],
|
|
1244
|
+
state_mutability: "view"
|
|
1245
|
+
},
|
|
1246
|
+
{
|
|
1247
|
+
type: "function",
|
|
1248
|
+
name: "get_privacy_pool",
|
|
1249
|
+
inputs: [],
|
|
1250
|
+
outputs: [
|
|
1251
|
+
{
|
|
1252
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1253
|
+
}
|
|
1254
|
+
],
|
|
1255
|
+
state_mutability: "view"
|
|
1256
|
+
},
|
|
959
1257
|
{
|
|
960
1258
|
type: "function",
|
|
961
1259
|
name: "set_inscription_fee",
|
|
@@ -1028,6 +1326,18 @@ var stela_default = [
|
|
|
1028
1326
|
outputs: [],
|
|
1029
1327
|
state_mutability: "external"
|
|
1030
1328
|
},
|
|
1329
|
+
{
|
|
1330
|
+
type: "function",
|
|
1331
|
+
name: "set_privacy_pool",
|
|
1332
|
+
inputs: [
|
|
1333
|
+
{
|
|
1334
|
+
name: "privacy_pool",
|
|
1335
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1336
|
+
}
|
|
1337
|
+
],
|
|
1338
|
+
outputs: [],
|
|
1339
|
+
state_mutability: "external"
|
|
1340
|
+
},
|
|
1031
1341
|
{
|
|
1032
1342
|
type: "function",
|
|
1033
1343
|
name: "pause",
|
|
@@ -1089,16 +1399,6 @@ var stela_default = [
|
|
|
1089
1399
|
}
|
|
1090
1400
|
]
|
|
1091
1401
|
},
|
|
1092
|
-
{
|
|
1093
|
-
type: "struct",
|
|
1094
|
-
name: "core::array::Span::<core::felt252>",
|
|
1095
|
-
members: [
|
|
1096
|
-
{
|
|
1097
|
-
name: "snapshot",
|
|
1098
|
-
type: "@core::array::Array::<core::felt252>"
|
|
1099
|
-
}
|
|
1100
|
-
]
|
|
1101
|
-
},
|
|
1102
1402
|
{
|
|
1103
1403
|
type: "struct",
|
|
1104
1404
|
name: "core::byte_array::ByteArray",
|
|
@@ -1900,6 +2200,121 @@ var stela_default = [
|
|
|
1900
2200
|
}
|
|
1901
2201
|
]
|
|
1902
2202
|
},
|
|
2203
|
+
{
|
|
2204
|
+
type: "event",
|
|
2205
|
+
name: "stela::stela::StelaProtocol::OrderFilled",
|
|
2206
|
+
kind: "struct",
|
|
2207
|
+
members: [
|
|
2208
|
+
{
|
|
2209
|
+
name: "inscription_id",
|
|
2210
|
+
type: "core::integer::u256",
|
|
2211
|
+
kind: "key"
|
|
2212
|
+
},
|
|
2213
|
+
{
|
|
2214
|
+
name: "order_hash",
|
|
2215
|
+
type: "core::felt252",
|
|
2216
|
+
kind: "key"
|
|
2217
|
+
},
|
|
2218
|
+
{
|
|
2219
|
+
name: "taker",
|
|
2220
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
2221
|
+
kind: "key"
|
|
2222
|
+
},
|
|
2223
|
+
{
|
|
2224
|
+
name: "fill_bps",
|
|
2225
|
+
type: "core::integer::u256",
|
|
2226
|
+
kind: "data"
|
|
2227
|
+
},
|
|
2228
|
+
{
|
|
2229
|
+
name: "total_filled_bps",
|
|
2230
|
+
type: "core::integer::u256",
|
|
2231
|
+
kind: "data"
|
|
2232
|
+
}
|
|
2233
|
+
]
|
|
2234
|
+
},
|
|
2235
|
+
{
|
|
2236
|
+
type: "event",
|
|
2237
|
+
name: "stela::stela::StelaProtocol::OrderCancelled",
|
|
2238
|
+
kind: "struct",
|
|
2239
|
+
members: [
|
|
2240
|
+
{
|
|
2241
|
+
name: "order_hash",
|
|
2242
|
+
type: "core::felt252",
|
|
2243
|
+
kind: "key"
|
|
2244
|
+
},
|
|
2245
|
+
{
|
|
2246
|
+
name: "maker",
|
|
2247
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
2248
|
+
kind: "data"
|
|
2249
|
+
}
|
|
2250
|
+
]
|
|
2251
|
+
},
|
|
2252
|
+
{
|
|
2253
|
+
type: "event",
|
|
2254
|
+
name: "stela::stela::StelaProtocol::OrdersBulkCancelled",
|
|
2255
|
+
kind: "struct",
|
|
2256
|
+
members: [
|
|
2257
|
+
{
|
|
2258
|
+
name: "maker",
|
|
2259
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
2260
|
+
kind: "key"
|
|
2261
|
+
},
|
|
2262
|
+
{
|
|
2263
|
+
name: "new_min_nonce",
|
|
2264
|
+
type: "core::felt252",
|
|
2265
|
+
kind: "data"
|
|
2266
|
+
}
|
|
2267
|
+
]
|
|
2268
|
+
},
|
|
2269
|
+
{
|
|
2270
|
+
type: "event",
|
|
2271
|
+
name: "stela::stela::StelaProtocol::PrivateSettled",
|
|
2272
|
+
kind: "struct",
|
|
2273
|
+
members: [
|
|
2274
|
+
{
|
|
2275
|
+
name: "inscription_id",
|
|
2276
|
+
type: "core::integer::u256",
|
|
2277
|
+
kind: "key"
|
|
2278
|
+
},
|
|
2279
|
+
{
|
|
2280
|
+
name: "lender_commitment",
|
|
2281
|
+
type: "core::felt252",
|
|
2282
|
+
kind: "key"
|
|
2283
|
+
},
|
|
2284
|
+
{
|
|
2285
|
+
name: "shares_committed",
|
|
2286
|
+
type: "core::integer::u256",
|
|
2287
|
+
kind: "data"
|
|
2288
|
+
}
|
|
2289
|
+
]
|
|
2290
|
+
},
|
|
2291
|
+
{
|
|
2292
|
+
type: "event",
|
|
2293
|
+
name: "stela::stela::StelaProtocol::PrivateSharesRedeemed",
|
|
2294
|
+
kind: "struct",
|
|
2295
|
+
members: [
|
|
2296
|
+
{
|
|
2297
|
+
name: "inscription_id",
|
|
2298
|
+
type: "core::integer::u256",
|
|
2299
|
+
kind: "key"
|
|
2300
|
+
},
|
|
2301
|
+
{
|
|
2302
|
+
name: "nullifier",
|
|
2303
|
+
type: "core::felt252",
|
|
2304
|
+
kind: "key"
|
|
2305
|
+
},
|
|
2306
|
+
{
|
|
2307
|
+
name: "shares",
|
|
2308
|
+
type: "core::integer::u256",
|
|
2309
|
+
kind: "data"
|
|
2310
|
+
},
|
|
2311
|
+
{
|
|
2312
|
+
name: "recipient",
|
|
2313
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
2314
|
+
kind: "data"
|
|
2315
|
+
}
|
|
2316
|
+
]
|
|
2317
|
+
},
|
|
1903
2318
|
{
|
|
1904
2319
|
type: "event",
|
|
1905
2320
|
name: "stela::stela::StelaProtocol::Event",
|
|
@@ -1969,6 +2384,31 @@ var stela_default = [
|
|
|
1969
2384
|
name: "OrderSettled",
|
|
1970
2385
|
type: "stela::stela::StelaProtocol::OrderSettled",
|
|
1971
2386
|
kind: "nested"
|
|
2387
|
+
},
|
|
2388
|
+
{
|
|
2389
|
+
name: "OrderFilled",
|
|
2390
|
+
type: "stela::stela::StelaProtocol::OrderFilled",
|
|
2391
|
+
kind: "nested"
|
|
2392
|
+
},
|
|
2393
|
+
{
|
|
2394
|
+
name: "OrderCancelled",
|
|
2395
|
+
type: "stela::stela::StelaProtocol::OrderCancelled",
|
|
2396
|
+
kind: "nested"
|
|
2397
|
+
},
|
|
2398
|
+
{
|
|
2399
|
+
name: "OrdersBulkCancelled",
|
|
2400
|
+
type: "stela::stela::StelaProtocol::OrdersBulkCancelled",
|
|
2401
|
+
kind: "nested"
|
|
2402
|
+
},
|
|
2403
|
+
{
|
|
2404
|
+
name: "PrivateSettled",
|
|
2405
|
+
type: "stela::stela::StelaProtocol::PrivateSettled",
|
|
2406
|
+
kind: "nested"
|
|
2407
|
+
},
|
|
2408
|
+
{
|
|
2409
|
+
name: "PrivateSharesRedeemed",
|
|
2410
|
+
type: "stela::stela::StelaProtocol::PrivateSharesRedeemed",
|
|
2411
|
+
kind: "nested"
|
|
1972
2412
|
}
|
|
1973
2413
|
]
|
|
1974
2414
|
}
|
|
@@ -2012,6 +2452,30 @@ var InscriptionClient = class {
|
|
|
2012
2452
|
const result = await this.contract.call("get_relayer_fee");
|
|
2013
2453
|
return extractU256(result);
|
|
2014
2454
|
}
|
|
2455
|
+
async getTreasury() {
|
|
2456
|
+
const result = await this.contract.call("get_treasury");
|
|
2457
|
+
return String(result[0]);
|
|
2458
|
+
}
|
|
2459
|
+
async isPaused() {
|
|
2460
|
+
const result = await this.contract.call("is_paused");
|
|
2461
|
+
return Boolean(result[0]);
|
|
2462
|
+
}
|
|
2463
|
+
async isOrderRegistered(orderHash) {
|
|
2464
|
+
const result = await this.contract.call("is_order_registered", [orderHash]);
|
|
2465
|
+
return Boolean(result[0]);
|
|
2466
|
+
}
|
|
2467
|
+
async isOrderCancelled(orderHash) {
|
|
2468
|
+
const result = await this.contract.call("is_order_cancelled", [orderHash]);
|
|
2469
|
+
return Boolean(result[0]);
|
|
2470
|
+
}
|
|
2471
|
+
async getFilledBps(orderHash) {
|
|
2472
|
+
const result = await this.contract.call("get_filled_bps", [orderHash]);
|
|
2473
|
+
return extractU256(result);
|
|
2474
|
+
}
|
|
2475
|
+
async getMakerMinNonce(maker) {
|
|
2476
|
+
const result = await this.contract.call("get_maker_min_nonce", [maker]);
|
|
2477
|
+
return String(result[0] ?? "0");
|
|
2478
|
+
}
|
|
2015
2479
|
// ── Call Builders ──────────────────────────────────────────────────
|
|
2016
2480
|
buildCreateInscription(params) {
|
|
2017
2481
|
const calldata = [
|
|
@@ -2060,6 +2524,21 @@ var InscriptionClient = class {
|
|
|
2060
2524
|
calldata: [...toU256(inscriptionId), ...toU256(shares)]
|
|
2061
2525
|
};
|
|
2062
2526
|
}
|
|
2527
|
+
buildPrivateRedeem(request, proof) {
|
|
2528
|
+
const calldata = [
|
|
2529
|
+
// PrivateRedeemRequest struct fields (must match Cairo Serde order)
|
|
2530
|
+
request.root,
|
|
2531
|
+
...toU256(request.inscriptionId),
|
|
2532
|
+
...toU256(request.shares),
|
|
2533
|
+
request.nullifier,
|
|
2534
|
+
request.changeCommitment,
|
|
2535
|
+
request.recipient,
|
|
2536
|
+
// proof array
|
|
2537
|
+
String(proof.length),
|
|
2538
|
+
...proof
|
|
2539
|
+
];
|
|
2540
|
+
return { contractAddress: this.address, entrypoint: "private_redeem", calldata };
|
|
2541
|
+
}
|
|
2063
2542
|
buildSettle(params) {
|
|
2064
2543
|
const calldata = [
|
|
2065
2544
|
// Order struct fields
|
|
@@ -2088,12 +2567,50 @@ var InscriptionClient = class {
|
|
|
2088
2567
|
params.offer.lender,
|
|
2089
2568
|
...toU256(params.offer.issuedDebtPercentage),
|
|
2090
2569
|
params.offer.nonce.toString(),
|
|
2570
|
+
params.offer.lenderCommitment ?? "0",
|
|
2091
2571
|
// lender_sig array
|
|
2092
2572
|
String(params.lenderSig.length),
|
|
2093
2573
|
...params.lenderSig
|
|
2094
2574
|
];
|
|
2095
2575
|
return { contractAddress: this.address, entrypoint: "settle", calldata };
|
|
2096
2576
|
}
|
|
2577
|
+
buildFillSignedOrder(order, signature, fillBps) {
|
|
2578
|
+
const calldata = [
|
|
2579
|
+
// SignedOrder struct fields
|
|
2580
|
+
order.maker,
|
|
2581
|
+
order.allowed_taker,
|
|
2582
|
+
...toU256(order.inscription_id),
|
|
2583
|
+
...toU256(order.bps),
|
|
2584
|
+
order.deadline.toString(),
|
|
2585
|
+
order.nonce,
|
|
2586
|
+
...toU256(order.min_fill_bps),
|
|
2587
|
+
// signature array
|
|
2588
|
+
String(signature.length),
|
|
2589
|
+
...signature,
|
|
2590
|
+
// fill_bps
|
|
2591
|
+
...toU256(fillBps)
|
|
2592
|
+
];
|
|
2593
|
+
return { contractAddress: this.address, entrypoint: "fill_signed_order", calldata };
|
|
2594
|
+
}
|
|
2595
|
+
buildCancelOrder(order) {
|
|
2596
|
+
const calldata = [
|
|
2597
|
+
order.maker,
|
|
2598
|
+
order.allowed_taker,
|
|
2599
|
+
...toU256(order.inscription_id),
|
|
2600
|
+
...toU256(order.bps),
|
|
2601
|
+
order.deadline.toString(),
|
|
2602
|
+
order.nonce,
|
|
2603
|
+
...toU256(order.min_fill_bps)
|
|
2604
|
+
];
|
|
2605
|
+
return { contractAddress: this.address, entrypoint: "cancel_order", calldata };
|
|
2606
|
+
}
|
|
2607
|
+
buildCancelOrdersByNonce(minNonce) {
|
|
2608
|
+
return {
|
|
2609
|
+
contractAddress: this.address,
|
|
2610
|
+
entrypoint: "cancel_orders_by_nonce",
|
|
2611
|
+
calldata: [minNonce]
|
|
2612
|
+
};
|
|
2613
|
+
}
|
|
2097
2614
|
// ── Execute Methods ────────────────────────────────────────────────
|
|
2098
2615
|
/**
|
|
2099
2616
|
* Execute one or more calls via the connected account.
|
|
@@ -2125,6 +2642,19 @@ var InscriptionClient = class {
|
|
|
2125
2642
|
async redeem(inscriptionId, shares) {
|
|
2126
2643
|
return this.execute([this.buildRedeem(inscriptionId, shares)]);
|
|
2127
2644
|
}
|
|
2645
|
+
async privateRedeem(request, proof) {
|
|
2646
|
+
return this.execute([this.buildPrivateRedeem(request, proof)]);
|
|
2647
|
+
}
|
|
2648
|
+
async fillSignedOrder(order, signature, fillBps, approvals) {
|
|
2649
|
+
const calls = [...approvals ?? [], this.buildFillSignedOrder(order, signature, fillBps)];
|
|
2650
|
+
return this.execute(calls);
|
|
2651
|
+
}
|
|
2652
|
+
async cancelOrder(order) {
|
|
2653
|
+
return this.execute([this.buildCancelOrder(order)]);
|
|
2654
|
+
}
|
|
2655
|
+
async cancelOrdersByNonce(minNonce) {
|
|
2656
|
+
return this.execute([this.buildCancelOrdersByNonce(minNonce)]);
|
|
2657
|
+
}
|
|
2128
2658
|
};
|
|
2129
2659
|
function serializeAssets(assets) {
|
|
2130
2660
|
const calldata = [String(assets.length)];
|
|
@@ -2493,6 +3023,6 @@ var StelaSdk = class {
|
|
|
2493
3023
|
}
|
|
2494
3024
|
};
|
|
2495
3025
|
|
|
2496
|
-
export { ASSET_TYPE_ENUM, ASSET_TYPE_NAMES, ApiClient, ApiError, InscriptionClient, LockerClient, MAX_BPS, SELECTORS, STATUS_LABELS, STELA_ADDRESS, ShareClient, StelaSdk, TOKENS, VALID_STATUSES, VIRTUAL_SHARE_OFFSET, addressesEqual, calculateFeeShares, computeStatus, convertToShares, deserializeSignature, findTokenByAddress, formatAddress, formatDuration, formatTimestamp, formatTokenValue, fromU256, getInscriptionOrderTypedData, getLendOfferTypedData, getTokensForNetwork, hashAssets, inscriptionIdToHex, normalizeAddress, parseAmount, parseEvent, parseEvents, resolveNetwork, scaleByPercentage, serializeSignature, sharesToPercentage, toHex, toU256 };
|
|
3026
|
+
export { ASSET_TYPE_ENUM, ASSET_TYPE_NAMES, ApiClient, ApiError, InscriptionClient, LockerClient, MAX_BPS, SELECTORS, STATUS_LABELS, STELA_ADDRESS, ShareClient, StelaSdk, TOKENS, VALID_STATUSES, VIRTUAL_SHARE_OFFSET, addressesEqual, calculateFeeShares, computeCommitment, computeNullifier, computeStatus, convertToShares, createPrivateNote, deserializeSignature, findTokenByAddress, formatAddress, formatDuration, formatTimestamp, formatTokenValue, fromU256, generateSalt, getInscriptionOrderTypedData, getLendOfferTypedData, getTokensForNetwork, hashAssets, hashPair, inscriptionIdToHex, normalizeAddress, parseAmount, parseEvent, parseEvents, resolveNetwork, scaleByPercentage, serializeSignature, sharesToPercentage, toHex, toU256 };
|
|
2497
3027
|
//# sourceMappingURL=index.js.map
|
|
2498
3028
|
//# sourceMappingURL=index.js.map
|