Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ BOT_TOKENS="{\"secret\":\"dev\"}"
Create `terminator/.dev.vars` file with the following content:

```
FILCDN_CONTROLLER_ADDRESS_PRIVATE_KEY=0xSomePrivateKey
FILBEAM_OPERATOR_CONTROLLER_PRIVATE_KEY=0xSomePrivateKey
```

### Workflow
Expand Down
8 changes: 7 additions & 1 deletion payment-settler/lib/rail-settlement.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
/** @import {PublicClient, WalletClient, PrivateKeyAccount} from 'viem' */
/**
* @import {
Comment thread
DarkLord017 marked this conversation as resolved.
* PrivateKeyAccount,
* PublicClient,
* WalletClient
* } from "viem"
*/
import filbeamAbi from '../lib/FilBeamOperator.abi.json'

/**
Expand Down
4 changes: 3 additions & 1 deletion piece-retriever/lib/retrieval.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import { createPieceCIDStream } from './piece.js'
* url: string
* validate: function | null
* }>}
* - The response from the fetch request, the cache miss and the content length.
* -
Comment thread
DarkLord017 marked this conversation as resolved.
*
* The response from the fetch request, the cache miss and the content length.
*/
export async function retrieveFile(
ctx,
Expand Down
2 changes: 1 addition & 1 deletion terminator/lib/chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function getChainClient(env) {
})

const account = privateKeyToAccount(
/** @type {`0x${string}`} */ (env.FILBEAM_CONTROLLER_PRIVATE_KEY),
/** @type {`0x${string}`} */ (env.FILBEAM_OPERATOR_CONTROLLER_PRIVATE_KEY),
)

