iov-core icon indicating copy to clipboard operation
iov-core copied to clipboard

Allow MultiChainSigner.signAndPost to take multiple transactions

Open webmaster128 opened this issue 6 years ago • 3 comments

This is required by the faucet (refilling distributors) to remove the need to wait for a block just to get an updated nonce

webmaster128 avatar Jan 25 '19 18:01 webmaster128

This is how an overload for one or many can work:

/**
   * Queries the nonce, signs the transaction and posts it to the blockchain.
   *
   * The transaction signer is determined by the transaction content. A lookup for
   * the private key for the signer in the given wallet ID is done automatically.
   */
  public async signAndPost(transaction: UnsignedTransaction, walletId: WalletId): Promise<PostTxResponse>;
  public async signAndPost(transactions: ReadonlyArray<UnsignedTransaction>, walletId: WalletId): Promise<ReadonlyArray<Promise<PostTxResponse>>>;
  public async signAndPost(tx: UnsignedTransaction | ReadonlyArray<UnsignedTransaction>, walletId: WalletId): Promise<PostTxResponse | ReadonlyArray<Promise<PostTxResponse>>> {
    if (isUnsignedTransaction(tx)) {
      const firstResult = (await this.signAndPost([tx], walletId))[0];
      return firstResult;
    }

However, implementing this is too complicated as long as one identity can be in a profile multiple times

webmaster128 avatar Jan 27 '19 19:01 webmaster128

However, implementing this is too complicated as long as one identity can be in a profile multiple times

Yes, I would love to enforce uniqueness and then remove need for WalletId in many of these methods, where an identity (public key and chain) is sufficient. Did you have another issue for that one as well?

Seems like a good thing shortly post-v0.12

ethanfrey avatar Jan 28 '19 14:01 ethanfrey

Did you have another issue for that one as well?

Jap, but was not on the board before: https://github.com/iov-one/iov-core/issues/652

webmaster128 avatar Jan 29 '19 17:01 webmaster128