Skip to content

Commit

Permalink
Added AccountFund for mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsan6sha committed Jan 27, 2024
1 parent 6e59fdf commit 6835f6f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Fula.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Fula' # Name for your pod
s.version = '1.0.0'
s.version = '1.42.0'
s.summary = 'Go-fula for iOS'
s.homepage = 'https://github.com/functionland/go-fula'

Expand Down
2 changes: 1 addition & 1 deletion blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func (bl *FxBlockchain) callBlockchain(ctx context.Context, method string, actio

func (bl *FxBlockchain) PlugSeedIfNeeded(ctx context.Context, action string, req interface{}) interface{} {
switch action {
case actionSeeded, actionAccountExists, actionPoolCreate, actionPoolJoin, actionPoolCancelJoin, actionPoolVote, actionPoolLeave, actionManifestUpload, actionManifestStore, actionManifestRemove, actionManifestRemoveStorer, actionManifestRemoveStored, actionManifestBatchStore:
case actionSeeded, actionAccountExists, actionAccountFund, actionPoolCreate, actionPoolJoin, actionPoolCancelJoin, actionPoolVote, actionPoolLeave, actionManifestUpload, actionManifestStore, actionManifestRemove, actionManifestRemoveStorer, actionManifestRemoveStored, actionManifestBatchStore:
seed, err := bl.keyStorer.LoadKey(ctx)
if err != nil {
log.Errorw("seed is empty", "err", err)
Expand Down
20 changes: 20 additions & 0 deletions mobile/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package fulamobile
import (
"context"
"fmt"
"math/big"
"strconv"

"github.com/functionland/go-fula/blockchain"
Expand Down Expand Up @@ -36,6 +37,25 @@ func (c *Client) AssetsBalance(account string, assetId int, classId int) ([]byte
return c.bl.AssetsBalance(ctx, c.bloxPid, blockchain.AssetsBalanceRequest{Account: account, AssetId: uint64(assetId), ClassId: uint64(classId)})
}

// AccountFund requests blox at Config.BloxAddr to fund the account.
// the addr must be a valid multiaddr that includes peer ID.
func (c *Client) AccountFund(account string) ([]byte, error) {
ctx := context.TODO()
amountString := "1000000000000000000"

// Create a new big.Int
bigAmount := new(big.Int)
_, ok := bigAmount.SetString(amountString, 10)
if !ok {
err := fmt.Errorf("error: the number %s is not valid", amountString)
return nil, err
}

// Convert big.Int to blockchain.BigInt
amount := blockchain.BigInt{Int: *bigAmount}
return c.bl.AccountFund(ctx, c.bloxPid, blockchain.AccountFundRequest{Amount: amount, To: account})
}

func (c *Client) TransferToFula(amountStr string, walletAccount string, chain string) ([]byte, error) {
ctx := context.TODO()
// Convert amount from string to uint64
Expand Down

0 comments on commit 6835f6f

Please sign in to comment.