From 47fef6e095a4ef3ad40669f70e1f206871687274 Mon Sep 17 00:00:00 2001 From: Valentin Trinque Date: Mon, 6 Nov 2023 13:48:33 +0100 Subject: [PATCH] fix: Make the stringer a bit more generic --- core/datasource/common/data_signer.go | 8 +-- core/types/asset.go | 12 ++-- core/types/chain_events.go | 38 ++++++------- core/types/collateral.go | 2 +- core/types/delegation.go | 4 +- core/types/fees.go | 26 ++++----- core/types/governance_cancel_transfer.go | 4 +- core/types/governance_new_asset.go | 4 +- core/types/governance_new_freeform.go | 2 +- core/types/governance_new_market.go | 34 +++++------ core/types/governance_new_spot_market.go | 20 +++---- core/types/governance_new_transfer.go | 4 +- core/types/governance_proposal.go | 4 +- core/types/governance_update_asset.go | 12 ++-- core/types/governance_update_market.go | 34 +++++------ core/types/governance_update_market_state.go | 6 +- .../governance_update_network_parameter.go | 4 +- .../governance_update_referral_program.go | 4 +- core/types/governance_update_spot_market.go | 18 +++--- ...vernance_update_volume_discount_program.go | 4 +- core/types/liquidity.go | 8 +-- core/types/market.go | 56 +++++++++---------- core/types/matching.go | 16 +++--- core/types/orders.go | 6 +- core/types/pricemonitoring.go | 8 +-- core/types/processor.go | 8 +-- core/types/risk.go | 18 +++--- core/types/staking.go | 8 +-- core/types/transfer.go | 6 +- libs/stringer/stringer.go | 23 +++----- libs/stringer/stringer_test.go | 12 ++-- 31 files changed, 203 insertions(+), 210 deletions(-) diff --git a/core/datasource/common/data_signer.go b/core/datasource/common/data_signer.go index bdcb7a47aab..3781a4b6fa8 100644 --- a/core/datasource/common/data_signer.go +++ b/core/datasource/common/data_signer.go @@ -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" ) @@ -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), ) } @@ -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), ) } @@ -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 { diff --git a/core/types/asset.go b/core/types/asset.go index f44079e9e48..dd97a719165 100644 --- a/core/types/asset.go +++ b/core/types/asset.go @@ -127,7 +127,7 @@ func (a AssetDetails) String() string { a.Symbol, a.Quantum.String(), a.Decimals, - stringer.ReflectPointerToString(a.Source), + stringer.ObjToString(a.Source), ) } @@ -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), ) } @@ -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), ) } @@ -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), ) } @@ -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), ) } diff --git a/core/types/chain_events.go b/core/types/chain_events.go index c8060a4debc..cd5be030e69 100644 --- a/core/types/chain_events.go +++ b/core/types/chain_events.go @@ -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), ) } @@ -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), ) } @@ -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, @@ -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), ) } @@ -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), ) } @@ -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), ) } @@ -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), ) } @@ -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), ) } @@ -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), ) } @@ -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), ) } @@ -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), ) } @@ -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), ) } @@ -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), ) } @@ -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), ) } @@ -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), ) } @@ -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, ) } @@ -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), ) } @@ -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), ) } diff --git a/core/types/collateral.go b/core/types/collateral.go index 2e6d1c36478..930dd885625 100644 --- a/core/types/collateral.go +++ b/core/types/collateral.go @@ -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(), diff --git a/core/types/delegation.go b/core/types/delegation.go index 6af8398555d..090d9cb9411 100644 --- a/core/types/delegation.go +++ b/core/types/delegation.go @@ -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), ) } @@ -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, ) } diff --git a/core/types/fees.go b/core/types/fees.go index 759ce09f0ba..f773690c9be 100644 --- a/core/types/fees.go +++ b/core/types/fees.go @@ -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), ) } @@ -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), ) } @@ -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), ) } diff --git a/core/types/governance_cancel_transfer.go b/core/types/governance_cancel_transfer.go index f0662e85a61..d7bf316d5f5 100644 --- a/core/types/governance_cancel_transfer.go +++ b/core/types/governance_cancel_transfer.go @@ -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), ) } @@ -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), ) } diff --git a/core/types/governance_new_asset.go b/core/types/governance_new_asset.go index cc0c5dc81d2..cb85ffc004d 100644 --- a/core/types/governance_new_asset.go +++ b/core/types/governance_new_asset.go @@ -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), ) } @@ -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), ) } diff --git a/core/types/governance_new_freeform.go b/core/types/governance_new_freeform.go index ba63a289069..6524c6088b5 100644 --- a/core/types/governance_new_freeform.go +++ b/core/types/governance_new_freeform.go @@ -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), ) } diff --git a/core/types/governance_new_market.go b/core/types/governance_new_market.go index eed7bc25fb9..65f0415c0d2 100644 --- a/core/types/governance_new_market.go +++ b/core/types/governance_new_market.go @@ -47,7 +47,7 @@ type ProposalTermsNewMarket struct { func (a ProposalTermsNewMarket) String() string { return fmt.Sprintf( "newMarket(%s)", - stringer.ReflectPointerToString(a.NewMarket), + stringer.PtrToString(a.NewMarket), ) } @@ -139,7 +139,7 @@ func (n NewMarket) DeepClone() *NewMarket { func (n NewMarket) String() string { return fmt.Sprintf( "changes(%s)", - stringer.ReflectPointerToString(n.Changes), + stringer.PtrToString(n.Changes), ) } @@ -264,10 +264,10 @@ func (n NewMarketConfiguration) String() string { n.Metadata, n.DecimalPlaces, n.PositionDecimalPlaces, - stringer.ReflectPointerToString(n.Instrument), - stringer.ReflectPointerToString(n.PriceMonitoringParameters), - stringer.ReflectPointerToString(n.LiquidityMonitoringParameters), - stringer.ReflectPointerToString(n.RiskParameters), + stringer.PtrToString(n.Instrument), + stringer.PtrToString(n.PriceMonitoringParameters), + stringer.PtrToString(n.LiquidityMonitoringParameters), + stringer.ObjToString(n.RiskParameters), n.LinearSlippageFactor.String(), n.QuadraticSlippageFactor.String(), ) @@ -405,7 +405,7 @@ type NewMarketConfigurationSimple struct { func (n NewMarketConfigurationSimple) String() string { return fmt.Sprintf( "simple(%s)", - stringer.ReflectPointerToString(n.Simple), + stringer.PtrToString(n.Simple), ) } @@ -460,7 +460,7 @@ func (n NewMarketConfigurationLogNormal) newRiskParamsIntoProto() interface{} { func (n NewMarketConfigurationLogNormal) String() string { return fmt.Sprintf( "logNormal(%s)", - stringer.ReflectPointerToString(n.LogNormal), + stringer.PtrToString(n.LogNormal), ) } @@ -490,7 +490,7 @@ type InstrumentConfigurationFuture struct { func (i InstrumentConfigurationFuture) String() string { return fmt.Sprintf( "future(%s)", - stringer.ReflectPointerToString(i.Future), + stringer.PtrToString(i.Future), ) } @@ -530,7 +530,7 @@ type InstrumentConfigurationPerps struct { func (i InstrumentConfigurationPerps) String() string { return fmt.Sprintf( "perps(%s)", - stringer.ReflectPointerToString(i.Perps), + stringer.PtrToString(i.Perps), ) } @@ -605,7 +605,7 @@ func (i InstrumentConfiguration) String() string { "name(%s) code(%s) product(%s)", i.Name, i.Code, - stringer.ReflectPointerToString(i.Product), + stringer.ObjToString(i.Product), ) } @@ -720,9 +720,9 @@ func (f FutureProduct) String() string { "quote(%s) settlementAsset(%s) settlementData(%s) tradingTermination(%s) binding(%s)", f.QuoteName, f.SettlementAsset, - stringer.ReflectPointerToString(f.DataSourceSpecForSettlementData), - stringer.ReflectPointerToString(f.DataSourceSpecForTradingTermination), - stringer.ReflectPointerToString(f.DataSourceSpecBinding), + stringer.ObjToString(f.DataSourceSpecForSettlementData), + stringer.ObjToString(f.DataSourceSpecForTradingTermination), + stringer.PtrToString(f.DataSourceSpecBinding), ) } @@ -781,9 +781,9 @@ func (p PerpsProduct) String() string { p.InterestRate.String(), p.ClampLowerBound.String(), p.ClampUpperBound.String(), - stringer.ReflectPointerToString(p.DataSourceSpecForSettlementData), - stringer.ReflectPointerToString(p.DataSourceSpecForSettlementSchedule), - stringer.ReflectPointerToString(p.DataSourceSpecBinding), + stringer.ObjToString(p.DataSourceSpecForSettlementData), + stringer.ObjToString(p.DataSourceSpecForSettlementSchedule), + stringer.PtrToString(p.DataSourceSpecBinding), ) } diff --git a/core/types/governance_new_spot_market.go b/core/types/governance_new_spot_market.go index 422ff0c6615..823fc0dfca1 100644 --- a/core/types/governance_new_spot_market.go +++ b/core/types/governance_new_spot_market.go @@ -30,7 +30,7 @@ type ProposalTermsNewSpotMarket struct { func (a ProposalTermsNewSpotMarket) String() string { return fmt.Sprintf( "newSpotMarket(%s)", - stringer.ReflectPointerToString(a.NewSpotMarket), + stringer.PtrToString(a.NewSpotMarket), ) } @@ -103,7 +103,7 @@ func (n NewSpotMarket) DeepClone() *NewSpotMarket { func (n NewSpotMarket) String() string { return fmt.Sprintf( "changes(%s)", - stringer.ReflectPointerToString(n.Changes), + stringer.PtrToString(n.Changes), ) } @@ -201,11 +201,11 @@ func (n NewSpotMarketConfiguration) String() string { n.Metadata, n.DecimalPlaces, n.PositionDecimalPlaces, - stringer.ReflectPointerToString(n.Instrument), - stringer.ReflectPointerToString(n.PriceMonitoringParameters), - stringer.ReflectPointerToString(n.TargetStakeParameters), - stringer.ReflectPointerToString(n.RiskParameters), - stringer.ReflectPointerToString(n.SLAParams), + stringer.PtrToString(n.Instrument), + stringer.PtrToString(n.PriceMonitoringParameters), + stringer.PtrToString(n.TargetStakeParameters), + stringer.ObjToString(n.RiskParameters), + stringer.PtrToString(n.SLAParams), ) } @@ -266,7 +266,7 @@ type NewSpotMarketConfigurationSimple struct { func (n NewSpotMarketConfigurationSimple) String() string { return fmt.Sprintf( "simple(%s)", - stringer.ReflectPointerToString(n.Simple), + stringer.PtrToString(n.Simple), ) } @@ -321,7 +321,7 @@ func (n NewSpotMarketConfigurationLogNormal) newRiskParamsIntoProto() interface{ func (n NewSpotMarketConfigurationLogNormal) String() string { return fmt.Sprintf( "logNormal(%s)", - stringer.ReflectPointerToString(n.LogNormal), + stringer.PtrToString(n.LogNormal), ) } @@ -342,7 +342,7 @@ type InstrumentConfigurationSpot struct { func (i InstrumentConfigurationSpot) String() string { return fmt.Sprintf( "spot(%s)", - stringer.ReflectPointerToString(i.Spot), + stringer.PtrToString(i.Spot), ) } diff --git a/core/types/governance_new_transfer.go b/core/types/governance_new_transfer.go index cc1fc48be89..74e88403962 100644 --- a/core/types/governance_new_transfer.go +++ b/core/types/governance_new_transfer.go @@ -32,7 +32,7 @@ type ProposalTermsNewTransfer struct { func (a ProposalTermsNewTransfer) String() string { return fmt.Sprintf( "newTransfer(%s)", - stringer.ReflectPointerToString(a.NewTransfer), + stringer.PtrToString(a.NewTransfer), ) } @@ -105,7 +105,7 @@ func (n NewTransfer) DeepClone() *NewTransfer { func (n NewTransfer) String() string { return fmt.Sprintf( "changes(%s)", - stringer.ReflectPointerToString(n.Changes), + stringer.PtrToString(n.Changes), ) } diff --git a/core/types/governance_proposal.go b/core/types/governance_proposal.go index f1c9e6a62c7..d7232b8a87c 100644 --- a/core/types/governance_proposal.go +++ b/core/types/governance_proposal.go @@ -373,7 +373,7 @@ func (p Proposal) String() string { p.Party, p.State.String(), p.Timestamp, - stringer.ReflectPointerToString(p.Terms), + stringer.PtrToString(p.Terms), p.Reason.String(), p.ErrorDetails, p.RequiredMajority.String(), @@ -561,7 +561,7 @@ func (p ProposalTerms) String() string { p.ValidationTimestamp, p.ClosingTimestamp, p.EnactmentTimestamp, - stringer.ReflectPointerToString(p.Change), + stringer.ObjToString(p.Change), ) } diff --git a/core/types/governance_update_asset.go b/core/types/governance_update_asset.go index 9e227669f0f..37f33123732 100644 --- a/core/types/governance_update_asset.go +++ b/core/types/governance_update_asset.go @@ -39,7 +39,7 @@ type ProposalTermsUpdateAsset struct { func (a ProposalTermsUpdateAsset) String() string { return fmt.Sprintf( "updateAsset(%v)", - stringer.ReflectPointerToString(a.UpdateAsset), + stringer.PtrToString(a.UpdateAsset), ) } @@ -120,7 +120,7 @@ func (a UpdateAsset) String() string { return fmt.Sprintf( "assetID(%s) changes(%s)", a.AssetID, - stringer.ReflectPointerToString(a.Changes), + stringer.PtrToString(a.Changes), ) } @@ -158,7 +158,7 @@ func (a AssetDetailsUpdate) String() string { return fmt.Sprintf( "quantum(%s) (%s)", a.Quantum.String(), - stringer.ReflectPointerToString(a.Source), + stringer.ObjToString(a.Source), ) } @@ -244,7 +244,7 @@ type AssetDetailsUpdateERC20 struct { func (a AssetDetailsUpdateERC20) String() string { return fmt.Sprintf( "erc20Update(%s)", - stringer.ReflectPointerToString(a.ERC20Update), + stringer.PtrToString(a.ERC20Update), ) } @@ -350,7 +350,7 @@ func (e ERC20Update) DeepClone() *ERC20Update { func (e ERC20Update) String() string { return fmt.Sprintf( "lifetimeLimit(%s) withdrawThreshold(%s)", - stringer.UintPointerToString(e.LifetimeLimit), - stringer.UintPointerToString(e.WithdrawThreshold), + stringer.PtrToString(e.LifetimeLimit), + stringer.PtrToString(e.WithdrawThreshold), ) } diff --git a/core/types/governance_update_market.go b/core/types/governance_update_market.go index 38ab78d79c7..09d3f769dcd 100644 --- a/core/types/governance_update_market.go +++ b/core/types/governance_update_market.go @@ -32,7 +32,7 @@ type ProposalTermsUpdateMarket struct { func (a ProposalTermsUpdateMarket) String() string { return fmt.Sprintf( "updateMarket(%s)", - stringer.ReflectPointerToString(a.UpdateMarket), + stringer.PtrToString(a.UpdateMarket), ) } @@ -91,7 +91,7 @@ func (n UpdateMarket) String() string { return fmt.Sprintf( "marketID(%s) changes(%s)", n.MarketID, - stringer.ReflectPointerToString(n.Changes), + stringer.PtrToString(n.Changes), ) } @@ -137,11 +137,11 @@ type UpdateMarketConfiguration struct { func (n UpdateMarketConfiguration) String() string { return fmt.Sprintf( "instrument(%s) metadata(%v) priceMonitoring(%s) liquidityMonitoring(%s) risk(%s) linearSlippageFactor(%s) quadraticSlippageFactor(%s)", - stringer.ReflectPointerToString(n.Instrument), + stringer.PtrToString(n.Instrument), MetadataList(n.Metadata).String(), - stringer.ReflectPointerToString(n.PriceMonitoringParameters), - stringer.ReflectPointerToString(n.LiquidityMonitoringParameters), - stringer.ReflectPointerToString(n.RiskParameters), + stringer.PtrToString(n.PriceMonitoringParameters), + stringer.PtrToString(n.LiquidityMonitoringParameters), + stringer.ObjToString(n.RiskParameters), n.LinearSlippageFactor.String(), n.QuadraticSlippageFactor.String(), ) @@ -311,7 +311,7 @@ func (i UpdateInstrumentConfiguration) String() string { return fmt.Sprintf( "code(%s) product(%s)", i.Code, - stringer.ReflectPointerToString(i.Product), + stringer.ObjToString(i.Product), ) } @@ -344,7 +344,7 @@ func (i UpdateInstrumentConfigurationFuture) DeepClone() updateInstrumentConfigu func (i UpdateInstrumentConfigurationFuture) String() string { return fmt.Sprintf( "future(%s)", - stringer.ReflectPointerToString(i.Future), + stringer.PtrToString(i.Future), ) } @@ -376,7 +376,7 @@ func (i UpdateInstrumentConfigurationPerps) DeepClone() updateInstrumentConfigur func (i UpdateInstrumentConfigurationPerps) String() string { return fmt.Sprintf( "perps(%s)", - stringer.ReflectPointerToString(i.Perps), + stringer.PtrToString(i.Perps), ) } @@ -479,9 +479,9 @@ func (f UpdateFutureProduct) String() string { return fmt.Sprintf( "quoteName(%s) settlementData(%s) tradingTermination(%s) binding(%s)", f.QuoteName, - stringer.ReflectPointerToString(f.DataSourceSpecForSettlementData), - stringer.ReflectPointerToString(f.DataSourceSpecForTradingTermination), - stringer.ReflectPointerToString(f.DataSourceSpecBinding), + stringer.ObjToString(f.DataSourceSpecForSettlementData), + stringer.ObjToString(f.DataSourceSpecForTradingTermination), + stringer.PtrToString(f.DataSourceSpecBinding), ) } @@ -532,9 +532,9 @@ func (p UpdatePerpsProduct) String() string { p.InterestRate.String(), p.ClampLowerBound.String(), p.ClampUpperBound.String(), - stringer.ReflectPointerToString(p.DataSourceSpecForSettlementData), - stringer.ReflectPointerToString(p.DataSourceSpecForSettlementSchedule), - stringer.ReflectPointerToString(p.DataSourceSpecBinding), + stringer.ObjToString(p.DataSourceSpecForSettlementData), + stringer.ObjToString(p.DataSourceSpecForSettlementSchedule), + stringer.PtrToString(p.DataSourceSpecBinding), ) } @@ -545,7 +545,7 @@ type UpdateMarketConfigurationSimple struct { func (n UpdateMarketConfigurationSimple) String() string { return fmt.Sprintf( "simple(%s)", - stringer.ReflectPointerToString(n.Simple), + stringer.PtrToString(n.Simple), ) } @@ -581,7 +581,7 @@ type UpdateMarketConfigurationLogNormal struct { func (n UpdateMarketConfigurationLogNormal) String() string { return fmt.Sprintf( "logNormal(%s)", - stringer.ReflectPointerToString(n.LogNormal), + stringer.PtrToString(n.LogNormal), ) } diff --git a/core/types/governance_update_market_state.go b/core/types/governance_update_market_state.go index 40d5b1a6a92..6cf82149250 100644 --- a/core/types/governance_update_market_state.go +++ b/core/types/governance_update_market_state.go @@ -34,7 +34,7 @@ type UpdateMarketState struct { func (a ProposalTermsUpdateMarketState) String() string { return fmt.Sprintf( "updateMarketState(%s)", - stringer.ReflectPointerToString(a.UpdateMarketState), + stringer.PtrToString(a.UpdateMarketState), ) } @@ -105,7 +105,7 @@ func (c UpdateMarketState) IntoProto() *vegapb.UpdateMarketState { func (c UpdateMarketState) String() string { return fmt.Sprintf( "changes(%s)", - stringer.ReflectPointerToString(c.Changes), + stringer.PtrToString(c.Changes), ) } @@ -139,5 +139,5 @@ type MarketStateUpdateConfiguration struct { } func (c MarketStateUpdateConfiguration) String() string { - return fmt.Sprintf("marketID(%s), updateType(%d), settlementPrice(%s)", c.MarketID, c.UpdateType, stringer.ReflectPointerToString(c.SettlementPrice)) + return fmt.Sprintf("marketID(%s), updateType(%d), settlementPrice(%s)", c.MarketID, c.UpdateType, stringer.PtrToString(c.SettlementPrice)) } diff --git a/core/types/governance_update_network_parameter.go b/core/types/governance_update_network_parameter.go index 8377f0049eb..276aaa315b2 100644 --- a/core/types/governance_update_network_parameter.go +++ b/core/types/governance_update_network_parameter.go @@ -29,7 +29,7 @@ type ProposalTermsUpdateNetworkParameter struct { func (a ProposalTermsUpdateNetworkParameter) String() string { return fmt.Sprintf( "updateNetworkParameter(%s)", - stringer.ReflectPointerToString(a.UpdateNetworkParameter), + stringer.PtrToString(a.UpdateNetworkParameter), ) } @@ -88,7 +88,7 @@ func (n UpdateNetworkParameter) IntoProto() *vegapb.UpdateNetworkParameter { func (n UpdateNetworkParameter) String() string { return fmt.Sprintf( "changes(%s)", - stringer.ReflectPointerToString(n.Changes), + stringer.PtrToString(n.Changes), ) } diff --git a/core/types/governance_update_referral_program.go b/core/types/governance_update_referral_program.go index 44576ec8bb2..a13ebe9f036 100644 --- a/core/types/governance_update_referral_program.go +++ b/core/types/governance_update_referral_program.go @@ -31,7 +31,7 @@ type ProposalTermsUpdateReferralProgram struct { func (a ProposalTermsUpdateReferralProgram) String() string { return fmt.Sprintf( "updateReferralProgram(%s)", - stringer.ReflectPointerToString(a.UpdateReferralProgram), + stringer.PtrToString(a.UpdateReferralProgram), ) } @@ -79,7 +79,7 @@ func (p UpdateReferralProgram) IntoProto() *vegapb.UpdateReferralProgram { func (p UpdateReferralProgram) String() string { return fmt.Sprintf( "changes(%s)", - stringer.ReflectPointerToString(p.Changes), + stringer.PtrToString(p.Changes), ) } diff --git a/core/types/governance_update_spot_market.go b/core/types/governance_update_spot_market.go index b6f8bf4b940..ecc6129a197 100644 --- a/core/types/governance_update_spot_market.go +++ b/core/types/governance_update_spot_market.go @@ -30,7 +30,7 @@ type ProposalTermsUpdateSpotMarket struct { func (a ProposalTermsUpdateSpotMarket) String() string { return fmt.Sprintf( "updateSpotMarket(%s)", - stringer.ReflectPointerToString(a.UpdateSpotMarket), + stringer.PtrToString(a.UpdateSpotMarket), ) } @@ -86,7 +86,7 @@ func (n UpdateSpotMarket) String() string { return fmt.Sprintf( "marketID(%s) changes(%s)", n.MarketID, - stringer.ReflectPointerToString(n.Changes), + stringer.PtrToString(n.Changes), ) } @@ -123,12 +123,12 @@ type UpdateSpotMarketConfiguration struct { func (n UpdateSpotMarketConfiguration) String() string { return fmt.Sprintf( "instrument(%s) metadata(%v) priceMonitoring(%s) targetStakeParameters(%s) risk(%s) slaParams(%s)", - stringer.ReflectPointerToString(n.Instrument), + stringer.PtrToString(n.Instrument), MetadataList(n.Metadata).String(), - stringer.ReflectPointerToString(n.PriceMonitoringParameters), - stringer.ReflectPointerToString(n.TargetStakeParameters), - stringer.ReflectPointerToString(n.RiskParameters), - stringer.ReflectPointerToString(n.SLAParams), + stringer.PtrToString(n.PriceMonitoringParameters), + stringer.PtrToString(n.TargetStakeParameters), + stringer.ObjToString(n.RiskParameters), + stringer.PtrToString(n.SLAParams), ) } @@ -217,7 +217,7 @@ type UpdateSpotMarketConfigurationSimple struct { func (n UpdateSpotMarketConfigurationSimple) String() string { return fmt.Sprintf( "simple(%s)", - stringer.ReflectPointerToString(n.Simple), + stringer.PtrToString(n.Simple), ) } @@ -253,7 +253,7 @@ type UpdateSpotMarketConfigurationLogNormal struct { func (n UpdateSpotMarketConfigurationLogNormal) String() string { return fmt.Sprintf( "logNormal(%s)", - stringer.ReflectPointerToString(n.LogNormal), + stringer.PtrToString(n.LogNormal), ) } diff --git a/core/types/governance_update_volume_discount_program.go b/core/types/governance_update_volume_discount_program.go index fbaffcba0d0..43a0a6ef002 100644 --- a/core/types/governance_update_volume_discount_program.go +++ b/core/types/governance_update_volume_discount_program.go @@ -31,7 +31,7 @@ type ProposalTermsUpdateVolumeDiscountProgram struct { func (a ProposalTermsUpdateVolumeDiscountProgram) String() string { return fmt.Sprintf( "updateVolumeDiscountProgram(%s)", - stringer.ReflectPointerToString(a.UpdateVolumeDiscountProgram), + stringer.PtrToString(a.UpdateVolumeDiscountProgram), ) } @@ -79,7 +79,7 @@ func (p UpdateVolumeDiscountProgram) IntoProto() *vegapb.UpdateVolumeDiscountPro func (p UpdateVolumeDiscountProgram) String() string { return fmt.Sprintf( "changes(%s)", - stringer.ReflectPointerToString(p.Changes), + stringer.PtrToString(p.Changes), ) } diff --git a/core/types/liquidity.go b/core/types/liquidity.go index f840e8c68d1..5a9e9f8ae64 100644 --- a/core/types/liquidity.go +++ b/core/types/liquidity.go @@ -188,7 +188,7 @@ func (l LiquidityProvisionSubmission) String() string { "marketID(%s) reference(%s) commitmentAmount(%s) fee(%s)", l.MarketID, l.Reference, - stringer.UintPointerToString(l.CommitmentAmount), + stringer.PtrToString(l.CommitmentAmount), l.Fee.String(), ) } @@ -226,7 +226,7 @@ func (l LiquidityProvision) String() string { l.Party, l.Status.String(), l.Reference, - stringer.UintPointerToString(l.CommitmentAmount), + stringer.PtrToString(l.CommitmentAmount), l.Fee.String(), l.Version, l.CreatedAt, @@ -315,7 +315,7 @@ func (l LiquidityMonitoringParameters) String() string { "auctionExtension(%v) trigerringRatio(%s) targetStake(%s)", l.AuctionExtension, l.TriggeringRatio.String(), - stringer.ReflectPointerToString(l.TargetStakeParameters), + stringer.PtrToString(l.TargetStakeParameters), ) } @@ -388,7 +388,7 @@ func (a LiquidityProvisionAmendment) String() string { "marketID(%s) reference(%s) commitmentAmount(%s) fee(%s)", a.MarketID, a.Reference, - stringer.UintPointerToString(a.CommitmentAmount), + stringer.PtrToString(a.CommitmentAmount), a.Fee.String(), ) } diff --git a/core/types/market.go b/core/types/market.go index 030fb2c7a48..0697538cf27 100644 --- a/core/types/market.go +++ b/core/types/market.go @@ -345,9 +345,9 @@ func (t TradableInstrument) GetLogNormalRiskModel() *LogNormalRiskModel { func (t TradableInstrument) String() string { return fmt.Sprintf( "instrument(%s) marginCalculator(%s) riskModel(%s)", - stringer.ReflectPointerToString(t.Instrument), - stringer.ReflectPointerToString(t.MarginCalculator), - stringer.ReflectPointerToString(t.RiskModel), + stringer.PtrToString(t.Instrument), + stringer.PtrToString(t.MarginCalculator), + stringer.ObjToString(t.RiskModel), ) } @@ -374,7 +374,7 @@ func (InstrumentSpot) Type() ProductType { func (i InstrumentSpot) String() string { return fmt.Sprintf( "spot(%s)", - stringer.ReflectPointerToString(i.Spot), + stringer.PtrToString(i.Spot), ) } @@ -419,7 +419,7 @@ func (InstrumentFuture) Type() ProductType { func (i InstrumentFuture) String() string { return fmt.Sprintf( "future(%s)", - stringer.ReflectPointerToString(i.Future), + stringer.PtrToString(i.Future), ) } @@ -456,9 +456,9 @@ func (f Future) String() string { "quoteName(%s) settlementAsset(%s) dataSourceSpec(settlementData(%s) tradingTermination(%s) binding(%s))", f.QuoteName, f.SettlementAsset, - stringer.ReflectPointerToString(f.DataSourceSpecForSettlementData), - stringer.ReflectPointerToString(f.DataSourceSpecForTradingTermination), - stringer.ReflectPointerToString(f.DataSourceSpecBinding), + stringer.PtrToString(f.DataSourceSpecForSettlementData), + stringer.PtrToString(f.DataSourceSpecForTradingTermination), + stringer.PtrToString(f.DataSourceSpecBinding), ) } @@ -473,7 +473,7 @@ func (InstrumentPerps) Type() ProductType { func (i InstrumentPerps) String() string { return fmt.Sprintf( "perps(%s)", - stringer.ReflectPointerToString(i.Perps), + stringer.PtrToString(i.Perps), ) } @@ -528,9 +528,9 @@ func (p Perps) String() string { p.InterestRate.String(), p.ClampLowerBound.String(), p.ClampUpperBound.String(), - stringer.ReflectPointerToString(p.DataSourceSpecForSettlementData), - stringer.ReflectPointerToString(p.DataSourceSpecForSettlementSchedule), - stringer.ReflectPointerToString(p.DataSourceSpecBinding), + stringer.PtrToString(p.DataSourceSpecForSettlementData), + stringer.PtrToString(p.DataSourceSpecForSettlementSchedule), + stringer.PtrToString(p.DataSourceSpecBinding), ) } @@ -761,8 +761,8 @@ func (i Instrument) String() string { i.ID, i.Name, i.Code, - stringer.ReflectPointerToString(i.Product), - stringer.ReflectPointerToString(i.Metadata), + stringer.ObjToString(i.Product), + stringer.PtrToString(i.Metadata), ) } @@ -917,24 +917,24 @@ func (m MarketData) IntoProto() *vegapb.MarketData { func (m MarketData) String() string { return fmt.Sprintf( "markPrice(%s) lastTradedPrice(%s) bestBidPrice(%s) bestBidVolume(%v) bestOfferPrice(%s) bestOfferVolume(%v) bestStaticBidPrice(%s) bestStaticBidVolume(%v) bestStaticOfferPrice(%s) bestStaticOfferVolume(%v) midPrice(%s) staticMidPrice(%s) market(%s) timestamp(%v) openInterest(%v) auctionEnd(%v) auctionStart(%v) indicativePrice(%s) indicativeVolume(%v) marketTradingMode(%s) marketState(%s) trigger(%s) extensionTrigger(%s) targetStake(%s) suppliedStake(%s) priceMonitoringBounds(%s) marketValueProxy(%s) liquidityProviderFeeShare(%v) liquidityProviderSLA(%v) nextMTM(%v) marketGrowth(%v)", - stringer.UintPointerToString(m.MarkPrice), - stringer.UintPointerToString(m.LastTradedPrice), + stringer.PtrToString(m.MarkPrice), + stringer.PtrToString(m.LastTradedPrice), m.BestBidPrice.String(), m.BestBidVolume, - stringer.UintPointerToString(m.BestOfferPrice), + stringer.PtrToString(m.BestOfferPrice), m.BestOfferVolume, - stringer.UintPointerToString(m.BestStaticBidPrice), + stringer.PtrToString(m.BestStaticBidPrice), m.BestStaticBidVolume, - stringer.UintPointerToString(m.BestStaticOfferPrice), + stringer.PtrToString(m.BestStaticOfferPrice), m.BestStaticOfferVolume, - stringer.UintPointerToString(m.MidPrice), - stringer.UintPointerToString(m.StaticMidPrice), + stringer.PtrToString(m.MidPrice), + stringer.PtrToString(m.StaticMidPrice), m.Market, m.Timestamp, m.OpenInterest, m.AuctionEnd, m.AuctionStart, - stringer.UintPointerToString(m.IndicativePrice), + stringer.PtrToString(m.IndicativePrice), m.IndicativeVolume, m.MarketTradingMode.String(), m.MarketState.String(), @@ -1094,16 +1094,16 @@ func (m Market) String() string { return fmt.Sprintf( "ID(%s) tradableInstrument(%s) decimalPlaces(%v) positionDecimalPlaces(%v) fees(%s) openingAuction(%s) priceMonitoringSettings(%s) liquidityMonitoringParameters(%s) tradingMode(%s) state(%s) marketTimestamps(%s)", m.ID, - stringer.ReflectPointerToString(m.TradableInstrument), + stringer.PtrToString(m.TradableInstrument), m.DecimalPlaces, m.PositionDecimalPlaces, - stringer.ReflectPointerToString(m.Fees), - stringer.ReflectPointerToString(m.OpeningAuction), - stringer.ReflectPointerToString(m.PriceMonitoringSettings), - stringer.ReflectPointerToString(m.LiquidityMonitoringParameters), + stringer.PtrToString(m.Fees), + stringer.PtrToString(m.OpeningAuction), + stringer.PtrToString(m.PriceMonitoringSettings), + stringer.PtrToString(m.LiquidityMonitoringParameters), m.TradingMode.String(), m.State.String(), - stringer.ReflectPointerToString(m.MarketTimestamps), + stringer.PtrToString(m.MarketTimestamps), ) } diff --git a/core/types/matching.go b/core/types/matching.go index 275d6541978..62a47c12461 100644 --- a/core/types/matching.go +++ b/core/types/matching.go @@ -195,11 +195,11 @@ func (o Order) String() string { o.CreatedAt, o.UpdatedAt, o.ExpiresAt, - stringer.UintPointerToString(o.OriginalPrice), - stringer.ReflectPointerToString(o.PeggedOrder), + stringer.PtrToString(o.OriginalPrice), + stringer.PtrToString(o.PeggedOrder), o.PostOnly, o.ReduceOnly, - stringer.ReflectPointerToString(o.IcebergOrder), + stringer.PtrToString(o.IcebergOrder), ) } @@ -534,7 +534,7 @@ func (p PeggedOrder) String() string { return fmt.Sprintf( "reference(%s) offset(%s)", p.Reference.String(), - stringer.UintPointerToString(p.Offset), + stringer.PtrToString(p.Offset), ) } @@ -672,8 +672,8 @@ func (t Trade) String() string { "ID(%s) marketID(%s) price(%s) marketPrice(%s) size(%v) buyer(%s) seller(%s) aggressor(%s) buyOrder(%s) sellOrder(%s) timestamp(%v) type(%s) buyerAuctionBatch(%v) sellerAuctionBatch(%v) buyerFee(%s) sellerFee(%s)", t.ID, t.MarketID, - stringer.UintPointerToString(t.Price), - stringer.UintPointerToString(t.MarketPrice), + stringer.PtrToString(t.Price), + stringer.PtrToString(t.MarketPrice), t.Size, t.Buyer, t.Seller, @@ -684,8 +684,8 @@ func (t Trade) String() string { t.Type.String(), t.BuyerAuctionBatch, t.SellerAuctionBatch, - stringer.ReflectPointerToString(t.SellerFee), - stringer.ReflectPointerToString(t.BuyerFee), + stringer.PtrToString(t.SellerFee), + stringer.PtrToString(t.BuyerFee), ) } diff --git a/core/types/orders.go b/core/types/orders.go index 9166cc5bcfa..aebae01d762 100644 --- a/core/types/orders.go +++ b/core/types/orders.go @@ -146,9 +146,9 @@ func (o OrderAmendment) String() string { o.SizeDelta, o.TimeInForce.String(), o.PeggedReference.String(), - stringer.UintPointerToString(o.Price), - stringer.Int64PointerToString(o.ExpiresAt), - stringer.UintPointerToString(o.PeggedOffset), + stringer.PtrToString(o.Price), + stringer.PtrToString(o.ExpiresAt), + stringer.PtrToString(o.PeggedOffset), ) } diff --git a/core/types/pricemonitoring.go b/core/types/pricemonitoring.go index 402719a80c3..561d304b30e 100644 --- a/core/types/pricemonitoring.go +++ b/core/types/pricemonitoring.go @@ -56,9 +56,9 @@ type PriceMonitoringBounds struct { func (p PriceMonitoringBounds) String() string { return fmt.Sprintf( "minValidPrice(%s) maxValidPrice(%s) trigger(%s) referencePrice(%s)", - stringer.UintPointerToString(p.MinValidPrice), - stringer.UintPointerToString(p.MaxValidPrice), - stringer.ReflectPointerToString(p.Trigger), + stringer.PtrToString(p.MinValidPrice), + stringer.PtrToString(p.MaxValidPrice), + stringer.PtrToString(p.Trigger), p.ReferencePrice.String(), ) } @@ -80,7 +80,7 @@ func (p PriceMonitoringSettings) DeepClone() *PriceMonitoringSettings { } func (p PriceMonitoringSettings) String() string { - return fmt.Sprintf("parameters(%s)", stringer.ReflectPointerToString(p.Parameters)) + return fmt.Sprintf("parameters(%s)", stringer.PtrToString(p.Parameters)) } func PriceMonitoringSettingsFromProto(pr *proto.PriceMonitoringSettings) *PriceMonitoringSettings { diff --git a/core/types/processor.go b/core/types/processor.go index 20ef439638b..17ac1019d15 100644 --- a/core/types/processor.go +++ b/core/types/processor.go @@ -162,14 +162,14 @@ func (o OrderSubmission) String() string { return fmt.Sprintf( "marketID(%s) price(%s) size(%v) side(%s) timeInForce(%s) expiresAt(%v) type(%s) reference(%s) peggedOrder(%s) postOnly(%v) reduceOnly(%v)", o.MarketID, - stringer.UintPointerToString(o.Price), + stringer.PtrToString(o.Price), o.Size, o.Side.String(), o.TimeInForce.String(), o.ExpiresAt, o.Type.String(), o.Reference, - stringer.ReflectPointerToString(o.PeggedOrder), + stringer.PtrToString(o.PeggedOrder), o.PostOnly, o.ReduceOnly, ) @@ -242,7 +242,7 @@ func (w WithdrawSubmission) String() string { return fmt.Sprintf( "asset(%s) amount(%s) ext(%s)", w.Asset, - stringer.UintPointerToString(w.Amount), - stringer.ReflectPointerToString(w.Ext), + stringer.PtrToString(w.Amount), + stringer.PtrToString(w.Ext), ) } diff --git a/core/types/risk.go b/core/types/risk.go index bd1880a4d6e..74460b90f39 100644 --- a/core/types/risk.go +++ b/core/types/risk.go @@ -93,7 +93,7 @@ func (l LogNormalRiskModel) String() string { "tau(%s) riskAversionParameter(%s) params(%s)", l.Tau.String(), l.RiskAversionParameter.String(), - stringer.ReflectPointerToString(l.Params), + stringer.PtrToString(l.Params), ) } @@ -104,7 +104,7 @@ type TradableInstrumentLogNormalRiskModel struct { func (t TradableInstrumentLogNormalRiskModel) String() string { return fmt.Sprintf( "logNormalRiskModel(%s)", - stringer.ReflectPointerToString(t.LogNormalRiskModel), + stringer.PtrToString(t.LogNormalRiskModel), ) } @@ -221,10 +221,10 @@ func (m MarginLevels) String() string { m.MarketID, m.Asset, m.Party, - stringer.UintPointerToString(m.InitialMargin), - stringer.UintPointerToString(m.MaintenanceMargin), - stringer.UintPointerToString(m.CollateralReleaseLevel), - stringer.UintPointerToString(m.SearchLevel), + stringer.PtrToString(m.InitialMargin), + stringer.PtrToString(m.MaintenanceMargin), + stringer.PtrToString(m.CollateralReleaseLevel), + stringer.PtrToString(m.SearchLevel), m.Timestamp, ) } @@ -255,7 +255,7 @@ func (m MarginCalculator) IntoProto() *proto.MarginCalculator { func (m MarginCalculator) String() string { return fmt.Sprintf( "scalingFactors(%s)", - stringer.ReflectPointerToString(m.ScalingFactors), + stringer.PtrToString(m.ScalingFactors), ) } @@ -343,7 +343,7 @@ type TradableInstrumentSimpleRiskModel struct { func (t TradableInstrumentSimpleRiskModel) String() string { return fmt.Sprintf( "simpleRiskModel(%s)", - stringer.ReflectPointerToString(t.SimpleRiskModel), + stringer.PtrToString(t.SimpleRiskModel), ) } @@ -414,7 +414,7 @@ func (s SimpleRiskModel) IntoProto() *proto.SimpleRiskModel { func (s SimpleRiskModel) String() string { return fmt.Sprintf( "params(%s)", - stringer.ReflectPointerToString(s.Params), + stringer.PtrToString(s.Params), ) } diff --git a/core/types/staking.go b/core/types/staking.go index 5248c0116b8..21e52a26d7a 100644 --- a/core/types/staking.go +++ b/core/types/staking.go @@ -61,7 +61,7 @@ func (s *StakeTotalSupply) String() string { return fmt.Sprintf( "tokenAddress(%s) totalSupply(%s)", s.TokenAddress, - stringer.UintPointerToString(s.TotalSupply), + stringer.PtrToString(s.TotalSupply), ) } @@ -111,7 +111,7 @@ func (s *StakeLinking) String() string { s.Type.String(), s.TS, s.Party, - stringer.UintPointerToString(s.Amount), + stringer.PtrToString(s.Amount), s.Status.String(), s.FinalizedAt, s.TxHash, @@ -218,7 +218,7 @@ func (s StakeDeposited) String() string { s.LogIndex, s.VegaPubKey, s.EthereumAddress, - stringer.UintPointerToString(s.Amount), + stringer.PtrToString(s.Amount), s.BlockTime, ) } @@ -269,7 +269,7 @@ func (s StakeRemoved) String() string { s.LogIndex, s.VegaPubKey, s.EthereumAddress, - stringer.UintPointerToString(s.Amount), + stringer.PtrToString(s.Amount), s.BlockTime, ) } diff --git a/core/types/transfer.go b/core/types/transfer.go index 82ec3cd8738..7022ac89de2 100644 --- a/core/types/transfer.go +++ b/core/types/transfer.go @@ -84,7 +84,7 @@ func (f FinancialAmount) String() string { return fmt.Sprintf( "asset(%s) amount(%s)", f.Asset, - stringer.UintPointerToString(f.Amount), + stringer.PtrToString(f.Amount), ) } @@ -141,9 +141,9 @@ func (t *Transfer) String() string { return fmt.Sprintf( "owner(%s) amount(%s) type(%s) minAmount(%s)", t.Owner, - stringer.ReflectPointerToString(t.Amount), + stringer.PtrToString(t.Amount), t.Type.String(), - stringer.UintPointerToString(t.MinAmount), + stringer.PtrToString(t.MinAmount), ) } diff --git a/libs/stringer/stringer.go b/libs/stringer/stringer.go index 78082d3afc8..19c988ba718 100644 --- a/libs/stringer/stringer.go +++ b/libs/stringer/stringer.go @@ -16,33 +16,26 @@ package stringer import ( + "fmt" "reflect" - "strconv" - - "code.vegaprotocol.io/vega/libs/num" ) type Stringer interface { String() string } -func ReflectPointerToString(obj Stringer) string { - if obj == nil || reflect.ValueOf(obj).Kind() == reflect.Ptr && reflect.ValueOf(obj).IsNil() { +func ObjToString(v Stringer) string { + if v == nil || reflect.ValueOf(v).Kind() == reflect.Ptr && reflect.ValueOf(v).IsNil() { return "nil" } - return obj.String() -} -func UintPointerToString(obj *num.Uint) string { - if obj == nil { - return "nil" - } - return obj.String() + return v.String() } -func Int64PointerToString(n *int64) string { - if n == nil { +func PtrToString[T any](v *T) string { + if v == nil { return "nil" } - return strconv.FormatInt(*n, 10) + + return fmt.Sprintf("%v", *v) } diff --git a/libs/stringer/stringer_test.go b/libs/stringer/stringer_test.go index 2e327a77478..6ab6d0e7050 100644 --- a/libs/stringer/stringer_test.go +++ b/libs/stringer/stringer_test.go @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/assert" ) -func TestReflectPointerToString(t *testing.T) { +func TestToString(t *testing.T) { tcs := []struct { name string stringer stringer.Stringer @@ -40,7 +40,7 @@ func TestReflectPointerToString(t *testing.T) { expected: "nil", }, { name: "with existing struct", - stringer: dummyStringer{}, + stringer: &dummyStringer{}, expected: "stringer", }, } @@ -48,7 +48,7 @@ func TestReflectPointerToString(t *testing.T) { for _, tc := range tcs { t.Run(tc.name, func(tt *testing.T) { // when - str := stringer.ReflectPointerToString(tc.stringer) + str := stringer.ObjToString(tc.stringer) // then assert.Equal(tt, tc.expected, str) @@ -56,7 +56,7 @@ func TestReflectPointerToString(t *testing.T) { } } -func TestUintPointerToString(t *testing.T) { +func TestPtrToString(t *testing.T) { tcs := []struct { name string num *num.Uint @@ -76,7 +76,7 @@ func TestUintPointerToString(t *testing.T) { for _, tc := range tcs { t.Run(tc.name, func(tt *testing.T) { // when - str := stringer.UintPointerToString(tc.num) + str := stringer.PtrToString(tc.num) // then assert.Equal(tt, tc.expected, str) @@ -107,7 +107,7 @@ func TestInt64PointerToString(t *testing.T) { for _, tc := range tcs { t.Run(tc.name, func(tt *testing.T) { // when - str := stringer.Int64PointerToString(tc.num) + str := stringer.PtrToString(tc.num) // then assert.Equal(tt, tc.expected, str)