@solard/cli 0.2.27 → 0.2.31
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 +3 -3
- package/src/commands/buy.ts +216 -207
- package/src/commands/sell.ts +248 -239
- package/src/commands/trade-fees.test.ts +15 -0
- package/src/commands/trade-fees.ts +24 -0
- package/src/commands/transfer.test.ts +33 -0
- package/src/commands/transfer.ts +205 -200
- package/src/index.ts +3330 -3329
- package/src/launch-watch-command.ts +301 -301
- package/src/price-feed-client.ts +174 -174
- package/src/price-feed-protocol.ts +45 -45
- package/src/price-feed-server.architecture.test.ts +20 -20
- package/src/price-feed-server.ts +315 -315
- package/src/refs.ts +59 -56
- package/src/trade-strategy-command.ts +1219 -1219
package/src/refs.ts
CHANGED
|
@@ -1,56 +1,59 @@
|
|
|
1
|
-
import { findExternalContact } from "@solard/core";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
*
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
1
|
+
import { findExternalContact } from "@solard/core";
|
|
2
|
+
import { PublicKey } from "@solana/web3.js";
|
|
3
|
+
|
|
4
|
+
export type ResolvedDestinationRef = {
|
|
5
|
+
input: string;
|
|
6
|
+
address: string;
|
|
7
|
+
contactName?: string;
|
|
8
|
+
walletName?: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type WalletResolver = {
|
|
12
|
+
resolveWallet(ref: string): { address: { toBase58(): string } };
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Resolve a CLI destination without ever treating an external contact as a
|
|
17
|
+
* signing wallet. Ambiguous contact/wallet names fail closed.
|
|
18
|
+
*/
|
|
19
|
+
export function resolveDestinationRef(
|
|
20
|
+
slrd: WalletResolver,
|
|
21
|
+
value: string,
|
|
22
|
+
): ResolvedDestinationRef {
|
|
23
|
+
const input = value.trim();
|
|
24
|
+
// A literal address needs no contact database lookup or schema initialization.
|
|
25
|
+
try { return { input, address: new PublicKey(input).toBase58() }; } catch {}
|
|
26
|
+
const contact = findExternalContact(input);
|
|
27
|
+
|
|
28
|
+
let walletAddress: string | null = null;
|
|
29
|
+
try {
|
|
30
|
+
walletAddress = slrd.resolveWallet(input).address.toBase58();
|
|
31
|
+
} catch {
|
|
32
|
+
walletAddress = null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (contact && walletAddress && contact.address !== walletAddress) {
|
|
36
|
+
throw new Error(
|
|
37
|
+
`Ambiguous destination ${input}: external contact @${contact.name} points to ${contact.address}, ` +
|
|
38
|
+
`but a stored signing wallet resolves to ${walletAddress}. Rename one of them.`,
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (contact) {
|
|
43
|
+
return {
|
|
44
|
+
input,
|
|
45
|
+
address: contact.address,
|
|
46
|
+
contactName: contact.name,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (walletAddress) {
|
|
51
|
+
return {
|
|
52
|
+
input,
|
|
53
|
+
address: walletAddress,
|
|
54
|
+
walletName: input.replace(/^@/, ""),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return { input, address: input };
|
|
59
|
+
}
|