Skip to content

Commit 5eec896

Browse files
author
HenryNguyen5
authored
Refactor Lerna + Workspaces (#25)
* Migrate src -> packages, seperate tsconfig for tests * Get yarn workspaces up and working * Fix cyclic dependencies and import errors Unfortunately, this ended up with a couple packages being merged into xmr-crypto-utils, along with messing up some of the type file locations. Annnnd some imports are exposed pretty ugily via xmr-crypto-utils. * Update package versions, yarn lock * Add lerna * Update package * Add publish command * Fix circular deps * Fix package links * Fix ledger scramble key * Change output to commonjs * Target es5 * Remove internal dep
1 parent 7207033 commit 5eec896

File tree

224 files changed

+6242
-4540
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

224 files changed

+6242
-4540
lines changed

README.md

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# xmr-core
1+
# @xmr-core/xmr-core
22

33
Forked from mymonero/mymonero-core-js, this library provides a few significant changes compared to its origin:
44

@@ -22,29 +22,27 @@ Below you'll find each package and its purpose.
2222

2323
## Features
2424

25-
- `xmr-address-utils` Utilities for working with Monero addresses
26-
- `xmr-b58` xmr-b58 contains functions to encode and decode base58 strings for monero operations
27-
- `xmr-cli` xmr-cli contains basic user operations that use the mono-repo packages for its functionality
28-
- `xmr-constants` xmr-constants contains constant declarations for working with Monero, such as address prefixes, blocktimes, and decimal places
29-
- `xmr-crypto-ops` Core crypto operations for Monero
30-
- `xmr-device` Implementations and interfaces of various hardware devices for creating Monero transactions securely
31-
- `xmr-fast-hash` An implementation of Monero's `cn_fast_hash`
32-
- `xmr-key-utils` A collection of functions for creating and verifying Monero related public/private keys.
33-
- `xmr-keyimg-memoized` Memoized key image generation library
34-
- `xmr-money` Helpers for formatting and parsing Moneroj.
35-
- `xmr-mymonero-libs` A collection of utilities for building ontop of a MyMonero compatible API
36-
- `xmr-nettype-address-prefixes` Helper library to get Monero address prefixes depending on the network type (mainnet|testnet|stagenet)
37-
- `xmr-pid` Validate, create, and manipulate, Monero payment ids
38-
- `xmr-rand` Create random hex strings for Monero operations
39-
- `xmr-str-utils` A library for working with strings commonly used in other Monero libraries
40-
- `xmr-transaction` Create Monero transactions and check their status
41-
- `xmr-types` A pure types library that contains shared interfaces and types for the xmr-core mono-repo
42-
- `xmr-varint` Create varints from numbers and strings for usage in Monero's data structures
43-
- `xmr-vendor` A container library that holds external dependencies that have been modified for usage in Monero transaction creation / validation
25+
- `@xmr-core/xmr-b58` @xmr-core/xmr-b58 contains functions to encode and decode base58 strings for monero operations
26+
- `@xmr-core/xmr-cli` @xmr-core/xmr-cli contains basic user operations that use the mono-repo packages for its functionality
27+
- `@xmr-core/xmr-constants` @xmr-core/xmr-constants contains constant declarations for working with Monero, such as address prefixes, blocktimes, and decimal places
28+
- `@xmr-core/xmr-crypto-utils` Core crypto operations for Monero
29+
- Utilities for working with Monero addresses
30+
- Implementations and interfaces of various hardware devices for creating Monero transactions securely
31+
- A collection of functions for creating and verifying Monero related public/private keys.
32+
- Validate, create, and manipulate, Monero payment ids
33+
- Create random hex strings for Monero operations
34+
- Get Monero address prefixes depending on the network type (mainnet|testnet|stagenet)
35+
- `@xmr-core/xmr-fast-hash` An implementation of Monero's `cn_fast_hash`
36+
- `@xmr-core/xmr-money` Helpers for formatting and parsing Moneroj.
37+
- `@xmr-core/xmr-mymonero-libs` A collection of utilities for building ontop of a MyMonero compatible API
38+
- `@xmr-core/xmr-str-utils` A library for working with strings commonly used in other Monero libraries
39+
- `@xmr-core/xmr-transaction` Create Monero transactions and check their status
40+
- `@xmr-core/xmr-varint` Create varints from numbers and strings for usage in Monero's data structures
41+
- `@xmr-core/xmr-vendor` A container library that holds external dependencies that have been modified for usage in Monero transaction creation / validation
4442

4543
## Usage
4644

47-
The most common use case would be under the domain of a wallet service implementing xmr support. To see basic examples on how this would be done, take a look at the `xmr-cli` package to do basic operations such as sending currency and checking a users balance.
45+
The most common use case would be under the domain of a wallet service implementing xmr support. To see basic examples on how this would be done, take a look at the `@xmr-core/xmr-cli` package to do basic operations such as sending currency and checking a users balance.
4846

4947
# Contributing
5048

@@ -70,4 +68,4 @@ We'll merge nearly anything constructive. Contributors welcome and credited in r
7068

7169
- 🔒 `cryptochangement` Subaddress send & decode support; Initial tests
7270

73-
- 💩 `henrynguyen5` Code quality, modernization, tests; HW wallet support _(in progress)_
71+
- 💩 `henrynguyen5` Code quality, modernization, tests; HW wallet support

__test__/borromean/borromean_1.spec.ts

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,7 @@ import { generate_parameters } from "./test_parameters";
22
import {
33
genBorromean,
44
verifyBorromean,
5-
} from "xmr-transaction/libs/ringct/components/prove_range/borromean";
6-
7-
// Copyright (c) 2014-2018, MyMonero.com
8-
//
9-
// All rights reserved.
10-
//
11-
// Redistribution and use in source and binary forms, with or without modification, are
12-
// permitted provided that the following conditions are met:
13-
//
14-
// 1. Redistributions of source code must retain the above copyright notice, this list of
15-
// conditions and the following disclaimer.
16-
//
17-
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
18-
// of conditions and the following disclaimer in the documentation and/or other
19-
// materials provided with the distribution.
20-
//
21-
// 3. Neither the name of the copyright holder nor the names of its contributors may be
22-
// used to endorse or promote products derived from this software without specific
23-
// prior written permission.
24-
//
25-
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
26-
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
27-
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
28-
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29-
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
30-
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31-
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
32-
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
33-
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5+
} from "xmr-transaction/src/libs/ringct/components/prove_range";
346

