@miden-sdk/miden-sdk 0.15.3 → 0.15.5
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 +85 -0
- package/dist/mt/{Cargo-D2qNRrNR.js → Cargo-C001gt8g.js} +587 -90
- package/dist/mt/Cargo-C001gt8g.js.map +1 -0
- package/dist/mt/api-types.d.ts +189 -0
- package/dist/mt/assets/miden_client_web.wasm +0 -0
- package/dist/mt/crates/miden_client_web.d.ts +153 -3
- package/dist/mt/docs-entry.d.ts +3 -0
- package/dist/mt/eager.js +1 -1
- package/dist/mt/index.d.ts +3 -0
- package/dist/mt/index.js +302 -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-D2qNRrNR-n_GEbq73.js → Cargo-C001gt8g-B8wBADUI.js} +587 -90
- package/dist/mt/workers/Cargo-C001gt8g-B8wBADUI.js.map +1 -0
- package/dist/mt/workers/assets/miden_client_web.wasm +0 -0
- package/dist/mt/workers/web-client-methods-worker.js +589 -90
- 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-BP7-0qVT.js → Cargo-CR1mzjgg.js} +593 -98
- package/dist/st/Cargo-CR1mzjgg.js.map +1 -0
- package/dist/st/api-types.d.ts +189 -0
- package/dist/st/assets/miden_client_web.wasm +0 -0
- package/dist/st/crates/miden_client_web.d.ts +153 -3
- package/dist/st/docs-entry.d.ts +3 -0
- package/dist/st/eager.js +1 -1
- package/dist/st/index.d.ts +3 -0
- package/dist/st/index.js +302 -13
- package/dist/st/index.js.map +1 -1
- package/dist/st/wasm.js +1 -1
- package/dist/st/workers/{Cargo-BP7-0qVT-CmfAy6bf.js → Cargo-CR1mzjgg-DeDmKA4W.js} +593 -98
- package/dist/st/workers/Cargo-CR1mzjgg-DeDmKA4W.js.map +1 -0
- package/dist/st/workers/assets/miden_client_web.wasm +0 -0
- package/dist/st/workers/web-client-methods-worker.js +595 -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 +4 -0
- package/js/resources/transactions.js +289 -12
- package/js/standalone.js +61 -0
- package/package.json +4 -4
- package/dist/mt/Cargo-D2qNRrNR.js.map +0 -1
- package/dist/mt/workers/Cargo-D2qNRrNR-n_GEbq73.js.map +0 -1
- package/dist/st/Cargo-BP7-0qVT.js.map +0 -1
- package/dist/st/workers/Cargo-BP7-0qVT-CmfAy6bf.js.map +0 -1
package/dist/mt/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import loadWasm from './wasm.js';
|
|
2
|
-
export { Account, AccountArray, AccountBuilder, AccountBuilderResult, AccountCode, AccountComponent, AccountComponentCode, AccountDelta, AccountFile, AccountHeader, AccountId, AccountIdArray, AccountInterface, AccountProof, AccountReader, AccountStatus, AccountStorage, AccountStorageDelta, AccountStorageMode, AccountStorageRequirements, AccountVaultDelta, Address, AdviceInputs, AdviceMap, AssetVault, AuthFalcon512RpoMultisigConfig, AuthSecretKey, BasicFungibleFaucetComponent, BlockHeader, CodeBuilder, CommittedNote, ConsumableNoteRecord, Endpoint, ExecutedTransaction, Felt, FeltArray, FetchedAccount, FetchedNote, FlattenedU8Vec, ForeignAccount, ForeignAccountArray, FungibleAsset, FungibleAssetDelta, FungibleAssetDeltaItem, GetProceduresResultItem, InputNote, InputNoteRecord, InputNoteState, InputNotes, IntoUnderlyingByteSource, IntoUnderlyingSink, IntoUnderlyingSource, JsAccountUpdate, JsSettingMutation, JsStateSyncUpdate, JsStorageMapEntry, JsStorageSlot, JsVaultAsset, Library, MerklePath, NetworkId, NetworkNoteStatusInfo, NetworkType, Note, NoteAndArgs, NoteAndArgsArray, NoteArray, NoteAssets, NoteAttachment, NoteAttachmentScheme, NoteConsumability, NoteConsumptionStatus, NoteDetails, NoteDetailsAndTag, NoteDetailsAndTagArray, NoteExecutionHint, NoteExportFormat, NoteFile, NoteFilter, NoteFilterTypes, NoteHeader, NoteId, NoteIdAndArgs, NoteIdAndArgsArray, NoteInclusionProof, NoteLocation, NoteMetadata, NoteRecipient, NoteRecipientArray, NoteScript, NoteStorage, NoteSyncBlock, NoteSyncInfo, NoteTag, NoteType, OutputNote, OutputNoteArray, OutputNoteRecord, OutputNoteState, OutputNotes, Package, PartialNote, Poseidon2, ProcedureThreshold, Program, ProvenTransaction, PswapLineageRecord, PswapLineageState, PublicKey, RpcClient, Rpo256, SerializedInputNoteData, SerializedOutputNoteData, SerializedTransactionData, Signature, SigningInputs, SigningInputsType, SlotAndKeys, SparseMerklePath, StorageMap, StorageMapEntry, StorageMapEntryJs, StorageMapInfo, StorageMapUpdate, StorageSlot, StorageSlotArray, SyncSummary, TestUtils, TokenSymbol, TransactionArgs, TransactionFilter, TransactionId, TransactionProver, TransactionRecord, TransactionRequest, TransactionRequestBuilder, TransactionResult, TransactionScript, TransactionScriptInputPair, TransactionScriptInputPairArray, TransactionStatus, TransactionStoreUpdate, TransactionSummary, WebClient, WebKeystoreApi, Word, createAuthFalcon512RpoMultisig, exportStore, importStore, initSync, initThreadPool, mtProbeAsync, mtProbeSync, parallelSumBench, rayonThreadCount, sequentialSumBench, setupLogging, wbg_rayon_PoolBuilder, wbg_rayon_start_worker } from './Cargo-
|
|
2
|
+
export { Account, AccountArray, AccountBuilder, AccountBuilderResult, AccountCode, AccountComponent, AccountComponentCode, AccountDelta, AccountFile, AccountHeader, AccountId, AccountIdArray, AccountInterface, AccountProof, AccountReader, AccountStatus, AccountStorage, AccountStorageDelta, AccountStorageMode, AccountStorageRequirements, AccountVaultDelta, Address, AdviceInputs, AdviceMap, AssetVault, AuthFalcon512RpoMultisigConfig, AuthSecretKey, BasicFungibleFaucetComponent, BlockHeader, CodeBuilder, CommittedNote, ConsumableNoteRecord, Endpoint, EthAddress, ExecutedTransaction, Felt, FeltArray, FetchedAccount, FetchedNote, FlattenedU8Vec, ForeignAccount, ForeignAccountArray, FungibleAsset, FungibleAssetDelta, FungibleAssetDeltaItem, GetProceduresResultItem, InputNote, InputNoteRecord, InputNoteState, InputNotes, IntoUnderlyingByteSource, IntoUnderlyingSink, IntoUnderlyingSource, JsAccountUpdate, JsSettingMutation, JsStateSyncUpdate, JsStorageMapEntry, JsStorageSlot, JsVaultAsset, Library, MerklePath, NetworkAccountTarget, NetworkId, NetworkNoteStatusInfo, NetworkType, Note, NoteAndArgs, NoteAndArgsArray, NoteArray, NoteAssets, NoteAttachment, NoteAttachmentScheme, NoteConsumability, NoteConsumptionStatus, NoteDetails, NoteDetailsAndTag, NoteDetailsAndTagArray, NoteExecutionHint, NoteExportFormat, NoteFile, NoteFilter, NoteFilterTypes, NoteHeader, NoteId, NoteIdAndArgs, NoteIdAndArgsArray, NoteInclusionProof, NoteLocation, NoteMetadata, NoteRecipient, NoteRecipientArray, NoteScript, NoteStorage, NoteSyncBlock, NoteSyncInfo, NoteTag, NoteType, OutputNote, OutputNoteArray, OutputNoteRecord, OutputNoteState, OutputNotes, Package, PartialNote, Poseidon2, ProcedureThreshold, Program, ProvenTransaction, PswapLineageRecord, PswapLineageState, PublicKey, RpcClient, Rpo256, SerializedInputNoteData, SerializedOutputNoteData, SerializedTransactionData, Signature, SigningInputs, SigningInputsType, SlotAndKeys, SparseMerklePath, StorageMap, StorageMapEntry, StorageMapEntryJs, StorageMapInfo, StorageMapUpdate, StorageSlot, StorageSlotArray, SyncSummary, TestUtils, TokenSymbol, TransactionArgs, TransactionFilter, TransactionId, TransactionProver, TransactionRecord, TransactionRequest, TransactionRequestBuilder, TransactionResult, TransactionScript, TransactionScriptInputPair, TransactionScriptInputPairArray, TransactionStatus, TransactionStoreUpdate, TransactionSummary, WebClient, WebKeystoreApi, Word, createAuthFalcon512RpoMultisig, exportStore, importStore, initSync, initThreadPool, mtProbeAsync, mtProbeSync, parallelSumBench, rayonThreadCount, sequentialSumBench, setupLogging, wbg_rayon_PoolBuilder, wbg_rayon_start_worker } from './Cargo-C001gt8g.js';
|
|
3
3
|
|
|
4
4
|
const WorkerAction = Object.freeze({
|
|
5
5
|
INIT: "init",
|
|
@@ -622,6 +622,97 @@ class TransactionsResource {
|
|
|
622
622
|
return { txId, note: null, result };
|
|
623
623
|
}
|
|
624
624
|
|
|
625
|
+
/**
|
|
626
|
+
* Builds a Public custom-script note carrying a NetworkAccountTarget
|
|
627
|
+
* attachment, submits it as an own output note, and optionally waits for
|
|
628
|
+
* confirmation. Provide exactly one of `recipient` or `script`.
|
|
629
|
+
*/
|
|
630
|
+
async createNetworkNote(opts) {
|
|
631
|
+
this.#client.assertNotTerminated();
|
|
632
|
+
const wasm = await this.#getWasm();
|
|
633
|
+
|
|
634
|
+
if (opts.recipient && opts.script) {
|
|
635
|
+
throw new Error(
|
|
636
|
+
"createNetworkNote requires exactly one of `recipient` or `script`, not both."
|
|
637
|
+
);
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
const senderId = resolveAccountRef(opts.account, wasm);
|
|
641
|
+
|
|
642
|
+
const target =
|
|
643
|
+
opts.target instanceof wasm.NetworkAccountTarget
|
|
644
|
+
? opts.target
|
|
645
|
+
: new wasm.NetworkAccountTarget(
|
|
646
|
+
resolveAccountRef(opts.target, wasm),
|
|
647
|
+
opts.executionHint
|
|
648
|
+
);
|
|
649
|
+
|
|
650
|
+
const noteAssets = opts.assets
|
|
651
|
+
? new wasm.NoteAssets(
|
|
652
|
+
(Array.isArray(opts.assets) ? opts.assets : [opts.assets]).map(
|
|
653
|
+
(a) =>
|
|
654
|
+
new wasm.FungibleAsset(
|
|
655
|
+
resolveAccountRef(a.token, wasm),
|
|
656
|
+
BigInt(a.amount)
|
|
657
|
+
)
|
|
658
|
+
)
|
|
659
|
+
)
|
|
660
|
+
: new wasm.NoteAssets();
|
|
661
|
+
|
|
662
|
+
const metadata = new wasm.NoteMetadata(
|
|
663
|
+
senderId,
|
|
664
|
+
wasm.NoteType.Public,
|
|
665
|
+
wasm.NoteTag.withAccountTarget(target.targetId())
|
|
666
|
+
);
|
|
667
|
+
|
|
668
|
+
let recipient = opts.recipient;
|
|
669
|
+
if (!recipient) {
|
|
670
|
+
if (!opts.script) {
|
|
671
|
+
throw new Error(
|
|
672
|
+
"createNetworkNote requires either `recipient` or `script`."
|
|
673
|
+
);
|
|
674
|
+
}
|
|
675
|
+
const storage = new wasm.NoteStorage(
|
|
676
|
+
new wasm.FeltArray(
|
|
677
|
+
(opts.inputs ?? []).map((value) => new wasm.Felt(value))
|
|
678
|
+
)
|
|
679
|
+
);
|
|
680
|
+
recipient = wasm.NoteRecipient.fromScript(opts.script, storage);
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
const attachments = [target.toAttachment()];
|
|
684
|
+
if (opts.attachment) {
|
|
685
|
+
attachments.push(new wasm.NoteAttachment(opts.attachment));
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
const note = wasm.Note.withAttachments(
|
|
689
|
+
noteAssets,
|
|
690
|
+
metadata,
|
|
691
|
+
recipient,
|
|
692
|
+
attachments
|
|
693
|
+
);
|
|
694
|
+
|
|
695
|
+
// NoteArray constructor consumes its elements; use push(¬e) to keep
|
|
696
|
+
// `note` valid so we can return it to the caller.
|
|
697
|
+
const ownOutputs = new wasm.NoteArray();
|
|
698
|
+
ownOutputs.push(note);
|
|
699
|
+
const request = new wasm.TransactionRequestBuilder()
|
|
700
|
+
.withOwnOutputNotes(ownOutputs)
|
|
701
|
+
.build();
|
|
702
|
+
|
|
703
|
+
const { txId, result } = await this.#submitOrSubmitWithProver(
|
|
704
|
+
senderId,
|
|
705
|
+
request,
|
|
706
|
+
opts.prover
|
|
707
|
+
);
|
|
708
|
+
|
|
709
|
+
if (opts.waitForConfirmation) {
|
|
710
|
+
await this.waitFor(txId.toHex(), { timeout: opts.timeout });
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
return { txId, note, result };
|
|
714
|
+
}
|
|
715
|
+
|
|
625
716
|
async mint(opts) {
|
|
626
717
|
this.#client.assertNotTerminated();
|
|
627
718
|
const wasm = await this.#getWasm();
|
|
@@ -640,6 +731,24 @@ class TransactionsResource {
|
|
|
640
731
|
return { txId, result };
|
|
641
732
|
}
|
|
642
733
|
|
|
734
|
+
async bridge(opts) {
|
|
735
|
+
this.#client.assertNotTerminated();
|
|
736
|
+
const wasm = await this.#getWasm();
|
|
737
|
+
const { accountId, request } = await this.#buildB2AggRequest(opts, wasm);
|
|
738
|
+
|
|
739
|
+
const { txId, result } = await this.#submitOrSubmitWithProver(
|
|
740
|
+
accountId,
|
|
741
|
+
request,
|
|
742
|
+
opts.prover
|
|
743
|
+
);
|
|
744
|
+
|
|
745
|
+
if (opts.waitForConfirmation) {
|
|
746
|
+
await this.waitFor(txId.toHex(), { timeout: opts.timeout });
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
return { txId, result };
|
|
750
|
+
}
|
|
751
|
+
|
|
643
752
|
async consume(opts) {
|
|
644
753
|
this.#client.assertNotTerminated();
|
|
645
754
|
const wasm = await this.#getWasm();
|
|
@@ -802,6 +911,10 @@ class TransactionsResource {
|
|
|
802
911
|
({ accountId, request } = await this.#buildMintRequest(opts, wasm));
|
|
803
912
|
break;
|
|
804
913
|
}
|
|
914
|
+
case "bridge": {
|
|
915
|
+
({ accountId, request } = await this.#buildB2AggRequest(opts, wasm));
|
|
916
|
+
break;
|
|
917
|
+
}
|
|
805
918
|
case "consume": {
|
|
806
919
|
({ accountId, request } = await this.#buildConsumeRequest(opts, wasm));
|
|
807
920
|
break;
|
|
@@ -846,6 +959,163 @@ class TransactionsResource {
|
|
|
846
959
|
async execute(opts) {
|
|
847
960
|
this.#client.assertNotTerminated();
|
|
848
961
|
const wasm = await this.#getWasm();
|
|
962
|
+
const { accountId, request } = this.#buildExecuteRequest(opts, wasm);
|
|
963
|
+
|
|
964
|
+
const { txId, result } = await this.#submitOrSubmitWithProver(
|
|
965
|
+
accountId,
|
|
966
|
+
request,
|
|
967
|
+
opts.prover
|
|
968
|
+
);
|
|
969
|
+
|
|
970
|
+
if (opts.waitForConfirmation) {
|
|
971
|
+
await this.waitFor(txId.toHex(), { timeout: opts.timeout });
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
return { txId, result };
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
/**
|
|
978
|
+
* Submit a heterogeneous batch of operations against a single account. All
|
|
979
|
+
* operations are executed, proven individually and as a batch, and submitted
|
|
980
|
+
* atomically — either every tx in the batch lands or none does.
|
|
981
|
+
*
|
|
982
|
+
* @param {BatchOptions} opts - Batch options including the account, operations array, and confirmation settings.
|
|
983
|
+
* @returns {Promise<BatchSubmitResult>} The block number the batch was accepted into.
|
|
984
|
+
*/
|
|
985
|
+
async batch(opts) {
|
|
986
|
+
this.#client.assertNotTerminated();
|
|
987
|
+
const wasm = await this.#getWasm();
|
|
988
|
+
|
|
989
|
+
if (!opts || !opts.account) {
|
|
990
|
+
throw new Error("batch: `account` is required");
|
|
991
|
+
}
|
|
992
|
+
if (!Array.isArray(opts.operations) || opts.operations.length === 0) {
|
|
993
|
+
throw new Error("batch: `operations` must be a non-empty array");
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
// Build each TransactionRequest. Per-op builders all use the batch-level
|
|
997
|
+
// `account` — V1 only supports same-account batches, mirroring the Rust
|
|
998
|
+
// constraint. We forward `opts.account` into each per-op options object so
|
|
999
|
+
// the existing builders' `resolveAccountRef` produces fresh AccountIds
|
|
1000
|
+
// when needed.
|
|
1001
|
+
const requests = [];
|
|
1002
|
+
for (let i = 0; i < opts.operations.length; i++) {
|
|
1003
|
+
const op = opts.operations[i];
|
|
1004
|
+
let built;
|
|
1005
|
+
switch (op?.kind) {
|
|
1006
|
+
case "send":
|
|
1007
|
+
built = await this.#buildSendRequest(
|
|
1008
|
+
{ ...op, account: opts.account },
|
|
1009
|
+
wasm
|
|
1010
|
+
);
|
|
1011
|
+
break;
|
|
1012
|
+
case "mint":
|
|
1013
|
+
built = await this.#buildMintRequest(
|
|
1014
|
+
{ ...op, account: opts.account },
|
|
1015
|
+
wasm
|
|
1016
|
+
);
|
|
1017
|
+
break;
|
|
1018
|
+
case "consume":
|
|
1019
|
+
built = await this.#buildConsumeRequest(
|
|
1020
|
+
{ ...op, account: opts.account },
|
|
1021
|
+
wasm
|
|
1022
|
+
);
|
|
1023
|
+
break;
|
|
1024
|
+
case "swap":
|
|
1025
|
+
built = await this.#buildSwapRequest(
|
|
1026
|
+
{ ...op, account: opts.account },
|
|
1027
|
+
wasm
|
|
1028
|
+
);
|
|
1029
|
+
break;
|
|
1030
|
+
case "execute":
|
|
1031
|
+
built = this.#buildExecuteRequest(
|
|
1032
|
+
{ ...op, account: opts.account },
|
|
1033
|
+
wasm
|
|
1034
|
+
);
|
|
1035
|
+
break;
|
|
1036
|
+
case "custom":
|
|
1037
|
+
if (!op.request) {
|
|
1038
|
+
throw new Error(
|
|
1039
|
+
`batch: operation[${i}] of kind "custom" is missing \`request\``
|
|
1040
|
+
);
|
|
1041
|
+
}
|
|
1042
|
+
built = { request: op.request };
|
|
1043
|
+
break;
|
|
1044
|
+
default:
|
|
1045
|
+
throw new Error(
|
|
1046
|
+
`batch: operation[${i}] has unknown kind "${op?.kind}"`
|
|
1047
|
+
);
|
|
1048
|
+
}
|
|
1049
|
+
requests.push(built.request);
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
return this.submitBatch(opts.account, requests, opts);
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
/**
|
|
1056
|
+
* Submit pre-built TransactionRequests as an atomic batch. Lower-level
|
|
1057
|
+
* counterpart of `batch()` — for callers that already have built requests in
|
|
1058
|
+
* hand. Equivalent to `submit()` but plural.
|
|
1059
|
+
*
|
|
1060
|
+
* @param {AccountRef} account - The account executing the batch.
|
|
1061
|
+
* @param {TransactionRequest[]} requests - Pre-built transaction requests.
|
|
1062
|
+
* @param {object} [options] - Optional settings (waitForConfirmation, timeout).
|
|
1063
|
+
* The batch is proved with the client's configured prover; the V1 batch API
|
|
1064
|
+
* has no per-call prover override.
|
|
1065
|
+
* @returns {Promise<BatchSubmitResult>} The block number the batch was accepted into.
|
|
1066
|
+
*/
|
|
1067
|
+
async submitBatch(account, requests, options) {
|
|
1068
|
+
this.#client.assertNotTerminated();
|
|
1069
|
+
const wasm = await this.#getWasm();
|
|
1070
|
+
|
|
1071
|
+
if (!Array.isArray(requests) || requests.length === 0) {
|
|
1072
|
+
throw new Error("submitBatch: `requests` must be a non-empty array");
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
const accountId = resolveAccountRef(account, wasm);
|
|
1076
|
+
const blockNumber = await this.#inner.submitNewTransactionBatch(
|
|
1077
|
+
accountId,
|
|
1078
|
+
requests.map((r) => r.serialize())
|
|
1079
|
+
);
|
|
1080
|
+
|
|
1081
|
+
if (options?.waitForConfirmation) {
|
|
1082
|
+
await this.#waitForBlock(blockNumber, options);
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
return { blockNumber };
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
/**
|
|
1089
|
+
* Polls until the local sync height reaches `blockNumber` or the timeout
|
|
1090
|
+
* expires. The Rust V1 batch API returns only a block number — there are no
|
|
1091
|
+
* per-tx ids to poll on, so we wait on the chain height instead.
|
|
1092
|
+
*
|
|
1093
|
+
* @param {number} blockNumber - The block height to wait for.
|
|
1094
|
+
* @param {object} [opts] - Polling options (timeout, interval).
|
|
1095
|
+
*/
|
|
1096
|
+
async #waitForBlock(blockNumber, opts) {
|
|
1097
|
+
const timeout = opts?.timeout ?? 60_000;
|
|
1098
|
+
const interval = opts?.interval ?? 5_000;
|
|
1099
|
+
const start = Date.now();
|
|
1100
|
+
|
|
1101
|
+
while (true) {
|
|
1102
|
+
if (timeout > 0 && Date.now() - start >= timeout) {
|
|
1103
|
+
throw new Error(
|
|
1104
|
+
`Batch confirmation timed out after ${timeout}ms (waiting for block ${blockNumber})`
|
|
1105
|
+
);
|
|
1106
|
+
}
|
|
1107
|
+
try {
|
|
1108
|
+
await this.#inner.syncStateWithTimeout(0);
|
|
1109
|
+
} catch {
|
|
1110
|
+
// sync may fail transiently; continue polling
|
|
1111
|
+
}
|
|
1112
|
+
const height = await this.#inner.getSyncHeight();
|
|
1113
|
+
if (height >= blockNumber) return;
|
|
1114
|
+
await new Promise((resolve) => setTimeout(resolve, interval));
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
#buildExecuteRequest(opts, wasm) {
|
|
849
1119
|
const accountId = resolveAccountRef(opts.account, wasm);
|
|
850
1120
|
|
|
851
1121
|
let builder = new wasm.TransactionRequestBuilder().withCustomScript(
|
|
@@ -873,18 +1143,7 @@ class TransactionsResource {
|
|
|
873
1143
|
);
|
|
874
1144
|
}
|
|
875
1145
|
|
|
876
|
-
|
|
877
|
-
const { txId, result } = await this.#submitOrSubmitWithProver(
|
|
878
|
-
accountId,
|
|
879
|
-
request,
|
|
880
|
-
opts.prover
|
|
881
|
-
);
|
|
882
|
-
|
|
883
|
-
if (opts.waitForConfirmation) {
|
|
884
|
-
await this.waitFor(txId.toHex(), { timeout: opts.timeout });
|
|
885
|
-
}
|
|
886
|
-
|
|
887
|
-
return { txId, result };
|
|
1146
|
+
return { accountId, request: builder.build() };
|
|
888
1147
|
}
|
|
889
1148
|
|
|
890
1149
|
async executeProgram(opts) {
|
|
@@ -1057,6 +1316,24 @@ class TransactionsResource {
|
|
|
1057
1316
|
return { accountId, request };
|
|
1058
1317
|
}
|
|
1059
1318
|
|
|
1319
|
+
async #buildB2AggRequest(opts, wasm) {
|
|
1320
|
+
const accountId = resolveAccountRef(opts.account, wasm);
|
|
1321
|
+
const bridgeAccountId = resolveAccountRef(opts.bridgeAccount, wasm);
|
|
1322
|
+
const faucetId = resolveAccountRef(opts.token, wasm);
|
|
1323
|
+
const amount = BigInt(opts.amount);
|
|
1324
|
+
const destinationAddress = wasm.EthAddress.fromHex(opts.destinationAddress);
|
|
1325
|
+
|
|
1326
|
+
const request = await this.#inner.newB2AggTransactionRequest(
|
|
1327
|
+
accountId,
|
|
1328
|
+
bridgeAccountId,
|
|
1329
|
+
faucetId,
|
|
1330
|
+
amount,
|
|
1331
|
+
opts.destinationNetwork,
|
|
1332
|
+
destinationAddress
|
|
1333
|
+
);
|
|
1334
|
+
return { accountId, request };
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1060
1337
|
async #buildConsumeRequest(opts, wasm) {
|
|
1061
1338
|
const accountId = resolveAccountRef(opts.account, wasm);
|
|
1062
1339
|
const noteInputs = Array.isArray(opts.notes) ? opts.notes : [opts.notes];
|
|
@@ -2487,6 +2764,17 @@ class StorageResult {
|
|
|
2487
2764
|
return this.#word.toFelts();
|
|
2488
2765
|
}
|
|
2489
2766
|
|
|
2767
|
+
/**
|
|
2768
|
+
* Returns all four elements of the stored Word as a BigUint64Array.
|
|
2769
|
+
* Pass-through to Word.toU64s() — ensures code that expects a Word-like
|
|
2770
|
+
* object (e.g., `result.toU64s()[0]`) works on StorageResult.
|
|
2771
|
+
* @returns {BigUint64Array}
|
|
2772
|
+
*/
|
|
2773
|
+
toU64s() {
|
|
2774
|
+
if (!this.#word) return new BigUint64Array();
|
|
2775
|
+
return this.#word.toU64s();
|
|
2776
|
+
}
|
|
2777
|
+
|
|
2490
2778
|
/**
|
|
2491
2779
|
* The first Felt of the stored Word.
|
|
2492
2780
|
* Returns the WASM Felt object — use .asInt() to get its BigInt value.
|
|
@@ -2639,6 +2927,7 @@ const SYNC_METHODS = new Set([
|
|
|
2639
2927
|
"buildSwapTag",
|
|
2640
2928
|
"createCodeBuilder",
|
|
2641
2929
|
"lastAuthError",
|
|
2930
|
+
"newB2AggTransactionRequest",
|
|
2642
2931
|
"newConsumeTransactionRequest",
|
|
2643
2932
|
"newMintTransactionRequest",
|
|
2644
2933
|
"newPswapCancelTransactionRequest",
|