Browse Source

some rename operations.

Ugochukwu Mmaduekwe 7 years ago
parent
commit
b3e392fd3e

+ 48 - 39
src/core.utils/UCoreUtils.pas

@@ -73,7 +73,8 @@ type
     class function ChangeKeyFinalizeAndDisplayMessage(const AOperationsTxt, AOperationToString: string; ANoOfOperations: integer; APublicKey: TAccountKey; ATotalFee: int64; AOperationsHashTree: TOperationsHashTree; var AErrorMessage: string): boolean; static;
     class function ChangeKeyFinalizeAndDisplayMessage(const AOperationsTxt, AOperationToString: string; ANoOfOperations: integer; APublicKey: TAccountKey; ATotalFee: int64; AOperationsHashTree: TOperationsHashTree; var AErrorMessage: string): boolean; static;
     class function UpdateChangeKeyPayload(const ASenderAccount: TAccount; const APublicKey: TAccountKey; const APayloadEncryptionMode: TExecuteOperationsModel.TPayloadEncryptionMode; const APayloadContent: string; var AEncodedPayloadBytes: TRawBytes; const APayloadEncryptionPassword: string; var AErrorMessage: string): boolean;
     class function UpdateChangeKeyPayload(const ASenderAccount: TAccount; const APublicKey: TAccountKey; const APayloadEncryptionMode: TExecuteOperationsModel.TPayloadEncryptionMode; const APayloadContent: string; var AEncodedPayloadBytes: TRawBytes; const APayloadEncryptionPassword: string; var AErrorMessage: string): boolean;
   public
   public
-    class function GetOperationShortText(const OpType, OpSubType : DWord) : AnsiString; static; inline;
+    class function ExecuteOperations(const ANewOps: TExecuteOperationsModel; AHandler: TExecuteOperationsModel.TOperationExecuteResultHandler; var errors: ansistring): boolean; static;
+    class function GetOperationShortText(const OpType, OpSubType: DWord): ansistring; static; inline;
     class function ExecuteSendPASC(const ASelectedAccounts: TArray<TAccount>; const ADestinationAccount, ASignerAccount: TAccount; AAmount, AFee: int64; const ASendPASCMode: TExecuteOperationsModel.TSendPASCMode; const APayloadEncryptionMode: TExecuteOperationsModel.TPayloadEncryptionMode; const APayloadContent, APayloadEncryptionPassword: string; var AErrorMessage: string): boolean; static;
     class function ExecuteSendPASC(const ASelectedAccounts: TArray<TAccount>; const ADestinationAccount, ASignerAccount: TAccount; AAmount, AFee: int64; const ASendPASCMode: TExecuteOperationsModel.TSendPASCMode; const APayloadEncryptionMode: TExecuteOperationsModel.TPayloadEncryptionMode; const APayloadContent, APayloadEncryptionPassword: string; var AErrorMessage: string): boolean; static;
     class function ExecuteChangeKey(const ASelectedAccounts: TArray<TAccount>; const ASignerAccount: TAccount; APublicKey: TAccountKey; AFee: int64; const APayloadEncryptionMode: TExecuteOperationsModel.TPayloadEncryptionMode; const APayloadContent, APayloadEncryptionPassword: string; var AErrorMessage: string): boolean; static;
     class function ExecuteChangeKey(const ASelectedAccounts: TArray<TAccount>; const ASignerAccount: TAccount; APublicKey: TAccountKey; AFee: int64; const APayloadEncryptionMode: TExecuteOperationsModel.TPayloadEncryptionMode; const APayloadContent, APayloadEncryptionPassword: string; var AErrorMessage: string): boolean; static;
     class procedure ExecuteEnlistAccountForSale(); static;
     class procedure ExecuteEnlistAccountForSale(); static;
@@ -83,20 +84,20 @@ type
 
 
   TOrderedAccountKeysListHelper = class helper for TOrderedAccountKeysList
   TOrderedAccountKeysListHelper = class helper for TOrderedAccountKeysList
   public
   public
