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

hicommonwealth / commonwealth / 14224467398

02 Apr 2025 04:14PM UTC coverage: 46.16% (+0.9%) from 45.271%
14224467398

Pull #11708

github

web-flow
Merge 8217924f6 into 93e428e3b
Pull Request #11708: Added deletion script for 1inch

1582 of 3790 branches covered (41.74%)

Branch coverage included in aggregate %.

2920 of 5963 relevant lines covered (48.97%)

40.21 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;
×
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
        tier: 0,
62
        spam_tier_level: -1,
63
        default_symbol: symbol,
64
        icon_url,
65
        description,
66
        network: ChainNetwork.Ethereum,
67
        type,
68
        social_links: [],
69
        base,
70
        bech32_prefix: node.bech32,
71
        active: true,
72
        chain_node_id: node.id,
73
        token_name: name,
74
        default_page: DefaultPage.Discussions,
75
        has_homepage: 'true',
76
        collapsed_on_homepage: false,
77
        custom_stages: [],
78
        directory_page_enabled: false,
79
        snapshot_spaces: [],
80
        stages_enabled: true,
81
      });
82
      return {
×
83
        community,
84
        namespaceAddress,
85
      };
86
    },
87
  };
88
}
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