Verify emitted event on clarinet console - smartcontracts

I'm relatively new to clarity smart contract language. I'm trying to emit some data via
print method when contract is deployed.
Console is showing list of deployed smart contracts, but no event log is there.
Sample code is:
I'm not sure if clarinet supports this.

Related

How to interact with already deployed smart contract after reloading it into remix

After I have deployed a contract, I'm able to interact with the setter functions, as well as with the getter functions. However, after a day goes by, when i try to interact with the same contract again, that is still open and loaded on my remix I get a "pending" message when I try to set and change some variables like a different address. When I try to call a get function also nothing happens. I don't know how to interact with my deployed contract again.
When I reload the contract using the contract address "at address", it properly loads the contract if I select the right smart contract (containing the getter and setter functions) from the dropdown menu in the "deploy and run" page. However, the same problem occurs, that is: when i try to set a variable the transaction is not mined (pending indefinetly), and the call functions also dont read the data.
In order for me to move forward with my project I need to be able to access and interact with the contract if I need to change a variable which currently doesn't work...
Anyone has an idea how to solve this (probably trivial) problem? Thanks!

BEP-20 Contract no deploy public view functions

I am studying how to make BEP-20 tokens. For this I copied the following contract in remix to be able to study it:
Contract in BscScan
If I copy the whole file and compile it in Remix, when I deploy it it doesn't show me any getters. No public view function appears. If I look at the contract displayed on the testnet, it doesn't have any supply of tokens either.
I separated the files and libraries for a better reading. And it is then, when I try to display it, that I get the following error:
VM error: revert. revert The transaction has been reverted to the initial state. Note: The called function should be payable if you send value and the value you send should be less than your current balance. Debug the transaction to get more information.
It gives me the feeling that this contract does not generate the tokens ... What am I wrong?
I managed to fix the problem. As I suspected, in order to deploy the contract I have to remove everything related to uniswap and cakeswap. This displays the contract correctly.
If you wanted to deploy the contract with the uniswap interfaces in injected web3, you would need the uniswap testnet.
I found a test address for cake here:
Binance Smart change tesnet

How do I see the contract log events in Ethereum?

I finished the https://www.ethereum.org/crowdsale tutorial in Ethereum and intentionally left the crowdsale having failed its funding goal (sample code at the start of the page). I fired the "safeWithdrawal" function from within Ethereum-Wallet and it adds the transaction on to the blockchain. But at this point I do not know how to listen to the response. The ether I sent was not returned.
I would like the ether to be returned.
I would like to know how to listen to the event that should have fired. Or any feedback mechanism to know that the why / how the event fired.
Screenshot: http://i.stack.imgur.com/2lsVo.png
Currently, the Ethereum-Wallet has no debugger built-in for smart contracts.
I suggest, you code up your example using the browser-solidity. It allows you not only to code and test the deployment but got most recently a debugger built in. Click the little bug.
The debugger used in browser solidity is remix which is both a javascript IDE but also a library which can be attached to your own javascript projects. It is possible that future releases of Ethereum-Wallet will also include remix, this would simplify your task pretty much.
But for now, the mentioned browser tool seems like perfectly suited for your needs.

Is it possible to write a plugin for Glimpse's existing SQL tab?

