-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Pablo Maldonado <[email protected]>
- Loading branch information
Showing
1 changed file
with
17 additions
and
13 deletions.
There are no files selected for viewing
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,35 @@ | ||
import { Idl, Program, Provider } from "@coral-xyz/anchor"; | ||
import { | ||
SvmSpokeIdl, | ||
SvmSpokeAnchor, | ||
MessageTransmitterAnchor, | ||
MessageTransmitterIdl, | ||
TokenMessengerMinterAnchor, | ||
TokenMessengerMinterIdl, | ||
MulticallHandlerAnchor, | ||
MulticallHandlerIdl, | ||
SvmSpokeAnchor, | ||
SvmSpokeIdl, | ||
TokenMessengerMinterAnchor, | ||
TokenMessengerMinterIdl, | ||
} from "./assets"; | ||
|
||
export function getConnectedProgram<P extends Idl>(idl: P, provider: Provider) { | ||
export function getConnectedProgram<P extends Idl>(idl: P, provider: Provider, programId?: string) { | ||
if (programId) { | ||
// An IDL must have been previously initialized | ||
return Program.at<P>(programId, provider); | ||
} | ||
return new Program<P>(idl, provider); | ||
} | ||
|
||
export function getSpokePoolProgram(provider: Provider) { | ||
return getConnectedProgram<SvmSpokeAnchor>(SvmSpokeIdl, provider); | ||
export function getSpokePoolProgram(provider: Provider, programId?: string) { | ||
return getConnectedProgram<SvmSpokeAnchor>(SvmSpokeIdl, provider, programId); | ||
} | ||
|
||
export function getMessageTransmitterProgram(provider: Provider) { | ||
return getConnectedProgram<MessageTransmitterAnchor>(MessageTransmitterIdl, provider); | ||
export function getMessageTransmitterProgram(provider: Provider, programId?: string) { | ||
return getConnectedProgram<MessageTransmitterAnchor>(MessageTransmitterIdl, provider, programId); | ||
} | ||
|
||
export function getTokenMessengerMinterProgram(provider: Provider) { | ||
return getConnectedProgram<TokenMessengerMinterAnchor>(TokenMessengerMinterIdl, provider); | ||
export function getTokenMessengerMinterProgram(provider: Provider, programId?: string) { | ||
return getConnectedProgram<TokenMessengerMinterAnchor>(TokenMessengerMinterIdl, provider, programId); | ||
} | ||
|
||
export function getMulticallHandlerProgram(provider: Provider) { | ||
return getConnectedProgram<MulticallHandlerAnchor>(MulticallHandlerIdl, provider); | ||
export function getMulticallHandlerProgram(provider: Provider, programId?: string) { | ||
return getConnectedProgram<MulticallHandlerAnchor>(MulticallHandlerIdl, provider, programId); | ||
} |