Skip to content

Commit

Permalink
Merge 381d60a into 271c7f5
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobDenver007 committed May 6, 2019
2 parents 271c7f5 + 381d60a commit b9a90f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 1 addition & 3 deletions processor/vm/instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/log"
"github.com/fractalplatform/fractal/accountmanager"
"github.com/fractalplatform/fractal/asset"
"github.com/fractalplatform/fractal/common"
"github.com/fractalplatform/fractal/crypto"
"github.com/fractalplatform/fractal/crypto/ecies"
Expand Down Expand Up @@ -1281,7 +1280,7 @@ func executeIssuseAsset(evm *EVM, contract *Contract, desc string) (uint64, erro
contractName := common.Name(input[7])
detail := input[8]

asset := &asset.AssetObject{AssetName: name, Symbol: symbol, Amount: total, Owner: owner, Founder: founder, Decimals: decimal, UpperLimit: limit, Contract: contractName, Detail: detail}
asset := &accountmanager.IssueAsset{AssetName: name, Symbol: symbol, Amount: total, Owner: owner, Founder: founder, Decimals: decimal, UpperLimit: limit, Contract: contractName, Detail: detail}

b, err := rlp.EncodeToBytes(asset)
if err != nil {
Expand Down Expand Up @@ -1451,7 +1450,6 @@ func opCallEx(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *S
action := types.NewAction(types.CallContract, contract.Name(), toName, 0, assetID, 0, value, nil, nil)

err = evm.AccountDB.TransferAsset(action.Sender(), action.Recipient(), action.AssetID(), action.Value())

//distribute gas
var assetName common.Name
assetFounder, _ := evm.AccountDB.GetAssetFounder(action.AssetID()) //get asset founder name
Expand Down
18 changes: 10 additions & 8 deletions test/fee/transaction_contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ var (
bNonce = uint64(0)
cNonce = uint64(0)

assetID = uint64(1)
assetID = uint64(0)
issueAssetName = "ether" + contract_a.String()
issueAssetID = int64(1)
contract_a_ID = int64(4105)
Expand Down Expand Up @@ -155,7 +155,7 @@ func formWithdrawContractFeeInput(abifile string, userId *big.Int) ([]byte, erro

func generateAccount() {
nonce, _ = testcommon.GetNonce(adminAccount)
issueAssetID = int64(nonce/4 + 2)
issueAssetID = int64(nonce/4 + 1)
contract_a_ID = int64(4105 + 4*nonce/4)

newPrivateKey_a, _ = crypto.GenerateKey()
Expand Down Expand Up @@ -274,15 +274,17 @@ func issueAssetForA() {
func transferAssetByContractFromA2B() {
jww.INFO.Println("transferAssetByContractFromA2B ")

input, err := formTransferAssetInput(multiAssetAbi, common.BigToAddress(big.NewInt(4096)), big.NewInt(1))
input, err := formTransferAssetInput(multiAssetAbi, common.BigToAddress(big.NewInt(4099)), big.NewInt(1))
if err != nil {
jww.INFO.Println("transferAssetByContractFromA2B formTransferAssetInput error ... ", err)
return
}

key_0 := types.MakeKeyPair(a_author_0_priv, []uint64{0})
aNonce++
sendTransferTx(types.CallContract, normal_a, contract_a, aNonce, assetID, big.NewInt(0), input, []*types.KeyPair{key_0})
for i := 0; i < 200; i++ {
aNonce++
sendTransferTx(types.CallContract, normal_a, contract_a, aNonce, assetID, big.NewInt(0), input, []*types.KeyPair{key_0})
}
}

func deployWithDrawContract() {
Expand Down Expand Up @@ -347,20 +349,20 @@ func main() {

time.Sleep(10 * time.Second)

b, _ := testcommon.GetAccountBalanceByID(contract_a, 1)
b, _ := testcommon.GetAccountBalanceByID(contract_a, 0)
fmt.Println("balance ", b)
withdrawFee()

time.Sleep(10 * time.Second)

b, _ = testcommon.GetAccountBalanceByID(contract_a, 1)
b, _ = testcommon.GetAccountBalanceByID(contract_a, 0)
fmt.Println("balance after withdraw ", b) //shoud be 1000000028786
}

func sendTransferTx(txType types.ActionType, from, to common.Name, nonce, assetID uint64, value *big.Int, input []byte, keys []*types.KeyPair) {
action := types.NewAction(txType, from, to, nonce, assetID, gasLimit, value, input, nil)
gasprice := big.NewInt(1)
tx := types.NewTransaction(1, gasprice, action)
tx := types.NewTransaction(0, gasprice, action)

signer := types.MakeSigner(big.NewInt(1))
err := types.SignActionWithMultiKey(action, tx, signer, keys)
Expand Down

0 comments on commit b9a90f2

Please sign in to comment.