Skip to content

Commit

Permalink
Merge pull request #12 from crash13override/master
Browse files Browse the repository at this point in the history
adding account create and generate keys
  • Loading branch information
luca-mayven authored Oct 20, 2023
2 parents 7b4dac0 + e5c7f36 commit 432c826
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions src/FlowSDK/Flow.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Flow {
protected $extraParam;
protected $gasLimit;
protected $outputDebug;
protected $key;

function __construct()
{
Expand Down Expand Up @@ -62,6 +63,14 @@ public function run(){
} else {
$cmd[] = 'latest';
}
} else if($this->type == 'createAccount'){
$cmd[] = 'accounts';
$cmd[] = 'create';
$cmd[] = '--key';
$cmd[] = $this->key;
} else if($this->type == 'generateKey'){
$cmd[] = 'keys';
$cmd[] = 'generate';
}

if($this->extraParam != '') {
Expand All @@ -73,14 +82,16 @@ public function run(){
$cmd[] = json_encode($this->args);
}

if(config('flow.network') != 'emulator'){
if(config('flow.network') != 'emulator' && !$this->type == 'generateKey'){
$cmd[] = '--network';
$cmd[] = config('flow.network');
if($this->type == 'transaction') {
if($this->type == 'transaction' || $this->type == 'createAccount') {
$cmd[] = '--signer';
$cmd[] = $this->signer;
$cmd[] = '--gas-limit';
$cmd[] = $this->gasLimit;
if($this->type == 'transaction') {
$cmd[] = '--gas-limit';
$cmd[] = $this->gasLimit;
}
}
}
$cmd[] = '-o';
Expand Down Expand Up @@ -111,6 +122,7 @@ protected function resetParams(){
$this->signer = 'testnet-account';
$this->gasLimit = 9999;
$this->outputDebug = false;
$this->key = '';
}

public function transaction($file){
Expand Down Expand Up @@ -144,6 +156,20 @@ public function block(){
return $this;
}


public function createAccount($key){
$this->resetParams();
$this->type = 'createAccount';
$this->key = $key;
return $this;
}

public function generateKey(){
$this->resetParams();
$this->type = 'generateKey';
return $this;
}

public function file($file){
$this->file = $file;
return $this;
Expand Down

0 comments on commit 432c826

Please sign in to comment.