Skip to content
Open
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
940 changes: 940 additions & 0 deletions .yarn/releases/yarn-4.13.0.cjs

Large diffs are not rendered by default.

925 changes: 0 additions & 925 deletions .yarn/releases/yarn-4.5.0.cjs

This file was deleted.

7 changes: 6 additions & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,9 @@ enableGlobalCache: false

nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.5.0.cjs
npmMinimalAgeGate: 1440

npmPreapprovedPackages:
- "@lightsparkdev/*"

yarnPath: .yarn/releases/yarn-4.13.0.cjs
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"build-sb": "turbo run build-sb",
"build": "turbo run build",
"build:watch": "turbo run build:watch",
"checks": "yarn deps:check && turbo gql-codegen && turbo run lint format circular-deps package:checks",
"checks": "yarn deps:check && turbo run gql-codegen lint format circular-deps package:checks",
"test-cmd": "turbo run test",
"circular-deps": "turbo run circular-deps",
"clean": "turbo run clean",
Expand Down Expand Up @@ -65,8 +65,11 @@
"built": false
}
},
"resolutions": {
"axios": "1.7.7"
},
"engines": {
"node": ">=18"
},
"packageManager": "yarn@4.5.0"
"packageManager": "yarn@4.13.0"
}
8 changes: 4 additions & 4 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@
"CHANGELOG.md"
],
"scripts": {
"build": "yarn tsc && tsup",
"build:watch": "yarn build --watch --clean=false",
"build": "yarn tsc && tsdown",
"build:watch": "tsdown --watch --no-clean",
"clean": "rm -rf dist",
"dev": "yarn build -- --watch",
"dev": "yarn build:watch",
"format:fix": "prettier src --write",
"format": "prettier src --check",
"lint:fix": "eslint --fix .",
Expand Down Expand Up @@ -89,7 +89,7 @@
"publint": "^0.3.9",
"ts-jest": "^29.1.1",
"tsc-absolute": "^1.0.1",
"tsup": "^8.2.4",
"tsdown": "^0.21.7",
"typescript": "^5.6.2"
},
"madge": {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/auth/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved

export { default as AuthProvider } from "./AuthProvider.js";
export type { default as AuthProvider } from "./AuthProvider.js";
export { default as LightsparkAuthException } from "./LightsparkAuthException.js";
export { default as StubAuthProvider } from "./StubAuthProvider.js";
2 changes: 1 addition & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved

export { DefaultRequester as Requester } from "./requester/DefaultRequester.js";
export { default as Query } from "./requester/Query.js";
export type { default as Query } from "./requester/Query.js";
export * from "./shared.js";
2 changes: 1 addition & 1 deletion packages/core/src/requester/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved

export { default as Query } from "./Query.js";
export type { default as Query } from "./Query.js";
export { default as Requester } from "./Requester.js";
43 changes: 43 additions & 0 deletions packages/core/src/utils/currency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ export const CurrencyUnit = {
HTG: "HTG",
JMD: "JMD",
PKR: "PKR",
ARS: "ARS",
USDT: "USDT",
USDC: "USDC",
USDB: "USDB",

Bitcoin: "BITCOIN",
Microbitcoin: "MICROBITCOIN",
Expand All @@ -77,8 +79,10 @@ export const CurrencyUnit = {
Htg: "HTG",
Jmd: "JMD",
Pkr: "PKR",
Ars: "ARS",
Usdt: "USDT",
Usdc: "USDC",
Usdb: "USDB",
} as const;

export type CurrencyUnitType = (typeof CurrencyUnit)[keyof typeof CurrencyUnit];
Expand Down Expand Up @@ -139,8 +143,10 @@ const standardUnitConversionObj = {
[CurrencyUnit.HTG]: (v: number) => v,
[CurrencyUnit.JMD]: (v: number) => v,
[CurrencyUnit.PKR]: (v: number) => v,
[CurrencyUnit.ARS]: (v: number) => v,
[CurrencyUnit.USDT]: (v: number) => v,
[CurrencyUnit.USDC]: (v: number) => v,
[CurrencyUnit.USDB]: (v: number) => v,
};

/* Round without decimals since we're returning cents: */
Expand Down Expand Up @@ -200,8 +206,10 @@ const CONVERSION_MAP = {
[CurrencyUnit.HTG]: toBitcoinConversion,
[CurrencyUnit.JMD]: toBitcoinConversion,
[CurrencyUnit.PKR]: toBitcoinConversion,
[CurrencyUnit.ARS]: toBitcoinConversion,
[CurrencyUnit.USDT]: toBitcoinConversion,
[CurrencyUnit.USDC]: toBitcoinConversion,
[CurrencyUnit.USDB]: toBitcoinConversion,
},
[CurrencyUnit.MICROBITCOIN]: {
[CurrencyUnit.BITCOIN]: (v: number) => v / 1_000_000,
Expand Down Expand Up @@ -245,8 +253,10 @@ const CONVERSION_MAP = {
[CurrencyUnit.HTG]: toMicrobitcoinConversion,
[CurrencyUnit.JMD]: toMicrobitcoinConversion,
[CurrencyUnit.PKR]: toMicrobitcoinConversion,
[CurrencyUnit.ARS]: toMicrobitcoinConversion,
[CurrencyUnit.USDT]: toMicrobitcoinConversion,
[CurrencyUnit.USDC]: toMicrobitcoinConversion,
[CurrencyUnit.USDB]: toMicrobitcoinConversion,
},
[CurrencyUnit.MILLIBITCOIN]: {
[CurrencyUnit.BITCOIN]: (v: number) => v / 1_000,
Expand Down Expand Up @@ -290,8 +300,10 @@ const CONVERSION_MAP = {
[CurrencyUnit.HTG]: toMillibitcoinConversion,
[CurrencyUnit.JMD]: toMillibitcoinConversion,
[CurrencyUnit.PKR]: toMillibitcoinConversion,
[CurrencyUnit.ARS]: toMillibitcoinConversion,
[CurrencyUnit.USDT]: toMillibitcoinConversion,
[CurrencyUnit.USDC]: toMillibitcoinConversion,
[CurrencyUnit.USDB]: toMillibitcoinConversion,
},
[CurrencyUnit.MILLISATOSHI]: {
[CurrencyUnit.BITCOIN]: (v: number) => v / 100_000_000_000,
Expand Down Expand Up @@ -335,8 +347,10 @@ const CONVERSION_MAP = {
[CurrencyUnit.HTG]: toMillisatoshiConversion,
[CurrencyUnit.JMD]: toMillisatoshiConversion,
[CurrencyUnit.PKR]: toMillisatoshiConversion,
[CurrencyUnit.ARS]: toMillisatoshiConversion,
[CurrencyUnit.USDT]: toMillisatoshiConversion,
[CurrencyUnit.USDC]: toMillisatoshiConversion,
[CurrencyUnit.USDB]: toMillisatoshiConversion,
},
[CurrencyUnit.NANOBITCOIN]: {
[CurrencyUnit.BITCOIN]: (v: number) => v / 1_000_000_000,
Expand Down Expand Up @@ -380,8 +394,10 @@ const CONVERSION_MAP = {
[CurrencyUnit.HTG]: toNanobitcoinConversion,
[CurrencyUnit.JMD]: toNanobitcoinConversion,
[CurrencyUnit.PKR]: toNanobitcoinConversion,
[CurrencyUnit.ARS]: toNanobitcoinConversion,
[CurrencyUnit.USDT]: toNanobitcoinConversion,
[CurrencyUnit.USDC]: toNanobitcoinConversion,
[CurrencyUnit.USDB]: toNanobitcoinConversion,
},
[CurrencyUnit.SATOSHI]: {
[CurrencyUnit.BITCOIN]: (v: number) => v / 100_000_000,
Expand Down Expand Up @@ -425,8 +441,10 @@ const CONVERSION_MAP = {
[CurrencyUnit.HTG]: toSatoshiConversion,
[CurrencyUnit.JMD]: toSatoshiConversion,
[CurrencyUnit.PKR]: toSatoshiConversion,
[CurrencyUnit.ARS]: toSatoshiConversion,
[CurrencyUnit.USDT]: toSatoshiConversion,
[CurrencyUnit.USDC]: toSatoshiConversion,
[CurrencyUnit.USDB]: toSatoshiConversion,
},
[CurrencyUnit.USD]: standardUnitConversionObj,
[CurrencyUnit.MXN]: standardUnitConversionObj,
Expand Down Expand Up @@ -463,8 +481,10 @@ const CONVERSION_MAP = {
[CurrencyUnit.HTG]: standardUnitConversionObj,
[CurrencyUnit.JMD]: standardUnitConversionObj,
[CurrencyUnit.PKR]: standardUnitConversionObj,
[CurrencyUnit.ARS]: standardUnitConversionObj,
[CurrencyUnit.USDT]: standardUnitConversionObj,
[CurrencyUnit.USDC]: standardUnitConversionObj,
[CurrencyUnit.USDB]: standardUnitConversionObj,
};

export function convertCurrencyAmountValue(
Expand Down Expand Up @@ -561,8 +581,10 @@ export type CurrencyMap = {
[CurrencyUnit.HTG]: number;
[CurrencyUnit.JMD]: number;
[CurrencyUnit.PKR]: number;
[CurrencyUnit.ARS]: number;
[CurrencyUnit.USDT]: number;
[CurrencyUnit.USDC]: number;
[CurrencyUnit.USDB]: number;
[CurrencyUnit.FUTURE_VALUE]: number;
formatted: {
sats: string;
Expand Down Expand Up @@ -609,8 +631,10 @@ export type CurrencyMap = {
[CurrencyUnit.HTG]: string;
[CurrencyUnit.JMD]: string;
[CurrencyUnit.PKR]: string;
[CurrencyUnit.ARS]: string;
[CurrencyUnit.USDT]: string;
[CurrencyUnit.USDC]: string;
[CurrencyUnit.USDB]: string;
[CurrencyUnit.FUTURE_VALUE]: string;
};
isZero: boolean;
Expand Down Expand Up @@ -838,11 +862,13 @@ function convertCurrencyAmountValues(
htg: CurrencyUnit.HTG,
jmd: CurrencyUnit.JMD,
pkr: CurrencyUnit.PKR,
ars: CurrencyUnit.ARS,
mibtc: CurrencyUnit.MICROBITCOIN,
mlbtc: CurrencyUnit.MILLIBITCOIN,
nbtc: CurrencyUnit.NANOBITCOIN,
usdt: CurrencyUnit.USDT,
usdc: CurrencyUnit.USDC,
usdb: CurrencyUnit.USDB,
};
return Object.entries(namesToUnits).reduce(
(acc, [name, unit]) => {
Expand Down Expand Up @@ -931,8 +957,10 @@ export function mapCurrencyAmount(
htg,
jmd,
pkr,
ars,
usdt,
usdc,
usdb,
} = convertCurrencyAmountValues(unit, value, unitsPerBtc, conversionOverride);

const mapWithCurrencyUnits = {
Expand Down Expand Up @@ -974,11 +1002,13 @@ export function mapCurrencyAmount(
[CurrencyUnit.HTG]: htg,
[CurrencyUnit.JMD]: jmd,
[CurrencyUnit.PKR]: pkr,
[CurrencyUnit.ARS]: ars,
[CurrencyUnit.MICROBITCOIN]: mibtc,
[CurrencyUnit.MILLIBITCOIN]: mlbtc,
[CurrencyUnit.NANOBITCOIN]: nbtc,
[CurrencyUnit.USDT]: usdt,
[CurrencyUnit.USDC]: usdc,
[CurrencyUnit.USDB]: usdb,
[CurrencyUnit.FUTURE_VALUE]: NaN,
formatted: {
[CurrencyUnit.BITCOIN]: formatCurrencyStr({
Expand Down Expand Up @@ -1145,6 +1175,10 @@ export function mapCurrencyAmount(
value: pkr,
unit: CurrencyUnit.PKR,
}),
[CurrencyUnit.ARS]: formatCurrencyStr({
value: ars,
unit: CurrencyUnit.ARS,
}),
[CurrencyUnit.USDT]: formatCurrencyStr({
value: usdt,
unit: CurrencyUnit.USDT,
Expand All @@ -1153,6 +1187,10 @@ export function mapCurrencyAmount(
value: usdc,
unit: CurrencyUnit.USDC,
}),
[CurrencyUnit.USDB]: formatCurrencyStr({
value: usdb,
unit: CurrencyUnit.USDB,
}),
[CurrencyUnit.FUTURE_VALUE]: "-",
},
};
Expand Down Expand Up @@ -1237,6 +1275,8 @@ export const abbrCurrencyUnit = (unit: CurrencyUnitType) => {
return "USDT";
case CurrencyUnit.USDC:
return "USDC";
case CurrencyUnit.USDB:
return "USDB";
case CurrencyUnit.BRL:
return "BRL";
case CurrencyUnit.CAD:
Expand Down Expand Up @@ -1295,6 +1335,8 @@ export const abbrCurrencyUnit = (unit: CurrencyUnitType) => {
return "JMD";
case CurrencyUnit.PKR:
return "PKR";
case CurrencyUnit.ARS:
return "ARS";
}
return "Unsupported CurrencyUnit";
};
Expand Down Expand Up @@ -1374,6 +1416,7 @@ export function formatCurrencyStr(
CurrencyUnit.HTG,
CurrencyUnit.JMD,
CurrencyUnit.PKR,
CurrencyUnit.ARS,
CurrencyUnit.HKD,
CurrencyUnit.SGD,
] as string[];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { defineConfig } from "tsup";
import { defineConfig } from "tsdown";

export default defineConfig({
entry: ["src/index.ts", "src/react-native/index.ts", "src/utils/index.ts"],
format: ["cjs", "esm"],
dts: true,
clean: true,
fixedExtension: false,
});
8 changes: 4 additions & 4 deletions packages/lightspark-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
"CHANGELOG.md"
],
"scripts": {
"build": "yarn tsc && tsup",
"build:watch": "yarn build --watch --clean=false",
"build": "yarn tsc && tsdown",
"build:watch": "tsdown --watch --no-clean",
"clean": "rm -rf dist",
"dev": "yarn build -- --watch",
"dev": "yarn build:watch",
"docs": "typedoc src",
"format:fix": "prettier src --write",
"format": "prettier src --check",
Expand Down Expand Up @@ -97,7 +97,7 @@
"publint": "^0.3.9",
"ts-jest": "^29.1.1",
"tsc-absolute": "^1.0.1",
"tsup": "^8.2.4",
"tsdown": "^0.21.7",
"typedoc": "^0.24.7",
"typescript": "^5.6.2"
},
Expand Down
Loading
Loading