@ethereum-sourcify/bytecode-utils
Version:
Decode the CBOR encoded data at the end of an Ethereum contract's bytecode.
38 lines • 1.45 kB
TypeScript
export type SolidityDecodedObject = {
ipfs?: string;
solcVersion?: string;
experimental?: boolean;
bzzr0?: string;
bzzr1?: string;
[key: string]: string | Uint8Array | undefined | boolean;
};
export type VyperDecodedObject = {
integrity?: string;
runtimeSize?: number;
dataSizes?: number[];
immutableSize?: number;
vyperVersion: string;
};
export declare enum AuxdataStyle {
SOLIDITY = "solidity",
VYPER = "vyper",
VYPER_LT_0_3_10 = "vyper_lt_0_3_10",
VYPER_LT_0_3_5 = "vyper_lt_0_3_5"
}
/**
* Decode contract's bytecode
* @param bytecode - hex of the bytecode with 0x prefix
* @param auxdataStyle - The style of auxdata, check AuxdataStyle enum for more info
* @returns Object describing the contract
*/
export declare const decode: <T extends AuxdataStyle>(bytecode: string, auxdataStyle: T) => T extends AuxdataStyle.SOLIDITY ? SolidityDecodedObject : VyperDecodedObject;
/**
* Splits the bytecode into execution bytecode and auxdata.
* If the bytecode does not contain CBOR-encoded auxdata, returns the whole bytecode.
*
* @param bytecode - Hex string of the bytecode with 0x prefix
* @param auxdataStyle - The style of auxdata (Solidity or Vyper)
* @returns An array containing execution bytecode and optionally auxdata and its length
*/
export declare const splitAuxdata: (bytecode: string, auxdataStyle: AuxdataStyle) => string[];
//# sourceMappingURL=bytecode.d.ts.map