Skip to content
Merged
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
7 changes: 7 additions & 0 deletions .changeset/pretty-radios-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@lightsparkdev/lightspark-sdk": patch
---

- Add createUmaInvitationWithPayment
- Add cancelUmaInvitation
- Remove unneeded crypto-browserify as dependency
6 changes: 6 additions & 0 deletions .changeset/thirty-planets-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@lightsparkdev/ui": patch
---

- Updates to BirthdayInput
- Add icons
5 changes: 5 additions & 0 deletions .changeset/twenty-hands-grow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@lightsparkdev/core": patch
---

- Remove unneeded crypto-browserify as dependency
2 changes: 1 addition & 1 deletion .github/workflows/runChangeset.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { parse as parseConfig } from "@changesets/config";
import * as git from "@changesets/git";
import parseChangeset from "@changesets/parse";
import * as fs from "fs";
import humanId from "human-id";
import { humanId } from "human-id";

const configText = fs.readFileSync(".changeset/config.json", {
encoding: "utf8",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/updatePR.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const { data: comments } = await github.rest.issues.listComments({
let comment = comments.find((comment) => comment.user.id === 41898282);

let changesetRawStr = process.env.CHANGESET.replace(/\n/g, "\\n");

changesetRawStr = changesetRawStr.replace(/^'(.*)'$/, "$1");
const hasUndef = changesetRawStr.includes("undefined");
const changeset = JSON.parse(changesetRawStr);

const changedPackagesLines = changeset.changedPackages
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@
"apps/private/*",
"apps/examples/*"
],
"dependencies": {
"@changesets/cli": "^2.27.1",
"@manypkg/cli": "^0.21.0",
"devDependencies": {
"@amplitude/session-replay-browser": "^1.22.6",
"@changesets/cli": "^2.29.4",
"@manypkg/cli": "^0.24.0",
"@octokit/auth-action": "^4.0.1",
"human-id": "^4.1.1",
"octokit": "^4.0.2",
"ts-prune": "^0.10.3",
"turbo": "^2.4.4"
Expand Down
1 change: 0 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
},
"license": "Apache-2.0",
"dependencies": {
"crypto-browserify": "^3.12.0",
"dayjs": "^1.11.7",
"graphql": "^16.6.0",
"graphql-ws": "^5.11.3",
Expand Down
1 change: 0 additions & 1 deletion packages/lightspark-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
"dependencies": {
"@lightsparkdev/core": "1.4.0",
"@lightsparkdev/crypto-wasm": "0.1.14",
"crypto-browserify": "^3.12.0",
"dayjs": "^1.11.7",
"dotenv": "^16.3.1",
"graphql": "^16.6.0",
Expand Down
81 changes: 81 additions & 0 deletions packages/lightspark-sdk/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import NodeKeyLoaderCache from "./NodeKeyLoaderCache.js";
import { type SigningKeyLoaderArgs } from "./SigningKeyLoader.js";
import { BitcoinFeeEstimate as BitcoinFeeEstimateQuery } from "./graphql/BitcoinFeeEstimate.js";
import { CancelInvoice } from "./graphql/CancelInvoice.js";
import { CancelUmaInvitation } from "./graphql/CancelUmaInvitation.js";
import { ClaimUmaInvitation } from "./graphql/ClaimUmaInvitation.js";
import { ClaimUmaInvitationWithIncentives } from "./graphql/ClaimUmaInvitationWithIncentives.js";
import { CreateApiToken } from "./graphql/CreateApiToken.js";
Expand All @@ -40,6 +41,7 @@ import { CreateTestModeInvoice } from "./graphql/CreateTestModeInvoice.js";
import { CreateTestModePayment } from "./graphql/CreateTestModePayment.js";
import { CreateUmaInvitation } from "./graphql/CreateUmaInvitation.js";
import { CreateUmaInvitationWithIncentives } from "./graphql/CreateUmaInvitationWithIncentives.js";
import { CreateUmaInvitationWithPayment } from "./graphql/CreateUmaInvitationWithPayment.js";
import { CreateUmaInvoice } from "./graphql/CreateUmaInvoice.js";
import { DecodeInvoice } from "./graphql/DecodeInvoice.js";
import { DeleteApiToken } from "./graphql/DeleteApiToken.js";
Expand Down Expand Up @@ -1737,6 +1739,85 @@ class LightsparkClient {
coreLogger.setEnabled(enabled, level);
logger.setEnabled(enabled, level);
}

/**
* Creates an UMA invitation with an attached payment.
*
* @param inviterUma The UMA of the inviter.
* @param amountToSend The amount and currency to send in the smallest unit of the currency (i.e. cents for USD).
* @param expiresAt The expiration date/time (Date).
* @returns The invitation that was created, or null if creation failed.
*/
public async createUmaInvitationWithPayment(
inviterUma: string,
amountToSend: {
amount: number;
currency: {
code: string;
name: string;
symbol: string;
decimals: number;
};
},
expiresAt: Date,
): Promise<UmaInvitation | null> {
return await this.executeRawQuery({
queryPayload: CreateUmaInvitationWithPayment,
variables: {
inviterUma,
paymentAmount: amountToSend.amount,
paymentCurrency: amountToSend.currency,
expiresAt: expiresAt.toISOString(),
},
constructObject: (responseJson: {
create_uma_invitation_with_payment: {
invitation: any; // eslint-disable-line @typescript-eslint/no-explicit-any
} | null;
}) => {
if (!responseJson.create_uma_invitation_with_payment?.invitation) {
throw new LightsparkException(
"CreateUmaInvitationWithPaymentError",
"Unable to create UMA invitation with payment",
);
}
return UmaInvitationFromJson(
responseJson.create_uma_invitation_with_payment.invitation,
);
},
});
}

/**
* Cancels an UMA invitation by its invite code.
*
* @param invitationCode The code of the invitation to cancel.
* @returns The cancelled invitation, or null if cancellation failed.
*/
public async cancelUmaInvitation(
invitationCode: string,
): Promise<UmaInvitation | null> {
return await this.executeRawQuery({
queryPayload: CancelUmaInvitation,
variables: {
inviteCode: invitationCode,
},
constructObject: (responseJson: {
cancel_uma_invitation: {
invitation: any; // eslint-disable-line @typescript-eslint/no-explicit-any
} | null;
}) => {
if (!responseJson.cancel_uma_invitation?.invitation) {
throw new LightsparkException(
"CancelUmaInvitationError",
"Unable to cancel UMA invitation",
);
}
return UmaInvitationFromJson(
responseJson.cancel_uma_invitation.invitation,
);
},
});
}
}

export default LightsparkClient;
19 changes: 19 additions & 0 deletions packages/lightspark-sdk/src/graphql/CancelUmaInvitation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved

import { FRAGMENT as UmaInvitationFragment } from "../objects/UmaInvitation.js";

export const CancelUmaInvitation = `
mutation CancelUmaInvitation(
$inviteCode: String!
) {
cancel_uma_invitation(input: {
invite_code: $inviteCode
}) {
invitation {
...UmaInvitationFragment
}
}
}

${UmaInvitationFragment}
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved

import { FRAGMENT as UmaInvitationFragment } from "../objects/UmaInvitation.js";

export const CreateUmaInvitationWithPayment = `
mutation CreateUmaInvitationWithPayment(
$inviterUma: String!
$paymentAmount: Int!
$paymentCurrency: UmaCurrencyInput!
$expiresAt: DateTime!
) {
create_uma_invitation_with_payment(input: {
inviter_uma: $inviterUma
payment_amount: $paymentAmount
payment_currency: $paymentCurrency
expires_at: $expiresAt
}) {
invitation {
...UmaInvitationFragment
}
}
}

${UmaInvitationFragment}
`;
41 changes: 26 additions & 15 deletions packages/ui/src/components/BirthdayInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ export function isValidBirthday(
}

const today = dayjs().startOf("day");
return date.isBefore(today);

// Reject dates before 1800 & after today
return date.isBefore(today) && date.year() >= 1800;
}

export function formatDateToText(dateStr: string): string {
Expand All @@ -68,7 +70,6 @@ export function formatDateToText(dateStr: string): string {
const month = parts[0];
const day = parts[1];
const year = parts[2];

if (month && !day && !year) {
if (month.length === 2) {
const monthNum = parseInt(month);
Expand Down Expand Up @@ -98,6 +99,13 @@ export function formatDateToText(dateStr: string): string {
return date.isValid() ? date.format("MMMM D, YYYY") : "";
}

function formatDateForDisplay(date: string): string {
if (!date) return "";
const parts = date.split("/");
if (parts.length === 1) return parts[0];
return parts.join(" / ");
}

export function BirthdayInput({
date,
setDate,
Expand All @@ -108,18 +116,19 @@ export function BirthdayInput({
const handleChange = (newValue: string): void => {
let value = newValue;

value = value.replace(/[^0-9/]/g, "");

if (value.length > 2 && value.charAt(2) !== "/") {
value = value.slice(0, 2) + "/" + value.slice(2);
value = value.replace(/[^0-9]/g, "");
let formattedValue = "";
if (value.length > 0) {
formattedValue = value.slice(0, 2);
}
if (value.length > 5 && value.charAt(5) !== "/") {
value = value.slice(0, 5) + "/" + value.slice(5);
if (value.length > 2) {
formattedValue += "/" + value.slice(2, 4);
}
if (value.length > 10) {
value = value.slice(0, 10);
if (value.length > 4) {
formattedValue += "/" + value.slice(4, 8);
}
setDate(value);

setDate(formattedValue);
};

const isCompleteDate = date.length === 10;
Expand All @@ -128,19 +137,21 @@ export function BirthdayInput({
return (
<>
<TextInput
maxLength={10}
maxLength={14}
placeholder="MM / DD / YYYY"
value={date}
value={formatDateForDisplay(date)}
onChange={handleChange}
inputMode="numeric"
typography={{
size: "Medium",
size: "Large",
}}
borderRadius={16}
hint={formatDateToText(date)}
error={
birthdayFieldBlurred && isInvalid ? invalidBirthdayError : undefined
}
borderRadius={16}
borderWidth={0.5}
paddingY={14}
/>
</>
);
Expand Down
8 changes: 1 addition & 7 deletions packages/ui/src/icons/central/ChevronRight.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@ export function ChevronRight({
strokeLinejoin = "round",
}: PathProps) {
return (
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M9 4L16.2929 11.2929C16.6834 11.6834 16.6834 12.3166 16.2929 12.7071L9 20"
stroke="currentColor"
Expand Down
18 changes: 18 additions & 0 deletions packages/ui/src/icons/central/Wrench.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export function Wrench() {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width="20"
height="20"
viewBox="0 0 20 20"
fill="none"
>
<path
d="M12.1417 13.4259C15.2163 13.4259 17.7088 10.9334 17.7088 7.8588C17.7088 7.21676 17.6002 6.60011 17.4002 6.02624L15.1394 8.28703C14.1933 9.23308 12.6595 9.23308 11.7135 8.28703C10.7674 7.34099 10.7674 5.80715 11.7135 4.86111L13.9743 2.60031C13.4004 2.40035 12.7838 2.29166 12.1417 2.29166C9.0671 2.29166 6.57459 4.78416 6.57459 7.8588C6.57459 8.618 6.72655 9.34166 7.00172 10.0011L2.4719 14.6025C2.14446 14.9352 2.15402 15.4717 2.49309 15.7925L4.36505 17.5633C4.69484 17.8752 5.21365 17.8658 5.53192 17.5422L9.99943 12.9988C10.6588 13.274 11.3825 13.4259 12.1417 13.4259Z"
stroke="#F1F7FE"
stroke-width="1.5"
stroke-linejoin="round"
/>
</svg>
);
}
1 change: 1 addition & 0 deletions packages/ui/src/icons/central/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,4 @@ export { TrashCan as CentralTrashCan } from "./TrashCan.js";
export { TriangleExclamation as CentralTriangleExclamation } from "./TriangleExclamation.js";
export { TriangleExclamationFilled as CentralTriangleExclamationFilled } from "./TriangleExclamationFilled.js";
export { WeakStrengthIcon as CentralWeakStrengthIcon } from "./WeakStrength.js";
export { Wrench as CentralWrench } from "./Wrench.js";
1 change: 1 addition & 0 deletions packages/ui/src/styles/colors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const baseColors = {
gray4: "#B6BAC3",
gray6: "#8E95A2",
gray7: "#FFFFFF9C",
gray70: "#ffffff70",
// transparent
transparent: "transparent",
transparenta02: "#00000005",
Expand Down
Loading