github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/fvm/evm/types/tokenVault.go (about) 1 package types 2 3 import "math/big" 4 5 // FLOWTokenVault holds a balance of flow token 6 type FLOWTokenVault struct { 7 balance Balance 8 } 9 10 func NewFlowTokenVault(balance Balance) *FLOWTokenVault { 11 return &FLOWTokenVault{balance: balance} 12 } 13 14 func (t *FLOWTokenVault) Balance() Balance { 15 return t.balance 16 } 17 18 func (t *FLOWTokenVault) Withdraw(b Balance) (*FLOWTokenVault, error) { 19 var err error 20 t.balance, err = SubBalance(t.balance, b) 21 return NewFlowTokenVault(b), err 22 } 23 24 func (t *FLOWTokenVault) Deposit(inp *FLOWTokenVault) error { 25 var err error 26 t.balance, err = AddBalance(t.balance, inp.balance) 27 // reset balance for the inp incase 28 inp.balance = new(big.Int) 29 return err 30 }