Skip to content

Commit 6313ad4

Browse files
committed
add token holder entity and resolver, and update package.json with new test scripts
add migration to fill token holders data
1 parent 0ff29b6 commit 6313ad4

File tree

10 files changed

+727
-0
lines changed

10 files changed

+727
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { MigrationInterface, QueryRunner } from 'typeorm';
2+
3+
export class CreateTokenHolderTable1746613421854 implements MigrationInterface {
4+
name = 'CreateTokenHolderTable1746613421854';
5+
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
await queryRunner.query(
8+
`CREATE TABLE "token_holder" (
9+
"id" SERIAL NOT NULL,
10+
"projectName" character varying NOT NULL,
11+
"address" character varying NOT NULL,
12+
"tag" character varying,
13+
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
14+
"updatedAt" TIMESTAMP NOT NULL DEFAULT now(),
15+
CONSTRAINT "PK_token_holder_id" PRIMARY KEY ("id")
16+
)`,
17+
);
18+
19+
await queryRunner.query(
20+
`CREATE INDEX "IDX_token_holder_address" ON "token_holder" ("address")`,
21+
);
22+
}
23+
24+
public async down(queryRunner: QueryRunner): Promise<void> {
25+
await queryRunner.query(`DROP INDEX "IDX_token_holder_address"`);
26+
await queryRunner.query(`DROP TABLE "token_holder"`);
27+
}
28+
}
Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
import { MigrationInterface, QueryRunner } from 'typeorm';
2+
3+
export class PopulateTokenHolders1746613421855 implements MigrationInterface {
4+
name = 'PopulateTokenHolders1746613421855';
5+
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
// Define the token holder data
8+
const tokenHolders = [
9+
// PACK
10+
{
11+
projectName: 'PACK',
12+
tag: 'Vesting Contract',
13+
address: '0xD1959e8a3D0C2cB2768543feD5bdD27D19b6c73e',
14+
},
15+
{
16+
projectName: 'PACK',
17+
tag: 'Liquidity Bot',
18+
address: '0xe2D718Cd6B9b3e65ad4DCe6903EC5e37FEd0297b',
19+
},
20+
{
21+
projectName: 'PACK',
22+
tag: 'DEX LP',
23+
address: '0x8a8C62E6B1C8EE5b104B7C7401D0b4cDfa4CeCBf',
24+
},
25+
// TDM
26+
{
27+
projectName: 'TDM',
28+
tag: 'Vesting Contract',
29+
address: '0xAbeFd091Abfb87528151e48973829c407FFA1333',
30+
},
31+
{
32+
projectName: 'TDM',
33+
tag: 'Liquidity Bot',
34+
address: '0xa44A5E67236CC2674e24294C1AB2f13b162338d8',
35+
},
36+
{
37+
projectName: 'TDM',
38+
tag: 'DEX LP',
39+
address: '0x3c2A6424f245136a15eAc951FA27D33B8357b362',
40+
},
41+
// LOCK
42+
{
43+
projectName: 'LOCK',
44+
tag: 'Vesting Contract',
45+
address: '0x9E17eFea75A3a33fB235B079D82c83458C14369C',
46+
},
47+
{
48+
projectName: 'LOCK',
49+
tag: 'Liquidity Bot',
50+
address: '0x7003c15252eC37DcC7f1134CFD9AD3d6d0449bB5',
51+
},
52+
{
53+
projectName: 'LOCK',
54+
tag: 'DEX LP',
55+
address: '0xfB7771110Fa0b9d2F3c921Ace03991701b8623aF',
56+
},
57+
// H2DAO
58+
{
59+
projectName: 'H2DAO',
60+
tag: 'Vesting Contract',
61+
address: '0x79c744e6db81dd83E83271cDB53578318F6c1D65',
62+
},
63+
{
64+
projectName: 'H2DAO',
65+
tag: 'Liquidity Bot',
66+
address: '0x27F32d16C1C8Ce8C36099A444B2A812C14a287FB',
67+
},
68+
{
69+
projectName: 'H2DAO',
70+
tag: 'DEX LP',
71+
address: '0x5F6520d0a751Aaf8353874583A152e49a0828eE5',
72+
},
73+
// X23
74+
{
75+
projectName: 'X23',
76+
tag: 'Vesting Contract',
77+
address: '0x6B5d37c206D56B16F44b0C1b89002fd9B138e9Be',
78+
},
79+
{
80+
projectName: 'X23',
81+
tag: 'Liquidity Bot',
82+
address: '0xd189BcEA30511d4E229BC2d901120f2881b9D0e2',
83+
},
84+
{
85+
projectName: 'X23',
86+
tag: 'DEX LP',
87+
address: '0x0De6dA16D5181a9Fe2543cE1eeb4bFD268D68838',
88+
},
89+
// CTZN
90+
{
91+
projectName: 'CTZN',
92+
tag: 'Vesting Contract',
93+
address: '0x0DDd250bfb440e6deF3157eE29747e8ac29153aD',
94+
},
95+
{
96+
projectName: 'CTZN',
97+
tag: 'Liquidity Bot',
98+
address: '0x28e7772b474C3f7147Ca2aD4F7C9Bd6a23c72E36',
99+
},
100+
{
101+
projectName: 'CTZN',
102+
tag: 'DEX LP',
103+
address: '0x746CF1bAaa81E6f2dEe39Bd4E3cB5E9f0Edf98a8',
104+
},
105+
// PRSM
106+
{
107+
projectName: 'PRSM',
108+
tag: 'Vesting Contract',
109+
address: '0x96b6aA42777D0fDDE8F8e45f35129D1D11CdA981',
110+
},
111+
{
112+
projectName: 'PRSM',
113+
tag: 'Liquidity Bot',
114+
address: '0x84028C23F5f8051598b20696C8240c012C994Ba1',
115+
},
116+
{
117+
projectName: 'PRSM',
118+
tag: 'DEX LP',
119+
address: '0x4DC15eDc968EceAec3A5e0F12d0aCECACee05e25',
120+
},
121+
// GRNDT
122+
{
123+
projectName: 'GRNDT',
124+
tag: 'Vesting Contract',
125+
address: '0x480f463b0831990b1929fB401f21E55B21E985cD',
126+
},
127+
{
128+
projectName: 'GRNDT',
129+
tag: 'Liquidity Bot',
130+
address: '0xA864e45F7799ba239580186E94b9390A6f568ade',
131+
},
132+
{
133+
projectName: 'GRNDT',
134+
tag: 'DEX LP',
135+
address: '0x460A8186AA4574C18709d1eFF118EfDAa5235C19',
136+
},
137+
// ACHAD
138+
{
139+
projectName: 'ACHAD',
140+
tag: 'Vesting Contract',
141+
address: '0xC7374519fc9DfcDaCD3bd1f337AC98dD3dB09dE9',
142+
},
143+
{
144+
projectName: 'ACHAD',
145+
tag: 'Liquidity Bot',
146+
address: '0x7ca5d9e997A9310b180fd394cF80183Eb5aaDF66',
147+
},
148+
{
149+
projectName: 'ACHAD',
150+
tag: 'DEX LP',
151+
address: '0x7F4818ae354C30d79b1E0C1838382D64b93366Aa',
152+
},
153+
// MELS
154+
{
155+
projectName: 'MELS',
156+
tag: 'Vesting Contract',
157+
address: '0xABfaeb84364c419b19A9241434a997c88731C6fa',
158+
},
159+
{
160+
projectName: 'MELS',
161+
tag: 'Liquidity Bot',
162+
address: '0xdB99BeF6D8Bb9703c9B2F110aE8C30580830b92D',
163+
},
164+
{
165+
projectName: 'MELS',
166+
tag: 'DEX LP',
167+
address: '0x6E9869FeA80D791e58AfA60d3Dd2e14B16Ef064a',
168+
},
169+
// BEAST
170+
{
171+
projectName: 'BEAST',
172+
tag: 'Vesting Contract',
173+
address: '0x1e4350605E143E58F0C786A76FA8f70257B3D20e',
174+
},
175+
{
176+
projectName: 'BEAST',
177+
tag: 'Liquidity Bot',
178+
address: '0xadfC4Bc382F4ECe69a19b3Eecad5Dd62d9e919ae',
179+
},
180+
{
181+
projectName: 'BEAST',
182+
tag: 'DEX LP',
183+
address: '0xb7a6F7e6Efa1024c44028bc1AB4E08F0F377567e',
184+
},
185+
// AKA
186+
{
187+
projectName: 'AKA',
188+
tag: 'Vesting Contract',
189+
address: '0x9858b8FeE34F27959e3CDFAf022a5D0844eaeA65',
190+
},
191+
{
192+
projectName: 'AKA',
193+
tag: 'Liquidity Bot',
194+
address: '0x6925B3c6ad873e1F84b65c37B4562F03D1D15687',
195+
},
196+
{
197+
projectName: 'AKA',
198+
tag: 'DEX LP',
199+
address: '0xd404B5ec643A129e2853D78Ba98368cee097ae92',
200+
},
201+
];
202+
203+
// Insert each token holder
204+
for (const tokenHolder of tokenHolders) {
205+
await queryRunner.query(
206+
`INSERT INTO "token_holder" ("projectName", "tag", "address")
207+
VALUES ($1, $2, $3)`,
208+
[tokenHolder.projectName, tokenHolder.tag, tokenHolder.address],
209+
);
210+
}
211+
}
212+
213+
public async down(queryRunner: QueryRunner): Promise<void> {
214+
// Define the project names that were inserted
215+
const projectNames = [
216+
'PACK',
217+
'TDM',
218+
'LOCK',
219+
'H2DAO',
220+
'X23',
221+
'CTZN',
222+
'PRSM',
223+
'GRNDT',
224+
'ACHAD',
225+
'MELS',
226+
'BEAST',
227+
'AKA',
228+
];
229+
230+
// Remove the inserted token holders
231+
for (const projectName of projectNames) {
232+
await queryRunner.query(
233+
`DELETE FROM "token_holder" WHERE "projectName" = $1`,
234+
[projectName],
235+
);
236+
}
237+
}
238+
}

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@
193193
"test:tokenPriceResolver": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/resolvers/tokenPriceResolver.test.ts",
194194
"test:vestingScheduleRepository": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/repositories/vestingScheduleRepository.test.ts",
195195
"test:vestingScheduleResolver": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/resolvers/vestingScheduleResolver.test.ts",
196+
"test:tokenHolderRepository": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/repositories/tokenHolderRepository.test.ts",
197+
"test:tokenHolderResolver": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/resolvers/tokenHolderResolver.test.ts",
196198
"start": "NODE_ENV=development ts-node-dev --project ./tsconfig.json --respawn ./src/index.ts",
197199
"start:test": "NODE_ENV=development ts-node-dev --project ./tsconfig.json --respawn ./test.ts",
198200
"serve": "pm2 startOrRestart ecosystem.config.js --node-args='--max-old-space-size=8192'",

