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 name operation type #813

Merged
merged 1 commit into from
Oct 27, 2023
Merged
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
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/bluele/gcache v0.0.2
github.com/go-openapi/runtime v0.25.0
github.com/jessevdk/go-flags v1.5.0
github.com/massalabs/station v0.3.5-0.20230918142757-8967f55f2177
github.com/massalabs/station v0.3.9-0.20231026134307-06ae6cb71371
github.com/massalabs/station-massa-hello-world v0.0.10
github.com/pkg/errors v0.9.1
github.com/rs/cors v1.8.3
Expand Down Expand Up @@ -43,10 +43,11 @@ require (
github.com/wailsapp/go-webview2 v1.0.1 // indirect
github.com/wailsapp/mimetype v1.4.1 // indirect
github.com/ybbus/jsonrpc/v3 v3.1.4 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
howett.net/plist v1.0.0 // indirect
)

Expand Down
14 changes: 8 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE=
github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0=
github.com/massalabs/station v0.3.5-0.20230918142757-8967f55f2177 h1:x7Jwx6hi9ON1lLxAfpe01L6gt8ER66lGpGChZXMKdzc=
github.com/massalabs/station v0.3.5-0.20230918142757-8967f55f2177/go.mod h1:ZrSECv8dWd2UJESRpzIIjwo4SUKScmNfVf6STbr/2Sc=
github.com/massalabs/station v0.3.9-0.20231026134307-06ae6cb71371 h1:ghiDY5tlHfQJ9NOm/dE6PTxGUuSAh49O0hH9MArQOUw=
github.com/massalabs/station v0.3.9-0.20231026134307-06ae6cb71371/go.mod h1:6VNh9PRA4uGwF6H+YGNRkbMY2pMAPK+ZFloDWHeRtJ0=
github.com/massalabs/station-massa-hello-world v0.0.10 h1:gzsPRD8PmFsGmd1UFG/xpOFut0zm4JKEUmjGo/g/fAA=
github.com/massalabs/station-massa-hello-world v0.0.10/go.mod h1:K1mf69YpRPPZziE53KHXE5IKlTMqU3r1wuLL0MWM21k=
github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE=
Expand Down Expand Up @@ -234,11 +234,11 @@ go.mongodb.org/mongo-driver v1.7.5/go.mod h1:VXEWRZ6URJIkUq2SCAyapmhH0ZLRBP+FT4x
go.mongodb.org/mongo-driver v1.10.0/go.mod h1:wsihk0Kdgv8Kqu1Anit4sfK+22vSFbUrAVEYRhCXrA8=
go.mongodb.org/mongo-driver v1.11.3 h1:Ql6K6qYHEzB6xvu4+AU0BoRoqf9vFPcc4o7MUIdPW8Y=
go.mongodb.org/mongo-driver v1.11.3/go.mod h1:PTSz5yu21bkT/wXpkS7WR5f0ddqw5quethTUn9WM+2g=
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ=
go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4=
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
Expand Down Expand Up @@ -310,6 +310,8 @@ gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Expand Down
25 changes: 10 additions & 15 deletions internal/handler/wallet/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
"github.com/massalabs/station-massa-wallet/pkg/utils"
"github.com/massalabs/station-massa-wallet/pkg/wallet/account"
"github.com/massalabs/station/pkg/node/sendoperation"
"github.com/massalabs/station/pkg/node/sendoperation/buyrolls"
"github.com/massalabs/station/pkg/node/sendoperation/callsc"
"github.com/massalabs/station/pkg/node/sendoperation/executesc"
"github.com/massalabs/station/pkg/node/sendoperation/sellrolls"
"github.com/massalabs/station/pkg/node/sendoperation/transaction"
"github.com/pkg/errors"
"lukechampine.com/blake3"
Expand All @@ -35,18 +37,12 @@
BuyRoll = "Buy Roll"
SellRoll = "Sell Roll"
Message = "Plain Text"
TransactionOpType = uint64(0)
BuyRollOpType = uint64(1)
SellRollOpType = uint64(2)
ExecuteSCOpType = uint64(3)
CallSCOpType = uint64(4)
)

