Skip to content

Commit

Permalink
Merge pull request #319 from 0xsend/bb/shovel-add-send-revenues-safe-…
Browse files Browse the repository at this point in the history
…receives

shovel: add send revenues safe received
  • Loading branch information
0xBigBoss authored Apr 16, 2024
2 parents fbbc4be + 577e991 commit 9db843c
Show file tree
Hide file tree
Showing 13 changed files with 345 additions and 12 deletions.
26 changes: 26 additions & 0 deletions .snaplet/snaplet-client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,23 @@ type Override = {
chain_id?: string;
};
}
send_revenues_safe_receives?: {
name?: string;
fields?: {
chain_id?: string;
log_addr?: string;
block_time?: string;
tx_hash?: string;
sender?: string;
v?: string;
ig_name?: string;
src_name?: string;
block_num?: string;
tx_idx?: string;
log_idx?: string;
abi_idx?: string;
};
}
send_token_transfers?: {
name?: string;
fields?: {
Expand Down Expand Up @@ -564,6 +581,15 @@ export interface Fingerprint {
id?: FingerprintNumberField;
chainId?: FingerprintNumberField;
}
sendRevenuesSafeReceives?: {
chainId?: FingerprintNumberField;
blockTime?: FingerprintNumberField;
v?: FingerprintNumberField;
blockNum?: FingerprintNumberField;
txIdx?: FingerprintNumberField;
logIdx?: FingerprintNumberField;
abiIdx?: FingerprintNumberField;
}
sendTokenTransfers?: {
id?: FingerprintNumberField;
chainId?: FingerprintNumberField;
Expand Down
15 changes: 15 additions & 0 deletions .snaplet/snaplet.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,20 @@ interface Table_public_send_liquidity_pools {
address: string;
chain_id: number;
}
interface Table_public_send_revenues_safe_receives {
chain_id: number | null;
log_addr: string | null;
block_time: number | null;
tx_hash: string | null;
sender: string | null;
v: number | null;
ig_name: string | null;
src_name: string | null;
block_num: number | null;
tx_idx: number | null;
log_idx: number | null;
abi_idx: number | null;
}
interface Table_public_send_token_transfers {
id: number;
chain_id: number | null;
Expand Down Expand Up @@ -544,6 +558,7 @@ interface Schema_public {
send_account_transfers: Table_public_send_account_transfers;
send_accounts: Table_public_send_accounts;
send_liquidity_pools: Table_public_send_liquidity_pools;
send_revenues_safe_receives: Table_public_send_revenues_safe_receives;
send_token_transfers: Table_public_send_token_transfers;
send_transfer_logs: Table_public_send_transfer_logs;
tag_receipts: Table_public_tag_receipts;
Expand Down
1 change: 0 additions & 1 deletion apps/distributor/src/distributor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,6 @@ export class DistributorWorker {
log.error({ error: error.message, code: error.code }, 'Error saving shares.')
throw error
}
return shares
}

private async worker() {
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fork_block_number = 19582866

[profile.base]
# should be updated after releases
fork_block_number = 12817027
fork_block_number = 13216640

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options

Expand Down
81 changes: 81 additions & 0 deletions packages/shovel/etc/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,87 @@
"start": "$BASE_BLOCK_START"
}
]
},
{
"name": "send_revenues_safe_receives",
"enabled": true,
"table": {
"name": "send_revenues_safe_receives",
"columns": [
{
"name": "chain_id",
"type": "numeric"
},
{
"name": "log_addr",
"type": "bytea"
},
{
"name": "block_time",
"type": "numeric"
},
{
"name": "tx_hash",
"type": "bytea"
},
{
"name": "sender",
"type": "bytea"
},
{
"name": "v",
"type": "numeric"
}
]
},
"block": [
{
"name": "chain_id",
"column": "chain_id"
},
{
"name": "block_time",
"column": "block_time"
},
{
"name": "tx_hash",
"column": "tx_hash"
},
{
"name": "log_addr",
"column": "log_addr",
"filter_op": "contains",
"filter_arg": [
"0x269cD0a2afd1BAbdA7A74ab1dC853869a37aa4a7",
"0x71fa02bb11e4b119bEDbeeD2f119F62048245301"
]
}
],
"event": {
"type": "event",
"name": "SafeReceived",
"inputs": [
{
"name": "sender",
"internalType": "address",
"type": "address",
"indexed": true,
"column": "sender"
},
{
"name": "value",
"type": "uint256",
"indexed": false,
"column": "v"
}
]
},
"sources": [
{
"name": "base_logs",
"start": "$BASE_BLOCK_START"
}
]
}
]
}
2 changes: 1 addition & 1 deletion packages/shovel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"test": "bun test"
},
"devDependencies": {
"@indexsupply/shovel-config": "^0.0.8",
"@indexsupply/shovel-config": "^0.0.11",
"@my/wagmi": "workspace:*",
"@types/bun": "latest",
"permissionless": "^0.1.11",
Expand Down
9 changes: 5 additions & 4 deletions packages/shovel/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
sendAccountTransfersIntegration,
// sendAccountTransactionsIntegration,
sendTokenTransfersIntegration,
sendRevenuesSafeReceives,
} from './integrations'

