Skip to content

Commit

Permalink
Fix always opening of stake account on mainnet
Browse files Browse the repository at this point in the history
  • Loading branch information
jeisses committed Dec 14, 2023
1 parent d3a84c1 commit 047d08d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
17 changes: 9 additions & 8 deletions src/nosana_node/nosana.clj
Original file line number Diff line number Diff line change
Expand Up @@ -806,14 +806,15 @@
(log :debug e)
(throw (ex-info "Could not create NOS ATA" {}))
nil)))
(when (not (sol/get-account-data (sol/get-nos-stake-pda (:address conf)) (:network conf)))
;; create stake with 0 NOS and 364 days duration
(try
(println "> Opening a NOS Stake account")
(open-stake conf 0 (* 24 60 60 364))
(catch Exception e
(throw (ex-info "Could not create stake" {}))
nil)))
(let [stake-pda (sol/get-nos-stake-pda (:address conf) (-> conf :programs :nos-token))]
(when (not (sol/get-account-data stake-pda (:network conf)))
;; create stake with 0 NOS and 364 days duration
(try
(println "> Opening a NOS Stake account")
(open-stake conf 0 (* 24 60 60 364))
(catch Exception e
(throw (ex-info "Could not create stake" {}))
nil))))
sys)

(defn use-fund-sol-wallet [{:nos/keys [conf vault] :as sys}]
Expand Down
4 changes: 2 additions & 2 deletions src/nosana_node/solana.clj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
:devnet "https://api.devnet.solana.com"
:mainnet "https://rpc.hellomoon.io/853e30f5-383d-4cc6-a5ee-b5fb4c7a7178"})

(def addresses
(def addresses
{:token (PublicKey. "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA")
:associated-token (PublicKey. "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL")
:system (PublicKey. "11111111111111111111111111111111")
Expand Down Expand Up @@ -267,7 +267,7 @@

(defn get-nos-stake-pda
"Find the PDA of a stake for an account."
[addr]
[addr nos-addr]
(.getAddress
(PublicKey/findProgramAddress [(.getBytes "stake")
(.toByteArray nos-addr)
Expand Down

0 comments on commit 047d08d

Please sign in to comment.