-
Notifications
You must be signed in to change notification settings - Fork 324
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ioctl] Build contract deploy command line into new ioctl (#3708)
* [ioctl] build contract deploy command line into new ioctl * build unittest to cover the modification1~ * group iotex-core packages * remove stale comments Co-authored-by: huofei <68298506@qq.com>
- Loading branch information
1 parent
ba5fe4a
commit de9bd7a
Showing
2 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (c) 2022 IoTeX Foundation | ||
// This source code is provided 'as is' and no warranties are given as to title or non-infringement, | ||
// merchantability or fitness for purpose and, to the extent permitted by law, | ||
// all liability for your use of the code is disclaimed. This source code is governed by Apache | ||
// License 2.0 that can be found in the LICENSE file. | ||
|
||
package contract | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/iotexproject/iotex-core/ioctl" | ||
"github.com/iotexproject/iotex-core/ioctl/config" | ||
) | ||
|
||
// Multi-language support | ||
var ( | ||
_deployCmdShorts = map[config.Language]string{ | ||
config.English: "Deploy smart contract of IoTeX blockchain", | ||
config.Chinese: "在IoTeX区块链部署智能合约", | ||
} | ||
) | ||
|
||
// NewContractDeployCmd represents the contract deploy command | ||
func NewContractDeployCmd(client ioctl.Client) *cobra.Command { | ||
short, _ := client.SelectTranslation(_deployCmdShorts) | ||
cmd := &cobra.Command{ | ||
Use: "deploy", | ||
Short: short, | ||
} | ||
|
||
// TODO add sub commands | ||
// cmd.AddCommand(NewcontractDeployBytecodeCmd) | ||
// cmd.AddCommand(NewContractDeployBinCmd) | ||
// cmd.AddCommand(NewContractDeploySolCmd) | ||
// action.RegisterWriteCommand(NewContractDeployBytecodeCmd) | ||
// action.RegisterWriteCommand(NewContractDeployBinCmd) | ||
// action.RegisterWriteCommand(NewContractDeploySolCmd) | ||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) 2022 IoTeX Foundation | ||
// This source code is provided 'as is' and no warranties are given as to title or non-infringement, | ||
// merchantability or fitness for purpose and, to the extent permitted by law, | ||
// all liability for your use of the code is disclaimed. This source code is governed by Apache | ||
// License 2.0 that can be found in the LICENSE file. | ||
|
||
package contract | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/golang/mock/gomock" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/iotexproject/iotex-core/ioctl/config" | ||
"github.com/iotexproject/iotex-core/ioctl/util" | ||
"github.com/iotexproject/iotex-core/test/mock/mock_ioctlclient" | ||
) | ||
|
||
func TestNewContractDeployCmd(t *testing.T) { | ||
require := require.New(t) | ||
ctrl := gomock.NewController(t) | ||
defer ctrl.Finish() | ||
client := mock_ioctlclient.NewMockClient(ctrl) | ||
client.EXPECT().SelectTranslation(gomock.Any()).Return("contract", config.English).AnyTimes() | ||
|
||
cmd := NewContractDeployCmd(client) | ||
result, err := util.ExecuteCmd(cmd) | ||
require.NoError(err) | ||
require.Contains(result, "contract\n\n") | ||
} |