warp-contracts / warp

An implementation of the Arweave SmartWeave smart contracts protocol.
MIT License
159 stars 44 forks source link

[FEATURE] - support sortKey or blockHeight in `viewState` #504

Closed dtfiedler closed 9 months ago

dtfiedler commented 10 months ago

Is your feature request related to a problem? Please describe. The current docs suggest viewState supports sortKey/blockHeight, but it is not a provided param on the SDK

    /**
     * Returns the "view" of the state, computed by the SWC -
     * i.e. object that is a derivative of a current state and some specific
     * smart contract business logic.
     * Similar to the "interactRead" from the current SDK version.
     *
     * This method firstly evaluates the contract state to the requested block height.
     * Having the contract state on this block height - it then calls the contract's code
     * with specified input.
     *
     * @param input - the input to the contract - eg. function name and parameters
     * @param tags - a set of tags that can be added to the interaction transaction
     * @param transfer - additional {@link ArTransfer} data that can be attached to the interaction
     * @param caller - caller of the view state operation
     * transaction
     */
    viewState<Input = unknown, View = unknown>(input: Input, tags?: Tags, transfer?: ArTransfer, caller?: string, signal?: AbortSignal): Promise<InteractionResult<State, View>>;

Describe the solution you'd like Support sortKey and/or blockHeight when calling viewState.

e.g.

const readInteractionResult = await contract.viewState(
  {
    function: functionName,
    ...input,
  },
  sortKey, // or blockHeight
);
ppedziwiatr commented 9 months ago

added in 1.4.31