ethers.js icon indicating copy to clipboard operation
ethers.js copied to clipboard

Retruning an Object instead of an Array on ContractStructOutput

Open ix-hammer-turtle opened this issue 1 year ago • 1 comments

Describe the Feature

Search Terms

tuple,object,array

Description

In version 6.12, the functionality is available for Result objects (https://github.com/ethers-io/ethers.js/issues/4681). However, it is still not operational with ContractStructObject. It would be beneficial to have this feature.

Code Example

const proposal = await this.proposalVoteContract.getProposal(projectId, proposalId);

const proposalObject: Proposal = {
  proposed: proposal.proposed,
  executed: proposal.executed,
  canceled: proposal.canceled,
  id: Number(proposal.id),
  proposalId: Number(proposal.proposalId),
  title: proposal.title,
  description: proposal.description,
  quorumPercent: Number(proposal.quorumPercent),
  snapshotAt: Number(proposal.snapshotAt),
  startAt: Number(proposal.startAt),
  endAt: Number(proposal.endAt),
  isExecutable: proposal.isExecutable,
  availableToExecuteAt: Number(proposal.availableToExecuteAt),
  erc20: proposal.erc20,
  from: proposal.from,
  to: proposal.to,
  amount: Number(proposal.amount),
  fundRaiser: proposal.fundRaiser,
};

// instead

const proposal = await this.proposalVoteContract.getProposal(projectId, proposalId);

const proposalObject = proposal.toObject()

ix-hammer-turtle avatar Sep 20 '24 10:09 ix-hammer-turtle

Sorry, I don't quite understand the request... Can you provide examples of what you want?

ricmoo avatar Oct 16 '24 00:10 ricmoo