Skip to content

Commit 0d16052

Browse files
committed
refactor: delete indexers
build: move build-only settings to "tsconfig.build.json" refactor: export mainnets before testnets refactor: get rid of "logAndThrow" refactor: move release-specific helpers refactor: move "logger" and "check-broadcast" to "src/internal" refactor: non-default exports refactor: rename "scripts" to "cli" refactor: simplify logic in "resolvers.ts"
1 parent baa17dc commit 0d16052

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+299
-526
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ const arbitrum = chains.queries.get({ chainId: 42161 });
6565
const polygon = chains.queries.get({ slug: "polygon" });
6666

6767
// Check if chain supports Sablier UI
68-
if (ethereum.isSupportedByUI) {
69-
console.log("Available on app.sablier.com");
68+
if (arbitrum.isSupportedByUI) {
69+
console.log("Arbitrum available on app.sablier.com");
7070
}
7171
```
7272

scripts/print-aliases.ts renamed to cli/print/aliases.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { logger } from "@src/internal/logger";
12
import { sablier } from "@src/sablier";
23
import _ from "lodash";
3-
import logger from "./logger";
44

55
type AliasRow = {
66
alias: string;
File renamed without changes.

scripts/print-missing.ts renamed to cli/print/missing-broadcasts.ts

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@
44
* for all chains, only the ones listed in the releases.
55
*
66
* Usage:
7-
* bun run scripts/print-missing.ts airdrops
8-
* bun run scripts/print-missing.ts flow
9-
* bun run scripts/print-missing.ts lockup
7+
* bun run cli/print/missing-broadcasts.ts airdrops
8+
* bun run cli/print/missing-broadcasts.ts flow
9+
* bun run cli/print/missing-broadcasts.ts lockup
1010
*/
11+
12+
import { checkBroadcast } from "@src/check-broadcast";
13+
import { Protocol } from "@src/enums";
14+
import { logger } from "@src/internal/logger";
1115
import { sablier } from "@src/sablier";
1216
import type { Sablier } from "@src/types";
1317
import _ from "lodash";
14-
import { checkBroadcast } from "./check-broadcast";
15-
import logger from "./logger";
1618

1719
const EMOJIS = {
1820
check: "✅",
@@ -30,31 +32,30 @@ const EMOJIS = {
3032

3133
async function main(): Promise<void> {
3234
const missing: Record<string, Sablier.Chain[]> = {};
33-
const protocol = parseArgs();
35+
const protocolArg = parseArgs();
3436

35-
logger.info(`\n${EMOJIS.folder} Checking ${protocol} broadcasts...\n`);
37+
console.log(`${EMOJIS.folder} Checking ${protocolArg} broadcasts...\n`);
3638

37-
const allReleases = sablier.releases.getAll({ protocol });
38-
for (const release of allReleases) {
39-
for (const deployment of release.deployments) {
40-
const chain = sablier.chains.getOrThrow(deployment.chainId);
39+
const releases = sablier.releases.getAll({ protocol: protocolArg });
40+
for (const r of releases) {
41+
for (const d of r.deployments) {
42+
const chain = sablier.chains.getOrThrow(d.chainId);
4143

4244
let hasValidBroadcasts = false;
4345

44-
if (release.kind === "lockupV1") {
46+
if (r.kind === "lockupV1") {
4547
const components = ["core", "periphery"];
46-
hasValidBroadcasts = await Promise.all(
47-
components.map((component) => checkBroadcast(release, chain, component)),
48-
).then((results) => results.every(Boolean));
48+
const results = await Promise.all(components.map((component) => checkBroadcast(r, chain, component)));
49+
hasValidBroadcasts = results.every(Boolean);
4950
} else {
50-
const paths = await checkBroadcast(release, chain);
51+
const paths = await checkBroadcast(r, chain);
5152
hasValidBroadcasts = !_.isEmpty(paths);
5253
}
5354

5455
// Add to missing list if broadcasts aren't valid
5556
if (!hasValidBroadcasts) {
56-
_.defaults(missing, { [release.version]: [] });
57-
missing[release.version].push(chain);
57+
_.defaults(missing, { [r.version]: [] });
58+
missing[r.version].push(chain);
5859
}
5960
}
6061
}
@@ -124,15 +125,15 @@ main();
124125
/* -------------------------------------------------------------------------- */
125126

126127
function parseArgs(): Sablier.Protocol {
127-
const protocol = process.argv[2] as Sablier.Protocol;
128-
const validProtocols: Sablier.Protocol[] = ["airdrops", "flow", "legacy", "lockup"];
129-
if (!protocol || !validProtocols.includes(protocol)) {
130-
const msg = `Error: Please provide one of these protocols: ${validProtocols.join(", ")}`;
128+
const protocolArg = process.argv[2] as Sablier.Protocol;
129+
const available = _.values(Protocol);
130+
if (!protocolArg || !available.includes(protocolArg)) {
131+
const msg = `Error: Please provide one of these protocols: ${available.join(", ")}`;
131132
logger.error(msg);
132133
throw new Error(msg);
133134
}
134135

135-
return protocol;
136+
return protocolArg;
136137
}
137138

138139
function printSectionHeader(text: string): void {

data/flow/v1.0/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<!---
2+
TODO: update
3+
-->
4+
15
# v1.0.0
26

37
## Contract Deployed

data/lockup/v1.2/core/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<!---
2+
TODO: update
3+
-->
4+
15
# v1.2.0
26

37
## Contract Deployed

justfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
set shell := ["bash", "-euo", "pipefail", "-c"]
2+
13
# ---------------------------------------------------------------------------- #
24
# RECIPES #
35
# ---------------------------------------------------------------------------- #
@@ -42,9 +44,9 @@ prettier-check:
4244
prettier-write:
4345
bun prettier --cache --write "**/*.{md,yml}"
4446

45-
# Print available chain arguments
46-
@print thing:
47-
bun run scripts/print-{{ thing }}.ts
47+
# Run print CLI script. See the files under ./cli/print for available scripts
48+
@print script *args:
49+
bun run cli/print/{{ script }}.ts {{ args }}
4850

4951
# Setup Husky
5052
setup:

src/chains/data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ import * as mainnets from "./mainnets";
22
import * as testnets from "./testnets";
33

44
export { mainnets, testnets };
5-
export const chains = { ...testnets, ...mainnets };
5+
export const chains = { ...mainnets, ...testnets };

scripts/check-broadcast.ts renamed to src/check-broadcast.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as path from "node:path";
22
import type { Sablier } from "@src/types";
33
import * as fs from "fs-extra";
4-
import { logInfo } from "./logger";
4+
import { logVerbose } from "./internal/logger";
55

66
const ROOT_DIR = path.join(__dirname, "..");
77
const DATA_DIR = path.join(ROOT_DIR, "data");
@@ -12,12 +12,12 @@ const DATA_DIR = path.join(ROOT_DIR, "data");
1212
* ├── lockup/
1313
* │ └── v2.0/
1414
* │ └── broadcasts/
15-
* │ └── ethereum.json
15+
* │ └── mainnet.json
1616
* └── lockup/
1717
* └── v1.2/
1818
* └── core/
1919
* └── broadcasts/
20-
* └── ethereum.json
20+
* └── mainnet.json
2121
*/
2222
export function checkBroadcast(release: Sablier.Release, chain: Sablier.Chain, innerPath?: string): string | null {
2323
let chainType = "";
@@ -35,7 +35,7 @@ export function checkBroadcast(release: Sablier.Release, chain: Sablier.Chain, i
3535

3636
if (!fs.existsSync(pathToCheck)) {
3737
const relativePath = path.relative(ROOT_DIR, pathToCheck);
38-
logInfo({
38+
logVerbose({
3939
msg: `No broadcasts for ${chain.slug} at ${relativePath}`,
4040
release,
4141
});

src/contracts/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1-
export * from "./catalog";
2-
export * from "./names";
1+
import { catalog } from "./catalog";
2+
import { names } from "./names";
3+
4+
export const contracts = {
5+
catalog,
6+
names,
7+
};

0 commit comments

Comments
 (0)