-    function GetBalance(IncludePending : boolean = false) : TBalanceSummary;
-    function GetAccounts(IncludePending : boolean = false) : TArray<TAccount>;
-    function GetAccountNumbers : TArray<Cardinal>;
+    function GetBalance(IncludePending: boolean = False): TBalanceSummary;
+    function GetAccounts(IncludePending: boolean = False): TArray<TAccount>;
+    function GetAccountNumbers: TArray<cardinal>;
   end;
   end;
 
 
   { TSafeBoxHelper }
   { TSafeBoxHelper }
 
 
   TSafeBoxHelper = class helper for TPCSafeBox
   TSafeBoxHelper = class helper for TPCSafeBox
   private
   private
-    function GetBalanceInternal(const AKeys: array of TAccountKey; IncludePending : boolean = false): TBalanceSummary;
+    function GetBalanceInternal(const AKeys: array of TAccountKey; IncludePending: boolean = False): TBalanceSummary;
   public
   public
     function GetModifiedAccounts(const AAccounts: array of TAccount): TArray<TAccount>;
     function GetModifiedAccounts(const AAccounts: array of TAccount): TArray<TAccount>;
-    function GetBalance(const AKey: TAccountKey; IncludePending : boolean = false): TBalanceSummary; overload;
-    function GetBalance(const AKeys: array of TAccountKey; IncludePending : boolean = false): TBalanceSummary; overload;
+    function GetBalance(const AKey: TAccountKey; IncludePending: boolean = False): TBalanceSummary; overload;
+    function GetBalance(const AKeys: array of TAccountKey; IncludePending: boolean = False): TBalanceSummary; overload;
   end;
   end;
 
 
   { TNodeHelper }
   { TNodeHelper }
@@ -379,8 +380,15 @@ begin
   end;
   end;
 end;
 end;
 
 
-class function TOperationsManager.GetOperationShortText(const OpType,
-  OpSubType: DWord): AnsiString;
+class function TOperationsManager.ExecuteOperations(
+  const ANewOps: TExecuteOperationsModel;
+  AHandler: TExecuteOperationsModel.TOperationExecuteResultHandler;
+  var errors: ansistring): boolean;
+begin
+
+end;
+
+class function TOperationsManager.GetOperationShortText(const OpType, OpSubType: DWord): ansistring;
 begin
 begin
   Result := TCellRenderers.OperationShortText(OpType, OpSubType);
   Result := TCellRenderers.OperationShortText(OpType, OpSubType);
 end;
 end;
@@ -522,12 +530,7 @@ begin
 
 
 end;
 end;
 
 
-class function TOperationsManager.ExecuteChangeKey(
-  const ASelectedAccounts: TArray<TAccount>; const ASignerAccount: TAccount;
-  APublicKey: TAccountKey; AFee: int64;
-  const APayloadEncryptionMode: TExecuteOperationsModel.TPayloadEncryptionMode;
-  const APayloadContent, APayloadEncryptionPassword: string;
-  var AErrorMessage: string): boolean;
+class function TOperationsManager.ExecuteChangeKey(const ASelectedAccounts: TArray<TAccount>; const ASignerAccount: TAccount; APublicKey: TAccountKey; AFee: int64; const APayloadEncryptionMode: TExecuteOperationsModel.TPayloadEncryptionMode; const APayloadContent, APayloadEncryptionPassword: string; var AErrorMessage: string): boolean;
 var
 var
   LWalletKey: TWalletKey;
   LWalletKey: TWalletKey;
   LWalletKeys: TWalletKeys;
   LWalletKeys: TWalletKeys;
@@ -540,7 +543,8 @@ var
   LIdx, LAccountIdx, LSignerNoOfOperations: integer;
   LIdx, LAccountIdx, LSignerNoOfOperations: integer;
   LCurrentAccount, LSignerAccount: TAccount;
   LCurrentAccount, LSignerAccount: TAccount;
   LPayloadEncodedBytes: TRawBytes;
   LPayloadEncodedBytes: TRawBytes;
