Skip to content

Commit

Permalink
Sequentialize strategies invocation graph
Browse files Browse the repository at this point in the history
- Potentially fixes #170
- Fixes #146
  • Loading branch information
TimDaub committed Jul 11, 2022
1 parent 2ca0706 commit 0de7b87
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 30 deletions.
12 changes: 10 additions & 2 deletions src/strategies/soundxyz-call-tokenuri/transformer.mjs
@@ -1,15 +1,23 @@
// @format
import { resolve } from "path";
import { env } from "process";
import { decodeSolidityHexStringFactory } from "../../strategy-factories/decode-solidity-hex-string-factory/transformer.mjs";

export const name = "soundxyz-call-tokenuri";
export const version = "0.1.0";
const nextStrategyName = "soundxyz-get-tokenuri";
const nextStrategyMessage = {
type: "extraction",
version,
name: "soundxyz-get-tokenuri",
args: [resolve(env.DATA_DIR, `${name}-transformation`)],
};

const resultKey = "tokenURI";

const { onClose, onError, onLine } = decodeSolidityHexStringFactory({
strategyName: name,
version,
nextStrategyName,
nextStrategyMessage,
resultKey,
});

Expand Down
12 changes: 11 additions & 1 deletion src/strategies/soundxyz-get-tokenuri/transformer.mjs
@@ -1,4 +1,7 @@
// @format
import { resolve } from "path";
import { env } from "process";

import { decodeCallOutput } from "eth-fun";

import logger from "../../logger.mjs";
Expand All @@ -11,7 +14,14 @@ export function onClose() {
log("closed");
return {
write: null,
messages: [],
messages: [
{
type: "extraction",
version,
name: "zora-call-tokenuri",
args: [resolve(env.DATA_DIR, `web3subgraph-transformation`)],
},
],
};
}

Expand Down
12 changes: 0 additions & 12 deletions src/strategies/web3subgraph/transformer.mjs
Expand Up @@ -53,18 +53,6 @@ export function onClose() {
name: "soundxyz-call-tokenuri",
args: [resolve(env.DATA_DIR, fileName)],
},
{
type: "extraction",
version,
name: "zora-call-tokenuri",
args: [resolve(env.DATA_DIR, fileName)],
},
{
type: "extraction",
version,
name: "zora-call-tokenmetadatauri",
args: [resolve(env.DATA_DIR, fileName)],
},
],
write: null,
};
Expand Down
9 changes: 7 additions & 2 deletions src/strategies/zora-call-tokenmetadatauri/transformer.mjs
Expand Up @@ -3,13 +3,18 @@ import { decodeSolidityHexStringFactory } from "../../strategy-factories/decode-

export const name = "zora-call-tokenmetadatauri";
export const version = "0.1.0";
const nextStrategyName = "zora-get-tokenuri";
const nextStrategyMessage = {
type: "extraction",
version,
name: "zora-get-tokenuri",
args: [],
};
const resultKey = "tokenURI";

const { onClose, onError, onLine } = decodeSolidityHexStringFactory({
strategyName: name,
version,
nextStrategyName,
nextStrategyMessage,
resultKey,
});

Expand Down
12 changes: 10 additions & 2 deletions src/strategies/zora-call-tokenuri/transformer.mjs
@@ -1,15 +1,23 @@
// @format
import { resolve } from "path";
import { env } from "process";

import { decodeSolidityHexStringFactory } from "../../strategy-factories/decode-solidity-hex-string-factory/transformer.mjs";

export const name = "zora-call-tokenuri";
export const version = "0.1.0";
const nextStrategyName = null;
const nextStrategyMessage = {
type: "extraction",
version,
name: "zora-call-tokenmetadatauri",
args: [resolve(env.DATA_DIR, `web3subgraph-transformation`)],
};
const resultKey = "tokenURI";

const { onClose, onError, onLine } = decodeSolidityHexStringFactory({
strategyName: name,
version,
nextStrategyName,
nextStrategyMessage,
resultKey,
});

Expand Down
Expand Up @@ -7,23 +7,15 @@ import { decodeCallOutput } from "eth-fun";
import logger from "../../logger.mjs";

export const decodeSolidityHexStringFactory = (props) => {
const { strategyName, version, nextStrategyName, resultKey } = props;
const { strategyName, version, nextStrategyMessage, resultKey } = props;

const log = logger(strategyName);

function onClose() {
if (strategyName && nextStrategyName) {
const fileName = `${strategyName}-transformation`;
if (nextStrategyMessage) {
return {
write: null,
messages: [
{
type: "extraction",
version,
name: nextStrategyName,
args: [resolve(env.DATA_DIR, fileName)],
},
],
messages: [nextStrategyMessage],
};
}
return {
Expand Down

0 comments on commit 0de7b87

Please sign in to comment.