357
const { indi, P1v, P2v, xv } = generate_parameters();
368

__test__/borromean/borromean_2.spec.ts

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,8 @@
1-
// Copyright (c) 2014-2018, MyMonero.com
2-
//
3-
// All rights reserved.
4-
//
5-
// Redistribution and use in source and binary forms, with or without modification, are
6-
// permitted provided that the following conditions are met:
7-
//
8-
// 1. Redistributions of source code must retain the above copyright notice, this list of
9-
// conditions and the following disclaimer.
10-
//
11-
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
12-
// of conditions and the following disclaimer in the documentation and/or other
13-
// materials provided with the distribution.
14-
//
15-
// 3. Neither the name of the copyright holder nor the names of its contributors may be
16-
// used to endorse or promote products derived from this software without specific
17-
// prior written permission.
18-
//
19-
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20-
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21-
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22-
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23-
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24-
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25-
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26-
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27-
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28-
291
import { generate_parameters } from "./test_parameters";
302
import {
313
genBorromean,
324
verifyBorromean,
33-
} from "xmr-transaction/libs/ringct/components/prove_range/borromean";
5+
} from "xmr-transaction/src/libs/ringct/components/prove_range";
346

357
const { indi, P1v, P2v, xv } = generate_parameters();
368

__test__/borromean/borromean_3.spec.ts

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,8 @@
1-
// Copyright (c) 2014-2018, MyMonero.com
2-
//
3-
// All rights reserved.
4-
//
5-
// Redistribution and use in source and binary forms, with or without modification, are
6-
// permitted provided that the following conditions are met:
7-
//
8-
// 1. Redistributions of source code must retain the above copyright notice, this list of
9-
// conditions and the following disclaimer.
10-
//
11-
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
12-
// of conditions and the following disclaimer in the documentation and/or other
13-
// materials provided with the distribution.
14-
//
15-
// 3. Neither the name of the copyright holder nor the names of its contributors may be
16-
// used to endorse or promote products derived from this software without specific
17-
// prior written permission.
18-
//
19-
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20-
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21-
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22-
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23-
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24-
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25-
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26-
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27-
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28-
291
import { generate_parameters } from "./test_parameters";
302
import {
313
genBorromean,
324
verifyBorromean,
33-
} from "xmr-transaction/libs/ringct/components/prove_range/borromean";
5+
} from "xmr-transaction/src/libs/ringct/components/prove_range";
346

357
const { indi, P1v, P2v, xv } = generate_parameters();
368

__test__/borromean/borromean_4.spec.ts

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,8 @@
1-
// Copyright (c) 2014-2018, MyMonero.com
2-
//
3-
// All rights reserved.
4-
//
5-
// Redistribution and use in source and binary forms, with or without modification, are
6-
// permitted provided that the following conditions are met:
7-
//
8-
// 1. Redistributions of source code must retain the above copyright notice, this list of
9-
// conditions and the following disclaimer.
10-
//
11-
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
12-
// of conditions and the following disclaimer in the documentation and/or other
13-
// materials provided with the distribution.
14-
//
15-
// 3. Neither the name of the copyright holder nor the names of its contributors may be
16-
// used to endorse or promote products derived from this software without specific
17-
// prior written permission.
18-
//
19-
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20-
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21-
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22-
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23-
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24-
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25-
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26-
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27-
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28-
291
import {
302
genBorromean,
313
verifyBorromean,
32-
} from "xmr-transaction/libs/ringct/components/prove_range/borromean";
4+
} from "xmr-transaction/src/libs/ringct/components/prove_range";
5+
336
import { generate_parameters } from "./test_parameters";
347
const { indi, P1v, P2v, xv } = generate_parameters();
358

