@aztec/aztec.js 0.0.1-commit.24de95ac → 0.0.1-commit.3469e52
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 +26 -42
- package/dest/account/account.d.ts.map +1 -1
- package/dest/account/account.js +19 -47
- package/dest/account/account_contract.d.ts +9 -10
- package/dest/account/account_contract.d.ts.map +1 -1
- package/dest/account/account_with_secret_key.d.ts +20 -9
- 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 +4 -3
- package/dest/account/index.d.ts.map +1 -1
- package/dest/account/index.js +2 -0
- package/dest/account/signerless_account.d.ts +7 -9
- package/dest/account/signerless_account.d.ts.map +1 -1
- package/dest/account/signerless_account.js +8 -11
- package/dest/api/abi.d.ts +1 -1
- package/dest/api/account.d.ts +3 -4
- package/dest/api/account.d.ts.map +1 -1
- package/dest/api/account.js +2 -3
- package/dest/api/addresses.d.ts +1 -1
- 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 +3 -3
- package/dest/api/contract.d.ts.map +1 -1
- package/dest/api/contract.js +1 -1
- package/dest/api/crypto.d.ts +1 -1
- package/dest/api/deployment.d.ts +1 -1
- package/dest/api/eth_address.d.ts +1 -1
- package/dest/api/ethereum.d.ts +1 -1
- package/dest/api/events.d.ts +1 -1
- package/dest/api/fee.d.ts +1 -1
- package/dest/api/fee_testing.d.ts +1 -1
- package/dest/api/fields.d.ts +3 -2
- package/dest/api/fields.d.ts.map +1 -1
- package/dest/api/fields.js +2 -1
- package/dest/api/keys.d.ts +1 -1
- package/dest/api/log.d.ts +1 -1
- package/dest/api/messaging.d.ts +1 -1
- package/dest/api/node.d.ts +1 -1
- package/dest/api/note.d.ts +2 -2
- package/dest/api/note.d.ts.map +1 -1
- package/dest/api/note.js +1 -1
- package/dest/api/protocol.d.ts +7 -1
- package/dest/api/protocol.d.ts.map +1 -1
- package/dest/api/protocol.js +6 -0
- package/dest/api/trees.d.ts +1 -1
- 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/utils.d.ts +1 -1
- package/dest/api/wallet.d.ts +2 -3
- package/dest/api/wallet.d.ts.map +1 -1
- package/dest/api/wallet.js +1 -2
- package/dest/authorization/call_authorization_request.d.ts +2 -2
- package/dest/authorization/call_authorization_request.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.d.ts +2 -3
- package/dest/contract/base_contract_interaction.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.js +1 -1
- package/dest/contract/batch_call.d.ts +8 -9
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +54 -34
- package/dest/contract/checker.d.ts +1 -1
- package/dest/contract/contract.d.ts +2 -2
- package/dest/contract/contract.d.ts.map +1 -1
- package/dest/contract/contract.js +4 -5
- package/dest/contract/contract_base.d.ts +6 -10
- package/dest/contract/contract_base.d.ts.map +1 -1
- package/dest/contract/contract_base.js +5 -12
- package/dest/contract/contract_function_interaction.d.ts +3 -3
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.js +9 -6
- package/dest/contract/deploy_method.d.ts +9 -8
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +14 -11
- package/dest/contract/deploy_sent_tx.d.ts +12 -7
- package/dest/contract/deploy_sent_tx.d.ts.map +1 -1
- package/dest/contract/deploy_sent_tx.js +10 -4
- package/dest/contract/get_gas_limits.d.ts +1 -1
- package/dest/contract/interaction_options.d.ts +4 -4
- package/dest/contract/interaction_options.d.ts.map +1 -1
- package/dest/contract/interaction_options.js +4 -10
- package/dest/contract/protocol_contracts/auth-registry.d.ts +36 -0
- package/dest/contract/protocol_contracts/auth-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/auth-registry.js +976 -0
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts +35 -0
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/contract-class-registry.js +797 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts +31 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.js +871 -0
- package/dest/contract/protocol_contracts/fee-juice.d.ts +30 -0
- package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/fee-juice.js +840 -0
- package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts +34 -0
- package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/multi-call-entrypoint.js +576 -0
- package/dest/contract/protocol_contracts/public-checks.d.ts +26 -0
- package/dest/contract/protocol_contracts/public-checks.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/public-checks.js +592 -0
- package/dest/contract/sent_tx.d.ts +2 -3
- package/dest/contract/sent_tx.d.ts.map +1 -1
- package/dest/contract/sent_tx.js +1 -1
- package/dest/contract/wait_for_proven.d.ts +2 -2
- package/dest/contract/wait_for_proven.d.ts.map +1 -1
- package/dest/deployment/broadcast_function.d.ts +1 -1
- package/dest/deployment/broadcast_function.js +4 -4
- package/dest/deployment/contract_deployer.d.ts +1 -1
- package/dest/deployment/contract_deployer.d.ts.map +1 -1
- package/dest/deployment/contract_deployer.js +1 -1
- package/dest/deployment/publish_class.d.ts +1 -1
- package/dest/deployment/publish_class.js +3 -3
- package/dest/deployment/publish_instance.d.ts +2 -2
- package/dest/deployment/publish_instance.d.ts.map +1 -1
- package/dest/deployment/publish_instance.js +3 -3
- package/dest/ethereum/portal_manager.d.ts +7 -6
- package/dest/ethereum/portal_manager.d.ts.map +1 -1
- package/dest/ethereum/portal_manager.js +48 -22
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts +2 -2
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
- package/dest/fee/fee_juice_payment_method_with_claim.js +3 -3
- package/dest/fee/fee_payment_method.d.ts +2 -2
- package/dest/fee/fee_payment_method.d.ts.map +1 -1
- package/dest/fee/private_fee_payment_method.d.ts +2 -2
- package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/private_fee_payment_method.js +4 -4
- package/dest/fee/public_fee_payment_method.d.ts +2 -2
- package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/public_fee_payment_method.js +4 -4
- package/dest/fee/sponsored_fee_payment.d.ts +2 -2
- package/dest/fee/sponsored_fee_payment.d.ts.map +1 -1
- package/dest/fee/sponsored_fee_payment.js +2 -2
- package/dest/scripts/generate_protocol_contract_types.d.ts +2 -0
- package/dest/scripts/generate_protocol_contract_types.d.ts.map +1 -0
- package/dest/scripts/generate_protocol_contract_types.js +120 -0
- package/dest/utils/abi_types.d.ts +2 -2
- package/dest/utils/abi_types.d.ts.map +1 -1
- package/dest/utils/authwit.d.ts +9 -7
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +25 -14
- package/dest/utils/cross_chain.d.ts +2 -2
- package/dest/utils/cross_chain.d.ts.map +1 -1
- package/dest/utils/fee_juice.d.ts +2 -2
- package/dest/utils/fee_juice.js +2 -2
- package/dest/utils/field_compressed_string.d.ts +1 -1
- package/dest/utils/field_compressed_string.d.ts.map +1 -1
- package/dest/utils/field_compressed_string.js +1 -1
- package/dest/utils/node.d.ts +2 -2
- package/dest/utils/node.d.ts.map +1 -1
- package/dest/utils/pub_key.d.ts +2 -2
- package/dest/utils/pub_key.d.ts.map +1 -1
- package/dest/utils/pub_key.js +1 -1
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts +6 -9
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -1
- package/dest/wallet/account_entrypoint_meta_payment_method.js +29 -44
- package/dest/wallet/account_manager.d.ts +3 -9
- package/dest/wallet/account_manager.d.ts.map +1 -1
- package/dest/wallet/account_manager.js +6 -12
- package/dest/wallet/deploy_account_method.d.ts +20 -6
- package/dest/wallet/deploy_account_method.d.ts.map +1 -1
- package/dest/wallet/deploy_account_method.js +9 -7
- package/dest/wallet/index.d.ts +1 -2
- package/dest/wallet/index.d.ts.map +1 -1
- package/dest/wallet/index.js +0 -1
- package/dest/wallet/wallet.d.ts +273 -1499
- package/dest/wallet/wallet.d.ts.map +1 -1
- package/dest/wallet/wallet.js +71 -114
- package/package.json +16 -13
- package/src/account/account.ts +35 -60
- package/src/account/account_contract.ts +7 -8
- package/src/account/account_with_secret_key.ts +34 -9
- package/src/account/index.ts +3 -2
- package/src/account/signerless_account.ts +15 -15
- package/src/api/account.ts +10 -3
- package/src/api/authorization.ts +1 -0
- package/src/api/block.ts +1 -1
- package/src/api/contract.ts +2 -1
- package/src/api/fields.ts +2 -1
- package/src/api/note.ts +1 -1
- package/src/api/protocol.ts +7 -0
- package/src/api/tx.ts +2 -0
- package/src/api/wallet.ts +5 -9
- package/src/authorization/call_authorization_request.ts +1 -1
- package/src/contract/base_contract_interaction.ts +2 -3
- package/src/contract/batch_call.ts +67 -48
- package/src/contract/contract.ts +7 -5
- package/src/contract/contract_base.ts +5 -15
- package/src/contract/contract_function_interaction.ts +10 -11
- package/src/contract/deploy_method.ts +20 -18
- package/src/contract/deploy_sent_tx.ts +17 -10
- package/src/contract/interaction_options.ts +4 -10
- package/src/contract/protocol_contracts/auth-registry.ts +554 -0
- package/src/contract/protocol_contracts/contract-class-registry.ts +442 -0
- package/src/contract/protocol_contracts/contract-instance-registry.ts +502 -0
- package/src/contract/protocol_contracts/fee-juice.ts +466 -0
- package/src/contract/protocol_contracts/multi-call-entrypoint.ts +338 -0
- package/src/contract/protocol_contracts/public-checks.ts +324 -0
- package/src/contract/sent_tx.ts +2 -3
- package/src/deployment/broadcast_function.ts +4 -4
- package/src/deployment/contract_deployer.ts +3 -2
- package/src/deployment/publish_class.ts +3 -3
- package/src/deployment/publish_instance.ts +3 -6
- package/src/ethereum/portal_manager.ts +65 -34
- package/src/fee/fee_juice_payment_method_with_claim.ts +4 -2
- package/src/fee/fee_payment_method.ts +1 -1
- package/src/fee/private_fee_payment_method.ts +5 -3
- package/src/fee/public_fee_payment_method.ts +5 -3
- package/src/fee/sponsored_fee_payment.ts +3 -1
- package/src/scripts/generate_protocol_contract_types.ts +150 -0
- package/src/utils/abi_types.ts +1 -1
- package/src/utils/authwit.ts +24 -18
- package/src/utils/cross_chain.ts +1 -1
- package/src/utils/fee_juice.ts +2 -2
- package/src/utils/field_compressed_string.ts +1 -1
- package/src/utils/pub_key.ts +2 -2
- package/src/wallet/account_entrypoint_meta_payment_method.ts +29 -60
- package/src/wallet/account_manager.ts +7 -15
- package/src/wallet/deploy_account_method.ts +23 -13
- package/src/wallet/index.ts +0 -1
- package/src/wallet/wallet.ts +177 -142
- 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/protocol_contracts.d.ts +0 -9
- package/dest/contract/protocol_contracts.d.ts.map +0 -1
- package/dest/contract/protocol_contracts.js +0 -26
- package/dest/contract/unsafe_contract.d.ts +0 -15
- package/dest/contract/unsafe_contract.d.ts.map +0 -1
- package/dest/contract/unsafe_contract.js +0 -6
- package/dest/wallet/base_wallet.d.ts +0 -91
- package/dest/wallet/base_wallet.d.ts.map +0 -1
- package/dest/wallet/base_wallet.js +0 -238
- package/src/account/interface.ts +0 -25
- package/src/contract/protocol_contracts.ts +0 -35
- package/src/contract/unsafe_contract.ts +0 -19
- package/src/wallet/base_wallet.ts +0 -350
package/src/api/account.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {
|
|
2
|
+
type Account,
|
|
3
|
+
type AccountContract,
|
|
4
|
+
AccountWithSecretKey,
|
|
5
|
+
BaseAccount,
|
|
6
|
+
type AuthorizationProvider,
|
|
7
|
+
getAccountContractAddress,
|
|
8
|
+
type Salt,
|
|
9
|
+
} from '../account/index.js';
|
|
2
10
|
export type { AuthWitnessProvider, ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
11
|
+
export { ChainInfoSchema } from '@aztec/entrypoints/interfaces';
|
|
3
12
|
|
|
4
|
-
export { AccountWithSecretKey } from '../account/account_with_secret_key.js';
|
|
5
|
-
export { type Account, BaseAccount } from '../account/account.js';
|
|
6
13
|
export { SignerlessAccount } from '../account/signerless_account.js';
|
package/src/api/authorization.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
|
2
2
|
export {
|
|
3
3
|
SetPublicAuthwitContractInteraction,
|
|
4
4
|
type ContractFunctionInteractionCallIntent,
|
|
5
|
+
isContractFunctionInteractionCallIntent,
|
|
5
6
|
getMessageHashFromIntent,
|
|
6
7
|
computeAuthWitMessageHash,
|
|
7
8
|
computeInnerAuthWitHashFromAction,
|
package/src/api/block.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Body,
|
|
1
|
+
export { Body, L2BlockNew } from '@aztec/stdlib/block';
|
|
2
2
|
export { getTimestampRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
package/src/api/contract.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
17
|
* ```ts
|
|
18
|
-
* const contract =
|
|
18
|
+
* const contract = Contract.at(address, MyContractArtifact, wallet);
|
|
19
19
|
* await contract.methods.mint(1000, owner).send().wait();
|
|
20
20
|
* console.log(`Total supply is now ${await contract.methods.totalSupply().simulate()}`);
|
|
21
21
|
* ```
|
|
@@ -44,6 +44,7 @@ export {
|
|
|
44
44
|
type ProfileInteractionOptions,
|
|
45
45
|
type SimulateInteractionOptions,
|
|
46
46
|
type InteractionFeeOptions,
|
|
47
|
+
type GasSettingsOption,
|
|
47
48
|
toProfileOptions,
|
|
48
49
|
toSendOptions,
|
|
49
50
|
toSimulateOptions,
|
package/src/api/fields.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { Fr, Fq } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
export { GrumpkinScalar, Point } from '@aztec/foundation/curves/grumpkin';
|
package/src/api/note.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { Comparator, Note } from '@aztec/stdlib/note';
|
package/src/api/protocol.ts
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
export { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
2
2
|
export { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
3
|
+
|
|
4
|
+
export { AuthRegistryContract } from '../contract/protocol_contracts/auth-registry.js';
|
|
5
|
+
export { ContractClassRegistryContract } from '../contract/protocol_contracts/contract-class-registry.js';
|
|
6
|
+
export { ContractInstanceRegistryContract } from '../contract/protocol_contracts/contract-instance-registry.js';
|
|
7
|
+
export { FeeJuiceContract } from '../contract/protocol_contracts/fee-juice.js';
|
|
8
|
+
export { MultiCallEntrypointContract } from '../contract/protocol_contracts/multi-call-entrypoint.js';
|
|
9
|
+
export { PublicChecksContract } from '../contract/protocol_contracts/public-checks.js';
|
package/src/api/tx.ts
CHANGED
package/src/api/wallet.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
export {
|
|
2
2
|
type Aliased,
|
|
3
|
-
type ContractInstanceAndArtifact,
|
|
4
|
-
type UserFeeOptions,
|
|
5
3
|
type SimulateOptions,
|
|
6
4
|
type ProfileOptions,
|
|
7
5
|
type SendOptions,
|
|
@@ -11,25 +9,23 @@ export {
|
|
|
11
9
|
type BatchedMethodResultWrapper,
|
|
12
10
|
type BatchResults,
|
|
13
11
|
type Wallet,
|
|
14
|
-
|
|
12
|
+
type PrivateEvent,
|
|
13
|
+
type PrivateEventFilter,
|
|
15
14
|
FunctionCallSchema,
|
|
16
15
|
ExecutionPayloadSchema,
|
|
17
|
-
|
|
16
|
+
GasSettingsOptionSchema,
|
|
18
17
|
WalletSimulationFeeOptionSchema,
|
|
19
18
|
SendOptionsSchema,
|
|
20
19
|
SimulateOptionsSchema,
|
|
21
20
|
ProfileOptionsSchema,
|
|
22
|
-
InstanceDataSchema,
|
|
23
21
|
MessageHashOrIntentSchema,
|
|
24
22
|
BatchedMethodSchema,
|
|
25
|
-
ContractMetadataSchema,
|
|
26
|
-
ContractClassMetadataSchema,
|
|
27
23
|
EventMetadataDefinitionSchema,
|
|
24
|
+
PrivateEventSchema,
|
|
25
|
+
PrivateEventFilterSchema,
|
|
28
26
|
WalletSchema,
|
|
29
27
|
} from '../wallet/wallet.js';
|
|
30
28
|
|
|
31
|
-
export { type FeeOptions, BaseWallet } from '../wallet/base_wallet.js';
|
|
32
|
-
|
|
33
29
|
export { AccountManager } from '../wallet/account_manager.js';
|
|
34
30
|
|
|
35
31
|
export { type DeployAccountOptions, DeployAccountMethod } from '../wallet/deploy_account_method.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Fr } from '@aztec/foundation/
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import { FieldReader } from '@aztec/foundation/serialize';
|
|
3
3
|
import { AuthorizationSelector, FunctionSelector } from '@aztec/stdlib/abi';
|
|
4
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
2
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
2
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
4
|
-
import type { Capsule } from '@aztec/stdlib/tx';
|
|
3
|
+
import type { Capsule, ExecutionPayload } from '@aztec/stdlib/tx';
|
|
5
4
|
|
|
6
5
|
import type { Wallet } from '../wallet/wallet.js';
|
|
7
6
|
import { type RequestInteractionOptions, type SendInteractionOptions, toSendOptions } from './interaction_options.js';
|
|
@@ -42,7 +41,7 @@ export abstract class BaseContractInteraction {
|
|
|
42
41
|
// docs:end:send
|
|
43
42
|
const sendTx = async () => {
|
|
44
43
|
const executionPayload = await this.request(options);
|
|
45
|
-
const sendOptions =
|
|
44
|
+
const sendOptions = toSendOptions(options);
|
|
46
45
|
return this.wallet.sendTx(executionPayload, sendOptions);
|
|
47
46
|
};
|
|
48
47
|
return new SentTx(this.wallet, sendTx);
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/entrypoints/payload';
|
|
2
1
|
import { type FunctionCall, FunctionType, decodeFromAbi } from '@aztec/stdlib/abi';
|
|
2
|
+
import {
|
|
3
|
+
ExecutionPayload,
|
|
4
|
+
TxSimulationResult,
|
|
5
|
+
UtilitySimulationResult,
|
|
6
|
+
mergeExecutionPayloads,
|
|
7
|
+
} from '@aztec/stdlib/tx';
|
|
3
8
|
|
|
4
|
-
import type { Wallet } from '../wallet/wallet.js';
|
|
9
|
+
import type { BatchedMethod, Wallet } from '../wallet/wallet.js';
|
|
5
10
|
import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
6
11
|
import {
|
|
7
12
|
type RequestInteractionOptions,
|
|
@@ -10,6 +15,7 @@ import {
|
|
|
10
15
|
} from './interaction_options.js';
|
|
11
16
|
|
|
12
17
|
/** A batch of function calls to be sent as a single transaction through a wallet. */
|
|
18
|
+
// docs:start:batch_call_class
|
|
13
19
|
export class BatchCall extends BaseContractInteraction {
|
|
14
20
|
constructor(
|
|
15
21
|
wallet: Wallet,
|
|
@@ -17,6 +23,7 @@ export class BatchCall extends BaseContractInteraction {
|
|
|
17
23
|
) {
|
|
18
24
|
super(wallet);
|
|
19
25
|
}
|
|
26
|
+
// docs:end:batch_call_class
|
|
20
27
|
|
|
21
28
|
/**
|
|
22
29
|
* Returns an execution request that represents this operation.
|
|
@@ -35,13 +42,12 @@ export class BatchCall extends BaseContractInteraction {
|
|
|
35
42
|
}
|
|
36
43
|
|
|
37
44
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* @
|
|
44
|
-
* @returns The result of the transaction as returned by the contract function.
|
|
45
|
+
* Simulates the batch, supporting private, public and utility functions. Although this is a single
|
|
46
|
+
* interaction with the wallet, private and public functions will be grouped into a single ExecutionPayload
|
|
47
|
+
* that the wallet will simulate as a single transaction. Utility function calls will simply be executed
|
|
48
|
+
* one by one.
|
|
49
|
+
* @param options - An optional object containing additional configuration for the interaction.
|
|
50
|
+
* @returns The results of all the interactions that make up the batch
|
|
45
51
|
*/
|
|
46
52
|
public async simulate(options: SimulateInteractionOptions): Promise<any> {
|
|
47
53
|
const { indexedExecutionPayloads, utility } = (await this.getExecutionPayloads()).reduce<{
|
|
@@ -70,52 +76,65 @@ export class BatchCall extends BaseContractInteraction {
|
|
|
70
76
|
{ indexedExecutionPayloads: [], utility: [], publicIndex: 0, privateIndex: 0 },
|
|
71
77
|
);
|
|
72
78
|
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
const batchRequests: BatchedMethod[] = [];
|
|
80
|
+
|
|
81
|
+
// Add utility calls to batch
|
|
82
|
+
for (const [call] of utility) {
|
|
83
|
+
batchRequests.push({
|
|
84
|
+
name: 'simulateUtility' as const,
|
|
85
|
+
args: [call, options?.authWitnesses],
|
|
86
|
+
});
|
|
87
|
+
}
|
|
81
88
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
// Add tx simulation to batch if there are any private/public calls
|
|
90
|
+
if (indexedExecutionPayloads.length > 0) {
|
|
91
|
+
const payloads = indexedExecutionPayloads.map(([request]) => request);
|
|
92
|
+
const combinedPayload = mergeExecutionPayloads(payloads);
|
|
93
|
+
const executionPayload = new ExecutionPayload(
|
|
94
|
+
combinedPayload.calls,
|
|
95
|
+
combinedPayload.authWitnesses.concat(options.authWitnesses ?? []),
|
|
96
|
+
combinedPayload.capsules.concat(options.capsules ?? []),
|
|
97
|
+
combinedPayload.extraHashedArgs,
|
|
98
|
+
);
|
|
91
99
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
100
|
+
batchRequests.push({
|
|
101
|
+
name: 'simulateTx' as const,
|
|
102
|
+
args: [executionPayload, toSimulateOptions(options)],
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const batchResults = batchRequests.length > 0 ? await this.wallet.batch(batchRequests) : [];
|
|
98
107
|
|
|
99
108
|
const results: any[] = [];
|
|
100
109
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
110
|
+
// Process utility results (they come first in batch results)
|
|
111
|
+
for (let i = 0; i < utility.length; i++) {
|
|
112
|
+
const [call, resultIndex] = utility[i];
|
|
113
|
+
const wrappedResult = batchResults[i];
|
|
114
|
+
if (wrappedResult.name === 'simulateUtility') {
|
|
115
|
+
const rawReturnValues = (wrappedResult.result as UtilitySimulationResult).result;
|
|
116
|
+
results[resultIndex] = rawReturnValues ? decodeFromAbi(call.returnTypes, rawReturnValues) : [];
|
|
117
|
+
}
|
|
118
|
+
}
|
|
105
119
|
|
|
106
|
-
if
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
120
|
+
// Process tx simulation result (it comes last if present)
|
|
121
|
+
if (indexedExecutionPayloads.length > 0) {
|
|
122
|
+
const txResultWrapper = batchResults[utility.length];
|
|
123
|
+
if (txResultWrapper.name === 'simulateTx') {
|
|
124
|
+
const simulatedTx = txResultWrapper.result as TxSimulationResult;
|
|
125
|
+
indexedExecutionPayloads.forEach(([request, callIndex, resultIndex]) => {
|
|
126
|
+
const call = request.calls[0];
|
|
127
|
+
// As account entrypoints are private, for private functions we retrieve the return values from the first nested call
|
|
128
|
+
// since we're interested in the first set of values AFTER the account entrypoint
|
|
129
|
+
// For public functions we retrieve the first values directly from the public output.
|
|
130
|
+
const rawReturnValues =
|
|
131
|
+
call.type == FunctionType.PRIVATE
|
|
132
|
+
? simulatedTx.getPrivateReturnValues()?.nested?.[resultIndex].values
|
|
133
|
+
: simulatedTx.getPublicReturnValues()?.[resultIndex].values;
|
|
116
134
|
|
|
117
|
-
|
|
118
|
-
|
|
135
|
+
results[callIndex] = rawReturnValues ? decodeFromAbi(call.returnTypes, rawReturnValues) : [];
|
|
136
|
+
});
|
|
137
|
+
}
|
|
119
138
|
}
|
|
120
139
|
|
|
121
140
|
return results;
|
package/src/contract/contract.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
2
2
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
3
4
|
import { PublicKeys } from '@aztec/stdlib/keys';
|
|
4
5
|
|
|
5
6
|
import type { Wallet } from '../wallet/wallet.js';
|
|
@@ -21,9 +22,8 @@ export class Contract extends ContractBase {
|
|
|
21
22
|
* @param wallet - The wallet to use when interacting with the contract.
|
|
22
23
|
* @returns A promise that resolves to a new Contract instance.
|
|
23
24
|
*/
|
|
24
|
-
public static
|
|
25
|
-
|
|
26
|
-
return new Contract(instance, artifact, wallet);
|
|
25
|
+
public static at(address: AztecAddress, artifact: ContractArtifact, wallet: Wallet): Contract {
|
|
26
|
+
return new Contract(address, artifact, wallet);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/**
|
|
@@ -34,7 +34,8 @@ export class Contract extends ContractBase {
|
|
|
34
34
|
* @param constructorName - The name of the constructor function to call.
|
|
35
35
|
*/
|
|
36
36
|
public static deploy(wallet: Wallet, artifact: ContractArtifact, args: any[], constructorName?: string) {
|
|
37
|
-
const postDeployCtor = (
|
|
37
|
+
const postDeployCtor = (instance: ContractInstanceWithAddress, wallet: Wallet) =>
|
|
38
|
+
Contract.at(instance.address, artifact, wallet);
|
|
38
39
|
return new DeployMethod(PublicKeys.default(), wallet, artifact, postDeployCtor, args, constructorName);
|
|
39
40
|
}
|
|
40
41
|
|
|
@@ -54,7 +55,8 @@ export class Contract extends ContractBase {
|
|
|
54
55
|
args: any[],
|
|
55
56
|
constructorName?: string,
|
|
56
57
|
) {
|
|
57
|
-
const postDeployCtor = (
|
|
58
|
+
const postDeployCtor = (instance: ContractInstanceWithAddress, wallet: Wallet) =>
|
|
59
|
+
Contract.at(instance.address, artifact, wallet);
|
|
58
60
|
return new DeployMethod(publicKeys, wallet, artifact, postDeployCtor, args, constructorName);
|
|
59
61
|
}
|
|
60
62
|
}
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
FunctionSelector,
|
|
6
6
|
getAllFunctionAbis,
|
|
7
7
|
} from '@aztec/stdlib/abi';
|
|
8
|
-
import
|
|
8
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
9
|
|
|
10
10
|
import type { Wallet } from '../wallet/wallet.js';
|
|
11
11
|
import { ContractFunctionInteraction } from './contract_function_interaction.js';
|
|
@@ -38,8 +38,8 @@ export class ContractBase {
|
|
|
38
38
|
public methods: { [name: string]: ContractMethod } = {};
|
|
39
39
|
|
|
40
40
|
protected constructor(
|
|
41
|
-
/** The
|
|
42
|
-
public readonly
|
|
41
|
+
/** The contract's address. */
|
|
42
|
+
public readonly address: AztecAddress,
|
|
43
43
|
/** The Application Binary Interface for the contract. */
|
|
44
44
|
public readonly artifact: ContractArtifact,
|
|
45
45
|
/** The wallet used for interacting with this contract. */
|
|
@@ -47,7 +47,7 @@ export class ContractBase {
|
|
|
47
47
|
) {
|
|
48
48
|
getAllFunctionAbis(artifact).forEach((f: FunctionAbi) => {
|
|
49
49
|
const interactionFunction = (...args: any[]) => {
|
|
50
|
-
return new ContractFunctionInteraction(this.wallet, this.
|
|
50
|
+
return new ContractFunctionInteraction(this.wallet, this.address, f, args);
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
this.methods[f.name] = Object.assign(interactionFunction, {
|
|
@@ -62,22 +62,12 @@ export class ContractBase {
|
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
/** Address of the contract. */
|
|
66
|
-
public get address() {
|
|
67
|
-
return this.instance.address;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/** Partial address of the contract. */
|
|
71
|
-
public get partialAddress() {
|
|
72
|
-
return computePartialAddress(this.instance);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
65
|
/**
|
|
76
66
|
* Creates a new instance of the contract wrapper attached to a different wallet.
|
|
77
67
|
* @param wallet - Wallet to use for sending txs.
|
|
78
68
|
* @returns A new contract instance.
|
|
79
69
|
*/
|
|
80
70
|
public withWallet(wallet: Wallet): this {
|
|
81
|
-
return new ContractBase(this.
|
|
71
|
+
return new ContractBase(this.address, this.artifact, wallet) as this;
|
|
82
72
|
}
|
|
83
73
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/entrypoints/payload';
|
|
2
1
|
import { type FunctionAbi, FunctionSelector, FunctionType, decodeFromAbi, encodeArguments } from '@aztec/stdlib/abi';
|
|
3
2
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
4
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
4
|
import { type Capsule, type HashedValues, type TxProfileResult, collectOffchainEffects } from '@aztec/stdlib/tx';
|
|
5
|
+
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
6
6
|
|
|
7
7
|
import type { Wallet } from '../wallet/wallet.js';
|
|
8
8
|
import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
@@ -103,25 +103,24 @@ export class ContractFunctionInteraction extends BaseContractInteraction {
|
|
|
103
103
|
): Promise<SimulationReturn<typeof options.includeMetadata>> {
|
|
104
104
|
// docs:end:simulate
|
|
105
105
|
if (this.functionDao.functionType == FunctionType.UTILITY) {
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
);
|
|
106
|
+
const call = await this.getFunctionCall();
|
|
107
|
+
const utilityResult = await this.wallet.simulateUtility(call, options.authWitnesses ?? []);
|
|
108
|
+
|
|
109
|
+
// Decode the raw field elements to the actual return type
|
|
110
|
+
const returnValue = utilityResult.result ? decodeFromAbi(this.functionDao.returnTypes, utilityResult.result) : [];
|
|
112
111
|
|
|
113
112
|
if (options.includeMetadata) {
|
|
114
113
|
return {
|
|
115
114
|
stats: utilityResult.stats,
|
|
116
|
-
result:
|
|
115
|
+
result: returnValue,
|
|
117
116
|
};
|
|
118
117
|
} else {
|
|
119
|
-
return
|
|
118
|
+
return returnValue;
|
|
120
119
|
}
|
|
121
120
|
}
|
|
122
121
|
|
|
123
122
|
const executionPayload = await this.request(options);
|
|
124
|
-
const simulatedTx = await this.wallet.simulateTx(executionPayload,
|
|
123
|
+
const simulatedTx = await this.wallet.simulateTx(executionPayload, toSimulateOptions(options));
|
|
125
124
|
|
|
126
125
|
let rawReturnValues;
|
|
127
126
|
if (this.functionDao.functionType == FunctionType.PRIVATE) {
|
|
@@ -168,7 +167,7 @@ export class ContractFunctionInteraction extends BaseContractInteraction {
|
|
|
168
167
|
}
|
|
169
168
|
|
|
170
169
|
const executionPayload = await this.request(options);
|
|
171
|
-
return await this.wallet.profileTx(executionPayload,
|
|
170
|
+
return await this.wallet.profileTx(executionPayload, toProfileOptions(options));
|
|
172
171
|
}
|
|
173
172
|
|
|
174
173
|
/**
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
2
|
import { type ContractArtifact, type FunctionAbi, type FunctionArtifact, getInitializer } from '@aztec/stdlib/abi';
|
|
4
3
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
5
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -11,12 +10,12 @@ import {
|
|
|
11
10
|
} from '@aztec/stdlib/contract';
|
|
12
11
|
import type { PublicKeys } from '@aztec/stdlib/keys';
|
|
13
12
|
import { type Capsule, type TxProfileResult, collectOffchainEffects } from '@aztec/stdlib/tx';
|
|
13
|
+
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
14
14
|
|
|
15
15
|
import { publishContractClass } from '../deployment/publish_class.js';
|
|
16
16
|
import { publishInstance } from '../deployment/publish_instance.js';
|
|
17
17
|
import type { Wallet } from '../wallet/wallet.js';
|
|
18
18
|
import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
19
|
-
import type { Contract } from './contract.js';
|
|
20
19
|
import type { ContractBase } from './contract_base.js';
|
|
21
20
|
import { ContractFunctionInteraction } from './contract_function_interaction.js';
|
|
22
21
|
import { DeploySentTx } from './deploy_sent_tx.js';
|
|
@@ -51,6 +50,8 @@ export type RequestDeployOptions = RequestInteractionOptions & {
|
|
|
51
50
|
skipInstancePublication?: boolean;
|
|
52
51
|
/** Skip contract initialization. */
|
|
53
52
|
skipInitialization?: boolean;
|
|
53
|
+
/** Skip contract registration in the wallet */
|
|
54
|
+
skipRegistration?: boolean;
|
|
54
55
|
};
|
|
55
56
|
|
|
56
57
|
/**
|
|
@@ -63,8 +64,6 @@ export type DeployOptions = Omit<RequestDeployOptions, 'deployer'> & {
|
|
|
63
64
|
*/
|
|
64
65
|
universalDeploy?: boolean;
|
|
65
66
|
} & Pick<SendInteractionOptions, 'from' | 'fee'>;
|
|
66
|
-
// docs:end:deploy_options
|
|
67
|
-
// TODO(@spalladino): Add unit tests for this class!
|
|
68
67
|
|
|
69
68
|
/**
|
|
70
69
|
* Options for simulating the deployment of a contract
|
|
@@ -96,7 +95,7 @@ export type SimulateDeployOptions = Omit<DeployOptions, 'fee'> & {
|
|
|
96
95
|
*
|
|
97
96
|
* Extends the BaseContractInteraction class.
|
|
98
97
|
*/
|
|
99
|
-
export class DeployMethod<TContract extends ContractBase =
|
|
98
|
+
export class DeployMethod<TContract extends ContractBase = ContractBase> extends BaseContractInteraction {
|
|
100
99
|
/** The contract instance to be deployed. */
|
|
101
100
|
private instance?: ContractInstanceWithAddress = undefined;
|
|
102
101
|
|
|
@@ -107,7 +106,7 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
107
106
|
private publicKeys: PublicKeys,
|
|
108
107
|
wallet: Wallet,
|
|
109
108
|
protected artifact: ContractArtifact,
|
|
110
|
-
protected postDeployCtor: (
|
|
109
|
+
protected postDeployCtor: (instance: ContractInstanceWithAddress, wallet: Wallet) => TContract,
|
|
111
110
|
private args: any[] = [],
|
|
112
111
|
constructorNameOrArtifact?: string | FunctionArtifact,
|
|
113
112
|
authWitnesses: AuthWitness[] = [],
|
|
@@ -125,7 +124,9 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
125
124
|
public async request(options?: RequestDeployOptions): Promise<ExecutionPayload> {
|
|
126
125
|
const publication = await this.getPublicationExecutionPayload(options);
|
|
127
126
|
|
|
128
|
-
|
|
127
|
+
if (!options?.skipRegistration) {
|
|
128
|
+
await this.wallet.registerContract(await this.getInstance(options), this.artifact);
|
|
129
|
+
}
|
|
129
130
|
|
|
130
131
|
const initialization = await this.getInitializationExecutionPayload(options);
|
|
131
132
|
const feeExecutionPayload = options?.fee?.paymentMethod
|
|
@@ -155,7 +156,7 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
155
156
|
public async register(options?: RequestDeployOptions): Promise<TContract> {
|
|
156
157
|
const instance = await this.getInstance(options);
|
|
157
158
|
await this.wallet.registerContract(instance, this.artifact);
|
|
158
|
-
return this.postDeployCtor(instance
|
|
159
|
+
return this.postDeployCtor(instance, this.wallet);
|
|
159
160
|
}
|
|
160
161
|
|
|
161
162
|
/**
|
|
@@ -183,16 +184,17 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
183
184
|
|
|
184
185
|
// Publish the contract class if it hasn't been published already.
|
|
185
186
|
if (!options?.skipClassPublication) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
`Skipping publication of already-registered contract class ${contractClass.id.toString()} for ${instance.address.toString()}`,
|
|
189
|
-
);
|
|
190
|
-
} else {
|
|
187
|
+
const classMetadata = await this.wallet.getContractClassMetadata(contractClass.id);
|
|
188
|
+
if (!classMetadata.isContractClassPubliclyRegistered) {
|
|
191
189
|
this.log.info(
|
|
192
190
|
`Creating request for publishing contract class ${contractClass.id.toString()} as part of deployment for ${instance.address.toString()}`,
|
|
193
191
|
);
|
|
194
192
|
const registerContractClassInteraction = await publishContractClass(this.wallet, this.artifact);
|
|
195
193
|
calls.push(await registerContractClassInteraction.request());
|
|
194
|
+
} else {
|
|
195
|
+
this.log.debug(
|
|
196
|
+
`Skipping contract class publication for ${contractClass.id.toString()} as it is already registered`,
|
|
197
|
+
);
|
|
196
198
|
}
|
|
197
199
|
}
|
|
198
200
|
|
|
@@ -201,7 +203,7 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
201
203
|
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/15596):
|
|
202
204
|
// Read the artifact, and if there are no public functions, warn the caller that publication of the
|
|
203
205
|
// contract instance is not necessary (until such time as they wish to update the instance (i.e. change its class_id)).
|
|
204
|
-
const deploymentInteraction =
|
|
206
|
+
const deploymentInteraction = publishInstance(this.wallet, instance);
|
|
205
207
|
calls.push(await deploymentInteraction.request());
|
|
206
208
|
}
|
|
207
209
|
|
|
@@ -239,7 +241,7 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
239
241
|
public override send(options: DeployOptions): DeploySentTx<TContract> {
|
|
240
242
|
const sendTx = async () => {
|
|
241
243
|
const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
|
|
242
|
-
const sendOptions =
|
|
244
|
+
const sendOptions = toSendOptions(options);
|
|
243
245
|
return this.wallet.sendTx(executionPayload, sendOptions);
|
|
244
246
|
};
|
|
245
247
|
this.log.debug(`Sent deployment tx of ${this.artifact.name} contract`);
|
|
@@ -274,7 +276,7 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
274
276
|
*/
|
|
275
277
|
public async simulate(options: SimulateDeployOptions): Promise<SimulationReturn<true>> {
|
|
276
278
|
const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
|
|
277
|
-
const simulatedTx = await this.wallet.simulateTx(executionPayload,
|
|
279
|
+
const simulatedTx = await this.wallet.simulateTx(executionPayload, toSimulateOptions(options));
|
|
278
280
|
|
|
279
281
|
const { gasLimits, teardownGasLimits } = getGasLimits(simulatedTx, options.fee?.estimatedGasPadding);
|
|
280
282
|
this.log.verbose(
|
|
@@ -297,7 +299,7 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
297
299
|
public async profile(options: DeployOptions & ProfileInteractionOptions): Promise<TxProfileResult> {
|
|
298
300
|
const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
|
|
299
301
|
return await this.wallet.profileTx(executionPayload, {
|
|
300
|
-
...
|
|
302
|
+
...toProfileOptions(options),
|
|
301
303
|
profileMode: options.profileMode,
|
|
302
304
|
skipProofGeneration: options.skipProofGeneration,
|
|
303
305
|
});
|