Skip to content

Commit

Permalink
Fix json serialization of interfaces by including a toJson function f…
Browse files Browse the repository at this point in the history
…or objects. LIG-3800 (#314)

* Bump prettier from 3.0.2 to 3.0.3 in /js (#6742)

Bumps [prettier](https://github.com/prettier/prettier) from 3.0.2 to
3.0.3.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/prettier/prettier/releases">prettier's
releases</a>.</em></p>
<blockquote>
<h2>3.0.3</h2>
<p>🔗 <a
href="https://github.com/prettier/prettier/blob/main/CHANGELOG.md#303">Changelog</a></p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/prettier/prettier/blob/main/CHANGELOG.md">prettier's
changelog</a>.</em></p>
<blockquote>
<h1>3.0.3</h1>
<p><a
href="https://github.com/prettier/prettier/compare/3.0.2...3.0.3">diff</a></p>
<h4>Add <code>preferUnplugged: true</code> to <code>package.json</code>
(<a
href="https://redirect.github.com/prettier/prettier/pull/15169">#15169</a>
by <a href="https://github.com/fisker"><code>@​fisker</code></a> and <a
href="https://github.com/so1ve"><code>@​so1ve</code></a>)</h4>
<p>Prettier v3 uses dynamic imports, user <a
href="https://redirect.github.com/yarnpkg/berry/pull/5411#issuecomment-1523502224">will
need to unplug Prettier</a> when Yarn's PnP mode is enabled, add <a
href="https://yarnpkg.com/configuration/manifest#preferUnplugged"><code>preferUnplugged:
true</code></a> to <code>package.json</code>, so Yarn will install
Prettier as unplug by default.</p>
<h4>Support shared config that forbids <code>require()</code> (<a
href="https://redirect.github.com/prettier/prettier/pull/15233">#15233</a>
by <a href="https://github.com/fisker"><code>@​fisker</code></a>)</h4>
<p>If an external shared config package is used, and the package
<code>exports</code> don't have <code>require</code> or
<code>default</code> export.</p>
<p>In Prettier 3.0.2 Prettier fails when attempt to
<code>require()</code> the package, and throws an error.</p>
<pre lang="text"><code>Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No
&quot;exports&quot; main defined in &lt;packageName&gt;/package.json
</code></pre>
<h4>Allow argument of <code>require()</code> to break (<a
href="https://redirect.github.com/prettier/prettier/pull/15256">#15256</a>
by <a href="https://github.com/fisker"><code>@​fisker</code></a>)</h4>
<!-- raw HTML omitted -->
<pre lang="jsx"><code>// Input
const plugin = require(
  global.STANDALONE
    ? path.join(__dirname, &quot;../standalone.js&quot;)
    : path.join(__dirname, &quot;..&quot;)
);
<p>// Prettier 3.0.2
const plugin = require(global.STANDALONE
? path.join(__dirname, &quot;../standalone.js&quot;)
: path.join(__dirname, &quot;..&quot;));</p>
<p>// Prettier 3.0.3
const plugin = require(
global.STANDALONE
? path.join(__dirname, &quot;../standalone.js&quot;)
: path.join(__dirname, &quot;..&quot;)
);
</code></pre></p>
<h4>Do not print trailing commas in arrow function type parameter lists
in <code>ts</code> code blocks (<a
href="https://redirect.github.com/prettier/prettier/pull/15286">#15286</a>
by <a
href="https://github.com/sosukesuzuki"><code>@​sosukesuzuki</code></a>)</h4>
<!-- raw HTML omitted -->
<pre lang="md"><code>&lt;!-- Input --&gt;
```ts
const foo = &lt;T&gt;() =&gt; {}
```
&lt;/tr&gt;&lt;/table&gt;
</code></pre>
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/prettier/prettier/commit/d5f31710b2fc25f3f472e86f9ee00a561a17ffa2"><code>d5f3171</code></a>
Release 3.0.3</li>
<li><a
href="https://github.com/prettier/prettier/commit/a35008fb0a010f92c1002ee074c6a7f3c0d8da41"><code>a35008f</code></a>
Support shared config that forbids <code>require()</code> (<a
href="https://redirect.github.com/prettier/prettier/issues/15233">#15233</a>)</li>
<li><a
href="https://github.com/prettier/prettier/commit/1ce97d13a3008bf6be1c17a374d2a80138a83fe1"><code>1ce97d1</code></a>
Support TypeScript 5.2 <code>using</code> / <code>await using</code>
declaration (<a
href="https://redirect.github.com/prettier/prettier/issues/15321">#15321</a>)</li>
<li><a
href="https://github.com/prettier/prettier/commit/a73cfa0ec43d575d35dbf7779dcec3694d57b3e9"><code>a73cfa0</code></a>
Fix build script <code>--report</code> option (<a
href="https://redirect.github.com/prettier/prettier/issues/15323">#15323</a>)</li>
<li><a
href="https://github.com/prettier/prettier/commit/941c6b3a3cda41e6940b1682437f12065c635dab"><code>941c6b3</code></a>
Minor refactor to <code>getSupportedFilesGlob</code> (<a
href="https://redirect.github.com/prettier/prettier/issues/15319">#15319</a>)</li>
<li><a
href="https://github.com/prettier/prettier/commit/f6c9e9b0b8e5affce678dd8286be301b298a47f4"><code>f6c9e9b</code></a>
Assert uniqueness in language properties (<a
href="https://redirect.github.com/prettier/prettier/issues/15320">#15320</a>)</li>
<li><a
href="https://github.com/prettier/prettier/commit/288ea7e911f83d79453034681f951d307520e1e5"><code>288ea7e</code></a>
chore(deps): update dependency webpack to v5.88.2 (<a
href="https://redirect.github.com/prettier/prettier/issues/15147">#15147</a>)</li>
<li><a
href="https://github.com/prettier/prettier/commit/6654451d9eced219f10fe8f763e9bd8c4e98a7b6"><code>6654451</code></a>
chore(deps): update dependency webpack to v5.88.2 (<a
href="https://redirect.github.com/prettier/prettier/issues/15148">#15148</a>)</li>
<li><a
href="https://github.com/prettier/prettier/commit/d05964460d9681ea16f479f449b7ce042663ead9"><code>d059644</code></a>
chore(deps): update dependency fast-glob to v3.3.1 (<a
href="https://redirect.github.com/prettier/prettier/issues/15001">#15001</a>)</li>
<li><a
href="https://github.com/prettier/prettier/commit/423011dcab464aaab18d233bbee34c37eb56bfd6"><code>423011d</code></a>
Minor refactor to <code>expandPatterns</code> (<a
href="https://redirect.github.com/prettier/prettier/issues/15317">#15317</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/prettier/prettier/compare/3.0.2...3.0.3">compare
view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=prettier&package-manager=npm_and_yarn&previous-version=3.0.2&new-version=3.0.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)

</details>

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Corey Martin <[email protected]>
GitOrigin-RevId: 4caab49b705e9365270d1f207d3479fbb401fbf7

* Fix json serialization of interfaces by including a toJson function for objects. (#7369)

- Switch interface types to `interface` instead of `type`
- Add `toJson()` to classes and `FooToJson()` to types and interfaces.

FIXES LIG-3800

GitOrigin-RevId: 1815f8524d3d59c6bbd47bd9931822aab087c2dd

* Update from public js-sdk main branch (#7389)

Update public `js` sources with the latest code from the [public
repository](https://github.com/lightsparkdev/js-sdk) main branch.

This typically happens when new versions of the SDK are released and
version updates need to be synced. The PR should be merged as soon as
possible to avoid updates to webdev overwriting the changes in the
js-sdk develop branch.

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Corey Martin <[email protected]>
GitOrigin-RevId: a6687c3bf0fc34d3167ca9cd0f147c4736e5bc6a

* Create smooth-rice-admire.md

* CI update lock file for PR

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Corey Martin <[email protected]>
Co-authored-by: Jeremy Klein <[email protected]>
Co-authored-by: lightspark-ci-js-sdk[bot] <134011073+lightspark-ci-js-sdk[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Lightspark Eng <[email protected]>
  • Loading branch information
7 people authored Nov 7, 2023
1 parent 6841478 commit 4857f66
Show file tree
Hide file tree
Showing 189 changed files with 4,771 additions and 1,734 deletions.
8 changes: 8 additions & 0 deletions .changeset/smooth-rice-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@lightsparkdev/lightspark-sdk": minor
"@lightsparkdev/wallet-sdk": minor
---

Fix json serialization of interfaces by including a toJson function for objects
- Switch interface types to `interface` instead of `type`
- Add `toJson()` to classes and `FooToJson()` to types and interfaces.
2 changes: 1 addition & 1 deletion apps/examples/remote-signing-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@types/supertest": "^2.0.14",
"jest": "^29.6.2",
"nodemon": "^2.0.22",
"prettier": "3.0.2",
"prettier": "3.0.3",
"prettier-plugin-organize-imports": "^3.2.2",
"supertest": "^6.3.3",
"ts-jest": "^29.1.1",
Expand Down
2 changes: 1 addition & 1 deletion apps/examples/uma-vasp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@types/supertest": "^2.0.14",
"jest": "^29.6.2",
"nodemon": "^2.0.22",
"prettier": "3.0.2",
"prettier": "3.0.3",
"prettier-plugin-organize-imports": "^3.2.2",
"supertest": "^6.3.3",
"ts-jest": "^29.1.1",
Expand Down
3 changes: 2 additions & 1 deletion apps/examples/uma-vasp/src/ReceivingVasp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as uma from "@uma-sdk/core";
import { Express, Request, Response } from "express";
import { errorMessage } from "./errors.js";
import UmaConfig from "./UmaConfig.js";
import { getLightsparkNodeQuery } from "@lightsparkdev/lightspark-sdk";

export default class ReceivingVasp {
constructor(
Expand Down Expand Up @@ -252,7 +253,7 @@ export default class ReceivingVasp {
}

private async getReceiverNodePubKey(): Promise<string> {
const nodeQuery = LightsparkNode.getLightsparkNodeQuery(this.config.nodeID);
const nodeQuery = getLightsparkNodeQuery(this.config.nodeID);
let node: LightsparkNode | null;
try {
node = await this.lightsparkClient.executeRawQuery(nodeQuery);
Expand Down
4 changes: 2 additions & 2 deletions apps/examples/uma-vasp/src/SendingVasp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
CurrencyUnit,
InvoiceData,
LightsparkClient,
LightsparkNode,
OutgoingPayment,
TransactionStatus,
} from "@lightsparkdev/lightspark-sdk";
Expand All @@ -16,6 +15,7 @@ import SendingVaspRequestCache, {
SendingVaspPayReqData,
} from "./SendingVaspRequestCache.js";
import UmaConfig from "./UmaConfig.js";
import { getLightsparkNodeQuery } from "@lightsparkdev/lightspark-sdk";

export default class SendingVasp {
private readonly requestCache: SendingVaspRequestCache =
Expand Down Expand Up @@ -411,7 +411,7 @@ export default class SendingVasp {

private async getNodePubKey() {
const node = await this.lightsparkClient.executeRawQuery(
LightsparkNode.getLightsparkNodeQuery(this.config.nodeID),
getLightsparkNodeQuery(this.config.nodeID),
);
if (!node) {
throw new Error("Node not found.");
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"eslint": "^8.3.0",
"eslint-watch": "^8.0.0",
"jest": "^29.6.2",
"prettier": "3.0.2",
"prettier": "3.0.3",
"prettier-plugin-organize-imports": "^3.2.2",
"ts-jest": "^29.1.1",
"tsc-absolute": "^1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/lightspark-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"eslint": "^8.3.0",
"eslint-watch": "^8.0.0",
"nodemon": "^2.0.22",
"prettier": "3.0.2",
"prettier": "3.0.3",
"prettier-plugin-organize-imports": "^3.2.2",
"ts-node": "^10.9.1",
"tsc-absolute": "^1.0.1",
Expand Down
6 changes: 2 additions & 4 deletions packages/lightspark-sdk/examples/node-scripts/example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
CurrencyAmount,
getCredentialsFromEnvOrThrow,
getDepositQuery,
getLightsparkNodeQuery,
LightsparkClient,
LightsparkNode,
Node,
} from "@lightsparkdev/lightspark-sdk";
import day from "dayjs";
Expand Down Expand Up @@ -275,9 +275,7 @@ console.log("");
// console.log("");

// Fetch the channels for Node 1
const node = await client.executeRawQuery(
LightsparkNode.getLightsparkNodeQuery(nodeId),
);
const node = await client.executeRawQuery(getLightsparkNodeQuery(nodeId));
if (!node) {
throw new Error("Unable to find node.");
}
Expand Down
56 changes: 28 additions & 28 deletions packages/lightspark-sdk/examples/node-scripts/internal_example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
BitcoinNetwork,
CurrencyAmount,
getDepositQuery,
getLightsparkNodeQuery,
LightsparkClient,
LightsparkNode,
Node,
} from "@lightsparkdev/lightspark-sdk";
import day from "dayjs";
Expand All @@ -21,19 +21,19 @@ const credentials = getCredentialsFromEnvOrThrow();
const client = new LightsparkClient(
new AccountTokenAuthProvider(
credentials.apiTokenClientId,
credentials.apiTokenClientSecret
credentials.apiTokenClientSecret,
),
"api.dev.dev.sparkinfra.net"
"api.dev.dev.sparkinfra.net",
);

// Get some fee estimates for Bitcoin (L1) transactions

const feeEstimate = await client.getBitcoinFeeEstimate(BitcoinNetwork.REGTEST);
console.log(
`Fees for a fast transaction ${feeEstimate.feeFast.preferredCurrencyValueApprox} ${feeEstimate.feeFast.preferredCurrencyUnit}.`
`Fees for a fast transaction ${feeEstimate.feeFast.preferredCurrencyValueApprox} ${feeEstimate.feeFast.preferredCurrencyUnit}.`,
);
console.log(
`Fees for a cheap transaction ${feeEstimate.feeMin.preferredCurrencyValueApprox} ${feeEstimate.feeMin.preferredCurrencyUnit}.\n`
`Fees for a cheap transaction ${feeEstimate.feeMin.preferredCurrencyValueApprox} ${feeEstimate.feeMin.preferredCurrencyUnit}.\n`,
);

// List your account's lightning nodes
Expand All @@ -52,12 +52,12 @@ console.log(`You have ${apiTokenConnection.count} API tokens.`);
const { apiToken, clientSecret } = await client.createApiToken(
"newTestToken",
false,
true
true,
);
console.log(
`Created API token ${apiToken.name} with ID ${
apiToken.id
}. Permissions: ${JSON.stringify(apiToken.permissions)}\n`
}. Permissions: ${JSON.stringify(apiToken.permissions)}\n`,
);

const apiTokenConnection2 = await account.getApiTokens(client);
Expand All @@ -73,8 +73,8 @@ console.log(`You now have ${apiTokenConnection3.count} API tokens.\n`);
console.log(
`Your account's conductivity on REGTEST is ${await account.getConductivity(
client,
[BitcoinNetwork.REGTEST]
)}/10.\n`
[BitcoinNetwork.REGTEST],
)}/10.\n`,
);

// Check your account's local and remote balances for REGTEST
Expand All @@ -88,7 +88,7 @@ const remoteBalance = await account.getRemoteBalance(client, [
if (localBalance && remoteBalance) {
console.log(
`Your local balance is ${localBalance.preferredCurrencyValueApprox} ${localBalance.preferredCurrencyUnit},
your remote balance is ${remoteBalance.preferredCurrencyValueApprox} ${remoteBalance.preferredCurrencyUnit}.`
your remote balance is ${remoteBalance.preferredCurrencyValueApprox} ${remoteBalance.preferredCurrencyUnit}.`,
);
}

Expand Down Expand Up @@ -127,18 +127,18 @@ let transactionsConnection = await account.getTransactions(
undefined,
undefined,
undefined,
BitcoinNetwork.REGTEST
BitcoinNetwork.REGTEST,
);

console.log(
`There is a total of ${transactionsConnection.count} transaction(s) on this account:`
`There is a total of ${transactionsConnection.count} transaction(s) on this account:`,
);
let depositTransactionId: string | undefined;
for (const transaction of transactionsConnection.entities) {
console.log(
` - ${transaction.typename} at ${transaction.createdAt}:
${transaction.amount.preferredCurrencyValueApprox} ${transaction.amount.preferredCurrencyUnit}
(${transaction.status})`
(${transaction.status})`,
);
if (transaction.typename == "Deposit") {
depositTransactionId = transaction.id;
Expand All @@ -155,7 +155,7 @@ for (const transaction of transactionsConnection.entities) {
fees = (transaction as unknown as { fees: CurrencyAmount }).fees;
if (fees !== undefined)
console.log(
` Paid ${fees.preferredCurrencyValueApprox} ${fees.preferredCurrencyUnit} in fees.`
` Paid ${fees.preferredCurrencyValueApprox} ${fees.preferredCurrencyUnit} in fees.`,
);
}
}
Expand All @@ -175,11 +175,11 @@ while (hasNext && iterations < 30) {
undefined,
undefined,
undefined,
BitcoinNetwork.REGTEST
BitcoinNetwork.REGTEST,
);
const num = transactionsConnection.entities.length;
console.log(
`We got ${num} transactions for the page (iteration #${iterations})`
`We got ${num} transactions for the page (iteration #${iterations})`,
);
if (transactionsConnection.pageInfo.hasNextPage) {
hasNext = true;
Expand All @@ -201,10 +201,10 @@ transactionsConnection = await account.getTransactions(
undefined,
day().utc().subtract(1, "day").format(),
undefined,
BitcoinNetwork.REGTEST
BitcoinNetwork.REGTEST,
);
console.log(
`We had ${transactionsConnection.count} transactions in the past 24 hours.`
`We had ${transactionsConnection.count} transactions in the past 24 hours.`,
);

// Get details for a transaction
Expand All @@ -214,7 +214,7 @@ if (!depositTransactionId) {
}

const deposit = await client.executeRawQuery(
getDepositQuery(depositTransactionId)
getDepositQuery(depositTransactionId),
);
console.log("Details of deposit transaction");
console.log(deposit);
Expand All @@ -237,21 +237,23 @@ if (!decodedInvoice) {
}
console.log("Decoded payment request:");
console.log(
" destination public key = " + decodedInvoice.destination.publicKey
" destination public key = " + decodedInvoice.destination.publicKey,
);
console.log(
" amount = " +
decodedInvoice.amount.preferredCurrencyValueApprox +
" " +
decodedInvoice.amount.preferredCurrencyUnit
decodedInvoice.amount.preferredCurrencyUnit,
);
console.log(" memo = " + decodedInvoice.memo);
console.log("");

// Let's send the payment.

// First, we need to recover the signing key.
await client.loadNodeSigningKey(node2Id, { password: credentials.node2Password! });
await client.loadNodeSigningKey(node2Id, {
password: credentials.node2Password!,
});
console.log(`${credentials.node2Name}'s signing key has been loaded.`);

// Then we can send the payment
Expand All @@ -268,27 +270,25 @@ console.log("");
// console.log("");

// Fetch the channels for Node 1
const node1 = await client.executeRawQuery(
LightsparkNode.getLightsparkNodeQuery(node1Id)
);
const node1 = await client.executeRawQuery(getLightsparkNodeQuery(node1Id));
if (!node1) {
throw new Error("Unable to find node 1.");
}

const channelsConnection = await node1.getChannels(client, 10);
console.log(
`${credentials.node1Name} has ${channelsConnection.count} channel(s):`
`${credentials.node1Name} has ${channelsConnection.count} channel(s):`,
);
for (const channel of channelsConnection.entities) {
if (channel.remoteNodeId) {
const remoteNode = await client.executeRawQuery(
Node.getNodeQuery(channel.remoteNodeId)
Node.getNodeQuery(channel.remoteNodeId),
);
const alias = remoteNode?.alias ?? "UNKNOWN";
if (channel.localBalance && channel.remoteBalance) {
console.log(
` - With ${alias}. Local/remote balance = ${channel.localBalance.preferredCurrencyValueApprox} ${channel.localBalance.preferredCurrencyUnit}
/ ${channel.remoteBalance.preferredCurrencyValueApprox} ${channel.remoteBalance.preferredCurrencyUnit}`
/ ${channel.remoteBalance.preferredCurrencyValueApprox} ${channel.remoteBalance.preferredCurrencyUnit}`,
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/lightspark-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"eslint": "^8.3.0",
"eslint-watch": "^8.0.0",
"jest": "^29.6.2",
"prettier": "3.0.2",
"prettier": "3.0.3",
"prettier-plugin-organize-imports": "^3.2.2",
"ts-jest": "^29.1.1",
"tsc-absolute": "^1.0.1",
Expand Down
15 changes: 13 additions & 2 deletions packages/lightspark-sdk/src/objects/Account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,20 @@ import type BlockchainBalance from "./BlockchainBalance.js";
import { BlockchainBalanceFromJson } from "./BlockchainBalance.js";
import type CurrencyAmount from "./CurrencyAmount.js";
import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
import type Entity from "./Entity.js";
import type LightsparkNodeOwner from "./LightsparkNodeOwner.js";
import type TransactionFailures from "./TransactionFailures.js";
import type TransactionStatus from "./TransactionStatus.js";
import type TransactionType from "./TransactionType.js";

/** This is an object representing the connected Lightspark account. You can retrieve this object to see your account information and objects tied to your account. **/
class Account implements LightsparkNodeOwner {
class Account implements LightsparkNodeOwner, Entity {
constructor(
public readonly id: string,
public readonly createdAt: string,
public readonly updatedAt: string,
public readonly typename: string,
public readonly name?: string,
public readonly name?: string | undefined,
) {
autoBind(this);
}
Expand Down Expand Up @@ -1758,6 +1759,16 @@ ${FRAGMENT}
constructObject: (data: any) => AccountFromJson(data.current_account),
};
}

public toJson() {
return {
__typename: "Account",
account_id: this.id,
account_created_at: this.createdAt,
account_updated_at: this.updatedAt,
account_name: this.name,
};
}
}

export const AccountFromJson = (obj: any): Account => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved

import type ApiToken from "./ApiToken.js";
import { ApiTokenFromJson } from "./ApiToken.js";
import type Connection from "./Connection.js";
import { ApiTokenFromJson, ApiTokenToJson } from "./ApiToken.js";
import type PageInfo from "./PageInfo.js";
import { PageInfoFromJson } from "./PageInfo.js";
import { PageInfoFromJson, PageInfoToJson } from "./PageInfo.js";

type AccountToApiTokensConnection = Connection & {
interface AccountToApiTokensConnection {
/**
* The total count of objects in this connection, using the current filters. It is different from the
* number of objects returned in the current page (in the `entities` field).
Expand All @@ -21,7 +20,7 @@ type AccountToApiTokensConnection = Connection & {

/** The typename of the object **/
typename: string;
};
}

export const AccountToApiTokensConnectionFromJson = (
obj: any,
Expand All @@ -37,6 +36,18 @@ export const AccountToApiTokensConnectionFromJson = (
typename: "AccountToApiTokensConnection",
} as AccountToApiTokensConnection;
};
export const AccountToApiTokensConnectionToJson = (
obj: AccountToApiTokensConnection,
): any => {
return {
__typename: "AccountToApiTokensConnection",
account_to_api_tokens_connection_count: obj.count,
account_to_api_tokens_connection_page_info: PageInfoToJson(obj.pageInfo),
account_to_api_tokens_connection_entities: obj.entities.map((e) =>
ApiTokenToJson(e),
),
};
};

export const FRAGMENT = `
fragment AccountToApiTokensConnectionFragment on AccountToApiTokensConnection {
Expand Down
Loading

0 comments on commit 4857f66

Please sign in to comment.