Skip to content

Commit

Permalink
Merge pull request #6 from radianceteam/generator_fix
Browse files Browse the repository at this point in the history
[generator_fix] Fix non-string enum consts generation
  • Loading branch information
risentveber authored Feb 13, 2021
2 parents fc5fd39 + bb5acb8 commit 5022833
Show file tree
Hide file tree
Showing 16 changed files with 432 additions and 254 deletions.
5 changes: 4 additions & 1 deletion client/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import (
"fmt"
)

var errorCodesToErrorTypes = map[uint32]string{}

func (e *Error) Error() string {
if e == nil {
return ""
}

return fmt.Sprintf("%s, sdk_error_code=%d", e.Message, e.Code)
return fmt.Sprintf("sdk_error_code=%d,\n sdk_error_code_description=%s,\n sdk_error_msg='%s',\n sdk_error_data: '%s'",
e.Code, errorCodesToErrorTypes[e.Code], e.Message, e.Data)
}
40 changes: 26 additions & 14 deletions client/mod_abi.gen.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package client

// DON'T EDIT THIS FILE is generated 13 Feb 21 11:00 UTC
// DON'T EDIT THIS FILE! It is generated via 'task generate' at 13 Feb 21 15:01 UTC
//
// Mod abi
//
Expand All @@ -13,22 +13,34 @@ import (
"github.com/volatiletech/null"
)

type AbiErrorCode string

const (
RequiredAddressMissingForEncodeMessageAbiErrorCode AbiErrorCode = "RequiredAddressMissingForEncodeMessage"
RequiredCallSetMissingForEncodeMessageAbiErrorCode AbiErrorCode = "RequiredCallSetMissingForEncodeMessage"
InvalidJSONAbiErrorCode AbiErrorCode = "InvalidJson"
InvalidMessageAbiErrorCode AbiErrorCode = "InvalidMessage"
EncodeDeployMessageFailedAbiErrorCode AbiErrorCode = "EncodeDeployMessageFailed"
EncodeRunMessageFailedAbiErrorCode AbiErrorCode = "EncodeRunMessageFailed"
AttachSignatureFailedAbiErrorCode AbiErrorCode = "AttachSignatureFailed"
InvalidTvcImageAbiErrorCode AbiErrorCode = "InvalidTvcImage"
RequiredPublicKeyMissingForFunctionHeaderAbiErrorCode AbiErrorCode = "RequiredPublicKeyMissingForFunctionHeader"
InvalidSignerAbiErrorCode AbiErrorCode = "InvalidSigner"
InvalidAbiAbiErrorCode AbiErrorCode = "InvalidAbi"
RequiredAddressMissingForEncodeMessageAbiErrorCode = 301
RequiredCallSetMissingForEncodeMessageAbiErrorCode = 302
InvalidJSONAbiErrorCode = 303
InvalidMessageAbiErrorCode = 304
EncodeDeployMessageFailedAbiErrorCode = 305
EncodeRunMessageFailedAbiErrorCode = 306
AttachSignatureFailedAbiErrorCode = 307
InvalidTvcImageAbiErrorCode = 308
RequiredPublicKeyMissingForFunctionHeaderAbiErrorCode = 309
InvalidSignerAbiErrorCode = 310
InvalidAbiAbiErrorCode = 311
)

