Skip to content

Commit

Permalink
Update new relations on delegate activation
Browse files Browse the repository at this point in the history
  • Loading branch information
Groxan committed Aug 1, 2022
1 parent 3a2fdcb commit a4ad4ec
Showing 1 changed file with 169 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -497,12 +497,19 @@ void UpgradeUser(DelegationOperation delegation)
if (op.Sender?.Id == user.Id)
op.Sender = delegat;

if (op.Manager?.Id == user.Id)
op.Manager = delegat;

if (op.Initiator?.Id == user.Id)
op.Initiator = delegat;

if (op.Manager?.Id == user.Id)
op.Manager = delegat;

touched.Add((op, entry.State));
}
break;
case RegisterConstantOperation op:
if (op.Sender?.Id == user.Id)
{
op.Sender = delegat;
touched.Add((op, entry.State));
}
break;
Expand All @@ -513,18 +520,88 @@ void UpgradeUser(DelegationOperation delegation)
touched.Add((op, entry.State));
}
break;
case SetDepositsLimitOperation op:
if (op.Sender?.Id == user.Id)
{
op.Sender = delegat;
touched.Add((op, entry.State));
}
break;
case TransactionOperation op:
if (op.Sender?.Id == user.Id || op.Target?.Id == user.Id || op.Initiator?.Id == user.Id)
{
if (op.Sender?.Id == user.Id)
op.Sender = delegat;

if (op.Target?.Id == user.Id)
op.Target = delegat;

if (op.Initiator?.Id == user.Id)
op.Initiator = delegat;

if (op.Target?.Id == user.Id)
op.Target = delegat;

touched.Add((op, entry.State));
}
break;
case TransferTicketOperation op:
if (op.Sender?.Id == user.Id)
{
op.Sender = delegat;
touched.Add((op, entry.State));
}
break;
case TxRollupCommitOperation op:
if (op.Sender?.Id == user.Id)
{
op.Sender = delegat;
touched.Add((op, entry.State));
}
break;
case TxRollupDispatchTicketsOperation op:
if (op.Sender?.Id == user.Id)
{
op.Sender = delegat;
touched.Add((op, entry.State));
}
break;
case TxRollupFinalizeCommitmentOperation op:
if (op.Sender?.Id == user.Id)
{
op.Sender = delegat;
touched.Add((op, entry.State));
}
break;
case TxRollupOriginationOperation op:
if (op.Sender?.Id == user.Id)
{
op.Sender = delegat;
touched.Add((op, entry.State));
}
break;
case TxRollupRejectionOperation op:
if (op.Sender?.Id == user.Id)
{
op.Sender = delegat;
touched.Add((op, entry.State));
}
break;
case TxRollupRemoveCommitmentOperation op:
if (op.Sender?.Id == user.Id)
{
op.Sender = delegat;
touched.Add((op, entry.State));
}
break;
case TxRollupReturnBondOperation op:
if (op.Sender?.Id == user.Id)
{
op.Sender = delegat;
touched.Add((op, entry.State));
}
break;
case TxRollupSubmitBatchOperation op:
if (op.Sender?.Id == user.Id)
{
op.Sender = delegat;
touched.Add((op, entry.State));
}
break;
Expand Down Expand Up @@ -623,12 +700,12 @@ void DowngradeDelegate(DelegationOperation delegation)
if (op.Sender?.Id == delegat.Id)
op.Sender = user;

if (op.Delegate?.Id == delegat.Id)
op.Delegate = null;

if (op.Initiator?.Id == delegat.Id)
op.Initiator = user;

if (op.Delegate?.Id == delegat.Id)
op.Delegate = null;

if (op.PrevDelegate?.Id == delegat.Id)
op.PrevDelegate = null;

Expand All @@ -641,15 +718,22 @@ void DowngradeDelegate(DelegationOperation delegation)
if (op.Sender?.Id == delegat.Id)
op.Sender = user;

if (op.Initiator?.Id == delegat.Id)
op.Initiator = user;

if (op.Manager?.Id == delegat.Id)
op.Manager = user;

if (op.Delegate?.Id == delegat.Id)
op.Delegate = null;

if (op.Initiator?.Id == delegat.Id)
op.Initiator = user;

touched.Add((op, entry.State));
}
break;
case RegisterConstantOperation op:
if (op.Sender?.Id == delegat.Id)
{
op.Sender = user;
touched.Add((op, entry.State));
}
break;
Expand All @@ -660,18 +744,88 @@ void DowngradeDelegate(DelegationOperation delegation)
touched.Add((op, entry.State));
}
break;
case SetDepositsLimitOperation op:
if (op.Sender?.Id == delegat.Id)
{
op.Sender = user;
touched.Add((op, entry.State));
}
break;
case TransactionOperation op:
if (op.Sender?.Id == delegat.Id || op.Target?.Id == delegat.Id || op.Initiator?.Id == delegat.Id)
{
if (op.Sender?.Id == delegat.Id)
op.Sender = user;

if (op.Target?.Id == delegat.Id)
op.Target = user;

if (op.Initiator?.Id == delegat.Id)
op.Initiator = user;

if (op.Target?.Id == delegat.Id)
op.Target = user;

touched.Add((op, entry.State));
}
break;
case TransferTicketOperation op:
if (op.Sender?.Id == delegat.Id)
{
op.Sender = user;
touched.Add((op, entry.State));
}
break;
case TxRollupCommitOperation op:
if (op.Sender?.Id == delegat.Id)
{
op.Sender = user;
touched.Add((op, entry.State));
}
break;
case TxRollupDispatchTicketsOperation op:
if (op.Sender?.Id == delegat.Id)
{
op.Sender = user;
touched.Add((op, entry.State));
}
break;
case TxRollupFinalizeCommitmentOperation op:
if (op.Sender?.Id == delegat.Id)
{
op.Sender = user;
touched.Add((op, entry.State));
}
break;
case TxRollupOriginationOperation op:
if (op.Sender?.Id == delegat.Id)
{
op.Sender = user;
touched.Add((op, entry.State));
}
break;
case TxRollupRejectionOperation op:
if (op.Sender?.Id == delegat.Id)
{
op.Sender = user;
touched.Add((op, entry.State));
}
break;
case TxRollupRemoveCommitmentOperation op:
if (op.Sender?.Id == delegat.Id)
{
op.Sender = user;
touched.Add((op, entry.State));
}
break;
case TxRollupReturnBondOperation op:
if (op.Sender?.Id == delegat.Id)
{
op.Sender = user;
touched.Add((op, entry.State));
}
break;
case TxRollupSubmitBatchOperation op:
if (op.Sender?.Id == delegat.Id)
{
op.Sender = user;
touched.Add((op, entry.State));
}
break;
Expand Down

0 comments on commit a4ad4ec

Please sign in to comment.