@aztec/aztec 0.77.0-testnet-ignition.29 → 0.77.0

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.
Files changed (34) hide show
  1. package/dest/cli/aztec_start_action.js +1 -1
  2. package/dest/cli/cmds/start_archiver.js +1 -1
  3. package/dest/cli/cmds/start_node.js +1 -1
  4. package/dest/cli/cmds/start_p2p_bootstrap.js +1 -1
  5. package/dest/index.d.ts +1 -1
  6. package/dest/index.d.ts.map +1 -1
  7. package/dest/index.js +1 -1
  8. package/dest/sandbox/banana_fpc.d.ts +11 -0
  9. package/dest/sandbox/banana_fpc.d.ts.map +1 -0
  10. package/dest/sandbox/banana_fpc.js +79 -0
  11. package/dest/sandbox/index.d.ts +5 -0
  12. package/dest/sandbox/index.d.ts.map +1 -0
  13. package/dest/sandbox/index.js +4 -0
  14. package/dest/{sandbox.d.ts → sandbox/sandbox.d.ts} +1 -4
  15. package/dest/sandbox/sandbox.d.ts.map +1 -0
  16. package/dest/{sandbox.js → sandbox/sandbox.js} +10 -64
  17. package/dest/sandbox/sponsored_fee_payment_method.d.ts +23 -0
  18. package/dest/sandbox/sponsored_fee_payment_method.d.ts.map +1 -0
  19. package/dest/sandbox/sponsored_fee_payment_method.js +36 -0
  20. package/dest/sandbox/sponsored_fpc.d.ts +6 -0
  21. package/dest/sandbox/sponsored_fpc.d.ts.map +1 -0
  22. package/dest/sandbox/sponsored_fpc.js +26 -0
  23. package/package.json +29 -29
  24. package/src/cli/aztec_start_action.ts +1 -1
  25. package/src/cli/cmds/start_archiver.ts +1 -1
  26. package/src/cli/cmds/start_node.ts +1 -1
  27. package/src/cli/cmds/start_p2p_bootstrap.ts +1 -1
  28. package/src/index.ts +7 -1
  29. package/src/sandbox/banana_fpc.ts +83 -0
  30. package/src/sandbox/index.ts +5 -0
  31. package/src/{sandbox.ts → sandbox/sandbox.ts} +13 -71
  32. package/src/sandbox/sponsored_fee_payment_method.ts +46 -0
  33. package/src/sandbox/sponsored_fpc.ts +38 -0
  34. package/dest/sandbox.d.ts.map +0 -1
@@ -5,7 +5,7 @@ import { getVersioningMiddleware } from '@aztec/stdlib/versioning';
5
5
  import { getOtelJsonRpcPropagationMiddleware } from '@aztec/telemetry-client';
6
6
  import { readFileSync } from 'fs';
7
7
  import { dirname, resolve } from 'path';
8
- import { createSandbox } from '../sandbox.js';
8
+ import { createSandbox } from '../sandbox/index.js';
9
9
  import { github, splash } from '../splash.js';
10
10
  import { extractNamespacedOptions, installSignalHandlers } from './util.js';
11
11
  import { getVersions } from './versioning.js';
@@ -22,7 +22,7 @@ import { extractRelevantOptions } from '../util.js';
22
22
  ...config
23
23
  };
24
24
  const storeLog = createLogger('archiver:lmdb');
25
- const store = await createStore('archiver', archiverConfig, storeLog);
25
+ const store = await createStore('archiver', KVArchiverDataStore.SCHEMA_VERSION, archiverConfig, storeLog);
26
26
  const archiverStore = new KVArchiverDataStore(store, archiverConfig.maxLogs);
27
27
  const telemetry = initTelemetryClient(getTelemetryClientConfig());
28
28
  // TODO(https://github.com/AztecProtocol/aztec-packages/issues/10056): place CL url in config here
@@ -6,7 +6,7 @@ import { P2PApiSchema } from '@aztec/stdlib/interfaces/server';
6
6
  import { initTelemetryClient, telemetryClientConfigMappings } from '@aztec/telemetry-client';
7
7
  import { getGenesisValues } from '@aztec/world-state/testing';
8
8
  import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
9
- import { createAztecNode, deployContractsToL1 } from '../../sandbox.js';
9
+ import { createAztecNode, deployContractsToL1 } from '../../sandbox/index.js';
10
10
  import { getL1Config } from '../get_l1_config.js';
11
11
  import { extractNamespacedOptions, extractRelevantOptions } from '../util.js';
