Skip to content

Commit c23bbc2

Browse files
committed
chore: remove pointer.To in favour of new(T)
This is a cleanup of the `deployment` codebase to remove the use of `pointer.To` in favour of `new(T)`.
1 parent a732bc8 commit c23bbc2

16 files changed

Lines changed: 160 additions & 187 deletions

File tree

deployment/ccip/changeset/crossfamily/cs_set_token_transfer_fee_config.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@ import (
1111

1212
cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment"
1313
cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils"
14-
"github.com/smartcontractkit/chainlink/deployment/helpers/pointer"
1514

15+
"github.com/smartcontractkit/chainlink/deployment"
1616
ccip_cs_common "github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
1717
ccip_cs_sol_v0_1_1 "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/solana_v0_1_1"
1818
ccip_cs_evm_v1_5_1 "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/v1_5_1"
1919
ccip_cs_evm_v1_6_0 "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/v1_6"
20-
21-
"github.com/smartcontractkit/chainlink/deployment"
2220
"github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview"
21+
"github.com/smartcontractkit/chainlink/deployment/helpers/pointer"
2322
)
2423

2524
var _ cldf.ChangeSetV2[SetTokenTransferFeeConfigInput] = SetTokenTransferFeeConfig
@@ -41,8 +40,8 @@ var _ cldf.ChangeSetV2[SetTokenTransferFeeConfigInput] = SetTokenTransferFeeConf
4140
var SetTokenTransferFeeConfig = cldf.CreateChangeSet(setTokenTransferFeeLogic, setTokenTransferFeePrecondition)
4241

4342
var SetTokenTransferFeeLatestSupportedVersions = OptionalVersions{
44-
Solana: pointer.To(ccip_cs_sol_v0_1_1.VersionSolanaV0_1_1),
45-
Evm: pointer.To(deployment.Version1_6_0.String()),
43+
Solana: new(ccip_cs_sol_v0_1_1.VersionSolanaV0_1_1),
44+
Evm: new(deployment.Version1_6_0.String()),
4645
}
4746

