Skip to content

Commit

Permalink
Merge branch 'master' into feat/update-examples
Browse files Browse the repository at this point in the history
  • Loading branch information
maycon-mello authored Dec 13, 2024
2 parents dacfb68 + 070f9c8 commit 9d153cd
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
23 changes: 23 additions & 0 deletions packages/data-store/src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {CURRENT_DATA_STORE_VERSION} from '../migration';
import {DataStore} from '../types';
import {WalletEntity, getWallet} from '../entities/wallet.entity';
import {closeDataStore} from '../index';
import { DEFAULT_CONFIGS } from '../configs';

describe('Data store', () => {
describe('v2-data-store migration', () => {
Expand Down Expand Up @@ -53,4 +54,26 @@ describe('Data store', () => {
closeDataStore(dataStore);
});
});

it('should validate regex hostnames correctly', () => {
const mainnetHostnames = DEFAULT_CONFIGS.networks.find(net => net.id === 'mainnet')?.credentialHostnames || [];
const testnetHostnames = DEFAULT_CONFIGS.networks.find(net => net.id === 'testnet')?.credentialHostnames || [];

const mainnetPatterns = mainnetHostnames.filter(host => host instanceof RegExp) as RegExp[];
const testnetPatterns = testnetHostnames.filter(host => host instanceof RegExp) as RegExp[];


mainnetPatterns.forEach(regex => {
expect(regex.test('creds.dock.io')).toBe(true);
expect(regex.test('creds.example.io')).toBe(true);
expect(regex.test('invalid.dock.io')).toBe(false);
});


testnetPatterns.forEach(regex => {
expect(regex.test('creds-test.dock.io')).toBe(true);
expect(regex.test('creds-something.io')).toBe(true);
expect(regex.test('invalid.io')).toBe(false);
});
});
});
4 changes: 2 additions & 2 deletions packages/data-store/src/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ export const DEFAULT_CONFIGS: DataStoreConfigs = {
{
name: 'Mainnet',
id: 'mainnet',
credentialHostnames: ['creds.dock.io'],
credentialHostnames: [/creds\..*\.io/],
configs: SUBSTRATE_NETWORKS.mainnet,
},
{
name: 'Testnet',
id: 'testnet',
credentialHostnames: [/creds-.*\.dock\.io/],
credentialHostnames: [/creds-.*\.*\.io/],
configs: SUBSTRATE_NETWORKS.testnet,
},
],
Expand Down
2 changes: 1 addition & 1 deletion packages/data-store/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export type DocumentResolverResult = {
export type Network = {
name: string;
id: string;
credentialHostnames: [string | RegExp];
credentialHostnames: Array<string | RegExp>;
configs?: any;
};

Expand Down
4 changes: 3 additions & 1 deletion packages/react-native/bundler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ const getWebpackConfig = ({entry, path, filename}) => ({
rules: [
{
test: /\.(m|c)?(j|t)s$/,
exclude: [/\/node_modules\/(?!@polkadot|@docknetwork|@digitalbazaar)/],
exclude: [
/\/node_modules\/(?!@polkadot|@docknetwork|@digitalbazaar|@cheqd)/,
],
use: {
loader: require.resolve('babel-loader'),
options: {
Expand Down

0 comments on commit 9d153cd

Please sign in to comment.