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

hicommonwealth / commonwealth / 12815130721

16 Jan 2025 06:20PM UTC coverage: 47.732% (-0.3%) from 47.993%
12815130721

push

github

web-flow
Merge pull request #10544 from hicommonwealth/10479-bot-commands-for-on-chain-actions

create namespace command

1350 of 3171 branches covered (42.57%)

Branch coverage included in aggregate %.

0 of 32 new or added lines in 2 files covered. (0.0%)

2680 of 5272 relevant lines covered (50.83%)

36.27 hits per line

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

0.0
/libs/model/src/bot/CreateBotNamespace.command.ts
1
import { ServerError, type Command } from '@hicommonwealth/core';
2
import {
3
  commonProtocol as cp,
4
  deployNamespace,
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
> {
NEW
20
  return {
×
21
    ...schemas.CreateBotNamespace,
22
    auth: [],
23
    body: async ({ payload }) => {
NEW
24
      const { name, description, icon_url, admin_address, chain_id } = payload;
×
25
      const namespaceFactory =
NEW
26
        cp.factoryContracts[chain_id as cp.ValidChains].factory;
×
27

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

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

NEW
38
      const namespaceAddress = await deployNamespace(
×
39
        namespaceFactory,
40
        name,
41
        admin_address,
42
        admin_address,
43
        node.private_url!,
44
        config.WEB3.CONTEST_BOT_PRIVATE_KEY,
45
      );
46

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

NEW
50
      const baseCommunity = await models.Community.findOne({ where: { base } });
×
NEW
51
      mustExist('Chain Base', baseCommunity);
×
NEW
52
      const symbol = name.toUpperCase().slice(0, 4);
×
NEW
53
      const community = await models.Community.create({
×
54
        id: name
55
          .replace(/[^A-Za-z0-9 -]/g, '')
56
          .replace(/(\s|-)+/g, '-')
57
          .replace(/^-|-$/g, '')
58
          .toLowerCase(),
59
        name,
60
        default_symbol: symbol,
61
        icon_url,
62
        description,
63
        network: ChainNetwork.Ethereum,
64
        type,
65
        social_links: [],
66
        base,
67
        bech32_prefix: node.bech32,
68
        active: true,
69
        chain_node_id: node.id,
70
        token_name: name,
71
        default_page: DefaultPage.Discussions,
72
        has_homepage: 'true',
73
        collapsed_on_homepage: false,
74
        custom_stages: [],
75
        directory_page_enabled: false,
76
        snapshot_spaces: [],
77
        stages_enabled: true,
78
      });
NEW
79
      return {
×
80
        community,
81
        namespaceAddress,
82
      };
83
    },
84
  };
85
}
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