@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 @@
|
|
|
1
|
+
{"version":3,"file":"tx-gas-details.test.js","sourceRoot":"","sources":["../../../../src/services/transactions/__tests__/tx-gas-details.test.ts"],"names":[],"mappings":";;;;;AAAA,gDAAw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\nimport {\n createFallbackProviderFromJsonConfig,\n EVMGasType,\n NetworkName,\n TransactionGasDetails,\n} from '@matrix-privacy/shared-models';\nimport {\n MOCK_ETH_WALLET_ADDRESS,\n MOCK_FALLBACK_PROVIDER_JSON_CONFIG_SEPOLIA,\n} from '../../../tests/mocks.test';\nimport {\n gasEstimateResponse,\n getGasEstimate,\n setGasDetailsForTransaction,\n} from '../tx-gas-details';\nimport { setFallbackProviderForNetwork } from '../../matrix';\nimport { ContractTransaction, FallbackProvider } from 'ethers';\n\nlet gasEstimateStub: SinonStub;\n\nchai.use(chaiAsPromised);\nconst { expect } = chai;\n\n\nconst stubGasEstimateSuccess = () => {\n gasEstimateStub = Sinon.stub(\n FallbackProvider.prototype,\n 'estimateGas',\n ).resolves(BigInt('200'));\n};\n\ndescribe('tx-gas', () => {\n afterEach(() => {\n gasEstimateStub?.restore();\n });\n\n it('Should format gas estimate response', async () => {\n const transaction = {} as ContractTransaction;\n const fallbackProvider = createFallbackProviderFromJsonConfig(\n MOCK_FALLBACK_PROVIDER_JSON_CONFIG_SEPOLIA,\n );\n\n setFallbackProviderForNetwork(\n NetworkName.Hardhat,\n fallbackProvider as unknown as FallbackProvider,\n );\n\n const gasEstimate = await getGasEstimate(\n NetworkName.Hardhat,\n transaction,\n MOCK_ETH_WALLET_ADDRESS,\n true, // sendWithPublicWallet\n false, // isCrossContractCall\n );\n\n const isGasEstimateWithDummyProof = false;\n const rsp = gasEstimateResponse(\n gasEstimate,\n undefined, // broadcasterFeeCommitment\n isGasEstimateWithDummyProof,\n );\n\n const expectedGas = 53000n; // This field may vary\n const variance = 0.05; // 5%\n const lowerBound = Number(expectedGas) * (1 - variance);\n const upperBound = Number(expectedGas) * (1 + variance);\n\n expect(Number(rsp.gasEstimate)).to.be.within(lowerBound, upperBound);\n }).timeout(6000);\n\n it('Should pull gas estimate for basic transaction - self-signed', async () => {\n stubGasEstimateSuccess();\n const fallbackProvider = createFallbackProviderFromJsonConfig(\n MOCK_FALLBACK_PROVIDER_JSON_CONFIG_SEPOLIA,\n );\n setFallbackProviderForNetwork(\n NetworkName.Hardhat,\n fallbackProvider as unknown as FallbackProvider,\n );\n const tx: ContractTransaction = {\n chainId: 31337n,\n to: MOCK_ETH_WALLET_ADDRESS,\n value: BigInt('100'),\n data: '0x',\n };\n\n const gasEstimate = await getGasEstimate(\n NetworkName.Hardhat,\n tx,\n MOCK_ETH_WALLET_ADDRESS,\n true, // sendWithPublicWallet\n false, // isCrossContractCall\n );\n const isGasEstimateWithDummyProof = true;\n const rsp = gasEstimateResponse(\n gasEstimate,\n undefined, // broadcasterFeeCommitment\n isGasEstimateWithDummyProof,\n );\n expect(rsp.gasEstimate).to.not.be.undefined;\n }).timeout(60_000);\n\n it('Should pull gas estimate for basic transaction - broadcaster', async () => {\n stubGasEstimateSuccess();\n const fallbackProvider = createFallbackProviderFromJsonConfig(\n MOCK_FALLBACK_PROVIDER_JSON_CONFIG_SEPOLIA,\n );\n setFallbackProviderForNetwork(\n NetworkName.Hardhat,\n fallbackProvider as unknown as FallbackProvider,\n );\n const tx: ContractTransaction = {\n chainId: 31337n,\n to: MOCK_ETH_WALLET_ADDRESS,\n value: BigInt('100'),\n data: '0x',\n };\n const gasEstimate = await getGasEstimate(\n NetworkName.Hardhat,\n tx,\n MOCK_ETH_WALLET_ADDRESS,\n false, // sendWithPublicWallet\n false, // isCrossContractCall\n );\n const isGasEstimateWithDummyProof = true;\n const rsp = gasEstimateResponse(\n gasEstimate,\n undefined, // broadcasterFeeCommitment\n isGasEstimateWithDummyProof,\n );\n expect(rsp.gasEstimate).to.not.be.undefined;\n }).timeout(60_000);\n\n it('Should set gas details for populated tx', () => {\n const transaction = {} as ContractTransaction;\n const gasDetailsType0: TransactionGasDetails = {\n evmGasType: EVMGasType.Type0,\n gasEstimate: 100_000n,\n gasPrice: 500n,\n };\n const gasDetailsType1: TransactionGasDetails = {\n evmGasType: EVMGasType.Type1,\n gasEstimate: 100_000n,\n gasPrice: 500n,\n };\n const gasDetailsType2: TransactionGasDetails = {\n evmGasType: EVMGasType.Type2,\n gasEstimate: 120_000n,\n maxFeePerGas: 10_000n,\n maxPriorityFeePerGas: 500n,\n };\n // Hardhat - self-sign\n setGasDetailsForTransaction(\n NetworkName.Hardhat,\n transaction,\n gasDetailsType2,\n true, // sendWithPublicWallet\n );\n expect(transaction.type).to.equal(2);\n expect(transaction.gasLimit).to.equal(144_000n);\n expect(transaction.gasPrice).to.be.undefined;\n expect(transaction.maxFeePerGas).to.equal(10_000n);\n expect(transaction.maxPriorityFeePerGas).to.equal(500n);\n // Hardhat - Broadcaster\n setGasDetailsForTransaction(\n NetworkName.Hardhat,\n transaction,\n gasDetailsType1,\n false, // sendWithPublicWallet\n );\n // Hardhat - self-sign - type0\n setGasDetailsForTransaction(\n NetworkName.Hardhat,\n transaction,\n gasDetailsType0,\n true, // sendWithPublicWallet\n );\n // Hardhat - Broadcaster - type0\n setGasDetailsForTransaction(\n NetworkName.Hardhat,\n transaction,\n gasDetailsType0,\n false, // sendWithPublicWallet\n );\n expect(transaction.type).to.equal(0);\n expect(transaction.gasLimit).to.equal(120000n);\n expect(transaction.gasPrice).to.equal(500n);\n });\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const engine_1 = require("@matrix-privacy/engine");
|
|
7
|
+
const chai_1 = __importDefault(require("chai"));
|
|
8
|
+
const chai_as_promised_1 = __importDefault(require("chai-as-promised"));
|
|
9
|
+
const mocks_test_1 = require("../../../tests/mocks.test");
|
|
10
|
+
const setup_test_1 = require("../../../tests/setup.test");
|
|
11
|
+
const wallets_1 = require("../../matrix/wallets/wallets");
|
|
12
|
+
const tx_notes_1 = require("../tx-notes");
|
|
13
|
+
const MOCK_TOKEN = '0x236c614a38362644deb15c9789779faf508bc6fe';
|
|
14
|
+
chai_1.default.use(chai_as_promised_1.default);
|
|
15
|
+
const { expect } = chai_1.default;
|
|
16
|
+
const padTo32BytesUnHex = (str) => {
|
|
17
|
+
return engine_1.ByteUtils.padToLength(engine_1.ByteUtils.strip0x(str), engine_1.ByteLength.UINT_256);
|
|
18
|
+
};
|
|
19
|
+
const formatAmountString = (erc20Amount) => {
|
|
20
|
+
return BigInt(erc20Amount.amount);
|
|
21
|
+
};
|
|
22
|
+
let matrixWalletID;
|
|
23
|
+
describe('tx-notes', () => {
|
|
24
|
+
before(async function run() {
|
|
25
|
+
this.timeout(60000);
|
|
26
|
+
await (0, setup_test_1.initTestEngine)();
|
|
27
|
+
await (0, setup_test_1.initTestEngineNetworks)();
|
|
28
|
+
const matrixWalletInfo = await (0, wallets_1.createMatrixWallet)(mocks_test_1.MOCK_DB_ENCRYPTION_KEY, mocks_test_1.MOCK_MNEMONIC, undefined);
|
|
29
|
+
matrixWalletID = matrixWalletInfo.id;
|
|
30
|
+
});
|
|
31
|
+
after(async () => {
|
|
32
|
+
await (0, setup_test_1.closeTestEngine)();
|
|
33
|
+
});
|
|
34
|
+
it('Should test erc20 note creation', () => {
|
|
35
|
+
const erc20AmountRecipient = {
|
|
36
|
+
tokenAddress: MOCK_TOKEN,
|
|
37
|
+
amount: BigInt(0x100),
|
|
38
|
+
recipientAddress: mocks_test_1.MOCK_MATRIX_WALLET_ADDRESS,
|
|
39
|
+
};
|
|
40
|
+
const matrixWallet = (0, wallets_1.fullWalletForID)(matrixWalletID);
|
|
41
|
+
const note = (0, tx_notes_1.erc20NoteFromERC20AmountRecipient)(erc20AmountRecipient, matrixWallet, engine_1.OutputType.Transfer, true, // showSenderAddressToRecipient
|
|
42
|
+
mocks_test_1.MOCK_MEMO);
|
|
43
|
+
const addressData = engine_1.MatrixEngine.decodeAddress(mocks_test_1.MOCK_MATRIX_WALLET_ADDRESS);
|
|
44
|
+
expect(note.value).to.equal(formatAmountString(erc20AmountRecipient));
|
|
45
|
+
expect(note.receiverAddressData.masterPublicKey).to.equal(addressData.masterPublicKey);
|
|
46
|
+
expect(note.tokenHash).to.equal(padTo32BytesUnHex(MOCK_TOKEN));
|
|
47
|
+
});
|
|
48
|
+
it('Should test NFT note creation', () => {
|
|
49
|
+
const erc20AmountRecipient = {
|
|
50
|
+
tokenAddress: MOCK_TOKEN,
|
|
51
|
+
amount: BigInt(0x100),
|
|
52
|
+
recipientAddress: mocks_test_1.MOCK_MATRIX_WALLET_ADDRESS,
|
|
53
|
+
};
|
|
54
|
+
const matrixWallet = (0, wallets_1.fullWalletForID)(matrixWalletID);
|
|
55
|
+
const note = (0, tx_notes_1.erc20NoteFromERC20AmountRecipient)(erc20AmountRecipient, matrixWallet, engine_1.OutputType.Transfer, true, // showSenderAddressToRecipient
|
|
56
|
+
mocks_test_1.MOCK_MEMO);
|
|
57
|
+
const addressData = engine_1.MatrixEngine.decodeAddress(mocks_test_1.MOCK_MATRIX_WALLET_ADDRESS);
|
|
58
|
+
expect(note.value).to.equal(formatAmountString(erc20AmountRecipient));
|
|
59
|
+
expect(note.receiverAddressData.masterPublicKey).to.equal(addressData.masterPublicKey);
|
|
60
|
+
expect(note.tokenHash).to.equal(padTo32BytesUnHex(MOCK_TOKEN));
|
|
61
|
+
});
|
|
62
|
+
it('Should test token array comparisons', () => {
|
|
63
|
+
const erc20AmountRecipients1 = [
|
|
64
|
+
{
|
|
65
|
+
tokenAddress: '1',
|
|
66
|
+
amount: 100n,
|
|
67
|
+
recipientAddress: mocks_test_1.MOCK_MATRIX_WALLET_ADDRESS,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
tokenAddress: '2',
|
|
71
|
+
amount: BigInt(200),
|
|
72
|
+
recipientAddress: mocks_test_1.MOCK_MATRIX_WALLET_ADDRESS,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
tokenAddress: '3',
|
|
76
|
+
amount: 300n,
|
|
77
|
+
recipientAddress: mocks_test_1.MOCK_MATRIX_WALLET_ADDRESS,
|
|
78
|
+
},
|
|
79
|
+
];
|
|
80
|
+
// Same same
|
|
81
|
+
const erc20AmountRecipients2 = [
|
|
82
|
+
{
|
|
83
|
+
tokenAddress: '1',
|
|
84
|
+
amount: 100n,
|
|
85
|
+
recipientAddress: mocks_test_1.MOCK_MATRIX_WALLET_ADDRESS,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
tokenAddress: '2',
|
|
89
|
+
amount: BigInt(200),
|
|
90
|
+
recipientAddress: mocks_test_1.MOCK_MATRIX_WALLET_ADDRESS,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
tokenAddress: '3',
|
|
94
|
+
amount: 300n,
|
|
95
|
+
recipientAddress: mocks_test_1.MOCK_MATRIX_WALLET_ADDRESS,
|
|
96
|
+
},
|
|
97
|
+
];
|
|
98
|
+
// Different addresses
|
|
99
|
+
const erc20AmountRecipients3 = [
|
|
100
|
+
{
|
|
101
|
+
tokenAddress: '1',
|
|
102
|
+
amount: 100n,
|
|
103
|
+
recipientAddress: mocks_test_1.MOCK_MATRIX_WALLET_ADDRESS,
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
tokenAddress: '3',
|
|
107
|
+
amount: BigInt(200),
|
|
108
|
+
recipientAddress: mocks_test_1.MOCK_MATRIX_WALLET_ADDRESS,
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
tokenAddress: '5',
|
|
112
|
+
amount: 300n,
|
|
113
|
+
recipientAddress: mocks_test_1.MOCK_MATRIX_WALLET_ADDRESS,
|
|
114
|
+
},
|
|
115
|
+
];
|
|
116
|
+
// Different amounts
|
|
117
|
+
const erc20AmountRecipients4 = [
|
|
118
|
+
{
|
|
119
|
+
tokenAddress: '1',
|
|
120
|
+
amount: 100n,
|
|
121
|
+
recipientAddress: mocks_test_1.MOCK_MATRIX_WALLET_ADDRESS,
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
tokenAddress: '2',
|
|
125
|
+
amount: 300n,
|
|
126
|
+
recipientAddress: mocks_test_1.MOCK_MATRIX_WALLET_ADDRESS,
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
tokenAddress: '3',
|
|
130
|
+
amount: BigInt(200),
|
|
131
|
+
recipientAddress: mocks_test_1.MOCK_MATRIX_WALLET_ADDRESS,
|
|
132
|
+
},
|
|
133
|
+
];
|
|
134
|
+
// Different recipients
|
|
135
|
+
const erc20AmountRecipients5 = [
|
|
136
|
+
{
|
|
137
|
+
tokenAddress: '1',
|
|
138
|
+
amount: 100n,
|
|
139
|
+
recipientAddress: mocks_test_1.MOCK_MATRIX_WALLET_ADDRESS,
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
tokenAddress: '2',
|
|
143
|
+
amount: BigInt(200),
|
|
144
|
+
recipientAddress: mocks_test_1.MOCK_MATRIX_WALLET_ADDRESS,
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
tokenAddress: '3',
|
|
148
|
+
amount: 300n,
|
|
149
|
+
recipientAddress: mocks_test_1.MOCK_ETH_WALLET_ADDRESS,
|
|
150
|
+
},
|
|
151
|
+
];
|
|
152
|
+
expect((0, tx_notes_1.compareERC20AmountRecipientArrays)(erc20AmountRecipients1, erc20AmountRecipients2)).to.be.true;
|
|
153
|
+
expect((0, tx_notes_1.compareERC20AmountRecipientArrays)(erc20AmountRecipients1, erc20AmountRecipients3)).to.be.false;
|
|
154
|
+
expect((0, tx_notes_1.compareERC20AmountRecipientArrays)(erc20AmountRecipients1, erc20AmountRecipients4)).to.be.false;
|
|
155
|
+
expect((0, tx_notes_1.compareERC20AmountRecipientArrays)(erc20AmountRecipients1, erc20AmountRecipients5)).to.be.false;
|
|
156
|
+
});
|
|
157
|
+
it('Should compare erc20 amount recipients', () => {
|
|
158
|
+
const sameA = [
|
|
159
|
+
{
|
|
160
|
+
tokenAddress: '0x1234',
|
|
161
|
+
amount: 100n,
|
|
162
|
+
recipientAddress: 'hello',
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
tokenAddress: '0x1234',
|
|
166
|
+
amount: BigInt(200),
|
|
167
|
+
recipientAddress: 'hello2',
|
|
168
|
+
},
|
|
169
|
+
];
|
|
170
|
+
const sameB = [
|
|
171
|
+
{
|
|
172
|
+
tokenAddress: '0x1234',
|
|
173
|
+
amount: BigInt(200),
|
|
174
|
+
recipientAddress: 'hello2',
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
tokenAddress: '0x1234',
|
|
178
|
+
amount: 100n,
|
|
179
|
+
recipientAddress: 'hello',
|
|
180
|
+
},
|
|
181
|
+
];
|
|
182
|
+
const differentC = [
|
|
183
|
+
{
|
|
184
|
+
tokenAddress: '0x1234',
|
|
185
|
+
amount: 100n,
|
|
186
|
+
recipientAddress: 'hello',
|
|
187
|
+
},
|
|
188
|
+
];
|
|
189
|
+
expect((0, tx_notes_1.compareERC20AmountRecipientArrays)(sameA, sameB)).to.be.true;
|
|
190
|
+
expect((0, tx_notes_1.compareERC20AmountRecipientArrays)(sameA, differentC)).to.be.false;
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
//# sourceMappingURL=tx-notes.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tx-notes.test.js","sourceRoot":"","sources":["../../../../src/services/transactions/__tests__/tx-notes.test.ts"],"names":[],"mappings":";;;;;AAAA,mDAKgC;AAChC,gDAAwB;AACxB,wEAA8C;AAK9C,0DAMmC;AACnC,0DAImC;AACnC,0DAGsC;AACtC,0CAGqB;AAErB,MAAM,UAAU,GAAG,4CAA4C,CAAC;AAEhE,cAAI,CAAC,GAAG,CAAC,0BAAc,CAAC,CAAC;AACzB,MAAM,EAAE,MAAM,EAAE,GAAG,cAAI,CAAC;AAExB,MAAM,iBAAiB,GAAG,CAAC,GAAW,EAAE,EAAE;IACxC,OAAO,kBAAS,CAAC,WAAW,CA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AAY,EAAE,QAAQ;gBACtB,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC;gBACnB,gBAAgB,EAAE,QAAQ;aAC3B;YACD;gBACE,YAAY,EAAE,QAAQ;gBACtB,MAAM,EAAE,IAAI;gBACZ,gBAAgB,EAAE,OAAO;aAC1B;SACF,CAAC;QACF,MAAM,UAAU,GAAiC;YAC/C;gBACE,YAAY,EAAE,QAAQ;gBACtB,MAAM,EAAE,IAAI;gBACZ,gBAAgB,EAAE,OAAO;aAC1B;SACF,CAAC;QAEF,MAAM,CAAC,IAAA,4CAAiC,EAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QACnE,MAAM,CAAC,IAAA,4CAAiC,EAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;IAC3E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {\n OutputType,\n ByteLength,\n ByteUtils,\n MatrixEngine,\n} from '@matrix-privacy/engine';\nimport chai from 'chai';\nimport chaiAsPromised from 'chai-as-promised';\nimport {\n MatrixERC20Amount,\n MatrixERC20AmountRecipient,\n} from '@matrix-privacy/shared-models';\nimport {\n MOCK_DB_ENCRYPTION_KEY,\n MOCK_ETH_WALLET_ADDRESS,\n MOCK_MEMO,\n MOCK_MNEMONIC,\n MOCK_MATRIX_WALLET_ADDRESS,\n} from '../../../tests/mocks.test';\nimport {\n closeTestEngine,\n initTestEngine,\n initTestEngineNetworks,\n} from '../../../tests/setup.test';\nimport {\n createMatrixWallet,\n fullWalletForID,\n} from '../../matrix/wallets/wallets';\nimport {\n compareERC20AmountRecipientArrays,\n erc20NoteFromERC20AmountRecipient,\n} from '../tx-notes';\n\nconst MOCK_TOKEN = '0x236c614a38362644deb15c9789779faf508bc6fe';\n\nchai.use(chaiAsPromised);\nconst { expect } = chai;\n\nconst padTo32BytesUnHex = (str: string) => {\n return ByteUtils.padToLength(ByteUtils.strip0x(str), ByteLength.UINT_256);\n};\n\nconst formatAmountString = (erc20Amount: MatrixERC20Amount) => {\n return BigInt(erc20Amount.amount);\n};\n\nlet matrixWalletID: string;\n\ndescribe('tx-notes', () => {\n before(async function run() {\n this.timeout(60_000);\n await initTestEngine();\n await initTestEngineNetworks();\n const matrixWalletInfo = await createMatrixWallet(\n MOCK_DB_ENCRYPTION_KEY,\n MOCK_MNEMONIC,\n undefined, // creationBlockNumbers\n );\n matrixWalletID = matrixWalletInfo.id;\n });\n after(async () => {\n await closeTestEngine();\n });\n\n it('Should test erc20 note creation', () => {\n const erc20AmountRecipient: MatrixERC20AmountRecipient = {\n tokenAddress: MOCK_TOKEN,\n amount: BigInt(0x100),\n recipientAddress: MOCK_MATRIX_WALLET_ADDRESS,\n };\n const matrixWallet = fullWalletForID(matrixWalletID);\n const note = erc20NoteFromERC20AmountRecipient(\n erc20AmountRecipient,\n matrixWallet,\n OutputType.Transfer,\n true, // showSenderAddressToRecipient\n MOCK_MEMO,\n );\n\n const addressData = MatrixEngine.decodeAddress(\n MOCK_MATRIX_WALLET_ADDRESS,\n );\n\n expect(note.value).to.equal(formatAmountString(erc20AmountRecipient));\n expect(note.receiverAddressData.masterPublicKey).to.equal(\n addressData.masterPublicKey,\n );\n expect(note.tokenHash).to.equal(padTo32BytesUnHex(MOCK_TOKEN));\n });\n\n it('Should test NFT note creation', () => {\n const erc20AmountRecipient: MatrixERC20AmountRecipient = {\n tokenAddress: MOCK_TOKEN,\n amount: BigInt(0x100),\n recipientAddress: MOCK_MATRIX_WALLET_ADDRESS,\n };\n const matrixWallet = fullWalletForID(matrixWalletID);\n const note = erc20NoteFromERC20AmountRecipient(\n erc20AmountRecipient,\n matrixWallet,\n OutputType.Transfer,\n true, // showSenderAddressToRecipient\n MOCK_MEMO,\n );\n\n const addressData = MatrixEngine.decodeAddress(\n MOCK_MATRIX_WALLET_ADDRESS,\n );\n\n expect(note.value).to.equal(formatAmountString(erc20AmountRecipient));\n expect(note.receiverAddressData.masterPublicKey).to.equal(\n addressData.masterPublicKey,\n );\n expect(note.tokenHash).to.equal(padTo32BytesUnHex(MOCK_TOKEN));\n });\n\n it('Should test token array comparisons', () => {\n const erc20AmountRecipients1: MatrixERC20AmountRecipient[] = [\n {\n tokenAddress: '1',\n amount: 100n,\n recipientAddress: MOCK_MATRIX_WALLET_ADDRESS,\n },\n {\n tokenAddress: '2',\n amount: BigInt(200),\n recipientAddress: MOCK_MATRIX_WALLET_ADDRESS,\n },\n {\n tokenAddress: '3',\n amount: 300n,\n recipientAddress: MOCK_MATRIX_WALLET_ADDRESS,\n },\n ];\n\n // Same same\n const erc20AmountRecipients2: MatrixERC20AmountRecipient[] = [\n {\n tokenAddress: '1',\n amount: 100n,\n recipientAddress: MOCK_MATRIX_WALLET_ADDRESS,\n },\n {\n tokenAddress: '2',\n amount: BigInt(200),\n recipientAddress: MOCK_MATRIX_WALLET_ADDRESS,\n },\n {\n tokenAddress: '3',\n amount: 300n,\n recipientAddress: MOCK_MATRIX_WALLET_ADDRESS,\n },\n ];\n\n // Different addresses\n const erc20AmountRecipients3: MatrixERC20AmountRecipient[] = [\n {\n tokenAddress: '1',\n amount: 100n,\n recipientAddress: MOCK_MATRIX_WALLET_ADDRESS,\n },\n {\n tokenAddress: '3',\n amount: BigInt(200),\n recipientAddress: MOCK_MATRIX_WALLET_ADDRESS,\n },\n {\n tokenAddress: '5',\n amount: 300n,\n recipientAddress: MOCK_MATRIX_WALLET_ADDRESS,\n },\n ];\n\n // Different amounts\n const erc20AmountRecipients4: MatrixERC20AmountRecipient[] = [\n {\n tokenAddress: '1',\n amount: 100n,\n recipientAddress: MOCK_MATRIX_WALLET_ADDRESS,\n },\n {\n tokenAddress: '2',\n amount: 300n,\n recipientAddress: MOCK_MATRIX_WALLET_ADDRESS,\n },\n {\n tokenAddress: '3',\n amount: BigInt(200),\n recipientAddress: MOCK_MATRIX_WALLET_ADDRESS,\n },\n ];\n\n // Different recipients\n const erc20AmountRecipients5: MatrixERC20AmountRecipient[] = [\n {\n tokenAddress: '1',\n amount: 100n,\n recipientAddress: MOCK_MATRIX_WALLET_ADDRESS,\n },\n {\n tokenAddress: '2',\n amount: BigInt(200),\n recipientAddress: MOCK_MATRIX_WALLET_ADDRESS,\n },\n {\n tokenAddress: '3',\n amount: 300n,\n recipientAddress: MOCK_ETH_WALLET_ADDRESS,\n },\n ];\n\n expect(\n compareERC20AmountRecipientArrays(\n erc20AmountRecipients1,\n erc20AmountRecipients2,\n ),\n ).to.be.true;\n expect(\n compareERC20AmountRecipientArrays(\n erc20AmountRecipients1,\n erc20AmountRecipients3,\n ),\n ).to.be.false;\n expect(\n compareERC20AmountRecipientArrays(\n erc20AmountRecipients1,\n erc20AmountRecipients4,\n ),\n ).to.be.false;\n expect(\n compareERC20AmountRecipientArrays(\n erc20AmountRecipients1,\n erc20AmountRecipients5,\n ),\n ).to.be.false;\n });\n\n it('Should compare erc20 amount recipients', () => {\n const sameA: MatrixERC20AmountRecipient[] = [\n {\n tokenAddress: '0x1234',\n amount: 100n,\n recipientAddress: 'hello',\n },\n {\n tokenAddress: '0x1234',\n amount: BigInt(200),\n recipientAddress: 'hello2',\n },\n ];\n const sameB: MatrixERC20AmountRecipient[] = [\n {\n tokenAddress: '0x1234',\n amount: BigInt(200),\n recipientAddress: 'hello2',\n },\n {\n tokenAddress: '0x1234',\n amount: 100n,\n recipientAddress: 'hello',\n },\n ];\n const differentC: MatrixERC20AmountRecipient[] = [\n {\n tokenAddress: '0x1234',\n amount: 100n,\n recipientAddress: 'hello',\n },\n ];\n\n expect(compareERC20AmountRecipientArrays(sameA, sameB)).to.be.true;\n expect(compareERC20AmountRecipientArrays(sameA, differentC)).to.be.false;\n });\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const chai_1 = __importDefault(require("chai"));
|
|
30
|
+
const chai_as_promised_1 = __importDefault(require("chai-as-promised"));
|
|
31
|
+
const sinon_1 = __importDefault(require("sinon"));
|
|
32
|
+
const shared_models_1 = require("@matrix-privacy/shared-models");
|
|
33
|
+
const setup_test_1 = require("../../../tests/setup.test");
|
|
34
|
+
const mocks_test_1 = require("../../../tests/mocks.test");
|
|
35
|
+
const tx_shield_base_token_1 = require("../tx-shield-base-token");
|
|
36
|
+
const txGasDetailsModule = __importStar(require("../tx-gas-details"));
|
|
37
|
+
const wallets_1 = require("../../matrix/wallets/wallets");
|
|
38
|
+
const engine_1 = require("@matrix-privacy/engine");
|
|
39
|
+
let getGasEstimateStub;
|
|
40
|
+
let gasEstimateStub;
|
|
41
|
+
let sendTxStub;
|
|
42
|
+
let matrixAddress;
|
|
43
|
+
const shieldPrivateKey = engine_1.ByteUtils.randomHex(32);
|
|
44
|
+
chai_1.default.use(chai_as_promised_1.default);
|
|
45
|
+
const { expect } = chai_1.default;
|
|
46
|
+
const gasDetails = {
|
|
47
|
+
evmGasType: shared_models_1.EVMGasType.Type2,
|
|
48
|
+
gasEstimate: 1000n,
|
|
49
|
+
maxFeePerGas: BigInt('0x1000'),
|
|
50
|
+
maxPriorityFeePerGas: BigInt('0x100'),
|
|
51
|
+
};
|
|
52
|
+
const stubGetGasEstimate = () => {
|
|
53
|
+
getGasEstimateStub = sinon_1.default.stub(txGasDetailsModule, 'getGasEstimate').resolves(200n);
|
|
54
|
+
};
|
|
55
|
+
const stubGetGasEstimateFailure = () => {
|
|
56
|
+
getGasEstimateStub = sinon_1.default.stub(txGasDetailsModule, 'getGasEstimate').rejects(new Error('test rejection - gas estimate'));
|
|
57
|
+
};
|
|
58
|
+
describe('tx-shield-base-token', () => {
|
|
59
|
+
before(async function run() {
|
|
60
|
+
this.timeout(60000);
|
|
61
|
+
await (0, setup_test_1.initTestEngine)();
|
|
62
|
+
await (0, setup_test_1.initTestEngineNetworks)();
|
|
63
|
+
const matrixWalletInfo = await (0, wallets_1.createMatrixWallet)(mocks_test_1.MOCK_DB_ENCRYPTION_KEY, mocks_test_1.MOCK_MNEMONIC, undefined);
|
|
64
|
+
matrixAddress = matrixWalletInfo.matrixAddress;
|
|
65
|
+
});
|
|
66
|
+
afterEach(() => {
|
|
67
|
+
gasEstimateStub?.restore();
|
|
68
|
+
sendTxStub?.restore();
|
|
69
|
+
getGasEstimateStub?.restore();
|
|
70
|
+
});
|
|
71
|
+
after(async () => {
|
|
72
|
+
await (0, setup_test_1.closeTestEngine)();
|
|
73
|
+
});
|
|
74
|
+
it('Should get gas estimate for valid shield base token', async () => {
|
|
75
|
+
stubGetGasEstimate();
|
|
76
|
+
const rsp = await (0, tx_shield_base_token_1.gasEstimateForShieldBaseToken)(shared_models_1.NetworkName.Hardhat, matrixAddress, shieldPrivateKey, mocks_test_1.MOCK_TOKEN_AMOUNTS[0], mocks_test_1.MOCK_ETH_WALLET_ADDRESS);
|
|
77
|
+
expect(rsp.gasEstimate).to.equal(200n);
|
|
78
|
+
});
|
|
79
|
+
it('Should error on gas estimates for invalid shield base token', async () => {
|
|
80
|
+
stubGetGasEstimate();
|
|
81
|
+
await expect((0, tx_shield_base_token_1.gasEstimateForShieldBaseToken)(shared_models_1.NetworkName.Hardhat, '123456789', shieldPrivateKey, mocks_test_1.MOCK_TOKEN_AMOUNTS[0], mocks_test_1.MOCK_ETH_WALLET_ADDRESS)).rejectedWith('Invalid Matrix address.');
|
|
82
|
+
});
|
|
83
|
+
it('Should error for ethers rejections', async () => {
|
|
84
|
+
stubGetGasEstimateFailure();
|
|
85
|
+
await expect((0, tx_shield_base_token_1.gasEstimateForShieldBaseToken)(shared_models_1.NetworkName.Hardhat, matrixAddress, shieldPrivateKey, mocks_test_1.MOCK_TOKEN_AMOUNTS[0], mocks_test_1.MOCK_ETH_WALLET_ADDRESS)).rejectedWith('test rejection - gas estimate');
|
|
86
|
+
});
|
|
87
|
+
it('Should send tx for valid shield base token', async () => {
|
|
88
|
+
stubGetGasEstimate();
|
|
89
|
+
const { transaction } = await (0, tx_shield_base_token_1.populateShieldBaseToken)(shared_models_1.NetworkName.Hardhat, matrixAddress, shieldPrivateKey, mocks_test_1.MOCK_TOKEN_AMOUNTS[0], gasDetails);
|
|
90
|
+
expect(transaction).to.be.an('object');
|
|
91
|
+
expect(transaction.data).to.be.a('string');
|
|
92
|
+
expect(transaction.to).to.be.a('string');
|
|
93
|
+
});
|
|
94
|
+
it('Should error on send tx for invalid shield base token', async () => {
|
|
95
|
+
stubGetGasEstimate();
|
|
96
|
+
await expect((0, tx_shield_base_token_1.populateShieldBaseToken)(shared_models_1.NetworkName.Hardhat, '123456789', shieldPrivateKey, mocks_test_1.MOCK_TOKEN_AMOUNTS[0], gasDetails)).rejectedWith('Invalid Matrix address.');
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
//# sourceMappingURL=tx-shield-base-token.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tx-shield-base-token.test.js","sourceRoot":"","sources":["../../../../src/services/transactions/__tests__/tx-shield-base-token.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAwB;AACxB,wEAA8C;AAC9C,kDAAyC;AACzC,iEAIuC;AACvC,0DAImC;AACnC,0DAKmC;AACnC,kEAGiC;AACjC,sEAAwD;AACxD,0DAAkE;AAClE,mDAAmD;AAEnD,IAAI,kBAA6B,CAAC;AAClC,IAAI,eAA0B,CAAC;AAC/B,IAAI,UAAqB,CAAC;AAC1B,IAAI,aAAqB,CAAC;AAE1B,MAAM,gBAAgB,GAAG,kBAAS,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;AAEjD,cAAI,CAAC,GAAG,CAAC,0BAAc,CAAC,CAAC;AACzB,MAAM,EAAE,MAAM,EAAE,GAAG,cAAI,CAAC;AAExB,MAAM,UAAU,GAA0B;IACxC,UAAU,EAAE,0BAAU,CAAC,KAAK;IAC5B,WAAW,EAAE,KAAK;IAClB,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC9B,oBAAoB,EAAE,MAAM,CAAC,OAAO,CAAC;CACtC,CAAC;AAEF,MAAM,kBAAkB,GAAG,GAAG,EAAE;IAC9B,kBAAkB,GAAG,eAAK,CAAC,IAAI,CAC7B,kBAAkB,EAClB,gBAAgB,CACjB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACnB,CAAC,CAAC;AAEF,MAAM,yBAAyB,GAAG,GAAG,EAAE;IACrC,kBAAkB,GAAG,eAAK,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ACF,CAAC,YAAY,CAAC,yBAAyB,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import chai from 'chai';\nimport chaiAsPromised from 'chai-as-promised';\nimport Sinon, { SinonStub } from 'sinon';\nimport {\n NetworkName,\n EVMGasType,\n TransactionGasDetails,\n} from '@matrix-privacy/shared-models';\nimport {\n closeTestEngine,\n initTestEngine,\n initTestEngineNetworks,\n} from '../../../tests/setup.test';\nimport {\n MOCK_DB_ENCRYPTION_KEY,\n MOCK_ETH_WALLET_ADDRESS,\n MOCK_MNEMONIC,\n MOCK_TOKEN_AMOUNTS,\n} from '../../../tests/mocks.test';\nimport {\n populateShieldBaseToken,\n gasEstimateForShieldBaseToken,\n} from '../tx-shield-base-token';\nimport * as txGasDetailsModule from '../tx-gas-details';\nimport { createMatrixWallet } from '../../matrix/wallets/wallets';\nimport { ByteUtils } from '@matrix-privacy/engine';\n\nlet getGasEstimateStub: SinonStub;\nlet gasEstimateStub: SinonStub;\nlet sendTxStub: SinonStub;\nlet matrixAddress: string;\n\nconst shieldPrivateKey = ByteUtils.randomHex(32);\n\nchai.use(chaiAsPromised);\nconst { expect } = chai;\n\nconst gasDetails: TransactionGasDetails = {\n evmGasType: EVMGasType.Type2,\n gasEstimate: 1000n,\n maxFeePerGas: BigInt('0x1000'),\n maxPriorityFeePerGas: BigInt('0x100'),\n};\n\nconst stubGetGasEstimate = () => {\n getGasEstimateStub = Sinon.stub(\n txGasDetailsModule,\n 'getGasEstimate',\n ).resolves(200n);\n};\n\nconst stubGetGasEstimateFailure = () => {\n getGasEstimateStub = Sinon.stub(txGasDetailsModule, 'getGasEstimate').rejects(\n new Error('test rejection - gas estimate'),\n );\n};\n\ndescribe('tx-shield-base-token', () => {\n before(async function run() {\n this.timeout(60_000);\n await initTestEngine();\n await initTestEngineNetworks();\n const matrixWalletInfo = await createMatrixWallet(\n MOCK_DB_ENCRYPTION_KEY,\n MOCK_MNEMONIC,\n undefined, // creationBlockNumbers\n );\n\n matrixAddress = matrixWalletInfo.matrixAddress;\n });\n afterEach(() => {\n gasEstimateStub?.restore();\n sendTxStub?.restore();\n getGasEstimateStub?.restore();\n });\n after(async () => {\n await closeTestEngine();\n });\n\n it('Should get gas estimate for valid shield base token', async () => {\n stubGetGasEstimate();\n const rsp = await gasEstimateForShieldBaseToken(\n NetworkName.Hardhat,\n matrixAddress,\n shieldPrivateKey,\n MOCK_TOKEN_AMOUNTS[0],\n MOCK_ETH_WALLET_ADDRESS,\n );\n expect(rsp.gasEstimate).to.equal(200n);\n });\n\n it('Should error on gas estimates for invalid shield base token', async () => {\n stubGetGasEstimate();\n await expect(\n gasEstimateForShieldBaseToken(\n NetworkName.Hardhat,\n '123456789',\n shieldPrivateKey,\n MOCK_TOKEN_AMOUNTS[0],\n MOCK_ETH_WALLET_ADDRESS,\n ),\n ).rejectedWith('Invalid Matrix address.');\n });\n\n it('Should error for ethers rejections', async () => {\n stubGetGasEstimateFailure();\n await expect(\n gasEstimateForShieldBaseToken(\n NetworkName.Hardhat,\n matrixAddress,\n shieldPrivateKey,\n MOCK_TOKEN_AMOUNTS[0],\n MOCK_ETH_WALLET_ADDRESS,\n ),\n ).rejectedWith('test rejection - gas estimate');\n });\n\n it('Should send tx for valid shield base token', async () => {\n stubGetGasEstimate();\n const { transaction } = await populateShieldBaseToken(\n NetworkName.Hardhat,\n matrixAddress,\n shieldPrivateKey,\n MOCK_TOKEN_AMOUNTS[0],\n gasDetails,\n );\n expect(transaction).to.be.an('object');\n expect(transaction.data).to.be.a('string');\n expect(transaction.to).to.be.a('string');\n });\n\n it('Should error on send tx for invalid shield base token', async () => {\n stubGetGasEstimate();\n await expect(\n populateShieldBaseToken(\n NetworkName.Hardhat,\n '123456789',\n shieldPrivateKey,\n MOCK_TOKEN_AMOUNTS[0],\n gasDetails,\n ),\n ).rejectedWith('Invalid Matrix address.');\n });\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const chai_1 = __importDefault(require("chai"));
|
|
30
|
+
const chai_as_promised_1 = __importDefault(require("chai-as-promised"));
|
|
31
|
+
const sinon_1 = __importDefault(require("sinon"));
|
|
32
|
+
const shared_models_1 = require("@matrix-privacy/shared-models");
|
|
33
|
+
const setup_test_1 = require("../../../tests/setup.test");
|
|
34
|
+
const mocks_test_1 = require("../../../tests/mocks.test");
|
|
35
|
+
const tx_shield_1 = require("../tx-shield");
|
|
36
|
+
const wallets_1 = require("../../matrix/wallets/wallets");
|
|
37
|
+
const matrix_1 = require("../../matrix");
|
|
38
|
+
const ethers_1 = require("ethers");
|
|
39
|
+
const txGasDetailsModule = __importStar(require("../tx-gas-details"));
|
|
40
|
+
let getGasEstimateStub;
|
|
41
|
+
let gasEstimateStub;
|
|
42
|
+
let sendTxStub;
|
|
43
|
+
const shieldPrivateKey = (0, matrix_1.getRandomBytes)(32);
|
|
44
|
+
chai_1.default.use(chai_as_promised_1.default);
|
|
45
|
+
const { expect } = chai_1.default;
|
|
46
|
+
const gasDetails = {
|
|
47
|
+
evmGasType: shared_models_1.EVMGasType.Type2,
|
|
48
|
+
gasEstimate: BigInt('0x10'),
|
|
49
|
+
maxFeePerGas: BigInt('0x1000'),
|
|
50
|
+
maxPriorityFeePerGas: BigInt('0x100'),
|
|
51
|
+
};
|
|
52
|
+
const MOCK_TOKEN_AMOUNT_RECIPIENTS = [
|
|
53
|
+
{
|
|
54
|
+
tokenAddress: mocks_test_1.MOCK_TOKEN_ADDRESS,
|
|
55
|
+
amount: BigInt(0x100),
|
|
56
|
+
recipientAddress: mocks_test_1.MOCK_MATRIX_WALLET_ADDRESS,
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
tokenAddress: mocks_test_1.MOCK_TOKEN_ADDRESS_2,
|
|
60
|
+
amount: BigInt(0x200),
|
|
61
|
+
recipientAddress: mocks_test_1.MOCK_MATRIX_WALLET_ADDRESS,
|
|
62
|
+
},
|
|
63
|
+
];
|
|
64
|
+
const MOCK_TOKEN_AMOUNT_RECIPIENTS_INVALID = [
|
|
65
|
+
{
|
|
66
|
+
tokenAddress: mocks_test_1.MOCK_TOKEN_ADDRESS,
|
|
67
|
+
amount: BigInt(0x100),
|
|
68
|
+
recipientAddress: '0x1234',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
tokenAddress: mocks_test_1.MOCK_TOKEN_ADDRESS_2,
|
|
72
|
+
amount: BigInt(0x200),
|
|
73
|
+
recipientAddress: '0x1234',
|
|
74
|
+
},
|
|
75
|
+
];
|
|
76
|
+
const stubSuccess = () => {
|
|
77
|
+
gasEstimateStub = sinon_1.default.stub(ethers_1.FallbackProvider.prototype, 'estimateGas').resolves(200n);
|
|
78
|
+
};
|
|
79
|
+
const stubFailure = () => {
|
|
80
|
+
gasEstimateStub = sinon_1.default.stub(ethers_1.FallbackProvider.prototype, 'estimateGas').rejects(new Error('test rejection - gas estimate'));
|
|
81
|
+
};
|
|
82
|
+
const stubGetGasEstimate = () => {
|
|
83
|
+
getGasEstimateStub = sinon_1.default.stub(txGasDetailsModule, 'getGasEstimate').resolves(200n);
|
|
84
|
+
};
|
|
85
|
+
const stubGetGasEstimateFailure = () => {
|
|
86
|
+
getGasEstimateStub = sinon_1.default.stub(txGasDetailsModule, 'getGasEstimate').rejects(new Error('test rejection - gas estimate'));
|
|
87
|
+
};
|
|
88
|
+
describe('tx-shield', () => {
|
|
89
|
+
before(async function run() {
|
|
90
|
+
this.timeout(60000);
|
|
91
|
+
await (0, setup_test_1.initTestEngine)();
|
|
92
|
+
await (0, setup_test_1.initTestEngineNetworks)();
|
|
93
|
+
await (0, wallets_1.createMatrixWallet)(mocks_test_1.MOCK_DB_ENCRYPTION_KEY, mocks_test_1.MOCK_MNEMONIC, undefined);
|
|
94
|
+
});
|
|
95
|
+
afterEach(() => {
|
|
96
|
+
gasEstimateStub?.restore();
|
|
97
|
+
sendTxStub?.restore();
|
|
98
|
+
getGasEstimateStub?.restore();
|
|
99
|
+
});
|
|
100
|
+
after(async () => {
|
|
101
|
+
await (0, setup_test_1.closeTestEngine)();
|
|
102
|
+
});
|
|
103
|
+
it('Should get expected signature message for shieldPrivateKey', () => {
|
|
104
|
+
expect((0, tx_shield_1.getShieldPrivateKeySignatureMessage)()).to.equal('MATRIX_SHIELD');
|
|
105
|
+
});
|
|
106
|
+
it('Should get gas estimate for valid shield', async () => {
|
|
107
|
+
stubGetGasEstimate();
|
|
108
|
+
const rsp = await (0, tx_shield_1.gasEstimateForShield)(shared_models_1.NetworkName.Hardhat, shieldPrivateKey, MOCK_TOKEN_AMOUNT_RECIPIENTS, mocks_test_1.MOCK_NFT_AMOUNT_RECIPIENTS, mocks_test_1.MOCK_ETH_WALLET_ADDRESS);
|
|
109
|
+
expect(rsp.gasEstimate).to.equal(200n);
|
|
110
|
+
});
|
|
111
|
+
it('Should error on gas estimates for invalid shield', async () => {
|
|
112
|
+
stubGetGasEstimate();
|
|
113
|
+
await expect((0, tx_shield_1.gasEstimateForShield)(shared_models_1.NetworkName.Hardhat, shieldPrivateKey, MOCK_TOKEN_AMOUNT_RECIPIENTS_INVALID, mocks_test_1.MOCK_NFT_AMOUNT_RECIPIENTS, mocks_test_1.MOCK_ETH_WALLET_ADDRESS)).rejectedWith('Invalid Matrix address.');
|
|
114
|
+
});
|
|
115
|
+
it('Should error for ethers rejections', async () => {
|
|
116
|
+
stubGetGasEstimateFailure();
|
|
117
|
+
await expect((0, tx_shield_1.gasEstimateForShield)(shared_models_1.NetworkName.Hardhat, shieldPrivateKey, MOCK_TOKEN_AMOUNT_RECIPIENTS, mocks_test_1.MOCK_NFT_AMOUNT_RECIPIENTS, mocks_test_1.MOCK_ETH_WALLET_ADDRESS)).rejectedWith('test rejection - gas estimate');
|
|
118
|
+
});
|
|
119
|
+
it('Should send tx for valid shield - no gas details', async () => {
|
|
120
|
+
stubGetGasEstimate();
|
|
121
|
+
const { transaction } = await (0, tx_shield_1.populateShield)(shared_models_1.NetworkName.Hardhat, shieldPrivateKey, MOCK_TOKEN_AMOUNT_RECIPIENTS, mocks_test_1.MOCK_NFT_AMOUNT_RECIPIENTS, undefined);
|
|
122
|
+
expect(transaction).to.be.an('object');
|
|
123
|
+
expect(transaction.data).to.be.a('string');
|
|
124
|
+
expect(transaction.to).to.be.a('string');
|
|
125
|
+
expect(transaction.gasPrice).to.be.undefined;
|
|
126
|
+
expect(transaction.gasLimit).to.be.undefined;
|
|
127
|
+
expect(transaction.maxFeePerGas).to.be.undefined;
|
|
128
|
+
expect(transaction.maxPriorityFeePerGas).to.be.undefined;
|
|
129
|
+
});
|
|
130
|
+
it('Should send tx for valid shield - gas details', async () => {
|
|
131
|
+
stubGetGasEstimate();
|
|
132
|
+
const { transaction } = await (0, tx_shield_1.populateShield)(shared_models_1.NetworkName.Hardhat, shieldPrivateKey, MOCK_TOKEN_AMOUNT_RECIPIENTS, mocks_test_1.MOCK_NFT_AMOUNT_RECIPIENTS, gasDetails);
|
|
133
|
+
expect(transaction).to.be.an('object');
|
|
134
|
+
expect(transaction.data).to.be.a('string');
|
|
135
|
+
expect(transaction.to).to.be.a('string');
|
|
136
|
+
expect(transaction.gasPrice).to.be.undefined;
|
|
137
|
+
expect(transaction.gasLimit).to.equal(BigInt('0x13'));
|
|
138
|
+
expect(transaction.maxFeePerGas).to.equal(BigInt('0x1000'));
|
|
139
|
+
expect(transaction.maxPriorityFeePerGas).to.equal(BigInt('0x0100'));
|
|
140
|
+
});
|
|
141
|
+
it('Should error on send tx for invalid shield', async () => {
|
|
142
|
+
stubGetGasEstimate();
|
|
143
|
+
await expect((0, tx_shield_1.populateShield)(shared_models_1.NetworkName.Hardhat, shieldPrivateKey, MOCK_TOKEN_AMOUNT_RECIPIENTS_INVALID, mocks_test_1.MOCK_NFT_AMOUNT_RECIPIENTS, gasDetails)).rejectedWith('Invalid Matrix address.');
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
//# sourceMappingURL=tx-shield.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tx-shield.test.js","sourceRoot":"","sources":["../../../../src/services/transactions/__tests__/tx-shield.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAwB;AACxB,wEAA8C;AAC9C,kDAAyC;AACzC,iEAKuC;AACvC,0DAImC;AACnC,0DAQmC;AACnC,4CAIsB;AACtB,0DAAkE;AAClE,yCAA8C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,MAAM,CAAC,CAAC,CAAC;QACtD,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC5D,MAAM,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4CAA4C,EAAE,KAAK,IAAI,EAAE;QAC1D,kBAAkB,EAAE,CAAC;QACrB,MAAM,MAAM,CACV,IAAA,0BAAc,EACZ,2BAAW,CAAC,OAAO,EACnB,gBAAgB,EAChB,oCAAoC,EACpC,uCAA0B,EAC1B,UAAU,CACX,CACF,CAAC,YAAY,CAAC,yBAAyB,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import chai from 'chai';\nimport chaiAsPromised from 'chai-as-promised';\nimport Sinon, { SinonStub } from 'sinon';\nimport {\n NetworkName,\n EVMGasType,\n MatrixERC20AmountRecipient,\n TransactionGasDetails,\n} from '@matrix-privacy/shared-models';\nimport {\n closeTestEngine,\n initTestEngine,\n initTestEngineNetworks,\n} from '../../../tests/setup.test';\nimport {\n MOCK_DB_ENCRYPTION_KEY,\n MOCK_ETH_WALLET_ADDRESS,\n MOCK_MNEMONIC,\n MOCK_NFT_AMOUNT_RECIPIENTS,\n MOCK_MATRIX_WALLET_ADDRESS,\n MOCK_TOKEN_ADDRESS,\n MOCK_TOKEN_ADDRESS_2,\n} from '../../../tests/mocks.test';\nimport {\n populateShield,\n gasEstimateForShield,\n getShieldPrivateKeySignatureMessage,\n} from '../tx-shield';\nimport { createMatrixWallet } from '../../matrix/wallets/wallets';\nimport { getRandomBytes } from '../../matrix';\nimport { FallbackProvider } from 'ethers';\nimport * as txGasDetailsModule from '../tx-gas-details';\n\nlet getGasEstimateStub: SinonStub;\nlet gasEstimateStub: SinonStub;\nlet sendTxStub: SinonStub;\n\nconst shieldPrivateKey = getRandomBytes(32);\n\nchai.use(chaiAsPromised);\nconst { expect } = chai;\n\nconst gasDetails: TransactionGasDetails = {\n evmGasType: EVMGasType.Type2,\n gasEstimate: BigInt('0x10'),\n maxFeePerGas: BigInt('0x1000'),\n maxPriorityFeePerGas: BigInt('0x100'),\n};\n\nconst MOCK_TOKEN_AMOUNT_RECIPIENTS: MatrixERC20AmountRecipient[] = [\n {\n tokenAddress: MOCK_TOKEN_ADDRESS,\n amount: BigInt(0x100),\n recipientAddress: MOCK_MATRIX_WALLET_ADDRESS,\n },\n {\n tokenAddress: MOCK_TOKEN_ADDRESS_2,\n amount: BigInt(0x200),\n recipientAddress: MOCK_MATRIX_WALLET_ADDRESS,\n },\n];\n\nconst MOCK_TOKEN_AMOUNT_RECIPIENTS_INVALID: MatrixERC20AmountRecipient[] = [\n {\n tokenAddress: MOCK_TOKEN_ADDRESS,\n amount: BigInt(0x100),\n recipientAddress: '0x1234',\n },\n {\n tokenAddress: MOCK_TOKEN_ADDRESS_2,\n amount: BigInt(0x200),\n recipientAddress: '0x1234',\n },\n];\n\nconst stubSuccess = () => {\n gasEstimateStub = Sinon.stub(\n FallbackProvider.prototype,\n 'estimateGas',\n ).resolves(200n);\n};\n\nconst stubFailure = () => {\n gasEstimateStub = Sinon.stub(\n FallbackProvider.prototype,\n 'estimateGas',\n ).rejects(new Error('test rejection - gas estimate'));\n};\n\nconst stubGetGasEstimate = () => {\n getGasEstimateStub = Sinon.stub(\n txGasDetailsModule,\n 'getGasEstimate',\n ).resolves(200n);\n};\n\nconst stubGetGasEstimateFailure = () => {\n getGasEstimateStub = Sinon.stub(txGasDetailsModule, 'getGasEstimate').rejects(\n new Error('test rejection - gas estimate'),\n );\n};\n\ndescribe('tx-shield', () => {\n before(async function run() {\n this.timeout(60_000);\n await initTestEngine();\n await initTestEngineNetworks();\n await createMatrixWallet(\n MOCK_DB_ENCRYPTION_KEY,\n MOCK_MNEMONIC,\n undefined, // creationBlockNumbers\n );\n });\n afterEach(() => {\n gasEstimateStub?.restore();\n sendTxStub?.restore();\n getGasEstimateStub?.restore();\n });\n after(async () => {\n await closeTestEngine();\n });\n\n it('Should get expected signature message for shieldPrivateKey', () => {\n expect(getShieldPrivateKeySignatureMessage()).to.equal('MATRIX_SHIELD');\n });\n\n it('Should get gas estimate for valid shield', async () => {\n stubGetGasEstimate();\n const rsp = await gasEstimateForShield(\n NetworkName.Hardhat,\n shieldPrivateKey,\n MOCK_TOKEN_AMOUNT_RECIPIENTS,\n MOCK_NFT_AMOUNT_RECIPIENTS,\n MOCK_ETH_WALLET_ADDRESS,\n );\n expect(rsp.gasEstimate).to.equal(200n);\n });\n\n it('Should error on gas estimates for invalid shield', async () => {\n stubGetGasEstimate();\n await expect(\n gasEstimateForShield(\n NetworkName.Hardhat,\n shieldPrivateKey,\n MOCK_TOKEN_AMOUNT_RECIPIENTS_INVALID,\n MOCK_NFT_AMOUNT_RECIPIENTS,\n MOCK_ETH_WALLET_ADDRESS,\n ),\n ).rejectedWith('Invalid Matrix address.');\n });\n\n it('Should error for ethers rejections', async () => {\n stubGetGasEstimateFailure();\n await expect(\n gasEstimateForShield(\n NetworkName.Hardhat,\n shieldPrivateKey,\n MOCK_TOKEN_AMOUNT_RECIPIENTS,\n MOCK_NFT_AMOUNT_RECIPIENTS,\n MOCK_ETH_WALLET_ADDRESS,\n ),\n ).rejectedWith('test rejection - gas estimate');\n });\n\n it('Should send tx for valid shield - no gas details', async () => {\n stubGetGasEstimate();\n const { transaction } = await populateShield(\n NetworkName.Hardhat,\n shieldPrivateKey,\n MOCK_TOKEN_AMOUNT_RECIPIENTS,\n MOCK_NFT_AMOUNT_RECIPIENTS,\n undefined, // gasDetails\n );\n expect(transaction).to.be.an('object');\n expect(transaction.data).to.be.a('string');\n expect(transaction.to).to.be.a('string');\n expect(transaction.gasPrice).to.be.undefined;\n expect(transaction.gasLimit).to.be.undefined;\n expect(transaction.maxFeePerGas).to.be.undefined;\n expect(transaction.maxPriorityFeePerGas).to.be.undefined;\n });\n\n it('Should send tx for valid shield - gas details', async () => {\n stubGetGasEstimate();\n const { transaction } = await populateShield(\n NetworkName.Hardhat,\n shieldPrivateKey,\n MOCK_TOKEN_AMOUNT_RECIPIENTS,\n MOCK_NFT_AMOUNT_RECIPIENTS,\n gasDetails,\n );\n expect(transaction).to.be.an('object');\n expect(transaction.data).to.be.a('string');\n expect(transaction.to).to.be.a('string');\n expect(transaction.gasPrice).to.be.undefined;\n expect(transaction.gasLimit).to.equal(BigInt('0x13'));\n expect(transaction.maxFeePerGas).to.equal(BigInt('0x1000'));\n expect(transaction.maxPriorityFeePerGas).to.equal(BigInt('0x0100'));\n });\n\n it('Should error on send tx for invalid shield', async () => {\n stubGetGasEstimate();\n await expect(\n populateShield(\n NetworkName.Hardhat,\n shieldPrivateKey,\n MOCK_TOKEN_AMOUNT_RECIPIENTS_INVALID,\n MOCK_NFT_AMOUNT_RECIPIENTS,\n gasDetails,\n ),\n ).rejectedWith('Invalid Matrix address.');\n });\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|