Skip to content

Commit

Permalink
Revert "feat: adds getReferralPartners and code arg"
Browse files Browse the repository at this point in the history
This reverts commit 6ad8b61.
  • Loading branch information
phola committed Oct 12, 2022
1 parent 6ad8b61 commit bb30392
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 312 deletions.
31 changes: 11 additions & 20 deletions src/marinade-referral-state/marinade-referral-partner-state.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
import { web3 } from "@project-serum/anchor"
import { Marinade } from "../marinade"
import { MarinadeReferralStateResponse } from "./marinade-referral-state.types"
import { web3 } from '@project-serum/anchor'
import { Marinade } from '../marinade'
import { MarinadeReferralStateResponse } from './marinade-referral-state.types'

export class MarinadeReferralPartnerState {
private constructor(
public readonly state: MarinadeReferralStateResponse.ReferralState,
public readonly referralStateAddress: web3.PublicKey,
public readonly marinadeReferralProgramId: web3.PublicKey
) {}
public readonly marinadeReferralProgramId: web3.PublicKey,
) { }

static async fetch(marinade: Marinade, referralCode?: web3.PublicKey) {
static async fetch(marinade: Marinade) {
const { marinadeReferralProgram, config } = marinade
const code = referralCode ?? config.referralCode
if (!code) {
throw new Error(
"The Referral Code must be provided in the MarinadeConfig or supplied as an arg!"
)

if (!config.referralCode) {
throw new Error('The Referral Code must be provided in the MarinadeConfig!')
}
const state =
(await marinadeReferralProgram.program.account.referralState.fetch(
code
)) as MarinadeReferralStateResponse.ReferralState
const state = await marinadeReferralProgram.program.account.referralState.fetch(config.referralCode) as MarinadeReferralStateResponse.ReferralState

return new MarinadeReferralPartnerState(
state,
code,
config.marinadeReferralProgramId
)
return new MarinadeReferralPartnerState(state, config.referralCode, config.marinadeReferralProgramId)
}
}
Loading

0 comments on commit bb30392

Please sign in to comment.