NN
Size: a a a
NN
N
NN
NN
N
UT
SK
SK
V
export class ParsedAccountInfo<T> {
constructor(public address: PublicKey, private _state: T) {}
static async load<T>
(connection: Connection, address: PublicKey, layout: Layout) : Promise< ParsedAccountInfo<T> | null> {
const accInfo = await connection.getAccountInfo(address);
if (accInfo?.data) {
return new this<T>(address, layout.decode(accInfo.data) as T);
}
return null;
}
get state() : T {
return this._state;
}
}
class ProtocolState extends ParsedAccountInfo<ProtocolStateType> {
public getProtocolAssets(): PublicKey[] {
return this.state.assets.filter(publicKey => !publicKey.equals(zeroPubKey));
}
}Property 'getProtocolAssets' is missing in type 'ParsedAccountInfo<ProtocolStateType>' but required in type 'ProtocolState'.
A
A
B
A
A
A
N
V
export class ParsedAccountInfo<T> {
constructor(public address: PublicKey, private _state: T) {}
static async load<T>
(connection: Connection, address: PublicKey, layout: Layout) : Promise< ParsedAccountInfo<T> | null> {
const accInfo = await connection.getAccountInfo(address);
if (accInfo?.data) {
return new this<T>(address, layout.decode(accInfo.data) as T);
}
return null;
}
get state() : T {
return this._state;
}
}
class ProtocolState extends ParsedAccountInfo<ProtocolStateType> {
public getProtocolAssets(): PublicKey[] {
return this.state.assets.filter(publicKey => !publicKey.equals(zeroPubKey));
}
}Property 'getProtocolAssets' is missing in type 'ParsedAccountInfo<ProtocolStateType>' but required in type 'ProtocolState'.
type Class<T> = new (...args: any[]) => T;
export class ParsedAccountInfo<T> {
constructor(public address: PublicKey, private _state: T) {}
static async load<T, R extends ParsedAccountInfo<T>>
(connection: Connection, address: PublicKey, layout: Layout, account: Class<R>) : Promise< R | null> {
const accInfo = await connection.getAccountInfo(address);
if (accInfo?.data) {
return new account(address, layout.decode(accInfo.data) as T);
}
return null;
}
get state() : T {
return this._state;
}
}
ProtocolStateA
RG
MK