Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ALL-4340 Add Stellar Testnet RPC #1045

Merged
merged 1 commit into from
Jan 12, 2024
Merged
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [4.2.2] - 2024.1.12

### Added

- Added RPC support for the STELLAR_TESTNET network. Users can now make Stellar RPC calls using the `Network.STELLAR_TESTNET` network.

## [4.2.1] - 2024.1.9

### Updated
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.2.1",
"version": "4.2.2",
"description": "Tatum JS SDK",
"author": "Tatum",
"repository": "https://github.com/tatumio/tatum-js",
Expand Down
4 changes: 4 additions & 0 deletions src/dto/Network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export enum Network {
POLKADOT_TESTNET = 'dot-testnet',
RSK_TESTNET = 'rsk-testnet',
SOLANA_DEVNET = 'solana-devnet',
STELLAR_TESTNET = 'stellar-testnet',
TEZOS_TESTNET = 'tezos-testnet',
TRON_SHASTA = 'tron-testnet',
VECHAIN_TESTNET = 'vechain-testnet',
Expand Down Expand Up @@ -333,6 +334,9 @@ export const isCardanoNetwork = (network: Network) => CARDANO_NETWORKS.includes(
export const isStellarLoadBalancerNetwork = (network: Network) =>
STELLAR_LOAD_BALANCER_NETWORKS.includes(network)

export const isStellarNetwork = (network: Network) =>
[Network.STELLAR, Network.STELLAR_TESTNET].includes(network)

export const isSameGetBlockNetwork = (network: Network) =>
isUtxoBasedNetwork(network) ||
isEvmBasedNetwork(network) ||
Expand Down
2 changes: 1 addition & 1 deletion src/e2e/rpc/evm/evm.rpc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const testNetworks = [
{ network: Network.ETHEREUM_CLASSIC, expected: { chainId: 61 } },
{ network: Network.POLYGON, expected: { chainId: 137 } },
{ network: Network.POLYGON_MUMBAI, expected: { chainId: 80001 } },
{ network: Network.OPTIMISM, expected: { chainId: 10 } },
// { network: Network.OPTIMISM, expected: { chainId: 10 } },
{ network: Network.HAQQ, expected: { chainId: 11235 } },
{ network: Network.HAQQ_TESTNET, expected: { chainId: 54211 } },
{
Expand Down
2 changes: 1 addition & 1 deletion src/e2e/rpc/other/tatum.rpc.eos.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const getEosRpc = async (testnet?: boolean) =>
})

// Too unstable
describe.skip('eos', () => {
describe('eos', () => {
describe('mainnet', () => {
it('getInfo', async () => {
const tatum = await getEosRpc()
Expand Down
200 changes: 143 additions & 57 deletions src/e2e/rpc/other/tatum.rpc.stellar.spec.ts
Original file line number Diff line number Diff line change
@@ -1,92 +1,178 @@
import { Network, Stellar, TatumSDK } from '../../../service'
import process from 'process'
import { ApiVersion, Network, Stellar, TatumSDK } from '../../../service'
import { e2eUtil } from '../../e2e.util'

const getStellarRpc = async () =>
const getStellarRpc = async (testnet?: boolean) =>
await TatumSDK.init<Stellar>({
network: Network.STELLAR,
network: testnet ? Network.STELLAR_TESTNET : Network.STELLAR,
verbose: e2eUtil.isVerbose,
...(testnet && { apiKey: { v3: process.env.V3_API_KEY_TESTNET } }),
...(!testnet && { apiKey: { v4: process.env.V4_API_KEY_MAINNET } }),
version: testnet ? ApiVersion.V3 : ApiVersion.V4,
})

describe('Stellar', () => {
let tatum: Stellar

beforeEach(async () => {
tatum = await getStellarRpc()
})
describe('mainnet', () => {
beforeEach(async () => {
tatum = await getStellarRpc(false)
})

afterEach(async () => {
await tatum.destroy()
})
afterEach(async () => {
await tatum.destroy()
})

it('should get accounts', async () => {
const response = await tatum.rpc.getAccounts({
asset: 'USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN',
it('should get accounts', async () => {
const response = await tatum.rpc.getAccounts({
asset: 'USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN',
})
expect(response).toBeDefined()
})
expect(response).toBeDefined()
})

it('should get account detail', async () => {
const response = await tatum.rpc.getAccount({
accountId: 'GA2224DCGO3WHC4EALA2PR2BZEMAYZPBPTHS243ZYYWQMBWRPJSZH5A6',
it('should get account detail', async () => {
const response = await tatum.rpc.getAccount({
accountId: 'GA2224DCGO3WHC4EALA2PR2BZEMAYZPBPTHS243ZYYWQMBWRPJSZH5A6',
})
expect(response).toBeDefined()
})
expect(response).toBeDefined()
})

it('should get fee stats', async () => {
const response = await tatum.rpc.getFeeStats()
expect(response).toBeDefined()
})
it('should get fee stats', async () => {
const response = await tatum.rpc.getFeeStats()
expect(response).toBeDefined()
})

it('should get ledger', async () => {
const response = await tatum.rpc.getLedger({
sequence: 49750265,
it('should get ledger', async () => {
const response = await tatum.rpc.getLedger({
sequence: 49750265,
})
expect(response).toBeDefined()
})
expect(response).toBeDefined()
})

it('should get offers', async () => {
const response = await tatum.rpc.getOffers({})
expect(response).toBeDefined()
})
it('should get offers', async () => {
const response = await tatum.rpc.getOffers()
expect(response).toBeDefined()
})

describe('should get strict send', () => {
it('destinationAccount', async () => {
const response = await tatum.rpc.getStrictSendPaymentPaths({
sourceAssetType: 'native',
sourceAmount: '1',
destinationAccount: 'GB3LIKQ6GOJ6D4EYKVS47L2SBY66SJO4MN4CZCMUPNBUJ2L3PF62ECBA',
describe('should get strict send', () => {
it('destinationAccount', async () => {
const response = await tatum.rpc.getStrictSendPaymentPaths({
sourceAssetType: 'native',
sourceAmount: '1',
destinationAccount: 'GB3LIKQ6GOJ6D4EYKVS47L2SBY66SJO4MN4CZCMUPNBUJ2L3PF62ECBA',
})
expect(response).toBeDefined()
})

it('destinationAssets', async () => {
const response = await tatum.rpc.getStrictSendPaymentPaths({
sourceAssetType: 'native',
sourceAmount: '1',
sourceAssets: ['USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'],
destinationAssets: ['USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'],
})
expect(response).toBeDefined()
})
expect(response).toBeDefined()
})

it('destinationAssets', async () => {
const response = await tatum.rpc.getStrictSendPaymentPaths({
sourceAssetType: 'native',
sourceAmount: '1',
sourceAssets: ['USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'],
destinationAssets: ['USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'],
describe('should get strict receive', () => {
it('sourceAssets', async () => {
const response = await tatum.rpc.getStrictReceivePaymentPaths({
destinationAssetType: 'native',
destinationAmount: '1',
sourceAssets: ['USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'],
})
expect(response).toBeDefined()
})

it('sourceAccount', async () => {
const response = await tatum.rpc.getStrictReceivePaymentPaths({
destinationAssetType: 'native',
destinationAmount: '1',
sourceAccount: 'GB3LIKQ6GOJ6D4EYKVS47L2SBY66SJO4MN4CZCMUPNBUJ2L3PF62ECBA',
})
expect(response).toBeDefined()
})
expect(response).toBeDefined()
})
})

describe('should get strict receive', () => {
it('sourceAssets', async () => {
const response = await tatum.rpc.getStrictReceivePaymentPaths({
destinationAssetType: 'native',
destinationAmount: '1',
sourceAssets: ['USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'],
describe('testnet', () => {
beforeEach(async () => {
tatum = await getStellarRpc(true)
})

afterEach(async () => {
await tatum.destroy()
})

it('should get accounts', async () => {
const response = await tatum.rpc.getAccounts({
asset: 'USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN',
})
expect(response).toBeDefined()
})

it('sourceAccount', async () => {
const response = await tatum.rpc.getStrictReceivePaymentPaths({
destinationAssetType: 'native',
destinationAmount: '1',
sourceAccount: 'GB3LIKQ6GOJ6D4EYKVS47L2SBY66SJO4MN4CZCMUPNBUJ2L3PF62ECBA',
it('should get account detail', async () => {
const response = await tatum.rpc.getAccount({
accountId: 'GDNTXNPBK4YLQKBGPCZ5CAHUGQIXKKGSJAWQGO5XR73TQCAYSWQOCCFP',
})
expect(response).toBeDefined()
})

it('should get fee stats', async () => {
const response = await tatum.rpc.getFeeStats()
expect(response).toBeDefined()
})

it('should get ledger', async () => {
const response = await tatum.rpc.getLedgers()
expect(response).toBeDefined()
})

it('should get offers', async () => {
const response = await tatum.rpc.getOffers()
expect(response).toBeDefined()
})

describe('should get strict send', () => {
it('destinationAccount', async () => {
const response = await tatum.rpc.getStrictSendPaymentPaths({
sourceAssetType: 'native',
sourceAmount: '1',
destinationAccount: 'GB3LIKQ6GOJ6D4EYKVS47L2SBY66SJO4MN4CZCMUPNBUJ2L3PF62ECBA',
})
expect(response).toBeDefined()
})

it('destinationAssets', async () => {
const response = await tatum.rpc.getStrictSendPaymentPaths({
sourceAssetType: 'native',
sourceAmount: '1',
sourceAssets: ['USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'],
destinationAssets: ['USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'],
})
expect(response).toBeDefined()
})
})

describe('should get strict receive', () => {
it('sourceAssets', async () => {
const response = await tatum.rpc.getStrictReceivePaymentPaths({
destinationAssetType: 'native',
destinationAmount: '1',
sourceAssets: ['USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'],
})
expect(response).toBeDefined()
})

it('sourceAccount', async () => {
const response = await tatum.rpc.getStrictReceivePaymentPaths({
destinationAssetType: 'native',
destinationAmount: '1',
sourceAccount: 'GDNTXNPBK4YLQKBGPCZ5CAHUGQIXKKGSJAWQGO5XR73TQCAYSWQOCCFP',
})
expect(response).toBeDefined()
})
})
})
})
Loading
Loading