diff --git a/griddriver/main.go b/griddriver/main.go index 606e40daa..b1af3d843 100644 --- a/griddriver/main.go +++ b/griddriver/main.go @@ -511,6 +511,11 @@ func main() { Usage: "json encoding of list of substrate BatchCreateContractData objects", Required: true, }, + cli.StringFlag{ + Name: "contracts-body", + Usage: "deployment body string", + Required: true, + }, }, Action: substrateDecorator(batchAllCreateContract), }, diff --git a/griddriver/substrate.go b/griddriver/substrate.go index b17c8d854..62ab48b4d 100644 --- a/griddriver/substrate.go +++ b/griddriver/substrate.go @@ -152,6 +152,7 @@ func signDeployment(ctx *cli.Context, sub *substrate.Substrate, identity substra } func batchAllCreateContract(ctx *cli.Context, sub *substrate.Substrate, identity substrate.Identity) (interface{}, error) { + body := ctx.String("contracts-body") data := []byte(ctx.String("contracts-data")) contractData := []substrate.BatchCreateContractData{} @@ -159,6 +160,12 @@ func batchAllCreateContract(ctx *cli.Context, sub *substrate.Substrate, identity return nil, fmt.Errorf("failed to decode contract data: %w", err) } + for id := range contractData { + if contractData[id].Name == "" { + contractData[id].Body = body + } + } + contractIds, err := sub.BatchAllCreateContract(identity, contractData) if err != nil { return nil, fmt.Errorf("failed to create contracts: %w", err) @@ -169,7 +176,7 @@ func batchAllCreateContract(ctx *cli.Context, sub *substrate.Substrate, identity return nil, fmt.Errorf("failed to encode contract ids: %w", err) } - return ret, nil + return string(ret), nil } func batchCancelContract(ctx *cli.Context, sub *substrate.Substrate, identity substrate.Identity) (interface{}, error) {