Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getTxBalance input style conflicts with data from wallet-headless #562

Open
alexruzenhack opened this issue Jul 21, 2023 · 0 comments
Open
Assignees
Labels
enhancement New feature or request

Comments

@alexruzenhack
Copy link
Contributor

This method getTxBalance accepts the input tx: IHistoryTx and IHistoryTx is presented by data in snake case style, as we can see bellow:

export interface IHistoryTx {
  tx_id: string;
  signalBits: number;
  version: number;
  weight: number;
  timestamp: number;
  is_voided: boolean;
  nonce: number,
  inputs: IHistoryInput[];
  outputs: IHistoryOutput[];
  parents: string[];
  token_name?: string; // For create token transaction
  token_symbol?: string; // For create token transaction
  tokens: string[];
  height?: number;
}

However the data in the wallet-headless project is defined in camel case style, therefore causing some issues of data compatibility, which force us to duplicate some properties to comply with the snake style too. See the example bellow extracted from the method decodeTx in the wallet.controller.js:

{
  txId: input.hash,
  index: input.index,
  decoded: utxo.decoded,
  token: utxo.token,
  value: utxo.value,
  // This is required by transactionUtils.getTxBalance
  // It should be ignored by users
  token_data: utxo.token_data,
  // User facing duplication to keep scheme consistency
  tokenData: utxo.token_data,
  script: utxo.script,
  signed: !!input.data,
  mine: await req.wallet.isAddressMine(utxo.decoded.address),
},

Should we commit with only one style throughout our projects?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Todo
Development

No branches or pull requests

1 participant