Skip to content

Commit

Permalink
extract keyword argument types into a single type
Browse files Browse the repository at this point in the history
  • Loading branch information
bjornkihlberg committed Oct 19, 2023
1 parent 0f861c9 commit 4890be9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ import { DecodingError } from "@marlowe.io/adapter/codec";
import { ISO8601 } from "@marlowe.io/adapter/time";

import {
AddressBech32,
AddressesAndCollaterals,
Metadata,
TagsGuard,
TextEnvelopeGuard,
TxId,
TxOutRef,
unAddressBech32,
unTxOutRef,
} from "@marlowe.io/runtime-core";
Expand All @@ -33,6 +35,7 @@ import {
unContractId,
} from "@marlowe.io/runtime-core";
import { assertGuardEqual, proxy } from "@marlowe.io/adapter/io-ts";
import { Input } from "@marlowe.io/language-core-v1";

/**
* A transaction range provides pagination options for the {@link index.RestAPI#getTransactionsForContract | Get transactions for contract } endpoint
Expand Down Expand Up @@ -129,6 +132,19 @@ export const TransactionTextEnvelope = t.type({
tx: TextEnvelopeGuard,
});

export type ApplyInputsToContractRequest = {
contractId: ContractId;
changeAddress: AddressBech32;
usedAddresses?: AddressBech32[];
collateralUTxOs?: TxOutRef[];
invalidBefore?: string;
invalidHereafter?: string;
version?: "v1";
metadata?: { [label: string | number]: any };
tags?: { [tag: string]: any };
inputs: Input[];
};

export type POST = (
contractId: ContractId,
postTransactionsRequest: PostTransactionsRequest,
Expand Down
18 changes: 3 additions & 15 deletions packages/runtime/client/rest/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,10 @@ import {
TextEnvelope,
TxId,
HexTransactionWitnessSet,
AddressBech32,
TxOutRef,
} from "@marlowe.io/runtime-core";
import { submitContractViaAxios } from "./contract/endpoints/singleton.js";
import { ContractDetails } from "./contract/details.js";
import { TransactionDetails } from "./contract/transaction/details.js";
import { Input } from "@marlowe.io/language-core-v1";
// import curlirize from 'axios-curlirize';

// TODO: DELETE
Expand Down Expand Up @@ -125,18 +122,9 @@ export interface RestAPI {
* Create an unsigned transaction which applies inputs to a contract.
* @see {@link https://docs.marlowe.iohk.io/api/apply-inputs-to-contract}
*/
applyInputsToContract(request: {
contractId: ContractId;
changeAddress: AddressBech32;
usedAddresses?: AddressBech32[];
collateralUTxOs?: TxOutRef[];
invalidBefore?: string;
invalidHereafter?: string;
version?: "v1";
metadata?: { [label: string | number]: any };
tags?: { [tag: string]: any };
inputs: Input[];
}): Promise<Transactions.TransactionTextEnvelope>;
applyInputsToContract(
request: Transactions.ApplyInputsToContractRequest
): Promise<Transactions.TransactionTextEnvelope>;
// getTransactionById: Transaction.GET; // - https://docs.marlowe.iohk.io/api/get-transaction-by-id
/**
* Submit a signed transaction (generated with {@link @marlowe.io/runtime/client/rest!index.RestAPI.html#applyInputsToContract} and signed with the {@link @marlowe.io/wallet!api.WalletAPI#signTx} procedure) that applies inputs to a contract.
Expand Down

0 comments on commit 4890be9

Please sign in to comment.