How to close associated token account using web3js solana tools - web3js

Is there any way to close the associated account using JS libs?

Absolutely! You can use the normal closeAccount() function that exists on the Token object, if you have one: https://github.com/solana-labs/solana-program-library/blob/e8b7009cc4d8cdd87232ccfc9ce93ab203ada496/token/js/client/token.js#L1109
And here's a test example using that function: https://github.com/solana-labs/solana-program-library/blob/e8b7009cc4d8cdd87232ccfc9ce93ab203ada496/token/js/cli/token-test.js#L480
If you don't, then you'll have to roughly copy the implementation of the first link, creating a closeAccount instruction using createCloseAccountInstruction and signing it with the owner: https://github.com/solana-labs/solana-program-library/blob/e8b7009cc4d8cdd87232ccfc9ce93ab203ada496/token/js/client/token.js#L1850

Related

Robot Framework Selenium | How to check if web page link is not the ${link}

I'm having an issue while trying to test a creation process of a user, i.e. I should try different cases while creating users, with name, without name, with symbols in name and etc...
My issue is that when I press the "Create" button, In case if the user is created I'm getting navigated to the users page which link looks like this website.com/user/userid123123, so I have to check if the link is "website.com/user/registration" in case if I expect any issues, but how do I check if user is successfully created if I can't handle the id of user earlier then it is created.
In general, there is a keyword to check if link is the one I need which is 'Link Should Be ${link}'.
But I also need some keyword which does the opposite action like 'Link Should Not Be ${link}'.
I have tried looking in the web if there is a keyword like the one I need, but I found nothing, I also looked for another solution for my problem but in that case as well I found no solution.
#dot Helped out with this, the issue can be easily solved if the page won't contain the field, so by checking that you can be sure that the test is complete!

Identity Server 4 AuthorizationContext.PromptModes empty

I am using the oidc-client library to authorize with our own Identity Server 4. It is working fine and I need to extend the login functionality. I'd like to use the OIDC-Parameter "prompt". The parameter is sent correctly to the connect/authorize endpoint. When the Login-Method is called, I am trying to get the AuthorizationContext by calling
var context = await _interaction.GetAuthorizationContextAsync(vm.ReturnUrl);
var prompt = context.PromptModes;
_interaction is an instance of IIdentityServerInteractionService. The PromptModes are always empty. Is this the right way I am trying to access them?
Thank you
It looks like you check the value in an inappropriate place.
The answer for a similar question on Github was:
we have to remove the prompt parameter because we would otherwise run into an endless loop. You could save the parameter in a separate parameter I guess.

How to upload multiple files on single statement in selenium?

I am not getting any warning or error message while executing the program.
wd.findElement(By.xpath("XPATH")).sendKeys("ABC.jpg","XYZ.jpg");
But no file is uploading.
wd.findElement(By.xpath("XPATH")).sendKeys("can we make CTRL+A operation" );
Thanks in advance.
I think you may be going about this while "file upload in Selenium" thing wrong, so that's what I'm going to address.
This article by SauceLabs covers the basic steps to handle a file upload through Selenium in both Java and Ruby. Assuming you're using Java, there are a few steps you'd need:
Set the FileDetector method for your WebDriver
Get a WebElement pointing to a valid HTML input tag of type file
Have Selenium type in the file's path (Not sure if this requires absolute paths, but it's probably a good idea)
Submit the form
The following code listing demonstrates how to perform each of these steps:
wd.setFileDetector(new LocalFileDetector());
// point your webdriver to the page containing the upload form.
WebElement upload = wd.findElement(By.xpath("XPATH")); // TODO replace xpath!
upload.sendKeys("/path/to/ABC.jpg");
upload.submit(); // NOTE: Submits the form *containing* the upload field!
Because you've set the file detection method to LocalFileDetection, Selenium will be able to find the appropriate file. If this is not set, then Selenium defaults to the UselessFileDetection implementation, which fails every time to avoid accidental file uploads.
Caveat: If you're using a Javascript or Flash-based multiple file upload system, then this probably won't work, since those typically bypass the original input field or handle upload independently from the form's submission.
You are not getting an error because sendKeys() accepts an array of CharSequence objects. and you are conforming to that method contract
But no file is uploading
That is because the way your code is written now, will actually send the text: ABC.jpgXYZ.jpg.

Close method not working in Office

Im trying to use Microsoft.Office.Interop.Word._Document.Close() in a .net 3.5 windows form app.
No matter how much I search here and on Google I cannot find the correct parameters to put in the Close method.
I am using version 14.0.0.0 of Microsoft.Office.Interop.Word and I would like to close the document without saving and ideally ensure that the application can isolate the document thread so that users can still open word documents outside the running application.
See the Close method of the Document class described in MSDN. If you need to omit the parameter and use the default value - pass the Type.Missing parameter.
Try this:
object doNotSaveChanges = Word.WdSaveOptions.wdDoNotSaveChanges;
object missing = System.Reflection.Missing.Value;
_Document.Close(ref doNotSaveChanges, ref missing, ref missing);
This is the source
I'm not sure if you'll need the middle line or not. It's not from the original source it's from here

How do you modify an extension from an X509?

I am creating an api for modifying X509 certificates in C and I want to add a way to modify an extension. For example, add another DNS entry to subjectNameAlt so that it would be DNS:example.com,DNS:example2.com instead of just DNS:example.com . The reason that deleting and re-adding is bad is because I then have to reparse the extension (which is difficult) and I would rather just add a piece of information. How would I do this via the OpenSSL API?
I tried to simply reuse the add code:
ex = X509V3_EXT_conf_nid(NULL, &ctx, NID_subject_alt_name, "DNS:new.dns.example");
if (!ex)
return;
X509_add_ext(cert,ex,-1);
X509_EXTENSION_free(ex);
But after running that, the extension isnt found at all (even if i try to add another new one).
Have a look at
demos/x509/mkcert.c
demos/x509/selfsign.c
demos/x509/mkreq.c
in your openssl distribution. I suspect that you are not setting up your context; or you are making an assumption in that some i2d/etc is called behind the scene when you say 'is not found at all'. Note that X509_sign() and their ilk do create a lot of this. If you are not calling anything -then do not expect any of those to be created.

Resources