Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ require (
github.com/gagliardetto/solana-go v1.13.0
github.com/smartcontractkit/ccip-owner-contracts v0.1.0
github.com/smartcontractkit/chain-selectors v1.0.97
github.com/smartcontractkit/chainlink-common v0.10.1-0.20260217160002-b56cb5356cc7
github.com/smartcontractkit/chainlink-deployments-framework v0.98.0
github.com/smartcontractkit/chainlink-evm v0.3.3
github.com/smartcontractkit/chainlink-evm/gethwrappers v0.0.0-20260421142741-9c7fbaf7c828
github.com/smartcontractkit/mcms v0.40.1
github.com/stretchr/testify v1.11.1
gopkg.in/yaml.v3 v3.0.1
Expand Down Expand Up @@ -209,7 +212,6 @@ require (
github.com/smartcontractkit/chainlink-aptos v0.0.0-20260306142855-8d629e752265 // indirect
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20260121163256-85accaf3d28d // indirect
github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings v0.0.0-20250912190424-fd2e35d7deb5 // indirect
github.com/smartcontractkit/chainlink-common v0.10.1-0.20260217160002-b56cb5356cc7 // indirect
github.com/smartcontractkit/chainlink-common/pkg/chipingress v0.0.10 // indirect
github.com/smartcontractkit/chainlink-protos/cre/go v0.0.0-20260226130359-963f935e0396 // indirect
github.com/smartcontractkit/chainlink-protos/job-distributor v0.18.0 // indirect
Expand Down
8 changes: 6 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -633,8 +633,8 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro=
github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4=
github.com/onsi/gomega v1.35.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
github.com/onsi/gomega v1.36.2 h1:koNYke6TVk6ZmnyHrCXba/T/MoLBXFjeC1PtvYgw0A8=
github.com/onsi/gomega v1.36.2/go.mod h1:DdwyADRjrc825LhMEkD76cHR5+pUnjhUN8GlHlRPHzY=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040=
Expand Down Expand Up @@ -746,6 +746,10 @@ github.com/smartcontractkit/chainlink-common/pkg/chipingress v0.0.10 h1:FJAFgXS9
github.com/smartcontractkit/chainlink-common/pkg/chipingress v0.0.10/go.mod h1:oiDa54M0FwxevWwyAX773lwdWvFYYlYHHQV1LQ5HpWY=
github.com/smartcontractkit/chainlink-deployments-framework v0.98.0 h1:Ov/KOEtubOHXX8oa9UtARhHmkQNCOIjWNt+Zi0AuzHM=
github.com/smartcontractkit/chainlink-deployments-framework v0.98.0/go.mod h1:24dwRW1PYolrlxSth///ddG3auGqR+50xaJiXfUHhkg=
github.com/smartcontractkit/chainlink-evm v0.3.3 h1:JqwyJEtnNEUaoQQPoOBTT4sn2lpdIZHtf0Hr0M60YDw=
github.com/smartcontractkit/chainlink-evm v0.3.3/go.mod h1:q0ZBvaoisNaqC8NcMYWNPTjee88nQktDEeJMQHq3hVI=
github.com/smartcontractkit/chainlink-evm/gethwrappers v0.0.0-20260421142741-9c7fbaf7c828 h1:BmsFk/TSHL6dPPR86GTqgSrUXLSINNFC6cfpFRrQX+4=
github.com/smartcontractkit/chainlink-evm/gethwrappers v0.0.0-20260421142741-9c7fbaf7c828/go.mod h1:a260YnLyWq2NHLUN5cSVyMGk9nhO6RguCaTI2rsVqyA=
github.com/smartcontractkit/chainlink-protos/cre/go v0.0.0-20260226130359-963f935e0396 h1:03tbcwjyIEjvHba1IWOj1sfThwebm2XNzyFHSuZtlWc=
github.com/smartcontractkit/chainlink-protos/cre/go v0.0.0-20260226130359-963f935e0396/go.mod h1:Jqt53s27Tr0jDl8mdBXg1xhu6F8Fci8JOuq43tgHOM8=
github.com/smartcontractkit/chainlink-protos/job-distributor v0.18.0 h1:q+VDPcxWrj5k9QizSYfUOSMnDH3Sd5HvbPguZOgfXTY=
Expand Down
36 changes: 36 additions & 0 deletions pkg/common/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package common

import (
"fmt"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
)

type ContractMetaData struct {
TypeAndVersion string `json:"typeAndVersion,omitempty"`
Address common.Address `json:"address,omitempty"`
Owner common.Address `json:"owner,omitempty"`
}

func NewContractMetaData(tv Meta, addr common.Address) (ContractMetaData, error) {
tvStr, err := tv.TypeAndVersion(nil)
if err != nil {
return ContractMetaData{}, fmt.Errorf("failed to get type and version addr %s: %w", addr.String(), err)
}
owner, err := tv.Owner(nil)
if err != nil {
return ContractMetaData{}, fmt.Errorf("failed to get owner addr %s: %w", addr.String(), err)
}

return ContractMetaData{
TypeAndVersion: tvStr,
Address: addr,
Owner: owner,
}, nil
}

type Meta interface {
TypeAndVersion(opts *bind.CallOpts) (string, error)
Owner(opts *bind.CallOpts) (common.Address, error)
}
21 changes: 21 additions & 0 deletions pkg/common/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package common

import (
"github.com/Masterminds/semver/v3"
)

var (
Version0_5_0 = *semver.MustParse("0.5.0")
Comment thread
ecPablo marked this conversation as resolved.
Version1_0_0 = *semver.MustParse("1.0.0")
Version1_1_0 = *semver.MustParse("1.1.0")
Version1_2_0 = *semver.MustParse("1.2.0")
Version1_5_0 = *semver.MustParse("1.5.0")
Version1_5_1 = *semver.MustParse("1.5.1")
Version1_6_0 = *semver.MustParse("1.6.0")
Version1_6_1 = *semver.MustParse("1.6.1")
Version1_6_1Dev = *semver.MustParse("1.6.1-dev")
Version1_6_2 = *semver.MustParse("1.6.2")
Version1_6_3Dev = *semver.MustParse("1.6.3-dev")
Version1_6_3 = *semver.MustParse("1.6.3")
Version1_7_0 = *semver.MustParse("1.7.0")
)
61 changes: 61 additions & 0 deletions pkg/contract/link/view/v1_0/link_token.go
Comment thread
ecPablo marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package v1_0

import (
"fmt"
"math/big"

"github.com/ethereum/go-ethereum/common"
linkcontracts "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/contracts/link"

"github.com/smartcontractkit/chainlink-evm/gethwrappers/shared/generated/initial/link_token"

cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment"

cldchangesetscommon "github.com/smartcontractkit/cld-changesets/pkg/common"
)

type LinkTokenView struct {
cldchangesetscommon.ContractMetaData
Decimals uint8 `json:"decimals"`
Supply *big.Int `json:"supply"`
Minters []common.Address `json:"minters"`
Burners []common.Address `json:"burners"`
}

func GenerateLinkTokenView(lt *link_token.LinkToken) (LinkTokenView, error) {
owner, err := lt.Owner(nil)
if err != nil {
owner = common.Address{}
}
decimals, err := lt.Decimals(nil)
if err != nil {
return LinkTokenView{}, fmt.Errorf("failed to get decimals %s: %w", lt.Address(), err)
}
totalSupply, err := lt.TotalSupply(nil)
if err != nil {
return LinkTokenView{}, fmt.Errorf("failed to get total supply %s: %w", lt.Address(), err)
}
minters, err := lt.GetMinters(nil)
if err != nil {
minters = []common.Address{}
}
burners, err := lt.GetBurners(nil)
if err != nil {
burners = []common.Address{}
}
Comment thread
ecPablo marked this conversation as resolved.
Comment thread
ecPablo marked this conversation as resolved.
Comment thread
ecPablo marked this conversation as resolved.

return LinkTokenView{
ContractMetaData: cldchangesetscommon.ContractMetaData{
TypeAndVersion: cldf.TypeAndVersion{
Type: linkcontracts.LinkToken,
Version: cldchangesetscommon.Version1_0_0,
}.String(),
Address: lt.Address(),
Owner: owner,
},
Decimals: decimals,
Supply: totalSupply,
Minters: minters,
Burners: burners,
}, nil
}
87 changes: 87 additions & 0 deletions pkg/contract/link/view/v1_0/link_token_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package v1_0

import (
"math/big"
"testing"

chainselectors "github.com/smartcontractkit/chain-selectors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/smartcontractkit/chainlink-common/pkg/utils/tests"

"github.com/smartcontractkit/chainlink-evm/gethwrappers/shared/generated/initial/link_token"

cldf_evm "github.com/smartcontractkit/chainlink-deployments-framework/chain/evm"
"github.com/smartcontractkit/chainlink-deployments-framework/engine/test/environment"
)

func TestLinkTokenView(t *testing.T) {
t.Parallel()

selector := chainselectors.TEST_90000001.Selector
env, err := environment.New(t.Context(),
environment.WithEVMSimulated(t, []uint64{selector}),
)
require.NoError(t, err)

chain := env.BlockChains.EVMChains()[selector]
_, tx, lt, err := link_token.DeployLinkToken(chain.DeployerKey, chain.Client)
require.NoError(t, err)
_, err = chain.Confirm(tx)
require.NoError(t, err)

testLinkTokenViewWithChain(t, chain, lt)
}

func TestLinkTokenViewZk(t *testing.T) {
// Timeouts in CI
tests.SkipFlakey(t, "https://smartcontract-it.atlassian.net/browse/CCIP-6427")
t.Parallel()

selector := chainselectors.TEST_90000050.Selector
env, err := environment.New(t.Context(),
environment.WithZKSyncContainer(t, []uint64{selector}),
)
require.NoError(t, err)

chain := env.BlockChains.EVMChains()[selector]
_, _, lt, err := link_token.DeployLinkTokenZk(nil, chain.ClientZkSyncVM, chain.DeployerKeyZkSyncVM, chain.Client)
require.NoError(t, err)

testLinkTokenViewWithChain(t, chain, lt)
}

func testLinkTokenViewWithChain(t *testing.T, chain cldf_evm.Chain, lt *link_token.LinkToken) {
t.Helper()

v, err := GenerateLinkTokenView(lt)
require.NoError(t, err)

assert.Equal(t, v.Owner, chain.DeployerKey.From)
assert.Equal(t, "LinkToken 1.0.0", v.TypeAndVersion)
assert.Equal(t, uint8(18), v.Decimals)
// Initially nothing minted and no minters/burners.
assert.Equal(t, "0", v.Supply.String())
require.Empty(t, v.Minters)
require.Empty(t, v.Burners)

// Add some minters
tx, err := lt.GrantMintAndBurnRoles(chain.DeployerKey, chain.DeployerKey.From)
require.NoError(t, err)
_, err = chain.Confirm(tx)
require.NoError(t, err)
tx, err = lt.Mint(chain.DeployerKey, chain.DeployerKey.From, big.NewInt(100))
require.NoError(t, err)
_, err = chain.Confirm(tx)
require.NoError(t, err)

v, err = GenerateLinkTokenView(lt)
require.NoError(t, err)

assert.Equal(t, "100", v.Supply.String())
require.Len(t, v.Minters, 1)
require.Equal(t, v.Minters[0].String(), chain.DeployerKey.From.String())
require.Len(t, v.Burners, 1)
require.Equal(t, v.Burners[0].String(), chain.DeployerKey.From.String())
}
43 changes: 43 additions & 0 deletions pkg/contract/link/view/v1_0/static_link_token.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package v1_0

import (
"fmt"
"math/big"

linkcontracts "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/contracts/link"
"github.com/smartcontractkit/chainlink-evm/gethwrappers/generated/link_token_interface"

cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment"

"github.com/smartcontractkit/cld-changesets/pkg/common"
)

type StaticLinkTokenView struct {
common.ContractMetaData
Decimals uint8 `json:"decimals"`
Supply *big.Int `json:"supply"`
}

func GenerateStaticLinkTokenView(lt *link_token_interface.LinkToken) (StaticLinkTokenView, error) {
decimals, err := lt.Decimals(nil)
if err != nil {
return StaticLinkTokenView{}, fmt.Errorf("failed to get decimals %s: %w", lt.Address(), err)
}
totalSupply, err := lt.TotalSupply(nil)
if err != nil {
return StaticLinkTokenView{}, fmt.Errorf("failed to get total supply %s: %w", lt.Address(), err)
}

return StaticLinkTokenView{
ContractMetaData: common.ContractMetaData{
TypeAndVersion: cldf.TypeAndVersion{
Type: linkcontracts.StaticLinkToken,
Version: common.Version1_0_0,
}.String(),
Address: lt.Address(),
// No owner.
},
Decimals: decimals,
Supply: totalSupply,
}, nil
}
39 changes: 39 additions & 0 deletions pkg/contract/link/view/v1_0/static_link_token_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package v1_0

import (
"testing"

"github.com/ethereum/go-ethereum/common"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

chain_selectors "github.com/smartcontractkit/chain-selectors"

"github.com/smartcontractkit/chainlink-deployments-framework/engine/test/environment"

"github.com/smartcontractkit/chainlink-evm/gethwrappers/generated/link_token_interface"
)

func TestStaticLinkTokenView(t *testing.T) {
t.Parallel()

selector := chain_selectors.TEST_90000001.Selector
env, err := environment.New(t.Context(),
environment.WithEVMSimulated(t, []uint64{selector}),
)
require.NoError(t, err)

chain := env.BlockChains.EVMChains()[selector]
_, tx, lt, err := link_token_interface.DeployLinkToken(chain.DeployerKey, chain.Client)
require.NoError(t, err)
_, err = chain.Confirm(tx)
require.NoError(t, err)
v, err := GenerateStaticLinkTokenView(lt)
require.NoError(t, err)

assert.Equal(t, v.Owner, common.HexToAddress("0x0")) // Ownerless
assert.Equal(t, "StaticLinkToken 1.0.0", v.TypeAndVersion)
assert.Equal(t, uint8(18), v.Decimals)
assert.Equal(t, "1000000000000000000000000000", v.Supply.String())
}
Loading
Loading