fix: changes in exch

This commit is contained in:
Daniil Kurepin 2024-01-07 20:12:36 +03:00
parent 9044ca51a9
commit ec2b55b383

View file

@ -21,15 +21,14 @@ func _deploy(data interface{}, isUpdate bool) {
})
if len(args.zaCoinHash) != interop.Hash160Len {
panic("invalid hash of zaCoin contract")
}
panic("invalid hash of zaCoin contract")
}
ctx := storage.GetContext()
storage.Put(ctx, zaCoinHashKey, args.zaCoinHash)
}
func BuyZaCoin(gasCount int){
func BuyZaCoin(gasCount int) bool {
playerOwner := runtime.GetScriptContainer().Sender
playerBalance := gas.BalanceOf(playerOwner)
@ -40,12 +39,19 @@ func BuyZaCoin(gasCount int){
contractHash := runtime.GetExecutingScriptHash()
transferredGas := gas.Transfer(playerOwner, contractHash, gasCount, nil).(bool)
if !transferredGas {
panic("failed to transfer gas")
}
transferredZaCoin := contract.Call(zaCoinHash, "transfer", contract.All, contractHash, playerBalance, gasCount, nil).(bool)
panic("failed to transfer gas")
}
resultAmountZaCoin := gasCount * 57
transferredZaCoin := contract.Call(zaCoinHash, "transfer", contract.All, contractHash, playerBalance, resultAmountZaCoin, nil).(bool)
if !transferredZaCoin {
panic("failed to transfer zaCoins")
} else {
runtime.Log("Gas balance: ", gas.BalanceOf(playerOwner))
runtime.Log("ZaCoin balance: ", contract.Call(zaCoinHash, "balanceOf", contract.ReadStates, playerOwner))
}
return transferredZaCoin
}