@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</
50 lines (44 loc) • 1.36 kB
text/typescript
import { coins, SigningStargateClient } from "@cosmjs/stargate";
import { StdFee } from "@cosmjs/amino/build/signdoc";
import { AccountData } from "@cosmjs/amino/build/signer";
import { BigNumber } from "bignumber.js";
import { KYVE_DECIMALS } from "../../../../../constants";
import { DENOM } from "../../../../../constants";
import { signTx, TxPromise } from "../../../../../utils/helper";
import { withTypeUrl } from "../../../../../registry/tx.registry";
export default class KyveBaseMsg {
private nativeClient: SigningStargateClient;
public readonly account: AccountData;
constructor(client: SigningStargateClient, account: AccountData) {
this.account = account;
this.nativeClient = client;
}
async transfer(
recipient: string,
amount: string,
options?: {
fee?: StdFee | "auto" | number;
memo?: string;
}
) {
const tx = {
typeUrl: "/cosmos.bank.v1beta1.MsgSend",
value: {
fromAddress: this.account.address,
toAddress: recipient,
amount: coins(amount, DENOM),
},
};
return new TxPromise(
this.nativeClient,
await signTx(this.nativeClient, this.account.address, tx, options)
);
}
async getKyveBalance() {
const data = await this.nativeClient.getBalance(
this.account.address,
DENOM
);
return data.amount;
}
}