const walletClient = createWalletClient({
Expand Down
3 changes: 1 addition & 2 deletions terminator/lib/fwss.js → terminator/lib/filbeam.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
export const abi = [
{
type: 'function',
name: 'terminateCDNService',
name: 'terminateCDNPaymentRails',
inputs: [
{
name: 'dataSetId',
type: 'uint256',
internalType: 'uint256',
},
],
outputs: [],
Expand Down
8 changes: 4 additions & 4 deletions terminator/lib/queue-handlers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'node:assert'
import { abi as fwssAbi } from './fwss.js'
import { abi as filBeamAbi } from './filbeam.js'
import { getChainClient as defaultGetChainClient } from './chain.js'
import { getRecentSendMessage as defaultGetRecentSendMessage } from './filfox.js'

Expand Down Expand Up @@ -41,16 +41,16 @@ export async function handleTerminateCdnServiceQueueMessage(
// Create contract call
const { request } = await publicClient.simulateContract({
account,
abi: fwssAbi,
abi: filBeamAbi,
address: /** @type {`0x${string}`} */ (
env.FILBEAM_OPERATOR_CONTRACT_ADDRESS
),
functionName: 'terminateCDNService',
functionName: 'terminateCDNPaymentRails',
args: [BigInt(dataSetId)],
})

console.log(
`Sending terminateCDNService transaction for dataSetId: ${dataSetId}`,
`Sending terminateCDNPaymentRails transaction for dataSetId: ${dataSetId}`,
)

// Send transaction
Expand Down
6 changes: 3 additions & 3 deletions terminator/test/chain.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('getChainClient', () => {
RPC_URL: 'https://api.node.glif.io/',
FILBEAM_OPERATOR_CONTRACT_ADDRESS:
'0x0000000000000000000000000000000000000000',
FILBEAM_CONTROLLER_PRIVATE_KEY:
FILBEAM_OPERATOR_CONTROLLER_PRIVATE_KEY:
'0xdead000000000000000000000000000000000000000000000000000000000000',
}

Expand All @@ -27,7 +27,7 @@ describe('getChainClient', () => {
RPC_URL: 'https://api.calibration.node.glif.io/',
FILBEAM_OPERATOR_CONTRACT_ADDRESS:
'0x0000000000000000000000000000000000000000',
FILBEAM_CONTROLLER_PRIVATE_KEY:
FILBEAM_OPERATOR_CONTROLLER_PRIVATE_KEY:
'0xdead000000000000000000000000000000000000000000000000000000000000',
}

Expand All @@ -46,7 +46,7 @@ describe('getChainClient', () => {
RPC_URL: 'https://api.calibration.node.glif.io/',
FILBEAM_OPERATOR_CONTRACT_ADDRESS:
'0x0000000000000000000000000000000000000000',
FILBEAM_CONTROLLER_PRIVATE_KEY:
FILBEAM_OPERATOR_CONTROLLER_PRIVATE_KEY:
'0xdead000000000000000000000000000000000000000000000000000000000000',
}

Expand Down
8 changes: 4 additions & 4 deletions terminator/test/queue-handlers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
handleTransactionRetryQueueMessage,
} from '../lib/queue-handlers.js'
import { env } from 'cloudflare:test'
import { abi as fwssAbi } from '../lib/fwss.js'
import { abi as filBeamAbi } from '../lib/filbeam.js'
import { randomId, withDataSet } from './test-helpers.js'
import { privateKeyToAccount } from 'viem/accounts'

Expand All @@ -14,7 +14,7 @@ const createMockEnv = (env) => ({
ENVIRONMENT: 'calibration',
RPC_URL: 'https://api.calibration.node.glif.io/',
FILBEAM_OPERATOR_CONTRACT_ADDRESS: '0xcontract',
FILBEAM_CONTROLLER_PRIVATE_KEY: '0xprivatekey',
FILBEAM_OPERATOR_CONTROLLER_PRIVATE_KEY: '0xprivatekey',
TRANSACTION_MONITOR_WORKFLOW: {
create: vi.fn().mockResolvedValue(undefined),
},
Expand Down Expand Up @@ -93,8 +93,8 @@ describe('handleTerminateCdnServiceQueueMessage', () => {
expect(mockChainClient.publicClient.simulateContract).toHaveBeenCalledWith({
account: mockAccount,
address: '0xcontract',
abi: fwssAbi,
functionName: 'terminateCDNService',
abi: filBeamAbi,
functionName: 'terminateCDNPaymentRails',
args: [BigInt(dataSetId)],
})

Expand Down
2 changes: 1 addition & 1 deletion terminator/worker-configuration.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ declare namespace Cloudflare {
ENVIRONMENT: "dev" | "calibration" | "mainnet";
RPC_URL: "https://api.calibration.node.glif.io/" | "https://api.node.glif.io/";
FILBEAM_OPERATOR_CONTRACT_ADDRESS: "0x0000000000000000000000000000000000000000" | "0x5991E4F9fcEF4AE23959eE03638B4688A7e1EcfF" | "0x9E90749D298C4ca43Bb468CA859Dfe167F9CdCf2";
FILBEAM_CONTROLLER_PRIVATE_KEY: string;
FILBEAM_OPERATOR_CONTROLLER_PRIVATE_KEY: string;
DB: D1Database;
TRANSACTION_QUEUE: Queue;
TRANSACTION_MONITOR_WORKFLOW: Workflow<Parameters<import("./bin/terminator").TransactionMonitorWorkflow['run']>[0]['payload']>;
Expand Down
4 changes: 3 additions & 1 deletion usage-reporter/lib/chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ export function getChainClient(env) {
})

const account = privateKeyToAccount(
/** @type {`0x${string}`} ` */ (env.FILBEAM_CONTROLLER_PRIVATE_KEY),
/** @type {`0x${string}`} ` */ (
env.FILBEAM_OPERATOR_CONTROLLER_PRIVATE_KEY
),
)

const walletClient = createWalletClient({
Expand Down
2 changes: 1 addition & 1 deletion usage-reporter/test/worker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('usage reporter worker scheduled entrypoint', () => {
const mockEnv = {
...env,
FILBEAM_OPERATOR_CONTRACT_ADDRESS: '0xMockFilBeamAddress',
FILBEAM_CONTROLLER_PRIVATE_KEY: '0xMockPrivateKey',
FILBEAM_OPERATOR_CONTROLLER_PRIVATE_KEY: '0xMockPrivateKey',
TRANSACTION_MONITOR_WORKFLOW: mockWorkflow,
}

Expand Down
4 changes: 2 additions & 2 deletions usage-reporter/worker-configuration.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ declare namespace Cloudflare {
RPC_URL: "https://api.calibration.node.glif.io/" | "https://api.node.glif.io/";
FILBEAM_OPERATOR_CONTRACT_ADDRESS: "0x0000000000000000000000000000000000000000" | "0x5991E4F9fcEF4AE23959eE03638B4688A7e1EcfF" | "0x9E90749D298C4ca43Bb468CA859Dfe167F9CdCf2";
FILECOIN_GENESIS_BLOCK_TIMESTAMP_MS: "1667326380000" | "1598306400000";
FILBEAM_CONTROLLER_PRIVATE_KEY: string;
FILBEAM_OPERATOR_CONTROLLER_PRIVATE_KEY: string;
DB: D1Database;
TRANSACTION_QUEUE: Queue;
TRANSACTION_MONITOR_WORKFLOW: Workflow<Parameters<import("./bin/usage-reporter").TransactionMonitorWorkflow['run']>[0]['payload']>;
Expand All @@ -21,7 +21,7 @@ type StringifyValues<EnvType extends Record<string, unknown>> = {
[Binding in keyof EnvType]: EnvType[Binding] extends string ? EnvType[Binding] : string;
};
declare namespace NodeJS {
interface ProcessEnv extends StringifyValues<Pick<Cloudflare.Env, "ENVIRONMENT" | "RPC_URL" | "FILBEAM_OPERATOR_CONTRACT_ADDRESS" | "FILECOIN_GENESIS_BLOCK_TIMESTAMP_MS" | "FILBEAM_CONTROLLER_PRIVATE_KEY">> {}
interface ProcessEnv extends StringifyValues<Pick<Cloudflare.Env, "ENVIRONMENT" | "RPC_URL" | "FILBEAM_OPERATOR_CONTRACT_ADDRESS" | "FILECOIN_GENESIS_BLOCK_TIMESTAMP_MS" | "FILBEAM_OPERATOR_CONTROLLER_PRIVATE_KEY">> {}
}

// Begin runtime types
Expand Down
4 changes: 2 additions & 2 deletions workflows/lib/chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { filecoinCalibration, filecoin } from 'viem/chains'
* @param {{
* ENVIRONMENT: 'mainnet' | 'calibration' | 'dev'
* RPC_URL: string
* FILBEAM_CONTROLLER_PRIVATE_KEY?: string
* FILBEAM_OPERATOR_CONTROLLER_PRIVATE_KEY?: string
* FILBEAM_OPERATOR_PAYMENT_SETTLER_PRIVATE_KEY?: string
* }} env
*/
Expand All @@ -21,7 +21,7 @@ export function getChainClient(env) {

// Support both payment-settler, terminator and usage-reporter private keys
const privateKey = /** @type {`0x${string}`} */ (
env.FILBEAM_CONTROLLER_PRIVATE_KEY ||
env.FILBEAM_OPERATOR_CONTROLLER_PRIVATE_KEY ||
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to regenerate workflows/worker-configuration.d.ts

env.FILBEAM_OPERATOR_PAYMENT_SETTLER_PRIVATE_KEY
)

Expand Down
7 changes: 6 additions & 1 deletion workflows/lib/transaction-monitor-workflow.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
/** @import {WorkflowEvent, WorkflowStep} from 'cloudflare:workers' */
/**
Comment thread
DarkLord017 marked this conversation as resolved.
* @import {
* WorkflowEvent,
* WorkflowStep
* } from "cloudflare:workers"
*/
import { WorkflowEntrypoint } from 'cloudflare:workers'
import { getChainClient } from './chain.js'

Expand Down
6 changes: 3 additions & 3 deletions workflows/test/transaction-monitor-workflow.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @import {WorkflowStep} from 'cloudflare:workers' */
/** @import {WorkflowStep} from "cloudflare:workers" */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you using npm run lint:fix to format the code or you're using your editor?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This issue has not been resolved

import { env } from 'cloudflare:test'
import { describe, it, expect, vi, afterEach } from 'vitest'
import { TransactionMonitorWorkflow } from '../lib/transaction-monitor-workflow.js'
Expand All @@ -17,13 +17,13 @@ describe('TransactionMonitorWorkflow', () => {
* TRANSACTION_QUEUE: { send: (message: any) => Promise<void> }
* ENVIRONMENT: string
* RPC_URL: string
* FILCDN_CONTROLLER_ADDRESS_PRIVATE_KEY: string
* FILBEAM_OPERATOR_CONTROLLER_PRIVATE_KEY: string
* }}
*/
const mockEnv = {
...env,
TRANSACTION_QUEUE: mockQueue,
FILCDN_CONTROLLER_ADDRESS_PRIVATE_KEY: '0x1234',
FILBEAM_OPERATOR_CONTROLLER_PRIVATE_KEY: '0x1234',
}

afterEach(() => {
Expand Down