12
12
  export async function startNode(options, signalHandlers, services, userLog) {
@@ -11,7 +11,7 @@ export async function startP2PBootstrap(options, signalHandlers, services, userL
11
11
  const config = extractRelevantOptions(options, bootnodeConfigMappings, 'p2p');
12
12
  userLog(`Starting P2P bootstrap node with config: ${jsonStringify(config)}`);
13
13
  const telemetryClient = initTelemetryClient(getTelemetryClientConfig());
14
- const store = await createStore('p2p-bootstrap', config, createLogger('p2p:bootstrap:store'));
14
+ const store = await createStore('p2p-bootstrap', 1, config, createLogger('p2p:bootstrap:store'));
15
15
  const node = new BootstrapNode(store, telemetryClient);
16
16
  await node.start(config);
17
17
  signalHandlers.push(()=>node.stop());
package/dest/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { createSandbox, getDeployedBananaCoinAddress, getDeployedBananaFPCAddress } from './sandbox.js';
1
+ export { createSandbox, getDeployedBananaCoinAddress, getDeployedBananaFPCAddress, getDeployedSponsoredFPCAddress, SponsoredFeePaymentMethod, } from './sandbox/index.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,4BAA4B,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,4BAA4B,EAC5B,2BAA2B,EAC3B,8BAA8B,EAC9B,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC"}
package/dest/index.js CHANGED
@@ -1 +1 @@
1
- export { createSandbox, getDeployedBananaCoinAddress, getDeployedBananaFPCAddress } from './sandbox.js';
1
+ export { createSandbox, getDeployedBananaCoinAddress, getDeployedBananaFPCAddress, getDeployedSponsoredFPCAddress, SponsoredFeePaymentMethod } from './sandbox/index.js';
@@ -0,0 +1,11 @@
1
+ import { type InitialAccountData } from '@aztec/accounts/testing';
2
+ import type { Wallet } from '@aztec/aztec.js';
3
+ import type { LogFn } from '@aztec/foundation/log';
4
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
5
+ import type { PXE } from '@aztec/stdlib/interfaces/client';
6
+ export declare function getBananaCoinAddress(initialAccounts: InitialAccountData[]): Promise<AztecAddress>;
7
+ export declare function getBananaFPCAddress(initialAccounts: InitialAccountData[]): Promise<AztecAddress>;
8
+ export declare function setupBananaFPC(initialAccounts: InitialAccountData[], deployer: Wallet, log: LogFn): Promise<void>;
9
+ export declare function getDeployedBananaCoinAddress(pxe: PXE): Promise<AztecAddress>;
10
+ export declare function getDeployedBananaFPCAddress(pxe: PXE): Promise<AztecAddress>;
11
+ //# sourceMappingURL=banana_fpc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"banana_fpc.d.ts","sourceRoot":"","sources":["../../src/sandbox/banana_fpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAA0B,MAAM,yBAAyB,CAAC;AAC1F,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAuB3D,wBAAsB,oBAAoB,CAAC,eAAe,EAAE,kBAAkB,EAAE,yBAE/E;AAWD,wBAAsB,mBAAmB,CAAC,eAAe,EAAE,kBAAkB,EAAE,yBAE9E;AAED,wBAAsB,cAAc,CAAC,eAAe,EAAE,kBAAkB,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,iBAcvG;AAED,wBAAsB,4BAA4B,CAAC,GAAG,EAAE,GAAG,yBAQ1D;AAED,wBAAsB,2BAA2B,CAAC,GAAG,EAAE,GAAG,yBAQzD"}
@@ -0,0 +1,79 @@
1
+ import { getInitialTestAccounts } from '@aztec/accounts/testing';
2
+ import { Fr } from '@aztec/foundation/fields';
3
+ import { FPCContract } from '@aztec/noir-contracts.js/FPC';
4
+ import { TokenContract } from '@aztec/noir-contracts.js/Token';
5
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
6
+ import { getContractInstanceFromDeployParams } from '@aztec/stdlib/contract';
7
+ const BANANA_COIN_SALT = new Fr(0);
8
+ const bananaCoinArgs = {
9
+ name: 'BC',
10
+ symbol: 'BC',
11
+ decimal: 18n
12
+ };
13
+ const BANANA_FPC_SALT = new Fr(0);
14
+ function getBananaAdmin(initialAccounts) {
15
+ return initialAccounts[0]?.address ?? AztecAddress.ZERO;
16
+ }
17
+ async function getBananaCoinInstance(initialAccounts) {
18
+ const admin = getBananaAdmin(initialAccounts);
19
+ return await getContractInstanceFromDeployParams(TokenContract.artifact, {
20
+ constructorArgs: [
21
+ admin,
22
+ bananaCoinArgs.name,
23
+ bananaCoinArgs.symbol,
24
+ bananaCoinArgs.decimal
25
+ ],
26
+ salt: BANANA_COIN_SALT
27
+ });
28
+ }
29
+ export async function getBananaCoinAddress(initialAccounts) {
30
+ return (await getBananaCoinInstance(initialAccounts)).address;
31
+ }
32
+ async function getBananaFPCInstance(initialAccounts) {
33
+ const bananaCoin = await getBananaCoinAddress(initialAccounts);
34
+ const admin = getBananaAdmin(initialAccounts);
35
+ return await getContractInstanceFromDeployParams(FPCContract.artifact, {
36
+ constructorArgs: [
37
+ bananaCoin,
38
+ admin
39
+ ],
40
+ salt: BANANA_FPC_SALT
41
+ });
42
+ }
43
+ export async function getBananaFPCAddress(initialAccounts) {
44
+ return (await getBananaFPCInstance(initialAccounts)).address;
45
+ }
46
+ export async function setupBananaFPC(initialAccounts, deployer, log) {
47
+ const bananaCoinAddress = await getBananaCoinAddress(initialAccounts);
48
+ const admin = getBananaAdmin(initialAccounts);
49
+ const [bananaCoin, fpc] = await Promise.all([
50
+ TokenContract.deploy(deployer, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal).send({
51
+ contractAddressSalt: BANANA_COIN_SALT,
52
+ universalDeploy: true
53
+ }).deployed(),
54
+ FPCContract.deploy(deployer, bananaCoinAddress, admin).send({
55
+ contractAddressSalt: BANANA_FPC_SALT,
56
+ universalDeploy: true
57
+ }).deployed()
58
+ ]);
59
+ log(`BananaCoin: ${bananaCoin.address}`);
60
+ log(`FPC: ${fpc.address}`);
61
+ }
62
+ export async function getDeployedBananaCoinAddress(pxe) {
63
+ const initialAccounts = await getInitialTestAccounts();
64
+ const bananaCoin = await getBananaCoinAddress(initialAccounts);
65
+ const contracts = await pxe.getContracts();
66
+ if (!contracts.find((c)=>c.equals(bananaCoin))) {
67
+ throw new Error('BananaCoin not deployed.');
68
+ }
69
+ return bananaCoin;
70
+ }
71
+ export async function getDeployedBananaFPCAddress(pxe) {
72
+ const initialAccounts = await getInitialTestAccounts();
73
+ const fpc = await getBananaFPCInstance(initialAccounts);
74
+ const contracts = await pxe.getContracts();
75
+ if (!contracts.find((c)=>c.equals(fpc.address))) {
76
+ throw new Error('BananaFPC not deployed.');
77
+ }
78
+ return fpc.address;
79
+ }
@@ -0,0 +1,5 @@
1
+ export * from './sandbox.js';
2
+ export { getDeployedBananaCoinAddress, getDeployedBananaFPCAddress } from './banana_fpc.js';
3
+ export { getDeployedSponsoredFPCAddress } from './sponsored_fpc.js';
4
+ export { SponsoredFeePaymentMethod } from './sponsored_fee_payment_method.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sandbox/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAE7B,OAAO,EAAE,4BAA4B,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAC5F,OAAO,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './sandbox.js';
2
+ export { getDeployedBananaCoinAddress, getDeployedBananaFPCAddress } from './banana_fpc.js';
3
+ export { getDeployedSponsoredFPCAddress } from './sponsored_fpc.js';
4
+ export { SponsoredFeePaymentMethod } from './sponsored_fee_payment_method.js';
@@ -4,8 +4,7 @@ import { type BlobSinkClientInterface } from '@aztec/blob-sink/client';
4
4
  import { Fr } from '@aztec/foundation/fields';
5
5
  import { type LogFn } from '@aztec/foundation/log';
6
6
  import { type PXEServiceConfig } from '@aztec/pxe';
7
- import { AztecAddress } from '@aztec/stdlib/aztec-address';
8
- import type { AztecNode, PXE } from '@aztec/stdlib/interfaces/client';
7
+ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
9
8
  import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
10
9
  import { type TelemetryClient } from '@aztec/telemetry-client';
11
10
  import { type HDAccount, type PrivateKeyAccount } from 'viem';
@@ -38,8 +37,6 @@ export declare function deployContractsToL1(aztecNodeConfig: AztecNodeConfig, hd
38
37
  } & {
39
38
  rollupAddress: import("@aztec/aztec.js").EthAddress;
40
39
  }>;
41
- export declare function getDeployedBananaCoinAddress(pxe: PXE): Promise<AztecAddress>;
42
- export declare function getDeployedBananaFPCAddress(pxe: PXE): Promise<AztecAddress>;
43
40
  /** Sandbox settings. */
44
41
  export type SandboxConfig = AztecNodeConfig & {
45
42
  /** Mnemonic used to derive the L1 deployer private key.*/
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../src/sandbox/sandbox.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,KAAK,eAAe,EAAE,gBAAgB,EAAoB,MAAM,mBAAmB,CAAC;AAE7F,OAAO,EAAE,KAAK,uBAAuB,EAAwB,MAAM,yBAAyB,CAAC;AAU7F,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,KAAK,KAAK,EAAgB,MAAM,uBAAuB,CAAC;AAGjE,OAAO,EAAE,KAAK,gBAAgB,EAAyC,MAAM,YAAY,CAAC;AAC1F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EACL,KAAK,eAAe,EAGrB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,iBAAiB,EAA2D,MAAM,MAAM,CAAC;AAavH;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,SAAS,GAAG,iBAAiB,EACxC,oBAAoB,mCAAS,EAC7B,IAAI,GAAE;IAAE,8BAA8B,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,kBAAkB,CAAC,EAAE,EAAE,CAAC;IAAC,gBAAgB,CAAC,EAAE,EAAE,CAAA;CAAO;;;;;;;;;;;;;;;;;;GA6BtH;AAED,wBAAwB;AACxB,MAAM,MAAM,aAAa,GAAG,eAAe,GAAG;IAC5C,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,qDAAqD;IACrD,KAAK,EAAE,OAAO,CAAC;IACf,uDAAuD;IACvD,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,MAAM,oCAA6B,EAAE,OAAO,EAAE,KAAK;;;;GAkGtF;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,MAAM,GAAE,OAAO,CAAC,eAAe,CAAM,EACrC,IAAI,GAAE;IAAE,SAAS,CAAC,EAAE,eAAe,CAAC;IAAC,cAAc,CAAC,EAAE,uBAAuB,CAAA;CAAO,EACpF,OAAO,GAAE;IAAE,mBAAmB,CAAC,EAAE,kBAAkB,EAAE,CAAA;CAAO,6BAY7D;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,GAAE,OAAO,CAAC,gBAAgB,CAAM,4CAI3F"}
@@ -9,20 +9,18 @@ import { GENESIS_ARCHIVE_ROOT, GENESIS_BLOCK_HASH } from '@aztec/constants';
9
9
  import { NULL_KEY, createEthereumChain, deployL1Contracts, getL1ContractsConfigEnvVars, waitForPublicClient } from '@aztec/ethereum';
10
10
  import { Fr } from '@aztec/foundation/fields';
11
11
  import { createLogger } from '@aztec/foundation/log';
12
- import { FPCContract } from '@aztec/noir-contracts.js/FPC';
13
- import { TokenContract } from '@aztec/noir-contracts.js/Token';
14
12
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
15
13
  import { ProtocolContractAddress, protocolContractTreeRoot } from '@aztec/protocol-contracts';
16
14
  import { createPXEService, getPXEServiceConfig } from '@aztec/pxe';
17
- import { AztecAddress } from '@aztec/stdlib/aztec-address';
18
- import { getContractInstanceFromDeployParams } from '@aztec/stdlib/contract';
19
15
  import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
20
16
  import { getGenesisValues } from '@aztec/world-state/testing';
21
17
  import { createPublicClient, fallback, http as httpViemTransport } from 'viem';
22
18
  import { mnemonicToAccount } from 'viem/accounts';
23
19
  import { foundry } from 'viem/chains';
24
- import { createAccountLogs } from './cli/util.js';
25
- import { DefaultMnemonic } from './mnemonic.js';
20
+ import { createAccountLogs } from '../cli/util.js';
21
+ import { DefaultMnemonic } from '../mnemonic.js';
22
+ import { getBananaFPCAddress, setupBananaFPC } from './banana_fpc.js';
23
+ import { getSponsoredFPCAddress, setupSponsoredFPC } from './sponsored_fpc.js';
26
24
  const logger = createLogger('sandbox');
27
25
  const localAnvil = foundry;
28
26
  /**
@@ -47,59 +45,6 @@ const localAnvil = foundry;
47
45
  aztecNodeConfig.l1Contracts = l1Contracts.l1ContractAddresses;
48
46
  return aztecNodeConfig.l1Contracts;
49
47
  }
50
- async function getBananaCoinInstance(admin) {
51
- return await getContractInstanceFromDeployParams(TokenContract.artifact, {
52
- constructorArgs: [
53
- admin,
54
- 'BC',
55
- 'BC',
56
- 18n
57
- ],
58
- salt: new Fr(0)
59
- });
60
- }
61
- async function getBananaFPCInstance(admin, bananaCoin) {
62
- return await getContractInstanceFromDeployParams(FPCContract.artifact, {
63
- constructorArgs: [
64
- bananaCoin,
65
- admin
66
- ],
67
- salt: new Fr(0)
68
- });
69
- }
70
- async function setupFPC(admin, deployer, bananaCoinInstance, fpcInstance, log) {
71
- const [bananaCoin, fpc] = await Promise.all([
72
- TokenContract.deploy(deployer, admin, 'BC', 'BC', 18n).send({
73
- contractAddressSalt: bananaCoinInstance.salt,
74
- universalDeploy: true
75
- }).deployed(),
76
- FPCContract.deploy(deployer, bananaCoinInstance.address, admin).send({
77
- contractAddressSalt: fpcInstance.salt,
78
- universalDeploy: true
79
- }).deployed()
80
- ]);
81
- log(`BananaCoin: ${bananaCoin.address}`);
82
- log(`FPC: ${fpc.address}`);
83
- }
84
- export async function getDeployedBananaCoinAddress(pxe) {
85
- const [initialAccount] = await getInitialTestAccounts();
86
- const bananaCoin = await getBananaCoinInstance(initialAccount.address);
87
- const contracts = await pxe.getContracts();
88
- if (!contracts.find((c)=>c.equals(bananaCoin.address))) {
89
- throw new Error('BananaCoin not deployed.');
90
- }
91
- return bananaCoin.address;
92
- }
93
- export async function getDeployedBananaFPCAddress(pxe) {
94
- const [initialAccount] = await getInitialTestAccounts();
95
- const bananaCoin = await getBananaCoinInstance(initialAccount.address);
96
- const fpc = await getBananaFPCInstance(initialAccount.address, bananaCoin.address);
97
- const contracts = await pxe.getContracts();
98
- if (!contracts.find((c)=>c.equals(fpc.address))) {
99
- throw new Error('BananaFPC not deployed.');
100
- }
101
- return fpc.address;
102
- }
103
48
  /**
104
49
  * Create and start a new Aztec Node and PXE. Deploys L1 contracts.
105
50
  * Does not start any HTTP services nor populate any initial accounts.
@@ -138,12 +83,12 @@ export async function getDeployedBananaFPCAddress(pxe) {
138
83
  }
139
84
  return [];
140
85
  })();
141
- const bananaAdmin = initialAccounts[0]?.address ?? AztecAddress.ZERO;
142
- const bananaCoin = await getBananaCoinInstance(bananaAdmin);
143
- const fpc = await getBananaFPCInstance(bananaAdmin, bananaCoin.address);
86
+ const bananaFPC = await getBananaFPCAddress(initialAccounts);
87
+ const sponsoredFPC = await getSponsoredFPCAddress();
144
88
  const fundedAddresses = initialAccounts.length ? [
145
89
  ...initialAccounts.map((a)=>a.address),
146
- fpc.address
90
+ bananaFPC,
91
+ sponsoredFPC
147
92
  ] : [];
148
93
  const { genesisArchiveRoot, genesisBlockHash, prefilledPublicData } = await getGenesisValues(fundedAddresses);
149
94
  let watcher = undefined;
@@ -192,7 +137,8 @@ export async function getDeployedBananaFPCAddress(pxe) {
192
137
  const accLogs = await createAccountLogs(accountsWithSecrets, pxe);
193
138
  userLog(accLogs.join(''));
194
139
  const deployer = await getSchnorrWallet(pxe, initialAccounts[0].address, initialAccounts[0].signingKey);
195
- await setupFPC(bananaAdmin, deployer, bananaCoin, fpc, userLog);
140
+ await setupBananaFPC(initialAccounts, deployer, userLog);
141
+ await setupSponsoredFPC(deployer, userLog);
196
142
  }
197
143
  const stop = async ()=>{
198
144
  await node.stop();
@@ -0,0 +1,23 @@
1
+ import type { FeePaymentMethod } from '@aztec/aztec.js';
2
+ import { type FunctionCall } from '@aztec/stdlib/abi';
3
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
+ import type { PXE } from '@aztec/stdlib/interfaces/client';
5
+ /**
6
+ * A payment method that uses the SponsoredFPCContract to pay the fee unconditionally.
7
+ */
8
+ export declare class SponsoredFeePaymentMethod implements FeePaymentMethod {
9
+ /**
10
+ * Contract which will pay the fee.
11
+ */
12
+ private paymentContract;
13
+ constructor(
14
+ /**
15
+ * Contract which will pay the fee.
16
+ */
17
+ paymentContract: AztecAddress);
18
+ static new(pxe: PXE): Promise<SponsoredFeePaymentMethod>;
19
+ getAsset(): Promise<AztecAddress>;
20
+ getFeePayer(): Promise<AztecAddress>;
21
+ getFunctionCalls(): Promise<FunctionCall[]>;
22
+ }
23
+ //# sourceMappingURL=sponsored_fee_payment_method.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sponsored_fee_payment_method.d.ts","sourceRoot":"","sources":["../../src/sandbox/sponsored_fee_payment_method.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,EAAE,KAAK,YAAY,EAAkC,MAAM,mBAAmB,CAAC;AACtF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAI3D;;GAEG;AACH,qBAAa,yBAA0B,YAAW,gBAAgB;IAE9D;;OAEG;IACH,OAAO,CAAC,eAAe;;IAHvB;;OAEG;IACK,eAAe,EAAE,YAAY;WAG1B,GAAG,CAAC,GAAG,EAAE,GAAG;IAKzB,QAAQ,IAAI,OAAO,CAAC,YAAY,CAAC;IAIjC,WAAW,IAAI,OAAO,CAAC,YAAY,CAAC;IAI9B,gBAAgB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;CAalD"}
@@ -0,0 +1,36 @@
1
+ import { ProtocolContractAddress } from '@aztec/protocol-contracts';
2
+ import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
3
+ import { getDeployedSponsoredFPCAddress } from './sponsored_fpc.js';
4
+ /**
5
+ * A payment method that uses the SponsoredFPCContract to pay the fee unconditionally.
6
+ */ export class SponsoredFeePaymentMethod {
7
+ paymentContract;
8
+ constructor(/**
9
+ * Contract which will pay the fee.
10
+ */ paymentContract){
11
+ this.paymentContract = paymentContract;
12
+ }
13
+ static async new(pxe) {
14
+ const sponsoredFPC = await getDeployedSponsoredFPCAddress(pxe);
15
+ return new SponsoredFeePaymentMethod(sponsoredFPC);
16
+ }
17
+ getAsset() {
18
+ return Promise.resolve(ProtocolContractAddress.FeeJuice);
19
+ }
20
+ getFeePayer() {
21
+ return Promise.resolve(this.paymentContract);
22
+ }
23
+ async getFunctionCalls() {
24
+ return [
25
+ {
26
+ name: 'sponsor_unconditionally',
27
+ to: this.paymentContract,
28
+ selector: await FunctionSelector.fromSignature('sponsor_unconditionally()'),
29
+ type: FunctionType.PRIVATE,
30
+ isStatic: false,
31
+ args: [],
32
+ returnTypes: []
33
+ }
34
+ ];
35
+ }
36
+ }
@@ -0,0 +1,6 @@
1
+ import { type PXE, type Wallet } from '@aztec/aztec.js';
2
+ import type { LogFn } from '@aztec/foundation/log';
3
+ export declare function getSponsoredFPCAddress(): Promise<import("@aztec/aztec.js").AztecAddress>;
4
+ export declare function setupSponsoredFPC(deployer: Wallet, log: LogFn): Promise<void>;
5
+ export declare function getDeployedSponsoredFPCAddress(pxe: PXE): Promise<import("@aztec/aztec.js").AztecAddress>;
6
+ //# sourceMappingURL=sponsored_fpc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sponsored_fpc.d.ts","sourceRoot":"","sources":["../../src/sandbox/sponsored_fpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,GAAG,EACR,KAAK,MAAM,EAEZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAWnD,wBAAsB,sBAAsB,oDAE3C;AAED,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,iBAMnE;AAED,wBAAsB,8BAA8B,CAAC,GAAG,EAAE,GAAG,mDAO5D"}
@@ -0,0 +1,26 @@
1
+ import { Fr, getContractInstanceFromDeployParams } from '@aztec/aztec.js';
2
+ import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
3
+ const SPONSORED_FPC_SALT = new Fr(0);
4
+ async function getSponsoredFPCInstance() {
5
+ return await getContractInstanceFromDeployParams(SponsoredFPCContract.artifact, {
6
+ salt: SPONSORED_FPC_SALT
7
+ });
8
+ }
9
+ export async function getSponsoredFPCAddress() {
10
+ return (await getSponsoredFPCInstance()).address;
11
+ }
12
+ export async function setupSponsoredFPC(deployer, log) {
13
+ const deployed = await SponsoredFPCContract.deploy(deployer).send({
14
+ contractAddressSalt: SPONSORED_FPC_SALT,
15
+ universalDeploy: true
16
+ }).deployed();
17
+ log(`SponsoredFPC: ${deployed.address}`);
18
+ }
19
+ export async function getDeployedSponsoredFPCAddress(pxe) {
20
+ const fpc = await getSponsoredFPCAddress();
21
+ const contracts = await pxe.getContracts();
22
+ if (!contracts.find((c)=>c.equals(fpc))) {
23
+ throw new Error('SponsoredFPC not deployed.');
24
+ }
25
+ return fpc;
26
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/aztec",
3
- "version": "0.77.0-testnet-ignition.29",
3
+ "version": "0.77.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js"
@@ -29,34 +29,34 @@
29
29
  "../package.common.json"
30
30
  ],
31
31
  "dependencies": {
32
- "@aztec/accounts": "0.77.0-testnet-ignition.29",
33
- "@aztec/archiver": "0.77.0-testnet-ignition.29",
34
- "@aztec/aztec-faucet": "0.77.0-testnet-ignition.29",
35
- "@aztec/aztec-node": "0.77.0-testnet-ignition.29",
36
- "@aztec/aztec.js": "0.77.0-testnet-ignition.29",
37
- "@aztec/bb-prover": "0.77.0-testnet-ignition.29",
38
- "@aztec/blob-sink": "0.77.0-testnet-ignition.29",
39
- "@aztec/bot": "0.77.0-testnet-ignition.29",
40
- "@aztec/builder": "0.77.0-testnet-ignition.29",
41
- "@aztec/cli": "0.77.0-testnet-ignition.29",
42
- "@aztec/cli-wallet": "0.77.0-testnet-ignition.29",
43
- "@aztec/constants": "0.77.0-testnet-ignition.29",
44
- "@aztec/entrypoints": "0.77.0-testnet-ignition.29",
45
- "@aztec/ethereum": "0.77.0-testnet-ignition.29",
46
- "@aztec/foundation": "0.77.0-testnet-ignition.29",
47
- "@aztec/kv-store": "0.77.0-testnet-ignition.29",
48
- "@aztec/noir-contracts.js": "0.77.0-testnet-ignition.29",
49
- "@aztec/noir-protocol-circuits-types": "0.77.0-testnet-ignition.29",
50
- "@aztec/p2p": "0.77.0-testnet-ignition.29",
51
- "@aztec/p2p-bootstrap": "0.77.0-testnet-ignition.29",
52
- "@aztec/protocol-contracts": "0.77.0-testnet-ignition.29",
53
- "@aztec/prover-client": "0.77.0-testnet-ignition.29",
54
- "@aztec/prover-node": "0.77.0-testnet-ignition.29",
55
- "@aztec/pxe": "0.77.0-testnet-ignition.29",
56
- "@aztec/stdlib": "0.77.0-testnet-ignition.29",
57
- "@aztec/telemetry-client": "0.77.0-testnet-ignition.29",
58
- "@aztec/txe": "0.77.0-testnet-ignition.29",
59
- "@aztec/world-state": "0.77.0-testnet-ignition.29",
32
+ "@aztec/accounts": "0.77.0",
33
+ "@aztec/archiver": "0.77.0",
34
+ "@aztec/aztec-faucet": "0.77.0",
35
+ "@aztec/aztec-node": "0.77.0",
36
+ "@aztec/aztec.js": "0.77.0",
37
+ "@aztec/bb-prover": "0.77.0",
38
+ "@aztec/blob-sink": "0.77.0",
39
+ "@aztec/bot": "0.77.0",
40
+ "@aztec/builder": "0.77.0",
41
+ "@aztec/cli": "0.77.0",
42
+ "@aztec/cli-wallet": "0.77.0",
43
+ "@aztec/constants": "0.77.0",
44
+ "@aztec/entrypoints": "0.77.0",
45
+ "@aztec/ethereum": "0.77.0",
46
+ "@aztec/foundation": "0.77.0",
47
+ "@aztec/kv-store": "0.77.0",
48
+ "@aztec/noir-contracts.js": "0.77.0",
49
+ "@aztec/noir-protocol-circuits-types": "0.77.0",
50
+ "@aztec/p2p": "0.77.0",
51
+ "@aztec/p2p-bootstrap": "0.77.0",
52
+ "@aztec/protocol-contracts": "0.77.0",
53
+ "@aztec/prover-client": "0.77.0",
54
+ "@aztec/prover-node": "0.77.0",
55
+ "@aztec/pxe": "0.77.0",
56
+ "@aztec/stdlib": "0.77.0",
57
+ "@aztec/telemetry-client": "0.77.0",
58
+ "@aztec/txe": "0.77.0",
59
+ "@aztec/world-state": "0.77.0",
60
60
  "@types/chalk": "^2.2.0",
61
61
  "abitype": "^0.8.11",
62
62
  "chalk": "^5.3.0",
@@ -13,7 +13,7 @@ import { getOtelJsonRpcPropagationMiddleware } from '@aztec/telemetry-client';
13
13
  import { readFileSync } from 'fs';
14
14
  import { dirname, resolve } from 'path';
15
15
 
16
- import { createSandbox } from '../sandbox.js';
16
+ import { createSandbox } from '../sandbox/index.js';
17
17
  import { github, splash } from '../splash.js';
18
18
  import { extractNamespacedOptions, installSignalHandlers } from './util.js';
19
19
  import { getVersions } from './versioning.js';
@@ -41,7 +41,7 @@ export async function startArchiver(
41
41
  archiverConfig = { ...archiverConfig, ...config };
42
42
 
43
43
  const storeLog = createLogger('archiver:lmdb');
44
- const store = await createStore('archiver', archiverConfig, storeLog);
44
+ const store = await createStore('archiver', KVArchiverDataStore.SCHEMA_VERSION, archiverConfig, storeLog);
45
45
  const archiverStore = new KVArchiverDataStore(store, archiverConfig.maxLogs);
46
46
 
47
47
  const telemetry = initTelemetryClient(getTelemetryClientConfig());
@@ -14,7 +14,7 @@ import { getGenesisValues } from '@aztec/world-state/testing';
14
14
 
15
15
  import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
16
16
 
17
- import { createAztecNode, deployContractsToL1 } from '../../sandbox.js';
17
+ import { createAztecNode, deployContractsToL1 } from '../../sandbox/index.js';
18
18
  import { getL1Config } from '../get_l1_config.js';
19
19
  import { extractNamespacedOptions, extractRelevantOptions } from '../util.js';
20
20
 
@@ -19,7 +19,7 @@ export async function startP2PBootstrap(
19
19
  const config = extractRelevantOptions<BootnodeConfig>(options, bootnodeConfigMappings, 'p2p');
20
20
  userLog(`Starting P2P bootstrap node with config: ${jsonStringify(config)}`);
21
21
  const telemetryClient = initTelemetryClient(getTelemetryClientConfig());
22
- const store = await createStore('p2p-bootstrap', config, createLogger('p2p:bootstrap:store'));
22
+ const store = await createStore('p2p-bootstrap', 1, config, createLogger('p2p:bootstrap:store'));
23
23
  const node = new BootstrapNode(store, telemetryClient);
24
24
  await node.start(config);
25
25
  signalHandlers.push(() => node.stop());
package/src/index.ts CHANGED
@@ -1 +1,7 @@
1
- export { createSandbox, getDeployedBananaCoinAddress, getDeployedBananaFPCAddress } from './sandbox.js';
1
+ export {
2
+ createSandbox,
3
+ getDeployedBananaCoinAddress,
4
+ getDeployedBananaFPCAddress,
5
+ getDeployedSponsoredFPCAddress,
6
+ SponsoredFeePaymentMethod,
7
+ } from './sandbox/index.js';
@@ -0,0 +1,83 @@
1
+ import { type InitialAccountData, getInitialTestAccounts } from '@aztec/accounts/testing';
2
+ import type { Wallet } from '@aztec/aztec.js';
3
+ import { Fr } from '@aztec/foundation/fields';
4
+ import type { LogFn } from '@aztec/foundation/log';
5
+ import { FPCContract } from '@aztec/noir-contracts.js/FPC';
6
+ import { TokenContract } from '@aztec/noir-contracts.js/Token';
7
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
8
+ import { type ContractInstanceWithAddress, getContractInstanceFromDeployParams } from '@aztec/stdlib/contract';
9
+ import type { PXE } from '@aztec/stdlib/interfaces/client';
10
+
11
+ const BANANA_COIN_SALT = new Fr(0);
12
+ const bananaCoinArgs = {
13
+ name: 'BC',
14
+ symbol: 'BC',
15
+ decimal: 18n,
16
+ };
17
+
18
+ const BANANA_FPC_SALT = new Fr(0);
19
+
20
+ function getBananaAdmin(initialAccounts: InitialAccountData[]): AztecAddress {
21
+ return initialAccounts[0]?.address ?? AztecAddress.ZERO;
22
+ }
23
+
24
+ async function getBananaCoinInstance(initialAccounts: InitialAccountData[]): Promise<ContractInstanceWithAddress> {
25
+ const admin = getBananaAdmin(initialAccounts);
26
+ return await getContractInstanceFromDeployParams(TokenContract.artifact, {
27
+ constructorArgs: [admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal],
28
+ salt: BANANA_COIN_SALT,
29
+ });
30
+ }
31
+
32
+ export async function getBananaCoinAddress(initialAccounts: InitialAccountData[]) {
33
+ return (await getBananaCoinInstance(initialAccounts)).address;
34
+ }
35
+
36
+ async function getBananaFPCInstance(initialAccounts: InitialAccountData[]): Promise<ContractInstanceWithAddress> {
37
+ const bananaCoin = await getBananaCoinAddress(initialAccounts);
38
+ const admin = getBananaAdmin(initialAccounts);
39
+ return await getContractInstanceFromDeployParams(FPCContract.artifact, {
40
+ constructorArgs: [bananaCoin, admin],
41
+ salt: BANANA_FPC_SALT,
42
+ });
43
+ }
44
+
45
+ export async function getBananaFPCAddress(initialAccounts: InitialAccountData[]) {
46
+ return (await getBananaFPCInstance(initialAccounts)).address;
47
+ }
48
+
49
+ export async function setupBananaFPC(initialAccounts: InitialAccountData[], deployer: Wallet, log: LogFn) {
50
+ const bananaCoinAddress = await getBananaCoinAddress(initialAccounts);
51
+ const admin = getBananaAdmin(initialAccounts);
52
+ const [bananaCoin, fpc] = await Promise.all([
53
+ TokenContract.deploy(deployer, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal)
54
+ .send({ contractAddressSalt: BANANA_COIN_SALT, universalDeploy: true })
55
+ .deployed(),
56
+ FPCContract.deploy(deployer, bananaCoinAddress, admin)
57
+ .send({ contractAddressSalt: BANANA_FPC_SALT, universalDeploy: true })
58
+ .deployed(),
59
+ ]);
60
+
61
+ log(`BananaCoin: ${bananaCoin.address}`);
62
+ log(`FPC: ${fpc.address}`);
63
+ }
64
+
65
+ export async function getDeployedBananaCoinAddress(pxe: PXE) {
66
+ const initialAccounts = await getInitialTestAccounts();
67
+ const bananaCoin = await getBananaCoinAddress(initialAccounts);
68
+ const contracts = await pxe.getContracts();
69
+ if (!contracts.find(c => c.equals(bananaCoin))) {
70
+ throw new Error('BananaCoin not deployed.');
71
+ }
72
+ return bananaCoin;
73
+ }
74
+
75
+ export async function getDeployedBananaFPCAddress(pxe: PXE) {
76
+ const initialAccounts = await getInitialTestAccounts();
77
+ const fpc = await getBananaFPCInstance(initialAccounts);
78
+ const contracts = await pxe.getContracts();
79
+ if (!contracts.find(c => c.equals(fpc.address))) {
80
+ throw new Error('BananaFPC not deployed.');
81
+ }
82
+ return fpc.address;
83
+ }
@@ -0,0 +1,5 @@
1
+ export * from './sandbox.js';
2
+
3
+ export { getDeployedBananaCoinAddress, getDeployedBananaFPCAddress } from './banana_fpc.js';
4
+ export { getDeployedSponsoredFPCAddress } from './sponsored_fpc.js';
5
+ export { SponsoredFeePaymentMethod } from './sponsored_fee_payment_method.js';
@@ -2,7 +2,7 @@
2
2
  import { getSchnorrWallet } from '@aztec/accounts/schnorr';
3
3
  import { deployFundedSchnorrAccounts, getInitialTestAccounts } from '@aztec/accounts/testing';
4
4
  import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
5
- import { AnvilTestWatcher, EthCheatCodes, SignerlessWallet, type Wallet } from '@aztec/aztec.js';
5
+ import { AnvilTestWatcher, EthCheatCodes, SignerlessWallet } from '@aztec/aztec.js';
6
6
  import { type BlobSinkClientInterface, createBlobSinkClient } from '@aztec/blob-sink/client';
7
7
  import { setupCanonicalL2FeeJuice } from '@aztec/cli/setup-contracts';
8
8
  import { GENESIS_ARCHIVE_ROOT, GENESIS_BLOCK_HASH } from '@aztec/constants';
@@ -15,14 +15,10 @@ import {
15
15
  } from '@aztec/ethereum';
16
16
  import { Fr } from '@aztec/foundation/fields';
17
17
  import { type LogFn, createLogger } from '@aztec/foundation/log';
18
- import { FPCContract } from '@aztec/noir-contracts.js/FPC';
19
- import { TokenContract } from '@aztec/noir-contracts.js/Token';
20
18
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
21
19
  import { ProtocolContractAddress, protocolContractTreeRoot } from '@aztec/protocol-contracts';
22
20
  import { type PXEServiceConfig, createPXEService, getPXEServiceConfig } from '@aztec/pxe';
23
- import { AztecAddress } from '@aztec/stdlib/aztec-address';
24
- import { type ContractInstanceWithAddress, getContractInstanceFromDeployParams } from '@aztec/stdlib/contract';
25
- import type { AztecNode, PXE } from '@aztec/stdlib/interfaces/client';
21
+ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
26
22
  import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
27
23
  import {
28
24
  type TelemetryClient,
@@ -35,8 +31,10 @@ import { type HDAccount, type PrivateKeyAccount, createPublicClient, fallback, h
35
31
  import { mnemonicToAccount } from 'viem/accounts';
36
32
  import { foundry } from 'viem/chains';
37
33
 
38
- import { createAccountLogs } from './cli/util.js';
39
- import { DefaultMnemonic } from './mnemonic.js';
34
+ import { createAccountLogs } from '../cli/util.js';
35
+ import { DefaultMnemonic } from '../mnemonic.js';
36
+ import { getBananaFPCAddress, setupBananaFPC } from './banana_fpc.js';
37
+ import { getSponsoredFPCAddress, setupSponsoredFPC } from './sponsored_fpc.js';
40
38
 
41
39
  const logger = createLogger('sandbox');
42
40
 
@@ -82,64 +80,6 @@ export async function deployContractsToL1(
82
80
  return aztecNodeConfig.l1Contracts;
83
81
  }
84
82
 
85
- async function getBananaCoinInstance(admin: AztecAddress): Promise<ContractInstanceWithAddress> {
86
- return await getContractInstanceFromDeployParams(TokenContract.artifact, {
87
- constructorArgs: [admin, 'BC', 'BC', 18n],
88
- salt: new Fr(0),
89
- });
90
- }
91
-
92
- async function getBananaFPCInstance(
93
- admin: AztecAddress,
94
- bananaCoin: AztecAddress,
95
- ): Promise<ContractInstanceWithAddress> {
96
- return await getContractInstanceFromDeployParams(FPCContract.artifact, {
97
- constructorArgs: [bananaCoin, admin],
98
- salt: new Fr(0),
99
- });
100
- }
101
-
102
- async function setupFPC(
103
- admin: AztecAddress,
104
- deployer: Wallet,
105
- bananaCoinInstance: ContractInstanceWithAddress,
106
- fpcInstance: ContractInstanceWithAddress,
107
- log: LogFn,
108
- ) {
109
- const [bananaCoin, fpc] = await Promise.all([
110
- TokenContract.deploy(deployer, admin, 'BC', 'BC', 18n)
111
- .send({ contractAddressSalt: bananaCoinInstance.salt, universalDeploy: true })
112
- .deployed(),
113
- FPCContract.deploy(deployer, bananaCoinInstance.address, admin)
114
- .send({ contractAddressSalt: fpcInstance.salt, universalDeploy: true })
115
- .deployed(),
116
- ]);
117
-
118
- log(`BananaCoin: ${bananaCoin.address}`);
119
- log(`FPC: ${fpc.address}`);
120
- }
121
-
122
- export async function getDeployedBananaCoinAddress(pxe: PXE) {
123
- const [initialAccount] = await getInitialTestAccounts();
124
- const bananaCoin = await getBananaCoinInstance(initialAccount.address);
125
- const contracts = await pxe.getContracts();
126
- if (!contracts.find(c => c.equals(bananaCoin.address))) {
127
- throw new Error('BananaCoin not deployed.');
128
- }
129
- return bananaCoin.address;
130
- }
131
-
132
- export async function getDeployedBananaFPCAddress(pxe: PXE) {
133
- const [initialAccount] = await getInitialTestAccounts();
134
- const bananaCoin = await getBananaCoinInstance(initialAccount.address);
135
- const fpc = await getBananaFPCInstance(initialAccount.address, bananaCoin.address);
136
- const contracts = await pxe.getContracts();
137
- if (!contracts.find(c => c.equals(fpc.address))) {
138
- throw new Error('BananaFPC not deployed.');
139
- }
140
- return fpc.address;
141
- }
142
-
143
83
  /** Sandbox settings. */
144
84
  export type SandboxConfig = AztecNodeConfig & {
145
85
  /** Mnemonic used to derive the L1 deployer private key.*/
@@ -190,10 +130,11 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}, userLog
190
130
  return [];
191
131
  })();
192
132
 
193
- const bananaAdmin = initialAccounts[0]?.address ?? AztecAddress.ZERO;
194
- const bananaCoin = await getBananaCoinInstance(bananaAdmin);
195
- const fpc = await getBananaFPCInstance(bananaAdmin, bananaCoin.address);
196
- const fundedAddresses = initialAccounts.length ? [...initialAccounts.map(a => a.address), fpc.address] : [];
133
+ const bananaFPC = await getBananaFPCAddress(initialAccounts);
134
+ const sponsoredFPC = await getSponsoredFPCAddress();
135
+ const fundedAddresses = initialAccounts.length
136
+ ? [...initialAccounts.map(a => a.address), bananaFPC, sponsoredFPC]
137
+ : [];
197
138
  const { genesisArchiveRoot, genesisBlockHash, prefilledPublicData } = await getGenesisValues(fundedAddresses);
198
139
 
199
140
  let watcher: AnvilTestWatcher | undefined = undefined;
@@ -244,7 +185,8 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}, userLog
244
185
  userLog(accLogs.join(''));
245
186
 
246
187
  const deployer = await getSchnorrWallet(pxe, initialAccounts[0].address, initialAccounts[0].signingKey);
247
- await setupFPC(bananaAdmin, deployer, bananaCoin, fpc, userLog);
188
+ await setupBananaFPC(initialAccounts, deployer, userLog);
189
+ await setupSponsoredFPC(deployer, userLog);
248
190
  }
249
191
 
250
192
  const stop = async () => {
@@ -0,0 +1,46 @@
1
+ import type { FeePaymentMethod } from '@aztec/aztec.js';
2
+ import { ProtocolContractAddress } from '@aztec/protocol-contracts';
3
+ import { type FunctionCall, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
4
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
5
+ import type { PXE } from '@aztec/stdlib/interfaces/client';
6
+
7
+ import { getDeployedSponsoredFPCAddress } from './sponsored_fpc.js';
8
+
9
+ /**
10
+ * A payment method that uses the SponsoredFPCContract to pay the fee unconditionally.
11
+ */
12
+ export class SponsoredFeePaymentMethod implements FeePaymentMethod {
13
+ constructor(
14
+ /**
15
+ * Contract which will pay the fee.
16
+ */
17
+ private paymentContract: AztecAddress,
18
+ ) {}
19
+
20
+ static async new(pxe: PXE) {
21
+ const sponsoredFPC = await getDeployedSponsoredFPCAddress(pxe);
22
+ return new SponsoredFeePaymentMethod(sponsoredFPC);
23
+ }
24
+
25
+ getAsset(): Promise<AztecAddress> {
26
+ return Promise.resolve(ProtocolContractAddress.FeeJuice);
27
+ }
28
+
29
+ getFeePayer(): Promise<AztecAddress> {
30
+ return Promise.resolve(this.paymentContract);
31
+ }
32
+
33
+ async getFunctionCalls(): Promise<FunctionCall[]> {
34
+ return [
35
+ {
36
+ name: 'sponsor_unconditionally',
37
+ to: this.paymentContract,
38
+ selector: await FunctionSelector.fromSignature('sponsor_unconditionally()'),
39
+ type: FunctionType.PRIVATE,
40
+ isStatic: false,
41
+ args: [],
42
+ returnTypes: [],
43
+ },
44
+ ];
45
+ }
46
+ }
@@ -0,0 +1,38 @@
1
+ import {
2
+ type ContractInstanceWithAddress,
3
+ Fr,
4
+ type PXE,
5
+ type Wallet,
6
+ getContractInstanceFromDeployParams,
7
+ } from '@aztec/aztec.js';
8
+ import type { LogFn } from '@aztec/foundation/log';
9
+ import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
10
+
11
+ const SPONSORED_FPC_SALT = new Fr(0);
12
+
13
+ async function getSponsoredFPCInstance(): Promise<ContractInstanceWithAddress> {
14
+ return await getContractInstanceFromDeployParams(SponsoredFPCContract.artifact, {
15
+ salt: SPONSORED_FPC_SALT,
16
+ });
17
+ }
18
+
19
+ export async function getSponsoredFPCAddress() {
20
+ return (await getSponsoredFPCInstance()).address;
21
+ }
22
+
23
+ export async function setupSponsoredFPC(deployer: Wallet, log: LogFn) {
24
+ const deployed = await SponsoredFPCContract.deploy(deployer)
25
+ .send({ contractAddressSalt: SPONSORED_FPC_SALT, universalDeploy: true })
26
+ .deployed();
27
+
28
+ log(`SponsoredFPC: ${deployed.address}`);
29
+ }
30
+
31
+ export async function getDeployedSponsoredFPCAddress(pxe: PXE) {
32
+ const fpc = await getSponsoredFPCAddress();
33
+ const contracts = await pxe.getContracts();
34
+ if (!contracts.find(c => c.equals(fpc))) {
35
+ throw new Error('SponsoredFPC not deployed.');
36
+ }
37
+ return fpc;
38
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../src/sandbox.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,KAAK,eAAe,EAAE,gBAAgB,EAAoB,MAAM,mBAAmB,CAAC;AAE7F,OAAO,EAAE,KAAK,uBAAuB,EAAwB,MAAM,yBAAyB,CAAC;AAU7F,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,KAAK,KAAK,EAAgB,MAAM,uBAAuB,CAAC;AAKjE,OAAO,EAAE,KAAK,gBAAgB,EAAyC,MAAM,YAAY,CAAC;AAC1F,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EACL,KAAK,eAAe,EAGrB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,iBAAiB,EAA2D,MAAM,MAAM,CAAC;AAWvH;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,SAAS,GAAG,iBAAiB,EACxC,oBAAoB,mCAAS,EAC7B,IAAI,GAAE;IAAE,8BAA8B,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,kBAAkB,CAAC,EAAE,EAAE,CAAC;IAAC,gBAAgB,CAAC,EAAE,EAAE,CAAA;CAAO;;;;;;;;;;;;;;;;;;GA6BtH;AAuCD,wBAAsB,4BAA4B,CAAC,GAAG,EAAE,GAAG,yBAQ1D;AAED,wBAAsB,2BAA2B,CAAC,GAAG,EAAE,GAAG,yBASzD;AAED,wBAAwB;AACxB,MAAM,MAAM,aAAa,GAAG,eAAe,GAAG;IAC5C,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,qDAAqD;IACrD,KAAK,EAAE,OAAO,CAAC;IACf,uDAAuD;IACvD,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,MAAM,oCAA6B,EAAE,OAAO,EAAE,KAAK;;;;GAgGtF;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,MAAM,GAAE,OAAO,CAAC,eAAe,CAAM,EACrC,IAAI,GAAE;IAAE,SAAS,CAAC,EAAE,eAAe,CAAC;IAAC,cAAc,CAAC,EAAE,uBAAuB,CAAA;CAAO,EACpF,OAAO,GAAE;IAAE,mBAAmB,CAAC,EAAE,kBAAkB,EAAE,CAAA;CAAO,6BAY7D;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,GAAE,OAAO,CAAC,gBAAgB,CAAM,4CAI3F"}