@aztec/foundation 0.1.0-alpha42 → 0.1.0-alpha44

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.
Files changed (34) hide show
  1. package/.tsbuildinfo +1 -1
  2. package/dest/abi/abi.d.ts +91 -0
  3. package/dest/abi/abi.d.ts.map +1 -1
  4. package/dest/abi/abi.js +19 -1
  5. package/dest/committable/committable.d.ts +28 -0
  6. package/dest/committable/committable.d.ts.map +1 -0
  7. package/dest/committable/committable.js +41 -0
  8. package/dest/committable/committable.test.d.ts +2 -0
  9. package/dest/committable/committable.test.d.ts.map +1 -0
  10. package/dest/committable/committable.test.js +26 -0
  11. package/dest/committable/index.d.ts +2 -0
  12. package/dest/committable/index.d.ts.map +1 -0
  13. package/dest/committable/index.js +2 -0
  14. package/dest/json-rpc/client/index.d.ts +1 -1
  15. package/dest/json-rpc/client/index.d.ts.map +1 -1
  16. package/dest/json-rpc/client/index.js +2 -2
  17. package/dest/json-rpc/client/json_rpc_client.d.ts +0 -8
  18. package/dest/json-rpc/client/json_rpc_client.d.ts.map +1 -1
  19. package/dest/json-rpc/client/json_rpc_client.js +1 -14
  20. package/dest/json-rpc/convert.d.ts.map +1 -1
  21. package/dest/json-rpc/convert.js +6 -12
  22. package/dest/json-rpc/convert.test.js +11 -2
  23. package/dest/json-rpc/server/json_rpc_server.d.ts.map +1 -1
  24. package/dest/json-rpc/server/json_rpc_server.js +5 -3
  25. package/package.json +4 -2
  26. package/src/abi/abi.ts +114 -0
  27. package/src/committable/committable.test.ts +32 -0
  28. package/src/committable/committable.ts +46 -0
  29. package/src/committable/index.ts +1 -0
  30. package/src/json-rpc/client/index.ts +1 -7
  31. package/src/json-rpc/client/json_rpc_client.ts +0 -20
  32. package/src/json-rpc/convert.test.ts +12 -1
  33. package/src/json-rpc/convert.ts +5 -10
  34. package/src/json-rpc/server/json_rpc_server.ts +6 -3
@@ -1,7 +1,7 @@
1
1
  import { Buffer } from 'buffer';
2
2
 
3
3
  import { ClassConverter } from './class_converter.js';
4
- import { convertFromJsonObj, convertToJsonObj } from './convert.js';
4
+ import { convertBigintsInObj, convertFromJsonObj, convertToJsonObj } from './convert.js';
5
5
  import { TestNote } from './fixtures/test_state.js';
6
6
 
7
7
  const TEST_BASE64 = 'YmFzZTY0IGRlY29kZXI=';
@@ -13,3 +13,14 @@ test('test an RPC function over client', () => {
13
13
  expect(convertFromJsonObj(cc, convertToJsonObj(cc, note))).toBeInstanceOf(TestNote);
14
14
  expect(convertFromJsonObj(cc, convertToJsonObj(cc, note)).toString()).toBe('1');
15
15
  });
16
+
17
+ test('converts a bigint', () => {
18
+ expect(convertBigintsInObj(10n)).toEqual({ type: 'bigint', data: '10' });
19
+ expect(convertBigintsInObj({ value: 10n })).toEqual({ value: { type: 'bigint', data: '10' } });
20
+ expect(convertBigintsInObj([10n])).toEqual([{ type: 'bigint', data: '10' }]);
21
+ });
22
+
23
+ test('does not convert a string', () => {
24
+ expect(convertBigintsInObj('hello')).toEqual('hello');
25
+ expect(convertBigintsInObj({ msg: 'hello' })).toEqual({ msg: 'hello' });
26
+ });
@@ -1,4 +1,5 @@
1
1
  import { Buffer } from 'buffer';
2
+ import cloneDeepWith from 'lodash.clonedeepwith';
2
3
 
3
4
  import { ClassConverter } from './class_converter.js';
4
5
 
@@ -8,17 +9,11 @@ import { ClassConverter } from './class_converter.js';
8
9
  * @returns The converted object with stringified bigints.
9
10
  */
10
11
  export const convertBigintsInObj = (obj: any) => {
11
- for (const i in obj) {
12
- if (typeof obj[i] === 'bigint') {
13
- obj[i] = {
14
- type: 'bigint',
15
- data: obj[i].toString(),
16
- };
17
- } else if (typeof obj[i] === 'object') {
18
- convertBigintsInObj(obj[i]);
12
+ return cloneDeepWith(obj, (value: any) => {
13
+ if (typeof value === 'bigint') {
14
+ return { type: 'bigint', data: value.toString() };
19
15
  }
20
- }
21
- return obj;
16
+ });
22
17
  };
23
18
 
24
19
  /**
@@ -45,10 +45,14 @@ export class JsonRpcServer {
45
45
  };
46
46
  const app = new Koa();
47
47
  app.on('error', error => {
48
- this.log.error(`KOA app-level error. ${JSON.stringify({ error })}`);
48
+ this.log.error(`Error on API handler: ${error}`);
49
49
  });
50
50
  app.use(compress({ br: false } as any));
51
- app.use(bodyParser());
51
+ app.use(
52
+ bodyParser({
53
+ jsonLimit: '10mb',
54
+ }),
55
+ );
52
56
  app.use(cors());
53
57
  app.use(exceptionHandler);
54
58
  app.use(router.routes());
@@ -111,7 +115,6 @@ export class JsonRpcServer {
111
115
  } else {
112
116
  try {
113
117
  const result = await this.proxy.call(method, params);
114
-
115
118
  ctx.body = {
116
119
  jsonrpc,
117
120
  id,