Skip to content

Commit

Permalink
supabase: sendtag checkout updates
Browse files Browse the repository at this point in the history
- confirm_tags to use transfers to sendtag checkout contract
- update tag receipt activity
- updates tests
  • Loading branch information
0xBigBoss committed Jul 21, 2024
1 parent 3c273a8 commit 2a9727b
Show file tree
Hide file tree
Showing 20 changed files with 888 additions and 187 deletions.
48 changes: 48 additions & 0 deletions .snaplet/snaplet-client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,37 @@ type Override = {
event_id?: string;
};
}
sendtag_checkout_contracts?: {
name?: string;
fields?: {
id?: string;
address?: string;
chain_id?: string;
created_at?: string;
updated_at?: string;
};
}
sendtag_checkout_receipts?: {
name?: string;
fields?: {
id?: string;
event_id?: string;
chain_id?: string;
log_addr?: string;
block_time?: string;
tx_hash?: string;
sender?: string;
amount?: string;
referrer?: string;
reward?: string;
ig_name?: string;
src_name?: string;
block_num?: string;
tx_idx?: string;
log_idx?: string;
abi_idx?: string;
};
}
tag_receipts?: {
name?: string;
fields?: {
Expand Down Expand Up @@ -715,6 +746,23 @@ export interface Fingerprint {
logIdx?: FingerprintNumberField;
abiIdx?: FingerprintNumberField;
}
sendtagCheckoutContracts?: {
id?: FingerprintNumberField;
chainId?: FingerprintNumberField;
createdAt?: FingerprintDateField;
updatedAt?: FingerprintDateField;
}
sendtagCheckoutReceipts?: {
id?: FingerprintNumberField;
chainId?: FingerprintNumberField;
blockTime?: FingerprintNumberField;
amount?: FingerprintNumberField;
reward?: FingerprintNumberField;
blockNum?: FingerprintNumberField;
txIdx?: FingerprintNumberField;
logIdx?: FingerprintNumberField;
abiIdx?: FingerprintNumberField;
}
tagReceipts?: {
id?: FingerprintNumberField;
createdAt?: FingerprintDateField;
Expand Down
26 changes: 26 additions & 0 deletions .snaplet/snaplet.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,30 @@ interface Table_public_send_token_transfers {
log_idx: number;
abi_idx: number;
}
interface Table_public_sendtag_checkout_contracts {
id: number;
address: string;
chain_id: number;
created_at: string | null;
updated_at: string | null;
}
interface Table_public_sendtag_checkout_receipts {
id: number;
chain_id: number;
log_addr: string;
block_time: number;
tx_hash: string;
sender: string;
amount: number;
referrer: string;
reward: number;
ig_name: string;
src_name: string;
block_num: number;
tx_idx: number;
log_idx: number;
abi_idx: number;
}
interface Table_auth_sessions {
id: string;
user_id: string;
Expand Down Expand Up @@ -619,6 +643,8 @@ interface Schema_public {
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;
sendtag_checkout_contracts: Table_public_sendtag_checkout_contracts;
sendtag_checkout_receipts: Table_public_sendtag_checkout_receipts;
tag_receipts: Table_public_tag_receipts;
tag_reservations: Table_public_tag_reservations;
tags: Table_public_tags;
Expand Down
24 changes: 23 additions & 1 deletion packages/contracts/script/anvil-add-send-merkle-drop-fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
import 'zx/globals'
import { supabaseAdmin } from 'app/utils/supabase/admin'
import type { Database } from '@my/supabase/database.types'
import { createClient } from '@supabase/supabase-js'

if (!process.env.NEXT_PUBLIC_SUPABASE_URL) {
throw new Error(
'NEXT_PUBLIC_SUPABASE_URL is not set. Please update the root .env.local and restart the server.'
)
}
if (!process.env.SUPABASE_SERVICE_ROLE) {
throw new Error(
'SUPABASE_SERVICE_ROLE is not set. Please update the root .env.local and restart the server.'
)
}

const SUPABASE_URL = process.env.NEXT_PUBLIC_SUPABASE_URL
const SUPABASE_SERVICE_ROLE = process.env.SUPABASE_SERVICE_ROLE

/**
* only meant to be used on the server side.
*/
const supabaseAdmin = createClient<Database>(SUPABASE_URL, SUPABASE_SERVICE_ROLE, {
auth: { persistSession: false },
})

$.verbose = true

Expand Down
48 changes: 46 additions & 2 deletions packages/contracts/script/anvil-add-sendtag-checkout-fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
import 'zx/globals'
import type { Database } from '@my/supabase/database.types'
import { createClient } from '@supabase/supabase-js'

if (!process.env.NEXT_PUBLIC_SUPABASE_URL) {
throw new Error(
'NEXT_PUBLIC_SUPABASE_URL is not set. Please update the root .env.local and restart the server.'
)
}
if (!process.env.SUPABASE_SERVICE_ROLE) {
throw new Error(
'SUPABASE_SERVICE_ROLE is not set. Please update the root .env.local and restart the server.'
)
}

const SUPABASE_URL = process.env.NEXT_PUBLIC_SUPABASE_URL
const SUPABASE_SERVICE_ROLE = process.env.SUPABASE_SERVICE_ROLE

/**
* only meant to be used on the server side.
*/
const supabaseAdmin = createClient<Database>(SUPABASE_URL, SUPABASE_SERVICE_ROLE, {
auth: { persistSession: false },
})

$.verbose = true

/**
Expand All @@ -19,12 +43,32 @@ MULTISIG=${$.env.MULTISIG}\t\thttps://basescan.org/address/${$.env.MULTISIG}
TOKEN=${$.env.TOKEN}\t\thttps://basescan.org/address/${$.env.TOKEN}
`
)
await $`forge script ./script/DeploySendtagCheckout.s.sol:DeploySendtagCheckoutScript \
const contractAddress: string | undefined = await $`forge script ./script/DeploySendtagCheckout.s.sol:DeploySendtagCheckoutScript \
-vvvv \
--rpc-url ${RPC_URL} \
--sender 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 \
--private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 \
--broadcast`
--broadcast`.then(
({ stdout }) => stdout.match(/contract SendtagCheckout (0x[a-fA-F0-9]{40})/)?.[1]
)

if (!contractAddress) {
console.error(chalk.red('Failed to deploy SendtagCheckout contract'))
process.exit(1)
}

console.log(chalk.blue(`SendtagCheckout contract deployed to ${contractAddress}`))
// add sendtag checkout contract to supabase
const { error } = await supabaseAdmin.from('sendtag_checkout_contracts').insert({
address: contractAddress.replace('0x', '\\x'),
chain_id: 845337,
})

if (error) {
console.error(chalk.red('Failed to add SendtagCheckout contract to supabase'))
console.error(error)
process.exit(1)
}

console.log(chalk.blue('Disable auto-mining...'))
await $`cast rpc --rpc-url ${RPC_URL} evm_setAutomine false`
Expand Down
104 changes: 104 additions & 0 deletions packages/shovel/etc/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,110 @@
"start": "$BASE_BLOCK_START"
}
]
},
{
"name": "sendtag_checkout_receipts",
"enabled": true,
"table": {
"name": "sendtag_checkout_receipts",
"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": "amount",
"type": "numeric"
},
{
"name": "referrer",
"type": "bytea"
},
{
"name": "reward",
"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": [
"0x3936f906910C0f74b6d1536614068368B94CDa85"
]
}
],
"event": {
"type": "event",
"anonymous": false,
"inputs": [
{
"name": "sender",
"column": "sender",
"internalType": "address",
"type": "address",
"indexed": true
},
{
"name": "amount",
"column": "amount",
"internalType": "uint256",
"type": "uint256",
"indexed": false
},
{
"name": "referrer",
"column": "referrer",
"internalType": "address",
"type": "address",
"indexed": false
},
{
"name": "reward",
"column": "reward",
"internalType": "uint256",
"type": "uint256",
"indexed": false
}
],
"name": "Receipt"
},
"sources": [
{
"name": "base_logs",
"start": "$BASE_BLOCK_START"
}
]
}
]
}
5 changes: 5 additions & 0 deletions packages/shovel/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
sendRevenuesSafeReceives,
sendAccountSigningKeyAdded,
sendAccountSigningKeyRemoved,
sendtagCheckoutReceiptsIntegration,
} from './integrations'

// baseSrcBlockHeaders is to be used for integrations that require block headers
Expand Down Expand Up @@ -61,6 +62,10 @@ export const integrations: Integration[] = [
...sendAccountReceivesIntegration,
sources: [{ name: baseSrcLogs.name, start: '$BASE_BLOCK_START' }],
},
{
...sendtagCheckoutReceiptsIntegration,
sources: [{ name: baseSrcLogs.name, start: '$BASE_BLOCK_START' }],
},
]

const c = makeConfig({
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 @@ -5,3 +5,4 @@ export { integration as sendRevenuesSafeReceives } from './send-revenues-safe-re
export { integration as sendAccountSigningKeyAdded } from './send-account-signing-key-added'
export { integration as sendAccountSigningKeyRemoved } from './send-account-signing-key-removed'
export { integration as sendAccountReceivesIntegration } from './send-account-receives'
export { integration as sendtagCheckoutReceiptsIntegration } from './sendtag-checkout-receipts'
Loading

0 comments on commit 2a9727b

Please sign in to comment.