Skip to content

Commit 595d726

Browse files
authored
ALL-4340 Add Stellar Testnet RPC (#1045)
1 parent 43dfdb1 commit 595d726

10 files changed

+254
-105
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## [4.2.2] - 2024.1.12
2+
3+
### Added
4+
5+
- Added RPC support for the STELLAR_TESTNET network. Users can now make Stellar RPC calls using the `Network.STELLAR_TESTNET` network.
6+
17
## [4.2.1] - 2024.1.9
28

39
### Updated

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tatumio/tatum",
3-
"version": "4.2.1",
3+
"version": "4.2.2",
44
"description": "Tatum JS SDK",
55
"author": "Tatum",
66
"repository": "https://github.com/tatumio/tatum-js",

src/dto/Network.ts

+4
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export enum Network {
8888
POLKADOT_TESTNET = 'dot-testnet',
8989
RSK_TESTNET = 'rsk-testnet',
9090
SOLANA_DEVNET = 'solana-devnet',
91+
STELLAR_TESTNET = 'stellar-testnet',
9192
TEZOS_TESTNET = 'tezos-testnet',
9293
TRON_SHASTA = 'tron-testnet',
9394
VECHAIN_TESTNET = 'vechain-testnet',
@@ -333,6 +334,9 @@ export const isCardanoNetwork = (network: Network) => CARDANO_NETWORKS.includes(
333334
export const isStellarLoadBalancerNetwork = (network: Network) =>
334335
STELLAR_LOAD_BALANCER_NETWORKS.includes(network)
335336

337+
export const isStellarNetwork = (network: Network) =>
338+
[Network.STELLAR, Network.STELLAR_TESTNET].includes(network)
339+
336340
export const isSameGetBlockNetwork = (network: Network) =>
337341
isUtxoBasedNetwork(network) ||
338342
isEvmBasedNetwork(network) ||

src/e2e/rpc/evm/evm.rpc.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const testNetworks = [
3333
{ network: Network.ETHEREUM_CLASSIC, expected: { chainId: 61 } },
3434
{ network: Network.POLYGON, expected: { chainId: 137 } },
3535
{ network: Network.POLYGON_MUMBAI, expected: { chainId: 80001 } },
36-
{ network: Network.OPTIMISM, expected: { chainId: 10 } },
36+
// { network: Network.OPTIMISM, expected: { chainId: 10 } },
3737
{ network: Network.HAQQ, expected: { chainId: 11235 } },
3838
{ network: Network.HAQQ_TESTNET, expected: { chainId: 54211 } },
3939
{

src/e2e/rpc/other/tatum.rpc.eos.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const getEosRpc = async (testnet?: boolean) =>
1515
})
1616

1717
// Too unstable
18-
describe.skip('eos', () => {
18+
describe('eos', () => {
1919
describe('mainnet', () => {
2020
it('getInfo', async () => {
2121
const tatum = await getEosRpc()
+143-57
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,178 @@
1-
import { Network, Stellar, TatumSDK } from '../../../service'
1+
import process from 'process'
2+
import { ApiVersion, Network, Stellar, TatumSDK } from '../../../service'
23
import { e2eUtil } from '../../e2e.util'
34

4-
const getStellarRpc = async () =>
5+
const getStellarRpc = async (testnet?: boolean) =>
56
await TatumSDK.init<Stellar>({
6-
network: Network.STELLAR,
7+
network: testnet ? Network.STELLAR_TESTNET : Network.STELLAR,
78
verbose: e2eUtil.isVerbose,
9+
...(testnet && { apiKey: { v3: process.env.V3_API_KEY_TESTNET } }),
10+
...(!testnet && { apiKey: { v4: process.env.V4_API_KEY_MAINNET } }),
11+
version: testnet ? ApiVersion.V3 : ApiVersion.V4,
812
})
913

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

13-
beforeEach(async () => {
14-
tatum = await getStellarRpc()
15-
})
17+
describe('mainnet', () => {
18+
beforeEach(async () => {
19+
tatum = await getStellarRpc(false)
20+
})
1621

17-
afterEach(async () => {
18-
await tatum.destroy()
19-
})
22+
afterEach(async () => {
23+
await tatum.destroy()
24+
})
2025

21-
it('should get accounts', async () => {
22-
const response = await tatum.rpc.getAccounts({
23-
asset: 'USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN',
26+
it('should get accounts', async () => {
27+
const response = await tatum.rpc.getAccounts({
28+
asset: 'USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN',
29+
})
30+
expect(response).toBeDefined()
2431
})
25-
expect(response).toBeDefined()
26-
})
2732

28-
it('should get account detail', async () => {
29-
const response = await tatum.rpc.getAccount({
30-
accountId: 'GA2224DCGO3WHC4EALA2PR2BZEMAYZPBPTHS243ZYYWQMBWRPJSZH5A6',
33+
it('should get account detail', async () => {
34+
const response = await tatum.rpc.getAccount({
35+
accountId: 'GA2224DCGO3WHC4EALA2PR2BZEMAYZPBPTHS243ZYYWQMBWRPJSZH5A6',
36+
})
37+
expect(response).toBeDefined()
3138
})
32-
expect(response).toBeDefined()
33-
})
3439

35-
it('should get fee stats', async () => {
36-
const response = await tatum.rpc.getFeeStats()
37-
expect(response).toBeDefined()
38-
})
40+
it('should get fee stats', async () => {
41+
const response = await tatum.rpc.getFeeStats()
42+
expect(response).toBeDefined()
43+
})
3944

40-
it('should get ledger', async () => {
41-
const response = await tatum.rpc.getLedger({
42-
sequence: 49750265,
45+
it('should get ledger', async () => {
46+
const response = await tatum.rpc.getLedger({
47+
sequence: 49750265,
48+
})
49+
expect(response).toBeDefined()
4350
})
44-
expect(response).toBeDefined()
45-
})
4651

47-
it('should get offers', async () => {
48-
const response = await tatum.rpc.getOffers({})
49-
expect(response).toBeDefined()
50-
})
52+
it('should get offers', async () => {
53+
const response = await tatum.rpc.getOffers()
54+
expect(response).toBeDefined()
55+
})
5156

52-
describe('should get strict send', () => {
53-
it('destinationAccount', async () => {
54-
const response = await tatum.rpc.getStrictSendPaymentPaths({
55-
sourceAssetType: 'native',
56-
sourceAmount: '1',
57-
destinationAccount: 'GB3LIKQ6GOJ6D4EYKVS47L2SBY66SJO4MN4CZCMUPNBUJ2L3PF62ECBA',
57+
describe('should get strict send', () => {
58+
it('destinationAccount', async () => {
59+
const response = await tatum.rpc.getStrictSendPaymentPaths({
60+
sourceAssetType: 'native',
61+
sourceAmount: '1',
62+
destinationAccount: 'GB3LIKQ6GOJ6D4EYKVS47L2SBY66SJO4MN4CZCMUPNBUJ2L3PF62ECBA',
63+
})
64+
expect(response).toBeDefined()
65+
})
66+
67+
it('destinationAssets', async () => {
68+
const response = await tatum.rpc.getStrictSendPaymentPaths({
69+
sourceAssetType: 'native',
70+
sourceAmount: '1',
71+
sourceAssets: ['USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'],
72+
destinationAssets: ['USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'],
73+
})
74+
expect(response).toBeDefined()
5875
})
59-
expect(response).toBeDefined()
6076
})
6177

62-
it('destinationAssets', async () => {
63-
const response = await tatum.rpc.getStrictSendPaymentPaths({
64-
sourceAssetType: 'native',
65-
sourceAmount: '1',
66-
sourceAssets: ['USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'],
67-
destinationAssets: ['USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'],
78+
describe('should get strict receive', () => {
79+
it('sourceAssets', async () => {
80+
const response = await tatum.rpc.getStrictReceivePaymentPaths({
81+
destinationAssetType: 'native',
82+
destinationAmount: '1',
83+
sourceAssets: ['USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'],
84+
})
85+
expect(response).toBeDefined()
86+
})
87+
88+
it('sourceAccount', async () => {
89+
const response = await tatum.rpc.getStrictReceivePaymentPaths({
90+
destinationAssetType: 'native',
91+
destinationAmount: '1',
92+
sourceAccount: 'GB3LIKQ6GOJ6D4EYKVS47L2SBY66SJO4MN4CZCMUPNBUJ2L3PF62ECBA',
93+
})
94+
expect(response).toBeDefined()
6895
})
69-
expect(response).toBeDefined()
7096
})
7197
})
7298

73-
describe('should get strict receive', () => {
74-
it('sourceAssets', async () => {
75-
const response = await tatum.rpc.getStrictReceivePaymentPaths({
76-
destinationAssetType: 'native',
77-
destinationAmount: '1',
78-
sourceAssets: ['USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'],
99+
describe('testnet', () => {
100+
beforeEach(async () => {
101+
tatum = await getStellarRpc(true)
102+
})
103+
104+
afterEach(async () => {
105+
await tatum.destroy()
106+
})
107+
108+
it('should get accounts', async () => {
109+
const response = await tatum.rpc.getAccounts({
110+
asset: 'USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN',
79111
})
80112
expect(response).toBeDefined()
81113
})
82114

83-
it('sourceAccount', async () => {
84-
const response = await tatum.rpc.getStrictReceivePaymentPaths({
85-
destinationAssetType: 'native',
86-
destinationAmount: '1',
87-
sourceAccount: 'GB3LIKQ6GOJ6D4EYKVS47L2SBY66SJO4MN4CZCMUPNBUJ2L3PF62ECBA',
115+
it('should get account detail', async () => {
116+
const response = await tatum.rpc.getAccount({
117+
accountId: 'GDNTXNPBK4YLQKBGPCZ5CAHUGQIXKKGSJAWQGO5XR73TQCAYSWQOCCFP',
88118
})
89119
expect(response).toBeDefined()
90120
})
121+
122+
it('should get fee stats', async () => {
123+
const response = await tatum.rpc.getFeeStats()
124+
expect(response).toBeDefined()
125+
})
126+
127+
it('should get ledger', async () => {
128+
const response = await tatum.rpc.getLedgers()
129+
expect(response).toBeDefined()
130+
})
131+
132+
it('should get offers', async () => {
133+
const response = await tatum.rpc.getOffers()
134+
expect(response).toBeDefined()
135+
})
136+
137+
describe('should get strict send', () => {
138+
it('destinationAccount', async () => {
139+
const response = await tatum.rpc.getStrictSendPaymentPaths({
140+
sourceAssetType: 'native',
141+
sourceAmount: '1',
142+
destinationAccount: 'GB3LIKQ6GOJ6D4EYKVS47L2SBY66SJO4MN4CZCMUPNBUJ2L3PF62ECBA',
143+
})
144+
expect(response).toBeDefined()
145+
})
146+
147+
it('destinationAssets', async () => {
148+
const response = await tatum.rpc.getStrictSendPaymentPaths({
149+
sourceAssetType: 'native',
150+
sourceAmount: '1',
151+
sourceAssets: ['USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'],
152+
destinationAssets: ['USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'],
153+
})
154+
expect(response).toBeDefined()
155+
})
156+
})
157+
158+
describe('should get strict receive', () => {
159+
it('sourceAssets', async () => {
160+
const response = await tatum.rpc.getStrictReceivePaymentPaths({
161+
destinationAssetType: 'native',
162+
destinationAmount: '1',
163+
sourceAssets: ['USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'],
164+
})
165+
expect(response).toBeDefined()
166+
})
167+
168+
it('sourceAccount', async () => {
169+
const response = await tatum.rpc.getStrictReceivePaymentPaths({
170+
destinationAssetType: 'native',
171+
destinationAmount: '1',
172+
sourceAccount: 'GDNTXNPBK4YLQKBGPCZ5CAHUGQIXKKGSJAWQGO5XR73TQCAYSWQOCCFP',
173+
})
174+
expect(response).toBeDefined()
175+
})
176+
})
91177
})
92178
})

0 commit comments

Comments
 (0)