Skip to content

Commit

Permalink
Providing evm specific implementation of tokenDataEncoder
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusz-sekara committed Sep 30, 2024
1 parent d435981 commit 2cf3610
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 26 deletions.
38 changes: 38 additions & 0 deletions core/capabilities/ccip/ccipevm/tokendata.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package ccipevm

import (
"context"

cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3"

"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/abihelpers"
)

type usdcAttestationPayload struct {
Message []byte
Attestation []byte
}

func (m usdcAttestationPayload) AbiString() string {
return `
[{
"components": [
{"name": "message", "type": "bytes"},
{"name": "attestation", "type": "bytes"}
],
"type": "tuple"
}]`
}

type EVMTokenDataEncoder struct{}

func NewEVMTokenDataEncoder() EVMTokenDataEncoder {
return EVMTokenDataEncoder{}
}

func (e EVMTokenDataEncoder) EncodeUSDC(_ context.Context, message cciptypes.Bytes, attestation cciptypes.Bytes) (cciptypes.Bytes, error) {
return abihelpers.EncodeAbiStruct[usdcAttestationPayload](usdcAttestationPayload{
Message: message,
Attestation: attestation,
})
}
4 changes: 2 additions & 2 deletions core/capabilities/ccip/oraclecreator/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3confighelper"

