Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/types/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export interface ContractMethod extends ContractMethodBase {
ret: ContractParamsSchema;
readonly: boolean;
payable?: boolean;
min_gas_leader?: number;
min_gas_validator?: number;
}

export type ContractSchema = {
Expand Down
39 changes: 39 additions & 0 deletions tests/client.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {createClient} from "../src/client/client";
import {localnet} from "@/chains/localnet";
import {createAccount, generatePrivateKey} from "../src/accounts/account";
import {TransactionHash, TransactionStatus} from "../src/types/transactions";
import type {ContractSchema} from "@/types/contracts";

test("type checks", () => {
const client = createClient({
Expand Down Expand Up @@ -46,6 +47,44 @@ test("type checks", () => {

void client.getContractSchemaForCode("class SomeContract...");

const schemaWithMinGas: ContractSchema = {
ctor: {
params: [],
kwparams: {},
},
methods: {
update: {
params: [],
kwparams: {},
ret: "null",
readonly: false,
min_gas_leader: 100,
min_gas_validator: 20,
},
},
};

const schemaWithoutMinGas: ContractSchema = {
ctor: {
params: [],
kwparams: {},
},
methods: {
update: {
params: [],
kwparams: {},
ret: "null",
readonly: false,
},
},
};

const minGasLeader: number | undefined = schemaWithMinGas.methods.update.min_gas_leader;
const minGasValidator: number | undefined = schemaWithMinGas.methods.update.min_gas_validator;
void minGasLeader;
void minGasValidator;
void schemaWithoutMinGas;

// Existing consumer-facing active-validator methods remain available, and
// the append-only joined registry is an explicitly named separate read.
void client.getActiveValidators();
Expand Down