• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hicommonwealth / commonwealth / 13973489816

20 Mar 2025 03:44PM UTC coverage: 43.661% (+0.02%) from 43.641%
13973489816

push

github

web-flow
Merge pull request #11177 from hicommonwealth/tim/cp-viem

Contest Web3 -> Viem

1393 of 3542 branches covered (39.33%)

Branch coverage included in aggregate %.

5 of 23 new or added lines in 8 files covered. (21.74%)

2 existing lines in 1 file now uncovered.

2612 of 5631 relevant lines covered (46.39%)

37.73 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/libs/model/src/aggregates/bot/CreateBotNamespace.command.ts
1
import { ServerError, type Command } from '@hicommonwealth/core';
2
import {
3
  deployNamespace,
4
  mustBeProtocolChainId,
5
} from '@hicommonwealth/evm-protocols';
6
import { config } from '@hicommonwealth/model';
7
import * as schemas from '@hicommonwealth/schemas';
8
import {
9
  ChainBase,
10
  ChainNetwork,
11
  ChainType,
12
  DefaultPage,
13
} from '@hicommonwealth/shared';
14
import { models } from '../../database';
15
import { mustExist } from '../../middleware/guards';
16

17
export function CreateBotNamespace(): Command<
18
  typeof schemas.CreateBotNamespace
19
> {
20
  return {
×
21
    ...schemas.CreateBotNamespace,
22
    auth: [],
23
    body: async ({ payload }) => {
24
      const { name, description, icon_url, admin_address, chain_id } = payload;
×
NEW
25
      mustBeProtocolChainId(chain_id);
×
26

27
      const node = await models.ChainNode.scope('withPrivateData').findOne({
×
28
        where: {
29
          eth_chain_id: chain_id,
30
        },
31
      });
32
      mustExist('chainNode', node);
×
33

34
      if (!config.WEB3.CONTEST_BOT_PRIVATE_KEY)
×
35
        throw new ServerError('Contest bot private key not set!');
×
36

37
      const namespaceAddress = await deployNamespace(
×
38
        name,
39
        admin_address,
40
        admin_address,
41
        {
42
          rpc: node.private_url!,
43
          eth_chain_id: chain_id,
44
        },
45
        config.WEB3.CONTEST_BOT_PRIVATE_KEY,
46
      );
47

48
      const base = ChainBase.Ethereum;
×
49
      const type = ChainType.Token;
×
50

51
      const baseCommunity = await models.Community.findOne({ where: { base } });
×
52
      mustExist('Chain Base', baseCommunity);
×
53
      const symbol = name.toUpperCase().slice(0, 4);
×
54
      const community = await models.Community.create({
×
55
        id: name
56
          .replace(/[^A-Za-z0-9 -]/g, '')
57
          .replace(/(\s|-)+/g, '-')
58
          .replace(/^-|-$/g, '')
59
          .toLowerCase(),
60
        name,
61
        default_symbol: symbol,
62
        icon_url,
63
        description,
64
        network: ChainNetwork.Ethereum,
65
        type,
66
        social_links: [],
67
        base,
68
        bech32_prefix: node.bech32,
69
        active: true,
70
        chain_node_id: node.id,
71
        token_name: name,
72
        default_page: DefaultPage.Discussions,
73
        has_homepage: 'true',
74
        collapsed_on_homepage: false,
75
        custom_stages: [],
76
        directory_page_enabled: false,
77
        snapshot_spaces: [],
78
        stages_enabled: true,
79
      });
80
      return {
×
81
        community,
82
        namespaceAddress,
83
      };
84
    },
85
  };
86
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc