Skip to content

Conversation

Pauan
Copy link
Collaborator

@Pauan Pauan commented May 2, 2025

As the methods have become more complex, they've gotten a lot of arguments.

This PR refactors them to use an object instead of arguments.

Old:

await programManager.run(credits, "transfer_private", [statePathRecord, beaconAddressString, "5u64"], true, undefined, undefined, undefined, undefined, undefined, offlineQuery);

New:

await programManager.run({
    program: credits,
    functionName: "transfer_private",
    inputs: [statePathRecord, beaconAddressString, "5u64"],
    proveExecution: true,
    offlineQuery: offlineQuery,
});

This has a few benefits:

  • Because it's using named fields on an object, it's now clearer what it is doing.
  • You no longer need to pass in undefined for fields that you aren't using.
  • It is much easier for us to add new fields to a method in the future, in a backwards-compatible way.

These are the APIs that have been changed:

  • Account
    • fromCiphertext
    • verify
  • WorkerAPI
    • run
  • FunctionKeyProvider
    • fetchRemoteKeys
    • fetchProvingKey
  • OfflineKeyProvider
    • verifyCreditsKeys
  • AleoNetworkClient
    • constructor
    • findRecords
    • findUnspentRecords
    • getProgramMappingValue
    • getProgramMappingPlaintext
    • waitForTransactionConfirmation
    • getBlockRange
  • ProgramManager
    • constructor
    • checkFee
    • buildDeploymentTransaction
    • deploy
    • run
    • join
    • split
    • synthesizeKeys
    • buildTransferTransaction
    • buildTransferPublicTransaction
    • buildTransferPublicAsSignerTransaction
    • transfer
    • buildBondPublicTransaction
    • bondPublic
    • buildBondValidatorTransaction
    • bondValidator
    • buildUnbondPublicTransaction
    • unbondPublic
    • buildClaimUnbondPublicTransaction
    • claimUnbondPublic
    • buildSetValidatorStateTransaction
    • setValidatorState
    • verifyExecution
    • getCreditsRecord
  • NetworkRecordProvider
    • constructor
    • findCreditsRecords
    • findCreditsRecord
    • findRecord
    • findRecords
  • BlockHeightSearch
    • constructor

@Pauan Pauan marked this pull request as draft May 3, 2025 21:22
@Pauan Pauan marked this pull request as ready for review May 4, 2025 23:50
Copy link
Member

@iamalwaysuncomfortable iamalwaysuncomfortable left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been on the list to do, I'll ensure this gets proper review shortly.

@Pauan Pauan force-pushed the feat/object-params branch from 42eab92 to eb3e621 Compare August 2, 2025 02:13
@Pauan Pauan force-pushed the feat/object-params branch 2 times, most recently from 50c76b5 to d5191d1 Compare August 16, 2025 22:03
@Pauan Pauan force-pushed the feat/object-params branch from d9c075a to cf02148 Compare August 24, 2025 17:14
@Pauan Pauan force-pushed the feat/object-params branch from 99c2314 to 185e647 Compare August 31, 2025 17:10
@Pauan Pauan force-pushed the feat/object-params branch from 185e647 to 45d498e Compare September 7, 2025 17:19
…ForTransactionConfirmation to use object params
* ProgramManager
* checkFee
* buildDeploymentTransaction
* deploy
* run
* join
* split
* synthesizeKeys
* buildTransferTransaction
* buildTransferPublicTransaction
* buildTransferPublicAsSignerTransaction
* transfer
* buildBondPublicTransaction
* bondPublic
* buildBondValidatorTransaction
* bondValidator
* buildUnbondPublicTransaction
* unbondPublic
* buildClaimUnbondPublicTransaction
* claimUnbondPublic
* buildSetValidatorStateTransaction
* setValidatorState
* verifyExecution
* getCreditsRecord
* findCreditsRecords
* findCreditsRecord
* findRecord
* findRecords
* BlockHeightSearch
@Pauan Pauan force-pushed the feat/object-params branch from 45d498e to aaf9bfe Compare September 15, 2025 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants