Skip to content

Commit

Permalink
Feat/fou 523 display price (#91)
Browse files Browse the repository at this point in the history
* refactor: change name validate orai address func
  • Loading branch information
quangdz1704 authored Dec 11, 2023
1 parent c06333a commit 61c0295
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/oraidex-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oraichain/oraidex-server",
"version": "1.0.36",
"version": "1.0.37",
"main": "dist/index.js",
"bin": "dist/index.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/oraidex-server/src/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function pairToString([base, quote]: string[]): string {
return `${base}-${quote}`;
}

export const validateContractAddress = (contractAddress: string) => {
export const validateOraiAddress = (contractAddress: string) => {
try {
const { prefix } = bech32.decode(contractAddress);
if (prefix === ORAI) return true;
Expand Down
4 changes: 2 additions & 2 deletions packages/oraidex-server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import {
getSpecificDateBeforeNow,
pairToString,
parseSymbolsToTickerId,
validateContractAddress
validateOraiAddress
} from "./helper";

const app = express();
Expand Down Expand Up @@ -464,7 +464,7 @@ app.get("/price-by-usdt/", async (req: Request<{}, {}, {}, GetPriceAssetByUsdt>,
const { contractAddress, denom } = req.query;
let price = 0;
if (contractAddress) {
const checkValidContractAddress = validateContractAddress(contractAddress);
const checkValidContractAddress = validateOraiAddress(contractAddress);
if (!checkValidContractAddress) {
res.status(200).send({ price: 0 });
return;
Expand Down
4 changes: 2 additions & 2 deletions packages/oraidex-server/tests/helper.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getDate24hBeforeNow, validateContractAddress } from "../src/helper";
import { getDate24hBeforeNow, validateOraiAddress } from "../src/helper";

describe("test-helper", () => {
it("test-getDate24hBeforeNow", () => {
Expand All @@ -17,7 +17,7 @@ describe("test-helper", () => {
["orai1lus0f0rhx8s03gdllx2n6vhkmf0536dv57wfge", true], // ORAIX
["orai12hzjxfh77wl572gdzct2fxv2arxcwh6gykc7qh", true] // USDT
])("test-validateContractAddress", (contractAddress, expected) => {
const checkContractAddress = validateContractAddress(contractAddress);
const checkContractAddress = validateOraiAddress(contractAddress);
// assert
expect(checkContractAddress).toEqual(expected);
});
Expand Down

0 comments on commit 61c0295

Please sign in to comment.