-  label loop_start;
+label
+  loop_start;
 begin
 begin
   if Length(ASelectedAccounts) = 0 then
   if Length(ASelectedAccounts) = 0 then
   begin
   begin
@@ -732,50 +736,54 @@ end;
 
 
 { TOrderedAccountKeysListHelper }
 { TOrderedAccountKeysListHelper }
 
 
-function TOrderedAccountKeysListHelper.GetBalance(IncludePending : boolean = false) : TBalanceSummary;
+function TOrderedAccountKeysListHelper.GetBalance(IncludePending: boolean = False): TBalanceSummary;
 var
 var
-  i : Integer;
-  LAccs : TArray<TAccount>;
+  i: integer;
+  LAccs: TArray<TAccount>;
 begin
 begin
   Result := CT_BalanceSummary_Nil;
   Result := CT_BalanceSummary_Nil;
   LAccs := Self.GetAccounts(IncludePending);
   LAccs := Self.GetAccounts(IncludePending);
-  for i := Low(LAccs) to High(LAccs) do begin
+  for i := Low(LAccs) to High(LAccs) do
+  begin
     Inc(Result.TotalPASA);
     Inc(Result.TotalPASA);
     Inc(Result.TotalPASC, LAccs[i].Balance);
     Inc(Result.TotalPASC, LAccs[i].Balance);
   end;
   end;
 end;
 end;
 
 
-function TOrderedAccountKeysListHelper.GetAccounts(IncludePending : boolean = false) : TArray<TAccount>;
+function TOrderedAccountKeysListHelper.GetAccounts(IncludePending: boolean = False): TArray<TAccount>;
 var
 var
-  i, j : integer;
-  LAccs : TList<TAccount>;
-  LAcc : TAccount;
-  LList : TOrderedCardinalList;
-  Disposables : TDisposables;
-begin
-  LAccs := Disposables.AddObject( TList<TAccount>.Create ) as TList<TAccount>;
-  for i := 0 to Self.Count - 1 do begin
+  i, j: integer;
+  LAccs: TList<TAccount>;
+  LAcc: TAccount;
+  LList: TOrderedCardinalList;
+  Disposables: TDisposables;
+begin
+  LAccs := Disposables.AddObject(TList<TAccount>.Create) as TList<TAccount>;
+  for i := 0 to Self.Count - 1 do
+  begin
     LList := Self.AccountKeyList[i];
     LList := Self.AccountKeyList[i];
-    for j := 0 to LList.Count - 1 do begin
+    for j := 0 to LList.Count - 1 do
+    begin
       if IncludePending then
       if IncludePending then
         LAcc := TNode.Node.Operations.SafeBoxTransaction.Account(j)
         LAcc := TNode.Node.Operations.SafeBoxTransaction.Account(j)
       else
       else
-        LAcc :=  TNode.Node.Bank.SafeBox.Account(LList.Get(j));
+        LAcc := TNode.Node.Bank.SafeBox.Account(LList.Get(j));
       LAccs.Add(LAcc);
       LAccs.Add(LAcc);
     end;
     end;
   end;
   end;
   Result := LAccs.ToArray;
   Result := LAccs.ToArray;
 end;
 end;
 
 
-function TOrderedAccountKeysListHelper.GetAccountNumbers : TArray<Cardinal>;
+function TOrderedAccountKeysListHelper.GetAccountNumbers: TArray<cardinal>;
 var
 var
-  i, j : integer;
-  LAccs : TList<Cardinal>;
-  LList : TOrderedCardinalList;
-  Disposables : TDisposables;
+  i, j: integer;
+  LAccs: TList<cardinal>;
+  LList: TOrderedCardinalList;
+  Disposables: TDisposables;
 begin
 begin
-  LAccs := Disposables.AddObject( TList<Cardinal>.Create ) as TList<Cardinal>;
-  for i := 0 to Self.Count - 1 do begin
+  LAccs := Disposables.AddObject(TList<cardinal>.Create) as TList<cardinal>;
+  for i := 0 to Self.Count - 1 do
+  begin
     LList := Self.AccountKeyList[i];
     LList := Self.AccountKeyList[i];
     for j := 0 to LList.Count - 1 do
     for j := 0 to LList.Count - 1 do
       LAccs.Add(j);
       LAccs.Add(j);
