11import { EasyPrivateVotingContractArtifact , EasyPrivateVotingContract } from "../artifacts/EasyPrivateVoting.js"
2- import { AccountWallet , CompleteAddress , ContractDeployer , createLogger , Fr , PXE , waitForPXE , TxStatus , createPXEClient , getContractInstanceFromDeployParams , Logger } from "@aztec/aztec.js" ;
3- import { getInitialTestAccountsWallets } from "@aztec/accounts/testing"
2+ import { AccountManager , AccountWallet , CompleteAddress , ContractDeployer , createLogger , Fr , PXE , waitForPXE , TxStatus , createPXEClient , getContractInstanceFromDeployParams , Logger } from "@aztec/aztec.js" ;
3+ import { getInitialTestAccountsWallets , generateSchnorrAccounts } from "@aztec/accounts/testing"
4+ import { getSchnorrAccount } from '@aztec/accounts/schnorr' ;
45import { spawn } from 'child_process' ;
6+ import { SponsoredFeePaymentMethod } from './sponsored_fee_payment_method.js' ;
57
68const setupSandbox = async ( ) => {
79 const { PXE_URL = 'http://localhost:8080' } = process . env ;
@@ -17,6 +19,7 @@ describe("Voting", () => {
1719 let accounts : CompleteAddress [ ] = [ ] ;
1820 let logger : Logger ;
1921 let sandboxInstance ;
22+ let sponsoredPaymentMethod : SponsoredFeePaymentMethod ;
2023
2124 beforeAll ( async ( ) => {
2225 sandboxInstance = spawn ( "aztec" , [ "start" , "--sandbox" ] , {
@@ -31,6 +34,7 @@ describe("Voting", () => {
3134
3235 wallets = await getInitialTestAccountsWallets ( pxe ) ;
3336 accounts = wallets . map ( w => w . getCompleteAddress ( ) )
37+ sponsoredPaymentMethod = await SponsoredFeePaymentMethod . new ( pxe ) ;
3438 } )
3539
3640 afterAll ( async ( ) => {
@@ -40,8 +44,17 @@ describe("Voting", () => {
4044 it ( "Deploys the contract" , async ( ) => {
4145 const salt = Fr . random ( ) ;
4246 const VotingContractArtifact = EasyPrivateVotingContractArtifact
43- const [ deployerWallet , adminWallet ] = wallets ; // using first account as deployer and second as contract admin
44- const adminAddress = adminWallet . getCompleteAddress ( ) . address ;
47+ // const [deployerWallet, adminWallet] = wallets; // using first account as deployer and second as contract admin
48+ const accounts = await Promise . all (
49+ ( await generateSchnorrAccounts ( 2 ) ) . map (
50+ async a => await getSchnorrAccount ( pxe , a . secret , a . signingKey , a . salt )
51+ )
52+ ) ;
53+ await Promise . all ( accounts . map ( a => a . deploy ( { fee : { paymentMethod : sponsoredPaymentMethod } } ) ) ) ;
54+ const daWallets = await Promise . all ( accounts . map ( a => a . getWallet ( ) ) ) ;
55+ const [ deployerWallet , adminWallet ] = daWallets ;
56+ const [ deployerAddress , adminAddress ] = daWallets . map ( w => w . getAddress ( ) ) ;
57+ // const adminAddress = adminWallet.getCompleteAddress().address;
4558
4659 const deploymentData = await getContractInstanceFromDeployParams ( VotingContractArtifact ,
4760 {
@@ -50,7 +63,10 @@ describe("Voting", () => {
5063 deployer : deployerWallet . getAddress ( )
5164 } ) ;
5265 const deployer = new ContractDeployer ( VotingContractArtifact , deployerWallet ) ;
53- const tx = deployer . deploy ( adminAddress ) . send ( { contractAddressSalt : salt } )
66+ const tx = deployer . deploy ( adminAddress ) . send ( {
67+ contractAddressSalt : salt ,
68+ fee : { paymentMethod : sponsoredPaymentMethod } // without the sponsoredFPC the deployment fails, thus confirming it works
69+ } )
5470 const receipt = await tx . getReceipt ( ) ;
5571
5672 expect ( receipt ) . toEqual (
0 commit comments