plotlink-ows 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +151 -0
- package/app/db.ts +8 -0
- package/app/lib/llm-client.ts +265 -0
- package/app/lib/paths.ts +11 -0
- package/app/lib/publish.ts +204 -0
- package/app/lib/writer-prompt.ts +44 -0
- package/app/node_modules/.prisma/local-client/client.d.ts +1 -0
- package/app/node_modules/.prisma/local-client/client.js +5 -0
- package/app/node_modules/.prisma/local-client/default.d.ts +1 -0
- package/app/node_modules/.prisma/local-client/default.js +5 -0
- package/app/node_modules/.prisma/local-client/edge.d.ts +1 -0
- package/app/node_modules/.prisma/local-client/edge.js +184 -0
- package/app/node_modules/.prisma/local-client/index-browser.js +173 -0
- package/app/node_modules/.prisma/local-client/index.d.ts +3304 -0
- package/app/node_modules/.prisma/local-client/index.js +207 -0
- package/app/node_modules/.prisma/local-client/libquery_engine-darwin-arm64.dylib.node +0 -0
- package/app/node_modules/.prisma/local-client/package.json +183 -0
- package/app/node_modules/.prisma/local-client/query_engine_bg.js +2 -0
- package/app/node_modules/.prisma/local-client/query_engine_bg.wasm +0 -0
- package/app/node_modules/.prisma/local-client/runtime/edge-esm.js +35 -0
- package/app/node_modules/.prisma/local-client/runtime/edge.js +35 -0
- package/app/node_modules/.prisma/local-client/runtime/index-browser.d.ts +370 -0
- package/app/node_modules/.prisma/local-client/runtime/index-browser.js +17 -0
- package/app/node_modules/.prisma/local-client/runtime/library.d.ts +3982 -0
- package/app/node_modules/.prisma/local-client/runtime/library.js +147 -0
- package/app/node_modules/.prisma/local-client/runtime/react-native.js +84 -0
- package/app/node_modules/.prisma/local-client/runtime/wasm-compiler-edge.js +85 -0
- package/app/node_modules/.prisma/local-client/runtime/wasm-engine-edge.js +38 -0
- package/app/node_modules/.prisma/local-client/schema.prisma +21 -0
- package/app/node_modules/.prisma/local-client/wasm-edge-light-loader.mjs +5 -0
- package/app/node_modules/.prisma/local-client/wasm-worker-loader.mjs +5 -0
- package/app/node_modules/.prisma/local-client/wasm.d.ts +1 -0
- package/app/node_modules/.prisma/local-client/wasm.js +191 -0
- package/app/prisma/schema.prisma +57 -0
- package/app/routes/auth.ts +173 -0
- package/app/routes/chat.ts +135 -0
- package/app/routes/config.ts +210 -0
- package/app/routes/dashboard.ts +186 -0
- package/app/routes/oauth.ts +150 -0
- package/app/routes/publish.ts +112 -0
- package/app/routes/wallet.ts +99 -0
- package/app/server.ts +154 -0
- package/app/vite.config.ts +19 -0
- package/app/web/App.tsx +102 -0
- package/app/web/components/Chat.tsx +272 -0
- package/app/web/components/Dashboard.tsx +222 -0
- package/app/web/components/LLMSetup.tsx +291 -0
- package/app/web/components/Layout.tsx +235 -0
- package/app/web/components/Login.tsx +62 -0
- package/app/web/components/Publish.tsx +245 -0
- package/app/web/components/Settings.tsx +175 -0
- package/app/web/components/Setup.tsx +84 -0
- package/app/web/components/WalletCard.tsx +117 -0
- package/app/web/dist/assets/index-C9kXlYO_.css +2 -0
- package/app/web/dist/assets/index-CJiiaLHs.js +9 -0
- package/app/web/dist/index.html +16 -0
- package/app/web/index.html +15 -0
- package/app/web/main.tsx +10 -0
- package/app/web/plotlink-logo.svg +5 -0
- package/app/web/styles.css +51 -0
- package/bin/plotlink-ows.js +394 -0
- package/lib/ows/index.ts +3 -0
- package/lib/ows/policy.ts +68 -0
- package/lib/ows/types.ts +14 -0
- package/lib/ows/wallet.ts +70 -0
- package/package.json +79 -0
- package/packages/cli/node_modules/commander/LICENSE +22 -0
- package/packages/cli/node_modules/commander/Readme.md +1149 -0
- package/packages/cli/node_modules/commander/esm.mjs +16 -0
- package/packages/cli/node_modules/commander/index.js +24 -0
- package/packages/cli/node_modules/commander/lib/argument.js +149 -0
- package/packages/cli/node_modules/commander/lib/command.js +2662 -0
- package/packages/cli/node_modules/commander/lib/error.js +39 -0
- package/packages/cli/node_modules/commander/lib/help.js +709 -0
- package/packages/cli/node_modules/commander/lib/option.js +367 -0
- package/packages/cli/node_modules/commander/lib/suggestSimilar.js +101 -0
- package/packages/cli/node_modules/commander/package-support.json +16 -0
- package/packages/cli/node_modules/commander/package.json +82 -0
- package/packages/cli/node_modules/commander/typings/esm.d.mts +3 -0
- package/packages/cli/node_modules/commander/typings/index.d.ts +1045 -0
- package/packages/cli/node_modules/resolve-from/index.d.ts +31 -0
- package/packages/cli/node_modules/resolve-from/index.js +47 -0
- package/packages/cli/node_modules/resolve-from/license +9 -0
- package/packages/cli/node_modules/resolve-from/package.json +36 -0
- package/packages/cli/node_modules/resolve-from/readme.md +72 -0
- package/packages/cli/node_modules/tsup/LICENSE +21 -0
- package/packages/cli/node_modules/tsup/README.md +75 -0
- package/packages/cli/node_modules/tsup/assets/cjs_shims.js +13 -0
- package/packages/cli/node_modules/tsup/assets/esm_shims.js +9 -0
- package/packages/cli/node_modules/tsup/assets/package.json +3 -0
- package/packages/cli/node_modules/tsup/dist/chunk-DI5BO6XE.js +153 -0
- package/packages/cli/node_modules/tsup/dist/chunk-JZ25TPTY.js +42 -0
- package/packages/cli/node_modules/tsup/dist/chunk-PEEXUWMS.js +6 -0
- package/packages/cli/node_modules/tsup/dist/chunk-TWFEYLU4.js +352 -0
- package/packages/cli/node_modules/tsup/dist/chunk-VGC3FXLU.js +203 -0
- package/packages/cli/node_modules/tsup/dist/cli-default.js +12 -0
- package/packages/cli/node_modules/tsup/dist/cli-main.js +8 -0
- package/packages/cli/node_modules/tsup/dist/cli-node.js +14 -0
- package/packages/cli/node_modules/tsup/dist/index.d.ts +511 -0
- package/packages/cli/node_modules/tsup/dist/index.js +1711 -0
- package/packages/cli/node_modules/tsup/dist/rollup.js +6949 -0
- package/packages/cli/node_modules/tsup/package.json +99 -0
- package/packages/cli/node_modules/tsup/schema.json +362 -0
- package/packages/cli/package.json +35 -0
- package/packages/cli/src/commands/agent-register.ts +77 -0
- package/packages/cli/src/commands/chain.ts +29 -0
- package/packages/cli/src/commands/claim.ts +70 -0
- package/packages/cli/src/commands/create.ts +34 -0
- package/packages/cli/src/commands/status.ts +201 -0
- package/packages/cli/src/config.ts +103 -0
- package/packages/cli/src/index.ts +21 -0
- package/packages/cli/src/sdk/abi.ts +222 -0
- package/packages/cli/src/sdk/client.ts +713 -0
- package/packages/cli/src/sdk/constants.ts +56 -0
- package/packages/cli/src/sdk/index.ts +46 -0
- package/packages/cli/src/sdk/ipfs.ts +88 -0
- package/packages/cli/src/sdk.ts +36 -0
- package/packages/cli/tsconfig.json +20 -0
- package/packages/cli/tsup.config.ts +14 -0
- package/public/.well-known/farcaster.json +38 -0
- package/public/basescan-icon.svg +4 -0
- package/public/embed-image.png +0 -0
- package/public/favicon.png +0 -0
- package/public/hunt-token.svg +11 -0
- package/public/icon-192.png +0 -0
- package/public/icon.png +0 -0
- package/public/manifest.json +26 -0
- package/public/mc-icon-light.svg +12 -0
- package/public/og-image.png +0 -0
- package/public/plotlink-logo-symbol.svg +5 -0
- package/public/plotlink-logo.svg +5 -0
- package/public/screenshot-1.png +0 -0
- package/public/screenshot-2.png +0 -0
- package/public/screenshot-3.png +0 -0
- package/public/splash.png +0 -0
- package/public/wide-banner.png +0 -0
- package/scripts/backfill-trade-prices.ts +97 -0
- package/scripts/backfill-usd-rates.ts +220 -0
- package/scripts/e2e-verify.ts +1100 -0
- package/scripts/ows-smoke-test.ts +37 -0
- package/scripts/score-users.mjs +203 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default contract addresses and chain configuration for PlotLink on Base.
|
|
3
|
+
*
|
|
4
|
+
* Mirrored from lib/contracts/constants.ts in the web app.
|
|
5
|
+
* These serve as defaults — callers can override via PlotLinkConfig.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
// Chain
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
/** Base Sepolia (testnet) chain ID. */
|
|
13
|
+
export const BASE_SEPOLIA_CHAIN_ID = 84532;
|
|
14
|
+
|
|
15
|
+
/** Base (mainnet) chain ID. */
|
|
16
|
+
export const BASE_MAINNET_CHAIN_ID = 8453;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Approximate deployment block for PlotLink contracts on Base Sepolia.
|
|
20
|
+
* Used as the default fromBlock in event log queries to avoid scanning
|
|
21
|
+
* from genesis (which times out on Base).
|
|
22
|
+
*/
|
|
23
|
+
export const DEPLOYMENT_BLOCK = BigInt(20_000_000);
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Deployment block for PlotLink contracts on Base mainnet.
|
|
27
|
+
* Used as the default fromBlock for mainnet event log queries.
|
|
28
|
+
*/
|
|
29
|
+
export const DEPLOYMENT_BLOCK_MAINNET = BigInt(43_840_298);
|
|
30
|
+
|
|
31
|
+
/** Supported chain IDs for the PlotLink SDK. */
|
|
32
|
+
export const SUPPORTED_CHAIN_IDS = new Set([BASE_SEPOLIA_CHAIN_ID, BASE_MAINNET_CHAIN_ID]);
|
|
33
|
+
|
|
34
|
+
// ---------------------------------------------------------------------------
|
|
35
|
+
// PlotLink contracts (Base Sepolia defaults)
|
|
36
|
+
// ---------------------------------------------------------------------------
|
|
37
|
+
|
|
38
|
+
/** StoryFactory — storyline + plot management (Base Sepolia). */
|
|
39
|
+
export const STORY_FACTORY_ADDRESS =
|
|
40
|
+
"0xfa5489b6710Ba2f8406b37fA8f8c3018e51FA229" as const;
|
|
41
|
+
|
|
42
|
+
/** StoryFactory — storyline + plot management (Base mainnet). */
|
|
43
|
+
export const STORY_FACTORY_MAINNET_ADDRESS =
|
|
44
|
+
"0x9D2AE1E99D0A6300bfcCF41A82260374e38744Cf" as const;
|
|
45
|
+
|
|
46
|
+
/** MCV2_Bond — bonding curve trading (Base Sepolia). */
|
|
47
|
+
export const MCV2_BOND_ADDRESS =
|
|
48
|
+
"0x5dfA75b0185efBaEF286E80B847ce84ff8a62C2d" as const;
|
|
49
|
+
|
|
50
|
+
/** MCV2_Bond — bonding curve trading (Base mainnet). */
|
|
51
|
+
export const MCV2_BOND_MAINNET_ADDRESS =
|
|
52
|
+
"0xc5a076cad94176c2996B32d8466Be1cE757FAa27" as const;
|
|
53
|
+
|
|
54
|
+
/** ERC-8004 Agent Identity Registry. */
|
|
55
|
+
export const ERC8004_REGISTRY_ADDRESS =
|
|
56
|
+
"0x8004A169FB4a3325136EB29fA0ceB6D2e539a432" as const;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @plotlink/sdk — TypeScript SDK for the PlotLink protocol on Base.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { PlotLink } from "@plotlink/sdk";
|
|
7
|
+
*
|
|
8
|
+
* const client = new PlotLink({
|
|
9
|
+
* privateKey: "0x...",
|
|
10
|
+
* rpcUrl: "https://sepolia.base.org",
|
|
11
|
+
* filebase: { accessKey: "...", secretKey: "...", bucket: "my-bucket" },
|
|
12
|
+
* });
|
|
13
|
+
*
|
|
14
|
+
* const { storylineId } = await client.createStoryline(
|
|
15
|
+
* "My Story",
|
|
16
|
+
* "Once upon a time...",
|
|
17
|
+
* "Fantasy",
|
|
18
|
+
* );
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
export { PlotLink } from "./client.js";
|
|
23
|
+
export type {
|
|
24
|
+
PlotLinkConfig,
|
|
25
|
+
CreateStorylineResult,
|
|
26
|
+
ChainPlotResult,
|
|
27
|
+
StorylineInfo,
|
|
28
|
+
PlotInfo,
|
|
29
|
+
RegisterAgentResult,
|
|
30
|
+
SetAgentWalletResult,
|
|
31
|
+
RoyaltyInfo,
|
|
32
|
+
TokenPriceInfo,
|
|
33
|
+
} from "./client.js";
|
|
34
|
+
export type { FilebaseConfig } from "./ipfs.js";
|
|
35
|
+
|
|
36
|
+
// Re-export constants for callers who need contract addresses
|
|
37
|
+
export {
|
|
38
|
+
STORY_FACTORY_ADDRESS,
|
|
39
|
+
MCV2_BOND_ADDRESS,
|
|
40
|
+
ERC8004_REGISTRY_ADDRESS,
|
|
41
|
+
BASE_SEPOLIA_CHAIN_ID,
|
|
42
|
+
BASE_MAINNET_CHAIN_ID,
|
|
43
|
+
} from "./constants.js";
|
|
44
|
+
|
|
45
|
+
// Re-export ABIs for direct contract reads
|
|
46
|
+
export { mcv2BondAbi } from "./abi.js";
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import {
|
|
2
|
+
S3Client,
|
|
3
|
+
PutObjectCommand,
|
|
4
|
+
HeadObjectCommand,
|
|
5
|
+
} from "@aws-sdk/client-s3";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Filebase configuration for IPFS pinning via S3-compatible API.
|
|
9
|
+
*/
|
|
10
|
+
export interface FilebaseConfig {
|
|
11
|
+
accessKey: string;
|
|
12
|
+
secretKey: string;
|
|
13
|
+
bucket: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Create an S3-compatible client for Filebase IPFS pinning.
|
|
18
|
+
*/
|
|
19
|
+
function createFilebaseClient(config: FilebaseConfig): S3Client {
|
|
20
|
+
return new S3Client({
|
|
21
|
+
endpoint: "https://s3.filebase.com",
|
|
22
|
+
region: "us-east-1",
|
|
23
|
+
credentials: {
|
|
24
|
+
accessKeyId: config.accessKey,
|
|
25
|
+
secretAccessKey: config.secretKey,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Upload content to Filebase (IPFS pinning via S3 API) and return the CID.
|
|
32
|
+
*
|
|
33
|
+
* The CID is retrieved from the HeadObject response metadata after upload.
|
|
34
|
+
* Content is stored as UTF-8 plain text.
|
|
35
|
+
*/
|
|
36
|
+
export async function uploadToIPFS(
|
|
37
|
+
content: string,
|
|
38
|
+
key: string,
|
|
39
|
+
config: FilebaseConfig,
|
|
40
|
+
): Promise<string> {
|
|
41
|
+
const s3 = createFilebaseClient(config);
|
|
42
|
+
|
|
43
|
+
await s3.send(
|
|
44
|
+
new PutObjectCommand({
|
|
45
|
+
Bucket: config.bucket,
|
|
46
|
+
Key: key,
|
|
47
|
+
Body: content,
|
|
48
|
+
ContentType: "text/plain; charset=utf-8",
|
|
49
|
+
}),
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const head = await s3.send(
|
|
53
|
+
new HeadObjectCommand({ Bucket: config.bucket, Key: key }),
|
|
54
|
+
);
|
|
55
|
+
const cid = head.Metadata?.cid;
|
|
56
|
+
if (!cid) {
|
|
57
|
+
throw new Error("Filebase response missing CID in metadata");
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return cid;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Upload content to IPFS with retry logic.
|
|
65
|
+
*
|
|
66
|
+
* 3 attempts with exponential backoff (1s, 2s, 4s).
|
|
67
|
+
*/
|
|
68
|
+
export async function uploadWithRetry(
|
|
69
|
+
content: string,
|
|
70
|
+
key: string,
|
|
71
|
+
config: FilebaseConfig,
|
|
72
|
+
maxRetries = 3,
|
|
73
|
+
): Promise<string> {
|
|
74
|
+
let lastError: Error | null = null;
|
|
75
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
76
|
+
try {
|
|
77
|
+
return await uploadToIPFS(content, key, config);
|
|
78
|
+
} catch (error) {
|
|
79
|
+
lastError = error instanceof Error ? error : new Error("Unknown error");
|
|
80
|
+
if (attempt < maxRetries) {
|
|
81
|
+
await new Promise((r) =>
|
|
82
|
+
setTimeout(r, Math.pow(2, attempt - 1) * 1000),
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
throw lastError || new Error("IPFS upload failed after retries");
|
|
88
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { PlotLink } from "./sdk/index.js";
|
|
2
|
+
import type { PlotLinkConfig } from "./sdk/index.js";
|
|
3
|
+
import { loadConfig } from "./config.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Build a PlotLink SDK client from CLI config.
|
|
7
|
+
*
|
|
8
|
+
* @param options.ipfs - Whether IPFS (Filebase) credentials are required.
|
|
9
|
+
* Commands that upload content (create, chain) need this; read-only commands don't.
|
|
10
|
+
*/
|
|
11
|
+
export function buildClient(options: { ipfs: boolean }): PlotLink {
|
|
12
|
+
const cfg = loadConfig();
|
|
13
|
+
|
|
14
|
+
const config: PlotLinkConfig = {
|
|
15
|
+
privateKey: cfg.privateKey,
|
|
16
|
+
rpcUrl: cfg.rpcUrl,
|
|
17
|
+
chainId: cfg.chainId,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
if (options.ipfs) {
|
|
21
|
+
if (!cfg.filebaseAccessKey || !cfg.filebaseSecretKey || !cfg.filebaseBucket) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
"Filebase credentials required for this command. " +
|
|
24
|
+
"Set PLOTLINK_FILEBASE_ACCESS_KEY, PLOTLINK_FILEBASE_SECRET_KEY, " +
|
|
25
|
+
"and PLOTLINK_FILEBASE_BUCKET env vars or add them to .plotlinkrc",
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
config.filebase = {
|
|
29
|
+
accessKey: cfg.filebaseAccessKey,
|
|
30
|
+
secretKey: cfg.filebaseSecretKey,
|
|
31
|
+
bucket: cfg.filebaseBucket,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return new PlotLink(config);
|
|
36
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2021",
|
|
4
|
+
"lib": ["ES2021"],
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "bundler",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"isolatedModules": true,
|
|
12
|
+
"declaration": true,
|
|
13
|
+
"declarationMap": true,
|
|
14
|
+
"outDir": "./dist",
|
|
15
|
+
"rootDir": "./src",
|
|
16
|
+
"noEmit": true
|
|
17
|
+
},
|
|
18
|
+
"include": ["src/**/*.ts"],
|
|
19
|
+
"exclude": ["node_modules", "dist"]
|
|
20
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defineConfig } from "tsup";
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
entry: ["src/index.ts"],
|
|
5
|
+
format: ["esm"],
|
|
6
|
+
dts: false,
|
|
7
|
+
splitting: false,
|
|
8
|
+
sourcemap: true,
|
|
9
|
+
clean: true,
|
|
10
|
+
outDir: "dist",
|
|
11
|
+
banner: {
|
|
12
|
+
js: "#!/usr/bin/env node",
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"accountAssociation": {
|
|
3
|
+
"header": "eyJmaWQiOjgxMDYsInR5cGUiOiJhdXRoIiwia2V5IjoiMHhhNzBiMDZhNzdkNmEwQTg0NmE4Yzg1RDYwMzA0OWFCNjA5NzU3RUY0In0",
|
|
4
|
+
"payload": "eyJkb21haW4iOiJwbG90bGluay54eXoifQ",
|
|
5
|
+
"signature": "jHCxpF3pxXBHBwI4uRuIFAskfPhL9bb4tTnmJ2VJLlwJMV3rZSeozOCw/8Pio4BTd0GLS0YUDIPGd7E51DATLhw="
|
|
6
|
+
},
|
|
7
|
+
"miniapp": {
|
|
8
|
+
"version": "1",
|
|
9
|
+
"name": "PlotLink",
|
|
10
|
+
"subtitle": "Write Stories. Trade Them.",
|
|
11
|
+
"description": "Tokenise your story from day 1. Publish plots, drive trading, earn royalties from every trade.",
|
|
12
|
+
"iconUrl": "https://plotlink.xyz/icon.png",
|
|
13
|
+
"homeUrl": "https://plotlink.xyz",
|
|
14
|
+
"imageUrl": "https://plotlink.xyz/embed-image.png",
|
|
15
|
+
"buttonTitle": "Open PlotLink",
|
|
16
|
+
"splashImageUrl": "https://plotlink.xyz/splash.png",
|
|
17
|
+
"splashBackgroundColor": "#E8DFD0",
|
|
18
|
+
"heroImageUrl": "https://plotlink.xyz/og-image.png",
|
|
19
|
+
"tagline": "Your story is a token.",
|
|
20
|
+
"ogTitle": "PlotLink",
|
|
21
|
+
"ogDescription": "Tokenise your story from day 1. Publish plots, drive trading, earn royalties from every trade.",
|
|
22
|
+
"ogImageUrl": "https://plotlink.xyz/og-image.png",
|
|
23
|
+
"screenshotUrls": [
|
|
24
|
+
"https://plotlink.xyz/screenshot-1.png",
|
|
25
|
+
"https://plotlink.xyz/screenshot-2.png",
|
|
26
|
+
"https://plotlink.xyz/screenshot-3.png"
|
|
27
|
+
],
|
|
28
|
+
"primaryCategory": "entertainment",
|
|
29
|
+
"tags": ["stories", "writing", "onchain", "base"],
|
|
30
|
+
"requiredChains": ["eip155:8453"],
|
|
31
|
+
"requiredCapabilities": [
|
|
32
|
+
"wallet.getEthereumProvider",
|
|
33
|
+
"actions.swapToken"
|
|
34
|
+
],
|
|
35
|
+
"webhookUrl": "https://plotlink.xyz/api/webhook/notifications"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M4.15603 9.50607C4.15604 9.39424 4.17811 9.2835 4.22096 9.18024C4.26382 9.07696 4.3266 8.98319 4.40572 8.9043C4.48485 8.82541 4.57875 8.76295 4.68203 8.72053C4.78531 8.6781 4.89594 8.65652 5.00757 8.65704L6.41934 8.66166C6.64444 8.66166 6.86032 8.75125 7.0195 8.91072C7.17867 9.07019 7.26809 9.28649 7.26809 9.51201V14.8608C7.42709 14.8136 7.63059 14.7632 7.85451 14.7104C8.00965 14.6738 8.14791 14.5858 8.24687 14.4606C8.34583 14.3355 8.39971 14.1805 8.39974 14.0208V7.38654C8.39974 7.16101 8.48915 6.9447 8.64832 6.78521C8.80749 6.6257 9.02338 6.53608 9.24849 6.53603H10.6645C10.8897 6.53608 11.1055 6.6257 11.2647 6.78521C11.4239 6.9447 11.5133 7.16101 11.5133 7.38654V13.5442C11.5133 13.5442 11.8675 13.4006 12.2124 13.2546C12.3406 13.2003 12.4499 13.1094 12.5268 12.9933C12.6038 12.8771 12.6448 12.7408 12.6449 12.6014V5.26059C12.6449 5.0351 12.7343 4.81884 12.8935 4.65936C13.0526 4.49989 13.2684 4.41028 13.4935 4.41023H14.9081C15.133 4.41047 15.3487 4.50014 15.5077 4.6596C15.6667 4.81905 15.756 5.03521 15.756 5.26059V11.3055C16.9825 10.415 18.2253 9.34395 19.2117 8.05613C19.3547 7.8692 19.4494 7.64969 19.4873 7.41717C19.5251 7.18465 19.505 6.94636 19.4285 6.72357C18.9719 5.40754 18.2461 4.20149 17.2977 3.1826C16.3491 2.16371 15.1988 1.35442 13.9202 0.806509C12.6416 0.258603 11.2629 -0.0158526 9.8724 0.000707134C8.48187 0.0172669 7.11009 0.324477 5.84486 0.902678C4.57962 1.48088 3.44881 2.31734 2.52474 3.35853C1.6007 4.39972 0.903758 5.62271 0.478538 6.94925C0.0533168 8.27577 -0.0908225 9.67665 0.0553422 11.0622C0.201507 12.4477 0.634757 13.7875 1.32737 14.9956C1.44804 15.204 1.62557 15.3736 1.83911 15.4845C2.05264 15.5953 2.29331 15.6428 2.53285 15.6213C2.80044 15.5977 3.13361 15.5643 3.52973 15.5178C3.70211 15.4981 3.86128 15.4156 3.97689 15.286C4.09251 15.1564 4.1565 14.9887 4.15669 14.8149V9.50607" fill="white"/>
|
|
3
|
+
<path d="M4.12598 18.0839C5.61704 19.1707 7.37912 19.8231 9.21725 19.9687C11.0554 20.1145 12.8979 19.7478 14.541 18.9095C16.1841 18.0712 17.5637 16.7938 18.5271 15.2187C19.4905 13.6436 20.0003 11.8321 20 9.98475C20 9.75363 19.9893 9.52614 19.974 9.29932C16.3221 14.7562 9.57929 17.3072 4.12598 18.0839Z" fill="#0052FF"/>
|
|
4
|
+
</svg>
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<svg width="500" height="500" viewBox="0 0 500 500" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<g clip-path="url(#clip0_98_6)">
|
|
3
|
+
<path d="M250 500C388.071 500 500 388.071 500 250C500 111.929 388.071 0 250 0C111.929 0 0 111.929 0 250C0 388.071 111.929 500 250 500Z" fill="#FC6F6F"/>
|
|
4
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M202.446 96.0144L202.445 172.304C216.387 164.124 232.643 159.431 250 159.431C300.411 159.431 341.529 199.016 343.663 248.648C343.711 248.648 343.75 248.687 343.75 248.735V339.1C343.75 351.857 333.409 362.198 320.652 362.198C307.896 362.198 297.554 351.857 297.554 339.1V248.82C297.554 248.726 297.478 248.649 297.383 248.649C297.383 248.649 297.384 248.649 297.383 248.649C295.316 224.417 274.891 205.391 250 205.391C225.413 205.391 205.184 223.956 202.702 247.765L202.626 248.564C202.621 248.612 202.58 248.649 202.532 248.649C202.484 248.648 202.446 248.686 202.446 248.734C202.446 248.733 202.446 248.734 202.446 248.734L202.446 339.1C202.446 351.857 192.104 362.198 179.348 362.198C166.591 362.198 156.25 351.857 156.25 339.1V96.0144C156.25 83.2578 166.591 72.9166 179.348 72.9166C192.104 72.9166 202.446 83.2579 202.446 96.0144C202.446 96.0145 202.446 96.0144 202.446 96.0144ZM179.348 427.083C192.104 427.083 202.446 416.795 202.446 404.103C202.446 391.411 192.104 381.123 179.348 381.123C166.591 381.123 156.25 391.411 156.25 404.103C156.25 416.795 166.591 427.083 179.348 427.083ZM320.652 427.083C333.409 427.083 343.75 416.795 343.75 404.103C343.75 391.411 333.409 381.123 320.652 381.123C307.896 381.123 297.554 391.411 297.554 404.103C297.554 416.795 307.896 427.083 320.652 427.083Z" fill="white"/>
|
|
5
|
+
</g>
|
|
6
|
+
<defs>
|
|
7
|
+
<clipPath id="clip0_98_6">
|
|
8
|
+
<rect width="500" height="500" fill="white"/>
|
|
9
|
+
</clipPath>
|
|
10
|
+
</defs>
|
|
11
|
+
</svg>
|
|
Binary file
|
package/public/icon.png
ADDED
|
Binary file
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "PlotLink",
|
|
3
|
+
"short_name": "PlotLink",
|
|
4
|
+
"icons": [
|
|
5
|
+
{
|
|
6
|
+
"src": "/icon-192.png",
|
|
7
|
+
"sizes": "192x192",
|
|
8
|
+
"type": "image/png"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"src": "/favicon.png",
|
|
12
|
+
"sizes": "512x512",
|
|
13
|
+
"type": "image/png"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"src": "/icon.png",
|
|
17
|
+
"sizes": "1024x1024",
|
|
18
|
+
"type": "image/png",
|
|
19
|
+
"purpose": "any maskable"
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"theme_color": "#E8DFD0",
|
|
23
|
+
"background_color": "#E8DFD0",
|
|
24
|
+
"display": "standalone",
|
|
25
|
+
"start_url": "/"
|
|
26
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg width="1020px" height="1020px" viewBox="0 0 1020 1020" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
3
|
+
<title>mc-icon-light</title>
|
|
4
|
+
<g id="logo" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
5
|
+
<g id="mc-icon-light" transform="translate(-30.000000, -30.000000)">
|
|
6
|
+
<g transform="translate(30.000000, 30.000000)">
|
|
7
|
+
<rect id="Rectangle" stroke="#15E6B7" stroke-width="24" fill="#0B0C1B" x="12" y="12" width="996" height="996" rx="498"></rect>
|
|
8
|
+
<path d="M736.934432,224.4 C769.334531,224.4 795.6,250.665469 795.6,283.065568 L795.6,740.863736 C795.6,771.09374 771.09374,795.6 740.863736,795.6 C710.633733,795.6 686.127473,771.09374 686.127473,740.863736 L686.127473,575.034575 C686.127473,553.774672 668.892916,536.540116 647.633014,536.540116 C633.317279,536.540116 620.184023,544.484345 613.538095,557.163931 L555.21226,668.442215 C546.44299,685.172869 529.113721,695.655242 510.224176,695.655242 C491.330835,695.655242 473.9942,685.183015 465.202528,668.459833 L406.692308,557.163931 C396.766677,538.283777 373.414975,531.024701 354.534821,540.950331 C341.836684,547.625966 333.884982,560.789906 333.884982,575.135874 L333.884982,740.857509 C333.884982,771.090952 309.375934,795.6 279.142491,795.6 C248.909048,795.6 224.4,771.090952 224.4,740.857509 L224.4,283.47033 C224.4,250.846687 250.846687,224.4 283.47033,224.4 C319.769722,224.4 353.053162,244.599081 369.811254,276.79865 L426.27033,385.28104 C450.395193,431.635375 507.529872,449.655921 553.884206,425.531058 C571.057571,416.593273 585.075942,402.602598 594.047672,385.446943 L651.08227,276.38594 C667.794142,244.429662 700.87212,224.4 736.934432,224.4 Z M425.2125,715.275 C447.393636,715.275 465.375,733.256364 465.375,755.4375 C465.375,777.618636 447.393636,795.6 425.2125,795.6 C403.031364,795.6 385.05,777.618636 385.05,755.4375 C385.05,733.256364 403.031364,715.275 425.2125,715.275 Z M594.7875,715.275 C616.968636,715.275 634.95,733.256364 634.95,755.4375 C634.95,777.618636 616.968636,795.6 594.7875,795.6 C572.606364,795.6 554.625,777.618636 554.625,755.4375 C554.625,733.256364 572.606364,715.275 594.7875,715.275 Z" id="Combined-Shape" fill="#15E6B7" fill-rule="nonzero"></path>
|
|
9
|
+
</g>
|
|
10
|
+
</g>
|
|
11
|
+
</g>
|
|
12
|
+
</svg>
|
|
Binary file
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg width="300" height="364" viewBox="0 0 300 364" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M47.3684 292.105H300V0H47.3684C21.2479 0 0 21.2479 0 47.3684V319.089C0 343.39 21.2479 363.158 47.3684 363.158H300V347.368H47.3684C30.2529 347.368 15.7895 334.416 15.7895 319.089C15.7895 303.947 29.6669 292.105 47.3684 292.105Z" fill="#8B4513"/>
|
|
3
|
+
<path d="M129.746 186.622C127.559 186.713 125.553 186.804 123.73 186.895C121.999 186.895 120.312 186.895 118.672 186.895C117.122 186.895 115.573 186.895 114.023 186.895C112.565 186.895 111.016 186.85 109.375 186.758V211.505C109.375 216.609 109.284 221.531 109.102 226.27C108.919 230.919 108.646 234.428 108.281 236.798L132.07 235.977V257.579H48.9453V239.122C52.0443 238.939 54.8242 238.666 57.2852 238.301C59.8372 237.846 61.9336 236.843 63.5742 235.294C65.306 233.653 66.6276 231.238 67.5391 228.048C68.4505 224.857 68.9062 220.437 68.9062 214.786V107.462C68.9062 104.91 68.9062 102.403 68.9062 99.9421C68.9974 97.4811 69.0885 95.1569 69.1797 92.9694C69.2708 90.6908 69.362 88.64 69.4531 86.8171C69.6354 84.9942 69.8177 83.4903 70 82.3054L48.9453 83.1257V61.5241L128.652 60.9772C140.775 60.8861 151.758 62.0254 161.602 64.3952C171.536 66.765 180.013 70.4564 187.031 75.4694C194.049 80.3913 199.473 86.7259 203.301 94.4733C207.129 102.221 209.043 111.518 209.043 122.364C209.134 130.202 207.585 137.859 204.395 145.333C201.204 152.716 196.328 159.415 189.766 165.43C183.294 171.446 175.091 176.368 165.156 180.196C155.221 184.024 143.418 186.166 129.746 186.622ZM121.953 166.661C129.609 166.661 136.217 165.704 141.777 163.79C147.337 161.785 151.895 158.868 155.449 155.04C159.004 151.212 161.602 146.518 163.242 140.958C164.974 135.398 165.84 129.063 165.84 121.954C165.84 115.756 165.247 110.424 164.062 105.958C162.878 101.492 161.283 97.7546 159.277 94.7468C157.272 91.6478 154.948 89.1869 152.305 87.364C149.753 85.4499 147.064 84.0371 144.238 83.1257C141.504 82.1231 138.724 81.485 135.898 81.2116C133.164 80.847 130.612 80.6647 128.242 80.6647C125.234 80.6647 122.546 80.8926 120.176 81.3483C117.897 81.8041 115.938 82.8067 114.297 84.3561C112.747 85.9056 111.517 88.1387 110.605 91.0554C109.785 93.972 109.375 97.8913 109.375 102.813V165.841C111.38 166.023 113.431 166.205 115.527 166.387C117.624 166.57 119.766 166.661 121.953 166.661Z" fill="white"/>
|
|
4
|
+
<path d="M215.98 100.579V93.9871C217.087 93.922 218.08 93.8243 218.959 93.6941C219.87 93.5313 220.619 93.1733 221.205 92.6199C221.824 92.0339 222.296 91.1713 222.621 90.032C222.947 88.8927 223.109 87.3139 223.109 85.2957V46.9656C223.109 46.0541 223.109 45.1589 223.109 44.28C223.142 43.4011 223.174 42.571 223.207 41.7898C223.24 40.976 223.272 40.2436 223.305 39.5925C223.37 38.9415 223.435 38.4044 223.5 37.9812L215.98 38.2742V30.5593H244.691V37.1511C243.552 37.2162 242.543 37.3302 241.664 37.4929C240.785 37.6557 240.036 38.0138 239.418 38.5671C238.832 39.1205 238.376 39.9669 238.051 41.1062C237.725 42.2455 237.562 43.8243 237.562 45.8425V84.1726C237.562 85.0841 237.546 85.9792 237.514 86.8582C237.514 87.7045 237.497 88.5183 237.465 89.2996C237.432 90.0808 237.383 90.797 237.318 91.448C237.286 92.0665 237.237 92.5873 237.172 93.0105L250.6 92.9617C254.538 92.9617 257.631 91.6108 259.877 88.9089C262.123 86.1746 263.246 82.073 263.246 76.6042H269.887L269.301 100.579H215.98Z" fill="white"/>
|
|
5
|
+
</svg>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg width="300" height="364" viewBox="0 0 300 364" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M47.3684 292.105H300V0H47.3684C21.2479 0 0 21.2479 0 47.3684V319.089C0 343.39 21.2479 363.158 47.3684 363.158H300V347.368H47.3684C30.2529 347.368 15.7895 334.416 15.7895 319.089C15.7895 303.947 29.6669 292.105 47.3684 292.105Z" fill="#8B4513"/>
|
|
3
|
+
<path d="M129.746 186.622C127.559 186.713 125.553 186.804 123.73 186.895C121.999 186.895 120.312 186.895 118.672 186.895C117.122 186.895 115.573 186.895 114.023 186.895C112.565 186.895 111.016 186.85 109.375 186.758V211.505C109.375 216.609 109.284 221.531 109.102 226.27C108.919 230.919 108.646 234.428 108.281 236.798L132.07 235.977V257.579H48.9453V239.122C52.0443 238.939 54.8242 238.666 57.2852 238.301C59.8372 237.846 61.9336 236.843 63.5742 235.294C65.306 233.653 66.6276 231.238 67.5391 228.048C68.4505 224.857 68.9062 220.437 68.9062 214.786V107.462C68.9062 104.91 68.9062 102.403 68.9062 99.9421C68.9974 97.4811 69.0885 95.1569 69.1797 92.9694C69.2708 90.6908 69.362 88.64 69.4531 86.8171C69.6354 84.9942 69.8177 83.4903 70 82.3054L48.9453 83.1257V61.5241L128.652 60.9772C140.775 60.8861 151.758 62.0254 161.602 64.3952C171.536 66.765 180.013 70.4564 187.031 75.4694C194.049 80.3913 199.473 86.7259 203.301 94.4733C207.129 102.221 209.043 111.518 209.043 122.364C209.134 130.202 207.585 137.859 204.395 145.333C201.204 152.716 196.328 159.415 189.766 165.43C183.294 171.446 175.091 176.368 165.156 180.196C155.221 184.024 143.418 186.166 129.746 186.622ZM121.953 166.661C129.609 166.661 136.217 165.704 141.777 163.79C147.337 161.785 151.895 158.868 155.449 155.04C159.004 151.212 161.602 146.518 163.242 140.958C164.974 135.398 165.84 129.063 165.84 121.954C165.84 115.756 165.247 110.424 164.062 105.958C162.878 101.492 161.283 97.7546 159.277 94.7468C157.272 91.6478 154.948 89.1869 152.305 87.364C149.753 85.4499 147.064 84.0371 144.238 83.1257C141.504 82.1231 138.724 81.485 135.898 81.2116C133.164 80.847 130.612 80.6647 128.242 80.6647C125.234 80.6647 122.546 80.8926 120.176 81.3483C117.897 81.8041 115.938 82.8067 114.297 84.3561C112.747 85.9056 111.517 88.1387 110.605 91.0554C109.785 93.972 109.375 97.8913 109.375 102.813V165.841C111.38 166.023 113.431 166.205 115.527 166.387C117.624 166.57 119.766 166.661 121.953 166.661Z" fill="white"/>
|
|
4
|
+
<path d="M215.98 100.579V93.9871C217.087 93.922 218.08 93.8243 218.959 93.6941C219.87 93.5313 220.619 93.1733 221.205 92.6199C221.824 92.0339 222.296 91.1713 222.621 90.032C222.947 88.8927 223.109 87.3139 223.109 85.2957V46.9656C223.109 46.0541 223.109 45.1589 223.109 44.28C223.142 43.4011 223.174 42.571 223.207 41.7898C223.24 40.976 223.272 40.2436 223.305 39.5925C223.37 38.9415 223.435 38.4044 223.5 37.9812L215.98 38.2742V30.5593H244.691V37.1511C243.552 37.2162 242.543 37.3302 241.664 37.4929C240.785 37.6557 240.036 38.0138 239.418 38.5671C238.832 39.1205 238.376 39.9669 238.051 41.1062C237.725 42.2455 237.562 43.8243 237.562 45.8425V84.1726C237.562 85.0841 237.546 85.9792 237.514 86.8582C237.514 87.7045 237.497 88.5183 237.465 89.2996C237.432 90.0808 237.383 90.797 237.318 91.448C237.286 92.0665 237.237 92.5873 237.172 93.0105L250.6 92.9617C254.538 92.9617 257.631 91.6108 259.877 88.9089C262.123 86.1746 263.246 82.073 263.246 76.6042H269.887L269.301 100.579H215.98Z" fill="white"/>
|
|
5
|
+
</svg>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/bin/env npx tsx
|
|
2
|
+
/**
|
|
3
|
+
* Backfill trade_history.price_per_token with marginal price (priceForNextMint)
|
|
4
|
+
* instead of the batch average that was previously stored.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* npx tsx scripts/backfill-trade-prices.ts
|
|
8
|
+
*
|
|
9
|
+
* Requires: NEXT_PUBLIC_SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { createClient } from "@supabase/supabase-js";
|
|
13
|
+
import { formatUnits } from "viem";
|
|
14
|
+
import { publicClient } from "../lib/rpc";
|
|
15
|
+
import { priceForNextMintFunction } from "../lib/contracts/abi";
|
|
16
|
+
import { MCV2_BOND } from "../lib/contracts/constants";
|
|
17
|
+
|
|
18
|
+
const SUPABASE_URL = process.env.NEXT_PUBLIC_SUPABASE_URL || "";
|
|
19
|
+
const SUPABASE_KEY = process.env.SUPABASE_SERVICE_ROLE_KEY || "";
|
|
20
|
+
|
|
21
|
+
if (!SUPABASE_URL || !SUPABASE_KEY) {
|
|
22
|
+
console.error("Missing NEXT_PUBLIC_SUPABASE_URL or SUPABASE_SERVICE_ROLE_KEY");
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const supabase = createClient(SUPABASE_URL, SUPABASE_KEY, {
|
|
27
|
+
auth: { autoRefreshToken: false, persistSession: false },
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
async function main() {
|
|
31
|
+
console.log("=== Backfill Trade Prices ===");
|
|
32
|
+
console.log(`MCV2_BOND: ${MCV2_BOND}`);
|
|
33
|
+
|
|
34
|
+
const { data: trades, error: fetchError } = await supabase
|
|
35
|
+
.from("trade_history")
|
|
36
|
+
.select("id, token_address, block_number, price_per_token")
|
|
37
|
+
.order("block_number", { ascending: true });
|
|
38
|
+
|
|
39
|
+
if (fetchError) {
|
|
40
|
+
console.error("Failed to fetch trades:", fetchError.message);
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (!trades || trades.length === 0) {
|
|
45
|
+
console.log("No trades to backfill.");
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
console.log(`Found ${trades.length} trades to backfill.`);
|
|
50
|
+
|
|
51
|
+
let updated = 0;
|
|
52
|
+
let failed = 0;
|
|
53
|
+
|
|
54
|
+
for (const trade of trades) {
|
|
55
|
+
try {
|
|
56
|
+
const price = await publicClient.readContract({
|
|
57
|
+
address: MCV2_BOND as `0x${string}`,
|
|
58
|
+
abi: [priceForNextMintFunction],
|
|
59
|
+
functionName: "priceForNextMint",
|
|
60
|
+
args: [trade.token_address as `0x${string}`],
|
|
61
|
+
blockNumber: BigInt(trade.block_number),
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const marginalPrice = Number(formatUnits(price, 18));
|
|
65
|
+
|
|
66
|
+
const { error: updateError } = await supabase
|
|
67
|
+
.from("trade_history")
|
|
68
|
+
.update({ price_per_token: marginalPrice })
|
|
69
|
+
.eq("id", trade.id);
|
|
70
|
+
|
|
71
|
+
if (updateError) {
|
|
72
|
+
console.error(` [FAIL] id=${trade.id}: ${updateError.message}`);
|
|
73
|
+
failed++;
|
|
74
|
+
} else {
|
|
75
|
+
const oldPrice = trade.price_per_token;
|
|
76
|
+
if (Math.abs(marginalPrice - oldPrice) > 0.0001) {
|
|
77
|
+
console.log(` [FIX] id=${trade.id} block=${trade.block_number}: ${oldPrice} → ${marginalPrice}`);
|
|
78
|
+
}
|
|
79
|
+
updated++;
|
|
80
|
+
}
|
|
81
|
+
} catch (err) {
|
|
82
|
+
console.error(` [FAIL] id=${trade.id} block=${trade.block_number}: ${(err as Error).message?.slice(0, 80)}`);
|
|
83
|
+
failed++;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Delay between RPC calls to avoid rate limits
|
|
87
|
+
await new Promise((r) => setTimeout(r, 200));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
console.log("");
|
|
91
|
+
console.log(`=== Backfill complete: ${updated} updated, ${failed} failed ===`);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
main().catch((err) => {
|
|
95
|
+
console.error("Fatal error:", err);
|
|
96
|
+
process.exit(2);
|
|
97
|
+
});
|