<commit_before><?php

class WebhookController extends BaseController {

    public function webhookCalled($wallet_identity)
    {
        //get the raw POST data
        $request = Request::instance();
        $input = $request->getContent();
        $payload = json_decode($input, true);

        if ($transaction = Transaction::find('tx_hash', $payload['data']['hash'])) {
            //update existing transaction confirmation count
            $transaction->confirmations = $payload['data']['confirmations'];
            $transaction->save();
        } else {
            //get the wallet
            $wallet = Wallet::where('identity', $wallet_identity)->first();

            //workout the amount sent/received by the address
            //...
            $amount = -100;

            //determine the direction of the transaction (receive or send)
            //...
            $direction = 'receive';
            $data = array(
                'tx_hash' => $payload['data']['hash'],
                'address' => '',    //$payload['data']['address'],    //not yet implemented in the webhook api
                'recipient' => null,                    //only used when sending transaction from this app
                'direction' => $direction,
                'amount' => $amount,
                'confirmations' => $payload['data']['confirmations'],
                'wallet_id' => $wallet->id,
            );
            $newTransaction = Transaction::create($data);
            return $newTransaction;
        }
    }

}
<commit_msg>store transaction data<commit_after><?php

class WebhookController extends BaseController {

    public function webhookCalled($wallet_identity)
    {
        //get the raw POST data
        $request = Request::instance();
        $input = $request->getContent();
        $payload = json_decode($input, true);

        if ($transaction = Transaction::where('tx_hash', $payload['data']['hash'])->first()) {
            //update existing transaction confirmation count
            $transaction->confirmations = $payload['data']['confirmations'];
            $transaction->save();
        } else {
            //get the wallet
            $wallet = Wallet::where('identity', $wallet_identity)->first();

            //workout the amount sent/received by the address
            //...
            $amount = -100;

            //determine the direction of the transaction (receive or send)
            //...
            $direction = 'receive';
            $data = array(
                'tx_hash' => $payload['data']['hash'],
                'address' => 'none',    //$payload['data']['address'],    //not yet implemented in the webhook api
                'recipient' => null,                    //only used when sending transaction from this app
                'direction' => $direction,
                'amount' => $amount,
                'confirmations' => $payload['data']['confirmations'],
                'wallet_id' => $wallet->id,
            );

            $transaction = Transaction::create($data);
        }
        return $transaction;
    }

}

{'fraction_non_alphanumeric': 0.1407359586830213, 'fraction_numerical': 0.001936733376371853, 'mean_word_length': 1.83013698630137, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '958411', 'n_tokens_mistral': 755, 'n_tokens_neox': 729, 'n_words': 191}