Skip to content

Commit a85184d

Browse files
committed
sdk: add missing admin functionality and queries
1 parent 5d109a9 commit a85184d

File tree

4 files changed

+570
-50
lines changed

4 files changed

+570
-50
lines changed

sdk/definitions/src/ntt.ts

+75-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export namespace Ntt {
3838
token: string;
3939
manager: string;
4040
transceiver: {
41-
wormhole: string;
41+
wormhole?: string;
4242
};
4343
quoter?: string;
4444
};
@@ -85,6 +85,12 @@ export namespace Ntt {
8585
payload: Uint8Array;
8686
};
8787

88+
export type Peer<C extends Chain> = {
89+
address: ChainAddress<C>;
90+
tokenDecimals: number;
91+
inboundLimit: bigint;
92+
};
93+
8894
// TODO: should layoutify this but couldnt immediately figure out how to
8995
// specify the length of the array as an encoded value
9096
export function encodeTransceiverInstructions(ixs: TransceiverInstruction[]) {
@@ -126,12 +132,31 @@ export namespace Ntt {
126132
* @typeparam C the chain
127133
*/
128134
export interface Ntt<N extends Network, C extends Chain> {
135+
getMode(): Promise<Ntt.Mode>;
136+
137+
isPaused(): Promise<boolean>;
138+
139+
pause(
140+
payer?: AccountAddress<C>
141+
): AsyncGenerator<UnsignedTransaction<N, C>>;
142+
143+
unpause(
144+
payer?: AccountAddress<C>
145+
): AsyncGenerator<UnsignedTransaction<N, C>>;
146+
147+
getOwner(): Promise<AccountAddress<C>>;
148+
149+
setOwner(newOwner: AccountAddress<C>, payer?: AccountAddress<C>): AsyncGenerator<UnsignedTransaction<N, C>>;
150+
151+
getThreshold(): Promise<number>;
152+
129153
setPeer(
130154
peer: ChainAddress,
131155
tokenDecimals: number,
132156
inboundLimit: bigint,
133157
payer?: AccountAddress<C>
134158
): AsyncGenerator<UnsignedTransaction<N, C>>;
159+
135160
setWormholeTransceiverPeer(
136161
peer: ChainAddress,
137162
payer?: AccountAddress<C>
@@ -182,16 +207,44 @@ export interface Ntt<N extends Network, C extends Chain> {
182207
/** Get the number of decimals associated with the token under management */
183208
getTokenDecimals(): Promise<number>;
184209

210+
/** Get the peer information for the given chain if it exists */
211+
getPeer<C extends Chain>(chain: C): Promise<Ntt.Peer<C> | null>;
212+
213+
getTransceiver(ix: number): Promise<NttTransceiver<N, C, Ntt.Attestation> | null>;
214+
185215
/**
186216
* getCurrentOutboundCapacity returns the current outbound capacity of the Ntt manager
187217
*/
188218
getCurrentOutboundCapacity(): Promise<bigint>;
219+
220+
/**
221+
* getOutboundLimit returns the maximum outbound capacity of the Ntt manager
222+
*/
223+
getOutboundLimit(): Promise<bigint>;
224+
225+
/**
226+
* setOutboundLimit sets the maximum outbound capacity of the Ntt manager
227+
*/
228+
setOutboundLimit(limit: bigint, payer?: AccountAddress<C>): AsyncGenerator<UnsignedTransaction<N, C>>;
229+
189230
/**
190231
* getCurrentInboundCapacity returns the current inbound capacity of the Ntt manager
191232
* @param fromChain the chain to check the inbound capacity for
192233
*/
193234
getCurrentInboundCapacity(fromChain: Chain): Promise<bigint>;
194235

236+
/**
237+
* getInboundLimit returns the maximum inbound capacity of the Ntt manager
238+
* @param fromChain the chain to check the inbound limit for
239+
*/
240+
getInboundLimit(fromChain: Chain): Promise<bigint>;
241+
242+
setInboundLimit(
243+
fromChain: Chain,
244+
limit: bigint,
245+
payer?: AccountAddress<C>
246+
): AsyncGenerator<UnsignedTransaction<N, C>>;
247+
195248
/**
196249
* getIsApproved returns whether an attestation is approved
197250
* an attestation is approved when it has been validated but has not necessarily
@@ -231,17 +284,37 @@ export interface Ntt<N extends Network, C extends Chain> {
231284
token: TokenAddress<C>,
232285
payer?: AccountAddress<C>
233286
): AsyncGenerator<UnsignedTransaction<N, C>>;
287+
288+
/**
289+
* Given a manager address, the rest of the addresses (token address and
290+
* transceiver addresses) can be queried from the manager contract directly.
291+
* This method verifies that the addresses that were used to construct the Ntt
292+
* instance match the addresses that are stored in the manager contract.
293+
*
294+
* TODO: perhaps a better way to do this would be by allowing async protocol
295+
* initializers so this can be done when constructing the Ntt instance.
296+
* That would be a larger change (in the connect sdk) so we do this for now.
297+
*
298+
* @returns the addresses that don't match the expected addresses, or null if
299+
* they all match
300+
*/
301+
verifyAddresses(): Promise<Partial<Ntt.Contracts> | null>;
234302
}
235303

236304
export interface NttTransceiver<
237305
N extends Network,
238306
C extends Chain,
239307
A extends Ntt.Attestation
240308
> {
309+
310+
getAddress(): ChainAddress<C>;
311+
241312
/** setPeer sets a peer address for a given chain
242313
* Note: Admin only
243314
*/
244-
setPeer(peer: ChainAddress<Chain>): AsyncGenerator<UnsignedTransaction<N, C>>;
315+
setPeer(peer: ChainAddress<Chain>, payer?: AccountAddress<C>): AsyncGenerator<UnsignedTransaction<N, C>>;
316+
317+
getPeer<C extends Chain>(chain: C): Promise<ChainAddress<C> | null>;
245318

246319
/**
247320
* receive calls the `receive*` method on the transceiver

0 commit comments

Comments
 (0)