4847
type OptionalVersions struct {

deployment/ccip/changeset/crossfamily/cs_set_token_transfer_fee_config_test.go

Lines changed: 35 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,30 @@ import (
88

99
"github.com/ethereum/go-ethereum/accounts/abi/bind"
1010
"github.com/ethereum/go-ethereum/common"
11-
mcmschangesets "github.com/smartcontractkit/cld-changesets/legacy/mcms/changesets"
11+
"github.com/gagliardetto/solana-go"
1212
"github.com/stretchr/testify/require"
1313

1414
chainsel "github.com/smartcontractkit/chain-selectors"
15-
16-
"github.com/gagliardetto/solana-go"
17-
18-
"github.com/smartcontractkit/chainlink-evm/pkg/utils"
15+
mcmschangesets "github.com/smartcontractkit/cld-changesets/legacy/mcms/changesets"
1916

2017
solfq "github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings/v0_1_1/fee_quoter"
2118
cldf_chain "github.com/smartcontractkit/chainlink-deployments-framework/chain"
2219
cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment"
2320
cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils"
21+
"github.com/smartcontractkit/chainlink-evm/pkg/utils"
2422

25-
"github.com/smartcontractkit/chainlink/deployment"
23+
ccip_cs_sol_v0_1_1 "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/solana_v0_1_1"
24+
solstateview "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview/solana"
2625
commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset"
27-
"github.com/smartcontractkit/chainlink/deployment/helpers/pointer"
2826

2927
solstate "github.com/smartcontractkit/chainlink-ccip/chains/solana/utils/state"
30-
28+
"github.com/smartcontractkit/chainlink/deployment"
3129
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
30+
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/crossfamily"
3231
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/testhelpers"
3332
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/testhelpers/v1_5"
3433
"github.com/smartcontractkit/chainlink/deployment/ccip/shared"
3534
"github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview"
36-
37-
solstateview "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview/solana"
38-
39-
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/crossfamily"
40-
ccip_cs_sol_v0_1_1 "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/solana_v0_1_1"
4135
)
4236

4337
const SetTokenTransferFeePriceRegStalenessThreshold = 60 * 60 * 24 * 14 // two weeks in seconds
@@ -234,8 +228,8 @@ func TestSetTokenTransferFeeConfig_Validations(t *testing.T) {
234228
MsgStr: "Unsupported EVM version hint fails fast",
235229
Config: crossfamily.SetTokenTransferFeeConfigInput{
236230
VersionHints: &crossfamily.OptionalVersions{
237-
Solana: pointer.To(ccip_cs_sol_v0_1_1.VersionSolanaV0_1_1), // valid solana (doesn't matter)
238-
Evm: pointer.To("1.4.9"), // bogus/unsupported
231+
Solana: new(ccip_cs_sol_v0_1_1.VersionSolanaV0_1_1), // valid solana (doesn't matter)
232+
Evm: new("1.4.9"), // bogus/unsupported
239233
},
240234
InputsByChain: map[uint64]map[uint64]crossfamily.TokenTransferFeeConfigArgs{
241235
evmSrc: {
@@ -254,8 +248,8 @@ func TestSetTokenTransferFeeConfig_Validations(t *testing.T) {
254248
MsgStr: "Unsupported Solana version hint fails fast",
255249
Config: crossfamily.SetTokenTransferFeeConfigInput{
256250
VersionHints: &crossfamily.OptionalVersions{
257-
Evm: pointer.To(deployment.Version1_6_0.String()),
258-
Solana: pointer.To("v0_0_9"), // bogus/unsupported
251+
Evm: new(deployment.Version1_6_0.String()),
252+
Solana: new("v0_0_9"), // bogus/unsupported
259253
},
260254
InputsByChain: map[uint64]map[uint64]crossfamily.TokenTransferFeeConfigArgs{
261255
solSrc: {
@@ -329,15 +323,15 @@ func TestSetTokenTransferFeeConfig_EVM_V1_6_0_Only(t *testing.T) {
329323
TokenAddressToFeeConfig: map[string]crossfamily.OptionalTokenTransferFeeConfig{
330324
link.Hex(): {
331325
// partial fields: defaults should be auto-filled by the EVM changeset when none exist
332-
MinFeeUsdCents: pointer.To(uint32(800)),
333-
DestGasOverhead: pointer.To(uint32(100)),
326+
MinFeeUsdCents: new(uint32(800)),
327+
DestGasOverhead: new(uint32(100)),
334328
},
335329
},
336330
},
337331
},
338332
},
339333
VersionHints: &crossfamily.OptionalVersions{
340-
Evm: pointer.To(deployment.Version1_6_0.String()),
334+
Evm: new(deployment.Version1_6_0.String()),
341335
},
342336
MCMS: &SetTokenTransferFeeMcmsConfig,
343337
}
@@ -420,19 +414,19 @@ func TestSetTokenTransferFeeConfig_EVM_V1_5_1_Only(t *testing.T) {
420414
dst: {
421415
TokenAddressToFeeConfig: map[string]crossfamily.OptionalTokenTransferFeeConfig{
422416
link.Hex(): {
423-
DestBytesOverhead: pointer.To(uint32(32)),
424-
DestGasOverhead: pointer.To(uint32(10)),
425-
MaxFeeUsdCents: pointer.To(uint32(math.MaxUint32)),
426-
MinFeeUsdCents: pointer.To(uint32(800)),
427-
DeciBps: pointer.To(uint16(0)),
428-
IsEnabled: pointer.To(true),
417+
DestBytesOverhead: new(uint32(32)),
418+
DestGasOverhead: new(uint32(10)),
419+
MaxFeeUsdCents: new(uint32(math.MaxUint32)),
420+
MinFeeUsdCents: new(uint32(800)),
421+
DeciBps: new(uint16(0)),
422+
IsEnabled: new(true),
429423
},
430424
},
431425
},
432426
},
433427
},
434428
VersionHints: &crossfamily.OptionalVersions{
435-
Evm: pointer.To(deployment.Version1_5_1.String()),
429+
Evm: new(deployment.Version1_5_1.String()),
436430
},
437431
MCMS: &SetTokenTransferFeeMcmsConfig,
438432
}
@@ -507,19 +501,19 @@ func TestSetTokenTransferFeeConfig_Solana_V0_1_0_Only(t *testing.T) {
507501
TokenAddressToFeeConfig: map[string]crossfamily.OptionalTokenTransferFeeConfig{
508502
tokenAddressX.String(): {
509503
// partial fields: defaults should be auto-filled by the SOL changeset when none exist
510-
DestGasOverhead: pointer.To(uint32(10)),
504+
DestGasOverhead: new(uint32(10)),
511505
},
512506
tokenAddressY.String(): {
513507
// partial fields: defaults should be auto-filled by the SOL changeset when none exist
514-
DestBytesOverhead: pointer.To(uint32(64)),
515-
DestGasOverhead: pointer.To(uint32(10)),
508+
DestBytesOverhead: new(uint32(64)),
509+
DestGasOverhead: new(uint32(10)),
516510
},
517511
},
518512
},
519513
},
520514
},
521515
VersionHints: &crossfamily.OptionalVersions{
522-
Solana: pointer.To(ccip_cs_sol_v0_1_1.VersionSolanaV0_1_1),
516+
Solana: new(ccip_cs_sol_v0_1_1.VersionSolanaV0_1_1),
523517
},
524518
MCMS: &SetTokenTransferFeeMcmsConfig,
525519
}
@@ -605,11 +599,11 @@ func TestSetTokenTransferFeeConfig_MixedFamilies_SingleApply(t *testing.T) {
605599
evmDst: {
606600
TokenAddressToFeeConfig: map[string]crossfamily.OptionalTokenTransferFeeConfig{
607601
link.Hex(): {
608-
MinFeeUsdCents: pointer.To(uint32(12)),
609-
DeciBps: pointer.To(uint16(7)),
610-
DestGasOverhead: pointer.To(uint32(222)),
611-
DestBytesOverhead: pointer.To(uint32(512)),
612-
IsEnabled: pointer.To(true),
602+
MinFeeUsdCents: new(uint32(12)),
603+
DeciBps: new(uint16(7)),
604+
DestGasOverhead: new(uint32(222)),
605+
DestBytesOverhead: new(uint32(512)),
606+
IsEnabled: new(true),
613607
},
614608
},
615609
},
@@ -620,18 +614,18 @@ func TestSetTokenTransferFeeConfig_MixedFamilies_SingleApply(t *testing.T) {
620614
TokenAddressToFeeConfig: map[string]crossfamily.OptionalTokenTransferFeeConfig{
621615
mint.String(): {
622616
// partial: defaults will fill any omitted fields
623-
MinFeeUsdCents: pointer.To(uint32(900)),
624-
DestGasOverhead: pointer.To(uint32(100)),
625-
DestBytesOverhead: pointer.To(uint32(128)),
617+
MinFeeUsdCents: new(uint32(900)),
618+
DestGasOverhead: new(uint32(100)),
619+
DestBytesOverhead: new(uint32(128)),
626620
// DeciBps/IsEnabled left nil -> defaults (0 / true)
627621
},
628622
},
629623
},
630624
},
631625
},
632626
VersionHints: &crossfamily.OptionalVersions{
633-
Solana: pointer.To(ccip_cs_sol_v0_1_1.VersionSolanaV0_1_1),
634-
Evm: pointer.To(deployment.Version1_6_0.String()),
627+
Solana: new(ccip_cs_sol_v0_1_1.VersionSolanaV0_1_1),
628+
Evm: new(deployment.Version1_6_0.String()),
635629
},
636630
MCMS: &SetTokenTransferFeeMcmsConfig,
637631
}

