Refactor out method to get account from private key
This commit is contained in:
parent
ea3dbc004c
commit
b8c31df54f
@ -499,16 +499,15 @@ export class Registry {
|
||||
);
|
||||
}
|
||||
|
||||
async getAddress(): Promise<any> {
|
||||
async getAccount(): Promise<Account> {
|
||||
const account = new Account(Buffer.from(this.registryConfig.privateKey, 'hex'));
|
||||
await account.init();
|
||||
|
||||
return account.address;
|
||||
return account;
|
||||
}
|
||||
|
||||
async getTxResponse(txHash: string): Promise<IndexedTx | null> {
|
||||
const account = new Account(Buffer.from(this.registryConfig.privateKey, 'hex'));
|
||||
await account.init();
|
||||
const account = await this.getAccount();
|
||||
const laconicClient = await this.registry.getLaconicClient(account);
|
||||
const txResponse: IndexedTx | null = await laconicClient.getTx(txHash);
|
||||
|
||||
|
@ -213,7 +213,7 @@ export class Service {
|
||||
const fundsReleased = await this.releaseDeployerFundsByProjectId(deployment.projectId);
|
||||
|
||||
// Return remaining amount to owner
|
||||
await this.returnCreatorFundsByProjectId(deployment.projectId, true);
|
||||
await this.returnUserFundsByProjectId(deployment.projectId, true);
|
||||
|
||||
await this.db.updateProjectById(deployment.projectId, {
|
||||
fundsReleased,
|
||||
@ -314,7 +314,7 @@ export class Service {
|
||||
log(`No winning deployer for auction ${project!.auctionId}`);
|
||||
|
||||
// Return all funds to the owner
|
||||
await this.returnCreatorFundsByProjectId(project.id, false)
|
||||
await this.returnUserFundsByProjectId(project.id, false)
|
||||
} else {
|
||||
const deployers = await this.saveDeployersByDeployerRecords(deployerRecords);
|
||||
for (const deployer of deployers) {
|
||||
@ -1332,7 +1332,7 @@ export class Service {
|
||||
return false;
|
||||
}
|
||||
|
||||
async returnCreatorFundsByProjectId(projectId: string, winningDeployersPresent: boolean) {
|
||||
async returnUserFundsByProjectId(projectId: string, winningDeployersPresent: boolean) {
|
||||
const project = await this.db.getProjectById(projectId);
|
||||
|
||||
if (!project || !project.auctionId) {
|
||||
@ -1405,7 +1405,9 @@ export class Service {
|
||||
}
|
||||
|
||||
async getAddress(): Promise<any> {
|
||||
return this.laconicRegistry.getAddress();
|
||||
const account = await this.laconicRegistry.getAccount();
|
||||
|
||||
return account.address;
|
||||
}
|
||||
|
||||
async verifyTx(txHash: string, amountSent: string, senderAddress: string): Promise<boolean> {
|
||||
|
@ -23,11 +23,7 @@ const Stopwatch = ({ offsetTimestamp, isPaused, ...props }: StopwatchProps) => {
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (isPaused) {
|
||||
pause();
|
||||
} else {
|
||||
start();
|
||||
}
|
||||
isPaused ? pause() : start();
|
||||
}, [isPaused]);
|
||||
|
||||
return <FormatMillisecond time={totalSeconds * 1000} {...props} />;
|
||||
|
@ -32,7 +32,7 @@ const ConnectWallet = ({
|
||||
>
|
||||
{accounts.map((account, index) => (
|
||||
<Option key={index} value={account.address}>
|
||||
{account.address}
|
||||
{account.address.split(':').slice(1).join(':')}
|
||||
</Option>
|
||||
))}
|
||||
</Select>
|
||||
|
Loading…
Reference in New Issue
Block a user