-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add blueprint to extract soundxyz artists
- Loading branch information
Showing
3 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { readFileSync } from "fs"; | ||
import { resolve } from "path"; | ||
import { env } from "process"; | ||
|
||
const platformAddresses = { | ||
"0xabefbc9fd2f806065b4f3c237d4b59d9a97bcac7": { | ||
name: "zora", | ||
}, | ||
"0x0bc2a24ce568dad89691116d5b34deb6c203f342": { | ||
name: "catalog", | ||
version: "2.0.0", | ||
}, | ||
"0xf5819e27b9bad9f97c177bf007c1f96f26d91ca6": { | ||
name: "noizd", | ||
}, | ||
"0x2b5426a5b98a3e366230eba9f95a24f09ae4a584": { | ||
name: "mintsongs", | ||
version: "2.0.0", | ||
}, | ||
}; | ||
|
||
export function ingestFile(name, mainObj = {}) { | ||
// NOTE: We don't want this function to have side effects as e.g. mutating | ||
// `mainObj`'s properties which is why we copy it. | ||
let copyObj = { ...mainObj }; | ||
const content = readFileSync(resolve(env.DATA_DIR, name)).toString(); | ||
const lines = content.split("\n").filter((line) => !!line); | ||
|
||
for (const line of lines) { | ||
const pLine = JSON.parse(line); | ||
copyObj = { ...copyObj, ...pLine }; | ||
} | ||
|
||
return copyObj; | ||
} | ||
|
||
export default { | ||
name: "call-block-logs", | ||
transformer: { | ||
args: [ | ||
ingestFile("soundxyz-filter-contracts-transformation", platformAddresses), | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import test from "ava"; | ||
|
||
import { ingestFile } from "../src/call-block-logs-with-soundxyz-artists.mjs"; | ||
|
||
test("if ingesting files can yield main object", (t) => { | ||
process.env.DATA_DIR = "./test/fixtures"; | ||
let mainObj = { hello: "world" }; | ||
const result = ingestFile( | ||
"soundxyz-filter-contracts-transformation", | ||
mainObj | ||
); | ||
t.deepEqual(mainObj, { hello: "world" }); | ||
t.deepEqual(result, { | ||
"0xca13eaa6135d719e743ffebb5c26de4ce2f9600c": { name: "sound" }, | ||
"0xb8dfff430eb204eeeae713a9d4642352e3df6887": { name: "sound" }, | ||
hello: "world", | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{"0xca13eaa6135d719e743ffebb5c26de4ce2f9600c":{"name":"sound"}} | ||
{"0xb8dfff430eb204eeeae713a9d4642352e3df6887":{"name":"sound"}} |