Skip to content

Commit

Permalink
added elided tx support
Browse files Browse the repository at this point in the history
  • Loading branch information
deemru committed Aug 13, 2024
1 parent 0e76f2f commit e660366
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 6 deletions.
65 changes: 65 additions & 0 deletions include/BlockchainParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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( [
Expand Down Expand Up @@ -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'] );
}
Expand Down
1 change: 1 addition & 0 deletions include/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 12 additions & 6 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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];
Expand All @@ -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
Expand Down

0 comments on commit e660366

Please sign in to comment.