All files / ethers.js/src.ts/abi/coders anonymous.ts

86.2% Statements 25/29
100% Branches 3/3
60% Functions 3/5
86.2% Lines 25/29

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 301x 1x 1x 1x 1x 1x 1x 1x 1x 1x 5376x 5376x 5376x 5376x 5376x 5376x 5376x 5376x     5376x 5376x     5376x 5376x 5376x 5376x 5376x  
import { Coder } from "./abstract-coder.js";
 
import type { Reader, Writer } from "./abstract-coder.js";
 
/**
 *  Clones the functionality of an existing Coder, but without a localName
 *
 *  @_ignore
 */
export class AnonymousCoder extends Coder {
    private coder: Coder;
 
    constructor(coder: Coder) {
        super(coder.name, coder.type, "_", coder.dynamic);
        this.coder = coder;
    }
 
    defaultValue(): any {
        return this.coder.defaultValue();
    }
 
    encode(writer: Writer, value: any): number {
        return this.coder.encode(writer, value);
    }
 
    decode(reader: Reader): any {
        return this.coder.decode(reader);
    }
}