Skip to content

Commit

Permalink
Merge branch 'main' into ng/cache-decimals
Browse files Browse the repository at this point in the history
  • Loading branch information
dimkouv authored Jan 8, 2025
2 parents 1945c92 + 17b5e61 commit ffb1a5e
Show file tree
Hide file tree
Showing 89 changed files with 5,940 additions and 2,889 deletions.
4 changes: 1 addition & 3 deletions .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ packages:
interfaces:
Controller:
Stream:
github.com/smartcontractkit/chainlink-ccip/execute/internal/gas:
interfaces:
EstimateProvider:
github.com/smartcontractkit/chainlink-ccip/pkg/reader:
interfaces:
CCIPReader:
Expand All @@ -36,6 +33,7 @@ packages:
github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3:
interfaces:
ExecutePluginCodec:
EstimateProvider:
github.com/smartcontractkit/chainlink-common/pkg/types:
interfaces:
ContractWriter:
Expand Down
23 changes: 21 additions & 2 deletions chains/solana/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export ANCHOR_IMAGE ?= backpackapp/build:$(ANCHOR_VERSION)
anchor_version:
@echo "${ANCHOR_VERSION}"

.PHONY: clippy
clippy:
cargo clippy --manifest-path ./contracts/programs/ccip-router/Cargo.toml

.PHONY: gomods
gomods: ## Install gomods
go install github.com/jmank88/[email protected]
Expand All @@ -16,10 +20,22 @@ gomods: ## Install gomods
gomodtidy: gomods
gomods tidy

.PHONY: format-contracts
format-contracts:
cd ./contracts && cargo fmt && go fmt ./...

.PHONY: rust-tests
rust-tests:
cd ./contracts && cargo test

.PHONY: lint-go
lint-go:
golangci-lint --max-issues-per-linter 0 --max-same-issues 0 --color=always --exclude=dot-imports --timeout 15m --out-format checkstyle:golangci-lint-report.xml run

.PHONY: lint-go-fix
lint-go-fix:
golangci-lint --max-issues-per-linter 0 --max-same-issues 0 --color=always --exclude=dot-imports --timeout 15m run --verbose --fix

.PHONY: anchor-go-gen
anchor-go-gen:
cd ./contracts && rm -rf ./target && anchor build && cd .. && ./scripts/anchor-go-gen.sh
Expand All @@ -32,6 +48,9 @@ format:
go-tests:
go test -v ./... -json -covermode=atomic -coverpkg=./... -coverprofile=integration_coverage.txt 2>&1 | tee /tmp/gotest.log | gotestloghelper -ci=true -singlepackage=true -hidepassingtests=false -hidepassinglogs=false

.PHONY: generate-idl
generate-idl:
.PHONY: build-contracts
build-contracts:
cd ./contracts && anchor build

.PHONY: solana-checks
solana-checks: clippy anchor-go-gen format gomodtidy lint-go rust-tests go-tests build-contracts
2 changes: 1 addition & 1 deletion chains/solana/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ go install github.com/gagliardetto/[email protected]
anchor build

# go bindings need to be regenerated if contract changes were made
./scrips/anchor-go-gen.sh
./scripts/anchor-go-gen.sh

# test contracts
go test ./... -v -count=1 -failfast
Expand Down
69 changes: 47 additions & 22 deletions chains/solana/contracts/programs/ccip-router/src/context.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use anchor_lang::{prelude::*, Ids};
use anchor_lang::prelude::*;
use anchor_spl::associated_token::{get_associated_token_address_with_program_id, AssociatedToken};
use anchor_spl::token::spl_token::native_mint;
use anchor_spl::token_interface::{Mint, TokenAccount, TokenInterface};
Expand Down Expand Up @@ -138,6 +138,49 @@ pub struct GetFee<'info> {
pub billing_token_config: Account<'info, BillingTokenConfigWrapper>,
}

#[derive(Accounts)]
pub struct WithdrawBilledFunds<'info> {
#[account(
owner = token_program.key() @ CcipRouterError::InvalidInputs,
)]
pub fee_token_mint: InterfaceAccount<'info, Mint>,