func init() { // nolint gochecknoinits
errorCodesToErrorTypes[RequiredAddressMissingForEncodeMessageAbiErrorCode] = "RequiredAddressMissingForEncodeMessageAbiErrorCode"
errorCodesToErrorTypes[RequiredCallSetMissingForEncodeMessageAbiErrorCode] = "RequiredCallSetMissingForEncodeMessageAbiErrorCode"
errorCodesToErrorTypes[InvalidJSONAbiErrorCode] = "InvalidJSONAbiErrorCode"
errorCodesToErrorTypes[InvalidMessageAbiErrorCode] = "InvalidMessageAbiErrorCode"
errorCodesToErrorTypes[EncodeDeployMessageFailedAbiErrorCode] = "EncodeDeployMessageFailedAbiErrorCode"
errorCodesToErrorTypes[EncodeRunMessageFailedAbiErrorCode] = "EncodeRunMessageFailedAbiErrorCode"
errorCodesToErrorTypes[AttachSignatureFailedAbiErrorCode] = "AttachSignatureFailedAbiErrorCode"
errorCodesToErrorTypes[InvalidTvcImageAbiErrorCode] = "InvalidTvcImageAbiErrorCode"
errorCodesToErrorTypes[RequiredPublicKeyMissingForFunctionHeaderAbiErrorCode] = "RequiredPublicKeyMissingForFunctionHeaderAbiErrorCode"
errorCodesToErrorTypes[InvalidSignerAbiErrorCode] = "InvalidSignerAbiErrorCode"
errorCodesToErrorTypes[InvalidAbiAbiErrorCode] = "InvalidAbiAbiErrorCode"
}

