@silkysquad/silk 1.0.0 → 1.0.2
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/README.md +1 -1
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +163 -0
- package/dist/cli.js.map +1 -0
- package/dist/client.d.ts +6 -0
- package/dist/client.js +36 -0
- package/dist/client.js.map +1 -0
- package/dist/commands/account.d.ts +11 -0
- package/dist/commands/account.js +156 -0
- package/dist/commands/account.js.map +1 -0
- package/dist/commands/balance.d.ts +3 -0
- package/dist/commands/balance.js +12 -0
- package/dist/commands/balance.js.map +1 -0
- package/dist/commands/cancel.d.ts +3 -0
- package/dist/commands/cancel.js +28 -0
- package/dist/commands/cancel.js.map +1 -0
- package/dist/commands/chat.d.ts +1 -0
- package/dist/commands/chat.js +12 -0
- package/dist/commands/chat.js.map +1 -0
- package/dist/commands/claim.d.ts +3 -0
- package/dist/commands/claim.js +28 -0
- package/dist/commands/claim.js.map +1 -0
- package/dist/commands/config.d.ts +6 -0
- package/dist/commands/config.js +40 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/contacts.d.ts +4 -0
- package/dist/commands/contacts.js +23 -0
- package/dist/commands/contacts.js.map +1 -0
- package/dist/commands/init.d.ts +1 -0
- package/dist/commands/init.js +37 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/pay.d.ts +4 -0
- package/dist/commands/pay.js +35 -0
- package/dist/commands/pay.js.map +1 -0
- package/dist/commands/payments.d.ts +4 -0
- package/dist/commands/payments.js +23 -0
- package/dist/commands/payments.js.map +1 -0
- package/dist/commands/wallet.d.ts +7 -0
- package/dist/commands/wallet.js +61 -0
- package/dist/commands/wallet.js.map +1 -0
- package/dist/config.d.ts +36 -0
- package/dist/config.js +63 -0
- package/dist/config.js.map +1 -0
- package/dist/contacts.d.ts +15 -0
- package/dist/contacts.js +74 -0
- package/dist/contacts.js.map +1 -0
- package/dist/errors.d.ts +14 -0
- package/dist/errors.js +87 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/output.d.ts +4 -0
- package/dist/output.js +42 -0
- package/dist/output.js.map +1 -0
- package/dist/transfers.d.ts +32 -0
- package/dist/transfers.js +12 -0
- package/dist/transfers.js.map +1 -0
- package/dist/validate.d.ts +8 -0
- package/dist/validate.js +69 -0
- package/dist/validate.js.map +1 -0
- package/package.json +29 -4
- package/CHANGELOG.md +0 -43
- package/SKILL.md +0 -698
- package/index.js +0 -1
- package/src/cli.ts +0 -175
- package/src/client.ts +0 -49
- package/src/commands/account.ts +0 -210
- package/src/commands/balance.ts +0 -14
- package/src/commands/cancel.ts +0 -34
- package/src/commands/chat.ts +0 -14
- package/src/commands/claim.ts +0 -34
- package/src/commands/config.ts +0 -46
- package/src/commands/contacts.ts +0 -26
- package/src/commands/init.ts +0 -44
- package/src/commands/pay.ts +0 -41
- package/src/commands/payments.ts +0 -29
- package/src/commands/wallet.ts +0 -67
- package/src/config.ts +0 -101
- package/src/contacts.ts +0 -94
- package/src/errors.ts +0 -95
- package/src/output.ts +0 -42
- package/src/transfers.ts +0 -49
- package/src/validate.ts +0 -80
- package/tsconfig.json +0 -19
- /package/{src/index.ts → dist/index.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transfers.js","sourceRoot":"","sources":["../src/transfers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAgB,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAmCvC,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,WAAmB,EACnB,MAAqB;IAErB,MAAM,MAAM,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,kBAAkB,WAAW,EAAE,CAAC,CAAC;IAC9D,MAAM,QAAQ,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;IACxC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,QAAQ,CAAC,oBAAoB,EAAE,uBAAuB,WAAW,EAAE,CAAC,CAAC;IACjF,CAAC;IACD,OAAO,QAAwB,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { TransferInfo } from './transfers.js';
|
|
3
|
+
export declare function validateAddress(address: string, field: string): void;
|
|
4
|
+
export declare function validateAmount(amount: string): number;
|
|
5
|
+
export declare function fetchTransfer(client: AxiosInstance, transferPda: string): Promise<TransferInfo>;
|
|
6
|
+
export declare function validateClaim(client: AxiosInstance, transferPda: string, claimerAddress: string): Promise<void>;
|
|
7
|
+
export declare function validateCancel(client: AxiosInstance, transferPda: string, cancellerAddress: string): Promise<void>;
|
|
8
|
+
export declare function validatePay(client: AxiosInstance, recipient: string, amount: string, senderAddress: string): Promise<number>;
|
package/dist/validate.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { PublicKey } from '@solana/web3.js';
|
|
2
|
+
import { SdkError } from './errors.js';
|
|
3
|
+
export function validateAddress(address, field) {
|
|
4
|
+
try {
|
|
5
|
+
new PublicKey(address);
|
|
6
|
+
}
|
|
7
|
+
catch {
|
|
8
|
+
throw new SdkError('INVALID_ADDRESS', `Invalid ${field} address: ${address}`);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export function validateAmount(amount) {
|
|
12
|
+
const num = parseFloat(amount);
|
|
13
|
+
if (isNaN(num) || num <= 0) {
|
|
14
|
+
throw new SdkError('INVALID_AMOUNT', `Amount must be a positive number, got: ${amount}`);
|
|
15
|
+
}
|
|
16
|
+
return num;
|
|
17
|
+
}
|
|
18
|
+
export async function fetchTransfer(client, transferPda) {
|
|
19
|
+
const res = await client.get(`/api/transfers/${transferPda}`);
|
|
20
|
+
const transfer = res.data?.data?.transfer;
|
|
21
|
+
if (!transfer) {
|
|
22
|
+
throw new SdkError('TRANSFER_NOT_FOUND', `Transfer not found: ${transferPda}`);
|
|
23
|
+
}
|
|
24
|
+
return transfer;
|
|
25
|
+
}
|
|
26
|
+
export async function validateClaim(client, transferPda, claimerAddress) {
|
|
27
|
+
const transfer = await fetchTransfer(client, transferPda);
|
|
28
|
+
if (transfer.status !== 'ACTIVE') {
|
|
29
|
+
throw new SdkError('TRANSFER_NOT_ACTIVE', `Transfer is ${transfer.status}, not ACTIVE`);
|
|
30
|
+
}
|
|
31
|
+
if (transfer.recipient !== claimerAddress) {
|
|
32
|
+
throw new SdkError('NOT_RECIPIENT', `Wallet ${claimerAddress} is not the recipient. Recipient is ${transfer.recipient}`);
|
|
33
|
+
}
|
|
34
|
+
const now = Date.now();
|
|
35
|
+
if (transfer.claimableAfter && now < new Date(transfer.claimableAfter).getTime()) {
|
|
36
|
+
throw new SdkError('CLAIM_WINDOW_NOT_OPEN', `Claim window opens at ${transfer.claimableAfter}`);
|
|
37
|
+
}
|
|
38
|
+
if (transfer.claimableUntil && now > new Date(transfer.claimableUntil).getTime()) {
|
|
39
|
+
throw new SdkError('CLAIM_WINDOW_CLOSED', `Claim window closed at ${transfer.claimableUntil}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export async function validateCancel(client, transferPda, cancellerAddress) {
|
|
43
|
+
const transfer = await fetchTransfer(client, transferPda);
|
|
44
|
+
if (transfer.status !== 'ACTIVE') {
|
|
45
|
+
throw new SdkError('TRANSFER_NOT_ACTIVE', `Transfer is ${transfer.status}, not ACTIVE`);
|
|
46
|
+
}
|
|
47
|
+
if (transfer.sender !== cancellerAddress) {
|
|
48
|
+
throw new SdkError('NOT_SENDER', `Wallet ${cancellerAddress} is not the sender. Sender is ${transfer.sender}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export async function validatePay(client, recipient, amount, senderAddress) {
|
|
52
|
+
validateAddress(recipient, 'recipient');
|
|
53
|
+
const amountNum = validateAmount(amount);
|
|
54
|
+
try {
|
|
55
|
+
const res = await client.get(`/api/wallet/${senderAddress}/balance`);
|
|
56
|
+
const tokens = res.data?.data?.tokens || [];
|
|
57
|
+
const usdc = tokens.find((t) => t.symbol === 'USDC');
|
|
58
|
+
if (usdc && parseFloat(usdc.balance) < amountNum) {
|
|
59
|
+
throw new SdkError('INSUFFICIENT_BALANCE', `Insufficient USDC balance: ${usdc.balance} < ${amountNum}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
if (err instanceof SdkError)
|
|
64
|
+
throw err;
|
|
65
|
+
// Balance check is best-effort; don't fail if the API is unreachable
|
|
66
|
+
}
|
|
67
|
+
return amountNum;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,MAAM,UAAU,eAAe,CAAC,OAAe,EAAE,KAAa;IAC5D,IAAI,CAAC;QACH,IAAI,SAAS,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,QAAQ,CAAC,iBAAiB,EAAE,WAAW,KAAK,aAAa,OAAO,EAAE,CAAC,CAAC;IAChF,CAAC;AACH,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,MAAc;IAC3C,MAAM,GAAG,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;IAC/B,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,QAAQ,CAAC,gBAAgB,EAAE,0CAA0C,MAAM,EAAE,CAAC,CAAC;IAC3F,CAAC;IACD,OAAO,GAAG,CAAC;AACb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YACjD,MAAM,IAAI,QAAQ,CAAC,sBAAsB,EAAE,8BAA8B,IAAI,CAAC,OAAO,MAAM,SAAS,EAAE,CAAC,CAAC;QAC1G,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,QAAQ;YAAE,MAAM,GAAG,CAAC;QACvC,qEAAqE;IACvE,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@silkysquad/silk",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "",
|
|
5
|
-
"
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "Agent payments on Solana — cancellable escrow USDC transfers and policy-controlled accounts",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"silk": "dist/cli.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
6
14
|
"scripts": {
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"dev": "tsc --watch",
|
|
17
|
+
"clean": "rm -rf dist",
|
|
7
18
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
19
|
},
|
|
9
|
-
"
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@solana/web3.js": "^1.98.4",
|
|
22
|
+
"axios": "^1.11.0",
|
|
23
|
+
"bs58": "^6.0.0",
|
|
24
|
+
"commander": "^12.1.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/node": "^22.10.7",
|
|
28
|
+
"typescript": "^5.7.3"
|
|
29
|
+
},
|
|
30
|
+
"private": false,
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"license": "MIT"
|
|
10
35
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to the Silkyway SDK will be documented in this file.
|
|
4
|
-
|
|
5
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
-
|
|
8
|
-
## [0.1.0] - 2026-02-12
|
|
9
|
-
|
|
10
|
-
### Added
|
|
11
|
-
|
|
12
|
-
- Initial release extracted from monorepo
|
|
13
|
-
- Escrow transfer support (`silk pay`, `silk claim`, `silk cancel`)
|
|
14
|
-
- On-chain account support with operator delegation and spending limits
|
|
15
|
-
- Multi-wallet management (`silk wallet create`, `silk wallet list`)
|
|
16
|
-
- Address book for contacts (`silk contacts add/remove/list/get`)
|
|
17
|
-
- Claim links for browser-based payment claiming
|
|
18
|
-
- Drift protocol integration for yield on account balances
|
|
19
|
-
- Multi-cluster support (mainnet-beta and devnet)
|
|
20
|
-
- Support chat integration (`silk chat`)
|
|
21
|
-
- DevNet faucet for testing (`silk wallet fund`)
|
|
22
|
-
- OpenClaw skill integration with ClawHub publishing
|
|
23
|
-
- Comprehensive CLI reference and API documentation
|
|
24
|
-
|
|
25
|
-
### Distribution
|
|
26
|
-
|
|
27
|
-
- Published to npm registry as `@silkyway/silk`
|
|
28
|
-
- Published to ClawHub as "silkyway" skill
|
|
29
|
-
- Dedicated repository at https://github.com/silkysquad/silk
|
|
30
|
-
|
|
31
|
-
### Requirements
|
|
32
|
-
|
|
33
|
-
- Node.js 18 or higher
|
|
34
|
-
- npm (comes with Node.js)
|
|
35
|
-
- Internet connection to Solana RPC and silkyway.ai API
|
|
36
|
-
|
|
37
|
-
### Security
|
|
38
|
-
|
|
39
|
-
- Non-custodial: private keys stored locally at `~/.config/silk/config.json`
|
|
40
|
-
- All authorization enforced on-chain by Solana programs
|
|
41
|
-
- Backend never sees private keys (build-sign-submit flow)
|
|
42
|
-
|
|
43
|
-
[0.1.0]: https://github.com/silkysquad/silk/releases/tag/v0.1.0
|