Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some small typo and convention #128

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (this *Controller) GetSigScheme() s.SignatureScheme {

type ControllerData struct {
ID string `json:"id"`
Public string `json:"publicKey,omitemtpy"`
Public string `json:"publicKey,omitempty"`
SigSch string `json:"signatureScheme"`
keypair.ProtectedKey
scrypt *keypair.ScryptParam
Expand Down Expand Up @@ -422,10 +422,8 @@ func VerifyID(id string) bool {
data := buf[:pos]
check := buf[pos:]
sum := checksum(data)
if !bytes.Equal(sum, check) {
return false
}
return true

return bytes.Equal(sum, check)
}

func checksum(data []byte) []byte {
Expand Down
1 change: 0 additions & 1 deletion native_contract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,4 @@ func TestOntId(t *testing.T) {
return
}
fmt.Printf("TestOntId GetDocumentJson:%+v\n", string(document))
return
}
17 changes: 8 additions & 9 deletions ont_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (
common3 "github.com/ontio/ontology-go-sdk/common"
"github.com/ontio/ontology-go-sdk/utils"
"github.com/ontio/ontology/common"
common2 "github.com/ontio/ontology/common"
"github.com/ontio/ontology/common/constants"
"github.com/ontio/ontology/core/payload"
"github.com/ontio/ontology/core/types"
Expand Down Expand Up @@ -79,7 +78,7 @@ func NewLayer2Sdk() *Layer2Sdk {
sdk.ChainId = common3.LAYER2_SYSTEM_ID
layer2Client := client.NewLayer2ClientMgr(&sdk.ClientMgr)
return &Layer2Sdk{
OntologySdk: sdk,
OntologySdk: sdk,
Layer2ClientMgr: layer2Client,
}
}
Expand Down Expand Up @@ -323,7 +322,7 @@ func isEnd(source *common.ZeroCopySource) (bool, error) {
}
}

func readAddress(source *common.ZeroCopySource) (common2.Address, error) {
func readAddress(source *common.ZeroCopySource) (common.Address, error) {
senderBytes, _, irregular, eof := source.NextVarBytes()
if irregular || eof {
return common.ADDRESS_EMPTY, io.ErrUnexpectedEOF
Expand Down Expand Up @@ -368,10 +367,10 @@ func (this *OntologySdk) GetPrivateKeyFromMnemonicCodesStrBip44(mnemonicCodesStr
if mnemonicCodesStr == "" {
return nil, fmt.Errorf("mnemonicCodesStr should not be nil")
}
//address_index
if index < 0 {
return nil, fmt.Errorf("index should be bigger than 0")
}
//address_index, u32 will never less than 0
// if index < 0 {
// return nil, fmt.Errorf("index should be bigger than 0")
// }
seed := bip39.NewSeed(mnemonicCodesStr, "")
masterKey, err := bip32.NewMasterKey(seed)
if err != nil {
Expand Down Expand Up @@ -404,7 +403,7 @@ func (this *OntologySdk) NewInvokeTransaction(gasPrice, gasLimit uint64, invokeC
TxType: types.InvokeNeo,
Nonce: rand.Uint32(),
Payload: invokePayload,
Sigs: make([]types.Sig, 0, 0),
Sigs: make([]types.Sig, 0),
}
return tx
}
Expand Down Expand Up @@ -508,7 +507,7 @@ func (this *OntologySdk) GetTxData(tx *types.MutableTransaction) (string, error)
if err != nil {
return "", fmt.Errorf("IntoImmutable error:%s", err)
}
sink := common2.ZeroCopySink{}
sink := common.ZeroCopySink{}
txData.Serialization(&sink)
rawtx := hex.EncodeToString(sink.Bytes())
return rawtx, nil
Expand Down
8 changes: 4 additions & 4 deletions wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,9 +630,9 @@ func (this *Wallet) Save() error {
for _, identity := range this.identities {
walletData.Identities = append(walletData.Identities, identity.ToIdentityData())
}
for _, acc := range this.accounts {
walletData.Accounts = append(walletData.Accounts, acc)
}

walletData.Accounts = append(walletData.Accounts, this.accounts...)

this.lock.RUnlock()
return walletData.Save(this.path)
}
Expand All @@ -653,7 +653,7 @@ func NewWalletData() *WalletData {
Scrypt: keypair.GetScryptParameters(),
Identities: nil,
Extra: "",
Accounts: make([]*AccountData, 0, 0),
Accounts: make([]*AccountData, 0),
}
}

Expand Down
3 changes: 3 additions & 0 deletions wasmvm_contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ func (this *WasmVMContract) DeployWasmVMSmartContract(
return common.UINT256_EMPTY, fmt.Errorf("code hex decode error:%s", err)
}
tx, err := utils2.NewDeployCodeTransaction(gasPrice, gasLimit, invokeCode, payload.WASMVM_TYPE, name, version, author, email, desc)
if err != nil {
return common.UINT256_EMPTY, fmt.Errorf("fail to create deploy tx: %v", err)
}
err = this.ontSdk.SignToTransaction(tx, singer)
if err != nil {
return common.Uint256{}, err
Expand Down