From 9321e3ce5e22fc2c88269b9bc0bc1eeb27369950 Mon Sep 17 00:00:00 2001 From: Marcos Date: Sun, 7 Jul 2024 21:18:40 -0300 Subject: [PATCH] add support to constructor arguments on deployment --- framework/framework.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/framework/framework.go b/framework/framework.go index b11d995..f93c463 100644 --- a/framework/framework.go +++ b/framework/framework.go @@ -253,14 +253,25 @@ type Chain struct { kettleAddr common.Address } -func (c *Chain) DeployContract(path string) *Contract { +func (c *Chain) DeployContract(path string, args ...interface{}) *Contract { artifact, err := ReadArtifact(path) if err != nil { panic(err) } + bytecode := artifact.Code + + // add contructor arguments + if len(args) > 0 { + packedArgs, err := artifact.Abi.Pack("", args...) + if err != nil { + panic(err) + } + bytecode = append(bytecode, packedArgs...) + } + // deploy contract - txnResult, err := sdk.DeployContract(artifact.Code, c.clt) + txnResult, err := sdk.DeployContract(bytecode, c.clt) if err != nil { panic(err) }