Skip to content

Commit

Permalink
add deferred calls endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
modship committed Jan 20, 2025
1 parent dc6018c commit de76ef9
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 13 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"build-esm": "tsc --project tsconfig.esm.json",
"build-commonjs": "tsc --project tsconfig.commonjs.json",
"build": "npm-run-all clean-dist build-*",
"generate:types": "npx open-rpc-typings --output-ts src/generated --name-ts client-types -d 'https://raw.githubusercontent.com/massalabs/massa/main/massa-node/base_config/openrpc.json'",
"generate:types": "npx open-rpc-typings --output-ts src/generated --name-ts client-types -d 'https://raw.githubusercontent.com/massalabs/massa/refs/heads/mainnet_2_3/massa-node/base_config/openrpc.json'",
"generate:test": "ts-interface-builder -o test/generated src/generated/client-types.ts",
"generate:deployer": "ts-node scripts/deployerGeneration/generate-deployer.ts",
"generate": "npm-run-all generate:*",
Expand Down Expand Up @@ -107,4 +107,4 @@
"bufferutil": "^4.0.7",
"utf-8-validate": "^6.0.2"
}
}
}
23 changes: 23 additions & 0 deletions src/client/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,29 @@ export class Connector {
return this.client.request('get_staking_addresses', {})
}

/**
* Returns if slot is available and the price to book the requested gas
*/
public get_deferred_call_quote: t.GetDeferredCallQuote = (params) => {
return this.client.request('get_deferred_call_quote', params)
}

/**
* Returns information about deferred calls.
*/
public get_deferred_call_info: t.GetDeferredCallInfo = (params) => {
return this.client.request('get_deferred_call_info', params)
}

/**
* Returns ids of deferred calls for provided slots.
*/
public get_deferred_call_ids_by_slot: t.GetDeferredCallIdsBySlot = (
params
) => {
return this.client.request('get_deferred_call_ids_by_slot', params)
}

/**
* Add to bootstrap blacklist given IP addresses
*/
Expand Down
18 changes: 18 additions & 0 deletions src/client/publicAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,4 +314,22 @@ export class PublicAPI {
): Promise<t.OperationId[]> {
return this.connector.send_operations(data)
}

async deferredCallQuote(
quoteRequests: t.DeferredCallsQuoteRequest[]
): Promise<t.DeferredCallsQuoteResponse[]> {
return this.connector.get_deferred_call_quote(quoteRequests)
}

async deferredCallsInfo(
deferredCallsIds: string[]
): Promise<t.DeferredCallResponse[]> {
return this.connector.get_deferred_call_info(deferredCallsIds)
}