"github.com/smartcontractkit/chainlink-ccip/execute/tokendata"
"github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/ccipevm"
evmconfig "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/configs/evm"
"github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/ocrimpls"
Expand All @@ -33,6 +32,7 @@ import (
"github.com/smartcontractkit/chainlink-ccip/pluginconfig"

"github.com/smartcontractkit/chainlink-common/pkg/types"

"github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm"
"github.com/smartcontractkit/chainlink/v2/core/logger"
"github.com/smartcontractkit/chainlink/v2/core/services/job"
Expand Down Expand Up @@ -242,7 +242,7 @@ func (i *pluginOracleCreator) createFactoryAndTransmitter(
ccipevm.NewExecutePluginCodecV1(),
ccipevm.NewMessageHasherV1(),
i.homeChainReader,
&tokendata.NoopTokenDataObserver{},
ccipevm.NewEVMTokenDataEncoder(),
ccipevm.NewGasEstimateProvider(),
contractReaders,
chainWriters,
Expand Down
4 changes: 2 additions & 2 deletions core/scripts/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/prometheus/client_golang v1.20.0
github.com/shopspring/decimal v1.4.0
github.com/smartcontractkit/chainlink-automation v1.0.4
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240927162447-20630b333f57
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240930132738-84b94d022da3
github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000
github.com/smartcontractkit/libocr v0.0.0-20240717100443-f6226e09bee7
github.com/spf13/cobra v1.8.1
Expand Down Expand Up @@ -271,7 +271,7 @@ require (
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/shirou/gopsutil/v3 v3.24.3 // indirect
github.com/smartcontractkit/chain-selectors v1.0.23 // indirect
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930060710-158d2a9ac9ca // indirect
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930134847-55b6efa23dd0 // indirect
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7 // indirect
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240916152957-433914114bd2 // indirect
github.com/smartcontractkit/chainlink-feeds v0.0.0-20240910155501-42f20443189f // indirect
Expand Down
8 changes: 4 additions & 4 deletions core/scripts/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1081,10 +1081,10 @@ github.com/smartcontractkit/chain-selectors v1.0.23 h1:D2Eaex4Cw/O7Lg3tX6WklOqnj
github.com/smartcontractkit/chain-selectors v1.0.23/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE=
github.com/smartcontractkit/chainlink-automation v1.0.4 h1:iyW181JjKHLNMnDleI8umfIfVVlwC7+n5izbLSFgjw8=
github.com/smartcontractkit/chainlink-automation v1.0.4/go.mod h1:u4NbPZKJ5XiayfKHD/v3z3iflQWqvtdhj13jVZXj/cM=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930060710-158d2a9ac9ca h1:cvifSiZr9VifpKjgVtGaEqknz2MwpY4shQhoOLpgQUE=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930060710-158d2a9ac9ca/go.mod h1:hxKOwuo3HBC9a5hoNOvstl2wVF6Z9kZDssHU5VCdqk8=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240927162447-20630b333f57 h1:pRiTiFOkPEyvgG0hchcCSZzwUbwYydnZBu0QbVaRnVk=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240927162447-20630b333f57/go.mod h1:F6WUS6N4mP5ScwpwyTyAJc9/vjR+GXbMCRUOVekQi1g=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930134847-55b6efa23dd0 h1:gX08H/UOOZy04g3UjEqVdJpn4xstNjaLa3TrssMjg64=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930134847-55b6efa23dd0/go.mod h1:EjivXI/zFPSSo1uxt+C8JN2YnIB+gEf5SGzG+0pnx+c=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240930132738-84b94d022da3 h1:Vd7ViAQVgefcvyHGdpMhF3GX7oXafumoxW5cSaOLM3k=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240930132738-84b94d022da3/go.mod h1:F6WUS6N4mP5ScwpwyTyAJc9/vjR+GXbMCRUOVekQi1g=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7 h1:lTGIOQYLk1Ufn++X/AvZnt6VOcuhste5yp+C157No/Q=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7/go.mod h1:BMYE1vC/pGmdFSsOJdPrAA0/4gZ0Xo0SxTMdGspBtRo=
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240916152957-433914114bd2 h1:yRk4ektpx/UxwarqAfgxUXLrsYXlaNeP1NOwzHGrK2Q=
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ require (
github.com/shopspring/decimal v1.4.0
github.com/smartcontractkit/chain-selectors v1.0.23
github.com/smartcontractkit/chainlink-automation v1.0.4
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930060710-158d2a9ac9ca
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240927162447-20630b333f57
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930135917-1047cb4558ef
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240930132738-84b94d022da3
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240916152957-433914114bd2
github.com/smartcontractkit/chainlink-feeds v0.0.0-20240910155501-42f20443189f
Expand Down
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1042,10 +1042,12 @@ github.com/smartcontractkit/chain-selectors v1.0.23 h1:D2Eaex4Cw/O7Lg3tX6WklOqnj
github.com/smartcontractkit/chain-selectors v1.0.23/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE=
github.com/smartcontractkit/chainlink-automation v1.0.4 h1:iyW181JjKHLNMnDleI8umfIfVVlwC7+n5izbLSFgjw8=
github.com/smartcontractkit/chainlink-automation v1.0.4/go.mod h1:u4NbPZKJ5XiayfKHD/v3z3iflQWqvtdhj13jVZXj/cM=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930060710-158d2a9ac9ca h1:cvifSiZr9VifpKjgVtGaEqknz2MwpY4shQhoOLpgQUE=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930060710-158d2a9ac9ca/go.mod h1:hxKOwuo3HBC9a5hoNOvstl2wVF6Z9kZDssHU5VCdqk8=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240927162447-20630b333f57 h1:pRiTiFOkPEyvgG0hchcCSZzwUbwYydnZBu0QbVaRnVk=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240927162447-20630b333f57/go.mod h1:F6WUS6N4mP5ScwpwyTyAJc9/vjR+GXbMCRUOVekQi1g=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930134847-55b6efa23dd0 h1:gX08H/UOOZy04g3UjEqVdJpn4xstNjaLa3TrssMjg64=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930134847-55b6efa23dd0/go.mod h1:EjivXI/zFPSSo1uxt+C8JN2YnIB+gEf5SGzG+0pnx+c=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930135917-1047cb4558ef h1:BJCraQIMjFfbLuPSw5X0mzLkIMljfSBxN+g2u7W8mEE=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930135917-1047cb4558ef/go.mod h1:EjivXI/zFPSSo1uxt+C8JN2YnIB+gEf5SGzG+0pnx+c=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240930132738-84b94d022da3 h1:Vd7ViAQVgefcvyHGdpMhF3GX7oXafumoxW5cSaOLM3k=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240930132738-84b94d022da3/go.mod h1:F6WUS6N4mP5ScwpwyTyAJc9/vjR+GXbMCRUOVekQi1g=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7 h1:lTGIOQYLk1Ufn++X/AvZnt6VOcuhste5yp+C157No/Q=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7/go.mod h1:BMYE1vC/pGmdFSsOJdPrAA0/4gZ0Xo0SxTMdGspBtRo=
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240916152957-433914114bd2 h1:yRk4ektpx/UxwarqAfgxUXLrsYXlaNeP1NOwzHGrK2Q=
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ require (
github.com/smartcontractkit/ccip-owner-contracts v0.0.0-20240926212305-a6deabdfce86
github.com/smartcontractkit/chain-selectors v1.0.23
github.com/smartcontractkit/chainlink-automation v1.0.4
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930060710-158d2a9ac9ca
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240927162447-20630b333f57
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930134847-55b6efa23dd0
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240930132738-84b94d022da3
github.com/smartcontractkit/chainlink-testing-framework/havoc v1.50.0
github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.9
github.com/smartcontractkit/chainlink-testing-framework/lib/grafana v1.50.0
Expand Down
8 changes: 4 additions & 4 deletions integration-tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1423,10 +1423,10 @@ github.com/smartcontractkit/chain-selectors v1.0.23 h1:D2Eaex4Cw/O7Lg3tX6WklOqnj
github.com/smartcontractkit/chain-selectors v1.0.23/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE=
github.com/smartcontractkit/chainlink-automation v1.0.4 h1:iyW181JjKHLNMnDleI8umfIfVVlwC7+n5izbLSFgjw8=
github.com/smartcontractkit/chainlink-automation v1.0.4/go.mod h1:u4NbPZKJ5XiayfKHD/v3z3iflQWqvtdhj13jVZXj/cM=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930060710-158d2a9ac9ca h1:cvifSiZr9VifpKjgVtGaEqknz2MwpY4shQhoOLpgQUE=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930060710-158d2a9ac9ca/go.mod h1:hxKOwuo3HBC9a5hoNOvstl2wVF6Z9kZDssHU5VCdqk8=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240927162447-20630b333f57 h1:pRiTiFOkPEyvgG0hchcCSZzwUbwYydnZBu0QbVaRnVk=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240927162447-20630b333f57/go.mod h1:F6WUS6N4mP5ScwpwyTyAJc9/vjR+GXbMCRUOVekQi1g=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930134847-55b6efa23dd0 h1:gX08H/UOOZy04g3UjEqVdJpn4xstNjaLa3TrssMjg64=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930134847-55b6efa23dd0/go.mod h1:EjivXI/zFPSSo1uxt+C8JN2YnIB+gEf5SGzG+0pnx+c=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240930132738-84b94d022da3 h1:Vd7ViAQVgefcvyHGdpMhF3GX7oXafumoxW5cSaOLM3k=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240930132738-84b94d022da3/go.mod h1:F6WUS6N4mP5ScwpwyTyAJc9/vjR+GXbMCRUOVekQi1g=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7 h1:lTGIOQYLk1Ufn++X/AvZnt6VOcuhste5yp+C157No/Q=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7/go.mod h1:BMYE1vC/pGmdFSsOJdPrAA0/4gZ0Xo0SxTMdGspBtRo=
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240916152957-433914114bd2 h1:yRk4ektpx/UxwarqAfgxUXLrsYXlaNeP1NOwzHGrK2Q=
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/load/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/rs/zerolog v1.33.0
github.com/slack-go/slack v0.12.2
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240927162447-20630b333f57
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240930132738-84b94d022da3
github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.9
github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.1
github.com/smartcontractkit/chainlink-testing-framework/wasp v1.50.0
Expand All @@ -30,7 +30,7 @@ require (
require (
github.com/AlekSi/pointer v1.1.0 // indirect
github.com/smartcontractkit/chainlink-automation v1.0.4 // indirect
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930060710-158d2a9ac9ca // indirect
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930134847-55b6efa23dd0 // indirect
github.com/smartcontractkit/libocr v0.0.0-20240717100443-f6226e09bee7 // indirect
)

Expand Down
8 changes: 4 additions & 4 deletions integration-tests/load/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1397,10 +1397,10 @@ github.com/smartcontractkit/chain-selectors v1.0.23 h1:D2Eaex4Cw/O7Lg3tX6WklOqnj
github.com/smartcontractkit/chain-selectors v1.0.23/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE=
github.com/smartcontractkit/chainlink-automation v1.0.4 h1:iyW181JjKHLNMnDleI8umfIfVVlwC7+n5izbLSFgjw8=
github.com/smartcontractkit/chainlink-automation v1.0.4/go.mod h1:u4NbPZKJ5XiayfKHD/v3z3iflQWqvtdhj13jVZXj/cM=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930060710-158d2a9ac9ca h1:cvifSiZr9VifpKjgVtGaEqknz2MwpY4shQhoOLpgQUE=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930060710-158d2a9ac9ca/go.mod h1:hxKOwuo3HBC9a5hoNOvstl2wVF6Z9kZDssHU5VCdqk8=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240927162447-20630b333f57 h1:pRiTiFOkPEyvgG0hchcCSZzwUbwYydnZBu0QbVaRnVk=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240927162447-20630b333f57/go.mod h1:F6WUS6N4mP5ScwpwyTyAJc9/vjR+GXbMCRUOVekQi1g=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930134847-55b6efa23dd0 h1:gX08H/UOOZy04g3UjEqVdJpn4xstNjaLa3TrssMjg64=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240930134847-55b6efa23dd0/go.mod h1:EjivXI/zFPSSo1uxt+C8JN2YnIB+gEf5SGzG+0pnx+c=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240930132738-84b94d022da3 h1:Vd7ViAQVgefcvyHGdpMhF3GX7oXafumoxW5cSaOLM3k=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240930132738-84b94d022da3/go.mod h1:F6WUS6N4mP5ScwpwyTyAJc9/vjR+GXbMCRUOVekQi1g=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7 h1:lTGIOQYLk1Ufn++X/AvZnt6VOcuhste5yp+C157No/Q=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7/go.mod h1:BMYE1vC/pGmdFSsOJdPrAA0/4gZ0Xo0SxTMdGspBtRo=
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240916152957-433914114bd2 h1:yRk4ektpx/UxwarqAfgxUXLrsYXlaNeP1NOwzHGrK2Q=
Expand Down

0 comments on commit 2cf3610

Please sign in to comment.