Skip to content

Commit

Permalink
fix: Make the stringer a bit more generic
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinTrinque committed Nov 7, 2023
1 parent 77ece04 commit 47fef6e
Show file tree
Hide file tree
Showing 31 changed files with 203 additions and 210 deletions.
8 changes: 4 additions & 4 deletions core/datasource/common/data_signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"fmt"
"strings"

errors "code.vegaprotocol.io/vega/core/datasource/errors"
"code.vegaprotocol.io/vega/core/datasource/errors"
"code.vegaprotocol.io/vega/libs/stringer"
datapb "code.vegaprotocol.io/vega/protos/vega/data/v1"
)
Expand Down Expand Up @@ -58,7 +58,7 @@ type SignerPubKey struct {
func (s SignerPubKey) String() string {
return fmt.Sprintf(
"signerPubKey(%s)",
stringer.ReflectPointerToString(s.PubKey),
stringer.PtrToString(s.PubKey),
)
}

Expand Down Expand Up @@ -202,7 +202,7 @@ type SignerETHAddress struct {
func (s SignerETHAddress) String() string {
return fmt.Sprintf(
"signerETHAddress(%s)",
stringer.ReflectPointerToString(s.ETHAddress),
stringer.PtrToString(s.ETHAddress),
)
}

Expand Down Expand Up @@ -355,7 +355,7 @@ func (s Signer) DeepClone() *Signer {
}

func (s Signer) String() string {
return stringer.ReflectPointerToString(s.Signer)
return stringer.ObjToString(s.Signer)
}

func (s Signer) IsEmpty() bool {
Expand Down
12 changes: 6 additions & 6 deletions core/types/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (a AssetDetails) String() string {
a.Symbol,
a.Quantum.String(),
a.Decimals,
stringer.ReflectPointerToString(a.Source),
stringer.ObjToString(a.Source),
)
}

Expand Down Expand Up @@ -229,7 +229,7 @@ type AssetDetailsBuiltinAsset struct {
func (a AssetDetailsBuiltinAsset) String() string {
return fmt.Sprintf(
"builtinAsset(%s)",
stringer.ReflectPointerToString(a.BuiltinAsset),
stringer.PtrToString(a.BuiltinAsset),
)
}

Expand Down Expand Up @@ -287,7 +287,7 @@ type BuiltinAsset struct {
func (a BuiltinAsset) String() string {
return fmt.Sprintf(
"maxFaucetAmountMint(%s)",
stringer.UintPointerToString(a.MaxFaucetAmountMint),
stringer.PtrToString(a.MaxFaucetAmountMint),
)
}

Expand All @@ -298,7 +298,7 @@ type AssetDetailsErc20 struct {
func (a AssetDetailsErc20) String() string {
return fmt.Sprintf(
"erc20(%s)",
stringer.ReflectPointerToString(a.ERC20),
stringer.PtrToString(a.ERC20),
)
}

Expand Down Expand Up @@ -403,7 +403,7 @@ func (e ERC20) String() string {
return fmt.Sprintf(
"contractAddress(%s) lifetimeLimit(%s) withdrawThreshold(%s)",
e.ContractAddress,
stringer.UintPointerToString(e.LifetimeLimit),
stringer.UintPointerToString(e.WithdrawThreshold),
stringer.PtrToString(e.LifetimeLimit),
stringer.PtrToString(e.WithdrawThreshold),
)
}
38 changes: 19 additions & 19 deletions core/types/chain_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type WithdrawExt struct {
func (x *WithdrawExt) String() string {
return fmt.Sprintf(
"ext(%s)",
stringer.ReflectPointerToString(x.Ext),
stringer.ObjToString(x.Ext),
)
}

Expand Down Expand Up @@ -90,7 +90,7 @@ func (x *WithdrawExtErc20) isWithdrawExtExt() {}
func (x *WithdrawExtErc20) String() string {
return fmt.Sprintf(
"erc20(%s)",
stringer.ReflectPointerToString(x.Erc20),
stringer.PtrToString(x.Erc20),
)
}

Expand Down Expand Up @@ -252,7 +252,7 @@ func (d *Deposit) String() string {
d.Status.String(),
d.PartyID,
d.Asset,
stringer.UintPointerToString(d.Amount),
stringer.PtrToString(d.Amount),
d.TxHash,
d.CreditDate,
d.CreationDate,
Expand Down Expand Up @@ -297,7 +297,7 @@ func (c ChainEventERC20) IntoProto() *commandspb.ChainEvent_Erc20 {
func (c ChainEventERC20) String() string {
return fmt.Sprintf(
"erc20(%s)",
stringer.ReflectPointerToString(c.ERC20),
stringer.PtrToString(c.ERC20),
)
}

Expand Down Expand Up @@ -339,7 +339,7 @@ func (b BuiltinAssetDeposit) String() string {
"party(%s) vegaAssetID(%s) amount(%s)",
b.PartyID,
b.VegaAssetID,
stringer.UintPointerToString(b.Amount),
stringer.PtrToString(b.Amount),
)
}

Expand Down Expand Up @@ -385,7 +385,7 @@ func (b BuiltinAssetWithdrawal) String() string {
"partyID(%s) vegaAssetID(%s) amount(%s)",
b.PartyID,
b.VegaAssetID,
stringer.UintPointerToString(b.Amount),
stringer.PtrToString(b.Amount),
)
}

Expand Down Expand Up @@ -417,7 +417,7 @@ func (c ChainEventBuiltin) IntoProto() *commandspb.ChainEvent_Builtin {
func (c ChainEventBuiltin) String() string {
return fmt.Sprintf(
"builtin(%s)",
stringer.ReflectPointerToString(c.Builtin),
stringer.PtrToString(c.Builtin),
)
}

Expand Down Expand Up @@ -466,7 +466,7 @@ func (c BuiltinAssetEvent) IntoProto() *vegapb.BuiltinAssetEvent {
func (c BuiltinAssetEvent) String() string {
return fmt.Sprintf(
"action(%s)",
stringer.ReflectPointerToString(c.Action),
stringer.ObjToString(c.Action),
)
}

Expand All @@ -477,7 +477,7 @@ type BuiltinAssetEventDeposit struct {
func (b BuiltinAssetEventDeposit) String() string {
return fmt.Sprintf(
"deposit(%s)",
stringer.ReflectPointerToString(b.Deposit),
stringer.PtrToString(b.Deposit),
)
}

Expand Down Expand Up @@ -511,7 +511,7 @@ type BuiltinAssetEventWithdrawal struct {
func (b BuiltinAssetEventWithdrawal) String() string {
return fmt.Sprintf(
"withdrawal(%s)",
stringer.ReflectPointerToString(b.Withdrawal),
stringer.PtrToString(b.Withdrawal),
)
}

Expand Down Expand Up @@ -626,7 +626,7 @@ func (e ERC20Event) String() string {
"index(%v) block(%v) action(%s)",
e.Index,
e.Block,
stringer.ReflectPointerToString(e.Action),
stringer.ObjToString(e.Action),
)
}

Expand All @@ -637,7 +637,7 @@ type ERC20EventAssetDelist struct {
func (e ERC20EventAssetDelist) String() string {
return fmt.Sprintf(
"assetDelist(%s)",
stringer.ReflectPointerToString(e.AssetDelist),
stringer.PtrToString(e.AssetDelist),
)
}

Expand Down Expand Up @@ -693,7 +693,7 @@ func (e ERC20EventAssetList) oneOfProto() interface{} {
func (e ERC20EventAssetList) String() string {
return fmt.Sprintf(
"assetList(%s)",
stringer.ReflectPointerToString(e.AssetList),
stringer.PtrToString(e.AssetList),
)
}

Expand Down Expand Up @@ -753,7 +753,7 @@ func (e ERC20EventWithdrawal) oneOfProto() interface{} {
func (e ERC20EventWithdrawal) String() string {
return fmt.Sprintf(
"withdrawal(%s)",
stringer.ReflectPointerToString(e.Withdrawal),
stringer.PtrToString(e.Withdrawal),
)
}

Expand Down Expand Up @@ -814,7 +814,7 @@ type ERC20EventDeposit struct {
func (e ERC20EventDeposit) String() string {
return fmt.Sprintf(
"deposit(%s)",
stringer.ReflectPointerToString(e.Deposit),
stringer.PtrToString(e.Deposit),
)
}

Expand Down Expand Up @@ -882,7 +882,7 @@ func (e ERC20Deposit) String() string {
"vegaAssetID(%s) targetPartyID(%s) amount(%s) sourceEthereumAddress(%s)",
e.VegaAssetID,
e.TargetPartyID,
stringer.UintPointerToString(e.Amount),
stringer.PtrToString(e.Amount),
e.SourceEthereumAddress,
)
}
Expand All @@ -904,7 +904,7 @@ func (e ERC20EventAssetLimitsUpdated) oneOfProto() interface{} {
func (e ERC20EventAssetLimitsUpdated) String() string {
return fmt.Sprintf(
"assetLimitsUpdated(%s)",
stringer.ReflectPointerToString(e.AssetLimitsUpdated),
stringer.PtrToString(e.AssetLimitsUpdated),
)
}

Expand Down Expand Up @@ -952,8 +952,8 @@ func (e ERC20AssetLimitsUpdated) String() string {
"vegaAssetID(%s) sourceEthereumAddress(%s) lifetimeLimits(%s) withdrawThreshold(%s)",
e.VegaAssetID,
e.SourceEthereumAddress,
stringer.UintPointerToString(e.LifetimeLimits),
stringer.UintPointerToString(e.WithdrawThreshold),
stringer.PtrToString(e.LifetimeLimits),
stringer.PtrToString(e.WithdrawThreshold),
)
}

Expand Down
2 changes: 1 addition & 1 deletion core/types/collateral.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (a Account) String() string {
"ID(%s) owner(%s) balance(%s) asset(%s) marketID(%s) type(%s)",
a.ID,
a.Owner,
stringer.UintPointerToString(a.Balance),
stringer.PtrToString(a.Balance),
a.Asset,
a.MarketID,
a.Type.String(),
Expand Down
4 changes: 2 additions & 2 deletions core/types/delegation.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (d Delegate) String() string {
return fmt.Sprintf(
"nodeID(%s) amount(%s)",
d.NodeID,
stringer.UintPointerToString(d.Amount),
stringer.PtrToString(d.Amount),
)
}

Expand All @@ -88,7 +88,7 @@ func (u Undelegate) String() string {
return fmt.Sprintf(
"nodeID(%s) amount(%s) method(%s)",
u.NodeID,
stringer.UintPointerToString(u.Amount),
stringer.PtrToString(u.Amount),
u.Method,
)
}
Expand Down
26 changes: 13 additions & 13 deletions core/types/fees.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (f Fees) DeepClone() *Fees {
func (f Fees) String() string {
return fmt.Sprintf(
"factors(%s)",
stringer.ReflectPointerToString(f.Factors),
stringer.PtrToString(f.Factors),
)
}

Expand Down Expand Up @@ -170,15 +170,15 @@ func (f Fee) Clone() *Fee {
func (f *Fee) String() string {
return fmt.Sprintf(
"makerFee(%s) liquidityFee(%s) infrastructureFee(%s) makerFeeReferrerDiscount(%s) liquidityFeeReferrerDiscount(%s) infrastructureFeeReferrerDiscount(%s) makerFeeVolumeDiscount(%s) liquidityFeeVolumeDiscount(%s) infrastructureFeeVolumeDiscount(%s)",
stringer.UintPointerToString(f.MakerFee),
stringer.UintPointerToString(f.LiquidityFee),
stringer.UintPointerToString(f.InfrastructureFee),
stringer.UintPointerToString(f.MakerFeeReferrerDiscount),
stringer.UintPointerToString(f.LiquidityFeeReferrerDiscount),
stringer.UintPointerToString(f.InfrastructureFeeReferrerDiscount),
stringer.UintPointerToString(f.MakerFeeVolumeDiscount),
stringer.UintPointerToString(f.LiquidityFeeVolumeDiscount),
stringer.UintPointerToString(f.InfrastructureFeeVolumeDiscount),
stringer.PtrToString(f.MakerFee),
stringer.PtrToString(f.LiquidityFee),
stringer.PtrToString(f.InfrastructureFee),
stringer.PtrToString(f.MakerFeeReferrerDiscount),
stringer.PtrToString(f.LiquidityFeeReferrerDiscount),
stringer.PtrToString(f.InfrastructureFeeReferrerDiscount),
stringer.PtrToString(f.MakerFeeVolumeDiscount),
stringer.PtrToString(f.LiquidityFeeVolumeDiscount),
stringer.PtrToString(f.InfrastructureFeeVolumeDiscount),
)
}

Expand Down Expand Up @@ -208,9 +208,9 @@ func (rf ReferrerReward) Clone() *ReferrerReward {
func (rf *ReferrerReward) String() string {
return fmt.Sprintf(
"makerFeeReferrerReward(%s) liquidityFeeReferrerReward(%s) infrastructureFeeReferrerReward(%s)",
stringer.UintPointerToString(rf.MakerFeeReferrerReward),
stringer.UintPointerToString(rf.LiquidityFeeReferrerReward),
stringer.UintPointerToString(rf.InfrastructureFeeReferrerReward),
stringer.PtrToString(rf.MakerFeeReferrerReward),
stringer.PtrToString(rf.LiquidityFeeReferrerReward),
stringer.PtrToString(rf.InfrastructureFeeReferrerReward),
)
}

Expand Down
4 changes: 2 additions & 2 deletions core/types/governance_cancel_transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type ProposalTermsCancelTransfer struct {
func (a ProposalTermsCancelTransfer) String() string {
return fmt.Sprintf(
"cancelTransfer(%s)",
stringer.ReflectPointerToString(a.CancelTransfer),
stringer.PtrToString(a.CancelTransfer),
)
}

Expand Down Expand Up @@ -90,7 +90,7 @@ func (c CancelTransfer) IntoProto() *vegapb.CancelTransfer {
func (c CancelTransfer) String() string {
return fmt.Sprintf(
"changes(%s)",
stringer.ReflectPointerToString(c.Changes),
stringer.PtrToString(c.Changes),
)
}

Expand Down
4 changes: 2 additions & 2 deletions core/types/governance_new_asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type ProposalTermsNewAsset struct {
func (a ProposalTermsNewAsset) String() string {
return fmt.Sprintf(
"newAsset(%v)",
stringer.ReflectPointerToString(a.NewAsset),
stringer.PtrToString(a.NewAsset),
)
}

Expand Down Expand Up @@ -118,7 +118,7 @@ func (n NewAsset) IntoProto() *vegapb.NewAsset {
func (n NewAsset) String() string {
return fmt.Sprintf(
"changes(%s)",
stringer.ReflectPointerToString(n.Changes),
stringer.PtrToString(n.Changes),
)
}

Expand Down
2 changes: 1 addition & 1 deletion core/types/governance_new_freeform.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type ProposalTermsNewFreeform struct {
func (f ProposalTermsNewFreeform) String() string {
return fmt.Sprintf(
"newFreeForm(%s)",
stringer.ReflectPointerToString(f.NewFreeform),
stringer.PtrToString(f.NewFreeform),
)
}

Expand Down
Loading

0 comments on commit 47fef6e

Please sign in to comment.