@miden-sdk/miden-sdk 0.15.2 → 0.15.4
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 +69 -0
- package/dist/mt/{Cargo-BbpPeJYa.js → Cargo-DjVnfWKi.js} +424 -88
- package/dist/mt/Cargo-DjVnfWKi.js.map +1 -0
- package/dist/mt/api-types.d.ts +130 -0
- package/dist/mt/assets/miden_client_web.wasm +0 -0
- package/dist/mt/crates/miden_client_web.d.ts +93 -3
- package/dist/mt/docs-entry.d.ts +2 -0
- package/dist/mt/eager.js +1 -1
- package/dist/mt/index.d.ts +3 -0
- package/dist/mt/index.js +211 -13
- 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/workers/{Cargo-BbpPeJYa-BlSVzh6v.js → Cargo-DjVnfWKi-DvLbB_Zb.js} +424 -88
- package/dist/mt/workers/Cargo-DjVnfWKi-DvLbB_Zb.js.map +1 -0
- package/dist/mt/workers/assets/miden_client_web.wasm +0 -0
- package/dist/mt/workers/web-client-methods-worker.js +425 -88
- 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/{Cargo-Dlo4tWNG.js → Cargo-Cwpuvlbc.js} +433 -98
- package/dist/st/Cargo-Cwpuvlbc.js.map +1 -0
- package/dist/st/api-types.d.ts +130 -0
- package/dist/st/assets/miden_client_web.wasm +0 -0
- package/dist/st/crates/miden_client_web.d.ts +93 -3
- package/dist/st/docs-entry.d.ts +2 -0
- package/dist/st/eager.js +1 -1
- package/dist/st/index.d.ts +3 -0
- package/dist/st/index.js +211 -13
- package/dist/st/index.js.map +1 -1
- package/dist/st/wasm.js +1 -1
- package/dist/st/workers/{Cargo-Dlo4tWNG-BPaiqKyy.js → Cargo-Cwpuvlbc-B0V_MEMU.js} +433 -98
- package/dist/st/workers/Cargo-Cwpuvlbc-B0V_MEMU.js.map +1 -0
- package/dist/st/workers/assets/miden_client_web.wasm +0 -0
- package/dist/st/workers/web-client-methods-worker.js +434 -98
- 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/node-index.js +150 -40
- package/js/resources/transactions.js +198 -12
- package/package.json +6 -4
- package/dist/mt/Cargo-BbpPeJYa.js.map +0 -1
- package/dist/mt/workers/Cargo-BbpPeJYa-BlSVzh6v.js.map +0 -1
- package/dist/st/Cargo-Dlo4tWNG.js.map +0 -1
- package/dist/st/workers/Cargo-Dlo4tWNG-BPaiqKyy.js.map +0 -1
package/README.md
CHANGED
|
@@ -423,6 +423,26 @@ 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
|
+
|
|
426
446
|
### Send Tokens
|
|
427
447
|
|
|
428
448
|
```typescript
|
|
@@ -452,6 +472,38 @@ const balance = await client.accounts.getBalance(wallet, dagToken);
|
|
|
452
472
|
console.log(`Balance: ${balance}`);
|
|
453
473
|
```
|
|
454
474
|
|
|
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
|
+
|
|
455
507
|
### Partial-Swap (PSWAP) Orders
|
|
456
508
|
|
|
457
509
|
A partial-swap note offers one asset for another and can be filled by multiple
|
|
@@ -491,6 +543,23 @@ await client.pswap.cancelByOrder({ orderId, waitForConfirmation: true });
|
|
|
491
543
|
`client.pswap.lineage(orderId)` returns one order's lineage, or `null` if it is
|
|
492
544
|
not tracked.
|
|
493
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
|
+
|
|
494
563
|
### Cleanup
|
|
495
564
|
|
|
496
565
|
When you're finished using a MidenClient instance, call `terminate()` to release its Web Worker:
|