diff --git a/src/nosana_node/nosana.clj b/src/nosana_node/nosana.clj index 25e0dbe..ed421da 100644 --- a/src/nosana_node/nosana.clj +++ b/src/nosana_node/nosana.clj @@ -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}] diff --git a/src/nosana_node/solana.clj b/src/nosana_node/solana.clj index 8ddd36d..89490a4 100644 --- a/src/nosana_node/solana.clj +++ b/src/nosana_node/solana.clj @@ -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") @@ -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)