This repository was archived by the owner on Mar 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
from parameter should accept a wallet #2825
Copy link
Copy link
Closed
Labels
2.x2.0 related issues2.0 related issuesFeature RequestStaleHas not received enough activityHas not received enough activity
Description
This is a feature request. Anytime we accept an address as a "from" parameter, it would be handy if we could pass it a wallet object instead of just an address. I realize the from address is used as a lookup into a currently decrypted wallet. But the place to decrypt should be during whatever procedure we're trying to pass in the address. Otherwise we have to decrypt the wallet before calling the function and this is putting it back into the global space again.
The below is a really bad idea, but is presently the only way to handle it.
let result;
if(window.confirm(`Would you like to send ${amount} ${symbol} to ${dest}?`)){
try{
let ctr = await this.XTokens[symbol];
let fin = (await ctr.displayToRaw(amount)).toString();
let wallet = await this.pinPrompt();
let params = {
from : wallet[0].address
}
params.gas = await ctr.methods.transfer(dest,fin).estimateGas(params);
console.debug("params: ",params);
result = await ctr.methods.transfer(dest,fin).send(params);
console.debug("result: ",result);
window.alert(`Successfully sent ${amount} ${symbol} to ${dest}! Transaction Hash is ${result.transactionHash}`);
}catch(err){
window.alert(err);
}
}
FYI the "this.pinPrompt" prompts a user for a password, decrypts the wallet and hands back the decrypted wallet.
It would be far better if I could just hand in "wallet" and perhaps the password.
nivida
Metadata
Metadata
Assignees
Labels
2.x2.0 related issues2.0 related issuesFeature RequestStaleHas not received enough activityHas not received enough activity