MCPcopy Create free account
hub / github.com/subquery/subql / updateDataSourcesV1_0_0

Function updateDataSourcesV1_0_0

packages/node-core/src/utils/project.ts:121–159  ·  view source on GitHub ↗
(
  _dataSources: (DS | CDS)[],
  reader: Reader,
  root: string,
  isCustomDs: IsCustomDs<DS, CDS>
)

Source from the content-addressed store, hash-verified

119}
120
121export async function updateDataSourcesV1_0_0<DS extends BaseDataSource, CDS extends DS & BaseCustomDataSource>(
122 _dataSources: (DS | CDS)[],
123 reader: Reader,
124 root: string,
125 isCustomDs: IsCustomDs<DS, CDS>
126): Promise<(DS | CDS)[]> {
127 // force convert to updated ds
128 return Promise.all(
129 _dataSources.map(async (dataSource) => {
130 dataSource.startBlock = dataSource.startBlock ?? 1;
131 const entryScript = await loadDataSourceScript(reader, dataSource.mapping.file);
132 if (isAssetsDs(dataSource) && dataSource.assets) {
133 for (const [, asset] of dataSource.assets.entries()) {
134 // Only need to resolve path for local file
135 if (reader instanceof LocalReader) {
136 asset.file = path.resolve(root, asset.file);
137 } else {
138 asset.file = await fetchAndSaveFile(reader, root, asset.file, '');
139 }
140 }
141 }
142 const file = await updateDataSourcesEntry(reader, dataSource.mapping.file, root, entryScript);
143 if (isCustomDs(dataSource)) {
144 if (dataSource.processor) {
145 dataSource.processor.file = await updateProcessor(reader, root, dataSource.processor.file);
146 }
147 return {
148 ...dataSource,
149 mapping: {...dataSource.mapping, file},
150 };
151 } else {
152 return {
153 ...dataSource,
154 mapping: {...dataSource.mapping, file},
155 };
156 }
157 })
158 );
159}
160
161export async function updateDataSourcesEntry(
162 reader: Reader,

Callers 2

createMethod · 0.90
loadProjectTemplatesFunction · 0.85

Calls 7

loadDataSourceScriptFunction · 0.85
isAssetsDsFunction · 0.85
fetchAndSaveFileFunction · 0.85
updateDataSourcesEntryFunction · 0.85
updateProcessorFunction · 0.85
mapMethod · 0.80
isCustomDsFunction · 0.50

Tested by

no test coverage detected