Skip to content

Commit

Permalink
Merge pull request #16 from secretkeylabs/vic/signet
Browse files Browse the repository at this point in the history
Add Signet support
  • Loading branch information
fedeerbes authored Jun 6, 2024
2 parents e0fff30 + 9614d69 commit 7c7b997
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
23 changes: 16 additions & 7 deletions src/runes/api.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { BitcoinNetworkType } from '../types';
import {
CreateEtchOrderRequest,
CreateMintOrderRequest,
Expand All @@ -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;
Expand Down Expand Up @@ -160,8 +165,12 @@ 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<Record<BitcoinNetworkType, RunesApi>> = {};
export const getRunesApiClient = (
network: BitcoinNetworkType = BitcoinNetworkType.Mainnet
): RunesApi => {
if (!clients[network]) {
clients[network] = new RunesApi(network);
}
return clients[network]!;
};
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Requests, Return } from './request';
export enum BitcoinNetworkType {
Mainnet = 'Mainnet',
Testnet = 'Testnet',
Signet = 'Signet',
}

export interface BitcoinNetwork {
Expand Down

0 comments on commit 7c7b997

Please sign in to comment.