From a193dc15777937e5822703519c549dfb9f0f6b66 Mon Sep 17 00:00:00 2001 From: Arnaud Schenk Date: Thu, 16 Jul 2020 17:45:17 +0100 Subject: [PATCH 1/2] fix(aztec.js): fix node build --- packages/aztec.js/src/note/index.js | 6 ++++-- packages/aztec.js/webpack.common.js | 3 --- packages/aztec.js/webpack.dev.js | 16 ++++++++++++++++ packages/aztec.js/webpack.prod.js | 17 ++++++++++++++++- 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/packages/aztec.js/src/note/index.js b/packages/aztec.js/src/note/index.js index f27d02e7f..192592708 100644 --- a/packages/aztec.js/src/note/index.js +++ b/packages/aztec.js/src/note/index.js @@ -307,10 +307,12 @@ export function encodeMetadata(noteArray) { * @returns {Note} created note instance */ export async function fromEventLog(logNoteData, spendingKey = null) { - const publicKey = noteCoder.decodeNoteFromEventLog(logNoteData); - const newNote = new Note(publicKey, null); + const notePublicKey = noteCoder.decodeNoteFromEventLog(logNoteData); + const newNote = new Note(notePublicKey, null); if (spendingKey) { await newNote.derive(spendingKey); + const { publicKey } = secp256k1.accountFromPrivateKey(spendingKey); + newNote.owner = publicKey; } return newNote; } diff --git a/packages/aztec.js/webpack.common.js b/packages/aztec.js/webpack.common.js index 79807ccc0..c9b31ebd2 100644 --- a/packages/aztec.js/webpack.common.js +++ b/packages/aztec.js/webpack.common.js @@ -37,7 +37,4 @@ module.exports = { maxAssetSize: 200000, maxEntrypointSize: 400000, }, - resolve: { - extensions: ['.js', '.json'], - }, }; diff --git a/packages/aztec.js/webpack.dev.js b/packages/aztec.js/webpack.dev.js index 3262e0bd3..3c90084a2 100644 --- a/packages/aztec.js/webpack.dev.js +++ b/packages/aztec.js/webpack.dev.js @@ -1,4 +1,6 @@ const merge = require('webpack-merge'); +const CopyWebpackPlugin = require('copy-webpack-plugin'); + const common = require('./webpack.common.js'); const config = { @@ -14,6 +16,17 @@ const nodeConfig = merge(common, { }, output: { filename: 'bundle.node.js' }, target: 'node', + plugins: [ + new CopyWebpackPlugin([ + { + from: 'node_modules/@aztec/bn128/**/*.wasm', + to: '[name].[ext]', + }, + ]), + ], + resolve: { + extensions: ['.js', '.json', '.wasm'], + }, }); const webConfig = merge(common, { @@ -21,6 +34,9 @@ const webConfig = merge(common, { node: { crypto: true, fs: 'empty' }, output: { filename: 'bundle.web.js' }, target: 'web', + resolve: { + extensions: ['.js', '.json'], + }, }); module.exports = [nodeConfig, webConfig]; diff --git a/packages/aztec.js/webpack.prod.js b/packages/aztec.js/webpack.prod.js index b3b78a8df..5a6aa4492 100644 --- a/packages/aztec.js/webpack.prod.js +++ b/packages/aztec.js/webpack.prod.js @@ -1,9 +1,10 @@ const merge = require('webpack-merge'); +const CopyWebpackPlugin = require('copy-webpack-plugin'); const common = require('./webpack.common.js'); const config = { mode: 'production', - devtool: '', + devtool: 'inline-source-map', }; const nodeConfig = merge(common, { @@ -14,6 +15,17 @@ const nodeConfig = merge(common, { }, output: { filename: 'bundle.node.js' }, target: 'node', + plugins: [ + new CopyWebpackPlugin([ + { + from: 'node_modules/@aztec/bn128/**/*.wasm', + to: '[name].[ext]', + }, + ]), + ], + resolve: { + extensions: ['.js', '.json', '.wasm'], + }, }); const webConfig = merge(common, { @@ -21,6 +33,9 @@ const webConfig = merge(common, { node: { crypto: true, fs: 'empty' }, output: { filename: 'bundle.web.js' }, target: 'web', + resolve: { + extensions: ['.js', '.json'], + }, }); module.exports = [nodeConfig, webConfig]; From 2d364218cc00535a4b7cf56ca8c51436884c2d36 Mon Sep 17 00:00:00 2001 From: Arnaud Schenk Date: Mon, 20 Jul 2020 11:56:30 +0100 Subject: [PATCH 2/2] fix(aztec.js): save the owner address instead of public key --- packages/aztec.js/src/note/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/aztec.js/src/note/index.js b/packages/aztec.js/src/note/index.js index 192592708..dcee0336d 100644 --- a/packages/aztec.js/src/note/index.js +++ b/packages/aztec.js/src/note/index.js @@ -311,8 +311,8 @@ export async function fromEventLog(logNoteData, spendingKey = null) { const newNote = new Note(notePublicKey, null); if (spendingKey) { await newNote.derive(spendingKey); - const { publicKey } = secp256k1.accountFromPrivateKey(spendingKey); - newNote.owner = publicKey; + const { address } = secp256k1.accountFromPrivateKey(spendingKey); + newNote.owner = address; } return newNote; }