Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement extra args codec #16016

Open
wants to merge 20 commits into
base: solana-offchain-plugin
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion core/capabilities/ccip/ccipsolana/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

func DecodeExtraArgsToMap(extraArgs []byte) (map[string]any, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good rule of thumb to add a docstring to exported methods

outputMap := make(map[string]any)
var args ccip_router.SVMExtraArgs
var args ccip_router.AnyExtraArgs
decoder := agbinary.NewBorshDecoder(extraArgs)
err := args.UnmarshalWithDecoder(decoder)
if err != nil {
Expand Down
19 changes: 9 additions & 10 deletions core/capabilities/ccip/ccipsolana/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,22 @@
"testing"

agbinary "github.com/gagliardetto/binary"
"github.com/gagliardetto/solana-go"
"github.com/stretchr/testify/require"

"github.com/smartcontractkit/chainlink-ccip/chains/solana/contracts/tests/config"
"github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings/ccip_router"
)

func Test_decodeExtraArgs(t *testing.T) {
t.Run("decode extra args into map svm", func(t *testing.T) {
extraArgs := ccip_router.SVMExtraArgs{
ComputeUnits: 1000,
IsWritableBitmap: 2,
Accounts: []solana.PublicKey{
config.ReceiverExternalExecutionConfigPDA,
config.ReceiverTargetAccountPDA,
solana.SystemProgramID,
},
extraArgs := ccip_router.AnyExtraArgs{
// TODO wait for onchain team fix this AnyExtraArgs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the source chain here is SVM, we won't need these SVM specific fields here, since you will not go from SVM -> SVM.
Atleast not until CCIP supports another SVM chain apart from Solana.

For testing right now, we should be good with just EVM specific fields in this struct.

//ComputeUnits: 1000,
//IsWritableBitmap: 2,
//Accounts: []solana.PublicKey{
// config.ReceiverExternalExecutionConfigPDA,
// config.ReceiverTargetAccountPDA,
// solana.SystemProgramID,
//},

Check failure on line 23 in core/capabilities/ccip/ccipsolana/helpers_test.go

View workflow job for this annotation

GitHub Actions / GolangCI Lint (.)

commentFormatting: put a space between `//` and comment text (gocritic)
}

var buf bytes.Buffer
Expand Down
Loading