Socket
Socket
Sign inDemoInstall

@truffle/abi-utils

Package Overview
Dependencies
Maintainers
14
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@truffle/abi-utils - npm Package Compare versions

Comparing version 0.2.17 to 0.3.0

dist/lib/signature.d.ts

1

dist/lib/index.d.ts
export * from "./types";
export * from "./normalize";
export * from "./signature";
import * as Arbitrary from "./arbitrary";
export { Arbitrary };
//# sourceMappingURL=index.d.ts.map

@@ -32,4 +32,5 @@ "use strict";

__exportStar(require("./normalize"), exports);
__exportStar(require("./signature"), exports);
const Arbitrary = __importStar(require("./arbitrary"));
exports.Arbitrary = Arbitrary;
//# sourceMappingURL=index.js.map

7

package.json
{
"name": "@truffle/abi-utils",
"version": "0.2.17",
"version": "0.3.0",
"description": "Utilities for working with ABIs",

@@ -29,3 +29,4 @@ "license": "MIT",

"faker": "5.5.3",
"fast-check": "3.1.1"
"fast-check": "3.1.1",
"web3-utils": "1.7.4"
},

@@ -54,3 +55,3 @@ "devDependencies": {

},
"gitHead": "0d96061f25e0927cd1d158b1636464ded86a57bb"
"gitHead": "fb1f58675bf52bb7dc11e45026c8b43aeca401e9"
}

@@ -11,2 +11,3 @@ # `@truffle/abi-utils`

- [TypeScript types](#typescript-types)
- [Selector and signature computation](#selector-and-signature-computation)
- [Arbitrary random ABIs](#arbitrary-random-abis)

@@ -21,3 +22,4 @@

> // handle: v--- new way v--- old way v--- default
> const isPayable = entry.stateMutability === "payable" || entry.payable || false;
> const isPayable =
> entry.stateMutability === "payable" || entry.payable || false;
>

@@ -27,3 +29,4 @@ > // handle "outputs" possibly being undefined

> ```
_^ Have you ever had to do this sort of thing?_ :scream:
>
> _^ Have you ever had to do this sort of thing?_ :scream:

@@ -47,2 +50,3 @@ Solidity's official [JSON ABI specification](https://solidity.readthedocs.io/en/v0.7.3/abi-spec.html)

Specifically, this normalizes by:
- Ensuring every ABI entry has a `type` field, since it's optional for

@@ -66,3 +70,2 @@ `type: "function"`

## TypeScript types

@@ -87,8 +90,29 @@

const abi: Abi.Abi = [{"type": "constructor"/*, ...*/}/*, ...*/];
const parameter: Abi.Parameter = {"type": "tuple[]", "components": [/*...*/]};
const abi: Abi.Abi = [{ type: "constructor" /*, ...*/ } /*, ...*/];
const parameter: Abi.Parameter = {
type: "tuple[]",
components: [
/*...*/
]
};
// etc.
```
## Selector and signature computation
This package exports the following functions for computing signatures and selectors:
- `abiSelector`: This function takes a `FunctionEntry`, `EventEntry`, or
`ErrorEntry` and computes its selector, returned as a hex string. This will
be 4 bytes for a function or error, and 32 bytes for an event.
- `abiSignature`: This function takes a `FunctionEntry`, `EventEntry`, or
`ErrorEntry` and computes its written-out signature (e.g., `"setStoredValue(uint256)"`).
- `abiTupleSignature`: This function takes a `Parameter[]` and computes the signature
of that tuple on its own; e.g., `"(uint256,string)"` for a `uint` and a `string`.
- `abiTypeSignature`: This function takes an individual `Parameter` and computes
the signature of that type on its own; e.g., `uint256` for a `uint`.
In addition, the package also exports the constant `ShortSelectorSize`, which
is equal to 4 (the number of bytes in a function or event selector).
## Arbitrary random ABIs

@@ -95,0 +119,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc