From 9ff37fcf69a2c4908fc692898207f240248c208e Mon Sep 17 00:00:00 2001 From: Lukas Kotol Date: Thu, 15 Feb 2024 15:15:23 +0100 Subject: [PATCH] ALL-4358 - Add Flare subscription support --- CHANGELOG.md | 6 ++++ package.json | 2 +- src/dto/AddressEventNotificationChain.ts | 1 + src/dto/Chain.ts | 1 + src/dto/Network.ts | 4 +-- src/e2e/e2e.constant.ts | 40 ++++++++++++++++++++++ src/e2e/e2e.util.ts | 4 +++ src/e2e/rpc/other/tatum.rpc.solana.spec.ts | 3 +- src/e2e/tatum.notification.spec.ts | 2 +- src/service/tatum/tatum.evm.ts | 2 +- src/util/constant.ts | 1 + src/util/util.shared.ts | 7 ++++ 12 files changed, 67 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98c305a03e..0b2990a38c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## [4.2.9] - 2024.2.15 + +### Added + +- Added support for Flare, Flare Coston, Flare Coston 2 and Flare Songbird subscriptions. + ## [4.2.8] - 2024.2.15 ### Updated diff --git a/package.json b/package.json index 1f58d2c269..196633748e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tatumio/tatum", - "version": "4.2.8", + "version": "4.2.9", "description": "Tatum JS SDK", "author": "Tatum", "repository": "https://github.com/tatumio/tatum-js", diff --git a/src/dto/AddressEventNotificationChain.ts b/src/dto/AddressEventNotificationChain.ts index 18a30f2589..809c6b8389 100644 --- a/src/dto/AddressEventNotificationChain.ts +++ b/src/dto/AddressEventNotificationChain.ts @@ -14,4 +14,5 @@ export enum AddressEventNotificationChain { TEZOS = 'TEZOS', EON = 'EON', CHZ = 'CHZ', + FLR = 'FLR', } diff --git a/src/dto/Chain.ts b/src/dto/Chain.ts index 5c3580ca6d..ff8766536d 100644 --- a/src/dto/Chain.ts +++ b/src/dto/Chain.ts @@ -10,4 +10,5 @@ export enum Chain { Dogecoin = 'Dogecoin', Tron = 'Tron', BinanceSmartChain = 'BinanceSmartChain', + Flare = 'Flare', } diff --git a/src/dto/Network.ts b/src/dto/Network.ts index 9fe11f0728..5152c3dd1b 100644 --- a/src/dto/Network.ts +++ b/src/dto/Network.ts @@ -763,16 +763,16 @@ export const NETWORK_METADATA: Record = { currency: Currency.FLR, testnet: false, chainId: 14, + defaultMainnet: true, }, [Network.FLARE_COSTON_2]: { currency: Currency.FLR, testnet: true, - defaultTestnet: true, chainId: 114, }, [Network.FLARE_SONGBIRD]: { currency: Currency.SGB, - testnet: false, + testnet: true, chainId: 19, }, [Network.FLARE_COSTON]: { diff --git a/src/e2e/e2e.constant.ts b/src/e2e/e2e.constant.ts index 1b81ae87e9..a88ee58e20 100644 --- a/src/e2e/e2e.constant.ts +++ b/src/e2e/e2e.constant.ts @@ -32,6 +32,10 @@ export const AddressEventNetworks = [ Network.XRP, Network.XRP_TESTNET, Network.TEZOS, + Network.FLARE, + Network.FLARE_COSTON, + Network.FLARE_COSTON_2, + Network.FLARE_SONGBIRD, ] export const IncomingNativeTxNetworks = [ @@ -61,6 +65,10 @@ export const IncomingNativeTxNetworks = [ Network.XRP, Network.XRP_TESTNET, Network.TEZOS, + Network.FLARE, + Network.FLARE_COSTON, + Network.FLARE_COSTON_2, + Network.FLARE_SONGBIRD, ] export const OutgoingNativeTxNetworks = [ @@ -88,6 +96,10 @@ export const OutgoingNativeTxNetworks = [ Network.XRP, Network.XRP_TESTNET, Network.TEZOS, + Network.FLARE, + Network.FLARE_COSTON, + Network.FLARE_COSTON_2, + Network.FLARE_SONGBIRD, ] export const OutgoingFailedNetworks = [ @@ -103,6 +115,10 @@ export const OutgoingFailedNetworks = [ Network.KLAYTN, Network.KLAYTN_BAOBAB, Network.TEZOS, + Network.FLARE, + Network.FLARE_COSTON, + Network.FLARE_COSTON_2, + Network.FLARE_SONGBIRD, ] export const PaidFeeNetworks = [ @@ -122,6 +138,10 @@ export const PaidFeeNetworks = [ Network.XRP, Network.XRP_TESTNET, Network.TEZOS, + Network.FLARE, + Network.FLARE_COSTON, + Network.FLARE_COSTON_2, + Network.FLARE_SONGBIRD, ] export const FungibleTxNetworks = [ @@ -141,6 +161,10 @@ export const FungibleTxNetworks = [ Network.SOLANA, Network.SOLANA_DEVNET, Network.TEZOS, + Network.FLARE, + Network.FLARE_COSTON, + Network.FLARE_COSTON_2, + Network.FLARE_SONGBIRD, ] export const NftNetworks = [ @@ -160,6 +184,10 @@ export const NftNetworks = [ Network.SOLANA, Network.SOLANA_DEVNET, Network.TEZOS, + Network.FLARE, + Network.FLARE_COSTON, + Network.FLARE_COSTON_2, + Network.FLARE_SONGBIRD, ] export const MultitokenNetworks = [ @@ -174,6 +202,10 @@ export const MultitokenNetworks = [ Network.BINANCE_SMART_CHAIN_TESTNET, Network.KLAYTN, Network.KLAYTN_BAOBAB, + Network.FLARE, + Network.FLARE_COSTON, + Network.FLARE_COSTON_2, + Network.FLARE_SONGBIRD, ] export const FailedTxPerBlockNetworks = [ @@ -193,6 +225,10 @@ export const FailedTxPerBlockNetworks = [ Network.SOLANA, Network.SOLANA_DEVNET, Network.TEZOS, + Network.FLARE, + Network.FLARE_COSTON, + Network.FLARE_COSTON_2, + Network.FLARE_SONGBIRD, ] export const ContractAddressLogEventNetworks = [ @@ -207,6 +243,10 @@ export const ContractAddressLogEventNetworks = [ Network.BINANCE_SMART_CHAIN_TESTNET, Network.KLAYTN, Network.KLAYTN_BAOBAB, + Network.FLARE, + Network.FLARE_COSTON, + Network.FLARE_COSTON_2, + Network.FLARE_SONGBIRD, ] export const InternalTxNetworks = [ diff --git a/src/e2e/e2e.util.ts b/src/e2e/e2e.util.ts index e3fb9edbb2..da0fb6c9e1 100644 --- a/src/e2e/e2e.util.ts +++ b/src/e2e/e2e.util.ts @@ -16,6 +16,10 @@ export const e2eUtil = { switch (network) { case Network.ETHEREUM_SEPOLIA: case Network.ETHEREUM_HOLESKY: + case Network.FLARE: + case Network.FLARE_COSTON: + case Network.FLARE_COSTON_2: + case Network.FLARE_SONGBIRD: return '0xdb4C3b4350EE869F2D0a2F43ce0292865E2Aa149' case Network.CELO_ALFAJORES: return '0xdf083B077F1FD890fC71feCaBbd3F68F94cD21Bf' diff --git a/src/e2e/rpc/other/tatum.rpc.solana.spec.ts b/src/e2e/rpc/other/tatum.rpc.solana.spec.ts index c81ad76368..b508da6269 100644 --- a/src/e2e/rpc/other/tatum.rpc.solana.spec.ts +++ b/src/e2e/rpc/other/tatum.rpc.solana.spec.ts @@ -12,7 +12,8 @@ const getClient = async (testnet?: boolean): Promise => const blockNumber = 203046000 -describe('Solana', () => { +// TODO: Too unstable +describe.skip('Solana', () => { describe('mainnet', () => { describe('getAccountInfo', () => { it('should return account info', async () => { diff --git a/src/e2e/tatum.notification.spec.ts b/src/e2e/tatum.notification.spec.ts index 627f05c0b0..15aede5d12 100644 --- a/src/e2e/tatum.notification.spec.ts +++ b/src/e2e/tatum.notification.spec.ts @@ -19,7 +19,7 @@ import { e2eUtil } from './e2e.util' // TODO pipeline dont work with API keys -describe.skip('notification', () => { +describe('notification', () => { beforeAll(async () => { const tatum = await TatumSDK.init({ network: Network.ETHEREUM, diff --git a/src/service/tatum/tatum.evm.ts b/src/service/tatum/tatum.evm.ts index 8ff0ede8f4..27ae29455f 100644 --- a/src/service/tatum/tatum.evm.ts +++ b/src/service/tatum/tatum.evm.ts @@ -58,7 +58,6 @@ export class EthereumClassic extends BaseEvm {} export class Fantom extends BaseEvm {} export class Gnosis extends BaseEvm {} export class Haqq extends BaseEvm {} -export class Flare extends BaseEvm {} export class HarmonyOne extends BaseEvm {} export class Kucoin extends BaseEvm {} export class Oasis extends BaseEvm {} @@ -66,6 +65,7 @@ export class Optimism extends BaseEvm {} export class Palm extends BaseEvm {} export class Vechain extends BaseEvm {} export class XinFin extends BaseEvm {} +export class Flare extends NotificationEvm {} export class Chiliz extends NotificationEvm {} export class HorizenEon extends BaseEvm { diff --git a/src/util/constant.ts b/src/util/constant.ts index f692087103..f223683b9e 100644 --- a/src/util/constant.ts +++ b/src/util/constant.ts @@ -18,6 +18,7 @@ export const Constant = { [AddressEventNotificationChain.DOGE]: Chain.Dogecoin, [AddressEventNotificationChain.TRON]: Chain.Tron, [AddressEventNotificationChain.BSC]: Chain.BinanceSmartChain, + [AddressEventNotificationChain.FLR]: Chain.Flare, }, }, DECIMALS: { diff --git a/src/util/util.shared.ts b/src/util/util.shared.ts index 29f16fff61..caae1da811 100644 --- a/src/util/util.shared.ts +++ b/src/util/util.shared.ts @@ -415,6 +415,8 @@ export const Utils = { return Network.HORIZEN_EON case AddressEventNotificationChain.CHZ: return Network.CHILIZ + case AddressEventNotificationChain.FLR: + return Network.FLARE default: throw new Error(`Chain ${chain} is not supported.`) } @@ -465,6 +467,11 @@ export const Utils = { return AddressEventNotificationChain.EON case Network.CHILIZ: return AddressEventNotificationChain.CHZ + case Network.FLARE: + case Network.FLARE_COSTON: + case Network.FLARE_COSTON_2: + case Network.FLARE_SONGBIRD: + return AddressEventNotificationChain.FLR default: throw new Error(`Network ${network} is not supported.`) }