northstar-eva-sdk 0.5.0 → 0.6.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/northstar-eva-sdk.d.ts +8 -8
- package/dist/northstar-eva-sdk.js +11 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -68,7 +68,7 @@ tx.sign(myKeypair); // or wallet.signTransaction(tx)
|
|
|
68
68
|
await connection.sendRawTransaction(tx.serialize());
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
-
Builders (each mirrors the send-method's inputs): `buildOpenSessionIx()`, `buildCloseSessionIx()`, `buildDepositFeeIx(lamports, recipient?)`, `buildWithdrawFeeFromErIx({ lamports,
|
|
71
|
+
Builders (each mirrors the send-method's inputs): `buildOpenSessionIx()`, `buildCloseSessionIx()`, `buildDepositFeeIx(lamports, recipient?)`, `buildWithdrawFeeFromErIx({ lamports, sender?, toL1? })` (Portal SOL bridge), `buildInitializeIx(p)`, `buildUpdateConfigIx(p)`, `buildCreateTrenchIx({ trenchId?, initialVirtualTokenReserves? })`, `buildDepositIx(p)`, `buildWithdrawIx({ trenchId, amount, thinkId? })` (eva trench withdraw), `buildFinalizeIx(p)`, `buildUserAtaIx(p)`, `buildBuyIx(p)`, `buildSellIx(p)`, `buildClosePoolIx(p)`, `buildClaimTokensIx(p)`, `buildDistributePrizeIx(p)`, plus `buildTransaction(ixs, { lane?, feePayer? })`, `nextTrenchId()`, and the `agentPda(id, user?)` PDA helper.
|
|
72
72
|
|
|
73
73
|
> The existing send-methods (`buy`, `sell`, `fundFeeToErPayer`, …) are unchanged — they now just call these builders internally. Builders perform the same state **reads** to resolve accounts (e.g. `buildBuyIx` reads global for `feeRecipient`) but never **send**.
|
|
74
74
|
|
|
@@ -133,7 +133,7 @@ The deposit ("fund fee to ER payer") API now **contains the open-session step**,
|
|
|
133
133
|
|
|
134
134
|
> **Backwards compatible:** existing code that calls `openSession()` before depositing still works (the extra `ensureSession` is a no-op when the session already exists). No signatures or return types changed.
|
|
135
135
|
|
|
136
|
-
The three user-fund APIs: **query balance** → `querySolBalance(account?)` · **deposit** → `fundFeeToErPayer(lamports, recipient?)` · **withdraw** → `withdrawFeeFromEr({ lamports,
|
|
136
|
+
The three user-fund APIs: **query balance** → `querySolBalance(account?)` · **deposit** → `fundFeeToErPayer(lamports, recipient?)` · **withdraw** → `withdrawFeeFromEr({ lamports, sender?, toL1? })`.
|
|
137
137
|
|
|
138
138
|
## What it is + the fee point
|
|
139
139
|
|
|
@@ -335,10 +335,10 @@ export declare class NorthstarEva {
|
|
|
335
335
|
buildCloseSessionIx(): TransactionInstruction;
|
|
336
336
|
/** Portal DepositFee instruction (L1) — "fund fee to ER payer". (Caller must ensure a session exists.) */
|
|
337
337
|
buildDepositFeeIx(lamports: bigint, recipient?: PublicKey): TransactionInstruction;
|
|
338
|
-
/** "Withdraw fee from ER" instruction (ER) — system transfer from `
|
|
338
|
+
/** "Withdraw fee from ER" instruction (ER) — system transfer from `sender` (default: the signer) → its WithdrawalSink. (Portal SOL bridge; distinct from the eva `withdraw` instruction.) */
|
|
339
339
|
buildWithdrawFeeFromErIx(p: {
|
|
340
340
|
lamports: bigint;
|
|
341
|
-
|
|
341
|
+
sender?: PublicKey;
|
|
342
342
|
toL1?: PublicKey;
|
|
343
343
|
}): TransactionInstruction;
|
|
344
344
|
/** Next sequential trench id (= total_trenches + 1) read from the ER global state. */
|
|
@@ -491,23 +491,23 @@ export declare class NorthstarEva {
|
|
|
491
491
|
* WithdrawalSink, returning the fee to whoever sent it. The validator pays the L1 SOL
|
|
492
492
|
* ASYNCHRONOUSLY at the next settlement (use {@link waitForL1Settlement} to await it).
|
|
493
493
|
*
|
|
494
|
-
*
|
|
495
|
-
*
|
|
496
|
-
*
|
|
497
|
-
*
|
|
494
|
+
* `sender` is a **PublicKey** (default: the SDK signer's pubkey). This send-method signs with
|
|
495
|
+
* the SDK's wallet adapter — so `sender` must be the SDK's own account (the user's wallet, which
|
|
496
|
+
* signs remotely; no secret key needed). To withdraw for a different account whose signature you
|
|
497
|
+
* collect elsewhere, use {@link buildWithdrawFeeFromErIx} and have that account sign the tx.
|
|
498
498
|
*
|
|
499
499
|
* NOTE: the L1 payout goes to the SAME account that deposited (the sender) — an arbitrary
|
|
500
500
|
* `toL1` destination is not supported by the Portal program yet (pending protocol change).
|
|
501
501
|
*/
|
|
502
502
|
requestWithdraw(p: {
|
|
503
503
|
lamports: bigint;
|
|
504
|
-
|
|
504
|
+
sender?: PublicKey;
|
|
505
505
|
toL1?: PublicKey;
|
|
506
506
|
}): Promise<ErTxResult>;
|
|
507
507
|
/** "Withdraw fee from ER" (the green-box withdraw API) — alias of {@link requestWithdraw}. */
|
|
508
508
|
withdrawFeeFromEr(p: {
|
|
509
509
|
lamports: bigint;
|
|
510
|
-
|
|
510
|
+
sender?: PublicKey;
|
|
511
511
|
toL1?: PublicKey;
|
|
512
512
|
}): Promise<ErTxResult>;
|
|
513
513
|
/** Poll an account's L1 balance until it rises by >= `expectedDelta` (settlement is async). Returns the final L1 balance. */
|
|
@@ -2419,12 +2419,12 @@ export class NorthstarEva {
|
|
|
2419
2419
|
buildDepositFeeIx(lamports, recipient = this.payer) {
|
|
2420
2420
|
return portal.depositFeeIx({ programId: this.cfg.portalProgramId, depositor: this.payer, recipient, lamports });
|
|
2421
2421
|
}
|
|
2422
|
-
/** "Withdraw fee from ER" instruction (ER) — system transfer from `
|
|
2422
|
+
/** "Withdraw fee from ER" instruction (ER) — system transfer from `sender` (default: the signer) → its WithdrawalSink. (Portal SOL bridge; distinct from the eva `withdraw` instruction.) */
|
|
2423
2423
|
buildWithdrawFeeFromErIx(p) {
|
|
2424
|
-
const
|
|
2425
|
-
if (p.toL1 && !p.toL1.equals(
|
|
2426
|
-
throw new Error("Arbitrary L1 withdrawal destination is not supported yet (Portal pays the
|
|
2427
|
-
return SystemProgram.transfer({ fromPubkey:
|
|
2424
|
+
const sender = p.sender ?? this.payer;
|
|
2425
|
+
if (p.toL1 && !p.toL1.equals(sender))
|
|
2426
|
+
throw new Error("Arbitrary L1 withdrawal destination is not supported yet (Portal pays the sender). Omit `toL1` or set it equal to sender.");
|
|
2427
|
+
return SystemProgram.transfer({ fromPubkey: sender, toPubkey: this.getWithdrawalSink(sender), lamports: Number(p.lamports) });
|
|
2428
2428
|
}
|
|
2429
2429
|
/** Next sequential trench id (= total_trenches + 1) read from the ER global state. */
|
|
2430
2430
|
async nextTrenchId() { return (await this.requireGlobal()).totalTrenches + 1n; }
|
|
@@ -2630,19 +2630,18 @@ export class NorthstarEva {
|
|
|
2630
2630
|
* WithdrawalSink, returning the fee to whoever sent it. The validator pays the L1 SOL
|
|
2631
2631
|
* ASYNCHRONOUSLY at the next settlement (use {@link waitForL1Settlement} to await it).
|
|
2632
2632
|
*
|
|
2633
|
-
*
|
|
2634
|
-
*
|
|
2635
|
-
*
|
|
2636
|
-
*
|
|
2633
|
+
* `sender` is a **PublicKey** (default: the SDK signer's pubkey). This send-method signs with
|
|
2634
|
+
* the SDK's wallet adapter — so `sender` must be the SDK's own account (the user's wallet, which
|
|
2635
|
+
* signs remotely; no secret key needed). To withdraw for a different account whose signature you
|
|
2636
|
+
* collect elsewhere, use {@link buildWithdrawFeeFromErIx} and have that account sign the tx.
|
|
2637
2637
|
*
|
|
2638
2638
|
* NOTE: the L1 payout goes to the SAME account that deposited (the sender) — an arbitrary
|
|
2639
2639
|
* `toL1` destination is not supported by the Portal program yet (pending protocol change).
|
|
2640
2640
|
*/
|
|
2641
2641
|
async requestWithdraw(p) {
|
|
2642
2642
|
this.requireNorthStar("withdrawFeeFromEr (withdraw ER→L1)");
|
|
2643
|
-
const
|
|
2644
|
-
|
|
2645
|
-
return this.sendOnEr([ix], [sender]);
|
|
2643
|
+
const ix = this.buildWithdrawFeeFromErIx({ lamports: p.lamports, sender: p.sender ?? this.payer, toL1: p.toL1 });
|
|
2644
|
+
return this.sendOnEr([ix], [this.wallet]); // signed by the SDK's wallet adapter (the user)
|
|
2646
2645
|
}
|
|
2647
2646
|
/** "Withdraw fee from ER" (the green-box withdraw API) — alias of {@link requestWithdraw}. */
|
|
2648
2647
|
async withdrawFeeFromEr(p) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "northstar-eva-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Run the eva program on a NorthStar ephemeral rollup (zero-fee hot path). A high-level class SDK over the NorthStar Portal/ER protocol + the eva Anchor program. Works localnet & devnet.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|