@truffle/abi-utils
Advanced tools
Comparing version 0.2.17 to 0.3.0
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 |
{ | ||
"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
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
65793
35
920
135
4
+ Addedweb3-utils@1.7.4
+ Added@noble/hashes@1.5.0(transitive)
+ Added@types/bn.js@5.1.6(transitive)
+ Added@types/node@22.5.5(transitive)
+ Added@types/pbkdf2@3.1.2(transitive)
+ Added@types/secp256k1@4.0.6(transitive)
+ Addedbase-x@3.0.10(transitive)
+ Addedblakejs@1.2.1(transitive)
+ Addedbn.js@4.11.64.12.05.2.1(transitive)
+ Addedbrorand@1.1.0(transitive)
+ Addedbrowserify-aes@1.2.0(transitive)
+ Addedbs58@4.0.1(transitive)
+ Addedbs58check@2.1.2(transitive)
+ Addedbuffer-xor@1.0.3(transitive)
+ Addedcipher-base@1.0.4(transitive)
+ Addedcreate-hash@1.2.0(transitive)
+ Addedcreate-hmac@1.1.7(transitive)
+ Addedelliptic@6.5.7(transitive)
+ Addedethereum-bloom-filters@1.2.0(transitive)
+ Addedethereum-cryptography@0.1.3(transitive)
+ Addedethereumjs-util@7.1.5(transitive)
+ Addedethjs-unit@0.1.6(transitive)
+ Addedevp_bytestokey@1.0.3(transitive)
+ Addedhash-base@3.1.0(transitive)
+ Addedhash.js@1.1.7(transitive)
+ Addedhmac-drbg@1.0.1(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-hex-prefixed@1.0.0(transitive)
+ Addedkeccak@3.0.4(transitive)
+ Addedmd5.js@1.3.5(transitive)
+ Addedminimalistic-assert@1.0.1(transitive)
+ Addedminimalistic-crypto-utils@1.0.1(transitive)
+ Addednode-addon-api@2.0.2(transitive)
+ Addednode-gyp-build@4.8.2(transitive)
+ Addednumber-to-bn@1.7.0(transitive)
+ Addedpbkdf2@3.1.2(transitive)
+ Addedrandombytes@2.1.0(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedripemd160@2.0.2(transitive)
+ Addedrlp@2.2.7(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedscrypt-js@3.0.1(transitive)
+ Addedsecp256k1@4.0.3(transitive)
+ Addedsetimmediate@1.0.5(transitive)
+ Addedsha.js@2.4.11(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedstrip-hex-prefix@1.0.0(transitive)
+ Addedundici-types@6.19.8(transitive)
+ Addedutf8@3.0.0(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedweb3-utils@1.7.4(transitive)