@ledgerhq/zcash-shielded 0.1.1-nightly.20251217131814

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.
@@ -0,0 +1,4 @@
1
+
2
+ > @ledgerhq/zcash-shielded@0.1.0 build /home/runner/work/ledger-live/ledger-live/libs/coin-modules/zcash-shielded
3
+ > tsc && tsc -m esnext --moduleResolution bundler --outDir lib-es
4
+
@@ -0,0 +1,16 @@
1
+ {
2
+ "entry": [
3
+ "src/ZCash.ts"
4
+ ],
5
+ "ignorePatterns": [
6
+ "**/node_modules/**",
7
+ "**/*.fixture.ts",
8
+ "**/*.mock.ts",
9
+ "**/*.test.{js,jsx,ts,tsx}"
10
+ ],
11
+ "ignoreUnresolved": [],
12
+ "ignoreUnused": [],
13
+ "ignoreUnimported": [
14
+ "src/ZCash.ts"
15
+ ]
16
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @ledgerhq/zcash-shielded
2
+
3
+ ## 0.1.1-nightly.20251217131814
4
+
5
+ ### Patch Changes
6
+
7
+ - [#13166](https://github.com/LedgerHQ/ledger-live/pull/13166) [`9a97195`](https://github.com/LedgerHQ/ledger-live/commit/9a9719585de98dee726345643549676712848972) Thanks [@alevito](https://github.com/alevito)! - Create the basic structure of a ZCash library for shielded transactions.
package/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2017-present Ledger https://www.ledger.com/
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ <img src="https://user-images.githubusercontent.com/4631227/191834116-59cf590e-25cc-4956-ae5c-812ea464f324.png" height="100" />
2
+
3
+ [GitHub](https://github.com/LedgerHQ/ledger-live/),
4
+ [Ledger Devs Discord](https://developers.ledger.com/discord-pro),
5
+ [Developer Portal](https://developers.ledger.com/)
6
+
7
+ ## @ledgerhq/zcash-shielded
8
+
9
+ ZCash shielded account library
10
+
11
+ ***
package/jest.config.js ADDED
@@ -0,0 +1,9 @@
1
+ /** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */
2
+ module.exports = {
3
+ collectCoverageFrom: ["src/**/*.ts"],
4
+ coveragePathIgnorePatterns: ["test/cli.ts", ".*\\.integration\\.test\\.[tj]s"],
5
+ coverageDirectory: "coverage",
6
+ preset: "ts-jest",
7
+ testEnvironment: "node",
8
+ testPathIgnorePatterns: ["lib/", "lib-es/", ".*\\.integration\\.test\\.[tj]s"],
9
+ };
@@ -0,0 +1,8 @@
1
+ /** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */
2
+ module.exports = {
3
+ preset: "ts-jest",
4
+ testEnvironment: "node",
5
+ testRegex: ".integration.test.ts$",
6
+ testPathIgnorePatterns: ["lib/", "lib-es/", "bridge.integration.test.ts"],
7
+ testTimeout: 60_000,
8
+ };
package/lib/ZCash.d.ts ADDED
@@ -0,0 +1,29 @@
1
+ /**
2
+ * ZCash API
3
+ */
4
+ export default class ZCash {
5
+ static readonly AVERAGE_BLOCK_SYNC_TIME_MS = 5;
6
+ /**
7
+ * Estimates sync time given a start and an end block.
8
+ *
9
+ * @param startBlock starting block
10
+ * @param endBlock end block, usually the latest confirmed block
11
+ * @return the estimated sync time
12
+ */
13
+ estimateSyncTime(startBlock: number, endBlock: number): Promise<number>;
14
+ /**
15
+ * Decrypts a ZCash shielded - i.e., encrypted - transaction.
16
+ *
17
+ * @param encryptedTransaction string raw string representing an encrypted transaction.
18
+ * @return a decrypted transaction
19
+ */
20
+ decryptTransaction(encryptedTransaction: string): Promise<string>;
21
+ /**
22
+ * Finds the lowest block height correspondent to a given timestamp
23
+ *
24
+ * @param timestamp
25
+ * @return a block height
26
+ */
27
+ findBlockHeight(timestamp: number): Promise<number>;
28
+ }
29
+ //# sourceMappingURL=ZCash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ZCash.d.ts","sourceRoot":"","sources":["../src/ZCash.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,CAAC,OAAO,OAAO,KAAK;IACxB,MAAM,CAAC,QAAQ,CAAC,0BAA0B,KAAK;IAE/C;;;;;;OAMG;IACG,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAI3D;;;;;OAKG;IACG,kBAAkB,CAAC,oBAAoB,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIvE;;;;;OAKG;IACG,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAG1D"}
package/lib/ZCash.js ADDED
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ /**
3
+ * ZCash API
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ class ZCash {
7
+ static AVERAGE_BLOCK_SYNC_TIME_MS = 5;
8
+ /**
9
+ * Estimates sync time given a start and an end block.
10
+ *
11
+ * @param startBlock starting block
12
+ * @param endBlock end block, usually the latest confirmed block
13
+ * @return the estimated sync time
14
+ */
15
+ async estimateSyncTime(startBlock, endBlock) {
16
+ return (endBlock - startBlock) * ZCash.AVERAGE_BLOCK_SYNC_TIME_MS;
17
+ }
18
+ /**
19
+ * Decrypts a ZCash shielded - i.e., encrypted - transaction.
20
+ *
21
+ * @param encryptedTransaction string raw string representing an encrypted transaction.
22
+ * @return a decrypted transaction
23
+ */
24
+ async decryptTransaction(encryptedTransaction) {
25
+ return `decrypted_${encryptedTransaction}`;
26
+ }
27
+ /**
28
+ * Finds the lowest block height correspondent to a given timestamp
29
+ *
30
+ * @param timestamp
31
+ * @return a block height
32
+ */
33
+ async findBlockHeight(timestamp) {
34
+ return timestamp + 42;
35
+ }
36
+ }
37
+ exports.default = ZCash;
38
+ //# sourceMappingURL=ZCash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ZCash.js","sourceRoot":"","sources":["../src/ZCash.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAEH,MAAqB,KAAK;IACxB,MAAM,CAAU,0BAA0B,GAAG,CAAC,CAAC;IAE/C;;;;;;OAMG;IACH,KAAK,CAAC,gBAAgB,CAAC,UAAkB,EAAE,QAAgB;QACzD,OAAO,CAAC,QAAQ,GAAG,UAAU,CAAC,GAAG,KAAK,CAAC,0BAA0B,CAAC;IACpE,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,kBAAkB,CAAC,oBAA4B;QACnD,OAAO,aAAa,oBAAoB,EAAE,CAAC;IAC7C,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,eAAe,CAAC,SAAiB;QACrC,OAAO,SAAS,GAAG,EAAE,CAAC;IACxB,CAAC;;AAhCH,wBAiCC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * ZCash API
3
+ */
4
+ export default class ZCash {
5
+ static readonly AVERAGE_BLOCK_SYNC_TIME_MS = 5;
6
+ /**
7
+ * Estimates sync time given a start and an end block.
8
+ *
9
+ * @param startBlock starting block
10
+ * @param endBlock end block, usually the latest confirmed block
11
+ * @return the estimated sync time
12
+ */
13
+ estimateSyncTime(startBlock: number, endBlock: number): Promise<number>;
14
+ /**
15
+ * Decrypts a ZCash shielded - i.e., encrypted - transaction.
16
+ *
17
+ * @param encryptedTransaction string raw string representing an encrypted transaction.
18
+ * @return a decrypted transaction
19
+ */
20
+ decryptTransaction(encryptedTransaction: string): Promise<string>;
21
+ /**
22
+ * Finds the lowest block height correspondent to a given timestamp
23
+ *
24
+ * @param timestamp
25
+ * @return a block height
26
+ */
27
+ findBlockHeight(timestamp: number): Promise<number>;
28
+ }
29
+ //# sourceMappingURL=ZCash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ZCash.d.ts","sourceRoot":"","sources":["../src/ZCash.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,CAAC,OAAO,OAAO,KAAK;IACxB,MAAM,CAAC,QAAQ,CAAC,0BAA0B,KAAK;IAE/C;;;;;;OAMG;IACG,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAI3D;;;;;OAKG;IACG,kBAAkB,CAAC,oBAAoB,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIvE;;;;;OAKG;IACG,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAG1D"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * ZCash API
3
+ */
4
+ export default class ZCash {
5
+ static AVERAGE_BLOCK_SYNC_TIME_MS = 5;
6
+ /**
7
+ * Estimates sync time given a start and an end block.
8
+ *
9
+ * @param startBlock starting block
10
+ * @param endBlock end block, usually the latest confirmed block
11
+ * @return the estimated sync time
12
+ */
13
+ async estimateSyncTime(startBlock, endBlock) {
14
+ return (endBlock - startBlock) * ZCash.AVERAGE_BLOCK_SYNC_TIME_MS;
15
+ }
16
+ /**
17
+ * Decrypts a ZCash shielded - i.e., encrypted - transaction.
18
+ *
19
+ * @param encryptedTransaction string raw string representing an encrypted transaction.
20
+ * @return a decrypted transaction
21
+ */
22
+ async decryptTransaction(encryptedTransaction) {
23
+ return `decrypted_${encryptedTransaction}`;
24
+ }
25
+ /**
26
+ * Finds the lowest block height correspondent to a given timestamp
27
+ *
28
+ * @param timestamp
29
+ * @return a block height
30
+ */
31
+ async findBlockHeight(timestamp) {
32
+ return timestamp + 42;
33
+ }
34
+ }
35
+ //# sourceMappingURL=ZCash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ZCash.js","sourceRoot":"","sources":["../src/ZCash.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,CAAC,OAAO,OAAO,KAAK;IACxB,MAAM,CAAU,0BAA0B,GAAG,CAAC,CAAC;IAE/C;;;;;;OAMG;IACH,KAAK,CAAC,gBAAgB,CAAC,UAAkB,EAAE,QAAgB;QACzD,OAAO,CAAC,QAAQ,GAAG,UAAU,CAAC,GAAG,KAAK,CAAC,0BAA0B,CAAC;IACpE,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,kBAAkB,CAAC,oBAA4B;QACnD,OAAO,aAAa,oBAAoB,EAAE,CAAC;IAC7C,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,eAAe,CAAC,SAAiB;QACrC,OAAO,SAAS,GAAG,EAAE,CAAC;IACxB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "@ledgerhq/zcash-shielded",
3
+ "version": "0.1.1-nightly.20251217131814",
4
+ "description": "ZCash library shielded accounts",
5
+ "keywords": [
6
+ "ZCash"
7
+ ],
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/LedgerHQ/ledger-live.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/LedgerHQ/ledger-live/issues"
14
+ },
15
+ "homepage": "https://github.com/LedgerHQ/ledger-live/tree/develop/libs/coin-modules/zcash-shielded",
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "main": "lib/ZCash.js",
20
+ "module": "lib-es/ZCash.js",
21
+ "types": "lib/ZCash.d.ts",
22
+ "typesVersions": {
23
+ "*": {
24
+ "lib/*": [
25
+ "lib/*"
26
+ ],
27
+ "lib-es/*": [
28
+ "lib-es/*"
29
+ ],
30
+ "*": [
31
+ "lib/*"
32
+ ]
33
+ }
34
+ },
35
+ "exports": {
36
+ "./lib/*": "./lib/ZCash.js",
37
+ "./lib-es/*": "./lib-es/ZCash.js",
38
+ "./*": {
39
+ "require": "./lib/ZCash.js",
40
+ "default": "./lib-es/ZCash.js"
41
+ },
42
+ "./package.json": "./package.json"
43
+ },
44
+ "license": "Apache-2.0",
45
+ "devDependencies": {
46
+ "@types/jest": "^29.5.10",
47
+ "jest": "^29.7.0",
48
+ "jest-util": "30.2.0",
49
+ "ts-jest": "^29.1.1"
50
+ },
51
+ "scripts": {
52
+ "clean": "rimraf lib lib-es",
53
+ "build": "tsc && tsc -m esnext --moduleResolution bundler --outDir lib-es",
54
+ "coverage": "jest --coverage --passWithNoTests",
55
+ "prewatch": "pnpm build",
56
+ "watch": "tsc --watch",
57
+ "watch:es": "tsc --watch -m esnext --moduleResolution bundler --outDir lib-es",
58
+ "doc": "documentation readme src/** --section=API --pe ts --re ts --re d.ts",
59
+ "lint": "eslint ./src --no-error-on-unmatched-pattern --ext .ts,.tsx --cache",
60
+ "lint:fix": "pnpm lint --fix",
61
+ "test": "jest",
62
+ "test-integ": "jest --config=jest.integ.config.js",
63
+ "typecheck": "tsc --noEmit",
64
+ "unimported": "unimported"
65
+ }
66
+ }
package/src/ZCash.ts ADDED
@@ -0,0 +1,38 @@
1
+ /**
2
+ * ZCash API
3
+ */
4
+
5
+ export default class ZCash {
6
+ static readonly AVERAGE_BLOCK_SYNC_TIME_MS = 5;
7
+
8
+ /**
9
+ * Estimates sync time given a start and an end block.
10
+ *
11
+ * @param startBlock starting block
12
+ * @param endBlock end block, usually the latest confirmed block
13
+ * @return the estimated sync time
14
+ */
15
+ async estimateSyncTime(startBlock: number, endBlock: number) {
16
+ return (endBlock - startBlock) * ZCash.AVERAGE_BLOCK_SYNC_TIME_MS;
17
+ }
18
+
19
+ /**
20
+ * Decrypts a ZCash shielded - i.e., encrypted - transaction.
21
+ *
22
+ * @param encryptedTransaction string raw string representing an encrypted transaction.
23
+ * @return a decrypted transaction
24
+ */
25
+ async decryptTransaction(encryptedTransaction: string): Promise<string> {
26
+ return `decrypted_${encryptedTransaction}`;
27
+ }
28
+
29
+ /**
30
+ * Finds the lowest block height correspondent to a given timestamp
31
+ *
32
+ * @param timestamp
33
+ * @return a block height
34
+ */
35
+ async findBlockHeight(timestamp: number): Promise<number> {
36
+ return timestamp + 42;
37
+ }
38
+ }
@@ -0,0 +1,25 @@
1
+ import ZCash from "../src/ZCash";
2
+
3
+ describe("estimateSyncTime", () => {
4
+ test("estimates the sync time", async () => {
5
+ const zcash = new ZCash();
6
+ const estimatedSyncTime = await zcash.estimateSyncTime(5, 10);
7
+ expect(estimatedSyncTime).toEqual(25);
8
+ });
9
+ });
10
+
11
+ describe("findBlockHeight", () => {
12
+ test("finds the lowest block height", async () => {
13
+ const zcash = new ZCash();
14
+ const height = await zcash.findBlockHeight(1234);
15
+ expect(height).toEqual(1276);
16
+ });
17
+ });
18
+
19
+ describe("decryptTransaction", () => {
20
+ test("decrypts an encrypted transaction", async () => {
21
+ const zcash = new ZCash();
22
+ const height = await zcash.decryptTransaction("transaction");
23
+ expect(height).toEqual("decrypted_transaction");
24
+ });
25
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "../../../tsconfig.base",
3
+ "compilerOptions": {
4
+ "declaration": true,
5
+ "declarationMap": true,
6
+ "downlevelIteration": true,
7
+ "lib": ["es2020", "dom"],
8
+ "outDir": "lib",
9
+ "exactOptionalPropertyTypes": true
10
+ },
11
+ "include": ["src/**/*"]
12
+ }