Skip to content

Commit

Permalink
transaction filter improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
oXtxNt9U committed Nov 28, 2024
1 parent 805425a commit 6a3355e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/api-http/source/resources/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class TransactionResource implements Contracts.Api.Resource {
blockId: resource.blockId,

confirmations,
data: resource.data,
data: resource.data === "0x" ? "" : resource.data,
gasLimit: resource.gasLimit,

gasPrice: resource.gasPrice,
Expand Down
7 changes: 4 additions & 3 deletions packages/api-http/source/schemas/schemas.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Joi from "joi";
import { walletAddressSchema } from "./wallets.js";

// Old

Expand All @@ -12,7 +13,7 @@ export const orderBy = Joi.alternatives().try(
Joi.array().items(Joi.string().regex(/^[._a-z]{1,40}:(asc|desc)$/i)),
);

export const address = Joi.string().alphanum().max(96);
export const address = walletAddressSchema;

export const delegateIdentifier = Joi.string()
.regex(/^[\w!$&.@]+$/)
Expand Down Expand Up @@ -82,14 +83,14 @@ export const transactionCriteriaSchemas = {
asset: orContainsCriteria(Joi.object()),
blockId: orEqualCriteria(blockId),
data: orEqualCriteria(
Joi.alternatives().try(Joi.string().valid("0x"), Joi.string().hex({ prefix: "optional" }).max(10)),
Joi.alternatives().try(Joi.string().valid("", "0x"), Joi.string().hex({ prefix: "optional" }).max(10)),
),
gasFee: orNumericCriteria(Joi.number().integer().min(0)),
gasPrice: orNumericCriteria(Joi.number().integer().min(0)),
id: orEqualCriteria(Joi.string().hex().length(64)),
nonce: orNumericCriteria(Joi.number().integer().positive()),
recipientId: orEqualCriteria(address),
senderAddress: orEqualCriteria(Joi.string().hex().length(42)),
senderAddress: orEqualCriteria(address),
senderId: orEqualCriteria(address),
senderPublicKey: orEqualCriteria(Joi.string().hex().length(66)),
sequence: orNumericCriteria(Joi.number().integer().positive()),
Expand Down
4 changes: 2 additions & 2 deletions packages/api-http/source/schemas/wallets.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Schemas } from "@mainsail/api-common";
import Joi from "joi";

export const walletAddressSchema = Joi.string().alphanum(); /* TODO: .length(34); */
export const walletPublicKeySchema = Joi.string().hex(); /* TODO: .length(66); */
export const walletAddressSchema = Joi.string().hex({ prefix: true }).length(42);
export const walletPublicKeySchema = Joi.string().hex({ prefix: false }).length(66);
export const walletUsernameSchema = Joi.string().max(256);

export const walletId = Joi.alternatives().try(
Expand Down

0 comments on commit 6a3355e

Please sign in to comment.