-
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.
Merge branch 'naynay/file-restructure' into naynay/signing-restructure
- Loading branch information
Showing
11 changed files
with
100 additions
and
109 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import Entropy from "@entropyxyz/sdk"; | ||
import { BaseCommand } from "../common/base-command"; | ||
import { setupProgress } from "../common/progress"; | ||
import * as TransferUtils from './utils' | ||
import inquirer from "inquirer"; | ||
|
||
const FLOW_CONTEXT = 'ENTROPY_TRANSFER' | ||
const question = [ | ||
{ | ||
type: "input", | ||
name: "amount", | ||
message: "Input amount to transfer:", | ||
default: "1", | ||
validate: (amount) => { | ||
if (isNaN(amount) || parseInt(amount) <= 0) { | ||
return 'Please enter a value greater than 0' | ||
} | ||
return true | ||
} | ||
}, | ||
{ | ||
type: "input", | ||
name: "recipientAddress", | ||
message: "Input recipient's address:", | ||
}, | ||
] | ||
|
||
export class TransferCommand extends BaseCommand { | ||
constructor (entropy: Entropy, endpoint: string) { | ||
super(entropy, endpoint, FLOW_CONTEXT) | ||
} | ||
|
||
public async askQuestions () { | ||
return inquirer.prompt(question) | ||
} | ||
|
||
public async sendTransfer (toAddress: string, amount: string) { | ||
const { start: startProgress, stop: stopProgress } = setupProgress('Transferring Funds') | ||
|
||
const formattedAmount = BigInt(parseInt(amount) * 1e10) | ||
startProgress() | ||
try { | ||
const transferStatus = await TransferUtils.transfer(this.entropy, { from: this.entropy.keyring.accounts.registration.pair, to: toAddress, amount: formattedAmount }) | ||
if (transferStatus.isFinalized) return stopProgress() | ||
} catch (error) { | ||
this.logger.error('There was an issue sending this transfer', error) | ||
stopProgress() | ||
throw error | ||
} | ||
} | ||
} |
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
File renamed without changes.
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