You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[experimental] Figure out how to write an assertion function for fully signed transactions while TypeScript does not support async assertions and typeguards
#1773
Closed
steveluscher opened this issue
Oct 24, 2023
· 4 comments
Essentially you can write an assertion function (playground)…
typeNumberLessThanTen=number&{readonlybrand: unique symbol};functionassertIsLessThan10(num: number): asserts num is NumberLessThanTen{if(num>=10){thrownewError('Too big');}}constnum=9;assertIsLessThan10(num);numsatisfiesNumberLessThanTen;
We could write an assertIsFullySignedTransaction() function that just checks to see if there is a signature for each signer, without actually performing any verification
We could break from the existing pattern of assertFoo/isFoo and make a function that both asserts and returns the transaction with the IFullySignedTransaction type added.
Neither of these are great, and both are really hard to take back (ie. deprecate) once we've released them.
The text was updated successfully, but these errors were encountered:
I'd argue we don't need this assert method to be async in the first place. Since the goal is the ensure it is "fully signed", we just need to go through the account metas that are required to sign, deduplicate the addresses and ensure the amount of unique signers required matches the amount of signatures in the transaction.
I'm assuming the async part would be to also verify each of these signatures match the expected set of signers but IMO that's a bit overkill when all we want is ensure we've not missed one signature.
Agreed. I think it'd be okay to have the type assertion just assert there's a signature for each expected signer, and then optionally to have a separate function(s) that asserts/checks signature validity without changing the type.
Arguably those are separate operations anyway, eg you might want to check the validity of the current signatures on a partially signed transaction.
Because there has been no activity on this issue for 7 days since it was closed, it has been automatically locked. Please open a new issue if it requires a follow up.
See microsoft/TypeScript#37681 (comment).
Essentially you can write an assertion function (playground)…
…but as soon as you make that assertion function async it stops working.
Options:
assertIsFullySignedTransaction()
function that just checks to see if there is a signature for each signer, without actually performing any verificationassertFoo
/isFoo
and make a function that both asserts and returns the transaction with theIFullySignedTransaction
type added.Neither of these are great, and both are really hard to take back (ie. deprecate) once we've released them.
The text was updated successfully, but these errors were encountered: