Skip to content
Merged
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
18 changes: 18 additions & 0 deletions internal/migrations/024-attestation-actions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,24 @@ $max_fee INT8
if $action_id = 0 {
ERROR('Action not allowed for attestation: ' || $action_name);
}

-- ===== FEE COLLECTION =====
-- Collect 40 TRUF flat fee for attestation request
$attestation_fee := '40000000000000000000'::NUMERIC(78, 0); -- 40 TRUF with 18 decimals
$caller_balance := ethereum_bridge.balance(@caller);

IF $caller_balance < $attestation_fee {
ERROR('Insufficient balance for attestation. Required: 40 TRUF');
}

-- Verify leader address is available
IF @leader_sender IS NULL {
ERROR('Leader address not available for fee transfer');
}

$leader_addr TEXT := encode(@leader_sender, 'hex')::TEXT;
ethereum_bridge.transfer($leader_addr, $attestation_fee);
-- ===== END FEE COLLECTION =====
Comment thread
MicBun marked this conversation as resolved.

-- Get current block height
$created_height := @height;
Expand Down
11 changes: 7 additions & 4 deletions tests/streams/attestation/attestation_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/stretchr/testify/require"

"github.com/trufnetwork/kwil-db/common"
"github.com/trufnetwork/kwil-db/core/crypto/auth"
"github.com/trufnetwork/kwil-db/core/types"
kwilTesting "github.com/trufnetwork/kwil-db/testing"
attestation "github.com/trufnetwork/node/extensions/tn_attestation"
Expand Down Expand Up @@ -144,11 +145,13 @@ func runAttestationUnauthorizedBlocked(t *testing.T, ctx context.Context, platfo
TxContext: &common.TxContext{
Ctx: ctx,
BlockContext: &common.BlockContext{
Height: 1,
Height: 1,
Proposer: helper.leaderPub, // Required for @leader_sender
},
Signer: unauthorizedAddr.Bytes(),
Caller: unauthorizedAddr.Address(),
TxID: platform.Txid(),
Signer: unauthorizedAddr.Bytes(),
Caller: unauthorizedAddr.Address(),
TxID: platform.Txid(),
Authenticator: auth.EthPersonalSignAuth, // Required for balance operations
},
}

Expand Down
Loading
Loading