__test__/borromean/test_parameters.ts

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,12 @@
1-
// Copyright (c) 2014-2018, MyMonero.com
2-
//
3-
// All rights reserved.
4-
//
5-
// Redistribution and use in source and binary forms, with or without modification, are
6-
// permitted provided that the following conditions are met:
7-
//
8-
// 1. Redistributions of source code must retain the above copyright notice, this list of
9-
// conditions and the following disclaimer.
10-
//
11-
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
12-
// of conditions and the following disclaimer in the documentation and/or other
13-
// materials provided with the distribution.
14-
//
15-
// 3. Neither the name of the copyright holder nor the names of its contributors may be
16-
// used to endorse or promote products derived from this software without specific
17-
// prior written permission.
18-
//
19-
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20-
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21-
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22-
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23-
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24-
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25-
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26-
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27-
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28-
291
import { randomBytes } from "crypto";
30-
import { padLeft } from "xmr-str-utils/std-strings";
31-
import { skGen } from "xmr-key-utils";
2+
import { padLeft } from "xmr-str-utils/src/std-strings";
3+
import { skGen } from "xmr-crypto-utils/src";
324
import {
335
ge_scalarmult_base,
346
ge_add,
357
ge_sub,
36-
} from "xmr-crypto-ops/primitive_ops";
37-
import { H2 } from "xmr-crypto-ops/constants";
8+
} from "xmr-crypto-utils/src/crypto-ops/primitive_ops";
9+
import { H2 } from "xmr-crypto-utils/src/crypto-ops/constants";
3810

3911
function randomBit() {
4012
// get random 8 bits in hex

__test__/cryptonote_utils.spec.ts renamed to __test__/cryptonote/cryptonote_utils.spec.ts

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,13 @@
1-
import { valid_hex } from "xmr-str-utils/hex-strings";
2-
import { NetType } from "xmr-types";
3-
import { cn_fast_hash } from "xmr-fast-hash";
1+
import { valid_hex } from "xmr-str-utils/src/hex-strings";
2+
import { cn_fast_hash } from "xmr-fast-hash/src";
3+
import { decode_address, NetType } from "xmr-crypto-utils/src/address-utils";
44
import {
55
generate_key_derivation,
66
derivation_to_scalar,
77
derive_public_key,
88
derive_subaddress_public_key,
9-
} from "xmr-crypto-ops/derivation";
10-
import { decode_address } from "xmr-address-utils";
11-
import { hash_to_scalar } from "xmr-crypto-ops/hash_ops";
12-
13-
// Copyright (c) 2014-2018, MyMonero.com
14-
//
15-
// All rights reserved.
16-
//
17-
// Redistribution and use in source and binary forms, with or without modification, are
18-
// permitted provided that the following conditions are met:
19-
//
20-
// 1. Redistributions of source code must retain the above copyright notice, this list of
21-
// conditions and the following disclaimer.
22-
//
23-
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
24-
// of conditions and the following disclaimer in the documentation and/or other
25-
// materials provided with the distribution.
26-
//
27-
// 3. Neither the name of the copyright holder nor the names of its contributors may be
28-
// used to endorse or promote products derived from this software without specific
29-
// prior written permission.
30-
//
31-
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
32-
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
33-
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
34-
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35-
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
36-
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
37-
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
38-
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
39-
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9+
} from "@xmr-core/xmr-crypto-utils/lib/crypto-ops/derivation";
10+
import { hash_to_scalar } from "@xmr-core/xmr-crypto-utils/lib/crypto-ops/hash_ops";
4011

4112
const public_key =
4213
"904e49462268d771cc1649084c35aa1296bfb214880fe2e7f373620a3e2ba597";

__test__/device/ledger/unspent-outs.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import TransportNodeHid from "@ledgerhq/hw-transport-node-hid";
2-
import { LedgerDevice } from "xmr-device";
2+
import { LedgerDevice } from "@xmr-core/xmr-crypto-utils";
33
import { MockApi } from "../../sendfunds/mockApi";
4-
import { JSONPretty } from "../../utils/formatters";
4+
import { JSONPretty } from "@xmr-core/xmr-str-utils";
5+
56
jest.setTimeout(1000 * 60 * 60);
67

78
describe("ledger tests", () => {

__test__/ecdh.spec.ts

Lines changed: 0 additions & 68 deletions
This file was deleted.

0 commit comments

Comments
 (0)