deployment/ccip/changeset/solana_v0_1_1/cs_chain_contracts_test.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import (
3535
"github.com/smartcontractkit/chainlink/deployment/ccip/shared"
3636
"github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview"
3737
solanastateview "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview/solana"
38-
"github.com/smartcontractkit/chainlink/deployment/helpers/pointer"
3938

4039
"github.com/smartcontractkit/chainlink/deployment"
4140
commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset"
@@ -415,10 +414,10 @@ func doTestBilling(t *testing.T, mcms bool) {
415414
evmChain: {
416415
TokenAddressToFeeConfig: map[solana.PublicKey]ccipChangesetSolana.OptionalFeeQuoterTokenTransferFeeConfig{
417416
tokenAddressB: {
418-
MinFeeUsdcents: pointer.To(uint32(800)),
419-
MaxFeeUsdcents: pointer.To(uint32(1600)),
420-
DestGasOverhead: pointer.To(uint32(100)),
421-
DestBytesOverhead: pointer.To(uint32(100)),
417+
MinFeeUsdcents: new(uint32(800)),
418+
MaxFeeUsdcents: new(uint32(1600)),
419+
DestGasOverhead: new(uint32(100)),
420+
DestBytesOverhead: new(uint32(100)),
422421
IsEnabled: nil, // auto-filled
423422
DeciBps: nil, // auto-filled
424423
},
@@ -430,10 +429,10 @@ func doTestBilling(t *testing.T, mcms bool) {
430429
evmChain2: {
431430
TokenAddressToFeeConfig: map[solana.PublicKey]ccipChangesetSolana.OptionalFeeQuoterTokenTransferFeeConfig{
432431
tokenAddressB: {
433-
MinFeeUsdcents: pointer.To(uint32(800)),
434-
MaxFeeUsdcents: pointer.To(uint32(1600)),
435-
DestGasOverhead: pointer.To(uint32(100)),
436-
DestBytesOverhead: pointer.To(uint32(100)),
432+
MinFeeUsdcents: new(uint32(800)),
433+
MaxFeeUsdcents: new(uint32(1600)),
434+
DestGasOverhead: new(uint32(100)),
435+
DestBytesOverhead: new(uint32(100)),
437436
IsEnabled: nil, // auto-filled
438437
DeciBps: nil, // auto-filled
439438
},

deployment/ccip/changeset/v1_5_1/cs_set_token_transfer_fee_config_test.go

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset"
2727

2828
"github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview"
29-
"github.com/smartcontractkit/chainlink/deployment/helpers/pointer"
3029
)
3130

3231
// Two weeks in seconds
@@ -167,12 +166,12 @@ func TestSetTokenTransferFeeConfig_Validations(t *testing.T) {
167166
TokensToUseDefaultFeeConfigs: []common.Address{tokenB},
168167
TokenTransferFeeConfigArgs: map[common.Address]v1_5_1.TokenTransferFeeArgs{
169168
tokenB: {
170-
MinFeeUSDCents: pointer.To(uint32(1)),
171-
MaxFeeUSDCents: pointer.To(uint32(2)),
172-
DeciBps: pointer.To(uint16(10)),
173-
DestGasOverhead: pointer.To(uint32(100)),
174-
DestBytesOverhead: pointer.To(uint32(200)),
175-
AggregateRateLimitEnabled: pointer.To(true),
169+
MinFeeUSDCents: new(uint32(1)),
170+
MaxFeeUSDCents: new(uint32(2)),
171+
DeciBps: new(uint16(10)),
172+
DestGasOverhead: new(uint32(100)),
173+
DestBytesOverhead: new(uint32(200)),
174+
AggregateRateLimitEnabled: new(true),
176175
},
177176
},
178177
},
@@ -276,12 +275,12 @@ func TestSetTokenTransferFeeConfig_Execution_WithoutMCMS(t *testing.T) {
276275
TokensToUseDefaultFeeConfigs: []common.Address{},
277276
TokenTransferFeeConfigArgs: map[common.Address]v1_5_1.TokenTransferFeeArgs{
278277
tokenA: {
279-
MinFeeUSDCents: pointer.To(uint32(100)),
280-
MaxFeeUSDCents: pointer.To(uint32(5000)),
281-
DeciBps: pointer.To(uint16(25)),
282-
DestGasOverhead: pointer.To(uint32(100_000)),
283-
DestBytesOverhead: pointer.To(uint32(1200)),
284-
AggregateRateLimitEnabled: pointer.To(true),
278+
MinFeeUSDCents: new(uint32(100)),
279+
MaxFeeUSDCents: new(uint32(5000)),
280+
DeciBps: new(uint16(25)),
281+
DestGasOverhead: new(uint32(100_000)),
282+
DestBytesOverhead: new(uint32(1200)),
283+
AggregateRateLimitEnabled: new(true),
285284
},
286285
},
287286
},
@@ -347,12 +346,12 @@ func TestSetTokenTransferFeeConfig_Execution_WithMCMS(t *testing.T) {
347346
TokensToUseDefaultFeeConfigs: []common.Address{},
348347
TokenTransferFeeConfigArgs: map[common.Address]v1_5_1.TokenTransferFeeArgs{
349348
tokenA: {
350-
MinFeeUSDCents: pointer.To(uint32(100)),
351-
MaxFeeUSDCents: pointer.To(uint32(5000)),
352-
DeciBps: pointer.To(uint16(25)),
353-
DestGasOverhead: pointer.To(uint32(100_000)),
354-
DestBytesOverhead: pointer.To(uint32(1200)),
355-
AggregateRateLimitEnabled: pointer.To(true),
349+
MinFeeUSDCents: new(uint32(100)),
350+
MaxFeeUSDCents: new(uint32(5000)),
351+
DeciBps: new(uint16(25)),
352+
DestGasOverhead: new(uint32(100_000)),
353+
DestBytesOverhead: new(uint32(1200)),
354+
AggregateRateLimitEnabled: new(true),
356355
},
357356
},
358357
},
@@ -390,12 +389,12 @@ func TestSetTokenTransferFeeConfig_Execution_WithMCMS(t *testing.T) {
390389
TokensToUseDefaultFeeConfigs: []common.Address{tokenB},
391390
TokenTransferFeeConfigArgs: map[common.Address]v1_5_1.TokenTransferFeeArgs{
392391
tokenA: {
393-
MinFeeUSDCents: nil, // keep current
394-
MaxFeeUSDCents: nil, // keep current
395-
DeciBps: pointer.To(uint16(30)), // change
396-
DestGasOverhead: nil, // keep current
397-
DestBytesOverhead: nil, // keep current
398-
AggregateRateLimitEnabled: nil, // keep current
392+
MinFeeUSDCents: nil, // keep current
393+
MaxFeeUSDCents: nil, // keep current
394+
DeciBps: new(uint16(30)), // change
395+
DestGasOverhead: nil, // keep current
396+
DestBytesOverhead: nil, // keep current
397+
AggregateRateLimitEnabled: nil, // keep current
399398
},
400399
},
401400
},
@@ -461,12 +460,12 @@ func TestSetTokenTransferFeeConfig_MultipleChains(t *testing.T) {
461460
TokensToUseDefaultFeeConfigs: []common.Address{tokenB},
462461
TokenTransferFeeConfigArgs: map[common.Address]v1_5_1.TokenTransferFeeArgs{
463462
tokenA: {
464-
MinFeeUSDCents: pointer.To(uint32(101)),
465-
MaxFeeUSDCents: pointer.To(uint32(5001)),
466-
DeciBps: pointer.To(uint16(26)),
467-
DestGasOverhead: pointer.To(uint32(110_000)),
468-
DestBytesOverhead: pointer.To(uint32(1300)),
469-
AggregateRateLimitEnabled: pointer.To(true),
463+
MinFeeUSDCents: new(uint32(101)),
464+
MaxFeeUSDCents: new(uint32(5001)),
465+
DeciBps: new(uint16(26)),
466+
DestGasOverhead: new(uint32(110_000)),
467+
DestBytesOverhead: new(uint32(1300)),
468+
AggregateRateLimitEnabled: new(true),
470469
},
471470
},
472471
},
@@ -476,12 +475,12 @@ func TestSetTokenTransferFeeConfig_MultipleChains(t *testing.T) {
476475
TokensToUseDefaultFeeConfigs: []common.Address{tokenD},
477476
TokenTransferFeeConfigArgs: map[common.Address]v1_5_1.TokenTransferFeeArgs{
478477
tokenC: {
479-
MinFeeUSDCents: pointer.To(uint32(202)),
480-
MaxFeeUSDCents: pointer.To(uint32(6002)),
481-
DeciBps: pointer.To(uint16(31)),
482-
DestGasOverhead: pointer.To(uint32(120_000)),
483-
DestBytesOverhead: pointer.To(uint32(1400)),
484-
AggregateRateLimitEnabled: pointer.To(false),
478+
MinFeeUSDCents: new(uint32(202)),
479+
MaxFeeUSDCents: new(uint32(6002)),
480+
DeciBps: new(uint16(31)),
481+
DestGasOverhead: new(uint32(120_000)),
482+
DestBytesOverhead: new(uint32(1400)),
483+
AggregateRateLimitEnabled: new(false),
485484
},
486485
},
487486
},

0 commit comments

Comments
 (0)