Description
Ethers Version
6.4.2
Search Terms
FixedNumber
Describe the Problem
I've been using the Ethers library in a project and I've encountered an issue with the FixedNumber object, specifically with operations that access o.#val, a private field.
Here's a simplified snippet of the FixedNumber class and a method that's causing problems:
export class FixedNumber {
...
#mul(o: FixedNumber, safeOp?: string): FixedNumber {
this.#checkFormat(o);
return this.#checkValue((this.#val * o.#val) / this.#tens, safeOp);
}
...
}
When the #mul method is called, it leads to the following error:
Uncaught (in promise) TypeError: Cannot read from private field
The issue arises from attempts to access the private field o.#val. I have observed this behavior when using the FixedNumber object within a Pinia store (Nuxt3), but the underlying problem appears to be in the FixedNumber object itself, even though it doesn't occur on other parts of the code.
This behavior is unexpected as operations on a FixedNumber object should not be attempting to access private properties of the object.
Code Snippet
#mul(o: FixedNumber, safeOp?: string): FixedNumber {
this.#checkFormat(o);
return this.#checkValue((this.#val * o.#val) / this.#tens, safeOp);
}
Contract ABI
No response
Errors
Uncaught (in promise) TypeError: Cannot read from private field
at __accessCheck (chunk-ZR4A2MMM.js?v=91ea41d3:38:11)
at __privateGet (chunk-ZR4A2MMM.js?v=91ea41d3:41:3)
at _FixedNumber.mul_fn (fixednumber.ts:359:46)
at _FixedNumber.mul (fixednumber.ts:373:51)
Environment
Browser (Chrome, Safari, etc)
Environment (Other)
Nuxt3 + pinia