Skip to content

Commit

Permalink
feat: token factry
Browse files Browse the repository at this point in the history
  • Loading branch information
emidev98 committed Nov 9, 2023
1 parent 8e5b3e8 commit 22010b8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 21 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@terra-money/feather.js",
"version": "2.0.0-beta.7",
"version": "2.0.0-beta.8",
"description": "The JavaScript SDK for Terra and Feather chains",
"license": "MIT",
"author": "Terraform Labs, PTE.",
Expand Down
46 changes: 27 additions & 19 deletions src/client/lcd/api/TokenFactoryAPI.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { APIParams } from '../APIRequester';

Check warning on line 1 in src/client/lcd/api/TokenFactoryAPI.ts

View workflow job for this annotation

GitHub Actions / build

'APIParams' is defined but never used
import { LCDClient } from '../LCDClient';
import { BaseAPI } from './BaseAPI';
import { QueryParamsResponse } from '@terra-money/terra.proto/cosmwasm/wasm/v1/query';
import { QueryParamsResponse } from '@terra-money/terra.proto/osmosis/tokenfactory/v1beta1/query';
import { AccAddress } from '../../../core';

export interface DenomsFromCreatorResponse {
Expand All @@ -14,40 +14,48 @@ export interface AuthorityMetadataResponse {
};
}

export interface BeforeSendHookResponse {
before_send_hook: {
cosmwasm_address: AccAddress;
};
}

export class TokenFactory extends BaseAPI {
constructor(public lcd: LCDClient) {
super(lcd.apiRequesters, lcd.config);
}

public params(
chainID: string,
params: APIParams = {}
): Promise<QueryParamsResponse> {
public params(chainID: string): Promise<QueryParamsResponse> {
return this.getReqFromChainID(chainID).get<QueryParamsResponse>(
`/osmosis/tokenfactory/v1beta1/params`,
params
`/osmosis/tokenfactory/v1beta1/params`
);
}

public denomsFromCreator(
creator: AccAddress,
params: APIParams = {}
creator: AccAddress
): Promise<DenomsFromCreatorResponse> {
const req = this.getReqFromAddress(creator);

return req.get<DenomsFromCreatorResponse>(
`/osmosis/tokenfactory/v1beta1/denoms_from_creator/${creator}`,
params
`/osmosis/tokenfactory/v1beta1/denoms_from_creator/${creator}`
);
}

/*
The following request does not work yet because the endpoint
does recognize the url encoded denom.
public authorityMetadata(
chainID: string,
denom: string
): Promise<AuthorityMetadataResponse> {
return this.getReqFromChainID(chainID).get<AuthorityMetadataResponse>(
`/osmosis/tokenfactory/v1beta1/denoms/${denom}/authority_metadata`
);
}

public authorityMetadata(chainID: string, denom: string, params: APIParams = {}): Promise<AuthorityMetadataResponse> {
return this.getReqFromChainID(chainID)
.get<AuthorityMetadataResponse>(`/osmosis/tokenfactory/v1beta1/denoms/${denom}/authority_metadata`, params);
}
*/
public beforeSendHook(
chainID: string,
denom: string
): Promise<BeforeSendHookResponse> {
return this.getReqFromChainID(chainID).get<BeforeSendHookResponse>(
`/osmosis/tokenfactory/v1beta1/denoms/${denom}/before_send_hook`
);
}
}

0 comments on commit 22010b8

Please sign in to comment.