@kyve/sdk
Version:
<p align="center"> <a href="https://kyve.network"> <img src="https://user-images.githubusercontent.com/62398724/137493477-63868209-a19b-4efa-9413-f06d41197d6d.png" style="border-radius: 50%" height="96"> </a> <h3 align="center"><code>@kyve/sdk</
77 lines (74 loc) • 2.33 kB
text/typescript
import { AccountData, OfflineAminoSigner } from "@cosmjs/amino/build/signer";
import { SigningStargateClient } from "@cosmjs/stargate";
import { makeADR36AminoSignDoc } from "@keplr-wallet/cosmos";
import { StdSignature } from "@cosmjs/amino";
import KyveBaseMethods from "./kyve/base/v1beta1/base";
import KyveBundlesMethods from "./kyve/bundles/v1beta1/bundles";
import KyveDelegationMethods from "./kyve/delegation/v1beta1/delegation";
import KyveGovMethods from "./kyve/gov/v1beta1/gov";
import KyvePoolMethods from "./kyve/pool/v1beta1/pool";
import KyveStakersMethods from "./kyve/stakers/v1beta1/stakers";
export default class KyveClient {
public nativeClient: SigningStargateClient;
public readonly account: AccountData;
public kyve: {
base: {
v1beta1: KyveBaseMethods;
};
gov: {
v1beta1: KyveGovMethods;
};
bundles: {
v1beta1: KyveBundlesMethods;
};
delegation: {
v1beta1: KyveDelegationMethods;
};
pool: {
v1beta1: KyvePoolMethods;
};
stakers: {
v1beta1: KyveStakersMethods;
};
};
private aminoSigner: OfflineAminoSigner | null;
constructor(
client: SigningStargateClient,
account: AccountData,
aminoSigner: OfflineAminoSigner | null
) {
this.account = account;
this.nativeClient = client;
this.aminoSigner = aminoSigner;
this.kyve = {
base: {
v1beta1: new KyveBaseMethods(this.nativeClient, this.account),
},
bundles: {
v1beta1: new KyveBundlesMethods(this.nativeClient, this.account),
},
delegation: {
v1beta1: new KyveDelegationMethods(this.nativeClient, this.account),
},
gov: {
v1beta1: new KyveGovMethods(this.nativeClient, this.account),
},
pool: {
v1beta1: new KyvePoolMethods(this.nativeClient, this.account),
},
stakers: {
v1beta1: new KyveStakersMethods(this.nativeClient, this.account),
},
};
}
async signString(message: string): Promise<StdSignature> {
if (this.aminoSigner === null)
throw new Error("Wallet doesn't support adr-036");
const signDoc = makeADR36AminoSignDoc(this.account.address, message);
const { signature } = await this.aminoSigner.signAmino(
this.account.address,
signDoc
);
return signature;
}
}