Skip to content

Commit

Permalink
Fix unresolve txn conversion error
Browse files Browse the repository at this point in the history
  • Loading branch information
sipec committed Jul 11, 2024
1 parent 626b323 commit 3b887f3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
5 changes: 3 additions & 2 deletions backend/api/src/unresolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { broadcastUpdatedAnswers } from 'shared/websockets/helpers'
import { convertAnswer } from 'common/supabase/contracts'
import { updateContract } from 'shared/supabase/contracts'
import { FieldVal } from 'shared/supabase/utils'
import { convertTxn } from 'common/supabase/txns'

const TXNS_PR_MERGED_ON = 1675693800000 // #PR 1476

Expand Down Expand Up @@ -180,7 +181,7 @@ const undoResolution = async (
and ($2 is null or (data->'data'->>'payoutStartTime')::numeric = $2)
and ($3 is null or data ->'data'->>'answerId' = $3)`,
[contractId, maxSpicePayoutStartTime, answerId],
(r) => r.data as ContractProduceSpiceTxn
(r) => convertTxn(r) as ContractProduceSpiceTxn
)

log('Reverting spice txns ' + spiceTxnsToRevert.length)
Expand Down Expand Up @@ -220,7 +221,7 @@ const undoResolution = async (
and ($2 is null or (data->'data'->>'payoutStartTime')::numeric = $2)
and ($3 is null or data ->'data'->>'answerId' = $3)`,
[contractId, maxSpicePayoutStartTime, answerId],
(r) => r.data as ContractOldResolutionPayoutTxn
(r) => convertTxn(r) as ContractOldResolutionPayoutTxn
)

log('Reverting mana txns ' + manaTxns.length)
Expand Down
5 changes: 3 additions & 2 deletions backend/scripts/reclaim-mana-undo.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { runScript } from './run-script'
import { runTxn } from 'shared/src/txn/run-txn'
import { ReclaimManaTxn } from 'common/src/txn'
import { convertTxn } from 'common/supabase/txns'

if (require.main === module) {
runScript(async ({ pg, firestore }) => {
Expand Down Expand Up @@ -29,12 +30,12 @@ if (require.main === module) {
({ from_id }) => from_id as string
)
const reclaimTxns = await pg.map(
`SELECT data FROM txns
`SELECT * FROM txns
WHERE
from_id IN ($1:list)
AND category = 'RECLAIM_MANA'`,
[usersIdsToUndoReclaim],
(r) => r.data as ReclaimManaTxn
(r) => convertTxn(r) as ReclaimManaTxn
)

for (const reclaimTxn of reclaimTxns) {
Expand Down
7 changes: 0 additions & 7 deletions backend/shared/src/supabase/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@ export async function getIds<T extends TableName>(
return db.map('select id from $1~', [table], (r) => r.id as string)
}

export async function getAll<T extends TableName>(
db: SupabaseDirectClient,
table: T
) {
return db.map('select data from $1~', [table], (r) => r.data as DataFor<T>)
}

export async function insert<
T extends TableName,
ColumnValues extends Tables[T]['Insert']
Expand Down

0 comments on commit 3b887f3

Please sign in to comment.