Skip to content

Commit ce5d771

Browse files
authored
Merge pull request #141 from 0xMiden/keinberger/chore/web-client-fix-remaining-tut-v12
chore: update remaining web client tutorials to v12
2 parents e94ff51 + b425464 commit ce5d771

File tree

4 files changed

+232
-192
lines changed

4 files changed

+232
-192
lines changed

docs/src/web-client/creating_multiple_notes_tutorial.md

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -131,17 +131,9 @@ export async function multiSendWithDelegatedProver(): Promise<void> {
131131
AccountId,
132132
NoteType,
133133
TransactionProver,
134-
NoteInputs,
135134
Note,
136135
NoteAssets,
137-
NoteRecipient,
138-
Word,
139-
OutputNotesArray,
140-
NoteExecutionHint,
141-
NoteTag,
142-
NoteExecutionMode,
143-
NoteMetadata,
144-
FeltArray,
136+
OutputNoteArray,
145137
Felt,
146138
FungibleAsset,
147139
TransactionRequestBuilder,
@@ -166,7 +158,7 @@ Add the code snippet below to the `multiSendWithDelegatedProver` function. This
166158
```ts
167159
// ── Creating new account ──────────────────────────────────────────────────────
168160
console.log("Creating account for Alice…");
169-
const alice = await client.newWallet(AccountStorageMode.public(), true);
161+
const alice = await client.newWallet(AccountStorageMode.public(), true, 0);
170162
console.log("Alice accout ID:", alice.id().toString());
171163

172164
// ── Creating new faucet ──────────────────────────────────────────────────────
@@ -176,40 +168,51 @@ const faucet = await client.newFaucet(
176168
"MID",
177169
8,
178170
BigInt(1_000_000),
171+
0,
179172
);
180173
console.log("Faucet ID:", faucet.id().toString());
181174

182175
// ── mint 10 000 MID to Alice ──────────────────────────────────────────────────────
183-
await client.submitTransaction(
184-
await client.newTransaction(
176+
{
177+
const txResult = await client.executeTransaction(
185178
faucet.id(),
186179
client.newMintTransactionRequest(
187180
alice.id(),
188181
faucet.id(),
189182
NoteType.Public,
190183
BigInt(10_000),
191184
),
192-
),
193-
prover,
194-
);
185+
);
186+
const proven = await client.proveTransaction(txResult, prover);
187+
const submissionHeight = await client.submitProvenTransaction(
188+
proven,
189+
txResult,
190+
);
191+
await client.applyTransaction(txResult, submissionHeight);
195192

196-
console.log("waiting for settlement");
197-
await new Promise((r) => setTimeout(r, 7_000));
198-
await client.syncState();
193+
console.log("waiting for settlement");
194+
await new Promise((r) => setTimeout(r, 7_000));
195+
await client.syncState();
196+
}
199197

200198
// ── consume the freshly minted notes ──────────────────────────────────────────────
201199
const noteIds = (await client.getConsumableNotes(alice.id())).map((rec) =>
202200
rec.inputNoteRecord().id().toString(),
203201
);
204202

205-
await client.submitTransaction(
206-
await client.newTransaction(
203+
{
204+
const txResult = await client.executeTransaction(
207205
alice.id(),
208206
client.newConsumeTransactionRequest(noteIds),
209-
),
210-
prover,
211-
);
212-
await client.syncState();
207+
);
208+
const proven = await client.proveTransaction(txResult, prover);
209+
await client.syncState();
210+
const submissionHeight = await client.submitProvenTransaction(
211+
proven,
212+
txResult,
213+
);
214+
await client.applyTransaction(txResult, submissionHeight);
215+
}
213216
```
214217

215218
## Step 5 — Build and Create P2ID notes
@@ -228,7 +231,7 @@ const assets = new NoteAssets([new FungibleAsset(faucet.id(), BigInt(100))]);
228231

229232
const p2idNotes = recipientAddresses.map((addr) => {
230233
const receiverAccountId = AccountId.fromHex(addr);
231-
let note = Note.createP2IDNote(
234+
const note = Note.createP2IDNote(
232235
alice.id(),
233236
receiverAccountId,
234237
assets,
@@ -240,16 +243,13 @@ const p2idNotes = recipientAddresses.map((addr) => {
240243
});
241244

242245
// ── create all P2ID notes ───────────────────────────────────────────────────────────────
243-
let transaction = await client.newTransaction(
246+
await client.submitNewTransaction(
244247
alice.id(),
245248
new TransactionRequestBuilder()
246-
.withOwnOutputNotes(new OutputNotesArray(p2idNotes))
249+
.withOwnOutputNotes(new OutputNoteArray(p2idNotes))
247250
.build(),
248251
);
249252

250-
// ── submit tx ───────────────────────────────────────────────────────────────
251-
await client.submitTransaction(transaction, prover);
252-
253253
console.log("All notes created ✅");
254254
```
255255

@@ -274,17 +274,9 @@ export async function multiSendWithDelegatedProver(): Promise<void> {
274274
AccountId,
275275
NoteType,
276276
TransactionProver,
277-
NoteInputs,
278277
Note,
279278
NoteAssets,
280-
NoteRecipient,
281-
Word,
282-
OutputNotesArray,
283-
NoteExecutionHint,
284-
NoteTag,
285-
NoteExecutionMode,
286-
NoteMetadata,
287-
FeltArray,
279+
OutputNoteArray,
288280
Felt,
289281
FungibleAsset,
290282
TransactionRequestBuilder,
@@ -302,7 +294,7 @@ export async function multiSendWithDelegatedProver(): Promise<void> {
302294

303295
// ── Creating new account ──────────────────────────────────────────────────────
304296
console.log("Creating account for Alice…");
305-
const alice = await client.newWallet(AccountStorageMode.public(), true);
297+
const alice = await client.newWallet(AccountStorageMode.public(), true, 0);
306298
console.log("Alice accout ID:", alice.id().toString());
307299

308300
// ── Creating new faucet ──────────────────────────────────────────────────────
@@ -312,40 +304,51 @@ export async function multiSendWithDelegatedProver(): Promise<void> {
312304
"MID",
313305
8,
314306
BigInt(1_000_000),
307+
0,
315308
);
316309
console.log("Faucet ID:", faucet.id().toString());
317310

318311
// ── mint 10 000 MID to Alice ──────────────────────────────────────────────────────
319-
await client.submitTransaction(
320-
await client.newTransaction(
312+
{
313+
const txResult = await client.executeTransaction(
321314
faucet.id(),
322315
client.newMintTransactionRequest(
323316
alice.id(),
324317
faucet.id(),
325318
NoteType.Public,
326319
BigInt(10_000),
327320
),
328-
),
329-
prover,
330-
);
321+
);
322+
const proven = await client.proveTransaction(txResult, prover);
323+
const submissionHeight = await client.submitProvenTransaction(
324+
proven,
325+
txResult,
326+
);
327+
await client.applyTransaction(txResult, submissionHeight);
331328

332-
console.log("waiting for settlement");
333-
await new Promise((r) => setTimeout(r, 7_000));
334-
await client.syncState();
329+
console.log("waiting for settlement");
330+
await new Promise((r) => setTimeout(r, 7_000));
331+
await client.syncState();
332+
}
335333

336334
// ── consume the freshly minted notes ──────────────────────────────────────────────
337335
const noteIds = (await client.getConsumableNotes(alice.id())).map((rec) =>
338336
rec.inputNoteRecord().id().toString(),
339337
);
340338

341-
await client.submitTransaction(
342-
await client.newTransaction(
339+
{
340+
const txResult = await client.executeTransaction(
343341
alice.id(),
344342
client.newConsumeTransactionRequest(noteIds),
345-
),
346-
prover,
347-
);
348-
await client.syncState();
343+
);
344+
const proven = await client.proveTransaction(txResult, prover);
345+
await client.syncState();
346+
const submissionHeight = await client.submitProvenTransaction(
347+
proven,
348+
txResult,
349+
);
350+
await client.applyTransaction(txResult, submissionHeight);
351+
}
349352

350353
// ── build 3 P2ID notes (100 MID each) ─────────────────────────────────────────────
351354
const recipientAddresses = [
@@ -358,7 +361,7 @@ export async function multiSendWithDelegatedProver(): Promise<void> {
358361

359362
const p2idNotes = recipientAddresses.map((addr) => {
360363
const receiverAccountId = AccountId.fromHex(addr);
361-
let note = Note.createP2IDNote(
364+
const note = Note.createP2IDNote(
362365
alice.id(),
363366
receiverAccountId,
364367
assets,
@@ -370,16 +373,13 @@ export async function multiSendWithDelegatedProver(): Promise<void> {
370373
});
371374

372375
// ── create all P2ID notes ───────────────────────────────────────────────────────────────
373-
let transaction = await client.newTransaction(
376+
await client.submitNewTransaction(
374377
alice.id(),
375378
new TransactionRequestBuilder()
376-
.withOwnOutputNotes(new OutputNotesArray(p2idNotes))
379+
.withOwnOutputNotes(new OutputNoteArray(p2idNotes))
377380
.build(),
378381
);
379382

380-
// ── submit tx ───────────────────────────────────────────────────────────────
381-
await client.submitTransaction(transaction, prover);
382-
383383
console.log("All notes created ✅");
384384
}
385385
```

0 commit comments

Comments
 (0)