@miden-sdk/miden-sdk 0.15.6 → 0.16.0-alpha.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 +0 -137
- package/dist/mt/{workers/Cargo-mvyTli7g-BwMMSyoq.js → Cargo-DKsyWYgG.js} +699 -1202
- package/dist/mt/Cargo-DKsyWYgG.js.map +1 -0
- package/dist/mt/api-types.d.ts +38 -250
- package/dist/mt/assets/miden_client_web.wasm +0 -0
- package/dist/mt/crates/miden_client_web.d.ts +179 -370
- package/dist/mt/docs-entry.d.ts +3 -6
- package/dist/mt/eager.js +1 -1
- package/dist/mt/index.d.ts +0 -3
- package/dist/mt/index.js +49 -450
- package/dist/mt/index.js.map +1 -1
- package/dist/mt/wasm.js +1 -1
- package/dist/mt/workerHelpers.js +1 -1
- package/dist/mt/{Cargo-mvyTli7g.js → workers/Cargo-DKsyWYgG-DfOhgt23.js} +700 -1201
- package/dist/mt/workers/Cargo-DKsyWYgG-DfOhgt23.js.map +1 -0
- package/dist/mt/workers/assets/miden_client_web.wasm +0 -0
- package/dist/mt/workers/web-client-methods-worker.js +703 -1207
- package/dist/mt/workers/web-client-methods-worker.js.map +1 -1
- package/dist/mt/workers/web-client-methods-worker.module.js +1 -1
- package/dist/mt/workers/web-client-methods-worker.module.js.map +1 -1
- package/dist/mt/workers/workerHelpers.js +1 -1
- package/dist/st/{workers/Cargo-Cysp4vto-BIw-TeJn.js → Cargo-LwITdlzJ.js} +694 -1195
- package/dist/st/Cargo-LwITdlzJ.js.map +1 -0
- package/dist/st/api-types.d.ts +38 -250
- package/dist/st/assets/miden_client_web.wasm +0 -0
- package/dist/st/crates/miden_client_web.d.ts +179 -370
- package/dist/st/docs-entry.d.ts +3 -6
- package/dist/st/eager.js +1 -1
- package/dist/st/index.d.ts +0 -3
- package/dist/st/index.js +49 -450
- package/dist/st/index.js.map +1 -1
- package/dist/st/wasm.js +1 -1
- package/dist/st/{Cargo-Cysp4vto.js → workers/Cargo-LwITdlzJ-Dyl2bCwN.js} +695 -1194
- package/dist/st/workers/Cargo-LwITdlzJ-Dyl2bCwN.js.map +1 -0
- package/dist/st/workers/assets/miden_client_web.wasm +0 -0
- package/dist/st/workers/web-client-methods-worker.js +698 -1200
- package/dist/st/workers/web-client-methods-worker.js.map +1 -1
- package/dist/st/workers/web-client-methods-worker.module.js +1 -1
- package/dist/st/workers/web-client-methods-worker.module.js.map +1 -1
- package/js/client.js +2 -4
- package/js/node/client-factory.js +4 -11
- package/js/node/napi-compat.js +1 -0
- package/js/node-index.js +11 -10
- package/js/resources/compiler.js +23 -12
- package/js/resources/transactions.js +20 -289
- package/js/standalone.js +3 -61
- package/package.json +4 -4
- package/dist/mt/Cargo-mvyTli7g.js.map +0 -1
- package/dist/mt/workers/Cargo-mvyTli7g-BwMMSyoq.js.map +0 -1
- package/dist/st/Cargo-Cysp4vto.js.map +0 -1
- package/dist/st/workers/Cargo-Cysp4vto-BIw-TeJn.js.map +0 -1
- package/js/resources/pswap.js +0 -132
package/README.md
CHANGED
|
@@ -423,26 +423,6 @@ console.log(faucet.id().toString());
|
|
|
423
423
|
console.log(faucet.isFaucet()); // true
|
|
424
424
|
```
|
|
425
425
|
|
|
426
|
-
### Read Faucet Metadata
|
|
427
|
-
|
|
428
|
-
`BasicFungibleFaucetComponent` extracts the on-chain token metadata from a faucet account. The same
|
|
429
|
-
component backs both basic and network-style faucets, so it works for either:
|
|
430
|
-
|
|
431
|
-
```typescript
|
|
432
|
-
import { BasicFungibleFaucetComponent } from "@miden-sdk/miden-sdk";
|
|
433
|
-
|
|
434
|
-
const faucet = BasicFungibleFaucetComponent.fromAccount(account);
|
|
435
|
-
|
|
436
|
-
faucet.symbol().toString(); // "DAG"
|
|
437
|
-
faucet.tokenName(); // "DAG Token"
|
|
438
|
-
faucet.decimals(); // 8
|
|
439
|
-
faucet.maxSupply().toString(); // "10000000"
|
|
440
|
-
faucet.tokenSupply().toString(); // amount minted so far, e.g. "0"
|
|
441
|
-
faucet.description(); // string | undefined
|
|
442
|
-
faucet.logoUri(); // string | undefined
|
|
443
|
-
faucet.externalLink(); // string | undefined
|
|
444
|
-
```
|
|
445
|
-
|
|
446
426
|
### Send Tokens
|
|
447
427
|
|
|
448
428
|
```typescript
|
|
@@ -472,123 +452,6 @@ const balance = await client.accounts.getBalance(wallet, dagToken);
|
|
|
472
452
|
console.log(`Balance: ${balance}`);
|
|
473
453
|
```
|
|
474
454
|
|
|
475
|
-
### Batch Operations
|
|
476
|
-
|
|
477
|
-
Submit multiple operations against a single account as one atomic batch — every transaction in the batch lands together or none does. Each operation builds its own `TransactionRequest` internally; you don't have to assemble or serialize them yourself.
|
|
478
|
-
|
|
479
|
-
```typescript
|
|
480
|
-
const { blockNumber } = await client.transactions.batch({
|
|
481
|
-
account: wallet,
|
|
482
|
-
operations: [
|
|
483
|
-
{ kind: "send", to: alice, token: dagToken, amount: 50n, type: "public" },
|
|
484
|
-
{ kind: "send", to: bob, token: dagToken, amount: 30n, type: "public" },
|
|
485
|
-
{ kind: "consume", notes: pendingNotes },
|
|
486
|
-
],
|
|
487
|
-
waitForConfirmation: true,
|
|
488
|
-
});
|
|
489
|
-
console.log(`Batch landed in block ${blockNumber}`);
|
|
490
|
-
```
|
|
491
|
-
|
|
492
|
-
Operations are discriminated by `kind`: `"send"`, `"mint"`, `"consume"`, `"swap"`, `"execute"`, and `"custom"` (escape hatch for a pre-built `TransactionRequest`). The shape of each operation mirrors the singular options object (`SendOptions`, `MintOptions`, …) minus the `account` field, which is set once at the batch level.
|
|
493
|
-
|
|
494
|
-
V1 supports only same-account batches — every operation must execute against the `account` passed at the top level. Mixing accounts in one batch is not supported.
|
|
495
|
-
|
|
496
|
-
For callers that already hold pre-built `TransactionRequest`s, `submitBatch` skips the high-level builders:
|
|
497
|
-
|
|
498
|
-
```typescript
|
|
499
|
-
const { blockNumber } = await client.transactions.submitBatch(wallet, [
|
|
500
|
-
request1,
|
|
501
|
-
request2,
|
|
502
|
-
]);
|
|
503
|
-
```
|
|
504
|
-
|
|
505
|
-
The V1 batch primitive returns only the block number — there are no per-tx ids in the result. `waitForConfirmation` polls local sync height until it reaches `blockNumber` (rather than per-tx polling like singular `send` / `consume`).
|
|
506
|
-
|
|
507
|
-
### Partial-Swap (PSWAP) Orders
|
|
508
|
-
|
|
509
|
-
A partial-swap note offers one asset for another and can be filled by multiple
|
|
510
|
-
counterparties over time — each partial fill pays the creator and leaves a
|
|
511
|
-
remainder note carrying the unfilled balance. The client tracks that chain as a
|
|
512
|
-
**lineage** keyed by a stable `orderId`, advancing it round by round as fills
|
|
513
|
-
are discovered on sync.
|
|
514
|
-
|
|
515
|
-
```typescript
|
|
516
|
-
// Offer 100 of token A for 25 of token B.
|
|
517
|
-
await client.transactions.pswapCreate({
|
|
518
|
-
account: wallet,
|
|
519
|
-
offer: { token: aToken, amount: 100n },
|
|
520
|
-
request: { token: bToken, amount: 25n }
|
|
521
|
-
});
|
|
522
|
-
await client.sync();
|
|
523
|
-
|
|
524
|
-
// The order is tracked as a lineage keyed by a stable order id.
|
|
525
|
-
const [lineage] = await client.pswap.lineagesFor(wallet);
|
|
526
|
-
const orderId = lineage.orderId();
|
|
527
|
-
console.log(lineage.remainingOffered().toString()); // unfilled offered balance
|
|
528
|
-
|
|
529
|
-
// A counterparty fills part of the order:
|
|
530
|
-
// client.transactions.pswapConsume({ account, note, fillAmount });
|
|
531
|
-
// On the next sync the lineage advances, and `remainingOffered()` shrinks.
|
|
532
|
-
|
|
533
|
-
// Reclaim the unfilled remainder on the current tip, by stable order id.
|
|
534
|
-
// `waitForConfirmation` blocks until the cancel commits AND a sync brings
|
|
535
|
-
// the consumed-note update down; without it, the call resolves at submit
|
|
536
|
-
// time and `pswap.lineage(orderId)` still reads `Active` until the next
|
|
537
|
-
// sync. The lineage only transitions to `Reclaimed` once the chain sees
|
|
538
|
-
// the cancel land.
|
|
539
|
-
await client.pswap.cancelByOrder({ orderId, waitForConfirmation: true });
|
|
540
|
-
```
|
|
541
|
-
|
|
542
|
-
`client.pswap.lineages()` returns every order this client created;
|
|
543
|
-
`client.pswap.lineage(orderId)` returns one order's lineage, or `null` if it is
|
|
544
|
-
not tracked.
|
|
545
|
-
|
|
546
|
-
### Bridge out (AggLayer)
|
|
547
|
-
|
|
548
|
-
`client.transactions.bridge(...)` bridges a fungible asset out to another network via the AggLayer. It emits a single public B2AGG note that the bridge account consumes, burning the asset so it can be claimed at the destination Ethereum address on the AggLayer-assigned network.
|
|
549
|
-
|
|
550
|
-
```typescript
|
|
551
|
-
await client.transactions.bridge({
|
|
552
|
-
account: wallet, // sender (executes the transaction)
|
|
553
|
-
bridgeAccount: bridge, // consumes the note and burns the asset
|
|
554
|
-
token: dagToken, // faucet of the asset being bridged
|
|
555
|
-
amount: 100n,
|
|
556
|
-
destinationNetwork: 1, // AggLayer-assigned network id
|
|
557
|
-
destinationAddress: "0x000000000000000000000000000000000000dEaD"
|
|
558
|
-
});
|
|
559
|
-
```
|
|
560
|
-
|
|
561
|
-
The 20-byte destination is also available as an `EthAddress` (`EthAddress.fromHex("0x…")`) for the lower-level builders `Note.createB2AggNote(...)` and `client.newB2AggTransactionRequest(...)`.
|
|
562
|
-
|
|
563
|
-
### Network Notes
|
|
564
|
-
|
|
565
|
-
A network note is a Public note carrying a `NetworkAccountTarget` attachment; a public network account auto-consumes it once the note lands on-chain — no manual `consume` call needed on the target side.
|
|
566
|
-
|
|
567
|
-
```typescript
|
|
568
|
-
const { txId, note } = await client.transactions.createNetworkNote({
|
|
569
|
-
account: senderId,
|
|
570
|
-
target: networkAccountId,
|
|
571
|
-
script: myNoteScript, // or: recipient: myRecipient
|
|
572
|
-
waitForConfirmation: true,
|
|
573
|
-
});
|
|
574
|
-
console.log(note.isNetworkNote()); // true
|
|
575
|
-
```
|
|
576
|
-
|
|
577
|
-
Provide exactly one of `script` or `recipient`. Notes are always Public — the attachment, not the tag, is what a network account matches on. The standalone `buildNetworkNote(opts)` builds the same note without submitting.
|
|
578
|
-
|
|
579
|
-
To create the receiving account, build a **public** account carrying the network-account auth component — its note-script allowlist tells the node which notes the account may auto-consume:
|
|
580
|
-
|
|
581
|
-
```typescript
|
|
582
|
-
const auth = AccountComponent.createNetworkAuth([myNoteScript.root()]);
|
|
583
|
-
const { account } = new AccountBuilder(seed)
|
|
584
|
-
.storageMode(AccountStorageMode.public())
|
|
585
|
-
.withComponent(myComponent)
|
|
586
|
-
.withAuthComponent(auth)
|
|
587
|
-
.build();
|
|
588
|
-
```
|
|
589
|
-
|
|
590
|
-
The allowlist must be non-empty. Transaction scripts are forbidden unless allowlisted via the optional second argument (`TransactionScript.root()`); the component bumps the nonce itself, so the account deploys via a scriptless transaction. Readback: `account.isNetworkAccount()` and `account.networkNoteAllowlist()`.
|
|
591
|
-
|
|
592
455
|
### Cleanup
|
|
593
456
|
|
|
594
457
|
When you're finished using a MidenClient instance, call `terminate()` to release its Web Worker:
|