ggez-banking-sdk 0.5.6 → 0.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,20 @@
1
1
  import { BlockchainAPIConfig, ErrorHandler } from "../types";
2
+ import type { BalancesData, TotalSupplyData, DenomSupplyData, ValidatorsData, ValidatorData, DelegationResponseData, DelegationsResponseData, StakingParamsData, DelegationRewardsData, TotalRewardsData } from "../types";
2
3
  import { BaseBlockchainService } from "./service";
3
4
  declare class BlockchainAPI extends BaseBlockchainService {
4
5
  constructor(config: BlockchainAPIConfig, errorHandler: ErrorHandler);
6
+ getBalance(address: string): Promise<import("..").ApiResponse<BalancesData>>;
7
+ getSpendableBalances(address: string): Promise<import("..").ApiResponse<BalancesData>>;
8
+ getTotalSupply(): Promise<import("..").ApiResponse<TotalSupplyData>>;
9
+ getSupplyByDenom(denom: string): Promise<import("..").ApiResponse<DenomSupplyData>>;
10
+ getValidators(): Promise<import("..").ApiResponse<ValidatorsData>>;
11
+ getValidator(validatorAddr: string): Promise<import("..").ApiResponse<ValidatorData>>;
12
+ getDelegation(delegatorAddr: string, validatorAddr: string): Promise<import("..").ApiResponse<DelegationResponseData>>;
13
+ getDelegations(delegatorAddr: string): Promise<import("..").ApiResponse<DelegationsResponseData>>;
14
+ getDelegatorValidators(delegatorAddr: string): Promise<import("..").ApiResponse<ValidatorsData>>;
15
+ getStakingParams(): Promise<import("..").ApiResponse<StakingParamsData>>;
16
+ getDelegationRewards(delegatorAddr: string, validatorAddr: string): Promise<import("..").ApiResponse<DelegationRewardsData>>;
17
+ getTotalRewards(delegatorAddr: string): Promise<import("..").ApiResponse<TotalRewardsData>>;
18
+ getAccount(address: string): Promise<import("..").ApiResponse<any>>;
5
19
  }
6
20
  export { BlockchainAPI };
@@ -1,7 +1,61 @@
1
+ import { BcApiEndpoints } from "../constant/constant";
1
2
  import { BaseBlockchainService } from "./service";
3
+ import { ResponseHelper } from "../helper";
2
4
  class BlockchainAPI extends BaseBlockchainService {
3
5
  constructor(config, errorHandler) {
4
6
  super(config, errorHandler);
5
7
  }
8
+ async getBalance(address) {
9
+ const response = await this.axiosInstance.get(`${BcApiEndpoints.Balances}/${address}`);
10
+ return ResponseHelper.getApiResponse(response);
11
+ }
12
+ async getSpendableBalances(address) {
13
+ const response = await this.axiosInstance.get(`${BcApiEndpoints.SpendableBalances}/${address}`);
14
+ return ResponseHelper.getApiResponse(response);
15
+ }
16
+ async getTotalSupply() {
17
+ const response = await this.axiosInstance.get(BcApiEndpoints.TotalSupply);
18
+ return ResponseHelper.getApiResponse(response);
19
+ }
20
+ async getSupplyByDenom(denom) {
21
+ const response = await this.axiosInstance.get(BcApiEndpoints.SupplyByDenom, { params: { denom } });
22
+ return ResponseHelper.getApiResponse(response);
23
+ }
24
+ async getValidators() {
25
+ const response = await this.axiosInstance.get(BcApiEndpoints.Validators);
26
+ return ResponseHelper.getApiResponse(response);
27
+ }
28
+ async getValidator(validatorAddr) {
29
+ const response = await this.axiosInstance.get(`${BcApiEndpoints.Validators}/${validatorAddr}`);
30
+ return ResponseHelper.getApiResponse(response);
31
+ }
32
+ async getDelegation(delegatorAddr, validatorAddr) {
33
+ const response = await this.axiosInstance.get(`${BcApiEndpoints.Validators}/${validatorAddr}/delegations/${delegatorAddr}`);
34
+ return ResponseHelper.getApiResponse(response);
35
+ }
36
+ async getDelegations(delegatorAddr) {
37
+ const response = await this.axiosInstance.get(`${BcApiEndpoints.DelegatorDelegations}/${delegatorAddr}`);
38
+ return ResponseHelper.getApiResponse(response);
39
+ }
40
+ async getDelegatorValidators(delegatorAddr) {
41
+ const response = await this.axiosInstance.get(`${BcApiEndpoints.Delegators}/${delegatorAddr}/validators`);
42
+ return ResponseHelper.getApiResponse(response);
43
+ }
44
+ async getStakingParams() {
45
+ const response = await this.axiosInstance.get(BcApiEndpoints.StakingParams);
46
+ return ResponseHelper.getApiResponse(response);
47
+ }
48
+ async getDelegationRewards(delegatorAddr, validatorAddr) {
49
+ const response = await this.axiosInstance.get(`${BcApiEndpoints.DistributionDelegators}/${delegatorAddr}/rewards/${validatorAddr}`);
50
+ return ResponseHelper.getApiResponse(response);
51
+ }
52
+ async getTotalRewards(delegatorAddr) {
53
+ const response = await this.axiosInstance.get(`${BcApiEndpoints.DistributionDelegators}/${delegatorAddr}/rewards`);
54
+ return ResponseHelper.getApiResponse(response);
55
+ }
56
+ async getAccount(address) {
57
+ const response = await this.axiosInstance.get(`${BcApiEndpoints.Account}/${address}`);
58
+ return ResponseHelper.getApiResponse(response);
59
+ }
6
60
  }
