1
- import { Contract , DeploySentTx , waitForPXE } from "@aztec/aztec.js" ;
1
+ import {
2
+ AztecAddress ,
3
+ Contract ,
4
+ DeploySentTx ,
5
+ waitForPXE ,
6
+ } from "@aztec/aztec.js" ;
7
+ import { TokenContract } from "@aztec/noir-contracts.js/Token" ;
8
+ import * as tokenContractArtifactJson from "@aztec/noir-contracts.js/artifacts/token_contract-Token" assert { type : "json" } ;
2
9
import { logger } from "../../logger.js" ;
3
10
import { getAztecNodeClient , getPxe , getWallets } from "../pxe.js" ;
4
11
import {
5
12
deployContract ,
6
13
logAndWaitForTx ,
7
- registerContractClassArtifact ,
14
+ verifyContractInstanceDeployment ,
8
15
} from "./utils/index.js" ;
9
- import { TokenContract } from "@aztec/noir-contracts.js/Token" ;
10
- import * as tokenContractArtifactJson from "@aztec/noir-contracts.js/artifacts/token_contract-Token" assert { type : "json" } ;
11
16
12
17
export async function run ( ) {
13
18
logger . info ( "===== TOKEN CONTRACT =====" ) ;
@@ -19,47 +24,68 @@ export async function run() {
19
24
const tokenAdmin = namedWallets . alice . getAddress ( ) ;
20
25
21
26
const contractLoggingName = "Token Contract" ;
27
+ const constructorArgs : [ AztecAddress , string , string , number ] = [
28
+ tokenAdmin ,
29
+ "lol" ,
30
+ "LOL" ,
31
+ 9 ,
32
+ ] ;
22
33
const tokenContract = await deployContract ( {
23
34
contractLoggingName,
24
35
deployFn : ( ) : DeploySentTx < TokenContract > => {
25
36
return TokenContract . deploy (
26
37
deployerWallet ,
27
- tokenAdmin ,
28
- "lol" ,
29
- "LOL" ,
30
- 9
38
+ constructorArgs [ 0 ] ,
39
+ constructorArgs [ 1 ] ,
40
+ constructorArgs [ 2 ] ,
41
+ constructorArgs [ 3 ] ,
31
42
) . send ( ) ;
32
43
} ,
33
44
node : getAztecNodeClient ( ) ,
34
45
} ) ;
35
46
36
- registerContractClassArtifact (
47
+ verifyContractInstanceDeployment ( {
37
48
contractLoggingName,
38
- tokenContractArtifactJson ,
39
- tokenContract . instance . contractClassId . toString ( ) ,
40
- tokenContract . instance . version
41
- ) . catch ( ( err ) => {
42
- logger . error ( err ) ;
49
+ contractInstanceAddress : tokenContract . address . toString ( ) ,
50
+ verifyArgs : {
51
+ artifactObj : tokenContractArtifactJson ,
52
+ publicKeysString : tokenContract . instance . publicKeys . toString ( ) ,
53
+ deployer : tokenContract . instance . deployer . toString ( ) ,
54
+ salt : tokenContract . instance . salt . toString ( ) ,
55
+ constructorArgs : constructorArgs . map ( ( arg ) => arg . toString ( ) ) ,
56
+ } ,
57
+ deployerMetadata : {
58
+ contractIdentifier : contractLoggingName ,
59
+ details : "Token contract" ,
60
+ creatorName : "Event Cannon" ,
61
+ creatorContact :
62
+ "email: [email protected] , discord: test#1234, telegram: @test" ,
63
+ appUrl : "https://aztec.network" ,
64
+ repoUrl : "https://github.com/AztecProtocol/aztec-packages" ,
65
+ reviewedAt : new Date ( ) ,
66
+ } ,
67
+ } ) . catch ( ( err ) => {
68
+ logger . error ( `Failed to verify contract instance deployment: ${ err } ` ) ;
43
69
} ) ;
44
70
45
71
await Promise . all ( [
46
72
logAndWaitForTx (
47
73
tokenContract . methods
48
74
. mint_to_public ( namedWallets . alice . getAddress ( ) , 1000 )
49
75
. send ( ) ,
50
- "Mint to Alice"
76
+ "Mint to Alice" ,
51
77
) ,
52
78
logAndWaitForTx (
53
79
tokenContract . methods
54
80
. mint_to_public ( namedWallets . bob . getAddress ( ) , 1000 )
55
81
. send ( ) ,
56
- "Mint to Bob"
82
+ "Mint to Bob" ,
57
83
) ,
58
84
logAndWaitForTx (
59
85
tokenContract . methods
60
86
. mint_to_public ( namedWallets . charlie . getAddress ( ) , 1000 )
61
87
. send ( ) ,
62
- "Mint to Charlie"
88
+ "Mint to Charlie" ,
63
89
) ,
64
90
] ) ;
65
91
const [ balanceAlice , balanceBob , balanceCharlie ] = await Promise . all ( [
@@ -83,19 +109,19 @@ export async function run() {
83
109
const aliceContract = ( await Contract . at (
84
110
tokenContract . address ,
85
111
TokenContract . artifact ,
86
- namedWallets . alice
112
+ namedWallets . alice ,
87
113
) ) as TokenContract ;
88
114
89
115
const bobsTokenContract = ( await Contract . at (
90
116
tokenContract . address ,
91
117
TokenContract . artifact ,
92
- namedWallets . bob
118
+ namedWallets . bob ,
93
119
) ) as TokenContract ;
94
120
95
121
const charliesTokenContract = ( await Contract . at (
96
122
tokenContract . address ,
97
123
TokenContract . artifact ,
98
- namedWallets . charlie
124
+ namedWallets . charlie ,
99
125
) ) as TokenContract ;
100
126
101
127
let bobNonce = 0 ;
@@ -105,10 +131,10 @@ export async function run() {
105
131
namedWallets . bob . getAddress ( ) ,
106
132
namedWallets . alice . getAddress ( ) ,
107
133
100 ,
108
- bobNonce
134
+ bobNonce ,
109
135
)
110
136
. send ( ) ,
111
- "Public transfer from Alice to Bob"
137
+ "Public transfer from Alice to Bob" ,
112
138
) ;
113
139
bobNonce ++ ;
114
140
@@ -130,7 +156,7 @@ export async function run() {
130
156
charliesTokenContract . methods
131
157
. transfer_to_private ( namedWallets . alice . getAddress ( ) , 100 )
132
158
. send ( ) ,
133
- "Public to private transfer from Charlie to Alice"
159
+ "Public to private transfer from Charlie to Alice" ,
134
160
) ;
135
161
136
162
let aliceNonce = 0 ;
@@ -140,10 +166,10 @@ export async function run() {
140
166
namedWallets . alice . getAddress ( ) ,
141
167
namedWallets . bob . getAddress ( ) ,
142
168
100 ,
143
- aliceNonce
169
+ aliceNonce ,
144
170
)
145
171
. send ( ) ,
146
- "Private transfer from Bob to Alice"
172
+ "Private transfer from Bob to Alice" ,
147
173
) ;
148
174
aliceNonce ++ ;
149
175
0 commit comments