@aztec/foundation 0.1.0-alpha23 → 0.1.0-alpha24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc.json +9 -2
- package/.tsbuildinfo +1 -1
- package/dest/abi/abi.d.ts +137 -0
- package/dest/abi/abi.d.ts.map +1 -0
- package/dest/abi/abi.js +18 -0
- package/dest/abi/abi_coder.d.ts +8 -1
- package/dest/abi/abi_coder.d.ts.map +1 -1
- package/dest/abi/abi_coder.js +12 -3
- package/dest/abi/decoder.d.ts +1 -1
- package/dest/abi/decoder.d.ts.map +1 -1
- package/dest/abi/index.d.ts +1 -136
- package/dest/abi/index.d.ts.map +1 -1
- package/dest/abi/index.js +2 -18
- package/dest/aztec-address/index.d.ts +7 -0
- package/dest/aztec-address/index.d.ts.map +1 -1
- package/dest/aztec-address/index.js +10 -1
- package/dest/crypto/random/index.js +2 -2
- package/dest/crypto/sha256/index.d.ts.map +1 -1
- package/dest/crypto/sha256/index.js +1 -1
- package/dest/crypto/sha256/index.test.js +2 -2
- package/dest/fields/fields.d.ts +6 -0
- package/dest/fields/fields.d.ts.map +1 -1
- package/dest/fields/fields.js +10 -2
- package/dest/fields/point.d.ts +8 -23
- package/dest/fields/point.d.ts.map +1 -1
- package/dest/fields/point.js +10 -31
- package/dest/json-rpc/client/json_rpc_client.d.ts +1 -1
- package/dest/json-rpc/client/json_rpc_client.d.ts.map +1 -1
- package/dest/json-rpc/client/json_rpc_client.js +1 -1
- package/dest/json-rpc/client/json_rpc_client.test.js +2 -2
- package/dest/json-rpc/convert.d.ts.map +1 -1
- package/dest/json-rpc/convert.js +1 -1
- package/dest/json-rpc/convert.test.js +2 -2
- package/dest/json-rpc/server/json_proxy.d.ts +1 -1
- package/dest/json-rpc/server/json_proxy.d.ts.map +1 -1
- package/dest/json-rpc/server/json_rpc_server.d.ts +1 -1
- package/dest/json-rpc/server/json_rpc_server.d.ts.map +1 -1
- package/dest/json-rpc/server/json_rpc_server.js +5 -5
- package/dest/json-rpc/server/json_rpc_server.test.js +2 -2
- package/dest/log/log_history.test.js +1 -1
- package/dest/mutex/mutex.test.d.ts.map +1 -1
- package/dest/mutex/mutex.test.js +1 -1
- package/dest/serialize/buffer_reader.d.ts +1 -1
- package/dest/serialize/buffer_reader.js +1 -1
- package/dest/serialize/buffer_reader.test.js +2 -2
- package/dest/serialize/serialize.test.js +2 -2
- package/dest/serialize/serializer.js +2 -2
- package/dest/transport/browser/shared_worker_listener.d.ts.map +1 -1
- package/dest/transport/browser/shared_worker_listener.js +1 -1
- package/dest/transport/browser/worker_listener.d.ts.map +1 -1
- package/dest/transport/browser/worker_listener.js +1 -1
- package/dest/transport/dispatch/create_dispatch_proxy.d.ts +2 -2
- package/dest/transport/dispatch/create_dispatch_proxy.d.ts.map +1 -1
- package/dest/transport/dispatch/create_dispatch_proxy.js +1 -1
- package/dest/transport/interface/listener.d.ts.map +1 -1
- package/dest/transport/node/node_connector.d.ts.map +1 -1
- package/dest/transport/node/node_connector.js +1 -1
- package/dest/transport/node/node_connector_socket.d.ts.map +1 -1
- package/dest/transport/node/node_connector_socket.js +1 -1
- package/dest/transport/node/node_listener.d.ts.map +1 -1
- package/dest/transport/node/node_listener.js +2 -2
- package/dest/transport/node/node_listener_socket.d.ts.map +1 -1
- package/dest/transport/node/node_listener_socket.js +1 -1
- package/dest/transport/transport_client.d.ts.map +1 -1
- package/dest/transport/transport_client.js +2 -2
- package/dest/wasm/wasm/wasm_module.d.ts.map +1 -1
- package/dest/wasm/wasm/wasm_module.js +2 -2
- package/dest/wasm/wasm/wasm_module.test.js +3 -3
- package/dest/wasm/worker/browser/web_data_store.d.ts.map +1 -1
- package/dest/wasm/worker/browser/web_data_store.js +1 -1
- package/dest/wasm/worker/node/node_data_store.d.ts.map +1 -1
- package/dest/wasm/worker/node/node_data_store.js +2 -2
- package/dest/wasm/worker/node/node_worker.d.ts.map +1 -1
- package/dest/wasm/worker/node/node_worker.js +2 -2
- package/dest/wasm/worker/node/start_node_module.d.ts.map +1 -1
- package/dest/wasm/worker/node/start_node_module.js +1 -1
- package/package.json +1 -1
- package/src/abi/abi.ts +147 -0
- package/src/abi/abi_coder.ts +13 -3
- package/src/abi/decoder.ts +1 -1
- package/src/abi/index.ts +1 -148
- package/src/aztec-address/index.ts +10 -0
- package/src/crypto/random/index.ts +1 -1
- package/src/crypto/sha256/index.test.ts +2 -1
- package/src/crypto/sha256/index.ts +1 -0
- package/src/fields/fields.ts +12 -2
- package/src/fields/point.ts +11 -34
- package/src/json-rpc/client/json_rpc_client.test.ts +2 -1
- package/src/json-rpc/client/json_rpc_client.ts +2 -1
- package/src/json-rpc/convert.test.ts +2 -2
- package/src/json-rpc/convert.ts +2 -1
- package/src/json-rpc/server/json_proxy.ts +1 -1
- package/src/json-rpc/server/json_rpc_server.test.ts +2 -1
- package/src/json-rpc/server/json_rpc_server.ts +5 -5
- package/src/log/log_history.test.ts +1 -0
- package/src/mutex/mutex.test.ts +1 -0
- package/src/serialize/buffer_reader.test.ts +2 -1
- package/src/serialize/buffer_reader.ts +1 -1
- package/src/serialize/serialize.test.ts +3 -3
- package/src/serialize/serializer.ts +1 -1
- package/src/transport/browser/shared_worker_listener.ts +1 -0
- package/src/transport/browser/worker_listener.ts +1 -0
- package/src/transport/dispatch/create_dispatch_proxy.ts +4 -3
- package/src/transport/interface/listener.ts +1 -0
- package/src/transport/node/node_connector.ts +1 -0
- package/src/transport/node/node_connector_socket.ts +1 -0
- package/src/transport/node/node_listener.ts +2 -1
- package/src/transport/node/node_listener_socket.ts +1 -0
- package/src/transport/transport_client.ts +3 -2
- package/src/wasm/wasm/wasm_module.test.ts +3 -2
- package/src/wasm/wasm/wasm_module.ts +3 -2
- package/src/wasm/worker/browser/web_data_store.ts +2 -1
- package/src/wasm/worker/node/node_data_store.ts +3 -2
- package/src/wasm/worker/node/node_worker.ts +2 -1
- package/src/wasm/worker/node/start_node_module.ts +2 -1
package/src/fields/point.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BufferReader } from '../serialize/buffer_reader.js';
|
|
2
|
-
import {
|
|
2
|
+
import { Fr } from './fields.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Represents a Point on an elliptic curve with x and y coordinates.
|
|
@@ -7,7 +7,7 @@ import { Coordinate } from './coordinate.js';
|
|
|
7
7
|
* converting instances to various output formats, and checking the equality of points.
|
|
8
8
|
*/
|
|
9
9
|
export class Point {
|
|
10
|
-
static ZERO = new Point(
|
|
10
|
+
static ZERO = new Point(Fr.ZERO, Fr.ZERO);
|
|
11
11
|
|
|
12
12
|
/** Used to differentiate this class from AztecAddress */
|
|
13
13
|
public readonly kind = 'point';
|
|
@@ -16,11 +16,11 @@ export class Point {
|
|
|
16
16
|
/**
|
|
17
17
|
* The point's x coordinate
|
|
18
18
|
*/
|
|
19
|
-
public readonly x:
|
|
19
|
+
public readonly x: Fr,
|
|
20
20
|
/**
|
|
21
21
|
* The point's y coordinate
|
|
22
22
|
*/
|
|
23
|
-
public readonly y:
|
|
23
|
+
public readonly y: Fr,
|
|
24
24
|
) {}
|
|
25
25
|
|
|
26
26
|
/**
|
|
@@ -30,7 +30,7 @@ export class Point {
|
|
|
30
30
|
*/
|
|
31
31
|
static random() {
|
|
32
32
|
// TODO is this a random point on the curve?
|
|
33
|
-
return new Point(
|
|
33
|
+
return new Point(Fr.random(), Fr.random());
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
@@ -42,17 +42,7 @@ export class Point {
|
|
|
42
42
|
*/
|
|
43
43
|
static fromBuffer(buffer: Buffer | BufferReader) {
|
|
44
44
|
const reader = BufferReader.asReader(buffer);
|
|
45
|
-
return new this(
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Creates a point instance from its x and y coordinates.
|
|
50
|
-
* @param x - X coordinate.
|
|
51
|
-
* @param y - Y coordinate.
|
|
52
|
-
* @returns A Point instance.
|
|
53
|
-
*/
|
|
54
|
-
static fromCoordinates(x: Coordinate, y: Coordinate) {
|
|
55
|
-
return new this(x, y);
|
|
45
|
+
return new this(Fr.fromBuffer(reader.readBytes(32)), Fr.fromBuffer(reader.readBytes(32)));
|
|
56
46
|
}
|
|
57
47
|
|
|
58
48
|
/**
|
|
@@ -68,22 +58,11 @@ export class Point {
|
|
|
68
58
|
}
|
|
69
59
|
|
|
70
60
|
/**
|
|
71
|
-
*
|
|
72
|
-
* The
|
|
73
|
-
* This method is useful for serialization and deserialization of the Point object.
|
|
74
|
-
*
|
|
75
|
-
* @returns A Buffer representation of the Point instance.
|
|
76
|
-
*/
|
|
77
|
-
toFieldsBuffer() {
|
|
78
|
-
return Buffer.concat([this.x.toFieldsBuffer(), this.y.toFieldsBuffer()]);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Returns the contents of the point as an array of 4 fields.
|
|
83
|
-
* @returns The point as an array of 4 fields
|
|
61
|
+
* Returns the contents of the point as an array of 2 fields.
|
|
62
|
+
* @returns The point as an array of 2 fields
|
|
84
63
|
*/
|
|
85
64
|
toFields() {
|
|
86
|
-
return this.x
|
|
65
|
+
return [this.x, this.y];
|
|
87
66
|
}
|
|
88
67
|
|
|
89
68
|
/**
|
|
@@ -91,11 +70,9 @@ export class Point {
|
|
|
91
70
|
* @returns The point as BigInts
|
|
92
71
|
*/
|
|
93
72
|
toBigInts() {
|
|
94
|
-
const x = this.x.toBigInt();
|
|
95
|
-
const y = this.y.toBigInt();
|
|
96
73
|
return {
|
|
97
|
-
x,
|
|
98
|
-
y,
|
|
74
|
+
x: this.x.value,
|
|
75
|
+
y: this.y.value,
|
|
99
76
|
};
|
|
100
77
|
}
|
|
101
78
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import request from 'supertest';
|
|
2
|
+
|
|
3
|
+
import { TestNote, TestState } from '../fixtures/test_state.js';
|
|
2
4
|
import { JsonRpcServer } from '../server/json_rpc_server.js';
|
|
3
|
-
import { TestState, TestNote } from '../fixtures/test_state.js';
|
|
4
5
|
import { createJsonRpcClient } from './json_rpc_client.js';
|
|
5
6
|
|
|
6
7
|
test('test an RPC function over client', async () => {
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
// This takes a {foo(): T} and makes {foo(): Promise<T>}
|
|
4
4
|
// while avoiding Promise of Promise.
|
|
5
5
|
import { RemoteObject } from 'comlink';
|
|
6
|
+
|
|
6
7
|
import { createDebugLogger } from '../../log/index.js';
|
|
7
8
|
import { retry } from '../../retry/index.js';
|
|
8
|
-
import { ClassConverter,
|
|
9
|
+
import { ClassConverter, JsonClassConverterInput, StringClassConverterInput } from '../class_converter.js';
|
|
9
10
|
import { JsonStringify, convertFromJsonObj, convertToJsonObj } from '../convert.js';
|
|
10
11
|
|
|
11
12
|
export { JsonStringify } from '../convert.js';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { Buffer } from 'buffer';
|
|
2
|
+
|
|
1
3
|
import { ClassConverter } from './class_converter.js';
|
|
2
4
|
import { convertFromJsonObj, convertToJsonObj } from './convert.js';
|
|
3
5
|
import { TestNote } from './fixtures/test_state.js';
|
|
4
6
|
|
|
5
|
-
import { Buffer } from 'buffer';
|
|
6
|
-
|
|
7
7
|
const TEST_BASE64 = 'YmFzZTY0IGRlY29kZXI=';
|
|
8
8
|
test('test an RPC function over client', () => {
|
|
9
9
|
const cc = new ClassConverter({ TestNote });
|
package/src/json-rpc/convert.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { ClassConverter } from './class_converter.js';
|
|
2
1
|
import { Buffer } from 'buffer';
|
|
3
2
|
|
|
3
|
+
import { ClassConverter } from './class_converter.js';
|
|
4
|
+
|
|
4
5
|
/**
|
|
5
6
|
* Recursively looks through an object for bigints and converts them to object format.
|
|
6
7
|
* @param obj - The object to convert.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createDebugLogger } from '../../log/index.js';
|
|
2
|
-
import { ClassConverter,
|
|
2
|
+
import { ClassConverter, JsonClassConverterInput, StringClassConverterInput } from '../class_converter.js';
|
|
3
3
|
import { convertFromJsonObj, convertToJsonObj } from '../convert.js';
|
|
4
4
|
import { assert, hasOwnProperty } from '../js_utils.js';
|
|
5
5
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import request from 'supertest';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import { TestNote, TestState } from '../fixtures/test_state.js';
|
|
3
4
|
import { JsonRpcServer } from './json_rpc_server.js';
|
|
4
5
|
|
|
5
6
|
test('test an RPC function with a primitive parameter', async () => {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import http from 'http';
|
|
2
|
-
import Router from 'koa-router';
|
|
3
1
|
import cors from '@koa/cors';
|
|
4
|
-
import
|
|
2
|
+
import http from 'http';
|
|
5
3
|
import Koa from 'koa';
|
|
6
4
|
import bodyParser from 'koa-bodyparser';
|
|
5
|
+
import compress from 'koa-compress';
|
|
6
|
+
import Router from 'koa-router';
|
|
7
7
|
|
|
8
8
|
import { createLogger } from '../../log/index.js';
|
|
9
|
-
import {
|
|
10
|
-
import { JsonProxy } from './json_proxy.js';
|
|
9
|
+
import { JsonClassConverterInput, StringClassConverterInput } from '../class_converter.js';
|
|
11
10
|
import { convertBigintsInObj } from '../convert.js';
|
|
11
|
+
import { JsonProxy } from './json_proxy.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* JsonRpcServer.
|
package/src/mutex/mutex.test.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jest } from '@jest/globals';
|
|
2
|
+
|
|
3
|
+
import { randomBytes } from '../crypto/index.js';
|
|
2
4
|
import { Fq, Fr } from '../fields/fields.js';
|
|
3
5
|
import { BufferReader } from './buffer_reader.js';
|
|
4
6
|
import { serializeBufferArrayToVector } from './free_funcs.js';
|
|
5
|
-
import { randomBytes } from '../crypto/index.js';
|
|
6
7
|
|
|
7
8
|
const ARRAY = Array.from(Array(32)).map((_, idx) => (idx % 2 === 0 ? 0 : 1));
|
|
8
9
|
const BUFFER = Buffer.from(ARRAY);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { randomBytes } from '../crypto/index.js';
|
|
2
2
|
import { Fr } from '../fields/fields.js';
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
deserializeArrayFromVector,
|
|
5
5
|
deserializeBufferFromVector,
|
|
6
|
-
deserializeUInt32,
|
|
7
6
|
deserializeField,
|
|
7
|
+
deserializeUInt32,
|
|
8
8
|
serializeBufferArrayToVector,
|
|
9
|
-
|
|
9
|
+
serializeBufferToVector,
|
|
10
10
|
} from './index.js';
|
|
11
11
|
|
|
12
12
|
describe('serialize', () => {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { serializeBufferArrayToVector } from './index.js';
|
|
2
1
|
import {
|
|
3
2
|
boolToByte,
|
|
4
3
|
numToInt32BE,
|
|
@@ -7,6 +6,7 @@ import {
|
|
|
7
6
|
serializeBufferToVector,
|
|
8
7
|
serializeDate,
|
|
9
8
|
} from './free_funcs.js';
|
|
9
|
+
import { serializeBufferArrayToVector } from './index.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* The Serializer class provides a convenient and efficient way to serialize various data types into binary format.
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { DispatchMsg } from './create_dispatch_fn.js';
|
|
2
|
-
import { TransportClient } from '../transport_client.js';
|
|
3
1
|
import { EventEmitter } from 'events';
|
|
4
|
-
|
|
2
|
+
|
|
3
|
+
import { TransferDescriptor, isTransferDescriptor } from '../interface/transferable.js';
|
|
4
|
+
import { TransportClient } from '../transport_client.js';
|
|
5
|
+
import { DispatchMsg } from './create_dispatch_fn.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* FilterOutAttributes type filters out all non-method properties of an object, leaving only the attributes
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import EventEmitter from 'events';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import { createDebugLogger } from '../log/index.js';
|
|
4
|
+
import { EventMessage, ResponseMessage, isEventMessage } from './dispatch/messages.js';
|
|
3
5
|
import { Connector } from './interface/connector.js';
|
|
4
6
|
import { Socket } from './interface/socket.js';
|
|
5
|
-
import { createDebugLogger } from '../log/index.js';
|
|
6
7
|
|
|
7
8
|
const debug = createDebugLogger('aztec:transport_client');
|
|
8
9
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { WasmModule } from './wasm_module.js';
|
|
2
|
-
import { fileURLToPath } from 'url';
|
|
3
1
|
import { readFile } from 'fs/promises';
|
|
4
2
|
import { dirname } from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
|
|
5
|
+
import { WasmModule } from './wasm_module.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Fetch a simple WASM.
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Buffer } from 'buffer';
|
|
2
2
|
import { randomBytes } from 'crypto';
|
|
3
|
-
|
|
4
|
-
import { getEmptyWasiSdk } from './empty_wasi_sdk.js';
|
|
3
|
+
|
|
5
4
|
import { MemoryFifo } from '../../fifo/index.js';
|
|
5
|
+
import { DebugLogger, createDebugLogger } from '../../log/index.js';
|
|
6
|
+
import { getEmptyWasiSdk } from './empty_wasi_sdk.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* The base shape of a WASM module providing low level memory and synchronous call access.
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { DataStore } from '../data_store.js';
|
|
2
|
-
import levelup, { LevelUp } from 'levelup';
|
|
3
1
|
import leveldown from 'leveldown';
|
|
2
|
+
import levelup, { LevelUp } from 'levelup';
|
|
4
3
|
import memdown from 'memdown';
|
|
5
4
|
|
|
5
|
+
import { DataStore } from '../data_store.js';
|
|
6
|
+
|
|
6
7
|
/**
|
|
7
8
|
* Cache for data used by wasm module.
|
|
8
9
|
*/
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Worker } from 'worker_threads';
|
|
2
|
+
|
|
3
|
+
import { DispatchMsg, NodeConnector, TransportClient, createDispatchProxy } from '../../../transport/index.js';
|
|
2
4
|
import { WasmModule } from '../../wasm/wasm_module.js';
|
|
3
5
|
import { WasmWorker } from '../wasm_worker.js';
|
|
4
|
-
import { DispatchMsg, NodeConnector, TransportClient, createDispatchProxy } from '../../../transport/index.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Creates a node worker.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { parentPort } from 'worker_threads';
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import { DispatchMsg, NodeListener, TransportServer } from '../../../transport/index.js';
|
|
4
|
+
import { WasmModule } from '../../wasm/wasm_module.js';
|
|
4
5
|
|
|
5
6
|
if (!parentPort) {
|
|
6
7
|
throw new Error('InvalidWorker');
|