Skip to content

Commit

Permalink
deploysc is displayed separately from executesc
Browse files Browse the repository at this point in the history
  • Loading branch information
fleandrei committed Jan 16, 2025
1 parent 647ebc9 commit 8c3a02c
Show file tree
Hide file tree
Showing 10 changed files with 530 additions and 513 deletions.
8 changes: 7 additions & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,12 @@ tasks:

wails-dev:
cmds:
- cmd: wails dev
- cmd: wails dev -tags webkit2_41
env:
STANDALONE: 1

# This task is used to install the plugin in the MassaStation plugins directory.
# This allow to use the plugin with MassaStation.
install-plugin:
cmds:
- cmd: mkdir -p /usr/local/share/massastation/plugins/wallet-plugin
Expand Down Expand Up @@ -132,11 +134,15 @@ tasks:
- task: build-wails
- task: build

# This task build and run the plugin as a standalone application, WITHOUT any connection to MassaStation
build-run:
cmds:
- task: build-standalone
- task: run

# This is the task to run for building and using the station-massa-wallet plugin with MassaStation
# It build the plugin and then install it in the MassaStation plugins directory.
# Hence, when massaStation is launched, it will detect the plugin and use it normaly
build-install-plugin:
cmds:
- task: generate
Expand Down
64 changes: 43 additions & 21 deletions internal/handler/wallet/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/massalabs/station/pkg/node/sendoperation/executesc"
"github.com/massalabs/station/pkg/node/sendoperation/sellrolls"
"github.com/massalabs/station/pkg/node/sendoperation/transaction"
onchain "github.com/massalabs/station/pkg/onchain"
"github.com/pkg/errors"
"lukechampine.com/blake3"
)
Expand All @@ -38,25 +39,27 @@ const (
)

type PromptRequestSignData struct {
Description string
Fees string
MinFees string
OperationType int
Coins string
Address string
Function string
MaxCoins string
WalletAddress string
Nickname string
RollCount uint64
RecipientAddress string
RecipientNickname string
Amount string
PlainText string
AllowFeeEdition bool
ChainID int64
Assets []models.AssetInfo
Parameters []byte
Description string
Fees string
MinFees string
OperationType int
Coins string
Address string
Function string
MaxCoins string // for ExecuteSC
WalletAddress string
Nickname string
RollCount uint64
RecipientAddress string
RecipientNickname string
Amount string
PlainText string
AllowFeeEdition bool
ChainID int64
Assets []models.AssetInfo
Parameters []byte
DeployedByteCodeSize uint // for executeSC of type deploySC
DeployedCoins uint64 // for executeSC of type DeploySC; the number of coins sent to the deployed contract
}

func NewSign(prompterApp prompt.WalletPrompterInterface, gc gcache.Cache, AssetsStore *assets.AssetsStore) operations.SignHandler {
Expand Down Expand Up @@ -316,9 +319,28 @@ func getExecuteSCPromptData(
return PromptRequestSignData{}, err
}

return PromptRequestSignData{
promptReq := PromptRequestSignData{
MaxCoins: strconv.FormatUint(msg.MaxCoins, 10),
}, nil
}

// Check the datastore to know whether the ExecuteSC is a DeploySC or not

if msg.DataStore == nil { // the executeSC is not a deploySC

Check failure on line 328 in internal/handler/wallet/sign.go

View workflow job for this annotation

GitHub Actions / test

msg.DataStore undefined (type *executesc.MessageContent has no field or method DataStore)

Check failure on line 328 in internal/handler/wallet/sign.go

View workflow job for this annotation

GitHub Actions / lint

msg.DataStore undefined (type *executesc.MessageContent has no field or method DataStore)

Check failure on line 328 in internal/handler/wallet/sign.go

View workflow job for this annotation

GitHub Actions / lint

msg.DataStore undefined (type *executesc.MessageContent has no field or method DataStore) (typecheck)
return promptReq, nil
}

dataStore, err := onchain.DeSerializeDatastore(msg.DataStore)

Check failure on line 332 in internal/handler/wallet/sign.go

View workflow job for this annotation

GitHub Actions / test

undefined: onchain.DeSerializeDatastore

Check failure on line 332 in internal/handler/wallet/sign.go

View workflow job for this annotation

GitHub Actions / test

msg.DataStore undefined (type *executesc.MessageContent has no field or method DataStore)

Check failure on line 332 in internal/handler/wallet/sign.go

View workflow job for this annotation

GitHub Actions / lint

undefined: onchain.DeSerializeDatastore

Check failure on line 332 in internal/handler/wallet/sign.go

View workflow job for this annotation

GitHub Actions / lint

msg.DataStore undefined (type *executesc.MessageContent has no field or method DataStore)

Check failure on line 332 in internal/handler/wallet/sign.go

View workflow job for this annotation

GitHub Actions / lint

undefined: onchain.DeSerializeDatastore (typecheck)
if err != nil {
return PromptRequestSignData{}, err
}

deployedContract, success := onchain.DatastoreToDeployedContract(dataStore)

Check failure on line 337 in internal/handler/wallet/sign.go

View workflow job for this annotation

GitHub Actions / test

undefined: onchain.DatastoreToDeployedContract

Check failure on line 337 in internal/handler/wallet/sign.go

View workflow job for this annotation

GitHub Actions / lint

undefined: onchain.DatastoreToDeployedContract) (typecheck)

Check failure on line 337 in internal/handler/wallet/sign.go

View workflow job for this annotation

GitHub Actions / lint

undefined: onchain.DatastoreToDeployedContract (typecheck)
if success { // the executeSC is a deploySC
promptReq.DeployedByteCodeSize = uint(len(deployedContract.ByteCode))
promptReq.DeployedCoins = deployedContract.Coins
}

return promptReq, nil
}

func getRollPromptData(
Expand Down
Loading

0 comments on commit 8c3a02c

Please sign in to comment.