|
1 | 1 | package scenarios |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "context" |
| 5 | + "fmt" |
| 6 | + "log" |
4 | 7 | "math/big" |
| 8 | + "time" |
5 | 9 |
|
6 | 10 | "github.com/ethereum/go-ethereum/accounts/abi/bind" |
7 | 11 | "github.com/ethereum/go-ethereum/common" |
@@ -174,11 +178,29 @@ func (c *ContractScenarioBase[T]) DeployScenario(config *config.LoadConfig, depl |
174 | 178 | } |
175 | 179 |
|
176 | 180 | // Deploy using contract-specific logic |
177 | | - address, _, err := c.deployer.DeployContract(auth, client) |
| 181 | + address, tx, err := c.deployer.DeployContract(auth, client) |
178 | 182 | if err != nil { |
179 | 183 | panic("Failed to deploy contract: " + err.Error()) |
180 | 184 | } |
181 | 185 |
|
| 186 | + log.Printf("📤 Deployment transaction sent: %s", tx.Hash().Hex()) |
| 187 | + |
| 188 | + // Wait for the deployment transaction to be mined |
| 189 | + ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute) |
| 190 | + defer cancel() |
| 191 | + |
| 192 | + receipt, err := bind.WaitMined(ctx, client, tx) |
| 193 | + if err != nil { |
| 194 | + panic(fmt.Sprintf("Failed to wait for deployment transaction to be mined: %v", err)) |
| 195 | + } |
| 196 | + |
| 197 | + // Check if deployment was successful |
| 198 | + if receipt.Status != ethtypes.ReceiptStatusSuccessful { |
| 199 | + panic(fmt.Sprintf("Deployment transaction failed with status %d (tx: %s)", receipt.Status, tx.Hash().Hex())) |
| 200 | + } |
| 201 | + |
| 202 | + log.Printf("✅ Deployment successful at block %d (gas used: %d)", receipt.BlockNumber.Uint64(), receipt.GasUsed) |
| 203 | + |
182 | 204 | // Bind contract instance using the provided bind function |
183 | 205 | bindFunc := c.deployer.GetBindFunc() |
184 | 206 | contract, err := bindFunc(address, client) |
|
0 commit comments