type (
AbiHandle uint32
FunctionHeader struct {
Expand Down
28 changes: 18 additions & 10 deletions client/mod_boc.gen.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package client

// DON'T EDIT THIS FILE is generated 13 Feb 21 11:00 UTC
// DON'T EDIT THIS FILE! It is generated via 'task generate' at 13 Feb 21 15:01 UTC
//
// Mod boc
//
Expand Down Expand Up @@ -30,18 +30,26 @@ type BocCacheType struct {
Pin string `json:"pin"`
}

type BocErrorCode string

const (
InvalidBocBocErrorCode BocErrorCode = "InvalidBoc"
SerializationErrorBocErrorCode BocErrorCode = "SerializationError"
InappropriateBlockBocErrorCode BocErrorCode = "InappropriateBlock"
MissingSourceBocBocErrorCode BocErrorCode = "MissingSourceBoc"
InsufficientCacheSizeBocErrorCode BocErrorCode = "InsufficientCacheSize"
BocRefNotFoundBocErrorCode BocErrorCode = "BocRefNotFound"
InvalidBocRefBocErrorCode BocErrorCode = "InvalidBocRef"
InvalidBocBocErrorCode = 201
SerializationErrorBocErrorCode = 202
InappropriateBlockBocErrorCode = 203
MissingSourceBocBocErrorCode = 204
InsufficientCacheSizeBocErrorCode = 205
BocRefNotFoundBocErrorCode = 206
InvalidBocRefBocErrorCode = 207
)

func init() { // nolint gochecknoinits
errorCodesToErrorTypes[InvalidBocBocErrorCode] = "InvalidBocBocErrorCode"
errorCodesToErrorTypes[SerializationErrorBocErrorCode] = "SerializationErrorBocErrorCode"
errorCodesToErrorTypes[InappropriateBlockBocErrorCode] = "InappropriateBlockBocErrorCode"
errorCodesToErrorTypes[MissingSourceBocBocErrorCode] = "MissingSourceBocBocErrorCode"
errorCodesToErrorTypes[InsufficientCacheSizeBocErrorCode] = "InsufficientCacheSizeBocErrorCode"
errorCodesToErrorTypes[BocRefNotFoundBocErrorCode] = "BocRefNotFoundBocErrorCode"
errorCodesToErrorTypes[InvalidBocRefBocErrorCode] = "InvalidBocRefBocErrorCode"
}

type ParamsOfParse struct {
// BOC encoded as base64.
Boc string `json:"boc"`
Expand Down
106 changes: 70 additions & 36 deletions client/mod_client.gen.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package client

// DON'T EDIT THIS FILE is generated 13 Feb 21 11:00 UTC
// DON'T EDIT THIS FILE! It is generated via 'task generate' at 13 Feb 21 15:01 UTC
//
// Mod client
//
Expand All @@ -12,44 +12,78 @@ import (
"github.com/volatiletech/null"
)

type ErrorCode string

const (
NotImplementedErrorCode ErrorCode = "NotImplemented"
InvalidHexErrorCode ErrorCode = "InvalidHex"
InvalidBase64ErrorCode ErrorCode = "InvalidBase64"
InvalidAddressErrorCode ErrorCode = "InvalidAddress"
CallbackParamsCantBeConvertedToJSONErrorCode ErrorCode = "CallbackParamsCantBeConvertedToJson"
WebsocketConnectErrorErrorCode ErrorCode = "WebsocketConnectError"
WebsocketReceiveErrorErrorCode ErrorCode = "WebsocketReceiveError"
WebsocketSendErrorErrorCode ErrorCode = "WebsocketSendError"
HTTPClientCreateErrorErrorCode ErrorCode = "HttpClientCreateError"
HTTPRequestCreateErrorErrorCode ErrorCode = "HttpRequestCreateError"
HTTPRequestSendErrorErrorCode ErrorCode = "HttpRequestSendError"
HTTPRequestParseErrorErrorCode ErrorCode = "HttpRequestParseError"
CallbackNotRegisteredErrorCode ErrorCode = "CallbackNotRegistered"
NetModuleNotInitErrorCode ErrorCode = "NetModuleNotInit"
InvalidConfigErrorCode ErrorCode = "InvalidConfig"
CannotCreateRuntimeErrorCode ErrorCode = "CannotCreateRuntime"
InvalidContextHandleErrorCode ErrorCode = "InvalidContextHandle"
CannotSerializeResultErrorCode ErrorCode = "CannotSerializeResult"
CannotSerializeErrorErrorCode ErrorCode = "CannotSerializeError"
CannotConvertJsValueToJSONErrorCode ErrorCode = "CannotConvertJsValueToJson"
CannotReceiveSpawnedResultErrorCode ErrorCode = "CannotReceiveSpawnedResult"
SetTimerErrorErrorCode ErrorCode = "SetTimerError"
InvalidParamsErrorCode ErrorCode = "InvalidParams"
ContractsAddressConversionFailedErrorCode ErrorCode = "ContractsAddressConversionFailed"
UnknownFunctionErrorCode ErrorCode = "UnknownFunction"
AppRequestErrorErrorCode ErrorCode = "AppRequestError"
NoSuchRequestErrorCode ErrorCode = "NoSuchRequest"
CanNotSendRequestResultErrorCode ErrorCode = "CanNotSendRequestResult"
CanNotReceiveRequestResultErrorCode ErrorCode = "CanNotReceiveRequestResult"
CanNotParseRequestResultErrorCode ErrorCode = "CanNotParseRequestResult"
UnexpectedCallbackResponseErrorCode ErrorCode = "UnexpectedCallbackResponse"
CanNotParseNumberErrorCode ErrorCode = "CanNotParseNumber"
InternalErrorErrorCode ErrorCode = "InternalError"
NotImplementedErrorCode = 1
InvalidHexErrorCode = 2
InvalidBase64ErrorCode = 3
InvalidAddressErrorCode = 4
CallbackParamsCantBeConvertedToJSONErrorCode = 5
WebsocketConnectErrorErrorCode = 6
WebsocketReceiveErrorErrorCode = 7
WebsocketSendErrorErrorCode = 8
HTTPClientCreateErrorErrorCode = 9
HTTPRequestCreateErrorErrorCode = 10
HTTPRequestSendErrorErrorCode = 11
HTTPRequestParseErrorErrorCode = 12
CallbackNotRegisteredErrorCode = 13
NetModuleNotInitErrorCode = 14
InvalidConfigErrorCode = 15
CannotCreateRuntimeErrorCode = 16
InvalidContextHandleErrorCode = 17
CannotSerializeResultErrorCode = 18
CannotSerializeErrorErrorCode = 19
CannotConvertJsValueToJSONErrorCode = 20
CannotReceiveSpawnedResultErrorCode = 21
SetTimerErrorErrorCode = 22
InvalidParamsErrorCode = 23
ContractsAddressConversionFailedErrorCode = 24
UnknownFunctionErrorCode = 25
AppRequestErrorErrorCode = 26
NoSuchRequestErrorCode = 27
CanNotSendRequestResultErrorCode = 28
CanNotReceiveRequestResultErrorCode = 29
CanNotParseRequestResultErrorCode = 30
UnexpectedCallbackResponseErrorCode = 31
CanNotParseNumberErrorCode = 32
InternalErrorErrorCode = 33
)

func init() { // nolint gochecknoinits
errorCodesToErrorTypes[NotImplementedErrorCode] = "NotImplementedErrorCode"
errorCodesToErrorTypes[InvalidHexErrorCode] = "InvalidHexErrorCode"
errorCodesToErrorTypes[InvalidBase64ErrorCode] = "InvalidBase64ErrorCode"
errorCodesToErrorTypes[InvalidAddressErrorCode] = "InvalidAddressErrorCode"
errorCodesToErrorTypes[CallbackParamsCantBeConvertedToJSONErrorCode] = "CallbackParamsCantBeConvertedToJSONErrorCode"
errorCodesToErrorTypes[WebsocketConnectErrorErrorCode] = "WebsocketConnectErrorErrorCode"
errorCodesToErrorTypes[WebsocketReceiveErrorErrorCode] = "WebsocketReceiveErrorErrorCode"
errorCodesToErrorTypes[WebsocketSendErrorErrorCode] = "WebsocketSendErrorErrorCode"
errorCodesToErrorTypes[HTTPClientCreateErrorErrorCode] = "HTTPClientCreateErrorErrorCode"
errorCodesToErrorTypes[HTTPRequestCreateErrorErrorCode] = "HTTPRequestCreateErrorErrorCode"
errorCodesToErrorTypes[HTTPRequestSendErrorErrorCode] = "HTTPRequestSendErrorErrorCode"
errorCodesToErrorTypes[HTTPRequestParseErrorErrorCode] = "HTTPRequestParseErrorErrorCode"
errorCodesToErrorTypes[CallbackNotRegisteredErrorCode] = "CallbackNotRegisteredErrorCode"
errorCodesToErrorTypes[NetModuleNotInitErrorCode] = "NetModuleNotInitErrorCode"
errorCodesToErrorTypes[InvalidConfigErrorCode] = "InvalidConfigErrorCode"
errorCodesToErrorTypes[CannotCreateRuntimeErrorCode] = "CannotCreateRuntimeErrorCode"
errorCodesToErrorTypes[InvalidContextHandleErrorCode] = "InvalidContextHandleErrorCode"
errorCodesToErrorTypes[CannotSerializeResultErrorCode] = "CannotSerializeResultErrorCode"
errorCodesToErrorTypes[CannotSerializeErrorErrorCode] = "CannotSerializeErrorErrorCode"
errorCodesToErrorTypes[CannotConvertJsValueToJSONErrorCode] = "CannotConvertJsValueToJSONErrorCode"
errorCodesToErrorTypes[CannotReceiveSpawnedResultErrorCode] = "CannotReceiveSpawnedResultErrorCode"
errorCodesToErrorTypes[SetTimerErrorErrorCode] = "SetTimerErrorErrorCode"
errorCodesToErrorTypes[InvalidParamsErrorCode] = "InvalidParamsErrorCode"
errorCodesToErrorTypes[ContractsAddressConversionFailedErrorCode] = "ContractsAddressConversionFailedErrorCode"
errorCodesToErrorTypes[UnknownFunctionErrorCode] = "UnknownFunctionErrorCode"
errorCodesToErrorTypes[AppRequestErrorErrorCode] = "AppRequestErrorErrorCode"
errorCodesToErrorTypes[NoSuchRequestErrorCode] = "NoSuchRequestErrorCode"
errorCodesToErrorTypes[CanNotSendRequestResultErrorCode] = "CanNotSendRequestResultErrorCode"
errorCodesToErrorTypes[CanNotReceiveRequestResultErrorCode] = "CanNotReceiveRequestResultErrorCode"
errorCodesToErrorTypes[CanNotParseRequestResultErrorCode] = "CanNotParseRequestResultErrorCode"
errorCodesToErrorTypes[UnexpectedCallbackResponseErrorCode] = "UnexpectedCallbackResponseErrorCode"
errorCodesToErrorTypes[CanNotParseNumberErrorCode] = "CanNotParseNumberErrorCode"
errorCodesToErrorTypes[InternalErrorErrorCode] = "InternalErrorErrorCode"
}

type Error struct {
Code uint32 `json:"code"`
Message string `json:"message"`
Expand Down
67 changes: 44 additions & 23 deletions client/mod_crypto.gen.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package client

// DON'T EDIT THIS FILE is generated 13 Feb 21 11:00 UTC
// DON'T EDIT THIS FILE! It is generated via 'task generate' at 13 Feb 21 15:01 UTC
//
// Mod crypto
//
Expand All @@ -12,31 +12,52 @@ import (
"github.com/volatiletech/null"
)

type CryptoErrorCode string

const (
InvalidPublicKeyCryptoErrorCode CryptoErrorCode = "InvalidPublicKey"
InvalidSecretKeyCryptoErrorCode CryptoErrorCode = "InvalidSecretKey"
InvalidKeyCryptoErrorCode CryptoErrorCode = "InvalidKey"
InvalidFactorizeChallengeCryptoErrorCode CryptoErrorCode = "InvalidFactorizeChallenge"
InvalidBigIntCryptoErrorCode CryptoErrorCode = "InvalidBigInt"
ScryptFailedCryptoErrorCode CryptoErrorCode = "ScryptFailed"
InvalidKeySizeCryptoErrorCode CryptoErrorCode = "InvalidKeySize"
NaclSecretBoxFailedCryptoErrorCode CryptoErrorCode = "NaclSecretBoxFailed"
NaclBoxFailedCryptoErrorCode CryptoErrorCode = "NaclBoxFailed"
NaclSignFailedCryptoErrorCode CryptoErrorCode = "NaclSignFailed"
Bip39InvalidEntropyCryptoErrorCode CryptoErrorCode = "Bip39InvalidEntropy"
Bip39InvalidPhraseCryptoErrorCode CryptoErrorCode = "Bip39InvalidPhrase"
Bip32InvalidKeyCryptoErrorCode CryptoErrorCode = "Bip32InvalidKey"
Bip32InvalidDerivePathCryptoErrorCode CryptoErrorCode = "Bip32InvalidDerivePath"
Bip39InvalidDictionaryCryptoErrorCode CryptoErrorCode = "Bip39InvalidDictionary"
Bip39InvalidWordCountCryptoErrorCode CryptoErrorCode = "Bip39InvalidWordCount"
MnemonicGenerationFailedCryptoErrorCode CryptoErrorCode = "MnemonicGenerationFailed"
MnemonicFromEntropyFailedCryptoErrorCode CryptoErrorCode = "MnemonicFromEntropyFailed"
SigningBoxNotRegisteredCryptoErrorCode CryptoErrorCode = "SigningBoxNotRegistered"
InvalidSignatureCryptoErrorCode CryptoErrorCode = "InvalidSignature"
InvalidPublicKeyCryptoErrorCode = 100
InvalidSecretKeyCryptoErrorCode = 101
InvalidKeyCryptoErrorCode = 102
InvalidFactorizeChallengeCryptoErrorCode = 106
InvalidBigIntCryptoErrorCode = 107
ScryptFailedCryptoErrorCode = 108
InvalidKeySizeCryptoErrorCode = 109
NaclSecretBoxFailedCryptoErrorCode = 110
NaclBoxFailedCryptoErrorCode = 111
NaclSignFailedCryptoErrorCode = 112
Bip39InvalidEntropyCryptoErrorCode = 113
Bip39InvalidPhraseCryptoErrorCode = 114
Bip32InvalidKeyCryptoErrorCode = 115
Bip32InvalidDerivePathCryptoErrorCode = 116
Bip39InvalidDictionaryCryptoErrorCode = 117
Bip39InvalidWordCountCryptoErrorCode = 118
MnemonicGenerationFailedCryptoErrorCode = 119
MnemonicFromEntropyFailedCryptoErrorCode = 120
SigningBoxNotRegisteredCryptoErrorCode = 121
InvalidSignatureCryptoErrorCode = 122
)

func init() { // nolint gochecknoinits
errorCodesToErrorTypes[InvalidPublicKeyCryptoErrorCode] = "InvalidPublicKeyCryptoErrorCode"
errorCodesToErrorTypes[InvalidSecretKeyCryptoErrorCode] = "InvalidSecretKeyCryptoErrorCode"
errorCodesToErrorTypes[InvalidKeyCryptoErrorCode] = "InvalidKeyCryptoErrorCode"
errorCodesToErrorTypes[InvalidFactorizeChallengeCryptoErrorCode] = "InvalidFactorizeChallengeCryptoErrorCode"
errorCodesToErrorTypes[InvalidBigIntCryptoErrorCode] = "InvalidBigIntCryptoErrorCode"
errorCodesToErrorTypes[ScryptFailedCryptoErrorCode] = "ScryptFailedCryptoErrorCode"
errorCodesToErrorTypes[InvalidKeySizeCryptoErrorCode] = "InvalidKeySizeCryptoErrorCode"
errorCodesToErrorTypes[NaclSecretBoxFailedCryptoErrorCode] = "NaclSecretBoxFailedCryptoErrorCode"
errorCodesToErrorTypes[NaclBoxFailedCryptoErrorCode] = "NaclBoxFailedCryptoErrorCode"
errorCodesToErrorTypes[NaclSignFailedCryptoErrorCode] = "NaclSignFailedCryptoErrorCode"
errorCodesToErrorTypes[Bip39InvalidEntropyCryptoErrorCode] = "Bip39InvalidEntropyCryptoErrorCode"
errorCodesToErrorTypes[Bip39InvalidPhraseCryptoErrorCode] = "Bip39InvalidPhraseCryptoErrorCode"
errorCodesToErrorTypes[Bip32InvalidKeyCryptoErrorCode] = "Bip32InvalidKeyCryptoErrorCode"
errorCodesToErrorTypes[Bip32InvalidDerivePathCryptoErrorCode] = "Bip32InvalidDerivePathCryptoErrorCode"
errorCodesToErrorTypes[Bip39InvalidDictionaryCryptoErrorCode] = "Bip39InvalidDictionaryCryptoErrorCode"
errorCodesToErrorTypes[Bip39InvalidWordCountCryptoErrorCode] = "Bip39InvalidWordCountCryptoErrorCode"
errorCodesToErrorTypes[MnemonicGenerationFailedCryptoErrorCode] = "MnemonicGenerationFailedCryptoErrorCode"
errorCodesToErrorTypes[MnemonicFromEntropyFailedCryptoErrorCode] = "MnemonicFromEntropyFailedCryptoErrorCode"
errorCodesToErrorTypes[SigningBoxNotRegisteredCryptoErrorCode] = "SigningBoxNotRegisteredCryptoErrorCode"
errorCodesToErrorTypes[InvalidSignatureCryptoErrorCode] = "InvalidSignatureCryptoErrorCode"
}

type (
SigningBoxHandle uint32
ParamsOfFactorize struct {
Expand Down
Loading

0 comments on commit 5022833

Please sign in to comment.