Skip to content

Commit

Permalink
ALL-3134 Update Tezos methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Hathoriel committed Nov 2, 2023
1 parent 18da3ab commit c2a16b5
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 24 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [4.1.22] - 2023.11.2
### Updated
- Naming of the Tezos RPC methods

## [4.1.21] - 2023.11.2
### Added
- Added RPC support for the TEZOS network. Users can now make RPC calls to these network using the `Network.TEZOS` network.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tatumio/tatum",
"version": "4.1.21",
"version": "4.1.22",
"description": "Tatum JS SDK",
"author": "Tatum",
"repository": "https://github.com/tatumio/tatum-js",
Expand Down
22 changes: 12 additions & 10 deletions src/dto/rpc/TezosRpcSuite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface GetContractBase extends GetBlock {
contractId: string
}

export interface GetContractsBigMapGet extends GetContractBase {
export interface GetContractBigMapValue extends GetContractBase {
key: any
type: any
}
Expand Down Expand Up @@ -78,25 +78,27 @@ export interface TezosRpcInterface {

getBlockHashes(params: GetBlockHashes): Promise<any>

getContracts(params: GetContract): Promise<any>
getContract(params: GetContract): Promise<any>

getContractsTickets(params: GetContractBase): Promise<any>
getContractTickets(params: GetContractBase): Promise<any>

getContractsBalance(params: GetContractBase): Promise<any>
getContractBalance(params: GetContractBase): Promise<any>

getContractsBalanceAndFrozenBonds(params: GetContractBase): Promise<any>
getContractBalanceAndFrozenBonds(params: GetContractBase): Promise<any>

getContractsBigMapGet(params: GetContractsBigMapGet): Promise<any>
getContractBigMapValue(params: GetContractBigMapValue): Promise<any>

getContractsCounter(params: GetContractBase): Promise<any>
getContractCounter(params: GetContractBase): Promise<any>

getContractDelegate(params: GetContractBase): Promise<any>

getContractsEntrypoints(params: GetContract): Promise<any>
getContractEntrypoints(params: GetContract): Promise<any>

getContractsEntrypoint(params: GetContractsEntrypoints): Promise<any>
getContractEntrypoint(params: GetContractsEntrypoints): Promise<any>

getContractsManagerKey(params: GetContractBase): Promise<any>
getContractManagerKey(params: GetContractBase): Promise<any>

getContracts(params: GetBlock): Promise<any>

getBlock(params: GetBlock): Promise<any>

Expand Down
6 changes: 3 additions & 3 deletions src/e2e/rpc/other/tatum.rpc.tezos.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const getTezosRpc = async (testnet?: boolean) =>
if (!testnet) {
it('getContract', async () => {
const tatum = await getTezosRpc(testnet)
const result = await tatum.rpc.getContracts({
const result = await tatum.rpc.getContract({
chainId: 'main',
contractId: 'KT1Hkg5qeNhfwpKW4fXvq7HGZB9z2EnmCCA9',
block: '3000000'
Expand All @@ -49,7 +49,7 @@ const getTezosRpc = async (testnet?: boolean) =>

it('getContractBalanceAndFrozenBonds', async () => {
const tatum = await getTezosRpc(testnet)
const result = await tatum.rpc.getContractsBalanceAndFrozenBonds({
const result = await tatum.rpc.getContractBalanceAndFrozenBonds({
chainId: 'main',
contractId: 'KT1Hkg5qeNhfwpKW4fXvq7HGZB9z2EnmCCA9',
block: '3000000'
Expand All @@ -60,7 +60,7 @@ const getTezosRpc = async (testnet?: boolean) =>

it('getContractsEntrypoints', async () => {
const tatum = await getTezosRpc(testnet)
const result = await tatum.rpc.getContractsEntrypoints({
const result = await tatum.rpc.getContractEntrypoints({
chainId: 'main',
contractId: 'KT1Hkg5qeNhfwpKW4fXvq7HGZB9z2EnmCCA9',
block: '3000000'
Expand Down
25 changes: 15 additions & 10 deletions src/service/rpc/other/AbstractTezosRpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
GetChainId,
GetContract,
GetContractBase,
GetContractsBigMapGet,
GetContractBigMapValue,
GetContractsEntrypoints,
GetInvalidBlocks,
GetProtocol, InjectBlock,
Expand Down Expand Up @@ -116,51 +116,56 @@ export abstract class AbstractTezosRpc implements TezosRpcInterface {
return this.sendGet({ path: `/chains/${chainId}/blocks/${block}/context/contracts/${contractId}/delegate`})
}

getContracts(params: GetContract): Promise<any> {
getContract(params: GetContract): Promise<any> {
const { chainId, contractId, block, ...rest } = params
return this.sendGet({ path: `/chains/${chainId}/blocks/${block}/context/contracts/${contractId}`, queryParams: rest })
}

getContractsBalance(params: GetContractBase): Promise<any> {
getContractBalance(params: GetContractBase): Promise<any> {
const { chainId, block, contractId } = params
return this.sendGet({ path: `/chains/${chainId}/blocks/${block}/context/contracts/${contractId}/balance`})
}

getContractsBalanceAndFrozenBonds(params: GetContractBase): Promise<any> {
getContractBalanceAndFrozenBonds(params: GetContractBase): Promise<any> {
const { chainId, block, contractId } = params
return this.sendGet({ path: `/chains/${chainId}/blocks/${block}/context/contracts/${contractId}/balance_and_frozen_bonds`})
}

getContractsBigMapGet(params: GetContractsBigMapGet): Promise<any> {
getContractBigMapValue(params: GetContractBigMapValue): Promise<any> {
const { chainId, block, contractId, ...rest } = params
return this.sendPost({ path: `/chains/${chainId}/blocks/${block}/context/contracts/${contractId}/big_map_get`, body: rest })
}

getContractsCounter(params: GetContractBase): Promise<any> {
getContractCounter(params: GetContractBase): Promise<any> {
const { chainId, block, contractId} = params
return this.sendGet({ path: `/chains/${chainId}/blocks/${block}/context/contracts/${contractId}/counter`})
}

getContractsEntrypoint(params: GetContractsEntrypoints): Promise<any> {
getContractEntrypoint(params: GetContractsEntrypoints): Promise<any> {
const { chainId, block, contractId, entrypoint, ...rest} = params
return this.sendGet({ path: `/chains/${chainId}/blocks/${block}/context/contracts/${contractId}/entrypoints/${entrypoint}`, queryParams: rest })
}

getContractsEntrypoints(params: GetContract): Promise<any> {
getContractEntrypoints(params: GetContract): Promise<any> {
const { chainId, block, contractId, ...rest} = params
return this.sendGet({ path: `/chains/${chainId}/blocks/${block}/context/contracts/${contractId}/entrypoints`, queryParams: rest })
}

getContractsManagerKey(params: GetContractBase): Promise<any> {
getContractManagerKey(params: GetContractBase): Promise<any> {
const { chainId, block, contractId} = params
return this.sendGet({ path: `/chains/${chainId}/blocks/${block}/context/contracts/${contractId}/manager_key`})
}

getContractsTickets(params: GetContractBase): Promise<any> {
getContractTickets(params: GetContractBase): Promise<any> {
const { chainId, block, contractId} = params
return this.sendGet({ path: `/chains/${chainId}/blocks/${block}/context/contracts/${contractId}/all_ticket_balances` })
}

getContracts(params: GetBlock): Promise<any> {
const { chainId, block } = params
return this.sendGet({ path: `/chains/${chainId}/blocks/${block}/context/contracts`})
}

getErrorsSchema(): Promise<any> {
return this.sendGet({ path: `/errors/` })
}
Expand Down

0 comments on commit c2a16b5

Please sign in to comment.