@ethersproject/abi#FormatTypes TypeScript Examples
The following examples show how to use
@ethersproject/abi#FormatTypes.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: function-fragment.ts From fuels-ts with Apache License 2.0 | 6 votes |
/**
* An override for the `format` method of Ethers' ParamType to handle Fuel/Ethereum ABI incompatibilities
*/
function formatOverride(this: ParamType, format?: string): string {
if (!format || format === FormatTypes.sighash) {
const structMatch = structRegEx.exec(this.type)?.groups;
if (structMatch) {
return `s${this.format(format)}`;
}
const arrayMatch = arrayRegEx.exec(this.type)?.groups;
if (arrayMatch) {
return `[${arrayMatch.item}; ${arrayMatch.length}]`;
}
}
return this.format(format);
}
Example #2
Source File: AbiEntry.ts From useDApp with MIT License | 6 votes |
export function toAbiEntry(abi: AbiInput): AbiEntry | undefined {
const coder = new Interface([abi])
const fragment = coder.functions[Object.keys(coder.functions)[0]]
if (!fragment) {
return undefined
}
const selector = coder.getSighash(fragment)
const code = fragment.format(FormatTypes.full)
return { code, coder, fragment, selector }
}
Example #3
Source File: abi.ts From snapshot-plugins with MIT License | 5 votes |
export function parseMethodToABI(method: FunctionFragment) {
return [method.format(FormatTypes.full)];
}