Skip to content

Commit

Permalink
ALL-3495 - Add getBlockByNumber to possible archive list (#1027)
Browse files Browse the repository at this point in the history
* ALL-3495 - Add getBlockByNumber to possible archive list

* ALL-3495 - Add getBlockByNumber to possible archive list - cleanup

* ALL-3495 - Add getBlockByNumber to possible archive list - pipeline

* ALL-3495 - Add getBlockByNumber to possible archive list - pipeline 2

* ALL-3495 - Add getBlockByNumber to possible archive list - pipeline 3

* ALL-3495 - Add getBlockByNumber to possible archive list - pipeline 4

* ALL-3495 - Add getBlockByNumber to possible archive list - pipeline 5
  • Loading branch information
Smrecz authored Nov 22, 2023
1 parent 446a1a5 commit 9f7f71f
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 18 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ jobs:
V3_API_KEY_TESTNET: ${{ secrets.V3_API_KEY_TESTNET }}
NON_TATUM_RPC_ETH_URL: ${{ secrets.NON_TATUM_RPC_ETH_URL }}
VERBOSE: ${{ secrets.verbose }}
- uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: TEST REPORT
path: reports/jest-junit.xml
reporter: jest-junit

release:
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [4.1.31] - 2023.11.22
### Changed
- Adjust logic redirecting for getBlockByNumber to call normal nodes for latest block

## [4.1.30] - 2023.11.17
### Changed
- Improved `LoadBalancer` stability
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ For more details, check out the [NFTs documentation](https://docs.tatum.io/docs/
Using TatumSDK, it's possible to connect your browser application to MetaMask and perform transactions using it. To achieve this, use the following code:

```ts
import { TatumSDK, Network, Ethereum } from '@tatumio/tatum'
import { TatumSDK, Network, Ethereum, MetaMask } from '@tatumio/tatum'

const tatum = await TatumSDK.init<Ethereum>({ network: Network.ETHEREUM })

Expand Down
14 changes: 13 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ module.exports = {
"^.+\\.(ts|tsx)$": "ts-jest"
},
testTimeout: 30000,
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts']
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
reporters: [
"default",
["jest-junit", {
outputDirectory: "reports",
outputName: "jest-junit.xml",
ancestorSeparator: " β€Ί ",
uniqueOutputName: "false",
suiteNameTemplate: "{filepath}",
classNameTemplate: "{classname}",
titleTemplate: "{title}"
}]
]
}

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tatumio/tatum",
"version": "4.1.30",
"version": "4.1.31",
"description": "Tatum JS SDK",
"author": "Tatum",
"repository": "https://github.com/tatumio/tatum-js",
Expand Down Expand Up @@ -42,6 +42,7 @@
"dotenv": "^16.0.3",
"eslint": "^8.14.0",
"jest": "^29.7.0",
"jest-junit": "^16.0.0",
"prettier": "^2.8.4",
"prettier-plugin-organize-imports": "^3.2.2",
"ts-jest": "^29.1.1",
Expand Down
29 changes: 20 additions & 9 deletions src/e2e/tatum.fee.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApiVersion, Network, TatumSDK } from '../service'
import { Bitcoin, Ethereum } from '../service/tatum'
import { Bitcoin, Ethereum } from '../service'
import { Status } from '../util'

describe('Fee', () => {
Expand All @@ -11,10 +11,16 @@ describe('Fee', () => {
version: ApiVersion.V3,
})

const { data, status } = await tatum.fee.getCurrentFee()
await tatum.destroy()
expect(status).toBe(Status.SUCCESS)
expect(data.gasPrice.fast).toBeDefined()
try{
const { data, status } = await tatum.fee.getCurrentFee()

expect(status).toBe(Status.SUCCESS)
expect(data.gasPrice.fast).toBeDefined()
}
finally {
await tatum.destroy()
}

})

it('should return fee for btc testnet', async () => {
Expand All @@ -25,9 +31,14 @@ describe('Fee', () => {
version: ApiVersion.V3,
})

const { data, status } = await tatum.fee.getCurrentFee()
await tatum.destroy()
expect(status).toBe(Status.SUCCESS)
expect(data.fast).toBeDefined()
try{
const { data, status } = await tatum.fee.getCurrentFee()
await tatum.destroy()
expect(status).toBe(Status.SUCCESS)
expect(data.fast).toBeDefined()
}
finally {
await tatum.destroy()
}
})
})
12 changes: 6 additions & 6 deletions src/service/rpc/evm/EvmUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export const ARCHIVE_METHODS = [
'getTransactionReceipt',
'getUncleCountByBlockHash',
'getUncleCountByBlockNumber',
'getBlockByNumber',
'getBlockTransactionCountByHash',
'getBlockTransactionCountByNumber',
'getBlockReceipts',
Expand All @@ -33,10 +32,11 @@ export const ARCHIVE_METHODS = [

export const POSSIBLE_ARCHIVE_METHODS = [
// Network state
{ method: 'getStorageAt', index: 2 }, // second param block
{ method: 'call', index: 1 }, // second param block
{ method: 'getBalance', index: 1 }, // second param block
{ method: 'getCode', index: 1 }, // second param block
{ method: 'getStorageAt', index: 2 },
{ method: 'call', index: 1 },
{ method: 'getBalance', index: 1 },
{ method: 'getCode', index: 1 },
{ method: 'getBlockByNumber', index: 0 },
]

export const EvmUtils = {
Expand All @@ -47,7 +47,7 @@ export const EvmUtils = {
}

const possibleArchiveMethod = POSSIBLE_ARCHIVE_METHODS.find(
(possibleArchiveMethod) => possibleArchiveMethod.method === rpc.method,
(possibleArchiveMethod) => rpc.method.includes(possibleArchiveMethod.method),
)
if (possibleArchiveMethod) {
const param = rpc?.params?.[possibleArchiveMethod.index]
Expand Down
25 changes: 25 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1963,6 +1963,16 @@ jest-haste-map@^29.7.0:
optionalDependencies:
fsevents "^2.3.2"

jest-junit@^16.0.0:
version "16.0.0"
resolved "https://registry.yarnpkg.com/jest-junit/-/jest-junit-16.0.0.tgz#d838e8c561cf9fdd7eb54f63020777eee4136785"
integrity sha512-A94mmw6NfJab4Fg/BlvVOUXzXgF0XIH6EmTgJ5NDPp4xoKq0Kr7sErb+4Xs9nZvu58pJojz5RFGpqnZYJTrRfQ==
dependencies:
mkdirp "^1.0.4"
strip-ansi "^6.0.1"
uuid "^8.3.2"
xml "^1.0.1"

jest-leak-detector@^29.7.0:
version "29.7.0"
resolved "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-29.7.0.tgz"
Expand Down Expand Up @@ -2325,6 +2335,11 @@ minimatch@^3.0.4:
dependencies:
brace-expansion "^1.1.7"

mkdirp@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==

[email protected]:
version "2.1.2"
resolved "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz"
Expand Down Expand Up @@ -2876,6 +2891,11 @@ uri-js@^4.2.2:
dependencies:
punycode "^2.1.0"

uuid@^8.3.2:
version "8.3.2"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==

v8-compile-cache-lib@^3.0.0:
version "3.0.1"
resolved "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz"
Expand Down Expand Up @@ -2936,6 +2956,11 @@ write-file-atomic@^4.0.2:
imurmurhash "^0.1.4"
signal-exit "^3.0.7"

xml@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5"
integrity sha512-huCv9IH9Tcf95zuYCsQraZtWnJvBtLVE0QHMOs8bWyZAFZNDcYjsPq1nEx8jKA9y+Beo9v+7OBPRisQTjinQMw==

y18n@^5.0.5:
version "5.0.8"
resolved "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz"
Expand Down

0 comments on commit 9f7f71f

Please sign in to comment.