-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "feat: adds getReferralPartners and code arg"
This reverts commit 6ad8b61.
- Loading branch information
Showing
3 changed files
with
110 additions
and
312 deletions.
There are no files selected for viewing
31 changes: 11 additions & 20 deletions
31
src/marinade-referral-state/marinade-referral-partner-state.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
Oops, something went wrong.