@@ -838,7 +846,8 @@ begin
 
 
   // Build the results
   // Build the results
   Result := CT_BalanceSummary_Nil;
   Result := CT_BalanceSummary_Nil;
-  for LAcc in LAccs do begin
+  for LAcc in LAccs do
+  begin
     Inc(Result.TotalPASA);
     Inc(Result.TotalPASA);
     Inc(Result.TotalPASC, LAcc.Balance);
     Inc(Result.TotalPASC, LAcc.Balance);
   end;
   end;

+ 14 - 9
src/core/UDataObjects.pas

@@ -11,12 +11,12 @@ uses Classes, SysUtils, UWizard, UAccounts, UBlockChain, UWallet,
   UBaseTypes, Generics.Defaults;
   UBaseTypes, Generics.Defaults;
 
 
 type
 type
-
   { TWIZAddKeyAction }
   { TWIZAddKeyAction }
 
 
   TWIZAddKeyAction = (akaGenerateKey, akaImportPrivateKey, akaImportPublicKey);
   TWIZAddKeyAction = (akaGenerateKey, akaImportPrivateKey, akaImportPublicKey);
 
 
-  { TFRMAddKeyModel }
+
+  { TWIZAddKeyModel }
 
 
   TWIZAddKeyModel = class(TComponent)
   TWIZAddKeyModel = class(TComponent)
   public
   public
@@ -33,9 +33,9 @@ type
   public
   public
     type
     type
 
 
-    { TModelType }
+    { TExecuteOperationType }
 
 
-    TModelType = (omtAccount, omtSendPasc, omtChangeKey, omtTransferAccount, omtChangeAccountPrivateKey, omtAddKey, omtEnlistAccountForSale);
+    TExecuteOperationType = (omtAccount, omtSendPasc, omtChangeKey, omtTransferAccount, omtChangeAccountPrivateKey, omtAddKey, omtEnlistAccountForSale);
 
 
     { TPayloadEncryptionMode }
     { TPayloadEncryptionMode }
 
 
@@ -56,6 +56,11 @@ type
     { TAccountSaleMode }
     { TAccountSaleMode }
     TAccountSaleMode = (akaPublicSale, akaPrivateSale);
     TAccountSaleMode = (akaPublicSale, akaPrivateSale);
 
 
+    { TOperationExecuteResultHandler }
+
+    TOperationExecuteResultHandler =
+    procedure(const ASourceAccount: TAccount; AOpType: TExecuteOperationType; const AOpText: ansistring; Result: boolean; const Message: ansistring) of object;
+
 
 
     { TAccountModel }
     { TAccountModel }
 
 
@@ -133,7 +138,7 @@ type
     end;
     end;
 
 
   private
   private
-    FModelType: TModelType;
+    FExecuteOperationType: TExecuteOperationType;
     FAccount: TAccountModel;
     FAccount: TAccountModel;
     FSendPASC: TSendPASCModel;
     FSendPASC: TSendPASCModel;
     FChangeKey: TChangeKeyModel;
     FChangeKey: TChangeKeyModel;
@@ -144,8 +149,8 @@ type
     FSigner: TSignerModel;
     FSigner: TSignerModel;
     FPayload: TPayloadModel;
     FPayload: TPayloadModel;
   public
   public
-    constructor Create(AOwner: TComponent; AType: TModelType); overload;
-    property ModelType: TModelType read FModelType;
+    constructor Create(AOwner: TComponent; AType: TExecuteOperationType); overload;
+    property ExecuteOperationType: TExecuteOperationType read FExecuteOperationType;
     property Account: TAccountModel read FAccount;
     property Account: TAccountModel read FAccount;
     property SendPASC: TSendPASCModel read FSendPASC;
     property SendPASC: TSendPASCModel read FSendPASC;
     property ChangeKey: TChangeKeyModel read FChangeKey;
     property ChangeKey: TChangeKeyModel read FChangeKey;
