From e6603668bc918ad4e328d6c268aa8ad4c3357ee8 Mon Sep 17 00:00:00 2001 From: Dmitrii Pichulin Date: Wed, 14 Aug 2024 01:58:14 +0300 Subject: [PATCH] added elided tx support --- include/BlockchainParser.php | 65 ++++++++++++++++++++++++++++++++++++ include/common.php | 1 + index.php | 18 ++++++---- 3 files changed, 78 insertions(+), 6 deletions(-) diff --git a/include/BlockchainParser.php b/include/BlockchainParser.php index d6357dc..455ec62 100644 --- a/include/BlockchainParser.php +++ b/include/BlockchainParser.php @@ -533,6 +533,69 @@ private function processFailedTransaction( $txkey, $tx ) } } + private function processElidedTransaction( $txkey, $tx ) + { + switch( $tx['type'] ) + { + case TX_INVOKE: + $this->appendTS( [ + UID => $this->getNewUid(), + TXKEY => $txkey, + TYPE => TX_INVOKE, + A => $this->getSenderId( $tx['sender'] ), + B => $this->getRecipientId( $tx['dApp'] ), + ASSET => NO_ASSET, + AMOUNT => 0, + FEEASSET => NO_ASSET, + FEE => 0, + ADDON => 0, + GROUP => ELIDED_GROUP, + ] ); + break; + case TX_ETHEREUM: + $payload = $tx['payload']; + switch( $payload['type'] ) + { + case 'invocation': + $this->appendTS( [ + UID => $this->getNewUid(), + TXKEY => $txkey, + TYPE => TX_ETHEREUM, + A => $this->getSenderId( $tx['sender'] ), + B => $this->getRecipientId( $payload['dApp'] ), + ASSET => NO_ASSET, + AMOUNT => 0, + FEEASSET => NO_ASSET, + FEE => 0, + ADDON => 0, + GROUP => ELIDED_GROUP, + ] ); + break; + + default: + w8_err( 'unknown failed payload type: ' . $payload['type'] ); + } + break; + case TX_EXCHANGE: + $this->appendTS( [ + UID => $this->getNewUid(), + TXKEY => $txkey, + TYPE => TX_MATCHER, + A => MATCHER, + B => $this->getRecipientId( $tx['sender'] ), + ASSET => NO_ASSET, + AMOUNT => 0, + FEEASSET => NO_ASSET, + FEE => 0, + ADDON => 0, + GROUP => ELIDED_GROUP, + ] ); + break; + default: + w8_err( 'processElidedTransaction unknown type: ' . $tx['type'] ); + } + } + private function processGenesisTransaction( $txkey, $tx ) { $this->appendTS( [ @@ -1412,6 +1475,8 @@ public function processTransaction( $txkey, $tx ) break; case 'script_execution_failed': return $this->processFailedTransaction( $txkey, $tx ); + case 'elided': + return $this->processElidedTransaction( $txkey, $tx ); default: w8_err( 'applicationStatus unknown: ' . $tx['applicationStatus'] ); } diff --git a/include/common.php b/include/common.php index d3c6166..cce0fe8 100644 --- a/include/common.php +++ b/include/common.php @@ -99,6 +99,7 @@ const SPONSOR_ASSET = -3; const FAILED_GROUP = -1; +const ELIDED_GROUP = -3; const ETHEREUM_TRANSFER_GROUP = -2; const EXPRESSION_FUNCTION = -1; diff --git a/index.php b/index.php index fbfaf9e..09238a0 100644 --- a/index.php +++ b/index.php @@ -642,9 +642,6 @@ function GetHeight_LeaseReset(){ return 0; } } } - if( $type == TX_ISSUE ) - $type = 3; - $a = $isa ? $address : $RO->getAddressById( $a ); $b = $isb ? $address : $RO->getAddressById( $b ); @@ -746,6 +743,8 @@ function GetHeight_LeaseReset(){ return 0; } { if( $groupId === FAILED_GROUP ) $addon = '(failed)'; + else if( $groupId === ELIDED_GROUP ) + $addon = '(elided)'; else if( $groupId === ETHEREUM_TRANSFER_GROUP ) $addon = '(transfer)'; else @@ -1604,14 +1603,18 @@ function w8io_tv_string( $t, $v ) { if( is_numeric( $arg ) ) { - if( $arg === '-1' ) + $arg = (int)$arg; + if( $arg === FAILED_GROUP ) $arg = 'failed'; else - if( $arg === '-2' ) + if( $arg === ELIDED_GROUP ) + $arg = 'elided'; + else + if( $arg === ETHEREUM_TRANSFER_GROUP ) $arg = 'ethereum_transfer'; else { - $arg = $RO->getGroupById( (int)$arg ); + $arg = $RO->getGroupById( $arg ); if( $arg === false ) exit( 'unknown group' ); $first = $arg[0]; @@ -1638,6 +1641,9 @@ function w8io_tv_string( $t, $v ) if( $arg === 'failed' ) $arg = FAILED_GROUP; else + if( $arg === 'elided' ) + $arg = ELIDED_GROUP; + else if( $arg === 'ethereum_transfer' ) $arg = ETHEREUM_TRANSFER_GROUP; else