@fepvenancio/stela-sdk 0.4.3 → 0.5.1
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 +29 -52
- package/dist/index.cjs +46 -265
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -158
- package/dist/index.d.ts +2 -158
- package/dist/index.js +48 -260
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/abi/stela.json +44 -145
package/README.md
CHANGED
|
@@ -117,7 +117,6 @@ Return a `Call` object for use with `account.execute()`. Bundle multiple calls (
|
|
|
117
117
|
| `buildRepay(id)` | Repay a filled inscription |
|
|
118
118
|
| `buildLiquidate(id)` | Liquidate an expired inscription |
|
|
119
119
|
| `buildRedeem(id, shares)` | Redeem shares for underlying assets |
|
|
120
|
-
| `buildPrivateRedeem(request, proof)` | Redeem shares via the privacy pool with a ZK proof |
|
|
121
120
|
| `buildSettle(params)` | Settle an off-chain order (used by relayer bots) |
|
|
122
121
|
| `buildFillSignedOrder(order, sig, fillBps)` | Fill a signed order on-chain |
|
|
123
122
|
| `buildCancelOrder(order)` | Cancel a specific signed order |
|
|
@@ -136,7 +135,6 @@ Convenience wrappers that call `account.execute()` directly. Accept optional `ap
|
|
|
136
135
|
| `repay(id, approvals?)` | Repay a loan |
|
|
137
136
|
| `liquidate(id)` | Liquidate an expired loan |
|
|
138
137
|
| `redeem(id, shares)` | Redeem ERC1155 shares |
|
|
139
|
-
| `privateRedeem(request, proof)` | Redeem via privacy pool |
|
|
140
138
|
| `fillSignedOrder(order, sig, fillBps, approvals?)` | Fill a signed order |
|
|
141
139
|
| `cancelOrder(order)` | Cancel a signed order |
|
|
142
140
|
| `cancelOrdersByNonce(minNonce)` | Bulk cancel by nonce |
|
|
@@ -208,58 +206,13 @@ import {
|
|
|
208
206
|
| Function | Description |
|
|
209
207
|
|----------|-------------|
|
|
210
208
|
| `getInscriptionOrderTypedData(params)` | Build SNIP-12 typed data for a borrower's InscriptionOrder |
|
|
211
|
-
| `getLendOfferTypedData(params)` | Build SNIP-12 typed data for a lender's LendOffer
|
|
209
|
+
| `getLendOfferTypedData(params)` | Build SNIP-12 typed data for a lender's LendOffer |
|
|
212
210
|
| `hashAssets(assets)` | Poseidon hash of an asset array (matches Cairo's `hash_assets()`) |
|
|
213
211
|
| `serializeSignature(sig)` | Convert `string[]` signature to `{ r, s }` for storage |
|
|
214
212
|
| `deserializeSignature(stored)` | Convert `{ r, s }` back to `string[]` |
|
|
215
213
|
|
|
216
214
|
---
|
|
217
215
|
|
|
218
|
-
### Privacy Utilities
|
|
219
|
-
|
|
220
|
-
Functions for the privacy pool (shielded share commitments via Poseidon hashing).
|
|
221
|
-
|
|
222
|
-
```typescript
|
|
223
|
-
import {
|
|
224
|
-
createPrivateNote,
|
|
225
|
-
computeCommitment,
|
|
226
|
-
computeNullifier,
|
|
227
|
-
hashPair,
|
|
228
|
-
generateSalt,
|
|
229
|
-
} from '@fepvenancio/stela-sdk'
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
| Function | Returns | Description |
|
|
233
|
-
|----------|---------|-------------|
|
|
234
|
-
| `createPrivateNote(owner, inscriptionId, shares, salt?)` | `PrivateNote` | Generate a full private note (auto-generates salt if omitted) |
|
|
235
|
-
| `computeCommitment(owner, inscriptionId, shares, salt)` | `string` | Compute a Poseidon commitment hash |
|
|
236
|
-
| `computeNullifier(commitment, ownerSecret)` | `string` | Derive a nullifier from a commitment |
|
|
237
|
-
| `hashPair(left, right)` | `string` | Poseidon hash of two children (Merkle tree nodes) |
|
|
238
|
-
| `generateSalt()` | `string` | Random felt252 salt for commitment uniqueness |
|
|
239
|
-
|
|
240
|
-
#### Types
|
|
241
|
-
|
|
242
|
-
```typescript
|
|
243
|
-
interface PrivateNote {
|
|
244
|
-
owner: string
|
|
245
|
-
inscriptionId: bigint
|
|
246
|
-
shares: bigint
|
|
247
|
-
salt: string
|
|
248
|
-
commitment: string
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
interface PrivateRedeemRequest {
|
|
252
|
-
root: string // Merkle root the proof was generated against
|
|
253
|
-
inscriptionId: bigint
|
|
254
|
-
shares: bigint
|
|
255
|
-
nullifier: string // Prevents double-spend
|
|
256
|
-
changeCommitment: string // For partial redemption ('0' if full)
|
|
257
|
-
recipient: string
|
|
258
|
-
}
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
---
|
|
262
|
-
|
|
263
216
|
### Math Utilities
|
|
264
217
|
|
|
265
218
|
Share calculation helpers that mirror the on-chain math.
|
|
@@ -296,7 +249,7 @@ import { parseEvent, parseEvents, SELECTORS } from '@fepvenancio/stela-sdk'
|
|
|
296
249
|
| `parseEvent(raw)` | Parse a single raw event into a typed `StelaEvent` |
|
|
297
250
|
| `parseEvents(raws)` | Parse an array of raw events |
|
|
298
251
|
|
|
299
|
-
Supported event types: `InscriptionCreated`, `InscriptionSigned`, `InscriptionCancelled`, `InscriptionRepaid`, `InscriptionLiquidated`, `SharesRedeemed`, `TransferSingle`, `OrderSettled`, `OrderFilled`, `OrderCancelled`, `OrdersBulkCancelled
|
|
252
|
+
Supported event types: `InscriptionCreated`, `InscriptionSigned`, `InscriptionCancelled`, `InscriptionRepaid`, `InscriptionLiquidated`, `SharesRedeemed`, `TransferSingle`, `OrderSettled`, `OrderFilled`, `OrderCancelled`, `OrdersBulkCancelled`.
|
|
300
253
|
|
|
301
254
|
---
|
|
302
255
|
|
|
@@ -369,12 +322,28 @@ All exported types from the SDK:
|
|
|
369
322
|
| `LockerInfo` | Locker information from the API |
|
|
370
323
|
| `LockerState` | Locker address + unlock status |
|
|
371
324
|
| `LockerCall` | Call to execute through a locker |
|
|
325
|
+
| `RawEvent` | Raw StarkNet event (keys, data, tx_hash, block) |
|
|
372
326
|
| `StelaEvent` | Discriminated union of all protocol events |
|
|
373
|
-
| `
|
|
374
|
-
| `
|
|
327
|
+
| `InscriptionCreatedEvent` | InscriptionCreated event type |
|
|
328
|
+
| `InscriptionSignedEvent` | InscriptionSigned event type |
|
|
329
|
+
| `InscriptionCancelledEvent` | InscriptionCancelled event type |
|
|
330
|
+
| `InscriptionRepaidEvent` | InscriptionRepaid event type |
|
|
331
|
+
| `InscriptionLiquidatedEvent` | InscriptionLiquidated event type |
|
|
332
|
+
| `SharesRedeemedEvent` | SharesRedeemed event type |
|
|
333
|
+
| `TransferSingleEvent` | ERC1155 TransferSingle event type |
|
|
334
|
+
| `OrderSettledEvent` | OrderSettled event type |
|
|
335
|
+
| `OrderFilledEvent` | OrderFilled event type |
|
|
336
|
+
| `OrderCancelledEvent` | OrderCancelled event type |
|
|
337
|
+
| `OrdersBulkCancelledEvent` | OrdersBulkCancelled event type |
|
|
375
338
|
| `TokenInfo` | Token metadata (symbol, name, decimals, addresses) |
|
|
376
339
|
| `StatusInput` | Input for `computeStatus()` |
|
|
377
340
|
| `StoredSignature` | Serialized signature for storage (`{ r, s }`) |
|
|
341
|
+
| `InscriptionClientOptions` | Options for InscriptionClient constructor |
|
|
342
|
+
| `ShareClientOptions` | Options for ShareClient constructor |
|
|
343
|
+
| `ApiClientOptions` | Options for ApiClient constructor |
|
|
344
|
+
| `ListInscriptionsParams` | Parameters for `listInscriptions()` |
|
|
345
|
+
| `InscriptionEventRow` | API response row for inscription events |
|
|
346
|
+
| `StelaSdkOptions` | Options for StelaSdk constructor |
|
|
378
347
|
|
|
379
348
|
---
|
|
380
349
|
|
|
@@ -384,6 +353,8 @@ All exported types from the SDK:
|
|
|
384
353
|
|--------|-------------|
|
|
385
354
|
| `STELA_ADDRESS` | Contract addresses per network (`{ sepolia, mainnet }`) |
|
|
386
355
|
| `resolveNetwork(raw?)` | Validate/default network string |
|
|
356
|
+
| `CHAIN_ID` | SNIP-12 chain ID shortstrings per network (`{ sepolia: 'SN_SEPOLIA', mainnet: 'SN_MAIN' }`) |
|
|
357
|
+
| `EXPLORER_TX_URL` | Block explorer base URLs per network (for transaction links) |
|
|
387
358
|
| `MAX_BPS` | `10_000n` (100% in basis points) |
|
|
388
359
|
| `VIRTUAL_SHARE_OFFSET` | `1e16n` (share calculation offset) |
|
|
389
360
|
| `ASSET_TYPE_ENUM` | AssetType to numeric enum mapping |
|
|
@@ -391,13 +362,19 @@ All exported types from the SDK:
|
|
|
391
362
|
| `VALID_STATUSES` | Array of all valid inscription statuses |
|
|
392
363
|
| `STATUS_LABELS` | Human-readable status labels |
|
|
393
364
|
|
|
365
|
+
### Classes
|
|
366
|
+
|
|
367
|
+
| Export | Description |
|
|
368
|
+
|--------|-------------|
|
|
369
|
+
| `ApiError` | Error class thrown by ApiClient on HTTP failures |
|
|
370
|
+
|
|
394
371
|
### ABIs
|
|
395
372
|
|
|
396
373
|
The package ships raw ABI JSON files in `src/abi/`:
|
|
397
374
|
|
|
398
375
|
| File | Contents |
|
|
399
376
|
|------|----------|
|
|
400
|
-
| `src/abi/stela.json` | Full Stela protocol ABI (IStelaProtocol + ERC1155 + Ownable
|
|
377
|
+
| `src/abi/stela.json` | Full Stela protocol ABI (IStelaProtocol + ERC1155 + Ownable) |
|
|
401
378
|
| `src/abi/erc20.json` | Minimal ERC20 ABI (approve, balanceOf, allowance) |
|
|
402
379
|
| `src/abi/locker.json` | Locker account ABI (__execute__, is_unlocked) |
|
|
403
380
|
|
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: "0x042f27b5cf82781d8fffd7daeec9184ac4f14c9e86e87b880bd81ef5197345ed",
|
|
28
28
|
mainnet: "0x0"
|
|
29
29
|
};
|
|
30
30
|
var VALID_NETWORKS = ["sepolia", "mainnet"];
|
|
@@ -492,16 +492,6 @@ function getInscriptionOrderTypedData(params) {
|
|
|
492
492
|
}
|
|
493
493
|
};
|
|
494
494
|
}
|
|
495
|
-
function getPrivateLendOfferTypedData(params) {
|
|
496
|
-
return getLendOfferTypedData({
|
|
497
|
-
orderHash: params.orderHash,
|
|
498
|
-
lender: "0x0",
|
|
499
|
-
issuedDebtPercentage: params.issuedDebtPercentage,
|
|
500
|
-
nonce: params.nonce,
|
|
501
|
-
chainId: params.chainId,
|
|
502
|
-
lenderCommitment: params.depositCommitment
|
|
503
|
-
});
|
|
504
|
-
}
|
|
505
495
|
function getLendOfferTypedData(params) {
|
|
506
496
|
return {
|
|
507
497
|
types: {
|
|
@@ -515,8 +505,7 @@ function getLendOfferTypedData(params) {
|
|
|
515
505
|
{ name: "order_hash", type: "felt" },
|
|
516
506
|
{ name: "lender", type: "ContractAddress" },
|
|
517
507
|
{ name: "issued_debt_percentage", type: "u256" },
|
|
518
|
-
{ name: "nonce", type: "felt" }
|
|
519
|
-
{ name: "lender_commitment", type: "felt" }
|
|
508
|
+
{ name: "nonce", type: "felt" }
|
|
520
509
|
],
|
|
521
510
|
u256: [
|
|
522
511
|
{ name: "low", type: "u128" },
|
|
@@ -535,8 +524,7 @@ function getLendOfferTypedData(params) {
|
|
|
535
524
|
low: (params.issuedDebtPercentage & (1n << 128n) - 1n).toString(),
|
|
536
525
|
high: (params.issuedDebtPercentage >> 128n).toString()
|
|
537
526
|
},
|
|
538
|
-
nonce: params.nonce.toString()
|
|
539
|
-
lender_commitment: params.lenderCommitment ?? "0"
|
|
527
|
+
nonce: params.nonce.toString()
|
|
540
528
|
}
|
|
541
529
|
};
|
|
542
530
|
}
|
|
@@ -548,54 +536,6 @@ function serializeSignature(sig) {
|
|
|
548
536
|
function deserializeSignature(stored) {
|
|
549
537
|
return [stored.r, stored.s];
|
|
550
538
|
}
|
|
551
|
-
var COMMITMENT_DOMAIN = starknet.shortString.encodeShortString("STELA_COMMITMENT_V1");
|
|
552
|
-
var NULLIFIER_DOMAIN = starknet.shortString.encodeShortString("STELA_NULLIFIER_V1");
|
|
553
|
-
function computeCommitment(owner, inscriptionId, shares, salt) {
|
|
554
|
-
const [idLow, idHigh] = toU256(inscriptionId);
|
|
555
|
-
const [sharesLow, sharesHigh] = toU256(shares);
|
|
556
|
-
return starknet.hash.computePoseidonHashOnElements([
|
|
557
|
-
COMMITMENT_DOMAIN,
|
|
558
|
-
owner,
|
|
559
|
-
idLow,
|
|
560
|
-
idHigh,
|
|
561
|
-
sharesLow,
|
|
562
|
-
sharesHigh,
|
|
563
|
-
salt
|
|
564
|
-
]);
|
|
565
|
-
}
|
|
566
|
-
function computeNullifier(commitment, ownerSecret) {
|
|
567
|
-
return starknet.hash.computePoseidonHashOnElements([NULLIFIER_DOMAIN, commitment, ownerSecret]);
|
|
568
|
-
}
|
|
569
|
-
function hashPair(left, right) {
|
|
570
|
-
return starknet.hash.computePoseidonHashOnElements([left, right]);
|
|
571
|
-
}
|
|
572
|
-
function generateSalt() {
|
|
573
|
-
const bytes = new Uint8Array(31);
|
|
574
|
-
crypto.getRandomValues(bytes);
|
|
575
|
-
return "0x" + Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
576
|
-
}
|
|
577
|
-
function computeDepositCommitment(depositor, token, amount, salt) {
|
|
578
|
-
const [amountLow, amountHigh] = toU256(amount);
|
|
579
|
-
return starknet.hash.computePoseidonHashOnElements([
|
|
580
|
-
COMMITMENT_DOMAIN,
|
|
581
|
-
depositor,
|
|
582
|
-
token,
|
|
583
|
-
amountLow,
|
|
584
|
-
amountHigh,
|
|
585
|
-
"0x" + salt.toString(16)
|
|
586
|
-
]);
|
|
587
|
-
}
|
|
588
|
-
function createPrivateNote(owner, inscriptionId, shares, salt) {
|
|
589
|
-
const noteSalt = salt ?? generateSalt();
|
|
590
|
-
const commitment = computeCommitment(owner, inscriptionId, shares, noteSalt);
|
|
591
|
-
return {
|
|
592
|
-
owner,
|
|
593
|
-
inscriptionId,
|
|
594
|
-
shares,
|
|
595
|
-
salt: noteSalt,
|
|
596
|
-
commitment
|
|
597
|
-
};
|
|
598
|
-
}
|
|
599
539
|
|
|
600
540
|
// src/abi/stela.json
|
|
601
541
|
var stela_default = [
|
|
@@ -710,46 +650,6 @@ var stela_default = [
|
|
|
710
650
|
}
|
|
711
651
|
]
|
|
712
652
|
},
|
|
713
|
-
{
|
|
714
|
-
type: "struct",
|
|
715
|
-
name: "stela::types::private_redeem::PrivateRedeemRequest",
|
|
716
|
-
members: [
|
|
717
|
-
{
|
|
718
|
-
name: "root",
|
|
719
|
-
type: "core::felt252"
|
|
720
|
-
},
|
|
721
|
-
{
|
|
722
|
-
name: "inscription_id",
|
|
723
|
-
type: "core::integer::u256"
|
|
724
|
-
},
|
|
725
|
-
{
|
|
726
|
-
name: "shares",
|
|
727
|
-
type: "core::integer::u256"
|
|
728
|
-
},
|
|
729
|
-
{
|
|
730
|
-
name: "nullifier",
|
|
731
|
-
type: "core::felt252"
|
|
732
|
-
},
|
|
733
|
-
{
|
|
734
|
-
name: "change_commitment",
|
|
735
|
-
type: "core::felt252"
|
|
736
|
-
},
|
|
737
|
-
{
|
|
738
|
-
name: "recipient",
|
|
739
|
-
type: "core::starknet::contract_address::ContractAddress"
|
|
740
|
-
}
|
|
741
|
-
]
|
|
742
|
-
},
|
|
743
|
-
{
|
|
744
|
-
type: "struct",
|
|
745
|
-
name: "core::array::Span::<core::felt252>",
|
|
746
|
-
members: [
|
|
747
|
-
{
|
|
748
|
-
name: "snapshot",
|
|
749
|
-
type: "@core::array::Array::<core::felt252>"
|
|
750
|
-
}
|
|
751
|
-
]
|
|
752
|
-
},
|
|
753
653
|
{
|
|
754
654
|
type: "struct",
|
|
755
655
|
name: "stela::snip12::InscriptionOrder",
|
|
@@ -819,10 +719,6 @@ var stela_default = [
|
|
|
819
719
|
{
|
|
820
720
|
name: "nonce",
|
|
821
721
|
type: "core::felt252"
|
|
822
|
-
},
|
|
823
|
-
{
|
|
824
|
-
name: "lender_commitment",
|
|
825
|
-
type: "core::felt252"
|
|
826
722
|
}
|
|
827
723
|
]
|
|
828
724
|
},
|
|
@@ -1002,22 +898,6 @@ var stela_default = [
|
|
|
1002
898
|
outputs: [],
|
|
1003
899
|
state_mutability: "external"
|
|
1004
900
|
},
|
|
1005
|
-
{
|
|
1006
|
-
type: "function",
|
|
1007
|
-
name: "private_redeem",
|
|
1008
|
-
inputs: [
|
|
1009
|
-
{
|
|
1010
|
-
name: "request",
|
|
1011
|
-
type: "stela::types::private_redeem::PrivateRedeemRequest"
|
|
1012
|
-
},
|
|
1013
|
-
{
|
|
1014
|
-
name: "proof",
|
|
1015
|
-
type: "core::array::Span::<core::felt252>"
|
|
1016
|
-
}
|
|
1017
|
-
],
|
|
1018
|
-
outputs: [],
|
|
1019
|
-
state_mutability: "external"
|
|
1020
|
-
},
|
|
1021
901
|
{
|
|
1022
902
|
type: "function",
|
|
1023
903
|
name: "settle",
|
|
@@ -1276,7 +1156,7 @@ var stela_default = [
|
|
|
1276
1156
|
},
|
|
1277
1157
|
{
|
|
1278
1158
|
type: "function",
|
|
1279
|
-
name: "
|
|
1159
|
+
name: "get_genesis_contract",
|
|
1280
1160
|
inputs: [],
|
|
1281
1161
|
outputs: [
|
|
1282
1162
|
{
|
|
@@ -1285,6 +1165,22 @@ var stela_default = [
|
|
|
1285
1165
|
],
|
|
1286
1166
|
state_mutability: "view"
|
|
1287
1167
|
},
|
|
1168
|
+
{
|
|
1169
|
+
type: "function",
|
|
1170
|
+
name: "get_volume_settled",
|
|
1171
|
+
inputs: [
|
|
1172
|
+
{
|
|
1173
|
+
name: "user",
|
|
1174
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1175
|
+
}
|
|
1176
|
+
],
|
|
1177
|
+
outputs: [
|
|
1178
|
+
{
|
|
1179
|
+
type: "core::integer::u256"
|
|
1180
|
+
}
|
|
1181
|
+
],
|
|
1182
|
+
state_mutability: "view"
|
|
1183
|
+
},
|
|
1288
1184
|
{
|
|
1289
1185
|
type: "function",
|
|
1290
1186
|
name: "set_inscription_fee",
|
|
@@ -1359,10 +1255,10 @@ var stela_default = [
|
|
|
1359
1255
|
},
|
|
1360
1256
|
{
|
|
1361
1257
|
type: "function",
|
|
1362
|
-
name: "
|
|
1258
|
+
name: "set_genesis_contract",
|
|
1363
1259
|
inputs: [
|
|
1364
1260
|
{
|
|
1365
|
-
name: "
|
|
1261
|
+
name: "genesis_contract",
|
|
1366
1262
|
type: "core::starknet::contract_address::ContractAddress"
|
|
1367
1263
|
}
|
|
1368
1264
|
],
|
|
@@ -1371,40 +1267,28 @@ var stela_default = [
|
|
|
1371
1267
|
},
|
|
1372
1268
|
{
|
|
1373
1269
|
type: "function",
|
|
1374
|
-
name: "
|
|
1375
|
-
inputs: [
|
|
1376
|
-
{
|
|
1377
|
-
name: "fee_vault",
|
|
1378
|
-
type: "core::starknet::contract_address::ContractAddress"
|
|
1379
|
-
}
|
|
1380
|
-
],
|
|
1270
|
+
name: "pause",
|
|
1271
|
+
inputs: [],
|
|
1381
1272
|
outputs: [],
|
|
1382
1273
|
state_mutability: "external"
|
|
1383
1274
|
},
|
|
1384
1275
|
{
|
|
1385
1276
|
type: "function",
|
|
1386
|
-
name: "
|
|
1387
|
-
inputs: [],
|
|
1388
|
-
outputs: [
|
|
1389
|
-
{
|
|
1390
|
-
type: "core::starknet::contract_address::ContractAddress"
|
|
1391
|
-
}
|
|
1392
|
-
],
|
|
1393
|
-
state_mutability: "view"
|
|
1394
|
-
},
|
|
1395
|
-
{
|
|
1396
|
-
type: "function",
|
|
1397
|
-
name: "pause",
|
|
1277
|
+
name: "unpause",
|
|
1398
1278
|
inputs: [],
|
|
1399
1279
|
outputs: [],
|
|
1400
1280
|
state_mutability: "external"
|
|
1401
1281
|
},
|
|
1402
1282
|
{
|
|
1403
1283
|
type: "function",
|
|
1404
|
-
name: "
|
|
1284
|
+
name: "get_pauser",
|
|
1405
1285
|
inputs: [],
|
|
1406
|
-
outputs: [
|
|
1407
|
-
|
|
1286
|
+
outputs: [
|
|
1287
|
+
{
|
|
1288
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1289
|
+
}
|
|
1290
|
+
],
|
|
1291
|
+
state_mutability: "view"
|
|
1408
1292
|
},
|
|
1409
1293
|
{
|
|
1410
1294
|
type: "function",
|
|
@@ -1453,6 +1337,16 @@ var stela_default = [
|
|
|
1453
1337
|
}
|
|
1454
1338
|
]
|
|
1455
1339
|
},
|
|
1340
|
+
{
|
|
1341
|
+
type: "struct",
|
|
1342
|
+
name: "core::array::Span::<core::felt252>",
|
|
1343
|
+
members: [
|
|
1344
|
+
{
|
|
1345
|
+
name: "snapshot",
|
|
1346
|
+
type: "@core::array::Array::<core::felt252>"
|
|
1347
|
+
}
|
|
1348
|
+
]
|
|
1349
|
+
},
|
|
1456
1350
|
{
|
|
1457
1351
|
type: "struct",
|
|
1458
1352
|
name: "core::byte_array::ByteArray",
|
|
@@ -1852,6 +1746,10 @@ var stela_default = [
|
|
|
1852
1746
|
{
|
|
1853
1747
|
name: "implementation_hash",
|
|
1854
1748
|
type: "core::felt252"
|
|
1749
|
+
},
|
|
1750
|
+
{
|
|
1751
|
+
name: "pauser",
|
|
1752
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
1855
1753
|
}
|
|
1856
1754
|
]
|
|
1857
1755
|
},
|
|
@@ -2320,55 +2218,6 @@ var stela_default = [
|
|
|
2320
2218
|
}
|
|
2321
2219
|
]
|
|
2322
2220
|
},
|
|
2323
|
-
{
|
|
2324
|
-
type: "event",
|
|
2325
|
-
name: "stela::stela::StelaProtocol::PrivateSettled",
|
|
2326
|
-
kind: "struct",
|
|
2327
|
-
members: [
|
|
2328
|
-
{
|
|
2329
|
-
name: "inscription_id",
|
|
2330
|
-
type: "core::integer::u256",
|
|
2331
|
-
kind: "key"
|
|
2332
|
-
},
|
|
2333
|
-
{
|
|
2334
|
-
name: "lender_commitment",
|
|
2335
|
-
type: "core::felt252",
|
|
2336
|
-
kind: "key"
|
|
2337
|
-
},
|
|
2338
|
-
{
|
|
2339
|
-
name: "shares_committed",
|
|
2340
|
-
type: "core::integer::u256",
|
|
2341
|
-
kind: "data"
|
|
2342
|
-
}
|
|
2343
|
-
]
|
|
2344
|
-
},
|
|
2345
|
-
{
|
|
2346
|
-
type: "event",
|
|
2347
|
-
name: "stela::stela::StelaProtocol::PrivateSharesRedeemed",
|
|
2348
|
-
kind: "struct",
|
|
2349
|
-
members: [
|
|
2350
|
-
{
|
|
2351
|
-
name: "inscription_id",
|
|
2352
|
-
type: "core::integer::u256",
|
|
2353
|
-
kind: "key"
|
|
2354
|
-
},
|
|
2355
|
-
{
|
|
2356
|
-
name: "nullifier",
|
|
2357
|
-
type: "core::felt252",
|
|
2358
|
-
kind: "key"
|
|
2359
|
-
},
|
|
2360
|
-
{
|
|
2361
|
-
name: "shares",
|
|
2362
|
-
type: "core::integer::u256",
|
|
2363
|
-
kind: "data"
|
|
2364
|
-
},
|
|
2365
|
-
{
|
|
2366
|
-
name: "recipient",
|
|
2367
|
-
type: "core::starknet::contract_address::ContractAddress",
|
|
2368
|
-
kind: "data"
|
|
2369
|
-
}
|
|
2370
|
-
]
|
|
2371
|
-
},
|
|
2372
2221
|
{
|
|
2373
2222
|
type: "event",
|
|
2374
2223
|
name: "stela::stela::StelaProtocol::Event",
|
|
@@ -2453,16 +2302,6 @@ var stela_default = [
|
|
|
2453
2302
|
name: "OrdersBulkCancelled",
|
|
2454
2303
|
type: "stela::stela::StelaProtocol::OrdersBulkCancelled",
|
|
2455
2304
|
kind: "nested"
|
|
2456
|
-
},
|
|
2457
|
-
{
|
|
2458
|
-
name: "PrivateSettled",
|
|
2459
|
-
type: "stela::stela::StelaProtocol::PrivateSettled",
|
|
2460
|
-
kind: "nested"
|
|
2461
|
-
},
|
|
2462
|
-
{
|
|
2463
|
-
name: "PrivateSharesRedeemed",
|
|
2464
|
-
type: "stela::stela::StelaProtocol::PrivateSharesRedeemed",
|
|
2465
|
-
kind: "nested"
|
|
2466
2305
|
}
|
|
2467
2306
|
]
|
|
2468
2307
|
}
|
|
@@ -2578,53 +2417,6 @@ var InscriptionClient = class {
|
|
|
2578
2417
|
calldata: [...toU256(inscriptionId), ...toU256(shares)]
|
|
2579
2418
|
};
|
|
2580
2419
|
}
|
|
2581
|
-
buildPrivateRedeem(request, proof) {
|
|
2582
|
-
const calldata = [
|
|
2583
|
-
// PrivateRedeemRequest struct fields (must match Cairo Serde order)
|
|
2584
|
-
request.root,
|
|
2585
|
-
...toU256(request.inscriptionId),
|
|
2586
|
-
...toU256(request.shares),
|
|
2587
|
-
request.nullifier,
|
|
2588
|
-
request.changeCommitment,
|
|
2589
|
-
request.recipient,
|
|
2590
|
-
// proof array
|
|
2591
|
-
String(proof.length),
|
|
2592
|
-
...proof
|
|
2593
|
-
];
|
|
2594
|
-
return { contractAddress: this.address, entrypoint: "private_redeem", calldata };
|
|
2595
|
-
}
|
|
2596
|
-
/**
|
|
2597
|
-
* Build a shield() call on the privacy pool contract.
|
|
2598
|
-
* The depositor shields tokens into the pool, creating a commitment that can
|
|
2599
|
-
* later be consumed during private settlement.
|
|
2600
|
-
*/
|
|
2601
|
-
buildShieldDeposit(params) {
|
|
2602
|
-
return {
|
|
2603
|
-
contractAddress: params.privacyPoolAddress,
|
|
2604
|
-
entrypoint: "shield",
|
|
2605
|
-
calldata: [
|
|
2606
|
-
params.token,
|
|
2607
|
-
...toU256(params.amount),
|
|
2608
|
-
params.commitment
|
|
2609
|
-
]
|
|
2610
|
-
};
|
|
2611
|
-
}
|
|
2612
|
-
/**
|
|
2613
|
-
* Build a settle() call for private settlement.
|
|
2614
|
-
*
|
|
2615
|
-
* In a private settlement, the lender is zero address and the lender_commitment
|
|
2616
|
-
* is the deposit commitment from the privacy pool. The contract skips lender
|
|
2617
|
-
* signature verification and instead consumes the deposit from the privacy pool.
|
|
2618
|
-
*/
|
|
2619
|
-
buildSettlePrivate(params) {
|
|
2620
|
-
return this.buildSettle({
|
|
2621
|
-
...params,
|
|
2622
|
-
offer: {
|
|
2623
|
-
...params.offer,
|
|
2624
|
-
lender: "0x0"
|
|
2625
|
-
}
|
|
2626
|
-
});
|
|
2627
|
-
}
|
|
2628
2420
|
buildSettle(params) {
|
|
2629
2421
|
const calldata = [
|
|
2630
2422
|
// Order struct fields
|
|
@@ -2653,7 +2445,6 @@ var InscriptionClient = class {
|
|
|
2653
2445
|
params.offer.lender,
|
|
2654
2446
|
...toU256(params.offer.issuedDebtPercentage),
|
|
2655
2447
|
params.offer.nonce.toString(),
|
|
2656
|
-
params.offer.lenderCommitment ?? "0",
|
|
2657
2448
|
// lender_sig array
|
|
2658
2449
|
String(params.lenderSig.length),
|
|
2659
2450
|
...params.lenderSig
|
|
@@ -2728,9 +2519,6 @@ var InscriptionClient = class {
|
|
|
2728
2519
|
async redeem(inscriptionId, shares) {
|
|
2729
2520
|
return this.execute([this.buildRedeem(inscriptionId, shares)]);
|
|
2730
2521
|
}
|
|
2731
|
-
async privateRedeem(request, proof) {
|
|
2732
|
-
return this.execute([this.buildPrivateRedeem(request, proof)]);
|
|
2733
|
-
}
|
|
2734
2522
|
async fillSignedOrder(order, signature, fillBps, approvals) {
|
|
2735
2523
|
const calls = [...approvals ?? [], this.buildFillSignedOrder(order, signature, fillBps)];
|
|
2736
2524
|
return this.execute(calls);
|
|
@@ -3129,12 +2917,8 @@ exports.VALID_STATUSES = VALID_STATUSES;
|
|
|
3129
2917
|
exports.VIRTUAL_SHARE_OFFSET = VIRTUAL_SHARE_OFFSET;
|
|
3130
2918
|
exports.addressesEqual = addressesEqual;
|
|
3131
2919
|
exports.calculateFeeShares = calculateFeeShares;
|
|
3132
|
-
exports.computeCommitment = computeCommitment;
|
|
3133
|
-
exports.computeDepositCommitment = computeDepositCommitment;
|
|
3134
|
-
exports.computeNullifier = computeNullifier;
|
|
3135
2920
|
exports.computeStatus = computeStatus;
|
|
3136
2921
|
exports.convertToShares = convertToShares;
|
|
3137
|
-
exports.createPrivateNote = createPrivateNote;
|
|
3138
2922
|
exports.deserializeSignature = deserializeSignature;
|
|
3139
2923
|
exports.findTokenByAddress = findTokenByAddress;
|
|
3140
2924
|
exports.formatAddress = formatAddress;
|
|
@@ -3142,13 +2926,10 @@ exports.formatDuration = formatDuration;
|
|
|
3142
2926
|
exports.formatTimestamp = formatTimestamp;
|
|
3143
2927
|
exports.formatTokenValue = formatTokenValue;
|
|
3144
2928
|
exports.fromU256 = fromU256;
|
|
3145
|
-
exports.generateSalt = generateSalt;
|
|
3146
2929
|
exports.getInscriptionOrderTypedData = getInscriptionOrderTypedData;
|
|
3147
2930
|
exports.getLendOfferTypedData = getLendOfferTypedData;
|
|
3148
|
-
exports.getPrivateLendOfferTypedData = getPrivateLendOfferTypedData;
|
|
3149
2931
|
exports.getTokensForNetwork = getTokensForNetwork;
|
|
3150
2932
|
exports.hashAssets = hashAssets;
|
|
3151
|
-
exports.hashPair = hashPair;
|
|
3152
2933
|
exports.inscriptionIdToHex = inscriptionIdToHex;
|
|
3153
2934
|
exports.normalizeAddress = normalizeAddress;
|
|
3154
2935
|
exports.parseAmount = parseAmount;
|