Skip to content

Commit a39a2bd

Browse files
Fix stack error
1 parent b139602 commit a39a2bd

4 files changed

Lines changed: 35 additions & 11 deletions

File tree

Anchor.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[programs.localnet]
2-
anchor_escrow = "D3B39yETxmG29V3QPPNsdEzxQyonU5tjiwEr3svnMoRt"
2+
anchor_escrow = "AHnWUmyXfyRqtN3AwoRxMoyVKskyF9cS59YE2ZbqB8x6"
33

44
[registry]
55
url = "https://anchor.projectserum.com"
@@ -13,4 +13,4 @@ test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"
1313

1414
[toolchain]
1515
anchor_version = "0.29.0" # `anchor-cli` version to use
16-
solana_version = "1.17.0" # Solana version to use
16+
solana_version = "1.18.1" # Solana version to use

programs/anchor-escrow/src/contexts/exchange.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,28 @@ pub struct Exchange<'info> {
1414
pub taker: Signer<'info>,
1515
#[account(mut)]
1616
pub initializer: SystemAccount<'info>,
17-
pub mint_a: Account<'info, Mint>,
18-
pub mint_b: Account<'info, Mint>,
17+
pub mint_a: Box<Account<'info, Mint>>,
18+
pub mint_b: Box<Account<'info, Mint>>,
1919
#[account(
2020
init_if_needed,
2121
payer = taker,
2222
associated_token::mint = mint_a,
2323
associated_token::authority = taker
2424
)]
25-
pub taker_ata_a: Account<'info, TokenAccount>,
25+
pub taker_ata_a: Box<Account<'info, TokenAccount>>,
2626
#[account(
2727
mut,
2828
associated_token::mint = mint_b,
2929
associated_token::authority = taker
3030
)]
31-
pub taker_ata_b: Account<'info, TokenAccount>,
31+
pub taker_ata_b: Box<Account<'info, TokenAccount>>,
3232
#[account(
3333
init_if_needed,
3434
payer = taker,
3535
associated_token::mint = mint_b,
3636
associated_token::authority = initializer
3737
)]
38-
pub initializer_ata_b: Account<'info, TokenAccount>,
38+
pub initializer_ata_b: Box<Account<'info, TokenAccount>>,
3939
#[account(
4040
mut,
4141
has_one = mint_b,
@@ -44,13 +44,13 @@ pub struct Exchange<'info> {
4444
seeds=[b"state", escrow.seed.to_le_bytes().as_ref()],
4545
bump = escrow.bump,
4646
)]
47-
pub escrow: Account<'info, Escrow>,
47+
pub escrow: Box<Account<'info, Escrow>>,
4848
#[account(
4949
mut,
5050
associated_token::mint = mint_a,
5151
associated_token::authority = escrow
5252
)]
53-
pub vault: Account<'info, TokenAccount>,
53+
pub vault: Box<Account<'info, TokenAccount>>,
5454
pub associated_token_program: Program<'info, AssociatedToken>,
5555
pub token_program: Program<'info, Token>,
5656
pub system_program: Program<'info, System>,

programs/anchor-escrow/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ mod contexts;
33
use contexts::*;
44
mod states;
55

6-
declare_id!("D3B39yETxmG29V3QPPNsdEzxQyonU5tjiwEr3svnMoRt");
6+
declare_id!("AHnWUmyXfyRqtN3AwoRxMoyVKskyF9cS59YE2ZbqB8x6");
77

88
#[program]
99
pub mod anchor_escrow {

tests/anchor-escrow.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as anchor from "@coral-xyz/anchor";
22
import { AnchorEscrow } from "../target/types/anchor_escrow";
3-
import { Keypair, LAMPORTS_PER_SOL, PublicKey, SystemProgram, Transaction } from "@solana/web3.js";
3+
import { Keypair, LAMPORTS_PER_SOL, PublicKey, SystemProgram, Transaction, TransactionMessage, VersionedTransaction } from "@solana/web3.js";
44
import {
55
ASSOCIATED_TOKEN_PROGRAM_ID,
66
MINT_SIZE,
@@ -132,5 +132,29 @@ describe("anchor-escrow", () => {
132132
.rpc()
133133
.then(confirm)
134134
.then(log);
135+
136+
// For Degugging Purpose
137+
138+
// const latestBlockhash = await anchor
139+
// .getProvider()
140+
// .connection.getLatestBlockhash();
141+
142+
// const ix = await program.methods
143+
// .exchange()
144+
// .accounts({ ...accounts })
145+
// .signers([taker])
146+
// .instruction()
147+
148+
// const msg = new TransactionMessage({
149+
// payerKey: provider.publicKey,
150+
// recentBlockhash: latestBlockhash.blockhash,
151+
// instructions: [ix],
152+
// }).compileToV0Message();
153+
154+
// const tx = new VersionedTransaction(msg);
155+
// tx.sign([taker]);
156+
157+
// console.log(Buffer.from(tx.serialize()).toString("base64"));
158+
// await provider.sendAndConfirm(tx).then(log);
135159
});
136160
});

0 commit comments

Comments
 (0)