Skip to content

Commit 6b913cc

Browse files
committed
Upgrade to 0.5.0
1 parent a879ea9 commit 6b913cc

File tree

6 files changed

+182
-169
lines changed

6 files changed

+182
-169
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33
All notable changes to this project will be documented in this file. See
44
[standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
55

6+
### [0.5.0] (2025-05-01)
7+
8+
### Change
9+
10+
- Remove the `stellarSDK` and the `rpc` instance so we start using the Stellar SDK directly now that recent versions
11+
don't fail like old ones with the "instance of" logic.
12+
- Make as many constructor params as optional as possible, if they are not provided just use default values
13+
- Avoid fetching the account in read only methods so calls are faster
14+
615
### [0.3.0] (2025-05-01)
716

817
### Add

README.md

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ protocol
66
```shell
77
npx jsr add @creit-tech/sorobandomains-sdk
88
```
9-
> If you are using another tool like Deno, Bun or PNPM; check the installation instructions [here](https://jsr.io/@creit-tech/sorobandomains-sdk).
9+
10+
> If you are using another tool like Deno, Bun or PNPM; check the installation instructions
11+
> [here](https://jsr.io/@creit-tech/sorobandomains-sdk).
1012
1113
## The SorobanDomainsSDK class
1214

@@ -16,21 +18,11 @@ The first step will be creating a new instance from the main class.
1618
import * as SDK from "@stellar/stellar-sdk";
1719
import config from "./myconfigfile.ts";
1820

19-
const sdk: SorobanDomainsSDK = new SorobanDomainsSDK({
20-
stellarSDK: SDK,
21-
rpc: new SDK.rpc.Server(config.RPC_URL),
22-
network: config.NETWORK,
23-
vaultsContractId: config.VAULTS_CONTRACT_ID,
24-
valuesDatabaseContractId: config.VALUES_DATABASE_CONTRACT_ID,
25-
reverseRegistrarContractId: config.REVERSE_REGISTRAR_CONTRACT_ID,
26-
defaultFee: config.DEFAULT_FEE,
27-
defaultTimeout: config.DEFAULT_TIMEOUT,
28-
simulationAccount: config.SIMULATION_ACCOUNT,
29-
});
21+
const sdk: SorobanDomainsSDK = new SorobanDomainsSDK({ rpcUrl: config.RPC_URL });
3022
```
3123

32-
> If you want to know what each value represents, check the `SorobanDomainsSDKParams` interface in the `./src/types.ts`
33-
> file.
24+
> There are more parameters you can provide to the SDK, check the `SorobanDomainsSDKParams` interface in the
25+
> [src/types.ts](https://github.com/Creit-Tech/sorobandomains-sdk-js/blob/main/src/types.ts) file to know all of them.
3426
3527
## Fetch a registered domain
3628

deno.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@creit-tech/sorobandomains-sdk",
3-
"version": "0.3.0",
3+
"version": "0.5.0",
44
"description": "An SDK to easily fetch domains from the sorobandomains.org protocol",
55
"license": "MIT",
66
"author": {
@@ -12,7 +12,8 @@
1212
"url": "https://github.com/Creit-Tech/sorobandomains-sdk-js.git"
1313
},
1414
"tasks": {
15-
"dev": "deno run --watch main.ts"
15+
"dev": "deno run --watch main.ts",
16+
"test": "deno test --allow-net"
1617
},
1718
"fmt": {
1819
"lineWidth": 120

src/sdk.test.ts

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { SorobanDomainsSDK } from "./sdk.ts";
22
import { describe, test } from "@std/testing/bdd";
33
import { assertEquals } from "@std/assert";
44
import { decodeHex } from "@std/encoding";
5+
import { type Record, RecordType } from "./types.ts";
56

67
describe("Basic logic", (): void => {
78
test("The `hash` function", () => {
@@ -23,15 +24,27 @@ describe("Basic logic", (): void => {
2324
});
2425

2526
test("It should validate domains correctly", (): void => {
26-
assertEquals(true, SorobanDomainsSDK.isValidDomain('stellar.xlm'));
27-
assertEquals(true, SorobanDomainsSDK.isValidDomain('dev.stellar.xlm'));
28-
assertEquals(false, SorobanDomainsSDK.isValidDomain('another.dev.stellar.xlm'));
29-
assertEquals(false, SorobanDomainsSDK.isValidDomain('stellar'));
30-
assertEquals(false, SorobanDomainsSDK.isValidDomain('stellar..xlm'));
31-
assertEquals(false, SorobanDomainsSDK.isValidDomain(' stellar.xlm'));
32-
assertEquals(false, SorobanDomainsSDK.isValidDomain('qwertyuiopasdfghjklzxcvbnm.xlm'));
33-
assertEquals(false, SorobanDomainsSDK.isValidDomain('hello-world.xlm'));
34-
assertEquals(false, SorobanDomainsSDK.isValidDomain('steLLar.xlm'));
35-
assertEquals(false, SorobanDomainsSDK.isValidDomain('ste11ar.xlm'));
27+
assertEquals(true, SorobanDomainsSDK.isValidDomain("stellar.xlm"));
28+
assertEquals(true, SorobanDomainsSDK.isValidDomain("dev.stellar.xlm"));
29+
assertEquals(false, SorobanDomainsSDK.isValidDomain("another.dev.stellar.xlm"));
30+
assertEquals(false, SorobanDomainsSDK.isValidDomain("stellar"));
31+
assertEquals(false, SorobanDomainsSDK.isValidDomain("stellar..xlm"));
32+
assertEquals(false, SorobanDomainsSDK.isValidDomain(" stellar.xlm"));
33+
assertEquals(false, SorobanDomainsSDK.isValidDomain("qwertyuiopasdfghjklzxcvbnm.xlm"));
34+
assertEquals(false, SorobanDomainsSDK.isValidDomain("hello-world.xlm"));
35+
assertEquals(false, SorobanDomainsSDK.isValidDomain("steLLar.xlm"));
36+
assertEquals(false, SorobanDomainsSDK.isValidDomain("ste11ar.xlm"));
37+
});
38+
});
39+
40+
describe("Connection with public registry", () => {
41+
test("Search an existing domain", async () => {
42+
const now: number = performance.now();
43+
const sdk: SorobanDomainsSDK = new SorobanDomainsSDK({ rpcUrl: "https://mainnet.sorobanrpc.com" });
44+
const domain: Record = await sdk.searchDomain({ domain: "tomer" });
45+
assertEquals(domain.type, RecordType.Domain);
46+
const then: number = performance.now();
47+
48+
console.log(`${(then - now).toFixed(2)}ms`);
3649
});
3750
});

0 commit comments

Comments
 (0)