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 server/contract/paypoint.tz
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ parameter string ;
{ parameter (string %pay);
storage address ;
code { CDR ;
AMOUNT ;
Expand Down
20 changes: 20 additions & 0 deletions server/contract/paypoint_fixed.tz
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{ parameter (string %pay);
storage address ;
code { CDR ;
AMOUNT ;
SWAP ;
DUP ;
DUG 2 ;
PUSH string "ERROR: invalid payee address" ;
SWAP ;
CONTRACT unit ;
IF_NONE { FAILWITH } { SWAP ; DROP } ;
SWAP ;
UNIT ;
TRANSFER_TOKENS ;
SWAP ;
NIL operation ;
DIG 2 ;
CONS ;
PAIR } }

26 changes: 25 additions & 1 deletion server/data_access.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,31 @@ const CANCEL_PAYMENT_SQL = "UPDATE tezpay.payments SET is_cancelled = TRUE WHERE
const GET_PAYMENT_SQL = "SELECT * FROM tezpay.payments WHERE external_id = $1";

export default function({db, paypoint_schema_name}) {
let GET_FULFILLMENTS_SQL = `SELECT tx_contexts.level, txs.operation_hash, txs.amount, entries.string as message FROM ${paypoint_schema_name}."entry.default" as entries INNER JOIN que_pasa.tx_contexts as tx_contexts ON tx_contexts.id = entries.tx_context_id INNER JOIN que_pasa.txs as txs ON txs.tx_context_id = entries.tx_context_id WHERE entries.string = $1 AND tx_contexts.level < (SELECT max(level) FROM que_pasa.levels) - $2`;
let GET_FULFILLMENTS_SQL = `
SELECT
tx_contexts.level,
txs.operation_hash,
txs.amount,
entries.msg as message
FROM (
SELECT
tx_context_id,
string AS msg
FROM ${paypoint_schema_name}."entry.pay"

UNION ALL

SELECT
tx_context_id,
pay AS msg
FROM ${paypoint_schema_name}."entry.default"
) AS entries
INNER JOIN que_pasa.tx_contexts AS tx_contexts
ON tx_contexts.id = entries.tx_context_id
INNER JOIN que_pasa.txs AS txs
ON txs.tx_context_id = entries.tx_context_id
WHERE entries.msg = $1
AND tx_contexts.level < (SELECT max(level) FROM que_pasa.levels) - $2`;

const get_paypoint_address = async function() {
let result = await db.query(GET_CONTRACT_ADDRESS, [paypoint_schema_name]);
Expand Down