Skip to content

Commit

Permalink
ALL-2694 Add Eos
Browse files Browse the repository at this point in the history
  • Loading branch information
Hathoriel committed Sep 26, 2023
1 parent 39d67e9 commit ac709cf
Showing 1 changed file with 141 additions and 20 deletions.
161 changes: 141 additions & 20 deletions src/dto/rpc/EosRpcSuite.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { BigNumber } from 'bignumber.js'
import { AbstractRpcInterface } from './AbstractJsonRpcInterface'

interface GetProducersI {
interface GetProducers {
json?: boolean
lowerBound?: string
limit?: number
Expand All @@ -19,14 +18,17 @@ interface Action {

// Definition for Authority
interface Authority {
// Fill in the fields for Authority based on your needs
actor: 'NamePrivileged' | 'NameBasic' | 'NameBid' | 'NameCatchAll'
permission: 'NamePrivileged' | 'NameBasic' | 'NameBid' | 'NameCatchAll'
}

// Definition for Extension
type Extension = Array<number | string>

type PublicKeys = string[]

// Main Transaction interface
interface TransactionI {
interface Transaction {
expiration: string // DateTime in string format
refBlockNum: number
refBlockPrefix: number
Expand All @@ -35,33 +37,152 @@ interface TransactionI {
delaySec: number
contextFreeActions: Action[]
actions: Action[]
transactionExtensions: Extension[]
transactionExtensions?: Extension[]
}

interface GetRequiredKeys {
transaction: Transaction
availableKeys: PublicKeys
}

interface PushTransaction {
signatures: string[]
compression: boolean
packedContextFreeData: string
packedTrx: string
}

interface BlockNumOrId {
blockNumOrId: string
}

interface BlockNum {
blockNum: number
}

interface AccountName {
accountName: string
}

interface GetCurrencyBalance {
code: string
account: string
symbol: string
}

interface GetRequiredKeysI {
transaction: TransactionI
availableKeys: string[]
interface GetCurrencyStats {
code: string
symbol: string
}

export interface EosRpcSuite extends AbstractRpcInterface {
/**
* Validates a Tron address.
* Returns an object containing various details about a specific account on the blockchain.
*
* @param body - The name of the account to retrieve.
* @return {Promise<any>} - A promise that resolves with the account information.
* https://developers.eos.io/manuals/eos/v2.2/nodeos/plugins/chain_api_plugin/api-reference/index#operation/get_account
*/
getAccount(body: AccountName): Promise<any>

/**
* Returns an object containing various details about a specific block on the blockchain.
*
* @param body - The number or ID of the block to retrieve.
* @return {Promise<any>} - A promise that resolves with the block information.
* https://developers.eos.io/manuals/eos/v2.2/nodeos/plugins/chain_api_plugin/api-reference/index#operation/get_block
*/
getBlock(body: BlockNumOrId): Promise<any>

/**
* Similar to get_block but returns a fixed-size smaller subset of the block data.
*
* @param body - The number or ID of the block to retrieve.
* @return {Promise<any>} - A promise that resolves with the block information.
* https://developers.eos.io/manuals/eos/v2.2/nodeos/plugins/chain_api_plugin/api-reference/index#operation/get_block_info
*/
getBlockInfo(body: BlockNum): Promise<any>

/**
* Returns an object containing various details about the blockchain.
*
* @param {string} address - The Tron address to be validated.
* @param {VisibleOption} [options] - The options for validation.
* @returns {Promise<any>} - Returns a Promise that resolves with validation result.
* https://docs.tatum.com/docs/rpc-api-reference/tron-rpc-documentation/api-calls-for-address-utility-methods/validateaddress
* @return {Promise<any>} - A promise that resolves with the blockchain information.
* https://developers.eos.io/manuals/eos/v2.2/nodeos/plugins/chain_api_plugin/api-reference/index#operation/get_info
*/
validateAddress(address: string, options?: VisibleOption): Promise<any>
getInfo(): Promise<any>

/**
* Broadcasts a raw Tron transaction.
* This method expects a transaction in JSON format and will attempt to apply it to the blockchain.
* @param body - The transaction to push.
* @return {Promise<any>} - Returns nothing on success.
* https://developers.eos.io/manuals/eos/v2.2/nodeos/plugins/chain_api_plugin/api-reference/index#operation/push_transaction
*/
pushTransaction(body: PushTransaction): Promise<any>

/**
* This method expects a transaction in JSON format and will attempt to apply it to the blockchain.
* @param body - The transaction to push.
* @return {Promise<any>} - Returns nothing on success.
* https://developers.eos.io/manuals/eos/v2.2/nodeos/plugins/chain_api_plugin/api-reference/index#operation/send_transaction
*/
sendTransaction(body: PushTransaction): Promise<any>

/**
* This method expects a transaction in JSON format and will attempt to apply it to the blockchain.
* @param transactions
* @return {Promise<any>} - Returns nothing on success.
* https://developers.eos.io/manuals/eos/v2.2/nodeos/plugins/chain_api_plugin/api-reference/index#operation/push_transactions
*/
pushTransactions(transactions: Transaction[]): Promise<any>

/**
* Retrieves the block header state
*
* @param body - The block number or ID to retrieve.
* @return {Promise<any>} - block header state
* https://developers.eos.io/manuals/eos/v2.2/nodeos/plugins/chain_api_plugin/api-reference/index#operation/get_block_header_state
*/
getBlockHeaderState(body: BlockNumOrId): Promise<any>

/**
* Retrieves the ABI for a contract based on its account name
*
* @param {TronTxRawBody} rawBody - The raw body of the transaction to be broadcasted.
* @returns {Promise<any>} - Returns a Promise that resolves with the broadcast result.
* https://docs.tatum.com/docs/rpc-api-reference/tron-rpc-documentation/api-calls-for-transaction-methods/broadcasttransaction
* @param body - The account name to retrieve the ABI for.
* @return {Promise<any>} - ABI for a contract
* https://developers.eos.io/manuals/eos/v2.2/nodeos/plugins/chain_api_plugin/api-reference/index#operation/get_abi
*/
broadcastTransaction(rawBody: TronTxRawBody): Promise<any>
getAbi(body: AccountName): Promise<any>

getProducers(body: GetProducersI): Promise<any>
/**
* Retrieves the current balance
*
* @param body - The currency balance to retrieve.
* @return {Promise<any>} - current balance
* https://developers.eos.io/manuals/eos/v2.2/nodeos/plugins/chain_api_plugin/api-reference/index#operation/get_currency_balance
*/
getCurrencyBalance(body: GetCurrencyBalance): Promise<any>

/**
* Retrieves currency stats
* @param body - The currency stats to retrieve.
* @return {Promise<any>} - currency stats
* https://developers.eos.io/manuals/eos/v2.2/nodeos/plugins/chain_api_plugin/api-reference/index#operation/get_currency_stats
*/
getCurrencyStats(body: GetCurrencyStats): Promise<any>

/**
* Returns the required keys needed to sign a transaction.
* @param body - The transaction to retrieve required keys for.
* @return {Promise<any>} - required keys
* https://developers.eos.io/manuals/eos/v2.2/nodeos/plugins/chain_api_plugin/api-reference/index#operation/get_required_keys
*/
getRequiredKeys(body: GetRequiredKeys): Promise<any>

/**
* Retrieves producers list
* @param body - The producers list to retrieve.
* @return {Promise<any>} - producers list
* https://developers.eos.io/manuals/eos/v2.2/nodeos/plugins/chain_api_plugin/api-reference/index#operation/get_producers
*/
getProducers(body: GetProducers): Promise<any>
}

0 comments on commit ac709cf

Please sign in to comment.