src/entities/entities.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import { QaccPointsHistory } from './qaccPointsHistory';
4141
import { UserRankMaterializedView } from './userRanksMaterialized';
4242
import { VestingData } from './vestingData';
4343
import { VestingSchedule } from './vestingSchedule';
44+
import { TokenHolder } from './tokenHolder';
4445
import { TokenPriceHistory } from './tokenPriceHistory';
4546

4647
export const getEntities = (): DataSourceOptions['entities'] => {
@@ -96,6 +97,7 @@ export const getEntities = (): DataSourceOptions['entities'] => {
9697
UserRankMaterializedView,
9798
VestingData,
9899
VestingSchedule,
100+
TokenHolder,
99101
TokenPriceHistory,
100102
];
101103
};

src/entities/tokenHolder.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { Field, ID, ObjectType } from 'type-graphql';
2+
import {
3+
BaseEntity,
4+
Column,
5+
CreateDateColumn,
6+
Entity,
7+
Index,
8+
PrimaryGeneratedColumn,
9+
UpdateDateColumn,
10+
} from 'typeorm';
11+
12+
@Entity()
13+
@ObjectType()
14+
export class TokenHolder extends BaseEntity {
15+
@Field(_type => ID)
16+
@PrimaryGeneratedColumn()
17+
readonly id: number;
18+
19+
@Field()
20+
@Column()
21+
projectName: string;
22+
23+
@Field()
24+
@Index()
25+
@Column()
26+
address: string;
27+
28+
@Field({ nullable: true })
29+
@Column({ nullable: true })
30+
tag?: string;
31+
32+
@Field()
33+
@CreateDateColumn()
34+
createdAt: Date;
35+
36+
@Field()
37+
@UpdateDateColumn()
38+
updatedAt: Date;
39+
}

0 commit comments

Comments
 (0)