mirror of
https://github.com/status-im/status-go.git
synced 2025-02-11 14:26:53 +00:00
- new file `contracts/community-tokens/contracts.go` added to unify contracts creation - the following community related path processors added: - `CommunityBurnProcessor` - `CommunityDeployAssetsProcessor` - `CommunityDeployCollectiblesProcessor` - `CommunityDeployOwnerTokenProcessor` - `CommunityMintTokensProcessor` - `CommunityRemoteBurnProcessor` - `CommunitySetSignerPubKeyProcessor` - `SendType` extended with appropriate options - added endpoints to duplicated `communitytokens` api: - `StoreDeployedCollectibles` - `StoreDeployedOwnerToken` - `StoreDeployedAssets` - removed endpoints from duplicated `communitytokens` api: - `DeployCollectibles` - `DeployOwnerToken` - `ReTrackOwnerTokenDeploymentTransaction` - `DeployAssets` - `DeployCollectiblesEstimate` - `DeployAssetsEstimate` - `DeployOwnerTokenEstimate` - `EstimateMintTokens` - `EstimateRemoteBurn` - `EstimateBurn` - `EstimateSetSignerPubKey` - `NewOwnerTokenInstance` - `NewCommunityTokenDeployerInstance` - `NewCommunityOwnerTokenRegistryInstance` - `NewCollectiblesInstance` - `NewAssetsInstance` - `MintTokens` - `RemoteBurn` - `GetCollectiblesContractInstance` - `GetAssetContractInstance` - `Burn` - `SetSignerPubKey` - `Path` type extended with new property: - `UsedContractAddress` - an address of the contract that will be used for the transaction
78 lines
2.1 KiB
Go
78 lines
2.1 KiB
Go
package requests
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
|
"github.com/status-im/status-go/errors"
|
|
"github.com/status-im/status-go/services/wallet/router/fees"
|
|
|
|
"gopkg.in/go-playground/validator.v9"
|
|
)
|
|
|
|
var (
|
|
ErrMaxFeesPerGasRequired = &errors.ErrorResponse{Code: errors.ErrorCode("WRC-001"), Details: "maxFeesPerGas is required"}
|
|
ErrPriorityFeeRequired = &errors.ErrorResponse{Code: errors.ErrorCode("WRC-002"), Details: "priorityFee is required"}
|
|
)
|
|
|
|
type PathTxCustomParams struct {
|
|
GasFeeMode fees.GasFeeMode `json:"gasFeeMode" validate:"gasFeeModeValid"`
|
|
Nonce uint64 `json:"nonce"`
|
|
GasAmount uint64 `json:"gasAmount"`
|
|
MaxFeesPerGas *hexutil.Big `json:"maxFeesPerGas"`
|
|
PriorityFee *hexutil.Big `json:"priorityFee"`
|
|
}
|
|
|
|
func gasFeeModeValid(fl validator.FieldLevel) bool {
|
|
mode := fl.Field().Interface().(fees.GasFeeMode)
|
|
switch mode {
|
|
case fees.GasFeeLow, fees.GasFeeMedium, fees.GasFeeHigh, fees.GasFeeCustom:
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
type PathTxIdentity struct {
|
|
RouterInputParamsUuid string `json:"routerInputParamsUuid" validate:"required"`
|
|
PathName string `json:"pathName" validate:"required"`
|
|
ChainID uint64 `json:"chainID" validate:"required"`
|
|
IsApprovalTx bool `json:"isApprovalTx"`
|
|
CommunityID string `json:"communityId"`
|
|
}
|
|
|
|
func (p *PathTxIdentity) PathIdentity() string {
|
|
return fmt.Sprintf("%s-%s-%d-%s", p.RouterInputParamsUuid, p.PathName, p.ChainID, p.CommunityID)
|
|
}
|
|
|
|
func (p *PathTxIdentity) TxIdentityKey() string {
|
|
return fmt.Sprintf("%s-%v", p.PathIdentity(), p.IsApprovalTx)
|
|
}
|
|
|
|
func (p *PathTxIdentity) Validate() error {
|
|
validate := validator.New()
|
|
return validate.Struct(p)
|
|
}
|
|
|
|
func (p *PathTxCustomParams) Validate() error {
|
|
validate := validator.New()
|
|
err := validate.RegisterValidation("gasFeeModeValid", gasFeeModeValid)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
err = validate.Struct(p)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if p.GasFeeMode != fees.GasFeeCustom {
|
|
return nil
|
|
}
|
|
if p.MaxFeesPerGas == nil {
|
|
return ErrMaxFeesPerGasRequired
|
|
}
|
|
if p.PriorityFee == nil {
|
|
return ErrPriorityFeeRequired
|
|
}
|
|
return nil
|
|
}
|