|
1 | 1 | import { Injectable, Logger, OnModuleInit } from '@nestjs/common';
|
2 | 2 | import { ConfigService } from '@nestjs/config';
|
3 | 3 | import axios from 'axios';
|
4 |
| -import { last } from 'lodash'; |
5 | 4 | import { AggregationService } from '../aggregation/aggregation.service';
|
6 | 5 | import { RecordsService } from '../base/RecordsService';
|
7 | 6 | import { Transfer, TransferAction } from '../base/TransferService';
|
@@ -44,10 +43,6 @@ export class Substrate2parachainService extends RecordsService implements OnModu
|
44 | 43 | }
|
45 | 44 |
|
46 | 45 | async onModuleInit() {
|
47 |
| - if (this.configService.get('CHAIN_TYPE') === 'formal') { |
48 |
| - return; |
49 |
| - } |
50 |
| - |
51 | 46 | this.transferService.transfers.forEach((item, index) => {
|
52 | 47 | this.taskService.addInterval(
|
53 | 48 | `${item.backing.chain}-parachain-fetch_history_data`,
|
@@ -118,13 +113,17 @@ export class Substrate2parachainService extends RecordsService implements OnModu
|
118 | 113 | bridgeDispatchError: '',
|
119 | 114 | });
|
120 | 115 |
|
| 116 | + if (!this.needSyncLock[index] && isLock) { |
| 117 | + this.needSyncLock[index] = true; |
| 118 | + } else if (!this.needSyncBurn[index] && !isLock) { |
| 119 | + this.needSyncBurn[index] = true; |
| 120 | + } |
| 121 | + |
121 | 122 | if (node.result === 0) {
|
122 | 123 | if (!this.needSyncLockConfirmed[index] && isLock) {
|
123 | 124 | this.needSyncLockConfirmed[index] = true;
|
124 |
| - this.needSyncLock[index] = true; |
125 | 125 | } else if (!this.needSyncBurnConfirmed && !isLock) {
|
126 | 126 | this.needSyncBurnConfirmed[index] = true;
|
127 |
| - this.needSyncBurn[index] = true; |
128 | 127 | }
|
129 | 128 | }
|
130 | 129 | }
|
@@ -173,28 +172,14 @@ export class Substrate2parachainService extends RecordsService implements OnModu
|
173 | 172 | return;
|
174 | 173 | }
|
175 | 174 |
|
176 |
| - const dispatchLaneId = '726f6c69'; |
177 |
| - const recordLaneId = '70616c69'; |
178 |
| - |
179 |
| - const pickId = (id: string) => { |
180 |
| - const target = last(id.split('-')); |
181 |
| - |
182 |
| - return action === 'lock' ? target : target.replace(recordLaneId, dispatchLaneId); |
183 |
| - }; |
184 |
| - |
185 |
| - const ids = uncheckedRecords.map((item) => `"${pickId(item.id)}"`).join(','); |
| 175 | + const ids = uncheckedRecords.map((item) => `"${item.id.split('-')[3]}"`).join(','); |
186 | 176 |
|
187 | 177 | const nodes = await axios
|
188 | 178 | .post(to.url, {
|
189 | 179 | query: `query { bridgeDispatchEvents (filter: {id: {in: [${ids}]}}) { nodes {id, method, block }}}`,
|
190 | 180 | variables: null,
|
191 | 181 | })
|
192 |
| - .then((res) => |
193 |
| - res.data?.data?.bridgeDispatchEvents?.nodes.map(({ id, ...rest }) => ({ |
194 |
| - ...rest, |
195 |
| - id: id.replace(dispatchLaneId, recordLaneId), |
196 |
| - })) |
197 |
| - ); |
| 182 | + .then((res) => res.data?.data?.bridgeDispatchEvents?.nodes); |
198 | 183 |
|
199 | 184 | if (nodes && nodes.length > 0) {
|
200 | 185 | for (const node of nodes) {
|
|
0 commit comments