@aztec/aztec.js 0.0.1-commit.f295ac2 → 0.0.1-commit.fc805bf
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/dest/account/account.d.ts +25 -40
- package/dest/account/account.d.ts.map +1 -1
- package/dest/account/account.js +19 -47
- package/dest/account/account_contract.d.ts +7 -8
- package/dest/account/account_contract.d.ts.map +1 -1
- package/dest/account/account_with_secret_key.d.ts +18 -7
- package/dest/account/account_with_secret_key.d.ts.map +1 -1
- package/dest/account/account_with_secret_key.js +21 -4
- package/dest/account/index.d.ts +3 -2
- package/dest/account/index.d.ts.map +1 -1
- package/dest/account/index.js +2 -0
- package/dest/account/signerless_account.d.ts +5 -6
- package/dest/account/signerless_account.d.ts.map +1 -1
- package/dest/account/signerless_account.js +8 -11
- package/dest/api/account.d.ts +2 -4
- package/dest/api/account.d.ts.map +1 -1
- package/dest/api/account.js +1 -3
- package/dest/api/authorization.d.ts +2 -2
- package/dest/api/authorization.d.ts.map +1 -1
- package/dest/api/authorization.js +1 -1
- package/dest/api/block.d.ts +2 -2
- package/dest/api/block.d.ts.map +1 -1
- package/dest/api/block.js +1 -1
- package/dest/api/contract.d.ts +16 -10
- package/dest/api/contract.d.ts.map +1 -1
- package/dest/api/contract.js +14 -8
- package/dest/api/keys.d.ts +1 -1
- package/dest/api/keys.js +1 -1
- package/dest/api/node.d.ts +8 -4
- package/dest/api/node.d.ts.map +1 -1
- package/dest/api/node.js +7 -3
- package/dest/api/tx.d.ts +2 -2
- package/dest/api/tx.d.ts.map +1 -1
- package/dest/api/tx.js +1 -1
- package/dest/api/wallet.d.ts +3 -2
- package/dest/api/wallet.d.ts.map +1 -1
- package/dest/api/wallet.js +2 -1
- package/dest/contract/base_contract_interaction.d.ts +8 -10
- package/dest/contract/base_contract_interaction.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.js +5 -17
- package/dest/contract/deploy_method.d.ts +63 -16
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +36 -19
- package/dest/contract/interaction_options.d.ts +42 -5
- package/dest/contract/interaction_options.d.ts.map +1 -1
- package/dest/contract/interaction_options.js +8 -1
- package/dest/contract/protocol_contracts/auth-registry.d.ts +1 -10
- package/dest/contract/protocol_contracts/auth-registry.d.ts.map +1 -1
- package/dest/contract/protocol_contracts/auth-registry.js +97 -467
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts +2 -11
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -1
- package/dest/contract/protocol_contracts/contract-class-registry.js +10 -422
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts +2 -11
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts.map +1 -1
- package/dest/contract/protocol_contracts/contract-instance-registry.js +80 -482
- package/dest/contract/protocol_contracts/fee-juice.d.ts +1 -10
- package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -1
- package/dest/contract/protocol_contracts/fee-juice.js +14 -412
- package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts +3 -3
- package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts.map +1 -1
- package/dest/contract/protocol_contracts/multi-call-entrypoint.js +13 -14
- package/dest/contract/protocol_contracts/public-checks.d.ts +3 -3
- package/dest/contract/protocol_contracts/public-checks.d.ts.map +1 -1
- package/dest/contract/protocol_contracts/public-checks.js +13 -22
- package/dest/contract/wait_for_proven.js +1 -1
- package/dest/contract/wait_opts.d.ts +16 -0
- package/dest/contract/wait_opts.d.ts.map +1 -0
- package/dest/contract/wait_opts.js +5 -0
- package/dest/utils/authwit.d.ts +8 -6
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +5 -9
- package/dest/utils/node.d.ts +12 -1
- package/dest/utils/node.d.ts.map +1 -1
- package/dest/utils/node.js +46 -0
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts +5 -8
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -1
- package/dest/wallet/account_entrypoint_meta_payment_method.js +28 -43
- package/dest/wallet/account_manager.d.ts +1 -7
- package/dest/wallet/account_manager.d.ts.map +1 -1
- package/dest/wallet/account_manager.js +5 -11
- package/dest/wallet/capabilities.d.ts +444 -0
- package/dest/wallet/capabilities.d.ts.map +1 -0
- package/dest/wallet/capabilities.js +3 -0
- package/dest/wallet/deploy_account_method.d.ts +34 -6
- package/dest/wallet/deploy_account_method.d.ts.map +1 -1
- package/dest/wallet/deploy_account_method.js +7 -5
- package/dest/wallet/index.d.ts +2 -1
- package/dest/wallet/index.d.ts.map +1 -1
- package/dest/wallet/index.js +1 -0
- package/dest/wallet/wallet.d.ts +1358 -20
- package/dest/wallet/wallet.d.ts.map +1 -1
- package/dest/wallet/wallet.js +136 -5
- package/package.json +9 -9
- package/src/account/account.ts +34 -58
- package/src/account/account_contract.ts +6 -7
- package/src/account/account_with_secret_key.ts +33 -8
- package/src/account/index.ts +2 -1
- package/src/account/signerless_account.ts +13 -12
- package/src/api/account.ts +9 -3
- package/src/api/authorization.ts +1 -0
- package/src/api/block.ts +1 -1
- package/src/api/contract.ts +22 -7
- package/src/api/keys.ts +2 -2
- package/src/api/node.ts +7 -3
- package/src/api/tx.ts +2 -0
- package/src/api/wallet.ts +43 -0
- package/src/contract/base_contract_interaction.ts +27 -15
- package/src/contract/deploy_method.ts +115 -23
- package/src/contract/interaction_options.ts +49 -4
- package/src/contract/protocol_contracts/auth-registry.ts +45 -236
- package/src/contract/protocol_contracts/contract-class-registry.ts +3 -204
- package/src/contract/protocol_contracts/contract-instance-registry.ts +34 -233
- package/src/contract/protocol_contracts/fee-juice.ts +4 -202
- package/src/contract/protocol_contracts/multi-call-entrypoint.ts +6 -12
- package/src/contract/protocol_contracts/public-checks.ts +6 -14
- package/src/contract/wait_for_proven.ts +1 -1
- package/src/contract/wait_opts.ts +21 -0
- package/src/utils/authwit.ts +19 -7
- package/src/utils/node.ts +62 -0
- package/src/wallet/account_entrypoint_meta_payment_method.ts +28 -60
- package/src/wallet/account_manager.ts +5 -13
- package/src/wallet/capabilities.ts +491 -0
- package/src/wallet/deploy_account_method.ts +37 -13
- package/src/wallet/index.ts +1 -0
- package/src/wallet/wallet.ts +149 -14
- package/dest/account/interface.d.ts +0 -19
- package/dest/account/interface.d.ts.map +0 -1
- package/dest/account/interface.js +0 -5
- package/dest/contract/deploy_sent_tx.d.ts +0 -48
- package/dest/contract/deploy_sent_tx.d.ts.map +0 -1
- package/dest/contract/deploy_sent_tx.js +0 -46
- package/dest/contract/sent_tx.d.ts +0 -50
- package/dest/contract/sent_tx.d.ts.map +0 -1
- package/dest/contract/sent_tx.js +0 -90
- package/src/account/interface.ts +0 -25
- package/src/contract/deploy_sent_tx.ts +0 -75
- package/src/contract/sent_tx.ts +0 -129
package/src/contract/sent_tx.ts
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
2
|
-
import { retryUntil } from '@aztec/foundation/retry';
|
|
3
|
-
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
4
|
-
import { TxHash, type TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
5
|
-
|
|
6
|
-
import type { Wallet } from '../wallet/wallet.js';
|
|
7
|
-
|
|
8
|
-
/** Options related to waiting for a tx. */
|
|
9
|
-
export type WaitOpts = {
|
|
10
|
-
/** The amount of time to ignore TxStatus.DROPPED receipts (in seconds) due to the presumption that it is being propagated by the p2p network. Defaults to 5. */
|
|
11
|
-
ignoreDroppedReceiptsFor?: number;
|
|
12
|
-
/** The maximum time (in seconds) to wait for the transaction to be mined. Defaults to 60. */
|
|
13
|
-
timeout?: number;
|
|
14
|
-
/** The time interval (in seconds) between retries to fetch the transaction receipt. Defaults to 1. */
|
|
15
|
-
interval?: number;
|
|
16
|
-
/** Whether to accept a revert as a status code for the tx when waiting for it. If false, will throw if the tx reverts. */
|
|
17
|
-
dontThrowOnRevert?: boolean;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export const DefaultWaitOpts: WaitOpts = {
|
|
21
|
-
ignoreDroppedReceiptsFor: 5,
|
|
22
|
-
timeout: 300,
|
|
23
|
-
interval: 1,
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* The SentTx class represents a sent transaction through the PXE (or directly to a node) providing methods to fetch
|
|
28
|
-
* its hash, receipt, and mining status.
|
|
29
|
-
*/
|
|
30
|
-
export class SentTx {
|
|
31
|
-
protected sendTxPromise: Promise<void>;
|
|
32
|
-
protected sendTxError?: Error;
|
|
33
|
-
protected txHash?: TxHash;
|
|
34
|
-
|
|
35
|
-
constructor(
|
|
36
|
-
protected walletOrNode: Wallet | AztecNode,
|
|
37
|
-
sendTx: () => Promise<TxHash>,
|
|
38
|
-
) {
|
|
39
|
-
const { promise, resolve } = promiseWithResolvers<void>();
|
|
40
|
-
this.sendTxPromise = promise;
|
|
41
|
-
sendTx()
|
|
42
|
-
.then(txHash => {
|
|
43
|
-
this.txHash = txHash;
|
|
44
|
-
resolve();
|
|
45
|
-
})
|
|
46
|
-
.catch(err => {
|
|
47
|
-
this.sendTxError = err;
|
|
48
|
-
// Calling resolve instead of reject here because we want to throw the error when getTxHash is called.
|
|
49
|
-
resolve();
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Retrieves the transaction hash of the SentTx instance.
|
|
55
|
-
* The function internally awaits for the 'txHashPromise' to resolve, and then returns the resolved transaction hash.
|
|
56
|
-
*
|
|
57
|
-
* @returns A promise that resolves to the transaction hash of the SentTx instance.
|
|
58
|
-
* TODO(#7717): Don't throw here.
|
|
59
|
-
*/
|
|
60
|
-
public async getTxHash(): Promise<TxHash> {
|
|
61
|
-
// Make sure sendTx has been resolved, which can be triggered when it returns a txHash or when it throws an error.
|
|
62
|
-
await this.sendTxPromise;
|
|
63
|
-
|
|
64
|
-
// If sendTx threw an error, throw it.
|
|
65
|
-
if (this.sendTxError) {
|
|
66
|
-
throw this.sendTxError;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// sendTx returned a txHash if it's been resolved and no error was set.
|
|
70
|
-
return Promise.resolve(this.txHash!);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Retrieve the transaction receipt associated with the current SentTx instance.
|
|
75
|
-
* The function fetches the transaction hash using 'getTxHash' and then queries
|
|
76
|
-
* the PXE to get the corresponding transaction receipt.
|
|
77
|
-
*
|
|
78
|
-
* @returns A promise that resolves to a TxReceipt object representing the fetched transaction receipt.
|
|
79
|
-
*/
|
|
80
|
-
public async getReceipt(): Promise<TxReceipt> {
|
|
81
|
-
const txHash = await this.getTxHash();
|
|
82
|
-
return await this.walletOrNode.getTxReceipt(txHash);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Awaits for a tx to be mined and returns the receipt. Throws if tx is not mined.
|
|
87
|
-
* @param opts - Options for configuring the waiting for the tx to be mined.
|
|
88
|
-
* @returns The transaction receipt.
|
|
89
|
-
*/
|
|
90
|
-
public async wait(opts?: WaitOpts): Promise<TxReceipt> {
|
|
91
|
-
const receipt = await this.waitForReceipt(opts);
|
|
92
|
-
if (receipt.status !== TxStatus.SUCCESS && !opts?.dontThrowOnRevert) {
|
|
93
|
-
throw new Error(
|
|
94
|
-
`Transaction ${(await this.getTxHash()).toString()} was ${receipt.status}. Reason: ${receipt.error ?? 'unknown'}`,
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
return receipt;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
protected async waitForReceipt(opts?: WaitOpts): Promise<TxReceipt> {
|
|
101
|
-
const txHash = await this.getTxHash();
|
|
102
|
-
const startTime = Date.now();
|
|
103
|
-
const ignoreDroppedReceiptsFor = opts?.ignoreDroppedReceiptsFor ?? DefaultWaitOpts.ignoreDroppedReceiptsFor;
|
|
104
|
-
|
|
105
|
-
return await retryUntil(
|
|
106
|
-
async () => {
|
|
107
|
-
const txReceipt = await this.walletOrNode.getTxReceipt(txHash);
|
|
108
|
-
// If receipt is not yet available, try again
|
|
109
|
-
if (txReceipt.status === TxStatus.PENDING) {
|
|
110
|
-
return undefined;
|
|
111
|
-
}
|
|
112
|
-
// If the tx was "dropped", either return it or ignore based on timing.
|
|
113
|
-
// We can ignore it at first because the transaction may have been sent to node 1, and now we're asking node 2 for the receipt.
|
|
114
|
-
// If we don't allow a short grace period, we could incorrectly return a TxReceipt with status DROPPED.
|
|
115
|
-
if (txReceipt.status === TxStatus.DROPPED) {
|
|
116
|
-
const elapsedSeconds = (Date.now() - startTime) / 1000;
|
|
117
|
-
if (!ignoreDroppedReceiptsFor || elapsedSeconds > ignoreDroppedReceiptsFor) {
|
|
118
|
-
return txReceipt;
|
|
119
|
-
}
|
|
120
|
-
return undefined;
|
|
121
|
-
}
|
|
122
|
-
return txReceipt;
|
|
123
|
-
},
|
|
124
|
-
'isMined',
|
|
125
|
-
opts?.timeout ?? DefaultWaitOpts.timeout,
|
|
126
|
-
opts?.interval ?? DefaultWaitOpts.interval,
|
|
127
|
-
);
|
|
128
|
-
}
|
|
129
|
-
}
|