From d8e7ccfa5dca1993ecb8e3c0dfbf093d76957b02 Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Tue, 24 Feb 2026 23:49:32 -0800 Subject: [PATCH] Improve type definitions --- index.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index de5cf75..cce9fea 100644 --- a/index.js +++ b/index.js @@ -194,10 +194,23 @@ function solcMultihashToCIDv1(byteArray) { return `${prefix}${out}`; } +/** + * @typedef {Object} BytecodeMetadata + * @property {Uint8Array} ipfs Byte array of a multihash of the SHA-256 hash of the full JSON metadata file. + * @property {Uint8Array} solc Byte array of the literal Solidity version number. + */ + +/** + * @typedef {Object} CIDs + * @property {string} solcVersion String representation of the Solidity version number used. + * @property {string} cidV0 A CID V0 that can be directly used to look up the JSON metadata file on IPFS. + * @property {string} cidV1 A CID V1 that can be directly used to look up the JSON metadata file on IPFS. + */ + /** * Get IPFS CIDs for the JSON metadata file from decoded bytecode metadata. - * @param {Object} metadata Decoded bytecode metadata. - * @returns {Object} The `solc` compiler version and IPFS CIDs (both CIDv0 and CIDv1) of the JSON metadata. + * @param {BytecodeMetadata} metadata Decoded bytecode metadata. + * @returns {CIDs} The `solc` compiler version and IPFS CIDs (both CIDv0 and CIDv1) of the JSON metadata. */ function calculateCID(metadata) { const { ipfs, solc } = metadata; -- 2.47.3