Skip to content
This repository has been archived by the owner on Mar 16, 2023. It is now read-only.

Commit

Permalink
fix(aztec.js): fix node build
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud Schenk committed Jul 16, 2020
1 parent 9aa5691 commit a193dc1
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
6 changes: 4 additions & 2 deletions packages/aztec.js/src/note/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 0 additions & 3 deletions packages/aztec.js/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,4 @@ module.exports = {
maxAssetSize: 200000,
maxEntrypointSize: 400000,
},
resolve: {
extensions: ['.js', '.json'],
},
};
16 changes: 16 additions & 0 deletions packages/aztec.js/webpack.dev.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const merge = require('webpack-merge');
const CopyWebpackPlugin = require('copy-webpack-plugin');

const common = require('./webpack.common.js');

const config = {
Expand All @@ -14,13 +16,27 @@ 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, {
...config,
node: { crypto: true, fs: 'empty' },
output: { filename: 'bundle.web.js' },
target: 'web',
resolve: {
extensions: ['.js', '.json'],
},
});

module.exports = [nodeConfig, webConfig];
17 changes: 16 additions & 1 deletion packages/aztec.js/webpack.prod.js
Original file line number Diff line number Diff line change
@@ -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, {
Expand All @@ -14,13 +15,27 @@ 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, {
...config,
node: { crypto: true, fs: 'empty' },
output: { filename: 'bundle.web.js' },
target: 'web',
resolve: {
extensions: ['.js', '.json'],
},
});

module.exports = [nodeConfig, webConfig];

0 comments on commit a193dc1

Please sign in to comment.