// baseSrcBlockHeaders is to be used for integrations that require block headers
Expand All @@ -30,23 +31,23 @@ export const sources: Source[] = [baseSrcBlockHeaders, baseSrcLogs]
export const integrations: Integration[] = [
{
...sendAccountDeployedIntegration,
// @ts-expect-error start is bigint but we will load it from env
sources: [{ name: baseSrcLogs.name, start: '$BASE_BLOCK_START' }],
},
{
...sendAccountTransfersIntegration,
// @ts-expect-error start is bigint but we will load it from env
sources: [{ name: baseSrcLogs.name, start: '$BASE_BLOCK_START' }],
},
{
...sendTokenTransfersIntegration,
// @ts-expect-error start is bigint but we will load it from env
sources: [{ name: baseSrcLogs.name, start: '$BASE_BLOCK_START' }],
},
{
...sendRevenuesSafeReceives,
sources: [{ name: baseSrcLogs.name, start: '$BASE_BLOCK_START' }],
},
// @todo split this into two integrations, one for Receive and one for UserOperationEvent
// {
// ...sendAccountTransactionsIntegration,
// // @ts-expect-error start is bigint but we will load it from env
// sources: [{ name: baseSrcBlockHeaders.name, start: '$BASE_BLOCK_START' }],
// },
]
Expand Down
1 change: 1 addition & 0 deletions packages/shovel/src/integrations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export { integration as sendAccountDeployedIntegration } from './send-account-de
export { integration as sendAccountTransfersIntegration } from './send-account-transfers'
export { integration as sendAccountTransactionsIntegration } from './send-account-transactions'
export { integration as sendTokenTransfersIntegration } from './send-token-transfers'
export { integration as sendRevenuesSafeReceives } from './send-revenues-safe-receives'
59 changes: 59 additions & 0 deletions packages/shovel/src/integrations/send-revenues-safe-receives.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import type { BlockData, Column, Integration, Table } from '@indexsupply/shovel-config'
import { sendRevenueSafeAddress } from '@my/wagmi'

export const sendRevenuesSafeReceivesTable: Table = {
name: 'send_revenues_safe_receives',
columns: [
{ name: 'chain_id', type: 'numeric' },
{ name: 'log_addr', type: 'bytea' },
{ name: 'block_time', type: 'numeric' },
{ name: 'tx_hash', type: 'bytea' },
{ name: 'sender', type: 'bytea' },
{ name: 'v', type: 'numeric' },
] as Column[],
} as const

export const integration: Omit<Integration, 'sources'> = {
name: 'send_revenues_safe_receives',
enabled: true,
table: sendRevenuesSafeReceivesTable,
block: [
{
name: 'chain_id',
column: 'chain_id',
},
{
name: 'block_time',
column: 'block_time',
},
{
name: 'tx_hash',
column: 'tx_hash',
},
{
name: 'log_addr',
column: 'log_addr',
filter_op: 'contains',
filter_arg: [...new Set(Object.values(sendRevenueSafeAddress))].sort(),
},
] as BlockData[],
event: {
type: 'event',
name: 'SafeReceived',
inputs: [
{
name: 'sender',
internalType: 'address',
type: 'address',
indexed: true,
column: 'sender',
},
{
name: 'value',
type: 'uint256',
indexed: false,
column: 'v',
},
],
},
} as const
81 changes: 81 additions & 0 deletions packages/shovel/test/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,87 @@ exports[`shovel config 1`] = `
"name": "send_token_transfers",
},
},
{
"block": [
{
"column": "chain_id",
"name": "chain_id",
},
{
"column": "block_time",
"name": "block_time",
},
{
"column": "tx_hash",
"name": "tx_hash",
},
{
"column": "log_addr",
"filter_arg": [
"0x269cD0a2afd1BAbdA7A74ab1dC853869a37aa4a7",
"0x71fa02bb11e4b119bEDbeeD2f119F62048245301",
],
"filter_op": "contains",
"name": "log_addr",
},
],
"enabled": true,
"event": {
"inputs": [
{
"column": "sender",
"indexed": true,
"internalType": "address",
"name": "sender",
"type": "address",
},
{
"column": "v",
"indexed": false,
"name": "value",
"type": "uint256",
},
],
"name": "SafeReceived",
"type": "event",
},
"name": "send_revenues_safe_receives",
"sources": [
{
"name": "base_logs",
"start": "$BASE_BLOCK_START",
},
],
"table": {
"columns": [
{
"name": "chain_id",
"type": "numeric",
},
{
"name": "log_addr",
"type": "bytea",
},
{
"name": "block_time",
"type": "numeric",
},
{
"name": "tx_hash",
"type": "bytea",
},
{
"name": "sender",
"type": "bytea",
},
{
"name": "v",
"type": "numeric",
},
],
"name": "send_revenues_safe_receives",
},
},
],
"pg_url": "$DATABASE_URL",
"sources": [
Expand Down
Loading

0 comments on commit 9db843c

Please sign in to comment.