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

fix: upgrade deprecated method #26

Merged
merged 6 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/lint-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ jobs:
solana --version


- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v4
with:
version: 8

Expand Down
3 changes: 2 additions & 1 deletion packages/lib/anchor-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"bn.js": "^5.2.1",
"@coral-xyz/anchor": "^0.29.0",
"@marinade.finance/ts-common": "workspace: 2.4.9",
"@marinade.finance/web3js-common": "workspace: 2.4.9"
"@marinade.finance/web3js-common": "workspace: 2.4.9",
"@anza-xyz/solana-rpc-get-stake-activation": "1.0.1"
},
"engines": {
"node": ">=16"
Expand Down
7 changes: 4 additions & 3 deletions packages/lib/anchor-common/src/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import fs from 'fs'
import { sleep } from '@marinade.finance/ts-common'
import { getStakeAccount } from '@marinade.finance/web3js-common'
import { waitForEpoch } from '@marinade.finance/web3js-common'
import { getStakeActivation } from '@anza-xyz/solana-rpc-get-stake-activation'

export async function getAnchorValidatorInfo(
connection: Connection,
Expand Down Expand Up @@ -87,10 +88,10 @@ export async function waitForStakeAccountActivation({
// 1. waiting for the stake account to be activated
{
const startTime = Date.now()
let stakeStatus = await connection.getStakeActivation(stakeAccount)
while (stakeStatus.state !== 'active') {
let stakeStatus = await getStakeActivation(connection, stakeAccount)
while (stakeStatus.status !== 'active') {
await sleep(1000)
stakeStatus = await connection.getStakeActivation(stakeAccount)
stakeStatus = await getStakeActivation(connection, stakeAccount)
if (Date.now() - startTime > timeoutSeconds * 1000) {
throw new Error(
`Stake account ${stakeAccount.toBase58()} was not activated in timeout of ${timeoutSeconds} seconds`
Expand Down
6 changes: 1 addition & 5 deletions packages/lib/web3js-common/src/stakeAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,7 @@ function isAccountInfoParsedData(
if (data === null) {
return false
}
return (
data.data &&
!(data.data instanceof Buffer) &&
data.data.parsed !== undefined
)
return data.data && !(data.data instanceof Buffer) && 'parsed' in data.data
}

export async function getStakeAccount(
Expand Down
15 changes: 11 additions & 4 deletions packages/marinade-ts-cli/__tests__/orderUnstakeAndClaim.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,13 @@ describe('Order unstake and claim using CLI', () => {
)
expect(tickets.size).toBe(1)
const startTime = Date.now()
let ticket: [PublicKey, TicketAccount] = tickets.entries().next().value
let ticket: [PublicKey, TicketAccount] | undefined = tickets
.entries()
.next().value

while (
!ticket[1].ticketDueDate ||
isNaN(ticket[1].ticketDueDate.getTime())
ticket &&
(!ticket[1].ticketDueDate || isNaN(ticket[1].ticketDueDate.getTime()))
) {
console.log(
'Waiting for ticket',
Expand All @@ -91,13 +94,17 @@ describe('Order unstake and claim using CLI', () => {
)
.entries()
.next().value
if (Date.now() - startTime > timeoutSeconds * 1000) {
if (ticket && Date.now() - startTime > timeoutSeconds * 1000) {
throw new Error(
`Ticket ${ticket[0]} was not available for claiming in timeout of ${timeoutSeconds} seconds`
)
}
}

if (!ticket) {
throw new Error('Ticket is undefined')
}

await (
expect([
'pnpm',
Expand Down
7 changes: 4 additions & 3 deletions packages/marinade-ts-cli/__tests__/setup/globalSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { AnchorProvider } from '@coral-xyz/anchor'
import NodeWallet from '@coral-xyz/anchor/dist/cjs/nodewallet'
import { Marinade, MarinadeConfig } from '@marinade.finance/marinade-ts-sdk'
import { getParsedStakeAccountInfo } from '@marinade.finance/marinade-ts-sdk/dist/src/util'
import { getStakeActivation } from '@anza-xyz/solana-rpc-get-stake-activation'
import {
Keypair,
PublicKey,
Expand Down Expand Up @@ -230,10 +231,10 @@ export async function waitForStakeAccountActivation({
// 1. waiting for the stake account to be activated
{
const startTime = Date.now()
let stakeStatus = await connection.getStakeActivation(stakeAccount)
while (stakeStatus.state !== 'active') {
let stakeStatus = await getStakeActivation(connection, stakeAccount)
while (stakeStatus.status !== 'active') {
await sleep(1000)
stakeStatus = await connection.getStakeActivation(stakeAccount)
stakeStatus = await getStakeActivation(connection, stakeAccount)
if (Date.now() - startTime > timeoutSeconds * 1000) {
throw new Error(
`Stake account ${stakeAccount.toBase58()} was not activated in timeout of ${timeoutSeconds} seconds`
Expand Down
3 changes: 2 additions & 1 deletion packages/marinade-ts-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"@marinade.finance/ledger-utils": "^3.0.1",
"@marinade.finance/cli-common": "workspace: 2.4.9",
"@marinade.finance/web3js-common": "workspace: 2.4.9",
"@marinade.finance/marinade-ts-sdk": "5.0.7"
"@marinade.finance/marinade-ts-sdk": "5.0.7",
"@anza-xyz/solana-rpc-get-stake-activation": "1.0.1"
},
"devDependencies": {
"@marinade.finance/jest-utils": "workspace: 2.4.9",
Expand Down
Loading
Loading