-
Notifications
You must be signed in to change notification settings - Fork 30
Feature for confirm custom transaction #306
base: master
Are you sure you want to change the base?
Conversation
change style of JSON tx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat. It would be helpful to add more detail into the README about what the purpose of "confirmTransaction" is. Also it looks like it's really "sendCustomTransaction", as the functionality first sends the transaction and then confirms it.
README.md
Outdated
@@ -55,7 +55,7 @@ window.addEventListener('message', (e) => { | |||
} | |||
}); | |||
``` | |||
4. Send an `'addFunds'` request | |||
4. Send an `'addFunds'` or `'confirmTX'` request |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
confirmTransaction
please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
README.md
Outdated
walletWindow.postMessage({ | ||
method: 'confirmTX', | ||
params: { | ||
description: "Description of tx", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tx -> transaction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
README.md
Outdated
params: { | ||
description: "Description of tx", | ||
format: 'JSON', | ||
transaction: "Your tx in JSON", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to describe this more. Is this a JSON array of octets representing the signed wire transaction, or some other kind of JSON representation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/wallet.js
Outdated
@@ -151,14 +153,15 @@ class TokenInput extends React.Component { | |||
placeholder="Enter amount to transfer" | |||
onChange={e => this.handleChange(e.target.value)} | |||
/> | |||
<FormControl.Feedback /> | |||
<FormControl.Feedback/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please remove all these whitespace changes? Ie, formatting style changes can be a separate PR, much easier to review the "important" bits of this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
…llet into develop # Conflicts: # src/wallet.js
@jstarry - hey can you please review this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Thanks for adding this functionality, super useful :D
const transaction = new web3.Transaction(); | ||
const inputs = JSON.parse(params.transaction); | ||
|
||
inputs.map(input => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a big fan of this approach because if we change Transaction structure, it would break. I would prefer to rely on the web3 sdk serialization methods instead for passing messages: transaction.serialize(): Buffer
and Transaction.from(buffer: Buffer)
.
I like that you are displaying the json formatted transaction in the confirmation before sending. I think that a toJSON method would be nice to have inside Web3, thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I also wanted to do this, but SDK does not serialize an unsigned transaction, can you give an example how to do it?
public serialize(): Buffersource
Serialize the Transaction in the wire format.
The Transaction must have a valid signature before invoking this method
I have error
Uncaught Error: Transaction recentBlockhash required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check out solana-labs/solana-web3.js@85b354e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to fill out recentBlockhash
, what if the user did not immediately confirm the transaction, it needs to be filled again on the wallet side?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting a placeholder is fine because the wallet will always set the recentBlockhash
when signing. Something like:
transaction.recentBlockhash = new PublicKey(0).toBase58();
src/wallet.js
Outdated
onSendCustomTransactionRequest(params, origin) { | ||
if (!params.format || !params.network || !params.transaction) { | ||
if (!params.network) this.addError(`Request did not specify a network`); | ||
if (!params.format) this.addError(`Request did not specify a transaction format`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you aren't checking the value of format
anywhere. Let's remove it for now, and add if we introduce other formats.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
README.md
Outdated
@@ -55,7 +55,7 @@ window.addEventListener('message', (e) => { | |||
} | |||
}); | |||
``` | |||
4. Send an `'addFunds'` request | |||
4. Send an `'addFunds'` or `'sendCustomTransaction'` request |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to re-organize this README section rather than adding more things to the "Funding dApps" section. I recommend
## Wallet Setup
... steps 1 - 3
## Requesting Funds
... steps 4 - 5
## Sending Custom Transactions
... your new steps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -321,14 +321,16 @@ export class Wallet extends React.Component { | |||
account: null, | |||
requestMode: false, | |||
requesterOrigin: '*', | |||
requestPending: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The user may not close the wallet window after the last request and may simply not respond to it, but may also request a new action in the DAPP therefore. For useful, I allowed DAPP to update the request, and in the future we will need a request queue.
src/wallet.js
Outdated
requestedPublicKey: '', | ||
requestedAmount: '', | ||
recipientPublicKey: '', | ||
recipientAmount: '', | ||
recipientIdentity: null, | ||
confirmationSignature: null, | ||
transactionConfirmed: null, | ||
unsignedTransaction: null, | ||
formattedUnsignedTransaction: '', | ||
description: '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please namespace this: unsignedTransactionDescription
is more wordy but easier to understand what it's used for
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -321,14 +321,16 @@ export class Wallet extends React.Component { | |||
account: null, | |||
requestMode: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's change this state flag from a boolean to an enum and rename to displayMode
since we have 3 display modes now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/wallet.js
Outdated
description: params.description ? params.description : '', | ||
unsignedTransaction: transaction, | ||
formattedUnsignedTransaction: JSON.stringify(JSON.parse(params.transaction), null, 4), | ||
requestedPublicKey: null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove, we can use a different approach to distinguish between "addFunds" and "sendCustomTransaction"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/wallet.js
Outdated
@@ -817,10 +906,46 @@ export class Wallet extends React.Component { | |||
</Col> | |||
</Row> | |||
</Grid> | |||
<div className="container">{this.renderPanels()}</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert this change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
No description provided.