@solard/sdk 0.2.21 → 0.2.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -3
- package/src/client.ts +9 -0
- package/src/default.ts +28 -0
- package/src/export-surface.test.ts +43 -7
- package/src/index.ts +15 -7
- package/src/protocol.ts +11 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solard/sdk",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "Public Solard SDK for wallets,
|
|
3
|
+
"version": "0.2.22",
|
|
4
|
+
"description": "Public Solard SDK for wallets, trading, history, live market subscriptions and token metadata.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
7
7
|
"module": "./src/index.ts",
|
|
@@ -12,6 +12,11 @@
|
|
|
12
12
|
"types": "./src/browser/index.ts",
|
|
13
13
|
"import": "./src/browser/index.ts",
|
|
14
14
|
"default": "./src/browser/index.ts"
|
|
15
|
+
},
|
|
16
|
+
"./protocol": {
|
|
17
|
+
"types": "./src/protocol.ts",
|
|
18
|
+
"import": "./src/protocol.ts",
|
|
19
|
+
"default": "./src/protocol.ts"
|
|
15
20
|
}
|
|
16
21
|
},
|
|
17
22
|
"files": [
|
|
@@ -22,7 +27,7 @@
|
|
|
22
27
|
"license": "MIT",
|
|
23
28
|
"dependencies": {
|
|
24
29
|
"@solana/web3.js": "^1.98.4",
|
|
25
|
-
"@solard/core": "0.2.
|
|
30
|
+
"@solard/core": "0.2.22"
|
|
26
31
|
},
|
|
27
32
|
"scripts": {
|
|
28
33
|
"typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.browser.json",
|
package/src/client.ts
CHANGED
|
@@ -20,6 +20,8 @@ import {
|
|
|
20
20
|
type TokenHolderSnapshotOptions,
|
|
21
21
|
type TokenRef,
|
|
22
22
|
type WalletRef,
|
|
23
|
+
type WalletPrivateKeyExport,
|
|
24
|
+
type WalletPrivateKeyFormat,
|
|
23
25
|
} from "@solard/core";
|
|
24
26
|
|
|
25
27
|
export type SolardOptions = {
|
|
@@ -78,6 +80,11 @@ export type Solard = {
|
|
|
78
80
|
createVanityWallet: ReturnType<typeof createCoreSolard>["createVanityWallet"];
|
|
79
81
|
importWallet: ReturnType<typeof createCoreSolard>["importWallet"];
|
|
80
82
|
listWallets: ReturnType<typeof createCoreSolard>["listWallets"];
|
|
83
|
+
walletAddress(wallet: WalletRef): string;
|
|
84
|
+
exportWalletPrivateKey(
|
|
85
|
+
wallet: WalletRef,
|
|
86
|
+
format?: WalletPrivateKeyFormat,
|
|
87
|
+
): WalletPrivateKeyExport;
|
|
81
88
|
addToken: ReturnType<typeof createCoreSolard>["addToken"];
|
|
82
89
|
resolveToken: ReturnType<typeof createCoreSolard>["resolveToken"];
|
|
83
90
|
tokenAccounts: ReturnType<typeof createCoreSolard>["tokenAccounts"];
|
|
@@ -127,6 +134,8 @@ export function createSolard(options: SolardOptions = {}): Solard {
|
|
|
127
134
|
createVanityWallet: core.createVanityWallet.bind(core),
|
|
128
135
|
importWallet: core.importWallet.bind(core),
|
|
129
136
|
listWallets: core.listWallets.bind(core),
|
|
137
|
+
walletAddress: core.walletAddress.bind(core),
|
|
138
|
+
exportWalletPrivateKey: core.exportWalletPrivateKey.bind(core),
|
|
130
139
|
addToken: core.addToken.bind(core),
|
|
131
140
|
resolveToken: core.resolveToken.bind(core),
|
|
132
141
|
tokenAccounts: core.tokenAccounts.bind(core),
|
package/src/default.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createSolard, type Solard } from "./client.ts";
|
|
2
|
+
|
|
3
|
+
let instance: Solard | undefined;
|
|
4
|
+
|
|
5
|
+
function client(): Solard {
|
|
6
|
+
instance ??= createSolard();
|
|
7
|
+
return instance;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const slrd = new Proxy({} as Solard, {
|
|
11
|
+
get(_target, key) {
|
|
12
|
+
if (key === "close") {
|
|
13
|
+
return () => {
|
|
14
|
+
const current = instance;
|
|
15
|
+
instance = undefined;
|
|
16
|
+
current?.close();
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
const current = client();
|
|
20
|
+
const value = Reflect.get(current as object, key, current);
|
|
21
|
+
return typeof value === "function" ? value.bind(current) : value;
|
|
22
|
+
},
|
|
23
|
+
set() {
|
|
24
|
+
return false;
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export default slrd;
|
|
@@ -4,6 +4,8 @@ import { join } from "node:path";
|
|
|
4
4
|
|
|
5
5
|
const source = readFileSync(join(import.meta.dir, "index.ts"), "utf8");
|
|
6
6
|
const client = readFileSync(join(import.meta.dir, "client.ts"), "utf8");
|
|
7
|
+
const protocol = readFileSync(join(import.meta.dir, "protocol.ts"), "utf8");
|
|
8
|
+
const defaultClient = readFileSync(join(import.meta.dir, "default.ts"), "utf8");
|
|
7
9
|
|
|
8
10
|
function exportedNames(value: string) {
|
|
9
11
|
const values: string[] = [];
|
|
@@ -28,12 +30,11 @@ describe("sdk membrane", () => {
|
|
|
28
30
|
expect(exportedNames(source)).toEqual({
|
|
29
31
|
values: [
|
|
30
32
|
"createSolard",
|
|
31
|
-
"
|
|
32
|
-
"decodePumpProgramData",
|
|
33
|
-
"decodePumpSwapProgramData",
|
|
34
|
-
"decodeRaydiumLaunchLabProgramData",
|
|
33
|
+
"fetchTokenMetadata",
|
|
35
34
|
"formatRaw",
|
|
35
|
+
"publicTokenMetadataUrl",
|
|
36
36
|
"subscribeLaunches",
|
|
37
|
+
"subscribeMigrations",
|
|
37
38
|
"subscribeTrades",
|
|
38
39
|
"sol",
|
|
39
40
|
"tokenAmount",
|
|
@@ -48,18 +49,20 @@ describe("sdk membrane", () => {
|
|
|
48
49
|
"CumulativeDistributionRecipient",
|
|
49
50
|
"CumulativeDistributionState",
|
|
50
51
|
"CumulativeEntitlement",
|
|
52
|
+
"FetchTokenMetadataOptions",
|
|
51
53
|
"HumanAmount",
|
|
52
54
|
"LaunchEvent",
|
|
53
55
|
"LaunchSubscription",
|
|
54
56
|
"LaunchVenue",
|
|
57
|
+
"MigrationDestination",
|
|
58
|
+
"MigrationEvent",
|
|
59
|
+
"MigrationSubscription",
|
|
60
|
+
"MigrationVenue",
|
|
55
61
|
"MarketHistory",
|
|
56
62
|
"MarketHistoryOptions",
|
|
57
63
|
"MarketPrice",
|
|
58
64
|
"MergedReplayEventStream",
|
|
59
|
-
"PumpDecodedEvent",
|
|
60
|
-
"PumpSwapDecodedEvent",
|
|
61
65
|
"QuoteAsset",
|
|
62
|
-
"RaydiumLaunchLabDecodedEvent",
|
|
63
66
|
"ReplayCoverage",
|
|
64
67
|
"ReplayEventSubscription",
|
|
65
68
|
"ReplayEventsOptions",
|
|
@@ -87,9 +90,15 @@ describe("sdk membrane", () => {
|
|
|
87
90
|
"TokenHolderSnapshot",
|
|
88
91
|
"TokenHolderSnapshotOptions",
|
|
89
92
|
"TokenEventHistoryProgress",
|
|
93
|
+
"TokenMetadata",
|
|
94
|
+
"TokenMetadataHint",
|
|
95
|
+
"TokenMetadataKind",
|
|
96
|
+
"TokenMetadataMode",
|
|
90
97
|
"TokenRef",
|
|
91
98
|
"TokenRow",
|
|
92
99
|
"WalletInfo",
|
|
100
|
+
"WalletPrivateKeyExport",
|
|
101
|
+
"WalletPrivateKeyFormat",
|
|
93
102
|
"WalletRef",
|
|
94
103
|
].sort(),
|
|
95
104
|
});
|
|
@@ -101,8 +110,35 @@ describe("sdk membrane", () => {
|
|
|
101
110
|
expect(client).not.toMatch(/\.\.\/\.\.\/core\/src|@solard\/core\//);
|
|
102
111
|
});
|
|
103
112
|
|
|
113
|
+
test("keeps raw protocol decoders off the root surface", () => {
|
|
114
|
+
expect(source).not.toMatch(
|
|
115
|
+
/decode(?:ProgramDataLogs|PumpProgramData|PumpSwapProgramData|RaydiumLaunchLabProgramData)/,
|
|
116
|
+
);
|
|
117
|
+
expect(exportedNames(protocol)).toEqual({
|
|
118
|
+
values: [
|
|
119
|
+
"decodeProgramDataLogs",
|
|
120
|
+
"decodePumpProgramData",
|
|
121
|
+
"decodePumpSwapProgramData",
|
|
122
|
+
"decodeRaydiumLaunchLabProgramData",
|
|
123
|
+
].sort(),
|
|
124
|
+
types: [
|
|
125
|
+
"PumpDecodedEvent",
|
|
126
|
+
"PumpSwapDecodedEvent",
|
|
127
|
+
"RaydiumLaunchLabDecodedEvent",
|
|
128
|
+
].sort(),
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
test("exports a lazy zero-config default client", () => {
|
|
133
|
+
expect(source).toContain('export { default } from "./default.ts"');
|
|
134
|
+
expect(defaultClient).toContain("instance ??= createSolard()");
|
|
135
|
+
expect(defaultClient).toContain('if (key === "close")');
|
|
136
|
+
expect(defaultClient).not.toContain("export default createSolard()");
|
|
137
|
+
});
|
|
138
|
+
|
|
104
139
|
test("does not create persistence at module import", () => {
|
|
105
140
|
expect(source).not.toMatch(/createCoreSolard|createTraderSolard\(\)/);
|
|
141
|
+
expect(defaultClient).not.toMatch(/^const\s+\w+\s*=\s*createSolard\(\)/m);
|
|
106
142
|
expect(client.indexOf("createCoreSolard(options)")).toBeGreaterThan(
|
|
107
143
|
client.indexOf("export function createSolard"),
|
|
108
144
|
);
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { default } from "./default.ts";
|
|
1
2
|
export { createSolard } from "./client.ts";
|
|
2
3
|
export type {
|
|
3
4
|
Solard,
|
|
@@ -46,26 +47,33 @@ export type {
|
|
|
46
47
|
TokenRef,
|
|
47
48
|
TokenRow,
|
|
48
49
|
WalletInfo,
|
|
50
|
+
WalletPrivateKeyExport,
|
|
51
|
+
WalletPrivateKeyFormat,
|
|
49
52
|
WalletRef,
|
|
50
53
|
} from "@solard/core";
|
|
51
54
|
|
|
52
55
|
export {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
decodePumpSwapProgramData,
|
|
56
|
-
decodeRaydiumLaunchLabProgramData,
|
|
56
|
+
fetchTokenMetadata,
|
|
57
|
+
publicTokenMetadataUrl,
|
|
57
58
|
subscribeLaunches,
|
|
59
|
+
subscribeMigrations,
|
|
58
60
|
subscribeTrades,
|
|
59
61
|
} from "@solard/core";
|
|
60
62
|
export type {
|
|
61
63
|
LaunchEvent,
|
|
62
64
|
LaunchSubscription,
|
|
63
65
|
LaunchVenue,
|
|
66
|
+
MigrationDestination,
|
|
67
|
+
MigrationEvent,
|
|
68
|
+
MigrationSubscription,
|
|
69
|
+
MigrationVenue,
|
|
64
70
|
TradeEvent,
|
|
65
71
|
TradeSide,
|
|
66
72
|
TradeSubscription,
|
|
67
73
|
TradeVenue,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
74
|
+
FetchTokenMetadataOptions,
|
|
75
|
+
TokenMetadata,
|
|
76
|
+
TokenMetadataHint,
|
|
77
|
+
TokenMetadataKind,
|
|
78
|
+
TokenMetadataMode,
|
|
71
79
|
} from "@solard/core";
|
package/src/protocol.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export {
|
|
2
|
+
decodeProgramDataLogs,
|
|
3
|
+
decodePumpProgramData,
|
|
4
|
+
decodePumpSwapProgramData,
|
|
5
|
+
decodeRaydiumLaunchLabProgramData,
|
|
6
|
+
} from "@solard/core";
|
|
7
|
+
export type {
|
|
8
|
+
PumpDecodedEvent,
|
|
9
|
+
PumpSwapDecodedEvent,
|
|
10
|
+
RaydiumLaunchLabDecodedEvent,
|
|
11
|
+
} from "@solard/core";
|