Skip to content

add checking accounts asm example#539

Open
Perelyn-sama wants to merge 1 commit intomainfrom
asm/checking-account
Open

add checking accounts asm example#539
Perelyn-sama wants to merge 1 commit intomainfrom
asm/checking-account

Conversation

@Perelyn-sama
Copy link
Collaborator

No description provided.

@dev-jodee dev-jodee self-requested a review March 24, 2026 12:44
# It also serves as a reference for the commands used for building & deploying Solana programs.
# Run this bad boy with "bash cicd.sh" or "./cicd.sh"

cargo build-sbf --manifest-path=./program/Cargo.toml --sbf-out-dir=./program/target/so
Copy link
Collaborator

Choose a reason for hiding this comment

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

same issue as the other 2

"test": "pnpm ts-mocha -p ./tsconfig.json -t 1000000 ./tests/test.ts",
"build-and-test": "sbpf build --deploy-dir ./tests/fixtures && pnpm test",
"build": "sbpf build",
"deploy": "solana program deploy ./program/target/so/program.so"
Copy link
Collaborator

Choose a reason for hiding this comment

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

pathing issue here as well

# instruction data
.equ INSTRUCTION_DATA_LEN, 0xa188
.equ INSTRUCTION_DATA, 0xa190
.equ PROGRAM_ID, 0xa198
Copy link
Collaborator

Choose a reason for hiding this comment

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

unused

### Validations

# Check number of accounts.
ldxdw r2, [r1 + NUM_ACCOUNTS]
Copy link
Collaborator

Choose a reason for hiding this comment

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

it's not really a problem for this sample use case, but this won't handle duplicate accounts (like if I send account to change and account to create with the same pubkey), the serialization is compacted, so I think it would break the hardcoded offsets

jne r2, 0, error_initialized # jump if initialized

# Check account_to_change is already initialized
ldxdw r2, [r1 + ACCOUNT_TO_CHANGE_LAMPORTS] # load lamports of account to change
Copy link
Collaborator

Choose a reason for hiding this comment

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

in the native example of it, we check owner of account to change, would be best to do it here as well for parity

// If we want to modify an account's data, it must be owned by our program.
    if account_to_change.owner != program_id {
        msg!("Account to change does not have the correct program id.");
        return Err(ProgramError::IncorrectProgramId);
    };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants