How to get the getTransaction method from Solana web3.js? - web3js

I am using Solana Phantom wallet to make solana transaction using Web3.js. The code is working fine, but I need to get the details of the transaction by calling getTransaction() method. But I don't know how to call that function? can anyone help? I am not using Node. I am using Web3.js library.
Code:
const { signature } = await window.solana.signAndSendTransaction(transaction);
await connection.confirmTransaction(signature);
console.log(signature);
connection.getTransaction(signature, (error, tx)=>{
console.log(tx);
})

Related

How to secure client http calls to the backend?

I am trying to figure out what is the best way to prevent random people access/make requests to the server.
Currently, everyone that have the url and the endpoint can easily make requests and I believe it's kind of security breach.
I am using Express.js that hosting static build of React.js
Here is an example of a call:
// Client:
async function getData(id){
try {
const res = await axios.get(`${backendDomain}/data/${id}`)
const data = res.data
return data
} catch (error) {
...
}
}
// Server:
app.get('/data/:id', function(req, res) {
...logic
res.send(data);
});
I tried adding to the Client "x-api-key" header and pass an api key that only I have and add a middleware that will check the api and see if it passed currectly from the client. But obviously it is not a good solution because you can see the key on "Network" section while inspecting.
What can I do?
Looking for the best way to prevent random people accessing the data

A way to fetch Microsoft Graph locations with PnPJs

As stated above in the title I am currently facing issues fetching graph places with PnPJs, using the #pnp/graph graphfi factory interface in SPFx.
I am currently able to fetch data from my events via graphfi as can be seen below:
React.useEffect(() => {
graph = graphfi().using(SPFx(props.context));
getSpecificCalendar();
}, []);
const getSpecificCalendar = async () => {
await graph.me.events().then((e) => setCalendarEvent(e));
}
I have tried to get the places property from the graph object but to no avail. The only properties present are me and users but no option for places.
Esentially what I want to do is to graph.places. The conclusion I have come to is that #pnp/graph does not have any methods to get room data. Any ideas other than what I have tried above would be extremely helpful.
It looks like pnpjs does not have the /places endpoint implemented (yet). You could try using the built-in SPFx graph client for now. Something like:
const client = await props.context.msGraphClientFactory.getClient('3')
const response = await client.api('/places/......').get();
Alternatively, you could implement the /places endpoint yourself and submit a pull request for pnpjs :)

how to set up mailchimp and get ping everything chimpy?

I been trying to get mailchimp with my react project but for the love of me just can't. I don't know why I can't get the ping and despite having the node module installed, it tells me it isnt.
im using these docs - https://mailchimp.com/developer/marketing/guides/quick-start/
and this code with ofcourse my information. Any clues, am I missing a key step here? has anyone got experience with this and if so, can i see your code for it ?
const mailchimp = require("#mailchimp/mailchimp_marketing");
mailchimp.setConfig({
apiKey: "YOUR_API_KEY",
server: "YOUR_SERVER_PREFIX",
});
async function run() {
const response = await mailchimp.ping.get();
console.log(response);
}
run();

How to get device ip - Expo React Native

How can I get the ip of the device using React Native and Expo,
I'm trying this and all I see on the alert is [object promise].
I'm running the app on an emulator and on the browser..
import * as Network from 'expo-network';
alert(Network.getIpAddressAsync());
Network.getIpAddressAsync() returns a Promise, so you need to resolve it first.
import * as Network from 'expo-network';
const ipAlert = async () => {
const ip = await Network.getIpAddressAsync()
alert(ip);
};
ipAlert();
As it is written in the documentation, the method Network.getIpAddressAsync() returns a Promise that resolves to a String of the current IP address of the device's main network interface.
Due to this fact, you need to wait for the promise to finish as it is asynchronous.
You can do so by either attaching the await keyword before it, like this:
await Network.getIpAddressAsync();
or by chaining a then function afterwards, like so:
Network.getIpAddressAsync().then(function(address) {
//Your logic here
});

salesforce forcejs not getting refresh token

i am using forcejs in my angular app which is working fine and gives me accessToken. However, I am not able to get refreshToken to be able to renew accessToken as needed. The code is below
import { OAuth, DataService } from 'forcejs';
async loginSFDC(){
let callbackUrl = 'https://my.callback.url'
let oauth = OAuth.createInstance('client key','', callbackUrl);
oauth.login().then(
async (oauthResult) => {
DataService.createInstance(oauthResult);
console.log("Logged Into Salesforce Successfully:::" + JSON.stringify(oauthResult));
});
}
the above code is printing accessToken but no refreshToken. Please advise
i have also tried passing the 2nd parameter in createInstance as http://login.salesfoce.com?scope=full+refresh_token but that does not work as url gets constructed wrong on adding the scope=full+refresh_token
From looking at the source code of forcejs, you can use the refreshAccessToken() method with the DataService instance you created.
After some more debugging it is discovered that the refresh token shows up when my code is running on localhost but does not when it is deployed to the the webserver. i dont know how to debug further or fix it. but i have verified that this behavior is consistently reproducible

Resources