type PromptRequestSignData struct {
Description string
Fees string
OperationType string
OperationID uint64
Coins string
Address string
Function string
Expand Down Expand Up @@ -222,34 +218,34 @@
return nil, errors.Wrap(err, "failed to decode transaction message")
}

if opType, err = sendoperation.DecodeOperationID(decodedMsg); err != nil {
if opType, err = sendoperation.DecodeOperationType(decodedMsg); err != nil {
wrappedErr := errors.Wrap(err, "failed to decode operation ID")

return nil, wrappedErr
} else {
switch opType {
case TransactionOpType:
case transaction.TransactionOpType:

Check warning on line 227 in internal/handler/wallet/sign.go

View check run for this annotation

Codecov / codecov/patch

internal/handler/wallet/sign.go#L227

Added line #L227 was not covered by tests
msg, err := transaction.DecodeMessage(decodedMsg)
if err != nil {
return nil, errors.Wrap(err, "failed to decode transaction message")
}
promptRequest = w.prepareTransactionPromptRequest(msg, acc, address, description, fees, expiry)

case BuyRollOpType, SellRollOpType:
case buyrolls.OpID, sellrolls.SellRollOpID:

Check warning on line 234 in internal/handler/wallet/sign.go

View check run for this annotation

Codecov / codecov/patch

internal/handler/wallet/sign.go#L234

Added line #L234 was not covered by tests
roll, err := sendoperation.RollDecodeMessage(decodedMsg)
if err != nil {
return nil, errors.Wrap(err, "failed to decode roll message")
}
promptRequest = w.prepareRollPromptRequest(roll, acc, address, description, fees, expiry)

case ExecuteSCOpType:
case executesc.ExecuteSCOpID:

Check warning on line 241 in internal/handler/wallet/sign.go

View check run for this annotation

Codecov / codecov/patch

internal/handler/wallet/sign.go#L241

Added line #L241 was not covered by tests
executeSC, err := executesc.DecodeMessage(decodedMsg)
if err != nil {
return nil, errors.Wrap(err, "failed to decode executeSC message")
}
promptRequest = w.prepareExecuteSCPromptRequest(executeSC, acc, address, description, fees, expiry)

case CallSCOpType:
case callsc.CallSCOpID:
callSC, err := callsc.DecodeMessage(decodedMsg)
if err != nil {
return nil, errors.Wrap(err, "failed to decode callSC message")
Expand Down Expand Up @@ -282,7 +278,6 @@
Description: description,
Fees: strconv.FormatUint(fees, 10),
OperationType: "Call SC",
OperationID: msg.OperationID,
MaxGas: strconv.FormatUint(msg.MaxGas, 10),
Coins: strconv.FormatUint(msg.Coins, 10),
Address: msg.Address,
Expand Down Expand Up @@ -328,10 +323,10 @@
) prompt.PromptRequest {
operationType := ""

switch msg.OperationID {
case 1:
switch msg.OperationType {
case buyrolls.OpID:

Check warning on line 327 in internal/handler/wallet/sign.go

View check run for this annotation

Codecov / codecov/patch

internal/handler/wallet/sign.go#L326-L327

Added lines #L326 - L327 were not covered by tests
operationType = BuyRoll
case 2:
case sellrolls.SellRollOpID:

Check warning on line 329 in internal/handler/wallet/sign.go

View check run for this annotation

Codecov / codecov/patch

internal/handler/wallet/sign.go#L329

Added line #L329 was not covered by tests
operationType = SellRoll
}

Expand Down
1 change: 0 additions & 1 deletion wails-frontend/src/pages/PasswordPromptHandler/Sign.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import {
export interface PromptRequestData {
Description: string;
Fees: string;
OperationID: number;
GasLimit: string;
Coins: string;
Address: string;
Expand Down
Loading