Comparing version 6.0.3 to 6.0.4
# typechain | ||
## 6.0.4 | ||
### Patch Changes | ||
- a26ea50: Constant size struct arrays are now properly supported and don't cause malformed TS emit anymore. | ||
## 6.0.3 | ||
@@ -4,0 +10,0 @@ |
@@ -136,2 +136,3 @@ "use strict"; | ||
} | ||
const isStructType = (evmType) => evmType.type === 'array' || evmType.type === 'tuple'; | ||
function parseRawAbiParameterType(rawAbiParameter, registerStruct) { | ||
@@ -144,4 +145,13 @@ const components = rawAbiParameter.components && | ||
const parsed = (0, parseEvmType_1.parseEvmType)(rawAbiParameter.type, components, rawAbiParameter.internalType); | ||
if (['tuple', 'array'].includes(parsed.type) && parsed.structName !== undefined) { | ||
registerStruct(parsed); | ||
if (isStructType(parsed)) { | ||
if ('size' in parsed && parsed.size > 1 && isStructType(parsed.itemType) && parsed.structName) { | ||
// We unwrap constant size struct arrays like `Item[4]` into `Item`. | ||
registerStruct({ | ||
...parsed.itemType, | ||
structName: parsed.structName.replace(new RegExp(`\\[${parsed.size}\\]$`), ''), | ||
}); | ||
} | ||
else { | ||
registerStruct(parsed); | ||
} | ||
} | ||
@@ -148,0 +158,0 @@ return parsed; |
@@ -79,2 +79,3 @@ "use strict"; | ||
function extractStructNameIfAvailable(internalType) { | ||
var _a; | ||
if (internalType === null || internalType === void 0 ? void 0 : internalType.startsWith('struct ')) { | ||
@@ -84,4 +85,5 @@ // get rid of "struct " in the beginning | ||
// get rid of the array sign at the end | ||
if (nameStr.endsWith('[]')) { | ||
nameStr = nameStr.slice(0, nameStr.length - 2); | ||
const arrayMarker = (_a = nameStr.match(/(\[\d*\])$/)) === null || _a === void 0 ? void 0 : _a[1]; | ||
if (arrayMarker) { | ||
nameStr = nameStr.slice(0, nameStr.length - arrayMarker.length); | ||
} | ||
@@ -88,0 +90,0 @@ // get rid of contract name if exists |
@@ -11,3 +11,3 @@ { | ||
], | ||
"version": "6.0.3", | ||
"version": "6.0.4", | ||
"license": "MIT", | ||
@@ -14,0 +14,0 @@ "repository": "https://github.com/ethereum-ts/Typechain", |
@@ -54,2 +54,9 @@ <p align="center"> | ||
### eth-sdk | ||
TypeChain generates only TypeScript typings (`d.ts`) files, if you're looking for "opionated", "batteries included" | ||
solution check out our new project: [eth-sdk](https://github.com/dethcrypto/eth-sdk). It generates typesafe, ready to | ||
use ethers.js wrappers and uses etherscan/sourcify to automatically get ABIs based only on smart contract addresses. | ||
Under the hood, `eth-sdk` relies on `TypeChain`. | ||
## Usage | ||
@@ -56,0 +63,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
94453
1223
207