diff --git a/helpers/transaction_request.go b/helpers/transaction_request.go index 2e1fba270..9a959d893 100644 --- a/helpers/transaction_request.go +++ b/helpers/transaction_request.go @@ -4,17 +4,17 @@ package helpers import ( - "encoding/json" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "net/http" ) type TransactionRequest interface { GetCommonTransactionRequest() CommonTransactionRequest FromCLI(CLICommand, client.Context) (TransactionRequest, error) - FromJSON(json.RawMessage) (TransactionRequest, error) + FromHTTPRequest(*http.Request) (TransactionRequest, error) MakeMsg() (sdkTypes.Msg, error) RegisterLegacyAminoCodec(*codec.LegacyAmino) Request diff --git a/x/assets/transactions/burn/transaction_request.go b/x/assets/transactions/burn/transaction_request.go index 40687cbc9..61efab024 100644 --- a/x/assets/transactions/burn/transaction_request.go +++ b/x/assets/transactions/burn/transaction_request.go @@ -9,8 +9,10 @@ import ( "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" + sdkCodec "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" @@ -50,8 +52,13 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.AssetID), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } @@ -82,7 +89,7 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { assetID.(ids.AssetID), ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { +func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) { codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) } func requestPrototype() helpers.TransactionRequest { diff --git a/x/assets/transactions/define/transaction_request.go b/x/assets/transactions/define/transaction_request.go index 1e260b9cf..22b6febc4 100644 --- a/x/assets/transactions/define/transaction_request.go +++ b/x/assets/transactions/define/transaction_request.go @@ -10,8 +10,10 @@ import ( baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" + sdkCodec "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" @@ -57,8 +59,13 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.MutableProperties), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } @@ -109,7 +116,7 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { mutableProperties, ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { +func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) { codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) } func requestPrototype() helpers.TransactionRequest { diff --git a/x/assets/transactions/deputize/transaction_request.go b/x/assets/transactions/deputize/transaction_request.go index b88696ab4..0aa25e61b 100644 --- a/x/assets/transactions/deputize/transaction_request.go +++ b/x/assets/transactions/deputize/transaction_request.go @@ -10,8 +10,10 @@ import ( baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" + sdkCodec "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" @@ -67,8 +69,13 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadBool(constants.CanMutateMaintainer), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } @@ -117,7 +124,7 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { transactionRequest.CanMutateMaintainer, ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { +func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) { codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) } func requestPrototype() helpers.TransactionRequest { diff --git a/x/assets/transactions/mint/transaction_request.go b/x/assets/transactions/mint/transaction_request.go index e251a03a1..37486c74e 100644 --- a/x/assets/transactions/mint/transaction_request.go +++ b/x/assets/transactions/mint/transaction_request.go @@ -10,8 +10,10 @@ import ( baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" + sdkCodec "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" @@ -61,8 +63,13 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.MutableProperties), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } @@ -125,7 +132,7 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { mutableProperties, ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { +func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) { codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) } func requestPrototype() helpers.TransactionRequest { diff --git a/x/assets/transactions/mutate/transaction_request.go b/x/assets/transactions/mutate/transaction_request.go index ac6163386..8c2008de8 100644 --- a/x/assets/transactions/mutate/transaction_request.go +++ b/x/assets/transactions/mutate/transaction_request.go @@ -10,8 +10,10 @@ import ( baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" + sdkCodec "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" @@ -55,8 +57,13 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.MutableProperties), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } @@ -100,7 +107,7 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { mutableProperties, ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { +func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) { codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) } func requestPrototype() helpers.TransactionRequest { diff --git a/x/assets/transactions/renumerate/transaction_request.go b/x/assets/transactions/renumerate/transaction_request.go index 5fc1b75fa..34a08d6d6 100644 --- a/x/assets/transactions/renumerate/transaction_request.go +++ b/x/assets/transactions/renumerate/transaction_request.go @@ -9,8 +9,10 @@ import ( "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" + sdkCodec "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" @@ -50,8 +52,13 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.AssetID), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } @@ -82,7 +89,7 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { assetID.(ids.AssetID), ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { +func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) { codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) } func requestPrototype() helpers.TransactionRequest { diff --git a/x/assets/transactions/revoke/transaction_request.go b/x/assets/transactions/revoke/transaction_request.go index 930b98575..572868d51 100644 --- a/x/assets/transactions/revoke/transaction_request.go +++ b/x/assets/transactions/revoke/transaction_request.go @@ -9,8 +9,10 @@ import ( "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" + sdkCodec "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" @@ -52,8 +54,13 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.ClassificationID), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } @@ -90,7 +97,7 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { classificationID.(ids.ClassificationID), ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { +func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) { codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) } func requestPrototype() helpers.TransactionRequest { diff --git a/x/assets/transactions/send/transaction_request.go b/x/assets/transactions/send/transaction_request.go index 91f7b580d..01ffd4e1b 100644 --- a/x/assets/transactions/send/transaction_request.go +++ b/x/assets/transactions/send/transaction_request.go @@ -9,8 +9,10 @@ import ( "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" + sdkCodec "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" @@ -54,8 +56,13 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.Value), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } @@ -98,7 +105,7 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { value, ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { +func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) { codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) } func requestPrototype() helpers.TransactionRequest { diff --git a/x/assets/transactions/unwrap/transaction_request.go b/x/assets/transactions/unwrap/transaction_request.go index 233be8e58..725d1f906 100644 --- a/x/assets/transactions/unwrap/transaction_request.go +++ b/x/assets/transactions/unwrap/transaction_request.go @@ -9,8 +9,10 @@ import ( "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" + sdkCodec "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" @@ -50,8 +52,13 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.Coins), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } @@ -82,7 +89,7 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { coins, ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { +func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) { codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) } func requestPrototype() helpers.TransactionRequest { diff --git a/x/assets/transactions/wrap/transaction_request.go b/x/assets/transactions/wrap/transaction_request.go index e061ac56d..5755d59af 100644 --- a/x/assets/transactions/wrap/transaction_request.go +++ b/x/assets/transactions/wrap/transaction_request.go @@ -11,6 +11,8 @@ import ( "github.com/cosmos/cosmos-sdk/client" sdkCodec "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" @@ -50,8 +52,13 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.Coins), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } diff --git a/x/identities/transactions/define/transaction_request.go b/x/identities/transactions/define/transaction_request.go index fbd18ab39..a3c7f1c8d 100644 --- a/x/identities/transactions/define/transaction_request.go +++ b/x/identities/transactions/define/transaction_request.go @@ -12,6 +12,8 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" @@ -57,8 +59,13 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.MutableProperties), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } diff --git a/x/identities/transactions/deputize/transaction_request.go b/x/identities/transactions/deputize/transaction_request.go index e3c7f09d3..f1dad2501 100644 --- a/x/identities/transactions/deputize/transaction_request.go +++ b/x/identities/transactions/deputize/transaction_request.go @@ -12,6 +12,8 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" @@ -65,8 +67,13 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadBool(constants.CanMutateMaintainer), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } diff --git a/x/identities/transactions/issue/transaction_request.go b/x/identities/transactions/issue/transaction_request.go index 991d958e2..a28e60c01 100644 --- a/x/identities/transactions/issue/transaction_request.go +++ b/x/identities/transactions/issue/transaction_request.go @@ -12,6 +12,8 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" @@ -59,8 +61,13 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.MutableProperties), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } diff --git a/x/identities/transactions/name/transaction_request.go b/x/identities/transactions/name/transaction_request.go index 368124b6c..a3ed1ea6c 100644 --- a/x/identities/transactions/name/transaction_request.go +++ b/x/identities/transactions/name/transaction_request.go @@ -10,6 +10,8 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" @@ -47,8 +49,13 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.Name), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } diff --git a/x/identities/transactions/provision/transaction_request.go b/x/identities/transactions/provision/transaction_request.go index b5e7f0eee..1671463ca 100644 --- a/x/identities/transactions/provision/transaction_request.go +++ b/x/identities/transactions/provision/transaction_request.go @@ -11,6 +11,8 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" @@ -50,8 +52,13 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.IdentityID), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } diff --git a/x/identities/transactions/quash/transaction_request.go b/x/identities/transactions/quash/transaction_request.go index 5e4345791..6964d11bc 100644 --- a/x/identities/transactions/quash/transaction_request.go +++ b/x/identities/transactions/quash/transaction_request.go @@ -11,6 +11,8 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" @@ -50,8 +52,13 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.IdentityID), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } diff --git a/x/identities/transactions/revoke/transaction_request.go b/x/identities/transactions/revoke/transaction_request.go index 01953c715..635033967 100644 --- a/x/identities/transactions/revoke/transaction_request.go +++ b/x/identities/transactions/revoke/transaction_request.go @@ -11,6 +11,8 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" @@ -52,8 +54,13 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.ClassificationID), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } diff --git a/x/identities/transactions/unprovision/transaction_request.go b/x/identities/transactions/unprovision/transaction_request.go index 8edcfa140..386c5d855 100644 --- a/x/identities/transactions/unprovision/transaction_request.go +++ b/x/identities/transactions/unprovision/transaction_request.go @@ -11,6 +11,8 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" @@ -50,8 +52,13 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.IdentityID), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } diff --git a/x/identities/transactions/update/transaction_request.go b/x/identities/transactions/update/transaction_request.go index 359c542f5..c15a54de9 100644 --- a/x/identities/transactions/update/transaction_request.go +++ b/x/identities/transactions/update/transaction_request.go @@ -12,6 +12,8 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" @@ -55,8 +57,13 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.MutableProperties), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } diff --git a/x/metas/transactions/reveal/transaction_request.go b/x/metas/transactions/reveal/transaction_request.go index 84cb17226..ca55ee454 100644 --- a/x/metas/transactions/reveal/transaction_request.go +++ b/x/metas/transactions/reveal/transaction_request.go @@ -10,6 +10,8 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" @@ -47,8 +49,13 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.Data), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } diff --git a/x/orders/transactions/cancel/transaction_request.go b/x/orders/transactions/cancel/transaction_request.go index cd969b8f7..c95716869 100644 --- a/x/orders/transactions/cancel/transaction_request.go +++ b/x/orders/transactions/cancel/transaction_request.go @@ -11,6 +11,8 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" @@ -50,8 +52,13 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.OrderID), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } diff --git a/x/orders/transactions/define/transaction_request.go b/x/orders/transactions/define/transaction_request.go index 57f132472..b2ca125ef 100644 --- a/x/orders/transactions/define/transaction_request.go +++ b/x/orders/transactions/define/transaction_request.go @@ -12,6 +12,8 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" @@ -57,8 +59,13 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.MutableProperties), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } diff --git a/x/orders/transactions/deputize/transaction_request.go b/x/orders/transactions/deputize/transaction_request.go index 1abb28a13..c0bc33e71 100644 --- a/x/orders/transactions/deputize/transaction_request.go +++ b/x/orders/transactions/deputize/transaction_request.go @@ -12,6 +12,8 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" @@ -65,8 +67,13 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadBool(constants.CanMutateMaintainer), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } diff --git a/x/orders/transactions/get/transaction_request.go b/x/orders/transactions/get/transaction_request.go index f6aeba30e..ede97c851 100644 --- a/x/orders/transactions/get/transaction_request.go +++ b/x/orders/transactions/get/transaction_request.go @@ -11,6 +11,8 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" @@ -50,8 +52,13 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.OrderID), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } diff --git a/x/orders/transactions/immediate/transaction_request.go b/x/orders/transactions/immediate/transaction_request.go index 2ab6af629..76323db81 100644 --- a/x/orders/transactions/immediate/transaction_request.go +++ b/x/orders/transactions/immediate/transaction_request.go @@ -13,6 +13,8 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" @@ -72,8 +74,13 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.MutableProperties), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } diff --git a/x/orders/transactions/make/transaction_request.go b/x/orders/transactions/make/transaction_request.go index 4f3d66757..ef11b14f9 100644 --- a/x/orders/transactions/make/transaction_request.go +++ b/x/orders/transactions/make/transaction_request.go @@ -13,6 +13,8 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" @@ -72,8 +74,13 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.MutableProperties), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } diff --git a/x/orders/transactions/modify/transaction_request.go b/x/orders/transactions/modify/transaction_request.go index 0435796d6..925194515 100644 --- a/x/orders/transactions/modify/transaction_request.go +++ b/x/orders/transactions/modify/transaction_request.go @@ -13,6 +13,8 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" @@ -62,8 +64,13 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.MutableProperties), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } diff --git a/x/orders/transactions/put/transaction_request.go b/x/orders/transactions/put/transaction_request.go index 9e104eb49..410b52725 100644 --- a/x/orders/transactions/put/transaction_request.go +++ b/x/orders/transactions/put/transaction_request.go @@ -12,6 +12,8 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" @@ -59,8 +61,13 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadInt64(constants.ExpiryHeight), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } diff --git a/x/orders/transactions/revoke/transaction_request.go b/x/orders/transactions/revoke/transaction_request.go index 569ff20bc..30227e20a 100644 --- a/x/orders/transactions/revoke/transaction_request.go +++ b/x/orders/transactions/revoke/transaction_request.go @@ -11,6 +11,8 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" @@ -52,8 +54,13 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.ClassificationID), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } diff --git a/x/orders/transactions/take/transaction_request.go b/x/orders/transactions/take/transaction_request.go index 37f97a91d..282059c74 100644 --- a/x/orders/transactions/take/transaction_request.go +++ b/x/orders/transactions/take/transaction_request.go @@ -11,6 +11,8 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" @@ -52,8 +54,13 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.OrderID), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err }