Skip to content

Commit

Permalink
More files
Browse files Browse the repository at this point in the history
  • Loading branch information
guibescos committed Sep 21, 2023
1 parent 6b9f34c commit f32193c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
5 changes: 2 additions & 3 deletions staking/programs/staking/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use {
PositionData,
PositionState,
MAX_POSITIONS,
POSITIONS_ACCOUNT_SIZE,
},
target::TargetMetadata,
vesting::VestingEvent,
Expand Down Expand Up @@ -46,7 +45,7 @@ impl WasmPositionData {
#[wasm_bindgen(constructor)]
pub fn from_buffer(buffer: &[u8]) -> Result<WasmPositionData, JsValue> {
convert_error(WasmPositionData::from_buffer_impl(
&buffer[..POSITIONS_ACCOUNT_SIZE],
&buffer[..PositionData::LEN],
))
}
fn from_buffer_impl(buffer: &[u8]) -> Result<WasmPositionData, Error> {
Expand Down Expand Up @@ -308,7 +307,7 @@ impl Constants {
}
#[wasm_bindgen]
pub fn POSITIONS_ACCOUNT_SIZE() -> usize {
POSITIONS_ACCOUNT_SIZE
PositionData::LEN
}
#[wasm_bindgen]
pub fn MAX_VOTER_WEIGHT() -> u64 {
Expand Down
7 changes: 6 additions & 1 deletion staking/target/idl/staking.json
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@
200
]
},
100
10
]
}
}
Expand All @@ -940,6 +940,11 @@
},
{
"name": "StakeAccountMetadataV2",
"docs": [
"This is the metadata account for each staker",
"It is derived from the positions account with seeds \"stake_metadata\" and the positions account",
"pubkey It stores some PDA bumps, the owner of the account and the vesting schedule"
],
"type": {
"kind": "struct",
"fields": [
Expand Down
14 changes: 12 additions & 2 deletions staking/target/types/staking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ export type Staking = {
200
]
},
100
10
]
}
}
Expand All @@ -940,6 +940,11 @@ export type Staking = {
},
{
"name": "stakeAccountMetadataV2",
"docs": [
"This is the metadata account for each staker",
"It is derived from the positions account with seeds \"stake_metadata\" and the positions account",
"pubkey It stores some PDA bumps, the owner of the account and the vesting schedule"
],
"type": {
"kind": "struct",
"fields": [
Expand Down Expand Up @@ -2405,7 +2410,7 @@ export const IDL: Staking = {
200
]
},
100
10
]
}
}
Expand All @@ -2414,6 +2419,11 @@ export const IDL: Staking = {
},
{
"name": "stakeAccountMetadataV2",
"docs": [
"This is the metadata account for each staker",
"It is derived from the positions account with seeds \"stake_metadata\" and the positions account",
"pubkey It stores some PDA bumps, the owner of the account and the vesting schedule"
],
"type": {
"kind": "struct",
"fields": [
Expand Down
7 changes: 6 additions & 1 deletion staking/tests/max_pos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
makeDefaultConfig,
CustomAbortController,
} from "./utils/before";
import { Constants } from "pyth-staking-wasm";

// When DEBUG is turned on, we turn preflight transaction checking off
// That way failed transactions show up in the explorer, which makes them
Expand Down Expand Up @@ -109,7 +110,11 @@ describe("fills a stake account with positions", async () => {
let deltaCost = costs[1] - costs[0]; // adding more positions increases the cost

let transaction = new Transaction();
for (let numPositions = 0; numPositions < 100; numPositions++) {
for (
let numPositions = 0;
numPositions < Constants.MAX_POSITIONS();
numPositions++
) {
if (
budgetRemaining < ixCost ||
transaction.instructions.length == maxInstructions
Expand Down

0 comments on commit f32193c

Please sign in to comment.