-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add abis to js exports * fix: add generated comment
- Loading branch information
Showing
7 changed files
with
1,254 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import util from 'node:util'; | ||
import {exec} from 'node:child_process'; | ||
import {existsSync, mkdirSync, rmSync, writeFileSync} from 'node:fs'; | ||
import {prefixWithGeneratedWarning} from './utils'; | ||
|
||
const awaitableExec = util.promisify(exec); | ||
|
||
const INTERFACES = ['IAaveGovernanceV2', 'ICollector', 'AggregatorInterface']; | ||
|
||
export async function generateABIs() { | ||
if (existsSync('./src/ts/abis')) { | ||
rmSync('./src/ts/abis', {recursive: true}); | ||
} | ||
mkdirSync('./src/ts/abis'); | ||
const jsExports = await Promise.all( | ||
INTERFACES.map(async (INTERFACE) => { | ||
const {stdout, stderr} = await awaitableExec(`forge inspect ${INTERFACE} abi`); | ||
if (stderr) { | ||
throw new Error(`Failed to generate abi for ${INTERFACE}`); | ||
} | ||
const varName = `${INTERFACE}_ABI`; | ||
writeFileSync( | ||
`./src/ts/abis/${INTERFACE}.ts`, | ||
prefixWithGeneratedWarning( | ||
`export const ${varName} = ${JSON.stringify( | ||
JSON.parse(stdout.trim()), | ||
null, | ||
2, | ||
)} as const;`, | ||
), | ||
); | ||
return `export {${varName}} from './abis/${INTERFACE}';`; | ||
}), | ||
); | ||
return { | ||
solidity: [], | ||
js: jsExports, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
// AUTOGENERATED - MANUALLY CHANGES WILL BE REVERTED BY THE GENERATOR | ||
export const AggregatorInterface_ABI = [ | ||
{ | ||
anonymous: false, | ||
inputs: [ | ||
{ | ||
indexed: true, | ||
internalType: 'int256', | ||
name: 'current', | ||
type: 'int256', | ||
}, | ||
{ | ||
indexed: true, | ||
internalType: 'uint256', | ||
name: 'roundId', | ||
type: 'uint256', | ||
}, | ||
{ | ||
indexed: false, | ||
internalType: 'uint256', | ||
name: 'updatedAt', | ||
type: 'uint256', | ||
}, | ||
], | ||
name: 'AnswerUpdated', | ||
type: 'event', | ||
}, | ||
{ | ||
anonymous: false, | ||
inputs: [ | ||
{ | ||
indexed: true, | ||
internalType: 'uint256', | ||
name: 'roundId', | ||
type: 'uint256', | ||
}, | ||
{ | ||
indexed: true, | ||
internalType: 'address', | ||
name: 'startedBy', | ||
type: 'address', | ||
}, | ||
{ | ||
indexed: false, | ||
internalType: 'uint256', | ||
name: 'startedAt', | ||
type: 'uint256', | ||
}, | ||
], | ||
name: 'NewRound', | ||
type: 'event', | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: 'uint256', | ||
name: 'roundId', | ||
type: 'uint256', | ||
}, | ||
], | ||
name: 'getAnswer', | ||
outputs: [ | ||
{ | ||
internalType: 'int256', | ||
name: '', | ||
type: 'int256', | ||
}, | ||
], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: 'uint256', | ||
name: 'roundId', | ||
type: 'uint256', | ||
}, | ||
], | ||
name: 'getTimestamp', | ||
outputs: [ | ||
{ | ||
internalType: 'uint256', | ||
name: '', | ||
type: 'uint256', | ||
}, | ||
], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [], | ||
name: 'latestAnswer', | ||
outputs: [ | ||
{ | ||
internalType: 'int256', | ||
name: '', | ||
type: 'int256', | ||
}, | ||
], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [], | ||
name: 'latestRound', | ||
outputs: [ | ||
{ | ||
internalType: 'uint256', | ||
name: '', | ||
type: 'uint256', | ||
}, | ||
], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [], | ||
name: 'latestTimestamp', | ||
outputs: [ | ||
{ | ||
internalType: 'uint256', | ||
name: '', | ||
type: 'uint256', | ||
}, | ||
], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
] as const; |
Oops, something went wrong.