Is it possible to write a plugin for Glimpse's existing SQL tab?
I'm trying to log my SQL queries and the currently available extensions don't support our in-house SQL libary. I have written a custom plugin which logs what I want, but it has limited functionality and it doesn't integrate with the existing SQL tab.
Currently, I'm logging to my custom plugin using a single helper method inside my DAL's base class. This function looks takes the SqlCommand and Duration in order to show data on my custom tab:
// simplified example:
Stopwatch sw = Stopwatch.StartNew();
sqlCommand.Connection = sqlConnection;
sqlConnection.Open();
object result = sqlCommand.ExecuteScalar();
sqlConnection.Close();
sw.Stop();
long duration = sw.ElapsedMilliseconds;
LogSqlActivity(sqlCommand, null, duration);
This works well on my 'custom' tab but unfortunately means I don't get metrics shown on Glimpse's HUD:
Is there a way I can provide Glimpse directly with the info it needs (in terms of method names, and parameters) so it displays natively on the SQL tab?
The following advise is based on the fact that you can't use DbProviderFactory and you can't use a proxied SqlCommand, etc.
The data that appears in the "out-of-the-box" SQL tab is based on messages of given types been published through our internal Message Broker (see below on information on this). Because of the above limitations in your case, to get things lighting up correctly (i.e. your data showing up in HUD and the SQL tab), you will need to simulate the work that we do under the covers when we publish these messages. This shouldn't be that difficult and once done, should just work moving forward.
If you have a look at the various proxies we have here you will be above to see what messages we publish in what circumstances. Here are some highlights:
DbCommand
Log command start - here
Log command error - here
Log command end - here
DbConnection:
Log connection open - here
Log connection closed - here
DbTransaction
Log Started - here
Log committed - here
Log rollback - here
Other
Command row count here - Glimpses calculates this at the DbDataReader level but you could do it elsewhere as well
Now that you have an idea of what messages we are expecting and how we generate them, as long as you pass in the right data when you publish those messages, everything should just light up - if you are interested here is the code that looks for the messages that you will be publishing.
Message Broker: If you at the GlimpseConfiguration here you will see how to access the Broker. This can be done statically if needed (as we do here). From here you can publish the messages you need.
Helpers: For generating some of the above messages, you can use the helpers inside the Support class here. I would have shifted all the code for publishing the actual messages to this class, but I didn't think there would be too many people doing what you are doing.
Update 1
Starting point: With the above approach you shouldn't need to write your own plugin. You should just be able to access the broker GlimpseConfiguration.GetConfiguredMessageBroker() (make sure you check if its null, which it is if Glimpse is turned off, etc) and publish your messages.
I would imagine that you would put the inspection that leverages the broker and published the messages, where ever you have knowledge of the information that needs to be collected (i.e. inside your custom lib). Normally this would require references inside your lib to glimpse (which you may not want), so to protect against this, from your lib, you would call a proxy (which could be another VS proj) that has the glimpse dependency. Hence your ado lib only has references to your own code.
To get your toes wet, try just publishing a couple of fake connection and command messages. Assuming the broker you get from GlimpseConfiguration.GetConfiguredMessageBroker() isn't null, these should just show up. Then you can work towards getting real data into it from your lib.
Update 2
Obsolete Broker Access
Its marked as obsolete because its going to change in v2. You will still be able to do what you need to do, but the way of accessing the broker has changed. For what you currently need to do this is ok.
Sometimes null
As you have found this is really dependent on where in the page lifecycle you are currently at. To get around this, I would probably change my original recommendation a little.
In the code where you are currently creating messages and pushing them to the message bus, try putting them into HttpContext.Current.Items. If you haven't used it before, this is a store which asp.net provides out of the box which lasts the lifetime of a given request. You could have a list that you put in there, still create the message objects that you are doing, but put them into that list instead of pushing them through the broker.
Then, create a HttpModule (its really simple to do) which taps into the PostLogRequest event. Within this handler, you would pull the list out of the context, iterate through it and push the message into the message broker (accessing the same way you have been).

NServiceBus Studio - Starting with an Event

I'm following along with the NSB video on TekPub (http://tekpub.com/view/nsb/1) as an introduction to the NSB
Studio (great work btw). I can create the PetShop example just fine, but now I'm
looking to create my own system. In the PetShop example, the process starts off
with the Sales component (in the FrontEnd endpoint) sending a SubmitOrder
command on the bus. When the SubmitOrder command was created, Studio created a
SubmitOrderSender, which is what is hosted in the FrontEnd endpoint.
In my existing system, I have a process that will do some work, and I want to
start the NSB process with an event, not a command. In Studio, I created a
new Service ("Foo") and manually added a new Component ("XxxRecievedSender"). I
then had the XxxReceivedSender publish an event ("XxxReceived"). Then I right
clicked on the XxxReceived event, and added a new subscriber ("Notifications").
Studio created the Notifications service and added a "XxxReceivedProcessor"
which subscribes to the XxxReceivedEvent.
The differences I noticed from the video are that the SubmitOrderSender that is
generated has an ISubmitOrder interface, and a Send(SubmitOrder) method. Since I
manually created my XxxReceivedSender, I didn't have those, so I added them
(except Publish instead of Send). Then, in my mvc frontend, I added the
IXxxReceivedSender to the home controller, and then executed Sender.Push(new
XxxReceived()). I then got errors that I needed to add MsmqSubscriptionStorage()
to the .configure() and then more errors that the queues weren't created. Once
I fixed those two things, the app runs, but when the event is published, the
XxxReceivedProcessor isn't received it.
I'm thinking that I'm doing something wrong here, but I can't figure out what it
is. Any advice? As Studio is a brand new feature, I'd be very interested
in the proper way to use it.
Try looking at the UnicastBusConfig in your subscribing endpoint to see that there is an entry in there telling NServiceBus to subscribe to your event at the MVC endpoint.
If that's handled, then start the subscriber by itself and see that a message arrives at your publisher. If so, then start the publisher and see that the message is processed and that there are no messages in your error queue.