#[account(
mut,
associated_token::mint = fee_token_mint,
associated_token::authority = fee_billing_signer,
associated_token::token_program = token_program,
)]
pub fee_token_accum: InterfaceAccount<'info, TokenAccount>,

#[account(
mut,
constraint = recipient.key() == get_associated_token_address_with_program_id(
&config.load()?.fee_aggregator.key(), &fee_token_mint.key(), &token_program.key()
) @ CcipRouterError::InvalidInputs,
)]
pub recipient: InterfaceAccount<'info, TokenAccount>,

pub token_program: Interface<'info, TokenInterface>,

/// CHECK: This is the signer for the billing CPIs, used here to close the receiver token account
#[account(
seeds = [FEE_BILLING_SIGNER_SEEDS],
bump
)]
pub fee_billing_signer: UncheckedAccount<'info>,

#[account(
seeds = [CONFIG_SEED],
bump,
constraint = valid_version(config.load()?.version, MAX_CONFIG_V) @ CcipRouterError::InvalidInputs, // validate state version
)]
pub config: AccountLoader<'info, Config>,

#[account(mut, address = config.load()?.owner @ CcipRouterError::Unauthorized)]
pub authority: Signer<'info>,
}

#[derive(Accounts)]
pub struct InitializeCCIPRouter<'info> {
#[account(
Expand Down Expand Up @@ -346,13 +389,7 @@ pub struct AddBillingTokenConfig<'info> {
)]
pub billing_token_config: Account<'info, BillingTokenConfigWrapper>,

/// CHECK: This is the token program OR the token-2022 program. Given that there are 2 options, this can't have the
/// type of a specific program (which would enforce its ID). Thus, it's an UncheckedAccount
/// with a constraint enforcing that it is one of the two allowed programs.
#[account(
constraint = TokenInterface::ids().contains(&token_program.key()) @ CcipRouterError::InvalidInputs,
)]
pub token_program: UncheckedAccount<'info>,
pub token_program: Interface<'info, TokenInterface>,

#[account(
owner = token_program.key() @ CcipRouterError::InvalidInputs,
Expand Down Expand Up @@ -425,13 +462,7 @@ pub struct RemoveBillingTokenConfig<'info> {
)]
pub billing_token_config: Account<'info, BillingTokenConfigWrapper>,

/// CHECK: This is the token program OR the token-2022 program. Given that there are 2 options, this can't have the
/// type of a specific program (which would enforce its ID). Thus, it's an UncheckedAccount
/// with a constraint enforcing that it is one of the two allowed programs.
#[account(
constraint = TokenInterface::ids().contains(&token_program.key()) @ CcipRouterError::InvalidInputs,
)]
pub token_program: UncheckedAccount<'info>,
pub token_program: Interface<'info, TokenInterface>,

#[account(
owner = token_program.key() @ CcipRouterError::InvalidInputs,
Expand Down Expand Up @@ -497,13 +528,7 @@ pub struct CcipSend<'info> {
// billing token //
///////////////////
// TODO improve all usages of CcipRouterError::InvalidInputs to be more specific
/// CHECK: This is the token program OR the token-2022 program. Given that there are 2 options, this can't have the
/// type of a specific program (which would enforce its ID). Thus, it's an UncheckedAccount
/// with a constraint enforcing that it is one of the two allowed programs.
#[account(
constraint = TokenInterface::ids().contains(&fee_token_program.key()) @ CcipRouterError::InvalidInputs,
)]
pub fee_token_program: UncheckedAccount<'info>,
pub fee_token_program: Interface<'info, TokenInterface>,

#[account(
owner = fee_token_program.key() @ CcipRouterError::InvalidInputs,
Expand Down
203 changes: 0 additions & 203 deletions chains/solana/contracts/programs/ccip-router/src/fee_quoter.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod v1;
Loading

0 comments on commit ffb1a5e

Please sign in to comment.