algorand / js-algorand-sdk

The official JavaScript SDK for Algorand.
https://algorand.github.io/js-algorand-sdk/
MIT License
287 stars 205 forks source link

fix: allow either boolean value for nonParticipation offline keyregs #866

Closed joe-p closed 7 months ago

joe-p commented 7 months ago

Fixes a bug in the typing that would make the user think they need to set nonParticipation to true.

Also removed nonParticipation: true from the example file.

Current behavior

  algosdk.makeKeyRegistrationTxnWithSuggestedParams(
    addr,
    undefined,
    undefined,
    undefined,
    undefined,
    undefined,
    undefined,
    suggestedParams,
    undefined,
    false,
    undefined
  )
No overload matches this call.
  Overload 1 of 2, '(from: string, note: Uint8Array | undefined, voteKey: string | Uint8Array, selectionKey: string | Uint8Array, voteFirst: number, voteLast: number, voteKeyDilution: number, suggestedParams: SuggestedParams, rekeyTo?: string | undefined, nonParticipation?: false | undefined, stateProofKey?: string | ... 1 more ... | undefined): Transaction', gave the following error.
    Argument of type 'undefined' is not assignable to parameter of type 'string | Uint8Array'.
  Overload 2 of 2, '(from: string, note: Uint8Array | undefined, voteKey: undefined, selectionKey: undefined, voteFirst: undefined, voteLast: undefined, voteKeyDilution: undefined, suggestedParams: SuggestedParams, rekeyTo?: string | undefined, nonParticipation?: true | undefined, stateProofKey?: undefined): Transaction', gave the following error.
    Argument of type 'false' is not assignable to parameter of type 'true'.ts(2769)
makeTxn.ts(141, 17): The call would have succeeded against this implementation, but implementation signatures of overloads are not externally visible.

New Behavior

  algosdk.makeKeyRegistrationTxnWithSuggestedParams(
    addr,
    undefined,
    undefined,
    undefined,
    undefined,
    undefined,
    undefined,
    suggestedParams,
    undefined,
    false,
    undefined
  )

No error displayed