7
61
  export { BlockchainAPI };
@@ -1,4 +1,5 @@
1
1
  export * from "./api";
2
+ export * from "./bc-api";
2
3
  export * from "./proxy";
3
4
  export * from "./context";
4
5
  export * from "./data";
package/dist/api/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./api";
2
+ export * from "./bc-api";
2
3
  export * from "./proxy";
3
4
  export * from "./context";
4
5
  export * from "./data";
@@ -15,6 +15,18 @@ declare const Endpoints: {
15
15
  declare const AccountEndpoints: {
16
16
  Limits: string;
17
17
  };
18
+ declare const BcApiEndpoints: {
19
+ readonly Balances: "/cosmos/bank/v1beta1/balances";
20
+ readonly SpendableBalances: "/cosmos/bank/v1beta1/spendable_balances";
21
+ readonly TotalSupply: "/cosmos/bank/v1beta1/supply";
22
+ readonly SupplyByDenom: "/cosmos/bank/v1beta1/supply/by_denom";
23
+ readonly Validators: "/cosmos/staking/v1beta1/validators";
24
+ readonly DelegatorDelegations: "/cosmos/staking/v1beta1/delegations";
25
+ readonly Delegators: "/cosmos/staking/v1beta1/delegators";
26
+ readonly StakingParams: "/cosmos/staking/v1beta1/params";
27
+ readonly DistributionDelegators: "/cosmos/distribution/v1beta1/delegators";
28
+ readonly Account: "/cosmos/auth/v1beta1/accounts";
29
+ };
18
30
  declare const BlockchainEndpoints: {
19
31
  readonly Send: "/send";
20
32
  readonly MultiSend: "/multisend";
@@ -112,4 +124,4 @@ declare const CookieKeys: {
112
124
  readonly access_token: "access_token";
113
125
  readonly jwt_token: "jwt_token";
114
126
  };
115
- export { Endpoints, AccountEndpoints, BlockchainEndpoints, LimitedEndpoints, OpenPaydEndpoints, OrganizationEndpoints, ProgramEndpoints, TransactionEndpoints, UserEndpoints, GrantType, HeaderKeys, HTTPMethod, CookieKeys, };
127
+ export { Endpoints, AccountEndpoints, BlockchainEndpoints, LimitedEndpoints, OpenPaydEndpoints, OrganizationEndpoints, ProgramEndpoints, TransactionEndpoints, UserEndpoints, BcApiEndpoints, GrantType, HeaderKeys, HTTPMethod, CookieKeys, };
@@ -16,6 +16,18 @@ const Endpoints = {
16
16
  const AccountEndpoints = {
17
17
  Limits: "/limits",
18
18
  };
19
+ const BcApiEndpoints = {
20
+ Balances: "/cosmos/bank/v1beta1/balances",
21
+ SpendableBalances: "/cosmos/bank/v1beta1/spendable_balances",
22
+ TotalSupply: "/cosmos/bank/v1beta1/supply",
23
+ SupplyByDenom: "/cosmos/bank/v1beta1/supply/by_denom",
24
+ Validators: "/cosmos/staking/v1beta1/validators",
25
+ DelegatorDelegations: "/cosmos/staking/v1beta1/delegations",
26
+ Delegators: "/cosmos/staking/v1beta1/delegators",
27
+ StakingParams: "/cosmos/staking/v1beta1/params",
28
+ DistributionDelegators: "/cosmos/distribution/v1beta1/delegators",
29
+ Account: "/cosmos/auth/v1beta1/accounts",
30
+ };
19
31
  const BlockchainEndpoints = {
20
32
  Send: "/send",
21
33
  MultiSend: "/multisend",
@@ -120,7 +132,7 @@ const CookieKeys = {
120
132
  // #endregion
121
133
  export {
122
134
  // #region "Endpoints"
123
- Endpoints, AccountEndpoints, BlockchainEndpoints, LimitedEndpoints, OpenPaydEndpoints, OrganizationEndpoints, ProgramEndpoints, TransactionEndpoints, UserEndpoints,
135
+ Endpoints, AccountEndpoints, BlockchainEndpoints, LimitedEndpoints, OpenPaydEndpoints, OrganizationEndpoints, ProgramEndpoints, TransactionEndpoints, UserEndpoints, BcApiEndpoints,
124
136
  // #endregion
125
137
  // #region "API"
126
138
  GrantType, HeaderKeys, HTTPMethod,