@matrix-privacy/wallet 0.0.1
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.
- package/.eslintrc.js +73 -0
- package/.prettierrc.js +21 -0
- package/LICENSE +21 -0
- package/README.md +7 -0
- package/dist/__tests__/index.test.d.ts +1 -0
- package/dist/__tests__/index.test.js +13 -0
- package/dist/__tests__/index.test.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/services/artifacts/__tests__/artifact-downloader.test.d.ts +1 -0
- package/dist/services/artifacts/__tests__/artifact-downloader.test.js +172 -0
- package/dist/services/artifacts/__tests__/artifact-downloader.test.js.map +1 -0
- package/dist/services/artifacts/artifact-downloader.d.ts +13 -0
- package/dist/services/artifacts/artifact-downloader.js +142 -0
- package/dist/services/artifacts/artifact-downloader.js.map +1 -0
- package/dist/services/artifacts/artifact-hash.d.ts +3 -0
- package/dist/services/artifacts/artifact-hash.js +53 -0
- package/dist/services/artifacts/artifact-hash.js.map +1 -0
- package/dist/services/artifacts/artifact-store.d.ts +11 -0
- package/dist/services/artifacts/artifact-store.js +15 -0
- package/dist/services/artifacts/artifact-store.js.map +1 -0
- package/dist/services/artifacts/artifact-util.d.ts +7 -0
- package/dist/services/artifacts/artifact-util.js +64 -0
- package/dist/services/artifacts/artifact-util.js.map +1 -0
- package/dist/services/artifacts/index.d.ts +2 -0
- package/dist/services/artifacts/index.js +19 -0
- package/dist/services/artifacts/index.js.map +1 -0
- package/dist/services/artifacts/json/artifact-v2-hashes.json +467 -0
- package/dist/services/ethers/__tests__/ethers-util.test.d.ts +1 -0
- package/dist/services/ethers/__tests__/ethers-util.test.js +19 -0
- package/dist/services/ethers/__tests__/ethers-util.test.js.map +1 -0
- package/dist/services/ethers/ethers-util.d.ts +1 -0
- package/dist/services/ethers/ethers-util.js +9 -0
- package/dist/services/ethers/ethers-util.js.map +1 -0
- package/dist/services/ethers/index.d.ts +1 -0
- package/dist/services/ethers/index.js +18 -0
- package/dist/services/ethers/index.js.map +1 -0
- package/dist/services/index.d.ts +4 -0
- package/dist/services/index.js +21 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/matrix/core/__tests__/engine.test.d.ts +1 -0
- package/dist/services/matrix/core/__tests__/engine.test.js +30 -0
- package/dist/services/matrix/core/__tests__/engine.test.js.map +1 -0
- package/dist/services/matrix/core/__tests__/providers.test.d.ts +1 -0
- package/dist/services/matrix/core/__tests__/providers.test.js +54 -0
- package/dist/services/matrix/core/__tests__/providers.test.js.map +1 -0
- package/dist/services/matrix/core/artifacts.d.ts +10 -0
- package/dist/services/matrix/core/artifacts.js +70 -0
- package/dist/services/matrix/core/artifacts.js.map +1 -0
- package/dist/services/matrix/core/engine.d.ts +4 -0
- package/dist/services/matrix/core/engine.js +21 -0
- package/dist/services/matrix/core/engine.js.map +1 -0
- package/dist/services/matrix/core/index.d.ts +8 -0
- package/dist/services/matrix/core/index.js +25 -0
- package/dist/services/matrix/core/index.js.map +1 -0
- package/dist/services/matrix/core/init.d.ts +21 -0
- package/dist/services/matrix/core/init.js +79 -0
- package/dist/services/matrix/core/init.js.map +1 -0
- package/dist/services/matrix/core/load-provider.d.ts +9 -0
- package/dist/services/matrix/core/load-provider.js +100 -0
- package/dist/services/matrix/core/load-provider.js.map +1 -0
- package/dist/services/matrix/core/merkletree.d.ts +5 -0
- package/dist/services/matrix/core/merkletree.js +40 -0
- package/dist/services/matrix/core/merkletree.js.map +1 -0
- package/dist/services/matrix/core/prover.d.ts +3 -0
- package/dist/services/matrix/core/prover.js +14 -0
- package/dist/services/matrix/core/prover.js.map +1 -0
- package/dist/services/matrix/core/providers.d.ts +9 -0
- package/dist/services/matrix/core/providers.js +31 -0
- package/dist/services/matrix/core/providers.js.map +1 -0
- package/dist/services/matrix/core/shields.d.ts +11 -0
- package/dist/services/matrix/core/shields.js +24 -0
- package/dist/services/matrix/core/shields.js.map +1 -0
- package/dist/services/matrix/history/__tests__/transaction-history.test.d.ts +1 -0
- package/dist/services/matrix/history/__tests__/transaction-history.test.js +249 -0
- package/dist/services/matrix/history/__tests__/transaction-history.test.js.map +1 -0
- package/dist/services/matrix/history/transaction-history.d.ts +4 -0
- package/dist/services/matrix/history/transaction-history.js +182 -0
- package/dist/services/matrix/history/transaction-history.js.map +1 -0
- package/dist/services/matrix/index.d.ts +4 -0
- package/dist/services/matrix/index.js +21 -0
- package/dist/services/matrix/index.js.map +1 -0
- package/dist/services/matrix/process/extract-transaction-data.d.ts +3 -0
- package/dist/services/matrix/process/extract-transaction-data.js +19 -0
- package/dist/services/matrix/process/extract-transaction-data.js.map +1 -0
- package/dist/services/matrix/process/index.d.ts +1 -0
- package/dist/services/matrix/process/index.js +18 -0
- package/dist/services/matrix/process/index.js.map +1 -0
- package/dist/services/matrix/quick-sync/V3/__tests__/quick-sync-events-graph-v3.test.d.ts +1 -0
- package/dist/services/matrix/quick-sync/V3/__tests__/quick-sync-events-graph-v3.test.js +56 -0
- package/dist/services/matrix/quick-sync/V3/__tests__/quick-sync-events-graph-v3.test.js.map +1 -0
- package/dist/services/matrix/quick-sync/V3/graph-type-formatters-v3.d.ts +8 -0
- package/dist/services/matrix/quick-sync/V3/graph-type-formatters-v3.js +103 -0
- package/dist/services/matrix/quick-sync/V3/graph-type-formatters-v3.js.map +1 -0
- package/dist/services/matrix/quick-sync/V3/graphql/.graphclient/sources/mumbai/introspectionSchema.d.ts +2 -0
- package/dist/services/matrix/quick-sync/V3/graphql/.graphclient/sources/mumbai/introspectionSchema.js +19861 -0
- package/dist/services/matrix/quick-sync/V3/graphql/.graphclient/sources/mumbai/introspectionSchema.js.map +1 -0
- package/dist/services/matrix/quick-sync/V3/graphql/.graphclient/sources/mumbai/types.d.ts +1352 -0
- package/dist/services/matrix/quick-sync/V3/graphql/.graphclient/sources/mumbai/types.js +4 -0
- package/dist/services/matrix/quick-sync/V3/graphql/.graphclient/sources/mumbai/types.js.map +1 -0
- package/dist/services/matrix/quick-sync/V3/graphql/index.d.ts +1680 -0
- package/dist/services/matrix/quick-sync/V3/graphql/index.js +348 -0
- package/dist/services/matrix/quick-sync/V3/graphql/index.js.map +1 -0
- package/dist/services/matrix/quick-sync/V3/quick-sync-events-graph-v3.d.ts +2 -0
- package/dist/services/matrix/quick-sync/V3/quick-sync-events-graph-v3.js +99 -0
- package/dist/services/matrix/quick-sync/V3/quick-sync-events-graph-v3.js.map +1 -0
- package/dist/services/matrix/quick-sync/graph-query.d.ts +5 -0
- package/dist/services/matrix/quick-sync/graph-query.js +26 -0
- package/dist/services/matrix/quick-sync/graph-query.js.map +1 -0
- package/dist/services/matrix/quick-sync/quick-sync-events.d.ts +2 -0
- package/dist/services/matrix/quick-sync/quick-sync-events.js +9 -0
- package/dist/services/matrix/quick-sync/quick-sync-events.js.map +1 -0
- package/dist/services/matrix/quick-sync/shared-formatters.d.ts +8 -0
- package/dist/services/matrix/quick-sync/shared-formatters.js +36 -0
- package/dist/services/matrix/quick-sync/shared-formatters.js.map +1 -0
- package/dist/services/matrix/util/__tests__/bytes-util.test.d.ts +1 -0
- package/dist/services/matrix/util/__tests__/bytes-util.test.js +23 -0
- package/dist/services/matrix/util/__tests__/bytes-util.test.js.map +1 -0
- package/dist/services/matrix/util/__tests__/crypto-util.test.d.ts +1 -0
- package/dist/services/matrix/util/__tests__/crypto-util.test.js +62 -0
- package/dist/services/matrix/util/__tests__/crypto-util.test.js.map +1 -0
- package/dist/services/matrix/util/bytes.d.ts +5 -0
- package/dist/services/matrix/util/bytes.js +22 -0
- package/dist/services/matrix/util/bytes.js.map +1 -0
- package/dist/services/matrix/util/crypto.d.ts +14 -0
- package/dist/services/matrix/util/crypto.js +80 -0
- package/dist/services/matrix/util/crypto.js.map +1 -0
- package/dist/services/matrix/util/graph-util.d.ts +3 -0
- package/dist/services/matrix/util/graph-util.js +13 -0
- package/dist/services/matrix/util/graph-util.js.map +1 -0
- package/dist/services/matrix/util/index.d.ts +2 -0
- package/dist/services/matrix/util/index.js +19 -0
- package/dist/services/matrix/util/index.js.map +1 -0
- package/dist/services/matrix/util/runtime.d.ts +2 -0
- package/dist/services/matrix/util/runtime.js +8 -0
- package/dist/services/matrix/util/runtime.js.map +1 -0
- package/dist/services/matrix/wallets/__tests__/balances-live.test.d.ts +1 -0
- package/dist/services/matrix/wallets/__tests__/balances-live.test.js +48 -0
- package/dist/services/matrix/wallets/__tests__/balances-live.test.js.map +1 -0
- package/dist/services/matrix/wallets/__tests__/balances-update.test.d.ts +1 -0
- package/dist/services/matrix/wallets/__tests__/balances-update.test.js +85 -0
- package/dist/services/matrix/wallets/__tests__/balances-update.test.js.map +1 -0
- package/dist/services/matrix/wallets/__tests__/balances.test.d.ts +1 -0
- package/dist/services/matrix/wallets/__tests__/balances.test.js +59 -0
- package/dist/services/matrix/wallets/__tests__/balances.test.js.map +1 -0
- package/dist/services/matrix/wallets/__tests__/wallets.test.d.ts +1 -0
- package/dist/services/matrix/wallets/__tests__/wallets.test.js +80 -0
- package/dist/services/matrix/wallets/__tests__/wallets.test.js.map +1 -0
- package/dist/services/matrix/wallets/balance-update.d.ts +10 -0
- package/dist/services/matrix/wallets/balance-update.js +126 -0
- package/dist/services/matrix/wallets/balance-update.js.map +1 -0
- package/dist/services/matrix/wallets/balances.d.ts +3 -0
- package/dist/services/matrix/wallets/balances.js +32 -0
- package/dist/services/matrix/wallets/balances.js.map +1 -0
- package/dist/services/matrix/wallets/index.d.ts +4 -0
- package/dist/services/matrix/wallets/index.js +21 -0
- package/dist/services/matrix/wallets/index.js.map +1 -0
- package/dist/services/matrix/wallets/wallets.d.ts +22 -0
- package/dist/services/matrix/wallets/wallets.js +252 -0
- package/dist/services/matrix/wallets/wallets.js.map +1 -0
- package/dist/services/transactions/__tests__/json/formatted-relay-adapt-error-logs.json +216 -0
- package/dist/services/transactions/__tests__/proof-cache.test.d.ts +1 -0
- package/dist/services/transactions/__tests__/proof-cache.test.js +114 -0
- package/dist/services/transactions/__tests__/proof-cache.test.js.map +1 -0
- package/dist/services/transactions/__tests__/tx-cross-contract-calls.test.d.ts +1 -0
- package/dist/services/transactions/__tests__/tx-cross-contract-calls.test.js +376 -0
- package/dist/services/transactions/__tests__/tx-cross-contract-calls.test.js.map +1 -0
- package/dist/services/transactions/__tests__/tx-gas-details.test.d.ts +1 -0
- package/dist/services/transactions/__tests__/tx-gas-details.test.js +109 -0
- package/dist/services/transactions/__tests__/tx-gas-details.test.js.map +1 -0
- package/dist/services/transactions/__tests__/tx-notes.test.d.ts +1 -0
- package/dist/services/transactions/__tests__/tx-notes.test.js +193 -0
- package/dist/services/transactions/__tests__/tx-notes.test.js.map +1 -0
- package/dist/services/transactions/__tests__/tx-shield-base-token.test.d.ts +1 -0
- package/dist/services/transactions/__tests__/tx-shield-base-token.test.js +99 -0
- package/dist/services/transactions/__tests__/tx-shield-base-token.test.js.map +1 -0
- package/dist/services/transactions/__tests__/tx-shield.test.d.ts +1 -0
- package/dist/services/transactions/__tests__/tx-shield.test.js +146 -0
- package/dist/services/transactions/__tests__/tx-shield.test.js.map +1 -0
- package/dist/services/transactions/__tests__/tx-transfer.test.d.ts +1 -0
- package/dist/services/transactions/__tests__/tx-transfer.test.js +263 -0
- package/dist/services/transactions/__tests__/tx-transfer.test.js.map +1 -0
- package/dist/services/transactions/__tests__/tx-unshield.test.d.ts +1 -0
- package/dist/services/transactions/__tests__/tx-unshield.test.js +759 -0
- package/dist/services/transactions/__tests__/tx-unshield.test.js.map +1 -0
- package/dist/services/transactions/index.d.ts +13 -0
- package/dist/services/transactions/index.js +30 -0
- package/dist/services/transactions/index.js.map +1 -0
- package/dist/services/transactions/proof-cache.d.ts +27 -0
- package/dist/services/transactions/proof-cache.js +130 -0
- package/dist/services/transactions/proof-cache.js.map +1 -0
- package/dist/services/transactions/tx-cross-contract-calls.d.ts +12 -0
- package/dist/services/transactions/tx-cross-contract-calls.js +210 -0
- package/dist/services/transactions/tx-cross-contract-calls.js.map +1 -0
- package/dist/services/transactions/tx-gas-broadcaster-fee-estimator.d.ts +5 -0
- package/dist/services/transactions/tx-gas-broadcaster-fee-estimator.js +110 -0
- package/dist/services/transactions/tx-gas-broadcaster-fee-estimator.js.map +1 -0
- package/dist/services/transactions/tx-gas-details.d.ts +5 -0
- package/dist/services/transactions/tx-gas-details.js +101 -0
- package/dist/services/transactions/tx-gas-details.js.map +1 -0
- package/dist/services/transactions/tx-generator.d.ts +13 -0
- package/dist/services/transactions/tx-generator.js +168 -0
- package/dist/services/transactions/tx-generator.js.map +1 -0
- package/dist/services/transactions/tx-notes.d.ts +11 -0
- package/dist/services/transactions/tx-notes.js +153 -0
- package/dist/services/transactions/tx-notes.js.map +1 -0
- package/dist/services/transactions/tx-nullifiers.d.ts +2 -0
- package/dist/services/transactions/tx-nullifiers.js +17 -0
- package/dist/services/transactions/tx-nullifiers.js.map +1 -0
- package/dist/services/transactions/tx-proof-transfer.d.ts +3 -0
- package/dist/services/transactions/tx-proof-transfer.js +39 -0
- package/dist/services/transactions/tx-proof-transfer.js.map +1 -0
- package/dist/services/transactions/tx-proof-unshield.d.ts +5 -0
- package/dist/services/transactions/tx-proof-unshield.js +132 -0
- package/dist/services/transactions/tx-proof-unshield.js.map +1 -0
- package/dist/services/transactions/tx-shield-base-token.d.ts +3 -0
- package/dist/services/transactions/tx-shield-base-token.js +55 -0
- package/dist/services/transactions/tx-shield-base-token.js.map +1 -0
- package/dist/services/transactions/tx-shield.d.ts +6 -0
- package/dist/services/transactions/tx-shield.js +77 -0
- package/dist/services/transactions/tx-shield.js.map +1 -0
- package/dist/services/transactions/tx-transfer.d.ts +3 -0
- package/dist/services/transactions/tx-transfer.js +39 -0
- package/dist/services/transactions/tx-transfer.js.map +1 -0
- package/dist/services/transactions/tx-unshield.d.ts +11 -0
- package/dist/services/transactions/tx-unshield.js +224 -0
- package/dist/services/transactions/tx-unshield.js.map +1 -0
- package/dist/tests/local-e2e.d.ts +13 -0
- package/dist/tests/local-e2e.js +487 -0
- package/dist/tests/local-e2e.js.map +1 -0
- package/dist/tests/mocks.test.d.ts +40 -0
- package/dist/tests/mocks.test.js +171 -0
- package/dist/tests/mocks.test.js.map +1 -0
- package/dist/tests/setup.test.d.ts +7 -0
- package/dist/tests/setup.test.js +88 -0
- package/dist/tests/setup.test.js.map +1 -0
- package/dist/tests/stubs/engine-stubs.test.d.ts +7 -0
- package/dist/tests/stubs/engine-stubs.test.js +72 -0
- package/dist/tests/stubs/engine-stubs.test.js.map +1 -0
- package/dist/utils/__tests__/blocked-address.test.d.ts +1 -0
- package/dist/utils/__tests__/blocked-address.test.js +23 -0
- package/dist/utils/__tests__/blocked-address.test.js.map +1 -0
- package/dist/utils/__tests__/logger.test.d.ts +1 -0
- package/dist/utils/__tests__/logger.test.js +28 -0
- package/dist/utils/__tests__/logger.test.js.map +1 -0
- package/dist/utils/__tests__/utils.test.d.ts +1 -0
- package/dist/utils/__tests__/utils.test.js +21 -0
- package/dist/utils/__tests__/utils.test.js.map +1 -0
- package/dist/utils/blocked-address.d.ts +2 -0
- package/dist/utils/blocked-address.js +17 -0
- package/dist/utils/blocked-address.js.map +1 -0
- package/dist/utils/error.d.ts +1 -0
- package/dist/utils/error.js +20 -0
- package/dist/utils/error.js.map +1 -0
- package/dist/utils/gas-price.d.ts +6 -0
- package/dist/utils/gas-price.js +19 -0
- package/dist/utils/gas-price.js.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +19 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +3 -0
- package/dist/utils/logger.js +21 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/utils.d.ts +4 -0
- package/dist/utils/utils.js +54 -0
- package/dist/utils/utils.js.map +1 -0
- package/package.json +94 -0
- package/postinstall.js +52 -0
- package/react-native-shims.js +42 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setLoggers = exports.sendErrorMessage = exports.sendMessage = void 0;
|
|
4
|
+
let log;
|
|
5
|
+
let error;
|
|
6
|
+
const sendMessage = (msg) => {
|
|
7
|
+
if (log)
|
|
8
|
+
log(msg);
|
|
9
|
+
};
|
|
10
|
+
exports.sendMessage = sendMessage;
|
|
11
|
+
const sendErrorMessage = (err) => {
|
|
12
|
+
if (error)
|
|
13
|
+
error(err);
|
|
14
|
+
};
|
|
15
|
+
exports.sendErrorMessage = sendErrorMessage;
|
|
16
|
+
const setLoggers = (logFunc, errorFunc) => {
|
|
17
|
+
log = logFunc;
|
|
18
|
+
error = errorFunc;
|
|
19
|
+
};
|
|
20
|
+
exports.setLoggers = setLoggers;
|
|
21
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":";;;AAAA,IAAI,GAAoC,CAAC;AACzC,IAAI,KAA8C,CAAC;AAE5C,MAAM,WAAW,GAAG,CAAC,GAAW,EAAE,EAAE;IACzC,IAAI,GAAG;QAAE,GAAG,CAAC,GAAG,CAAC,CAAC;AACpB,CAAC,CAAC;AAFW,QAAA,WAAW,eAEtB;AAEK,MAAM,gBAAgB,GAAG,CAAC,GAAmB,EAAE,EAAE;IACtD,IAAI,KAAK;QAAE,KAAK,CAAC,GAAG,CAAC,CAAC;AACxB,CAAC,CAAC;AAFW,QAAA,gBAAgB,oBAE3B;AAEK,MAAM,UAAU,GAAG,CACxB,OAAwC,EACxC,SAAkD,EAClD,EAAE;IACF,GAAG,GAAG,OAAO,CAAC;IACd,KAAK,GAAG,SAAS,CAAC;AACpB,CAAC,CAAC;AANW,QAAA,UAAU,cAMrB","sourcesContent":["let log: Optional<(msg: string) => void>;\nlet error: Optional<(err: Error | string) => void>;\n\nexport const sendMessage = (msg: string) => {\n if (log) log(msg);\n};\n\nexport const sendErrorMessage = (err: Error | string) => {\n if (error) error(err);\n};\n\nexport const setLoggers = (\n logFunc: Optional<(msg: string) => void>,\n errorFunc: Optional<(err: Error | string) => void>,\n) => {\n log = logFunc;\n error = errorFunc;\n};\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ContractTransaction } from 'ethers';
|
|
2
|
+
export declare const compareStringArrays: (a: Optional<string[]>, b: Optional<string[]>) => boolean;
|
|
3
|
+
export declare const compareContractTransactionArrays: (a: Optional<ContractTransaction[]>, b: Optional<ContractTransaction[]>) => boolean;
|
|
4
|
+
export declare const isDecimalStr: (str: string) => boolean;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isDecimalStr = exports.compareContractTransactionArrays = exports.compareStringArrays = void 0;
|
|
4
|
+
const logger_1 = require("./logger");
|
|
5
|
+
const compareStringArrays = (a, b) => {
|
|
6
|
+
if (!a && !b) {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
if (!a || !b || a.length !== b.length) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
for (const el of a) {
|
|
13
|
+
if (!b.includes(el)) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return true;
|
|
18
|
+
};
|
|
19
|
+
exports.compareStringArrays = compareStringArrays;
|
|
20
|
+
const compareContractTransactionArrays = (a, b) => {
|
|
21
|
+
if (!a && !b) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
if (!a || !b || a.length !== b.length) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
for (let i = 0; i < a.length; i += 1) {
|
|
29
|
+
for (const key of Object.keys(a[i])) {
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
31
|
+
if (a[i][key] !== b[i][key]) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
if (!(err instanceof Error)) {
|
|
39
|
+
throw new Error('Non-error thrown in compareContractTransactionArrays', {
|
|
40
|
+
cause: err,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
(0, logger_1.sendErrorMessage)(`Could not compare contract transaction arrays: ${err.message}`);
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
return true;
|
|
47
|
+
};
|
|
48
|
+
exports.compareContractTransactionArrays = compareContractTransactionArrays;
|
|
49
|
+
const isDecimalStr = (str) => {
|
|
50
|
+
const decimalPattern = /^[-+]?(\d+(\.\d*)?|\.\d+)$/;
|
|
51
|
+
return decimalPattern.test(str);
|
|
52
|
+
};
|
|
53
|
+
exports.isDecimalStr = isDecimalStr;
|
|
54
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":";;;AACA,qCAA4C;AAErC,MAAM,mBAAmB,GAAG,CACjC,CAAqB,EACrB,CAAqB,EACZ,EAAE;IACX,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE;QACZ,OAAO,IAAI,CAAC;KACb;IACD,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,EAAE;QACrC,OAAO,KAAK,CAAC;KACd;IACD,KAAK,MAAM,EAAE,IAAI,CAAC,EAAE;QAClB,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE;YACnB,OAAO,KAAK,CAAC;SACd;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAhBW,QAAA,mBAAmB,uBAgB9B;AAEK,MAAM,gCAAgC,GAAG,CAC9C,CAAkC,EAClC,CAAkC,EACzB,EAAE;IACX,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE;QACZ,OAAO,IAAI,CAAC;KACb;IACD,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,EAAE;QACrC,OAAO,KAAK,CAAC;KACd;IACD,IAAI;QACF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;YACpC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;gBACnC,sEAAsE;gBACtE,IAAK,CAAC,CAAC,CAAC,CAAS,CAAC,GAAG,CAAC,KAAM,CAAC,CAAC,CAAC,CAAS,CAAC,GAAG,CAAC,EAAE;oBAC7C,OAAO,KAAK,CAAC;iBACd;aACF;SACF;KACF;IAAC,OAAO,GAAG,EAAE;QACZ,IAAI,CAAC,CAAC,GAAG,YAAY,KAAK,CAAC,EAAE;YAC3B,MAAM,IAAI,KAAK,CAAC,sDAAsD,EAAE;gBACtE,KAAK,EAAE,GAAG;aACX,CAAC,CAAC;SACJ;QACD,IAAA,yBAAgB,EACd,kDAAkD,GAAG,CAAC,OAAO,EAAE,CAChE,CAAC;QACF,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAhCW,QAAA,gCAAgC,oCAgC3C;AAEK,MAAM,YAAY,GAAG,CAAC,GAAW,EAAW,EAAE;IACnD,MAAM,cAAc,GAAG,4BAA4B,CAAC;IACpD,OAAO,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClC,CAAC,CAAA;AAHY,QAAA,YAAY,gBAGxB","sourcesContent":["import { ContractTransaction } from 'ethers';\nimport { sendErrorMessage } from './logger';\n\nexport const compareStringArrays = (\n a: Optional<string[]>,\n b: Optional<string[]>,\n): boolean => {\n if (!a && !b) {\n return true;\n }\n if (!a || !b || a.length !== b.length) {\n return false;\n }\n for (const el of a) {\n if (!b.includes(el)) {\n return false;\n }\n }\n return true;\n};\n\nexport const compareContractTransactionArrays = (\n a: Optional<ContractTransaction[]>,\n b: Optional<ContractTransaction[]>,\n): boolean => {\n if (!a && !b) {\n return true;\n }\n if (!a || !b || a.length !== b.length) {\n return false;\n }\n try {\n for (let i = 0; i < a.length; i += 1) {\n for (const key of Object.keys(a[i])) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if ((a[i] as any)[key] !== (b[i] as any)[key]) {\n return false;\n }\n }\n }\n } catch (err) {\n if (!(err instanceof Error)) {\n throw new Error('Non-error thrown in compareContractTransactionArrays', {\n cause: err,\n });\n }\n sendErrorMessage(\n `Could not compare contract transaction arrays: ${err.message}`,\n );\n return false;\n }\n\n return true;\n};\n\nexport const isDecimalStr = (str: string): boolean => {\n const decimalPattern = /^[-+]?(\\d+(\\.\\d*)?|\\.\\d+)$/;\n return decimalPattern.test(str);\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@matrix-privacy/wallet",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"description": "Matrix Wallet SDK, compatible with mobile, browser and nodejs environments.",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist/**/*",
|
|
12
|
+
"*.js"
|
|
13
|
+
],
|
|
14
|
+
"exports": {
|
|
15
|
+
".": "./dist/index.js",
|
|
16
|
+
"./react-native-shims": "./react-native-shims.js"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"clean": "rm -rf dist",
|
|
20
|
+
"build": "yarn clean && yarn lint && yarn tsc",
|
|
21
|
+
"tsc-test": "tsc -p tsconfig.test.json && tsc-alias -p tsconfig.test.json",
|
|
22
|
+
"build-test": "yarn clean && yarn tsc-test",
|
|
23
|
+
"test-coverage": "yarn build-test && nyc mocha 'src/**/__tests__/*.test.ts'",
|
|
24
|
+
"test": "yarn build-test && mocha 'src/**/__tests__/*.test.ts'",
|
|
25
|
+
"tsc": "tsc && tsc-alias",
|
|
26
|
+
"check-circular-deps": "madge --circular .",
|
|
27
|
+
"eslint": "eslint src/**/* --ext .ts,.tsx --ignore-pattern **/*.graphql --fix",
|
|
28
|
+
"lint": "yarn check-circular-deps && yarn eslint && yarn tsc && yarn tsc-test",
|
|
29
|
+
"prepare": "yarn build",
|
|
30
|
+
"postinstall": "node postinstall.js",
|
|
31
|
+
"build-graphql-V3": "rm -rf src/services/matrix/quick-sync/V3/graphql/.graphclient && graphclient build --dir src/services/matrix/quick-sync/V3/graphql"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@graphql-mesh/cache-localforage": "^0.7.20",
|
|
35
|
+
"@graphql-mesh/cross-helpers": "^0.3.4",
|
|
36
|
+
"@graphql-mesh/graphql": "^0.34.16",
|
|
37
|
+
"@graphql-mesh/http": "^0.3.28",
|
|
38
|
+
"@graphql-mesh/merger-bare": "^0.96.0",
|
|
39
|
+
"@graphql-mesh/merger-stitching": "^0.18.24",
|
|
40
|
+
"@graphql-mesh/runtime": "^0.46.23",
|
|
41
|
+
"@graphql-mesh/store": "^0.9.20",
|
|
42
|
+
"@graphql-mesh/types": "^0.91.14",
|
|
43
|
+
"@graphql-mesh/utils": "^0.43.22",
|
|
44
|
+
"@noble/ed25519": "^1.7.1",
|
|
45
|
+
"@matrix-privacy/engine": "0.0.1",
|
|
46
|
+
"@matrix-privacy/shared-models": "0.0.1",
|
|
47
|
+
"@whatwg-node/fetch": "^0.8.4",
|
|
48
|
+
"assert": "2.0.0",
|
|
49
|
+
"axios": "1.7.2",
|
|
50
|
+
"brotli": "^1.3.3",
|
|
51
|
+
"buffer": "^6.0.3",
|
|
52
|
+
"crypto-browserify": "3.12.0",
|
|
53
|
+
"ethereum-cryptography": "^2.0.0",
|
|
54
|
+
"ethers": "6.14.3",
|
|
55
|
+
"events": "3.3.0",
|
|
56
|
+
"graphql": "^16.6.0",
|
|
57
|
+
"stream-browserify": "3.0.0"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@graphprotocol/client-cli": "^2.2.20",
|
|
61
|
+
"@types/chai": "^4.3.4",
|
|
62
|
+
"@types/chai-as-promised": "^7.1.5",
|
|
63
|
+
"@types/leveldown": "^4.0.3",
|
|
64
|
+
"@types/mocha": "^10.0.1",
|
|
65
|
+
"@types/node": "^18.11.18",
|
|
66
|
+
"@types/sinon": "^10.0.13",
|
|
67
|
+
"@typescript-eslint/eslint-plugin": "^5.48.2",
|
|
68
|
+
"@typescript-eslint/parser": "^5.48.2",
|
|
69
|
+
"chai": "^4.3.7",
|
|
70
|
+
"chai-as-promised": "^7.1.1",
|
|
71
|
+
"eslint": "^8.32.0",
|
|
72
|
+
"eslint-config-airbnb-base": "^15.0.0",
|
|
73
|
+
"eslint-config-prettier": "^8.6.0",
|
|
74
|
+
"eslint-plugin-import": "^2.27.5",
|
|
75
|
+
"eslint-plugin-no-only-tests": "^3.1.0",
|
|
76
|
+
"leveldown": "^6.1.1",
|
|
77
|
+
"madge": "^6.0.0",
|
|
78
|
+
"mocha": "^10.2.0",
|
|
79
|
+
"nyc": "^15.1.0",
|
|
80
|
+
"sinon": "^15.0.1",
|
|
81
|
+
"snarkjs": "^0.7.1",
|
|
82
|
+
"ts-node": "^10.9.1",
|
|
83
|
+
"tsc-alias": "^1.8.2",
|
|
84
|
+
"typescript": "^4.9.4"
|
|
85
|
+
},
|
|
86
|
+
"react-native": {
|
|
87
|
+
"crypto": false,
|
|
88
|
+
"util": false
|
|
89
|
+
},
|
|
90
|
+
"resolutions": {
|
|
91
|
+
"ethers": "6.14.3"
|
|
92
|
+
},
|
|
93
|
+
"packageManager": "yarn@1.22.22"
|
|
94
|
+
}
|
package/postinstall.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
const fs = require('node:fs');
|
|
3
|
+
const path = require('node:path');
|
|
4
|
+
|
|
5
|
+
const cwd = process.env.INIT_CWD;
|
|
6
|
+
const reactNativeFiles = ['ios', 'android', 'metro.config.js'];
|
|
7
|
+
const isReactNativeProject = reactNativeFiles.every(file =>
|
|
8
|
+
fs.existsSync(path.join(cwd, file)),
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Patch `cipher-base` so that `stream` is replaced with `stream-browserify`
|
|
13
|
+
*/
|
|
14
|
+
function patchCipherBase() {
|
|
15
|
+
if (!fs.existsSync(path.join(cwd, 'node_modules'))) return;
|
|
16
|
+
if (!fs.existsSync(path.join(cwd, 'node_modules', 'cipher-base'))) return;
|
|
17
|
+
|
|
18
|
+
const cipherBasePackageJson = JSON.parse(
|
|
19
|
+
fs.readFileSync(
|
|
20
|
+
path.join(cwd, 'node_modules', 'cipher-base', 'package.json'),
|
|
21
|
+
'utf8',
|
|
22
|
+
),
|
|
23
|
+
);
|
|
24
|
+
cipherBasePackageJson['react-native'] = {
|
|
25
|
+
stream: 'stream-browserify',
|
|
26
|
+
};
|
|
27
|
+
fs.writeFileSync(
|
|
28
|
+
path.join(cwd, 'node_modules', 'cipher-base', 'package.json'),
|
|
29
|
+
JSON.stringify(cipherBasePackageJson, null, 2),
|
|
30
|
+
'utf8',
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function warnIfNoGetRandomValues() {
|
|
35
|
+
const packageJson = JSON.parse(
|
|
36
|
+
fs.readFileSync(path.join(cwd, 'package.json'), 'utf8'),
|
|
37
|
+
);
|
|
38
|
+
if ('react-native-get-random-values' in packageJson['dependencies']) return;
|
|
39
|
+
throw new Error(
|
|
40
|
+
'react-native-get-random-values is missing. It seems like you are ' +
|
|
41
|
+
'installing @railgun-community/wallet in a React Native project. ' +
|
|
42
|
+
'This requires the peer dependency react-native-get-random-values. ' +
|
|
43
|
+
'\n' +
|
|
44
|
+
'Please add it to your package.json dependencies and run npm install ' +
|
|
45
|
+
'(or yarn) again.',
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (isReactNativeProject) {
|
|
50
|
+
patchCipherBase();
|
|
51
|
+
warnIfNoGetRandomValues();
|
|
52
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
|
|
3
|
+
// Wallet (and Engine) uses Buffer,
|
|
4
|
+
// which is not available in React Native.
|
|
5
|
+
global.Buffer ??= require('buffer').Buffer;
|
|
6
|
+
|
|
7
|
+
// Wallet uses ethereum-cryptography,
|
|
8
|
+
// which needs @noble/hashes,
|
|
9
|
+
// which needs crypto.getRandomValues,
|
|
10
|
+
// which is not available in React Native.
|
|
11
|
+
require('react-native-get-random-values');
|
|
12
|
+
|
|
13
|
+
// Engine uses AES encryption,
|
|
14
|
+
// which we shim with browserify-aes,
|
|
15
|
+
// which needs cipher-base,
|
|
16
|
+
// which needs stream-browserify,
|
|
17
|
+
// which needs process.nextTick,
|
|
18
|
+
// which is not available in React Native.
|
|
19
|
+
process.nextTick = setImmediate;
|
|
20
|
+
|
|
21
|
+
// Engine's getPrivateScalarFromPrivateKey uses @noble/ed25519 sha512,
|
|
22
|
+
// which needs (web) crypto.subtle.digest,
|
|
23
|
+
// which is not available in React Native.
|
|
24
|
+
const cryptoBrowserify = require('crypto-browserify');
|
|
25
|
+
global.crypto ??= {};
|
|
26
|
+
global.crypto.subtle ??= {};
|
|
27
|
+
global.crypto.subtle.digest ??= (algorithm, data) => {
|
|
28
|
+
const algo = algorithm.toLowerCase().replace('-', '');
|
|
29
|
+
return cryptoBrowserify.createHash(algo).update(data).digest();
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Other package.json dependencies and why we need them:
|
|
34
|
+
* - assert:
|
|
35
|
+
* - engine uses circomlibjs which uses assert
|
|
36
|
+
* - events:
|
|
37
|
+
* - engine uses EventEmitter;
|
|
38
|
+
* - engine uses levelup which uses EventEmitter
|
|
39
|
+
* - stream-browserify:
|
|
40
|
+
* - engine uses AES encryption, which we shim with browserify-aes, which
|
|
41
|
+
* needs cipher-base, which needs stream
|
|
42
|
+
*/
|