From 4e1d1227aa868cc628111ddd1bd4bb62a8111785 Mon Sep 17 00:00:00 2001 From: Victor Kirov Date: Fri, 24 May 2024 10:51:58 +0300 Subject: [PATCH 1/3] Add Signet support --- src/runes/api.ts | 21 ++++++++++++++------- src/types.ts | 1 + 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/runes/api.ts b/src/runes/api.ts index 41e2c6f..2434fd8 100644 --- a/src/runes/api.ts +++ b/src/runes/api.ts @@ -1,3 +1,4 @@ +import { BitcoinNetworkType } from '../types'; import { CreateEtchOrderRequest, CreateMintOrderRequest, @@ -9,12 +10,16 @@ import { RBFOrderRequest, RBFOrderResponse, } from './types'; -import { BitcoinNetworkType } from '../types'; import axios, { AxiosError, AxiosInstance } from 'axios'; +const urlNetworkSuffix = { + [BitcoinNetworkType.Mainnet]: '', + [BitcoinNetworkType.Testnet]: '-testnet', + [BitcoinNetworkType.Signet]: '-signet', +}; export const ORDINALS_API_BASE_URL = (network: BitcoinNetworkType = BitcoinNetworkType.Mainnet) => - `https://ordinals${network === BitcoinNetworkType.Testnet ? '-testnet' : ''}.xverse.app/v1`; + `https://ordinals${urlNetworkSuffix[network]}.xverse.app/v1`; export class RunesApi { client: AxiosInstance; @@ -160,8 +165,10 @@ export class RunesApi { }; } -const testnetClient = new RunesApi(BitcoinNetworkType.Testnet); -const mainnetClient = new RunesApi(BitcoinNetworkType.Mainnet); - -export const getRunesApiClient = (network: BitcoinNetworkType = BitcoinNetworkType.Mainnet) => - network === BitcoinNetworkType.Mainnet ? mainnetClient : testnetClient; +const clients: Partial> = {}; +export const getRunesApiClient = (network: BitcoinNetworkType = BitcoinNetworkType.Mainnet) => { + if (!clients[network]) { + clients[network] = new RunesApi(network); + } + return clients[network]; +}; diff --git a/src/types.ts b/src/types.ts index 1b6e0d2..2b97a2e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -4,6 +4,7 @@ import { Requests, Return } from './request'; export enum BitcoinNetworkType { Mainnet = 'Mainnet', Testnet = 'Testnet', + Signet = 'Signet', } export interface BitcoinNetwork { From 66520e658e56ddfc0dbd8066b07e823d882e48d2 Mon Sep 17 00:00:00 2001 From: Victor Kirov Date: Fri, 24 May 2024 10:56:02 +0300 Subject: [PATCH 2/3] Fix build --- src/runes/api.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/runes/api.ts b/src/runes/api.ts index 2434fd8..66120a0 100644 --- a/src/runes/api.ts +++ b/src/runes/api.ts @@ -166,9 +166,11 @@ export class RunesApi { } const clients: Partial> = {}; -export const getRunesApiClient = (network: BitcoinNetworkType = BitcoinNetworkType.Mainnet) => { +export const getRunesApiClient = ( + network: BitcoinNetworkType = BitcoinNetworkType.Mainnet +): RunesApi => { if (!clients[network]) { clients[network] = new RunesApi(network); } - return clients[network]; + return clients[network]!; }; From 9614d69f9d05ef4e064bd8042f8a54d3cfe8ac81 Mon Sep 17 00:00:00 2001 From: fede erbes Date: Thu, 6 Jun 2024 17:13:56 +0200 Subject: [PATCH 3/3] chore: bump patch version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2c9873f..4ef1a68 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@sats-connect/core", - "version": "0.0.10", + "version": "0.0.11", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@sats-connect/core", - "version": "0.0.10", + "version": "0.0.11", "license": "ISC", "dependencies": { "axios": "1.6.8", diff --git a/package.json b/package.json index b272517..57e1342 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@sats-connect/core", - "version": "0.0.10", + "version": "0.0.11", "main": "dist/index.mjs", "module": "dist/index.mjs", "types": "dist/index.d.mts",