1- import { createLogger , Fr , PXE , Logger , AccountManager } from "@aztec/aztec.js" ;
1+ import { createLogger , Fr , PXE , Logger , AccountManager , Fq } from "@aztec/aztec.js" ;
22import { getSchnorrAccount } from '@aztec/accounts/schnorr' ;
3- import { deriveSigningKey } from '@aztec/stdlib/keys' ;
43import { SponsoredFeePaymentMethod } from "@aztec/aztec.js/fee/testing" ;
54import { getSponsoredFPCInstance } from "./sponsored_fpc.js" ;
65import { SponsoredFPCContract } from "@aztec/noir-contracts.js/SponsoredFPC" ;
76
87export async function deploySchnorrAccount ( pxe : PXE ) : Promise < AccountManager > {
98 let logger : Logger ;
109 logger = createLogger ( 'aztec:aztec-starter' ) ;
11-
10+
1211 logger . info ( 'π€ Starting Schnorr account deployment...' ) ;
1312
1413 // Setup sponsored FPC
1514 logger . info ( 'π° Setting up sponsored fee payment for account deployment...' ) ;
1615 const sponsoredFPC = await getSponsoredFPCInstance ( ) ;
1716 logger . info ( `π° Sponsored FPC instance obtained at: ${ sponsoredFPC . address } ` ) ;
18-
17+
1918 logger . info ( 'π Registering sponsored FPC contract with PXE...' ) ;
2019 await pxe . registerContract ( { instance : sponsoredFPC , artifact : SponsoredFPCContract . artifact } ) ;
2120 const sponsoredPaymentMethod = new SponsoredFeePaymentMethod ( sponsoredFPC . address ) ;
@@ -24,24 +23,26 @@ export async function deploySchnorrAccount(pxe: PXE): Promise<AccountManager> {
2423 // Generate account keys
2524 logger . info ( 'π Generating account keys...' ) ;
2625 let secretKey = Fr . random ( ) ;
26+ let signingKey = Fq . random ( ) ;
2727 let salt = Fr . random ( ) ;
2828 logger . info ( `Save the following SECRET and SALT in .env for future use.` ) ;
2929 logger . info ( `π Secret key generated: ${ secretKey . toString ( ) } ` ) ;
30+ logger . info ( `ποΈ Signing key generated: ${ signingKey . toString ( ) } ` ) ;
3031 logger . info ( `π§ Salt generated: ${ salt . toString ( ) } ` ) ;
3132
3233 // Create Schnorr account
3334 logger . info ( 'ποΈ Creating Schnorr account instance...' ) ;
34- let schnorrAccount = await getSchnorrAccount ( pxe , secretKey , deriveSigningKey ( secretKey ) , salt ) ;
35+ let schnorrAccount = await getSchnorrAccount ( pxe , secretKey , signingKey , salt ) ;
3536 const accountAddress = schnorrAccount . getAddress ( ) ;
3637 logger . info ( `π Account address will be: ${ accountAddress } ` ) ;
3738
3839 // Deploy the account
3940 logger . info ( 'π Deploying account to the network...' ) ;
4041 logger . info ( 'β³ Waiting for account deployment transaction to be mined...' ) ;
41- let tx = await schnorrAccount . deploy ( {
42- fee : { paymentMethod : sponsoredPaymentMethod }
42+ let tx = await schnorrAccount . deploy ( {
43+ fee : { paymentMethod : sponsoredPaymentMethod }
4344 } ) . wait ( { timeout : 120000 } ) ;
44-
45+
4546 logger . info ( `β
Account deployment transaction successful!` ) ;
4647 logger . info ( `π Transaction hash: ${ tx . txHash } ` ) ;
4748
@@ -56,7 +57,7 @@ export async function deploySchnorrAccount(pxe: PXE): Promise<AccountManager> {
5657 try {
5758 const registeredAccounts = await pxe . getRegisteredAccounts ( ) ;
5859 const isRegistered = registeredAccounts . some ( acc => acc . address . equals ( deployedAddress ) ) ;
59-
60+
6061 if ( isRegistered ) {
6162 logger . info ( 'β
Account successfully registered with PXE' ) ;
6263 } else {
0 commit comments