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

feat(oft-solana): throw specific error if trying to send more than owned #1220

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

nazreen
Copy link
Contributor

@nazreen nazreen commented Jan 31, 2025

Currently, if a dev tries to run the sendOFT.ts script with an amount greater than the balance of their deployer address, they will be faced with an error like so:

SendTransactionError: Simulation failed. 
Message: Transaction simulation failed: Error processing Instruction 2: custom program error: 0x1. 
Logs: 
[
  "Program ComputeBudget111111111111111111111111111111 success",
  "Program 13DZBdTFGrhYCcgKFx7ensYs1yBLgGwXdD7kzRA9tU2v invoke [1]",
  "Program log: Instruction: Send",
  "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]",
  "Program log: Instruction: Burn",
  "Program log: Error: insufficient funds",
  "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 4171 of 227697 compute units",
  "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA failed: custom program error: 0x1",
  "Program 13DZBdTFGrhYCcgKFx7ensYs1yBLgGwXdD7kzRA9tU2v consumed 29174 of 252700 compute units",
  "Program 13DZBdTFGrhYCcgKFx7ensYs1yBLgGwXdD7kzRA9tU2v failed: custom program error: 0x1"
]. 

This is too cryptic. They will often resort to asking us for clarification. We can do better.

This PR removes this from ever being a blocker for self-service, by checking the balance of the deployer address and comparing it with the amount passed into the task.

Testing

init a repo with the example from this branch:

LAYERZERO_EXAMPLES_REPOSITORY_REF=#nazreen/oft-solana/throw-if-sending-more LZ_ENABLE_SOLANA_OFT_EXAMPLE=1 npx create-lz-oapp@latest

go through the usual steps until you reach the send step for Solana to Sepolia
then, input an amount greater than what was minted

you would get an error message like so:

Error: Attempting to send 10000000023456788, but <ADDRESS> only has balance of 9900000000

St0rmBr3w
St0rmBr3w previously approved these changes Jan 31, 2025
@nazreen nazreen requested a review from ryandgoulding February 3, 2025 06:00
@ryandgoulding
Copy link
Contributor

See #1230 PR into this branch

Signed-off-by: Ryan Goulding <[email protected]>
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.

3 participants