Skip to content

Commit

Permalink
feat: merge erc20 from develop to staging (#875)
Browse files Browse the repository at this point in the history
* feat: merge erc20 from develop

* feat: merge erc20 from develop

* feat: merge erc20 from develop

* fix: test ci
  • Loading branch information
phamphong9981 authored Jul 31, 2024
1 parent 12eb3d1 commit 1922f4d
Show file tree
Hide file tree
Showing 12 changed files with 2,000 additions and 603 deletions.
2 changes: 2 additions & 0 deletions src/models/account_balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import BaseModel from './base';
import { Account } from './account';

export class AccountBalance extends BaseModel {
static softDelete = false;

account!: Account;

id!: number;
Expand Down
1 change: 1 addition & 0 deletions src/services/api-gateways/api_gateway.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import config from '../../../config.json' assert { type: 'json' };
'v1.job.update-delegator-validator',
'v1.job.signature-mapping',
'v1.job.insert-verify-by-codehash',
'v1.erc20-admin.*',
],
},
{
Expand Down
49 changes: 49 additions & 0 deletions src/services/api-gateways/erc20_admin.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { Post, Service } from '@ourparentcenter/moleculer-decorators-extended';
import { Context, ServiceBroker } from 'moleculer';
import networks from '../../../network.json' assert { type: 'json' };
import BaseService from '../../base/base.service';

@Service({
name: 'erc20-admin',
version: 1,
})
export default class Erc20AdminService extends BaseService {
public constructor(public broker: ServiceBroker) {
super(broker);
}

@Post('/erc20-reindexing', {
name: 'erc20Reindexing',
params: {
chainid: {
type: 'string',
optional: false,
enum: networks.map((network) => network.chainId),
},
addresses: {
type: 'array',
optional: false,
items: 'string',
},
},
})
async erc20Reindexing(
ctx: Context<
{
chainid: string;
addresses: string[];
},
Record<string, unknown>
>
) {
const selectedChain = networks.find(
(network) => network.chainId === ctx.params.chainid
);
return this.broker.call(
`v1.Erc20.reindexing@${selectedChain?.moleculerNamespace}`,
{
addresses: ctx.params.addresses,
}
);
}
}
5 changes: 5 additions & 0 deletions src/services/evm/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ export const SERVICE = {
key: 'insertNewErc20Contracts',
path: 'v1.Erc20.insertNewErc20Contracts',
},
reindexing: {
key: 'reindexing',
path: 'v1.Erc20.reindexing',
},
},
Erc721: {
key: 'Erc721',
Expand Down Expand Up @@ -218,6 +222,7 @@ export const BULL_JOB_NAME = {
REFRESH_ERC721_STATS: 'refresh:erc721-stats',
REINDEX_ERC721: 'reindex:erc721',
HANDLE_SELF_DESTRUCT: 'handle:self-destruct',
REINDEX_ERC20: 'reindex:erc20',
};

export const MSG_TYPE = {
Expand Down
Loading

0 comments on commit 1922f4d

Please sign in to comment.