-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add get balances per block, add asynchronous updates
- Loading branch information
1 parent
70e8bf5
commit c2f1df1
Showing
10 changed files
with
151 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/src/app/tools/get-balances-per-block/get-balances-per-block.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<div class="card bg-dark"> | ||
<h5 class="card-header bg-dark">Get Balances from Address per Block</h5> | ||
<div class="card-body"> | ||
<p class="card-text"> | ||
Enter public address below to get the balance (one address) | ||
</p> | ||
<p class="card-text"> | ||
<input type="text" class="form-control" [(ngModel)]="address"><br /> | ||
Delimiter: <br /> | ||
<input type="text" class="form-control" [(ngModel)]="delimiter"><br /> | ||
|
||
Start Block: <br /> | ||
<input type="number" class="form-control" min="1" [(ngModel)]="startBlock"><br /> | ||
End Block: <br /> | ||
<input type="number" class="form-control" min="1" [(ngModel)]="endBlock"><br /> | ||
Iteration: <br /> | ||
<input type="number" class="form-control" min="1" [(ngModel)]="iteration"><br /> | ||
</p> | ||
<p class="card-text"> | ||
<button (click)="getBalances()" class="btn" >Get Balances</button> | ||
</p> | ||
<p class="card-text"> | ||
<textarea class="form-control font-code" rows="12" disabled>{{balances}}</textarea> | ||
</p> | ||
</div> | ||
</div> |
Empty file.
40 changes: 40 additions & 0 deletions
40
src/src/app/tools/get-balances-per-block/get-balances-per-block.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Component, OnInit, ChangeDetectorRef } from '@angular/core'; | ||
import { DataService } from 'src/app/shared/services/data.service'; | ||
import { Web3Service } from 'src/app/shared/services/web3.service'; | ||
|
||
@Component({ | ||
selector: 'w3tk-get-balances-per-block', | ||
templateUrl: './get-balances-per-block.component.html', | ||
styleUrls: ['./get-balances-per-block.component.scss'] | ||
}) | ||
export class GetBalancesPerBlockComponent implements OnInit { | ||
address: string = ""; | ||
delimiter: string = ", "; | ||
startBlock: number = 0; | ||
endBlock: number = 0; | ||
iteration: number = 17280; | ||
balances: string = ""; | ||
|
||
constructor(public dataService: DataService, private changeDetector: ChangeDetectorRef) { } | ||
|
||
ngOnInit(): void { | ||
} | ||
|
||
async getBalances() { | ||
|
||
if(this.endBlock == 0) { | ||
Web3Service.getLastBlockNumber(this.dataService.network).then((result) => { | ||
this.endBlock = result; | ||
}); | ||
} | ||
|
||
this.balances = ""; | ||
for await(const balance of Web3Service.getBalancesPerBlockAsync( | ||
this.address, this.dataService.network.rpcUrl, this.delimiter, | ||
this.startBlock, this.endBlock, this.iteration)) { | ||
this.balances += balance; | ||
this.changeDetector.detectChanges(); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters