Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aztec/foundation

Package Overview
Dependencies
Maintainers
6
Versions
172
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aztec/foundation - npm Package Compare versions

Comparing version 0.1.0-alpha46 to 0.1.0-alpha47

dest/abi/function_selector.d.ts

29

dest/abi/abi_coder.d.ts

@@ -1,30 +0,3 @@

/// <reference types="node" resolution-mode="require"/>
import { ABIParameter, ABIType } from '@aztec/foundation/abi';
import { ABIType } from '@aztec/foundation/abi';
/**
* Generate a function signature string for a given function name and parameters.
* The signature is used to uniquely identify functions within noir contracts.
* If the function name is 'constructor', it returns just the name, otherwise it returns the name followed by the list of parameter types.
*
* @param name - The name of the function.
* @param parameters - An array of ABIParameter objects, each containing the type information of a function parameter.
* @returns A string representing the function signature.
*/
export declare function computeFunctionSignature(name: string, parameters: ABIParameter[]): string;
/**
* Generate a function selector for a given function signature.
* @param signature - The signature of the function.
* @param size - Number of bytes of the return buffer.
* @returns A Buffer containing the n-byte function selector.
*/
export declare function computeFunctionSelector(signature: string, size: number): Buffer;
/**
* Generate a function selector for a given function name and parameters.
* It is derived by taking the first 4 bytes of the Keccak-256 hash of the function signature.
*
* @param name - The name of the function.
* @param parameters - An array of ABIParameter objects, each containing the type information of a function parameter.
* @returns A Buffer containing the 4-byte function selector.
*/
export declare function generateFunctionSelector(name: string, parameters: ABIParameter[]): Buffer;
/**
* Get the size of an ABI type in field elements.

@@ -31,0 +4,0 @@ * @param type - The ABI type.

@@ -1,36 +0,2 @@

import { keccak } from '@aztec/foundation/crypto';
/**
* Generate a function signature string for a given function name and parameters.
* The signature is used to uniquely identify functions within noir contracts.
* If the function name is 'constructor', it returns just the name, otherwise it returns the name followed by the list of parameter types.
*
* @param name - The name of the function.
* @param parameters - An array of ABIParameter objects, each containing the type information of a function parameter.
* @returns A string representing the function signature.
*/
export function computeFunctionSignature(name, parameters) {
return name === 'constructor' ? name : `${name}(${parameters.map(p => p.type.kind).join(',')})`;
}
/**
* Generate a function selector for a given function signature.
* @param signature - The signature of the function.
* @param size - Number of bytes of the return buffer.
* @returns A Buffer containing the n-byte function selector.
*/
export function computeFunctionSelector(signature, size) {
return keccak(Buffer.from(signature)).slice(0, size);
}
/**
* Generate a function selector for a given function name and parameters.
* It is derived by taking the first 4 bytes of the Keccak-256 hash of the function signature.
*
* @param name - The name of the function.
* @param parameters - An array of ABIParameter objects, each containing the type information of a function parameter.
* @returns A Buffer containing the 4-byte function selector.
*/
export function generateFunctionSelector(name, parameters) {
const signature = computeFunctionSignature(name, parameters);
return computeFunctionSelector(signature, 4);
}
/**
* Get the size of an ABI type in field elements.

@@ -58,2 +24,2 @@ * @param type - The ABI type.

}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWJpX2NvZGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2FiaS9hYmlfY29kZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLE1BQU0sRUFBRSxNQUFNLDBCQUEwQixDQUFDO0FBRWxEOzs7Ozs7OztHQVFHO0FBQ0gsTUFBTSxVQUFVLHdCQUF3QixDQUFDLElBQVksRUFBRSxVQUEwQjtJQUMvRSxPQUFPLElBQUksS0FBSyxhQUFhLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsR0FBRyxJQUFJLElBQUksVUFBVSxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsSUFBSSxDQUFDLEdBQUcsQ0FBQyxHQUFHLENBQUM7QUFDbEcsQ0FBQztBQUVEOzs7OztHQUtHO0FBQ0gsTUFBTSxVQUFVLHVCQUF1QixDQUFDLFNBQWlCLEVBQUUsSUFBWTt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FBSSxLQUFLLENBQUMsdUJBQXVCLGVBQWUsRUFBRSxDQUFDLENBQUM7U0FDM0Q7S0FDRjtBQUNILENBQUMifQ==
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWJpX2NvZGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2FiaS9hYmlfY29kZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUE7Ozs7R0FJRztBQUNILE1BQU0sVUFBVSxVQUFVLENBQUMsSUFBYTtJQUN0QyxRQUFRLElBQUksQ0FBQyxJQUFJLEVBQUU7UUFDakIsS0FBSyxPQUFPLENBQUM7UUFDYixLQUFLLFNBQVMsQ0FBQztRQUNmLEtBQUssU0FBUztZQUNaLE9BQU8sQ0FBQyxDQUFDO1FBQ1gsS0FBSyxRQUFRO1lBQ1gsT0FBTyxJQUFJLENBQUMsTUFBTSxDQUFDO1FBQ3JCLEtBQUssT0FBTztZQUNWLE9BQU8sSUFBSSxDQUFDLE1BQU0sR0FBRyxVQUFVLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDO1FBQzdDLEtBQUssUUFBUTtZQUNYLE9BQU8sSUFBSSxDQUFDLE1BQU0sQ0FBQyxNQUFNLENBQUMsQ0FBQyxHQUFHLEVBQUUsS0FBSyxFQUFFLEVBQUUsQ0FBQyxHQUFHLEdBQUcsVUFBVSxDQUFDLEtBQUssQ0FBQyxJQUFJLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQztRQUM3RSxPQUFPLENBQUMsQ0FBQztZQUNQLE1BQU0sZUFBZSxHQUFVLElBQUksQ0FBQztZQUNwQyxNQUFNLElBQUksS0FBSyxDQUFDLHVCQUF1QixlQUFlLEVBQUUsQ0FBQyxDQUFDO1NBQzNEO0tBQ0Y7QUFDSCxDQUFDIn0=

@@ -5,2 +5,3 @@ export * from './abi.js';

export * from './decoder.js';
export * from './function_selector.js';
//# sourceMappingURL=index.d.ts.map

@@ -5,2 +5,3 @@ export * from './abi.js';

export * from './decoder.js';
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvYWJpL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsVUFBVSxDQUFDO0FBQ3pCLGNBQWMsZ0JBQWdCLENBQUM7QUFDL0IsY0FBYyxjQUFjLENBQUM7QUFDN0IsY0FBYyxjQUFjLENBQUMifQ==
export * from './function_selector.js';
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvYWJpL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsVUFBVSxDQUFDO0FBQ3pCLGNBQWMsZ0JBQWdCLENBQUM7QUFDL0IsY0FBYyxjQUFjLENBQUM7QUFDN0IsY0FBYyxjQUFjLENBQUM7QUFDN0IsY0FBYyx3QkFBd0IsQ0FBQyJ9

@@ -21,3 +21,3 @@ import { Buffer } from 'buffer';

*/
constructor(module, importFn, loggerName = 'wasm') {
constructor(module, importFn, loggerName = 'aztec:wasm') {
this.module = module;

@@ -206,2 +206,2 @@ this.importFn = importFn;

}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2FzbV9tb2R1bGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvd2FzbS93YXNtX21vZHVsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsTUFBTSxFQUFFLE1BQU0sUUFBUSxDQUFDO0FBRWhDLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUF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, ABIType } from '@aztec/foundation/abi';
import { keccak } from '@aztec/foundation/crypto';
import { ABIType } from '@aztec/foundation/abi';
/**
* Generate a function signature string for a given function name and parameters.
* The signature is used to uniquely identify functions within noir contracts.
* If the function name is 'constructor', it returns just the name, otherwise it returns the name followed by the list of parameter types.
*
* @param name - The name of the function.
* @param parameters - An array of ABIParameter objects, each containing the type information of a function parameter.
* @returns A string representing the function signature.
*/
export function computeFunctionSignature(name: string, parameters: ABIParameter[]) {
return name === 'constructor' ? name : `${name}(${parameters.map(p => p.type.kind).join(',')})`;
}
/**
* Generate a function selector for a given function signature.
* @param signature - The signature of the function.
* @param size - Number of bytes of the return buffer.
* @returns A Buffer containing the n-byte function selector.
*/
export function computeFunctionSelector(signature: string, size: number) {
return keccak(Buffer.from(signature)).slice(0, size);
}
/**
* Generate a function selector for a given function name and parameters.
* It is derived by taking the first 4 bytes of the Keccak-256 hash of the function signature.
*
* @param name - The name of the function.
* @param parameters - An array of ABIParameter objects, each containing the type information of a function parameter.
* @returns A Buffer containing the 4-byte function selector.
*/
export function generateFunctionSelector(name: string, parameters: ABIParameter[]) {
const signature = computeFunctionSignature(name, parameters);
return computeFunctionSelector(signature, 4);
}
/**
* Get the size of an ABI type in field elements.

@@ -42,0 +5,0 @@ * @param type - The ABI type.

@@ -5,1 +5,2 @@ export * from './abi.js';

export * from './decoder.js';
export * from './function_selector.js';

@@ -62,3 +62,3 @@ import { Buffer } from 'buffer';

private importFn: (module: WasmModule) => any,
loggerName = 'wasm',
loggerName = 'aztec:wasm',
) {

@@ -65,0 +65,0 @@ this.debug = createDebugOnlyLogger(loggerName);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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