async deferredCallsBySlot(
slots: t.Slot[]
): Promise<t.DeferredCallsSlotResponse[]> {
return this.connector.get_deferred_call_ids_by_slot(slots)
}
}
56 changes: 53 additions & 3 deletions src/generated/client-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ export type OperationId = string;
*/
export type Error = boolean;
export type NumberHo1ClIqD = number;
export interface DeferredCallsQuoteRequest {
target_slot: Slot;
max_gas_request: NumberHo1ClIqD;
params_size: NumberHo1ClIqD;
[k: string]: any;
}
export type StringDoaGddGA = string;
/**
*
* `PrivateKey` is used for signature and decryption
Expand All @@ -151,7 +158,6 @@ export type PrivateKey = string;
*
*/
export type IpAddress = string;
export type StringDoaGddGA = string;
/**
*
* the content creator public key
Expand Down Expand Up @@ -268,6 +274,12 @@ export interface ObjectYWuwfL0B { [key: string]: any; }
*
*/
export interface ObjectTK16EAH4 { [key: string]: any; }
/**
*
* deferred call changes
*
*/
export interface Object8GtTSzoU { [key: string]: any; }
/**
*
* executed denunciation changes
Expand All @@ -289,6 +301,7 @@ export interface StateChanges {
async_pool_changes: UnorderedSetOfObjectHAgrRKSz46QV1Tyv;
pos_changes: ObjectYWuwfL0B;
executed_ops_changes: ObjectTK16EAH4;
deferred_call_changes: Object8GtTSzoU;
executed_denunciations_changes: Object413CQ8L2;
execution_trail_hash_change: ExecutionTrailHashChange;
}
Expand Down Expand Up @@ -959,6 +972,37 @@ export interface ExecutionStats {
*
*/
export type NumberBte4OVdF = number;
export interface DeferredCallsQuoteResponse {
target_slot: Slot;
max_gas_request: NumberHo1ClIqD;
available: BooleanVyG3AETh;
price: NumberHo1ClIqD;
[k: string]: any;
}
export type UnorderedSetOfNumberHo1ClIqDAokMKuEf = NumberHo1ClIqD[];
export interface DeferredCall {
sender_address: Address;
target_slot: Slot;
target_address: Address;
target_function: StringDoaGddGA;
parameters: UnorderedSetOfNumberHo1ClIqDAokMKuEf;
coins: NumberHo1ClIqD;
max_gas: NumberHo1ClIqD;
fee: NumberHo1ClIqD;
cancelled: BooleanVyG3AETh;
[k: string]: any;
}
export interface DeferredCallResponse {
call_id: StringDoaGddGA;
call: DeferredCall;
[k: string]: any;
}
export type UnorderedSetOfStringDoaGddGADvj0XlFa = StringDoaGddGA[];
export interface DeferredCallsSlotResponse {
slot?: Slot;
call_ids?: UnorderedSetOfStringDoaGddGADvj0XlFa;
[k: string]: any;
}
type AlwaysFalse = any;
export type UnorderedSetOfStakerdplIH7J8 = Staker[];
export interface ObjectOfPeriodBlockIdWrpyYBUS {
Expand Down Expand Up @@ -1018,14 +1062,14 @@ export interface ObjectOfNumberHo1ClIqDNumberHo1ClIqDTmeT75Fq {
end?: NumberHo1ClIqD;
}
export type UnorderedSetOfOperationId5TxbV4NZ = OperationId[];
export type UnorderedSetOfDeferredCallsQuoteRequestwrpyYBUS = DeferredCallsQuoteRequest[];
export type UnorderedSetOfPrivateKeyG69QLiLP = PrivateKey[];
/**
*
* Array of Ipv4 or Ipv6 address
*
*/
export type IpAddressList = IpAddress[];
export type UnorderedSetOfStringDoaGddGADvj0XlFa = StringDoaGddGA[];
export type UnorderedSetOfIpAddressiIc9WbOi = IpAddress[];
export type UnorderedSetOfOperationInputx51DfMZX = OperationInput[];
/**
Expand Down Expand Up @@ -1070,6 +1114,9 @@ export interface NodeStatus {
chain_id: NumberBte4OVdF;
minimal_fees?: Amount;
}
export type UnorderedSetOfDeferredCallsQuoteResponsewrpyYBUS = DeferredCallsQuoteResponse[];
export type UnorderedSetOfDeferredCallResponsewrpyYBUS = DeferredCallResponse[];
export type UnorderedSetOfDeferredCallsSlotResponsewrpyYBUS = DeferredCallsSlotResponse[];
/**
*
* Public key and a signature it has produced used for serialization/deserialization purpose
Expand Down Expand Up @@ -1098,7 +1145,7 @@ export interface FilledBlockInfo {
* Generated! Represents an alias to any of the provided schemas
*
*/
export type AnyOfUnorderedSetOfReadOnlyBytecodeExecutionNzcRfs8AUnorderedSetOfReadOnlyCallfpPkkjmfUnorderedSetOfAddressjJsnATCOAddressListBlockIdListSlotUnorderedSetOfDatastoreEntryInputLrTgdYH8UnorderedSetOfSlotwrpyYBUSUnorderedSetOfEndorsementIdqnHAk5M0EventFilterObjectOfNumberHo1ClIqDNumberHo1ClIqDTmeT75FqUnorderedSetOfOperationId5TxbV4NZPaginationUnorderedSetOfPrivateKeyG69QLiLPIpAddressListIpAddressListIpAddressListUnorderedSetOfStringDoaGddGADvj0XlFaIpAddressListIpAddressListIpAddressListIpAddressListIpAddressListUnorderedSetOfAddressjJsnATCOBytesUnorderedSetOfIpAddressiIc9WbOiIpAddressListIpAddressListUnorderedSetOfOperationInputx51DfMZXApiRequestInteger2AHOqbcQInteger2AHOqbcQInteger2AHOqbcQInteger2AHOqbcQUnorderedSetOfExecuteReadOnlyResponsewrpyYBUSUnorderedSetOfExecuteReadOnlyResponsewrpyYBUSUnorderedSetOfAddressInfowrpyYBUSBytecodeListUnorderedSetOfBlockInfowrpyYBUSBlockUnorderedSetOfCliqueMz9JAAOVUnorderedSetOfDatastoreEntryOutputgBhWTzxIUnorderedSetOfUnorderedSetOfTransferReceiptzpyvh8AYeEDRSdp7UnorderedSetOfEndorsementInfowrpyYBUSOutputEventsUnorderedSetOfGraphIntervalwrpyYBUSUnorderedSetOfOperationInfowrpyYBUSUnorderedSetOfStakerdplIH7J8NodeStatusAlwaysFalseUnorderedSetOfAddressjJsnATCOAlwaysFalseAlwaysFalseAlwaysFalseAlwaysFalseAlwaysFalseIpAddressListIpAddressListAlwaysFalseIpAddressListAlwaysFalseAlwaysFalseAlwaysFalseAlwaysFalseAlwaysFalsePubkeySigAlwaysFalseAlwaysFalseAlwaysFalseAlwaysFalseUnorderedSetOfOperationId5TxbV4NZPagedVecStakerUnorderedSetOfBlockParentwrpyYBUSVersionBlockInfoWrappedHeaderFilledBlockInfoOperationBooleanVyG3AEThBooleanVyG3AEThBooleanVyG3AEThBooleanVyG3AETh = UnorderedSetOfReadOnlyBytecodeExecutionNzcRfs8A | UnorderedSetOfReadOnlyCallfpPkkjmf | UnorderedSetOfAddressjJsnATCO | AddressList | BlockIdList | Slot | UnorderedSetOfDatastoreEntryInputLrTgdYH8 | UnorderedSetOfSlotwrpyYBUS | UnorderedSetOfEndorsementIdqnHAk5M0 | EventFilter | ObjectOfNumberHo1ClIqDNumberHo1ClIqDTmeT75Fq | UnorderedSetOfOperationId5TxbV4NZ | Pagination | UnorderedSetOfPrivateKeyG69QLiLP | IpAddressList | UnorderedSetOfStringDoaGddGADvj0XlFa | Bytes | UnorderedSetOfIpAddressiIc9WbOi | UnorderedSetOfOperationInputx51DfMZX | ApiRequest | Integer2AHOqbcQ | UnorderedSetOfExecuteReadOnlyResponsewrpyYBUS | UnorderedSetOfAddressInfowrpyYBUS | BytecodeList | UnorderedSetOfBlockInfowrpyYBUS | Block | UnorderedSetOfCliqueMz9JAAOV | UnorderedSetOfDatastoreEntryOutputgBhWTzxI | UnorderedSetOfUnorderedSetOfTransferReceiptzpyvh8AYeEDRSdp7 | UnorderedSetOfEndorsementInfowrpyYBUS | OutputEvents | UnorderedSetOfGraphIntervalwrpyYBUS | UnorderedSetOfOperationInfowrpyYBUS | UnorderedSetOfStakerdplIH7J8 | NodeStatus | AlwaysFalse | PubkeySig | PagedVecStaker | UnorderedSetOfBlockParentwrpyYBUS | Version | BlockInfo | WrappedHeader | FilledBlockInfo | Operation | BooleanVyG3AETh;
export type AnyOfUnorderedSetOfReadOnlyBytecodeExecutionNzcRfs8AUnorderedSetOfReadOnlyCallfpPkkjmfUnorderedSetOfAddressjJsnATCOAddressListBlockIdListSlotUnorderedSetOfDatastoreEntryInputLrTgdYH8UnorderedSetOfSlotwrpyYBUSUnorderedSetOfEndorsementIdqnHAk5M0EventFilterObjectOfNumberHo1ClIqDNumberHo1ClIqDTmeT75FqUnorderedSetOfOperationId5TxbV4NZPaginationUnorderedSetOfDeferredCallsQuoteRequestwrpyYBUSUnorderedSetOfStringDoaGddGADvj0XlFaUnorderedSetOfSlotwrpyYBUSUnorderedSetOfPrivateKeyG69QLiLPIpAddressListIpAddressListIpAddressListUnorderedSetOfStringDoaGddGADvj0XlFaIpAddressListIpAddressListIpAddressListIpAddressListIpAddressListUnorderedSetOfAddressjJsnATCOBytesUnorderedSetOfIpAddressiIc9WbOiIpAddressListIpAddressListUnorderedSetOfOperationInputx51DfMZXApiRequestInteger2AHOqbcQInteger2AHOqbcQInteger2AHOqbcQInteger2AHOqbcQUnorderedSetOfExecuteReadOnlyResponsewrpyYBUSUnorderedSetOfExecuteReadOnlyResponsewrpyYBUSUnorderedSetOfAddressInfowrpyYBUSBytecodeListUnorderedSetOfBlockInfowrpyYBUSBlockUnorderedSetOfCliqueMz9JAAOVUnorderedSetOfDatastoreEntryOutputgBhWTzxIUnorderedSetOfUnorderedSetOfTransferReceiptzpyvh8AYeEDRSdp7UnorderedSetOfEndorsementInfowrpyYBUSOutputEventsUnorderedSetOfGraphIntervalwrpyYBUSUnorderedSetOfOperationInfowrpyYBUSUnorderedSetOfStakerdplIH7J8NodeStatusUnorderedSetOfDeferredCallsQuoteResponsewrpyYBUSUnorderedSetOfDeferredCallResponsewrpyYBUSUnorderedSetOfDeferredCallsSlotResponsewrpyYBUSAlwaysFalseUnorderedSetOfAddressjJsnATCOAlwaysFalseAlwaysFalseAlwaysFalseAlwaysFalseAlwaysFalseIpAddressListIpAddressListAlwaysFalseIpAddressListAlwaysFalseAlwaysFalseAlwaysFalseAlwaysFalseAlwaysFalsePubkeySigAlwaysFalseAlwaysFalseAlwaysFalseAlwaysFalseUnorderedSetOfOperationId5TxbV4NZPagedVecStakerUnorderedSetOfBlockParentwrpyYBUSVersionBlockInfoWrappedHeaderFilledBlockInfoOperationBooleanVyG3AEThBooleanVyG3AEThBooleanVyG3AEThBooleanVyG3AETh = UnorderedSetOfReadOnlyBytecodeExecutionNzcRfs8A | UnorderedSetOfReadOnlyCallfpPkkjmf | UnorderedSetOfAddressjJsnATCO | AddressList | BlockIdList | Slot | UnorderedSetOfDatastoreEntryInputLrTgdYH8 | UnorderedSetOfSlotwrpyYBUS | UnorderedSetOfEndorsementIdqnHAk5M0 | EventFilter | ObjectOfNumberHo1ClIqDNumberHo1ClIqDTmeT75Fq | UnorderedSetOfOperationId5TxbV4NZ | Pagination | UnorderedSetOfDeferredCallsQuoteRequestwrpyYBUS | UnorderedSetOfStringDoaGddGADvj0XlFa | UnorderedSetOfPrivateKeyG69QLiLP | IpAddressList | Bytes | UnorderedSetOfIpAddressiIc9WbOi | UnorderedSetOfOperationInputx51DfMZX | ApiRequest | Integer2AHOqbcQ | UnorderedSetOfExecuteReadOnlyResponsewrpyYBUS | UnorderedSetOfAddressInfowrpyYBUS | BytecodeList | UnorderedSetOfBlockInfowrpyYBUS | Block | UnorderedSetOfCliqueMz9JAAOV | UnorderedSetOfDatastoreEntryOutputgBhWTzxI | UnorderedSetOfUnorderedSetOfTransferReceiptzpyvh8AYeEDRSdp7 | UnorderedSetOfEndorsementInfowrpyYBUS | OutputEvents | UnorderedSetOfGraphIntervalwrpyYBUS | UnorderedSetOfOperationInfowrpyYBUS | UnorderedSetOfStakerdplIH7J8 | NodeStatus | UnorderedSetOfDeferredCallsQuoteResponsewrpyYBUS | UnorderedSetOfDeferredCallResponsewrpyYBUS | UnorderedSetOfDeferredCallsSlotResponsewrpyYBUS | AlwaysFalse | PubkeySig | PagedVecStaker | UnorderedSetOfBlockParentwrpyYBUS | Version | BlockInfo | WrappedHeader | FilledBlockInfo | Operation | BooleanVyG3AETh;
export type ExecuteReadOnlyBytecode = (ReadOnlyBytecodeExecution: UnorderedSetOfReadOnlyBytecodeExecutionNzcRfs8A) => Promise<UnorderedSetOfExecuteReadOnlyResponsewrpyYBUS>;
export type ExecuteReadOnlyCall = (ReadOnlyCall: UnorderedSetOfReadOnlyCallfpPkkjmf) => Promise<UnorderedSetOfExecuteReadOnlyResponsewrpyYBUS>;
export type GetAddresses = (address: UnorderedSetOfAddressjJsnATCO) => Promise<UnorderedSetOfAddressInfowrpyYBUS>;
Expand All @@ -1114,6 +1161,9 @@ export type GetGraphInterval = (TimeInterval: ObjectOfNumberHo1ClIqDNumberHo1ClI
export type GetOperations = (operationId: UnorderedSetOfOperationId5TxbV4NZ) => Promise<UnorderedSetOfOperationInfowrpyYBUS>;
export type GetStakers = (PageRequest: Pagination) => Promise<UnorderedSetOfStakerdplIH7J8>;
export type GetStatus = () => Promise<NodeStatus>;
export type GetDeferredCallQuote = (req: UnorderedSetOfDeferredCallsQuoteRequestwrpyYBUS) => Promise<UnorderedSetOfDeferredCallsQuoteResponsewrpyYBUS>;
export type GetDeferredCallInfo = (arg: UnorderedSetOfStringDoaGddGADvj0XlFa) => Promise<UnorderedSetOfDeferredCallResponsewrpyYBUS>;
export type GetDeferredCallIdsBySlot = (slots: UnorderedSetOfSlotwrpyYBUS) => Promise<UnorderedSetOfDeferredCallsSlotResponsewrpyYBUS>;
export type AddStakingSecretKeys = (SecretKeys: UnorderedSetOfPrivateKeyG69QLiLP) => Promise<AlwaysFalse>;
export type GetStakingAddresses = () => Promise<UnorderedSetOfAddressjJsnATCO>;
export type NodeAddToBootstrapBlacklist = (ip: IpAddressList) => Promise<AlwaysFalse>;
Expand Down
Loading

0 comments on commit de76ef9

Please sign in to comment.