@@ -159,10 +164,10 @@ type
 
 
 implementation
 implementation
 
 
-constructor TExecuteOperationsModel.Create(AOwner: TComponent; AType: TExecuteOperationsModel.TModelType);
+constructor TExecuteOperationsModel.Create(AOwner: TComponent; AType: TExecuteOperationsModel.TExecuteOperationType);
 begin
 begin
   inherited Create(AOwner);
   inherited Create(AOwner);
-  FModelType := AType;
+  FExecuteOperationType := AType;
   FAccount := TAccountModel.Create(Self);
   FAccount := TAccountModel.Create(Self);
   FSendPASC := TSendPASCModel.Create(Self);
   FSendPASC := TSendPASCModel.Create(Self);
   FChangeKey := TChangeKeyModel.Create(Self);
   FChangeKey := TChangeKeyModel.Create(Self);

+ 3 - 3
src/gui/wizards/operations/UWIZOperationConfirmation.pas

@@ -125,7 +125,7 @@ begin
   FConfirmationGrid.DataSource := Data;
   FConfirmationGrid.DataSource := Data;
   paGrid.AddControlDockCenter(FConfirmationGrid);
   paGrid.AddControlDockCenter(FConfirmationGrid);
   lblSgnAcc.Caption := TAccountComp.AccountNumberToAccountTxtNumber(Model.Signer.SignerAccount.account);
   lblSgnAcc.Caption := TAccountComp.AccountNumberToAccountTxtNumber(Model.Signer.SignerAccount.account);
-  if not (Model.ModelType = omtEnlistAccountForSale) then
+  if not (Model.ExecuteOperationType = omtEnlistAccountForSale) then
   begin
   begin
     lblBeneficiaryAccount.Visible := False;
     lblBeneficiaryAccount.Visible := False;
     lblBenAcc.Visible := False;
     lblBenAcc.Visible := False;
@@ -186,7 +186,7 @@ begin
   end;
   end;
 
 
   if ABindingName = 'Operation' then
   if ABindingName = 'Operation' then
-    case Model.ModelType of
+    case Model.ExecuteOperationType of
       omtSendPasc:
       omtSendPasc:
       begin
       begin
         Result := IIF(Model.SendPASC.SendPASCMode = akaAllBalance, 'All Balance', Format('%s ', [TAccountComp.FormatMoney(Model.SendPASC.SingleAmountToSend)]));
         Result := IIF(Model.SendPASC.SendPASCMode = akaAllBalance, 'All Balance', Format('%s ', [TAccountComp.FormatMoney(Model.SendPASC.SingleAmountToSend)]));
@@ -199,7 +199,7 @@ begin
 
 
     end
     end
   else if ABindingName = 'Recipient' then
   else if ABindingName = 'Recipient' then
-    case Model.ModelType of
+    case Model.ExecuteOperationType of
       omtSendPasc:
       omtSendPasc:
         Result := Model.SendPASC.DestinationAccount.AccountString;
         Result := Model.SendPASC.DestinationAccount.AccountString;
       omtChangeKey:
       omtChangeKey:

+ 1 - 1
src/gui/wizards/operations/UWIZOperationSelected.pas

@@ -115,7 +115,7 @@ var
 begin
 begin
   Result := True;
   Result := True;
 
 
-  if Model.ModelType = omtEnlistAccountForSale then
+  if Model.ExecuteOperationType = omtEnlistAccountForSale then
     for i := Low(model.Account.SelectedAccounts) to High(model.Account.SelectedAccounts) do
     for i := Low(model.Account.SelectedAccounts) to High(model.Account.SelectedAccounts) do
       if TAccountComp.IsAccountForSale(model.Account.SelectedAccounts[i].accountInfo) then
       if TAccountComp.IsAccountForSale(model.Account.SelectedAccounts[i].accountInfo) then
       begin
       begin