@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
|
@@ -79,97 +79,6 @@ export class TransactionsResource {
|
|
|
79
79
|
return { txId, note: null, result };
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
/**
|
|
83
|
-
* Builds a Public custom-script note carrying a NetworkAccountTarget
|
|
84
|
-
* attachment, submits it as an own output note, and optionally waits for
|
|
85
|
-
* confirmation. Provide exactly one of `recipient` or `script`.
|
|
86
|
-
*/
|
|
87
|
-
async createNetworkNote(opts) {
|
|
88
|
-
this.#client.assertNotTerminated();
|
|
89
|
-
const wasm = await this.#getWasm();
|
|
90
|
-
|
|
91
|
-
if (opts.recipient && opts.script) {
|
|
92
|
-
throw new Error(
|
|
93
|
-
"createNetworkNote requires exactly one of `recipient` or `script`, not both."
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const senderId = resolveAccountRef(opts.account, wasm);
|
|
98
|
-
|
|
99
|
-
const target =
|
|
100
|
-
opts.target instanceof wasm.NetworkAccountTarget
|
|
101
|
-
? opts.target
|
|
102
|
-
: new wasm.NetworkAccountTarget(
|
|
103
|
-
resolveAccountRef(opts.target, wasm),
|
|
104
|
-
opts.executionHint
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
const noteAssets = opts.assets
|
|
108
|
-
? new wasm.NoteAssets(
|
|
109
|
-
(Array.isArray(opts.assets) ? opts.assets : [opts.assets]).map(
|
|
110
|
-
(a) =>
|
|
111
|
-
new wasm.FungibleAsset(
|
|
112
|
-
resolveAccountRef(a.token, wasm),
|
|
113
|
-
BigInt(a.amount)
|
|
114
|
-
)
|
|
115
|
-
)
|
|
116
|
-
)
|
|
117
|
-
: new wasm.NoteAssets();
|
|
118
|
-
|
|
119
|
-
const metadata = new wasm.NoteMetadata(
|
|
120
|
-
senderId,
|
|
121
|
-
wasm.NoteType.Public,
|
|
122
|
-
wasm.NoteTag.withAccountTarget(target.targetId())
|
|
123
|
-
);
|
|
124
|
-
|
|
125
|
-
let recipient = opts.recipient;
|
|
126
|
-
if (!recipient) {
|
|
127
|
-
if (!opts.script) {
|
|
128
|
-
throw new Error(
|
|
129
|
-
"createNetworkNote requires either `recipient` or `script`."
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
const storage = new wasm.NoteStorage(
|
|
133
|
-
new wasm.FeltArray(
|
|
134
|
-
(opts.inputs ?? []).map((value) => new wasm.Felt(value))
|
|
135
|
-
)
|
|
136
|
-
);
|
|
137
|
-
recipient = wasm.NoteRecipient.fromScript(opts.script, storage);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const attachments = [target.toAttachment()];
|
|
141
|
-
if (opts.attachment) {
|
|
142
|
-
attachments.push(new wasm.NoteAttachment(opts.attachment));
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const note = wasm.Note.withAttachments(
|
|
146
|
-
noteAssets,
|
|
147
|
-
metadata,
|
|
148
|
-
recipient,
|
|
149
|
-
attachments
|
|
150
|
-
);
|
|
151
|
-
|
|
152
|
-
// NoteArray constructor consumes its elements; use push(¬e) to keep
|
|
153
|
-
// `note` valid so we can return it to the caller.
|
|
154
|
-
const ownOutputs = new wasm.NoteArray();
|
|
155
|
-
ownOutputs.push(note);
|
|
156
|
-
const request = new wasm.TransactionRequestBuilder()
|
|
157
|
-
.withOwnOutputNotes(ownOutputs)
|
|
158
|
-
.build();
|
|
159
|
-
|
|
160
|
-
const { txId, result } = await this.#submitOrSubmitWithProver(
|
|
161
|
-
senderId,
|
|
162
|
-
request,
|
|
163
|
-
opts.prover
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
if (opts.waitForConfirmation) {
|
|
167
|
-
await this.waitFor(txId.toHex(), { timeout: opts.timeout });
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
return { txId, note, result };
|
|
171
|
-
}
|
|
172
|
-
|
|
173
82
|
async mint(opts) {
|
|
174
83
|
this.#client.assertNotTerminated();
|
|
175
84
|
const wasm = await this.#getWasm();
|
|
@@ -188,24 +97,6 @@ export class TransactionsResource {
|
|
|
188
97
|
return { txId, result };
|
|
189
98
|
}
|
|
190
99
|
|
|
191
|
-
async bridge(opts) {
|
|
192
|
-
this.#client.assertNotTerminated();
|
|
193
|
-
const wasm = await this.#getWasm();
|
|
194
|
-
const { accountId, request } = await this.#buildB2AggRequest(opts, wasm);
|
|
195
|
-
|
|
196
|
-
const { txId, result } = await this.#submitOrSubmitWithProver(
|
|
197
|
-
accountId,
|
|
198
|
-
request,
|
|
199
|
-
opts.prover
|
|
200
|
-
);
|
|
201
|
-
|
|
202
|
-
if (opts.waitForConfirmation) {
|
|
203
|
-
await this.waitFor(txId.toHex(), { timeout: opts.timeout });
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
return { txId, result };
|
|
207
|
-
}
|
|
208
|
-
|
|
209
100
|
async consume(opts) {
|
|
210
101
|
this.#client.assertNotTerminated();
|
|
211
102
|
const wasm = await this.#getWasm();
|
|
@@ -352,6 +243,14 @@ export class TransactionsResource {
|
|
|
352
243
|
return { txId, result };
|
|
353
244
|
}
|
|
354
245
|
|
|
246
|
+
/**
|
|
247
|
+
* Dry-run a transaction to obtain the TransactionSummary pending
|
|
248
|
+
* authorization (e.g. a multisig below its signing threshold). Rejects
|
|
249
|
+
* with an error carrying `code: "TRANSACTION_ALREADY_AUTHORIZED"` (on
|
|
250
|
+
* Node.js the code prefixes the message instead) when the transaction
|
|
251
|
+
* executes successfully, since a fully authorized transaction produces
|
|
252
|
+
* no summary. See {@link PreviewOptions}.
|
|
253
|
+
*/
|
|
355
254
|
async preview(opts) {
|
|
356
255
|
this.#client.assertNotTerminated();
|
|
357
256
|
const wasm = await this.#getWasm();
|
|
@@ -368,10 +267,6 @@ export class TransactionsResource {
|
|
|
368
267
|
({ accountId, request } = await this.#buildMintRequest(opts, wasm));
|
|
369
268
|
break;
|
|
370
269
|
}
|
|
371
|
-
case "bridge": {
|
|
372
|
-
({ accountId, request } = await this.#buildB2AggRequest(opts, wasm));
|
|
373
|
-
break;
|
|
374
|
-
}
|
|
375
270
|
case "consume": {
|
|
376
271
|
({ accountId, request } = await this.#buildConsumeRequest(opts, wasm));
|
|
377
272
|
break;
|
|
@@ -416,163 +311,6 @@ export class TransactionsResource {
|
|
|
416
311
|
async execute(opts) {
|
|
417
312
|
this.#client.assertNotTerminated();
|
|
418
313
|
const wasm = await this.#getWasm();
|
|
419
|
-
const { accountId, request } = this.#buildExecuteRequest(opts, wasm);
|
|
420
|
-
|
|
421
|
-
const { txId, result } = await this.#submitOrSubmitWithProver(
|
|
422
|
-
accountId,
|
|
423
|
-
request,
|
|
424
|
-
opts.prover
|
|
425
|
-
);
|
|
426
|
-
|
|
427
|
-
if (opts.waitForConfirmation) {
|
|
428
|
-
await this.waitFor(txId.toHex(), { timeout: opts.timeout });
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
return { txId, result };
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
/**
|
|
435
|
-
* Submit a heterogeneous batch of operations against a single account. All
|
|
436
|
-
* operations are executed, proven individually and as a batch, and submitted
|
|
437
|
-
* atomically — either every tx in the batch lands or none does.
|
|
438
|
-
*
|
|
439
|
-
* @param {BatchOptions} opts - Batch options including the account, operations array, and confirmation settings.
|
|
440
|
-
* @returns {Promise<BatchSubmitResult>} The block number the batch was accepted into.
|
|
441
|
-
*/
|
|
442
|
-
async batch(opts) {
|
|
443
|
-
this.#client.assertNotTerminated();
|
|
444
|
-
const wasm = await this.#getWasm();
|
|
445
|
-
|
|
446
|
-
if (!opts || !opts.account) {
|
|
447
|
-
throw new Error("batch: `account` is required");
|
|
448
|
-
}
|
|
449
|
-
if (!Array.isArray(opts.operations) || opts.operations.length === 0) {
|
|
450
|
-
throw new Error("batch: `operations` must be a non-empty array");
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
// Build each TransactionRequest. Per-op builders all use the batch-level
|
|
454
|
-
// `account` — V1 only supports same-account batches, mirroring the Rust
|
|
455
|
-
// constraint. We forward `opts.account` into each per-op options object so
|
|
456
|
-
// the existing builders' `resolveAccountRef` produces fresh AccountIds
|
|
457
|
-
// when needed.
|
|
458
|
-
const requests = [];
|
|
459
|
-
for (let i = 0; i < opts.operations.length; i++) {
|
|
460
|
-
const op = opts.operations[i];
|
|
461
|
-
let built;
|
|
462
|
-
switch (op?.kind) {
|
|
463
|
-
case "send":
|
|
464
|
-
built = await this.#buildSendRequest(
|
|
465
|
-
{ ...op, account: opts.account },
|
|
466
|
-
wasm
|
|
467
|
-
);
|
|
468
|
-
break;
|
|
469
|
-
case "mint":
|
|
470
|
-
built = await this.#buildMintRequest(
|
|
471
|
-
{ ...op, account: opts.account },
|
|
472
|
-
wasm
|
|
473
|
-
);
|
|
474
|
-
break;
|
|
475
|
-
case "consume":
|
|
476
|
-
built = await this.#buildConsumeRequest(
|
|
477
|
-
{ ...op, account: opts.account },
|
|
478
|
-
wasm
|
|
479
|
-
);
|
|
480
|
-
break;
|
|
481
|
-
case "swap":
|
|
482
|
-
built = await this.#buildSwapRequest(
|
|
483
|
-
{ ...op, account: opts.account },
|
|
484
|
-
wasm
|
|
485
|
-
);
|
|
486
|
-
break;
|
|
487
|
-
case "execute":
|
|
488
|
-
built = this.#buildExecuteRequest(
|
|
489
|
-
{ ...op, account: opts.account },
|
|
490
|
-
wasm
|
|
491
|
-
);
|
|
492
|
-
break;
|
|
493
|
-
case "custom":
|
|
494
|
-
if (!op.request) {
|
|
495
|
-
throw new Error(
|
|
496
|
-
`batch: operation[${i}] of kind "custom" is missing \`request\``
|
|
497
|
-
);
|
|
498
|
-
}
|
|
499
|
-
built = { request: op.request };
|
|
500
|
-
break;
|
|
501
|
-
default:
|
|
502
|
-
throw new Error(
|
|
503
|
-
`batch: operation[${i}] has unknown kind "${op?.kind}"`
|
|
504
|
-
);
|
|
505
|
-
}
|
|
506
|
-
requests.push(built.request);
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
return this.submitBatch(opts.account, requests, opts);
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
/**
|
|
513
|
-
* Submit pre-built TransactionRequests as an atomic batch. Lower-level
|
|
514
|
-
* counterpart of `batch()` — for callers that already have built requests in
|
|
515
|
-
* hand. Equivalent to `submit()` but plural.
|
|
516
|
-
*
|
|
517
|
-
* @param {AccountRef} account - The account executing the batch.
|
|
518
|
-
* @param {TransactionRequest[]} requests - Pre-built transaction requests.
|
|
519
|
-
* @param {object} [options] - Optional settings (waitForConfirmation, timeout).
|
|
520
|
-
* The batch is proved with the client's configured prover; the V1 batch API
|
|
521
|
-
* has no per-call prover override.
|
|
522
|
-
* @returns {Promise<BatchSubmitResult>} The block number the batch was accepted into.
|
|
523
|
-
*/
|
|
524
|
-
async submitBatch(account, requests, options) {
|
|
525
|
-
this.#client.assertNotTerminated();
|
|
526
|
-
const wasm = await this.#getWasm();
|
|
527
|
-
|
|
528
|
-
if (!Array.isArray(requests) || requests.length === 0) {
|
|
529
|
-
throw new Error("submitBatch: `requests` must be a non-empty array");
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
const accountId = resolveAccountRef(account, wasm);
|
|
533
|
-
const blockNumber = await this.#inner.submitNewTransactionBatch(
|
|
534
|
-
accountId,
|
|
535
|
-
requests.map((r) => r.serialize())
|
|
536
|
-
);
|
|
537
|
-
|
|
538
|
-
if (options?.waitForConfirmation) {
|
|
539
|
-
await this.#waitForBlock(blockNumber, options);
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
return { blockNumber };
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
/**
|
|
546
|
-
* Polls until the local sync height reaches `blockNumber` or the timeout
|
|
547
|
-
* expires. The Rust V1 batch API returns only a block number — there are no
|
|
548
|
-
* per-tx ids to poll on, so we wait on the chain height instead.
|
|
549
|
-
*
|
|
550
|
-
* @param {number} blockNumber - The block height to wait for.
|
|
551
|
-
* @param {object} [opts] - Polling options (timeout, interval).
|
|
552
|
-
*/
|
|
553
|
-
async #waitForBlock(blockNumber, opts) {
|
|
554
|
-
const timeout = opts?.timeout ?? 60_000;
|
|
555
|
-
const interval = opts?.interval ?? 5_000;
|
|
556
|
-
const start = Date.now();
|
|
557
|
-
|
|
558
|
-
while (true) {
|
|
559
|
-
if (timeout > 0 && Date.now() - start >= timeout) {
|
|
560
|
-
throw new Error(
|
|
561
|
-
`Batch confirmation timed out after ${timeout}ms (waiting for block ${blockNumber})`
|
|
562
|
-
);
|
|
563
|
-
}
|
|
564
|
-
try {
|
|
565
|
-
await this.#inner.syncStateWithTimeout(0);
|
|
566
|
-
} catch {
|
|
567
|
-
// sync may fail transiently; continue polling
|
|
568
|
-
}
|
|
569
|
-
const height = await this.#inner.getSyncHeight();
|
|
570
|
-
if (height >= blockNumber) return;
|
|
571
|
-
await new Promise((resolve) => setTimeout(resolve, interval));
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
#buildExecuteRequest(opts, wasm) {
|
|
576
314
|
const accountId = resolveAccountRef(opts.account, wasm);
|
|
577
315
|
|
|
578
316
|
let builder = new wasm.TransactionRequestBuilder().withCustomScript(
|
|
@@ -600,7 +338,18 @@ export class TransactionsResource {
|
|
|
600
338
|
);
|
|
601
339
|
}
|
|
602
340
|
|
|
603
|
-
|
|
341
|
+
const request = builder.build();
|
|
342
|
+
const { txId, result } = await this.#submitOrSubmitWithProver(
|
|
343
|
+
accountId,
|
|
344
|
+
request,
|
|
345
|
+
opts.prover
|
|
346
|
+
);
|
|
347
|
+
|
|
348
|
+
if (opts.waitForConfirmation) {
|
|
349
|
+
await this.waitFor(txId.toHex(), { timeout: opts.timeout });
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
return { txId, result };
|
|
604
353
|
}
|
|
605
354
|
|
|
606
355
|
async executeProgram(opts) {
|
|
@@ -773,24 +522,6 @@ export class TransactionsResource {
|
|
|
773
522
|
return { accountId, request };
|
|
774
523
|
}
|
|
775
524
|
|
|
776
|
-
async #buildB2AggRequest(opts, wasm) {
|
|
777
|
-
const accountId = resolveAccountRef(opts.account, wasm);
|
|
778
|
-
const bridgeAccountId = resolveAccountRef(opts.bridgeAccount, wasm);
|
|
779
|
-
const faucetId = resolveAccountRef(opts.token, wasm);
|
|
780
|
-
const amount = BigInt(opts.amount);
|
|
781
|
-
const destinationAddress = wasm.EthAddress.fromHex(opts.destinationAddress);
|
|
782
|
-
|
|
783
|
-
const request = await this.#inner.newB2AggTransactionRequest(
|
|
784
|
-
accountId,
|
|
785
|
-
bridgeAccountId,
|
|
786
|
-
faucetId,
|
|
787
|
-
amount,
|
|
788
|
-
opts.destinationNetwork,
|
|
789
|
-
destinationAddress
|
|
790
|
-
);
|
|
791
|
-
return { accountId, request };
|
|
792
|
-
}
|
|
793
|
-
|
|
794
525
|
async #buildConsumeRequest(opts, wasm) {
|
|
795
526
|
const accountId = resolveAccountRef(opts.account, wasm);
|
|
796
527
|
const noteInputs = Array.isArray(opts.notes) ? opts.notes : [opts.notes];
|
package/js/standalone.js
CHANGED
|
@@ -101,70 +101,12 @@ export function buildSwapTag(opts) {
|
|
|
101
101
|
|
|
102
102
|
function buildNoteAssets(assets, wasm) {
|
|
103
103
|
const assetArray = Array.isArray(assets) ? assets : [assets];
|
|
104
|
+
if (assetArray.length === 0) {
|
|
105
|
+
throw new TypeError("P2ID and P2IDE notes require at least one asset");
|
|
106
|
+
}
|
|
104
107
|
const fungibleAssets = assetArray.map((asset) => {
|
|
105
108
|
const faucetId = resolveAccountRef(asset.token, wasm);
|
|
106
109
|
return new wasm.FungibleAsset(faucetId, BigInt(asset.amount));
|
|
107
110
|
});
|
|
108
111
|
return new wasm.NoteAssets(fungibleAssets);
|
|
109
112
|
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Builds a Public custom-script note carrying a NetworkAccountTarget attachment
|
|
113
|
-
* (does not submit). Provide exactly one of `recipient` or `script`.
|
|
114
|
-
*
|
|
115
|
-
* @param {NetworkNoteOptions} opts
|
|
116
|
-
* @returns {Note}
|
|
117
|
-
*/
|
|
118
|
-
export function buildNetworkNote(opts) {
|
|
119
|
-
const wasm = getWasm();
|
|
120
|
-
if (opts.recipient && opts.script) {
|
|
121
|
-
throw new Error(
|
|
122
|
-
"buildNetworkNote requires exactly one of `recipient` or `script`, not both."
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
const sender = resolveAccountRef(opts.account, wasm);
|
|
126
|
-
|
|
127
|
-
const target =
|
|
128
|
-
opts.target instanceof wasm.NetworkAccountTarget
|
|
129
|
-
? opts.target
|
|
130
|
-
: new wasm.NetworkAccountTarget(
|
|
131
|
-
resolveAccountRef(opts.target, wasm),
|
|
132
|
-
opts.executionHint
|
|
133
|
-
);
|
|
134
|
-
|
|
135
|
-
const noteAssets = opts.assets
|
|
136
|
-
? buildNoteAssets(opts.assets, wasm)
|
|
137
|
-
: new wasm.NoteAssets();
|
|
138
|
-
|
|
139
|
-
const metadata = new wasm.NoteMetadata(
|
|
140
|
-
sender,
|
|
141
|
-
wasm.NoteType.Public,
|
|
142
|
-
wasm.NoteTag.withAccountTarget(target.targetId())
|
|
143
|
-
);
|
|
144
|
-
|
|
145
|
-
const recipient = opts.recipient ?? buildRecipient(opts, wasm);
|
|
146
|
-
|
|
147
|
-
const attachments = [target.toAttachment()];
|
|
148
|
-
if (opts.attachment) {
|
|
149
|
-
attachments.push(new wasm.NoteAttachment(opts.attachment));
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
return wasm.Note.withAttachments(
|
|
153
|
-
noteAssets,
|
|
154
|
-
metadata,
|
|
155
|
-
recipient,
|
|
156
|
-
attachments
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function buildRecipient(opts, wasm) {
|
|
161
|
-
if (!opts.script) {
|
|
162
|
-
throw new Error(
|
|
163
|
-
"buildNetworkNote requires either `recipient` or `script`."
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
const storage = new wasm.NoteStorage(
|
|
167
|
-
new wasm.FeltArray((opts.inputs ?? []).map((value) => new wasm.Felt(value)))
|
|
168
|
-
);
|
|
169
|
-
return wasm.NoteRecipient.fromScript(opts.script, storage);
|
|
170
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miden-sdk/miden-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0-alpha.1",
|
|
4
4
|
"description": "Miden Wasm SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -83,9 +83,9 @@
|
|
|
83
83
|
"glob": "^11.0.0"
|
|
84
84
|
},
|
|
85
85
|
"optionalDependencies": {
|
|
86
|
-
"@miden-sdk/node-darwin-arm64": "0.
|
|
87
|
-
"@miden-sdk/node-darwin-x64": "0.
|
|
88
|
-
"@miden-sdk/node-linux-x64-gnu": "0.
|
|
86
|
+
"@miden-sdk/node-darwin-arm64": "0.16.0-alpha.1",
|
|
87
|
+
"@miden-sdk/node-darwin-x64": "0.16.0-alpha.1",
|
|
88
|
+
"@miden-sdk/node-linux-x64-gnu": "0.16.0-alpha.1"
|
|
89
89
|
},
|
|
90
90
|
"scripts": {
|
|
91
91
|
"build-rust-client-js": "pnpm --filter web_store run build",
|