@keelcodes/sdk 1.0.0 → 2.1.0

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/dist/account.d.ts CHANGED
@@ -47,4 +47,27 @@ export declare class AccountAPI {
47
47
  subscribe: (p: SubscriptionParams) => Promise<SubscriptionResult>;
48
48
  cancel: (module: KeelModule) => Promise<unknown>;
49
49
  };
50
+ /** 创建提现(钱包签名;启用 TOTP 时需带 `totpCode`)。 */
51
+ withdraw(p: {
52
+ externalUserId: string;
53
+ toAddress: string;
54
+ amount: string;
55
+ token?: string;
56
+ totpCode?: string;
57
+ }): Promise<Record<string, unknown>>;
58
+ /** 提现列表(可选 `x-api-key`;无租户上下文时返回空列表 + 热钱包概况)。 */
59
+ withdrawals(p?: {
60
+ status?: string;
61
+ limit?: number;
62
+ offset?: number;
63
+ }): Promise<Record<string, unknown>>;
64
+ /** 租户余额总览(需配置 `tenantApiKey`)。 */
65
+ balances(): Promise<Record<string, unknown>>;
66
+ /** 租户交易流水(需配置 `tenantApiKey`)。 */
67
+ transactions(p?: {
68
+ limit?: number;
69
+ offset?: number;
70
+ }): Promise<Record<string, unknown>>;
71
+ /** 租户热钱包各链原生余额(需配置 `tenantApiKey`)。 */
72
+ hotWalletBalances(): Promise<Record<string, unknown>>;
50
73
  }
package/dist/account.js CHANGED
@@ -22,5 +22,39 @@ class AccountAPI {
22
22
  cancel: (module) => this.http.post('/v1/account/subscription/cancel', { module }),
23
23
  };
24
24
  }
25
+ /** 创建提现(钱包签名;启用 TOTP 时需带 `totpCode`)。 */
26
+ withdraw(p) {
27
+ return this.http.post('/v1/account/withdraw', p);
28
+ }
29
+ /** 提现列表(可选 `x-api-key`;无租户上下文时返回空列表 + 热钱包概况)。 */
30
+ withdrawals(p = {}) {
31
+ const q = new URLSearchParams();
32
+ if (p.status)
33
+ q.set('status', p.status);
34
+ if (p.limit)
35
+ q.set('limit', String(p.limit));
36
+ if (p.offset)
37
+ q.set('offset', String(p.offset));
38
+ const qs = q.toString();
39
+ return this.http.get('/v1/account/withdrawals' + (qs ? '?' + qs : ''));
40
+ }
41
+ /** 租户余额总览(需配置 `tenantApiKey`)。 */
42
+ balances() {
43
+ return this.http.get('/v1/account/balances');
44
+ }
45
+ /** 租户交易流水(需配置 `tenantApiKey`)。 */
46
+ transactions(p = {}) {
47
+ const q = new URLSearchParams();
48
+ if (p.limit)
49
+ q.set('limit', String(p.limit));
50
+ if (p.offset)
51
+ q.set('offset', String(p.offset));
52
+ const qs = q.toString();
53
+ return this.http.get('/v1/account/transactions' + (qs ? '?' + qs : ''));
54
+ }
55
+ /** 租户热钱包各链原生余额(需配置 `tenantApiKey`)。 */
56
+ hotWalletBalances() {
57
+ return this.http.get('/v1/account/hot-wallet/balances');
58
+ }
25
59
  }
26
60
  exports.AccountAPI = AccountAPI;
package/dist/data.d.ts CHANGED
@@ -75,6 +75,31 @@ export declare class DataAPI {
75
75
  predictions(params: PredictParams): Promise<PredictResult>;
76
76
  events(params?: EventsParams): Promise<EventsResult>;
77
77
  rag(params: RagParams): Promise<RagResult>;
78
+ /**
79
+ * SSE 实时流(ticker / factors)。返回原始 `Response`,由调用方消费 `res.body`。
80
+ * 该请求不设超时,需自行处理断线与重连。
81
+ */
82
+ stream(params?: {
83
+ channels?: string | string[];
84
+ symbols?: string | string[];
85
+ }): Promise<Response>;
86
+ /** 用户级数据 Key 自助管理(钱包签名;网关另需 `sk_data_*`)。 */
87
+ myKeys: {
88
+ /** 列出当前钱包持有的 key(不含明文)。 */
89
+ list: () => Promise<Record<string, unknown>>;
90
+ /** 创建 key:`{label, scope?, rate_limit?}`;明文仅本次返回。 */
91
+ create: (p: {
92
+ label: string;
93
+ scope?: string;
94
+ rate_limit?: number;
95
+ }) => Promise<Record<string, unknown>>;
96
+ /** 用一次性认领码换取 key 明文(仅一次可见)。 */
97
+ claim: (claimCode: string) => Promise<Record<string, unknown>>;
98
+ /** 轮换 key,返回新的明文。 */
99
+ rotate: (keyId: number | string) => Promise<Record<string, unknown>>;
100
+ /** 删除 key。 */
101
+ remove: (keyId: number | string) => Promise<Record<string, unknown>>;
102
+ };
78
103
  /** 取单符号最新行情(ticker)。 */
79
104
  ticker(symbol: string): Promise<Record<string, unknown>>;
80
105
  /** 列出受支持交易符号(可按市场 / 关键词过滤)。 */
package/dist/data.js CHANGED
@@ -7,6 +7,19 @@ exports.DataAPI = void 0;
7
7
  class DataAPI {
8
8
  constructor(http) {
9
9
  this.http = http;
10
+ /** 用户级数据 Key 自助管理(钱包签名;网关另需 `sk_data_*`)。 */
11
+ this.myKeys = {
12
+ /** 列出当前钱包持有的 key(不含明文)。 */
13
+ list: () => this.http.get('/v1/data/my-keys'),
14
+ /** 创建 key:`{label, scope?, rate_limit?}`;明文仅本次返回。 */
15
+ create: (p) => this.http.post('/v1/data/my-keys', p),
16
+ /** 用一次性认领码换取 key 明文(仅一次可见)。 */
17
+ claim: (claimCode) => this.http.post('/v1/data/my-keys/claim', { claim_code: claimCode }),
18
+ /** 轮换 key,返回新的明文。 */
19
+ rotate: (keyId) => this.http.post('/v1/data/my-keys/' + encodeURIComponent(String(keyId)) + '/rotate'),
20
+ /** 删除 key。 */
21
+ remove: (keyId) => this.http.delete('/v1/data/my-keys/' + encodeURIComponent(String(keyId))),
22
+ };
10
23
  // ── Market 子域(DEX 行情 / 监控 / 订阅):canonical `/v1/data/market*` ──
11
24
  this.market = {
12
25
  /** 按名称/符号搜索 DEX 代币(DexScreener)。 */
@@ -146,6 +159,18 @@ class DataAPI {
146
159
  rag(params) {
147
160
  return this.http.post('/v1/data/rag', params);
148
161
  }
162
+ /**
163
+ * SSE 实时流(ticker / factors)。返回原始 `Response`,由调用方消费 `res.body`。
164
+ * 该请求不设超时,需自行处理断线与重连。
165
+ */
166
+ stream(params = {}) {
167
+ const channels = Array.isArray(params.channels) ? params.channels.join(',') : (params.channels ?? 'ticker');
168
+ const q = new URLSearchParams({ channels });
169
+ if (params.symbols) {
170
+ q.set('symbols', Array.isArray(params.symbols) ? params.symbols.join(',') : params.symbols);
171
+ }
172
+ return this.http.stream('/v1/data/stream?' + q.toString());
173
+ }
149
174
  // ── 行情 / 符号 / 快照(旧 hub MCP 能力)──
150
175
  /** 取单符号最新行情(ticker)。 */
151
176
  ticker(symbol) {
package/dist/http.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { KeelConfig } from './types';
2
- /** SDK 版本(契约 §5,基线 1.0.0,随包版本同步)。 */
3
- export declare const SDK_VERSION = "1.0.0";
2
+ /** SDK 版本(契约 §5,基线 2.1.0,随包版本同步)。 */
3
+ export declare const SDK_VERSION = "2.1.0";
4
4
  export declare class HttpClient {
5
5
  private baseUrl;
6
6
  private headers;
@@ -11,7 +11,13 @@ export declare class HttpClient {
11
11
  get<T>(path: string, headers?: Record<string, string>): Promise<T>;
12
12
  post<T>(path: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
13
13
  put<T>(path: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
14
- private request;
14
+ delete<T>(path: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
15
+ /**
16
+ * 发起 SSE / 流式 GET,返回原始 `Response`(不解析 JSON、不设超时)。
17
+ * 调用方自行消费 `res.body`;非 2xx 仍抛 `KeelApiError`。
18
+ */
19
+ stream(path: string, headers?: Record<string, string>): Promise<Response>;
20
+ request<T>(method: string, path: string, body?: unknown, extraHeaders?: Record<string, string>): Promise<T>;
15
21
  /** 静态头 + (若配置)钱包签名头。签名按 WALLET_TOKEN_TTL_MS 复用。 */
16
22
  private buildHeaders;
17
23
  }
package/dist/http.js CHANGED
@@ -5,8 +5,8 @@
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.HttpClient = exports.SDK_VERSION = void 0;
7
7
  const errors_1 = require("./errors");
8
- /** SDK 版本(契约 §5,基线 1.0.0,随包版本同步)。 */
9
- exports.SDK_VERSION = '1.0.0';
8
+ /** SDK 版本(契约 §5,基线 2.1.0,随包版本同步)。 */
9
+ exports.SDK_VERSION = '2.1.0';
10
10
  /**
11
11
  * 钱包签名的复用时长(ms):首次签名后在该窗口内复用,避免每个请求都触发钱包弹窗。
12
12
  * 服务端会话 TTL 为 24h,此处取 1h 留足余量。
@@ -19,6 +19,8 @@ class HttpClient {
19
19
  this.headers = { 'Content-Type': 'application/json', 'X-Keel-Version': exports.SDK_VERSION };
20
20
  if (config.apiKey)
21
21
  this.headers['Authorization'] = `Bearer ${config.apiKey}`;
22
+ if (config.tenantApiKey)
23
+ this.headers['x-api-key'] = config.tenantApiKey;
22
24
  if (config.serviceKey)
23
25
  this.headers['X-Service-Key'] = config.serviceKey;
24
26
  if (config.wallet)
@@ -33,6 +35,24 @@ class HttpClient {
33
35
  async put(path, body, headers) {
34
36
  return this.request('PUT', path, body, headers);
35
37
  }
38
+ delete(path, body, headers) {
39
+ return this.request('DELETE', path, body, headers);
40
+ }
41
+ /**
42
+ * 发起 SSE / 流式 GET,返回原始 `Response`(不解析 JSON、不设超时)。
43
+ * 调用方自行消费 `res.body`;非 2xx 仍抛 `KeelApiError`。
44
+ */
45
+ async stream(path, headers) {
46
+ const res = await fetch(this.baseUrl + path, {
47
+ method: 'GET',
48
+ headers: { ...(await this.buildHeaders()), ...headers },
49
+ });
50
+ if (res.status < 200 || res.status >= 300) {
51
+ const json = await res.json().catch(() => ({}));
52
+ throw new errors_1.KeelApiError(path, res.status, json?.code ?? 'INTERNAL', json);
53
+ }
54
+ return res;
55
+ }
36
56
  async request(method, path, body, extraHeaders) {
37
57
  const controller = new AbortController();
38
58
  const timer = setTimeout(() => controller.abort(), this.timeout);
package/dist/index.d.ts CHANGED
@@ -10,6 +10,16 @@ export declare class Keel {
10
10
  readonly wallet: WalletAPI;
11
11
  readonly data: DataAPI;
12
12
  readonly account: AccountAPI;
13
+ private readonly http;
13
14
  constructor(config?: KeelConfig);
15
+ /**
16
+ * 通用逃生口:直接调用任意 canonical `/v1/<module>/*` 端点。
17
+ * 与命名空间方法共用同一套鉴权头(Bearer / x-api-key / 钱包签名)。
18
+ *
19
+ * @example
20
+ * const caps = await keel.request('GET', '/v1/payment/capabilities')
21
+ * const nft = await keel.request('GET', '/v1/wallet/nfts?chain=bsc')
22
+ */
23
+ request<T = unknown>(method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE', path: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
14
24
  }
15
25
  export default Keel;
package/dist/index.js CHANGED
@@ -18,11 +18,22 @@ Object.defineProperty(exports, "KeelApiError", { enumerable: true, get: function
18
18
  Object.defineProperty(exports, "isKeelApiError", { enumerable: true, get: function () { return errors_1.isKeelApiError; } });
19
19
  class Keel {
20
20
  constructor(config = {}) {
21
- const http = new http_1.HttpClient(config);
22
- this.payment = new payment_1.PaymentAPI(http);
23
- this.wallet = new wallet_1.WalletAPI(http);
24
- this.data = new data_1.DataAPI(http);
25
- this.account = new account_1.AccountAPI(http);
21
+ this.http = new http_1.HttpClient(config);
22
+ this.payment = new payment_1.PaymentAPI(this.http);
23
+ this.wallet = new wallet_1.WalletAPI(this.http);
24
+ this.data = new data_1.DataAPI(this.http);
25
+ this.account = new account_1.AccountAPI(this.http);
26
+ }
27
+ /**
28
+ * 通用逃生口:直接调用任意 canonical `/v1/<module>/*` 端点。
29
+ * 与命名空间方法共用同一套鉴权头(Bearer / x-api-key / 钱包签名)。
30
+ *
31
+ * @example
32
+ * const caps = await keel.request('GET', '/v1/payment/capabilities')
33
+ * const nft = await keel.request('GET', '/v1/wallet/nfts?chain=bsc')
34
+ */
35
+ request(method, path, body, headers) {
36
+ return this.http.request(method, path, body, headers);
26
37
  }
27
38
  }
28
39
  exports.Keel = Keel;
package/dist/payment.d.ts CHANGED
@@ -4,19 +4,14 @@ export interface ChargeParams {
4
4
  payer: string;
5
5
  amountWei: string;
6
6
  /** 收费 rail(内部路由,对外仅暴露语义)。 */
7
- method: 'fiat' | 'x402' | 'a2a' | 'batch' | 'invite';
7
+ method: 'x402' | 'a2a' | 'batch' | 'invite';
8
8
  asset?: string;
9
9
  chain?: string;
10
10
  reference: Reference;
11
11
  metadata?: Record<string, unknown>;
12
12
  }
13
- /** fiat 走 sessionUrl;链上走 payTo/priceWei。 */
13
+ /** 链上收费返回收款地址 / 价格 / 网络。 */
14
14
  export type ChargeResult = {
15
- reference: string;
16
- sessionUrl: string;
17
- paymentId: string;
18
- redirect: true;
19
- } | {
20
15
  reference: string;
21
16
  payTo: string;
22
17
  priceWei: string;
@@ -106,7 +101,7 @@ export interface PaymentRequiredBody {
106
101
  export declare class PaymentAPI {
107
102
  private http;
108
103
  constructor(http: HttpClient);
109
- /** 发起收费(内部路由 fiat/x402/a2a/batch/invite)。 */
104
+ /** 发起收费(内部路由 x402/a2a/batch/invite)。 */
110
105
  charge(params: ChargeParams): Promise<ChargeResult>;
111
106
  /** 主动付费。 */
112
107
  pay(params: PayParams): Promise<PayResult>;
@@ -132,29 +127,22 @@ export declare class PaymentAPI {
132
127
  }): Promise<Record<string, unknown>>;
133
128
  /** 支付通道发现:启用的 rail、各链收款钱包 / 价格 / 托管、各链可接受的稳定币。 */
134
129
  info(chain?: string): Promise<Record<string, unknown>>;
135
- /** fiat 结账(Stripe):返回 sessionUrl。mode=payment 为一次性扣款(默认订阅)。 */
136
- checkout(params: {
137
- subscriber: string;
138
- amountCents?: number;
139
- planId?: number;
140
- period?: string;
141
- currency?: string;
142
- chain?: string;
143
- mode?: 'subscription' | 'payment';
144
- metadata?: Record<string, unknown>;
145
- clientReference?: string;
146
- }): Promise<Record<string, unknown>>;
147
130
  /** 读取链上订阅详情(active / payToken / amountPaid / 周期 / 试用)。 */
148
131
  subscriptionDetail(chain: string, subscriber: string, resourceId: number): Promise<Record<string, unknown>>;
149
132
  /** 读取链上套餐定价(price / period / active)。 */
150
133
  price(planId: number, chain?: string): Promise<Record<string, unknown>>;
151
- /** 创建 a2a 链上支付意图(phase 1)。 */
134
+ /**
135
+ * 创建 a2a 支付意图(phase 1)。
136
+ * `settlementMode: 'direct'` 时 `payee` 必填,settle 只核验 payer → payee 的链上转账。
137
+ */
152
138
  a2aCreate(params: {
153
139
  subscriber: string;
154
140
  valueWei: string;
155
141
  asset?: string;
156
142
  chain?: string;
157
143
  payee?: string;
144
+ settlementMode?: 'collector' | 'direct';
145
+ expiresIn?: number;
158
146
  metadata?: Record<string, unknown>;
159
147
  }): Promise<Record<string, unknown>>;
160
148
  /** 确认 a2a 支付意图(phase 2):mode=tx 校验链上交易;mode=balance 走账本扣减。 */
@@ -168,6 +156,10 @@ export declare class PaymentAPI {
168
156
  asset?: string;
169
157
  ref?: string;
170
158
  }): Promise<Record<string, unknown>>;
159
+ /** 结算 direct 意图(phase 2):按 intent 绑定的 payee/asset/精确金额核验,并按链确认数判定终局。 */
160
+ a2aDirectSettle(paymentId: string, txHash: string): Promise<Record<string, unknown>>;
161
+ /** 取消未结算的 direct 意图(幂等)。 */
162
+ a2aCancel(paymentId: string): Promise<Record<string, unknown>>;
171
163
  /** 创建批量收款意图(一付款人对多收款人)。 */
172
164
  batchCreate(params: {
173
165
  subscriber: string;
@@ -235,31 +227,41 @@ export declare class PaymentAPI {
235
227
  transferConfirm(transferId: string): Promise<Record<string, unknown>>;
236
228
  /** 取消未执行的转账。 */
237
229
  transferCancel(transferId: string): Promise<Record<string, unknown>>;
238
- /** 打开 MPP 支付通道(校验充值交易)。 */
239
- mppOpen(params: {
240
- payer: string;
241
- depositWei: string;
242
- salt: string;
243
- txHash: string;
244
- chain?: string;
245
- metadata?: Record<string, unknown>;
246
- }): Promise<Record<string, unknown>>;
247
- /** 提交 MPP 累计凭证(EIP-712 签名)。 */
248
- mppVoucher(params: {
249
- channelId: string;
250
- cumulativeAmount: string;
251
- signature: string;
252
- }): Promise<Record<string, unknown>>;
253
- /** 为 MPP 通道追加充值。 */
254
- mppTopup(params: {
255
- channelId: string;
256
- txHash: string;
257
- additionalWei: string;
258
- }): Promise<Record<string, unknown>>;
259
- /** 批量结算 MPP 通道未结消费。 */
260
- mppSettle(channelId: string): Promise<Record<string, unknown>>;
261
- /** 关闭 MPP 通道(先结算尾部)。 */
262
- mppClose(channelId: string): Promise<Record<string, unknown>>;
263
- /** 读取 MPP 通道当前状态。 */
264
- mppSession(channelId: string): Promise<Record<string, unknown>>;
230
+ /** 周期订阅扣费(基于已创建的 authorization)。 */
231
+ period: {
232
+ /** 扣减一个周期;返回 authorizationId 与扣费结果。 */
233
+ charge: (authorizationId: string) => Promise<Record<string, unknown>>;
234
+ /** 查询周期授权状态(剩余额度 / 周期 / 状态)。 */
235
+ authorization: (authorizationId: string) => Promise<Record<string, unknown>>;
236
+ };
237
+ /** 托管(escrow)链上按量计费 / 退款。 */
238
+ escrow: {
239
+ /** relayer 代为签名扣费:`{chain, user, amountWei, reference}`。 */
240
+ charge: (p: {
241
+ chain: string;
242
+ user: string;
243
+ amountWei: string;
244
+ reference: string;
245
+ }) => Promise<Record<string, unknown>>;
246
+ /** relayer 代为签名退款:`{chain, user, amountWei, reference}`。 */
247
+ refund: (p: {
248
+ chain: string;
249
+ user: string;
250
+ amountWei: string;
251
+ reference: string;
252
+ }) => Promise<Record<string, unknown>>;
253
+ /** 查询托管余额(未配置链返回 `{configured:false, balanceWei:'0'}`)。 */
254
+ balance: (chain: string, user: string) => Promise<Record<string, unknown>>;
255
+ /** 查询链上托管配置(地址 / 限额)。 */
256
+ info: (chain: string) => Promise<Record<string, unknown>>;
257
+ /** relayer gas 健康;不传 chain 返回全部已配置链。 */
258
+ relayerStatus: (chain?: string) => Promise<Record<string, unknown>>;
259
+ /** 核验 Solana 原生 SOL 充值并入账(幂等键 `sol:<signature>`)。 */
260
+ solanaVerify: (p: {
261
+ signature: string;
262
+ from: string;
263
+ amountLamports: string | number;
264
+ waitMs?: number;
265
+ }) => Promise<Record<string, unknown>>;
266
+ };
265
267
  }
package/dist/payment.js CHANGED
@@ -7,8 +7,30 @@ exports.PaymentAPI = void 0;
7
7
  class PaymentAPI {
8
8
  constructor(http) {
9
9
  this.http = http;
10
- }
11
- /** 发起收费(内部路由 fiat/x402/a2a/batch/invite)。 */
10
+ /** 周期订阅扣费(基于已创建的 authorization)。 */
11
+ this.period = {
12
+ /** 扣减一个周期;返回 authorizationId 与扣费结果。 */
13
+ charge: (authorizationId) => this.http.post('/v1/payment/period/charge', { authorizationId }),
14
+ /** 查询周期授权状态(剩余额度 / 周期 / 状态)。 */
15
+ authorization: (authorizationId) => this.http.get('/v1/payment/period/authorization?authorizationId=' + encodeURIComponent(authorizationId)),
16
+ };
17
+ /** 托管(escrow)链上按量计费 / 退款。 */
18
+ this.escrow = {
19
+ /** relayer 代为签名扣费:`{chain, user, amountWei, reference}`。 */
20
+ charge: (p) => this.http.post('/v1/payment/escrow/charge', p),
21
+ /** relayer 代为签名退款:`{chain, user, amountWei, reference}`。 */
22
+ refund: (p) => this.http.post('/v1/payment/escrow/refund', p),
23
+ /** 查询托管余额(未配置链返回 `{configured:false, balanceWei:'0'}`)。 */
24
+ balance: (chain, user) => this.http.get('/v1/payment/escrow/balance?' + new URLSearchParams({ chain, user }).toString()),
25
+ /** 查询链上托管配置(地址 / 限额)。 */
26
+ info: (chain) => this.http.get('/v1/payment/escrow/info?chain=' + encodeURIComponent(chain)),
27
+ /** relayer gas 健康;不传 chain 返回全部已配置链。 */
28
+ relayerStatus: (chain) => this.http.get('/v1/payment/escrow/relayer-status' + (chain ? '?chain=' + encodeURIComponent(chain) : '')),
29
+ /** 核验 Solana 原生 SOL 充值并入账(幂等键 `sol:<signature>`)。 */
30
+ solanaVerify: (p) => this.http.post('/v1/payment/solana/verify', p),
31
+ };
32
+ }
33
+ /** 发起收费(内部路由 x402/a2a/batch/invite)。 */
12
34
  charge(params) {
13
35
  return this.http.post('/v1/payment/charge', params);
14
36
  }
@@ -61,15 +83,11 @@ class PaymentAPI {
61
83
  ledgerBalance(params) {
62
84
  return this.http.post('/v1/payment/ledger-balance', params);
63
85
  }
64
- // ── 旧 index MCP 能力补齐:通道发现 / 链上意图 / 批量 / 邀请 / 转账 / MPP ──
86
+ // ── 旧 index MCP 能力补齐:通道发现 / 链上意图 / 批量 / 邀请 / 转账 ──
65
87
  /** 支付通道发现:启用的 rail、各链收款钱包 / 价格 / 托管、各链可接受的稳定币。 */
66
88
  info(chain) {
67
89
  return this.http.get('/v1/payment/info' + (chain ? '?chain=' + encodeURIComponent(chain) : ''));
68
90
  }
69
- /** fiat 结账(Stripe):返回 sessionUrl。mode=payment 为一次性扣款(默认订阅)。 */
70
- checkout(params) {
71
- return this.http.post('/v1/payment/checkout', params);
72
- }
73
91
  /** 读取链上订阅详情(active / payToken / amountPaid / 周期 / 试用)。 */
74
92
  subscriptionDetail(chain, subscriber, resourceId) {
75
93
  return this.http.get('/v1/payment/subscription-detail/' + encodeURIComponent(chain) + '/' + encodeURIComponent(subscriber) + '/' + encodeURIComponent(String(resourceId)));
@@ -78,7 +96,10 @@ class PaymentAPI {
78
96
  price(planId, chain) {
79
97
  return this.http.get('/v1/payment/price?chain=' + encodeURIComponent(chain || 'bsc') + '&planId=' + encodeURIComponent(String(planId)));
80
98
  }
81
- /** 创建 a2a 链上支付意图(phase 1)。 */
99
+ /**
100
+ * 创建 a2a 支付意图(phase 1)。
101
+ * `settlementMode: 'direct'` 时 `payee` 必填,settle 只核验 payer → payee 的链上转账。
102
+ */
82
103
  a2aCreate(params) {
83
104
  return this.http.post('/v1/payment/a2a', params);
84
105
  }
@@ -86,6 +107,14 @@ class PaymentAPI {
86
107
  a2aSettle(params) {
87
108
  return this.http.post('/v1/payment/a2a/settle', params);
88
109
  }
110
+ /** 结算 direct 意图(phase 2):按 intent 绑定的 payee/asset/精确金额核验,并按链确认数判定终局。 */
111
+ a2aDirectSettle(paymentId, txHash) {
112
+ return this.http.post('/v1/payment/a2a/' + encodeURIComponent(paymentId) + '/settle', { txHash });
113
+ }
114
+ /** 取消未结算的 direct 意图(幂等)。 */
115
+ a2aCancel(paymentId) {
116
+ return this.http.post('/v1/payment/a2a/' + encodeURIComponent(paymentId) + '/cancel', {});
117
+ }
89
118
  /** 创建批量收款意图(一付款人对多收款人)。 */
90
119
  batchCreate(params) {
91
120
  return this.http.post('/v1/payment/batch', params);
@@ -149,29 +178,5 @@ class PaymentAPI {
149
178
  transferCancel(transferId) {
150
179
  return this.http.post('/v1/payment/transfers/' + encodeURIComponent(transferId) + '/cancel');
151
180
  }
152
- /** 打开 MPP 支付通道(校验充值交易)。 */
153
- mppOpen(params) {
154
- return this.http.post('/v1/payment/mpp/open', params);
155
- }
156
- /** 提交 MPP 累计凭证(EIP-712 签名)。 */
157
- mppVoucher(params) {
158
- return this.http.post('/v1/payment/mpp/voucher', params);
159
- }
160
- /** 为 MPP 通道追加充值。 */
161
- mppTopup(params) {
162
- return this.http.post('/v1/payment/mpp/topup', params);
163
- }
164
- /** 批量结算 MPP 通道未结消费。 */
165
- mppSettle(channelId) {
166
- return this.http.post('/v1/payment/mpp/settle', { channelId });
167
- }
168
- /** 关闭 MPP 通道(先结算尾部)。 */
169
- mppClose(channelId) {
170
- return this.http.post('/v1/payment/mpp/close', { channelId });
171
- }
172
- /** 读取 MPP 通道当前状态。 */
173
- mppSession(channelId) {
174
- return this.http.get('/v1/payment/mpp/session?channelId=' + encodeURIComponent(channelId));
175
- }
176
181
  }
177
182
  exports.PaymentAPI = PaymentAPI;
package/dist/types.d.ts CHANGED
@@ -13,6 +13,8 @@ export interface KeelConfig {
13
13
  baseUrl?: string;
14
14
  /** Bearer API key(按模块订阅签发,`sk_<module>_*`) */
15
15
  apiKey?: string;
16
+ /** 租户级 `x-api-key`(WAAS 租户资源面:余额 / 流水 / 提现列表等)。 */
17
+ tenantApiKey?: string;
16
18
  /** 内部服务鉴权 key(`X-Service-Key`);供网关服务级旁路放行可信内部组件(如 keel-mcp)。 */
17
19
  serviceKey?: string;
18
20
  /** 请求超时(ms),默认 30000 */
@@ -0,0 +1,5 @@
1
+ export * from './types';
2
+ export * from './solana-account-types';
3
+ export * from './solana-execution-types';
4
+ export * from './mpc-types';
5
+ export * from './wallet-api';
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ // ---------------------------------------------------------------------------
3
+ // @keelcodes/sdk — wallet 模块
4
+ // ---------------------------------------------------------------------------
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ __exportStar(require("./types"), exports);
21
+ __exportStar(require("./solana-account-types"), exports);
22
+ __exportStar(require("./solana-execution-types"), exports);
23
+ __exportStar(require("./mpc-types"), exports);
24
+ __exportStar(require("./wallet-api"), exports);
@@ -0,0 +1,47 @@
1
+ export interface MpcSendCodeParams {
2
+ email: string;
3
+ }
4
+ export interface MpcVerifyParams {
5
+ email: string;
6
+ code: string;
7
+ }
8
+ export interface MpcBalanceParams {
9
+ token: string;
10
+ chain?: string;
11
+ tokenAddress?: string;
12
+ }
13
+ export interface MpcSignMessageParams {
14
+ token: string;
15
+ message: string;
16
+ }
17
+ export interface MpcSignTypedDataParams {
18
+ token: string;
19
+ domain: Record<string, unknown>;
20
+ types: Record<string, unknown>;
21
+ value: Record<string, unknown>;
22
+ }
23
+ export interface MpcSendTransactionParams {
24
+ token: string;
25
+ to: string;
26
+ amount: string;
27
+ chain?: string;
28
+ tokenAddress?: string;
29
+ }
30
+ export interface MpcContractCallParams {
31
+ contractAddress: string;
32
+ abi: unknown[];
33
+ method: string;
34
+ args?: unknown[];
35
+ chain?: string;
36
+ }
37
+ export interface MpcContractWriteParams extends MpcContractCallParams {
38
+ token: string;
39
+ value?: string;
40
+ gasLimit?: string;
41
+ }
42
+ export interface MpcGasEstimateParams {
43
+ to?: string;
44
+ value?: string;
45
+ data?: string;
46
+ chain?: string;
47
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,118 @@
1
+ export interface SolanaDeriveAccountParams {
2
+ chain: string;
3
+ accountIndex: string | number;
4
+ smartAccountIndex?: string | number;
5
+ }
6
+ export interface SolanaDerivedAccount {
7
+ chain: string;
8
+ accountIndex: string;
9
+ smartAccountIndex: number;
10
+ settingsPda: string;
11
+ smartAccountPda: string;
12
+ }
13
+ export interface SolanaCreateAccountParams {
14
+ chain: string;
15
+ blockhash: string;
16
+ treasury: string;
17
+ creator: string;
18
+ settingsPda: string;
19
+ signers: Array<Record<string, unknown>>;
20
+ settingsAuthority?: string;
21
+ threshold?: number;
22
+ timeLock?: number;
23
+ rentCollector?: string;
24
+ memo?: string;
25
+ }
26
+ export interface SolanaInstallPolicyParams {
27
+ chain: string;
28
+ blockhash: string;
29
+ feePayer: string;
30
+ creator: string;
31
+ settingsPda: string;
32
+ transactionIndex: string | number;
33
+ signer: Record<string, unknown>;
34
+ /** 旧口径 `SettingsAction::AddSpendingLimit`(已 deprecated) */
35
+ spendingLimit?: Record<string, unknown>;
36
+ /** 新口径 `SettingsAction::PolicyCreate`(spending limit policy) */
37
+ spendingLimitPolicy?: SolanaSpendingLimitPolicy;
38
+ }
39
+ /** 新口径 spending limit policy(`PolicyCreate`;金额/seed 为十进制整数,可用字符串)。 */
40
+ export interface SolanaSpendingLimitPolicy {
41
+ seed: string | number;
42
+ mint: string;
43
+ sourceAccountIndex?: number;
44
+ amount: string | number;
45
+ maxPerUse?: string | number;
46
+ /** 旧 `Period` 枚举值(0=OneTime / 1=Day / 2=Week / 3=Month) */
47
+ period?: number;
48
+ start?: string | number;
49
+ expiration?: string | number;
50
+ accumulateUnused?: boolean;
51
+ enforceExactQuantity?: boolean;
52
+ destinations?: string[];
53
+ signers: Array<Record<string, unknown>>;
54
+ threshold?: number;
55
+ timeLock?: number;
56
+ }
57
+ export interface SolanaCreatePolicyTransactionParams {
58
+ chain: string;
59
+ blockhash: string;
60
+ feePayer: string;
61
+ /** policy PDA */
62
+ policy: string;
63
+ transactionIndex: string | number;
64
+ creator: string;
65
+ rentPayer?: string;
66
+ accountIndex?: number;
67
+ amount: string | number;
68
+ destination: string;
69
+ decimals: number;
70
+ }
71
+ export interface SolanaCreateProposalParams {
72
+ chain: string;
73
+ blockhash: string;
74
+ feePayer: string;
75
+ /** 共识账户:settings PDA(settings 交易)或 policy PDA(policy 交易) */
76
+ settingsPda: string;
77
+ transactionIndex: string | number;
78
+ creator: string;
79
+ rentPayer?: string;
80
+ isDraft?: boolean;
81
+ }
82
+ export interface SolanaApproveProposalParams {
83
+ chain: string;
84
+ blockhash: string;
85
+ feePayer: string;
86
+ /** 共识账户:settings PDA(settings 交易)或 policy PDA(policy 交易) */
87
+ settingsPda: string;
88
+ transactionIndex: string | number;
89
+ signer: string;
90
+ memo?: string;
91
+ }
92
+ export interface SolanaExecutePolicyTransactionParams {
93
+ chain: string;
94
+ blockhash: string;
95
+ feePayer: string;
96
+ /** policy PDA */
97
+ policy: string;
98
+ transactionIndex: string | number;
99
+ signer: string;
100
+ /** 策略执行所需的剩余账户(native SOL: [source, destination, systemProgram]) */
101
+ anchorRemainingAccounts: Array<{
102
+ pubkey: string;
103
+ isWritable?: boolean;
104
+ isSigner?: boolean;
105
+ }>;
106
+ }
107
+ export interface SolanaRemovePolicyParams {
108
+ chain: string;
109
+ blockhash: string;
110
+ feePayer: string;
111
+ creator: string;
112
+ settingsPda: string;
113
+ transactionIndex: string | number;
114
+ /** 待删除的 policy PDA(同时需在 execute 时作为 remaining account 传入) */
115
+ policy: string;
116
+ rentPayer?: string;
117
+ memo?: string;
118
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,90 @@
1
+ export interface SolanaCloseTransactionParams {
2
+ chain: string;
3
+ blockhash: string;
4
+ feePayer: string;
5
+ /** 共识账户:policy PDA(policy 交易)或 settings PDA(settings 交易) */
6
+ settingsPda: string;
7
+ transactionIndex: string | number;
8
+ /** transaction 账户 rent 回收地址;缺省 feePayer */
9
+ transactionRentCollector?: string;
10
+ /** proposal 账户 rent 回收地址;缺省 transactionRentCollector */
11
+ proposalRentCollector?: string;
12
+ }
13
+ export interface SolanaExecutePolicyPayloadParams {
14
+ chain: string;
15
+ blockhash: string;
16
+ feePayer: string;
17
+ /** policy PDA */
18
+ policy: string;
19
+ accountIndex?: number;
20
+ numSigners: number;
21
+ amount: string | number;
22
+ destination: string;
23
+ decimals: number;
24
+ instructionAccounts: Array<{
25
+ pubkey: string;
26
+ isWritable?: boolean;
27
+ isSigner?: boolean;
28
+ }>;
29
+ }
30
+ export interface SolanaCloseSettingsParams {
31
+ chain: string;
32
+ blockhash: string;
33
+ feePayer: string;
34
+ settingsPda: string;
35
+ transactionIndex: string | number;
36
+ transactionRentCollector?: string;
37
+ proposalRentCollector?: string;
38
+ }
39
+ export interface SolanaExecutePolicyParams {
40
+ chain: string;
41
+ blockhash: string;
42
+ feePayer: string;
43
+ settingsPda: string;
44
+ transactionIndex: string | number;
45
+ signer: string;
46
+ rentPayer?: string;
47
+ spendingLimits?: Array<Record<string, unknown>>;
48
+ /** `PolicyCreate` / `PolicyRemove` 的 policy PDA 列表(remaining accounts) */
49
+ policies?: string[];
50
+ }
51
+ export interface SolanaExecuteParams {
52
+ chain: string;
53
+ blockhash: string;
54
+ feePayer: string;
55
+ settingsPda: string;
56
+ signer: string;
57
+ spendingLimit: string;
58
+ mint?: string;
59
+ accountIndex: number;
60
+ amount: string | number;
61
+ decimals: number;
62
+ destination: string;
63
+ tokenProgram?: string;
64
+ memo?: string;
65
+ }
66
+ export interface SolanaRemoveSignerParams {
67
+ chain: string;
68
+ blockhash: string;
69
+ feePayer: string;
70
+ settingsPda: string;
71
+ settingsAuthority: string;
72
+ oldSigner: string;
73
+ memo?: string;
74
+ }
75
+ export interface SolanaSubmitParams {
76
+ chain: string;
77
+ transaction: string;
78
+ }
79
+ /** 构建端点返回的未签名交易(base64)。 */
80
+ export interface SolanaUnsignedTransaction {
81
+ chain: string;
82
+ transaction: string;
83
+ feePayer?: string;
84
+ instructionCount?: number;
85
+ }
86
+ export interface SolanaSubmitResult {
87
+ chain: string;
88
+ signature: string;
89
+ feePayer?: string;
90
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,74 @@
1
+ export type WalletType = 'waas' | 'mpc' | 'safe' | 'aa';
2
+ export interface CreateWalletParams {
3
+ type: WalletType;
4
+ chain?: string;
5
+ /** 幂等键(同 reference 不重复建钱包)。 */
6
+ reference?: string;
7
+ }
8
+ export interface ImportWalletParams {
9
+ type: WalletType;
10
+ seed?: string;
11
+ privateKey?: string;
12
+ }
13
+ export interface WalletCreated {
14
+ walletId: string;
15
+ address: string;
16
+ }
17
+ export interface SignParams {
18
+ walletId: string;
19
+ message?: string;
20
+ typedData?: Record<string, unknown>;
21
+ digest?: string;
22
+ chain?: string;
23
+ }
24
+ export interface SignResult {
25
+ signature: string;
26
+ address: string;
27
+ }
28
+ export interface SendParams {
29
+ walletId: string;
30
+ to: string;
31
+ amount: string;
32
+ chain: string;
33
+ tokenAddress?: string;
34
+ /** 幂等键(防重复转账)。 */
35
+ reference?: string;
36
+ }
37
+ export interface SendResult {
38
+ txHash: string;
39
+ status: string;
40
+ }
41
+ export interface ChainParams {
42
+ chain: string;
43
+ method: string;
44
+ params?: unknown[];
45
+ rawTransaction?: string;
46
+ }
47
+ export interface ChainResult {
48
+ result?: unknown;
49
+ txHash?: string;
50
+ }
51
+ export interface WalletBalanceParams {
52
+ address: string;
53
+ chain?: string;
54
+ token?: string;
55
+ }
56
+ export interface WalletChainBalance {
57
+ chain: string;
58
+ address: string;
59
+ balances: Array<{
60
+ token: string;
61
+ token_address: string;
62
+ /** 人类可读金额:EVM 为原生币小数(18 位),Solana 为 SOL 小数(9 位) */
63
+ balance: string;
64
+ /** 仅 Solana:原始 lamports(十进制字符串) */
65
+ balance_lamports?: string;
66
+ usd_value: string;
67
+ }>;
68
+ usdTotal: string;
69
+ error?: string;
70
+ }
71
+ export interface WalletBalanceResult {
72
+ chainBalances: WalletChainBalance[];
73
+ totalUsd: string;
74
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ // ---------------------------------------------------------------------------
3
+ // @keelcodes/sdk — wallet 模块:核心类型
4
+ // ---------------------------------------------------------------------------
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,109 +1,8 @@
1
- import { HttpClient } from './http';
2
- export type WalletType = 'waas' | 'mpc' | 'safe' | 'aa';
3
- export interface CreateWalletParams {
4
- type: WalletType;
5
- chain?: string;
6
- /** 幂等键(同 reference 不重复建钱包)。 */
7
- reference?: string;
8
- }
9
- export interface ImportWalletParams {
10
- type: WalletType;
11
- seed?: string;
12
- privateKey?: string;
13
- }
14
- export interface WalletCreated {
15
- walletId: string;
16
- address: string;
17
- }
18
- export interface SignParams {
19
- walletId: string;
20
- message?: string;
21
- typedData?: Record<string, unknown>;
22
- digest?: string;
23
- chain?: string;
24
- }
25
- export interface SignResult {
26
- signature: string;
27
- address: string;
28
- }
29
- export interface SendParams {
30
- walletId: string;
31
- to: string;
32
- amount: string;
33
- chain: string;
34
- tokenAddress?: string;
35
- /** 幂等键(防重复转账)。 */
36
- reference?: string;
37
- }
38
- export interface SendResult {
39
- txHash: string;
40
- status: string;
41
- }
42
- export interface ChainParams {
43
- chain: string;
44
- method: string;
45
- params?: unknown[];
46
- rawTransaction?: string;
47
- }
48
- export interface ChainResult {
49
- result?: unknown;
50
- txHash?: string;
51
- }
52
- export interface WalletBalanceParams {
53
- address: string;
54
- chain?: string;
55
- token?: string;
56
- }
57
- export interface WalletBalanceResult {
58
- balance: string;
59
- }
60
- export interface MpcSendCodeParams {
61
- email: string;
62
- }
63
- export interface MpcVerifyParams {
64
- email: string;
65
- code: string;
66
- }
67
- export interface MpcBalanceParams {
68
- token: string;
69
- chain?: string;
70
- tokenAddress?: string;
71
- }
72
- export interface MpcSignMessageParams {
73
- token: string;
74
- message: string;
75
- }
76
- export interface MpcSignTypedDataParams {
77
- token: string;
78
- domain: Record<string, unknown>;
79
- types: Record<string, unknown>;
80
- value: Record<string, unknown>;
81
- }
82
- export interface MpcSendTransactionParams {
83
- token: string;
84
- to: string;
85
- amount: string;
86
- chain?: string;
87
- tokenAddress?: string;
88
- }
89
- export interface MpcContractCallParams {
90
- contractAddress: string;
91
- abi: unknown[];
92
- method: string;
93
- args?: unknown[];
94
- chain?: string;
95
- }
96
- export interface MpcContractWriteParams extends MpcContractCallParams {
97
- token: string;
98
- value?: string;
99
- gasLimit?: string;
100
- }
101
- export interface MpcGasEstimateParams {
102
- to?: string;
103
- value?: string;
104
- data?: string;
105
- chain?: string;
106
- }
1
+ import { HttpClient } from '../http';
2
+ import type { CreateWalletParams, WalletCreated, ImportWalletParams, SignParams, SignResult, SendParams, SendResult, ChainParams, ChainResult, WalletBalanceParams, WalletBalanceResult } from './types';
3
+ import type { SolanaDeriveAccountParams, SolanaDerivedAccount, SolanaCreateAccountParams, SolanaInstallPolicyParams, SolanaCreatePolicyTransactionParams, SolanaCreateProposalParams, SolanaApproveProposalParams, SolanaExecutePolicyTransactionParams, SolanaRemovePolicyParams } from './solana-account-types';
4
+ import type { SolanaExecutePolicyPayloadParams, SolanaCloseSettingsParams, SolanaCloseTransactionParams, SolanaExecutePolicyParams, SolanaExecuteParams, SolanaRemoveSignerParams, SolanaSubmitParams, SolanaUnsignedTransaction, SolanaSubmitResult } from './solana-execution-types';
5
+ import type { MpcSendCodeParams, MpcVerifyParams, MpcBalanceParams, MpcSignMessageParams, MpcSignTypedDataParams, MpcSendTransactionParams, MpcContractCallParams, MpcContractWriteParams, MpcGasEstimateParams } from './mpc-types';
107
6
  export declare class WalletAPI {
108
7
  private http;
109
8
  constructor(http: HttpClient);
@@ -131,6 +30,27 @@ export declare class WalletAPI {
131
30
  /** 链上读写(读 + 广播统一,走 chain-rpc 聚合层)。 */
132
31
  chain(params: ChainParams): Promise<ChainResult>;
133
32
  balance(params: WalletBalanceParams): Promise<WalletBalanceResult>;
33
+ /** 查询当前钱包在指定链的充值地址。 */
34
+ address(chain: string): Promise<Record<string, unknown>>;
35
+ /** 交易流水(托管查库;`nc=true` 时直接扫链)。 */
36
+ transactions(p?: {
37
+ page?: number;
38
+ limit?: number;
39
+ chain?: string;
40
+ type?: string;
41
+ nc?: boolean;
42
+ }): Promise<Record<string, unknown>>;
43
+ /** 批量转账(需 admin 权限,B 端钱包签名不可用;建议用 `request` 直连或逐笔 `send`)。 */
44
+ batch(p: {
45
+ walletId: string;
46
+ transfers: Array<{
47
+ to: string;
48
+ amount: string;
49
+ }>;
50
+ paymentPassword: string;
51
+ }): Promise<Record<string, unknown>>;
52
+ /** 查询批量转账进度。 */
53
+ batchProgress(batchId: string): Promise<Record<string, unknown>>;
134
54
  /** Chain-RPC 子域:池状态 / 读套餐订阅面(canonical `/v1/wallet/chain/*`)。 */
135
55
  chainRpc: {
136
56
  /** chain-rpc 网关池状态(各链健康 / 活跃端点,脱敏)。 */
@@ -216,6 +136,32 @@ export declare class WalletAPI {
216
136
  create: (p: Record<string, unknown>) => Promise<unknown>;
217
137
  revoke: (sessionId: string) => Promise<unknown>;
218
138
  execute: (p: Record<string, unknown>) => Promise<unknown>;
139
+ /** Solana(Squads Smart Account):构建未签名交易 + 广播已签名交易。 */
140
+ solana: {
141
+ deriveAccount: (p: SolanaDeriveAccountParams) => Promise<SolanaDerivedAccount>;
142
+ createAccount: (p: SolanaCreateAccountParams) => Promise<SolanaUnsignedTransaction>;
143
+ installPolicy: (p: SolanaInstallPolicyParams) => Promise<SolanaUnsignedTransaction>;
144
+ executePolicy: (p: SolanaExecutePolicyParams) => Promise<SolanaUnsignedTransaction>;
145
+ /** 新口径:创建 spending limit policy 交易(待多签审批)。 */
146
+ createPolicyTransaction: (p: SolanaCreatePolicyTransactionParams) => Promise<SolanaUnsignedTransaction>;
147
+ /** settings / policy 交易提案:创建。 */
148
+ createProposal: (p: SolanaCreateProposalParams) => Promise<SolanaUnsignedTransaction>;
149
+ /** settings / policy 交易提案:审批(threshold 达成即 Approved)。 */
150
+ approveProposal: (p: SolanaApproveProposalParams) => Promise<SolanaUnsignedTransaction>;
151
+ /** 新口径:异步执行已批准的 policy 交易。 */
152
+ executePolicyTransaction: (p: SolanaExecutePolicyTransactionParams) => Promise<SolanaUnsignedTransaction>;
153
+ /** 新口径:删除 policy(PolicyRemove)并回收其 rent。 */
154
+ removePolicy: (p: SolanaRemovePolicyParams) => Promise<SolanaUnsignedTransaction>;
155
+ /** 新口径:同步执行 spending limit policy。 */
156
+ executePolicyPayload: (p: SolanaExecutePolicyPayloadParams) => Promise<SolanaUnsignedTransaction>;
157
+ /** 关闭废弃 settings 交易并回收 rent。 */
158
+ closeSettings: (p: SolanaCloseSettingsParams) => Promise<SolanaUnsignedTransaction>;
159
+ /** 关闭 policy 交易并回收 transaction/proposal rent。 */
160
+ closeTransaction: (p: SolanaCloseTransactionParams) => Promise<SolanaUnsignedTransaction>;
161
+ execute: (p: SolanaExecuteParams) => Promise<SolanaUnsignedTransaction>;
162
+ removeSigner: (p: SolanaRemoveSignerParams) => Promise<SolanaUnsignedTransaction>;
163
+ submit: (p: SolanaSubmitParams) => Promise<SolanaSubmitResult>;
164
+ };
219
165
  };
220
166
  /** MPC(email 分片钱包)子域:canonical `/v1/wallet/mpc/*`。 */
221
167
  mpc: {
@@ -1,7 +1,4 @@
1
1
  "use strict";
2
- // ---------------------------------------------------------------------------
3
- // @keelcodes/sdk — wallet 模块
4
- // ---------------------------------------------------------------------------
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.WalletAPI = void 0;
7
4
  class WalletAPI {
@@ -56,6 +53,32 @@ class WalletAPI {
56
53
  create: (p) => this.http.post('/v1/wallet/session/create', p),
57
54
  revoke: (sessionId) => this.http.post('/v1/wallet/session/revoke', { sessionId }),
58
55
  execute: (p) => this.http.post('/v1/wallet/session/execute', p),
56
+ /** Solana(Squads Smart Account):构建未签名交易 + 广播已签名交易。 */
57
+ solana: {
58
+ deriveAccount: (p) => this.http.post('/v1/wallet/session/solana/account/derive', p),
59
+ createAccount: (p) => this.http.post('/v1/wallet/session/solana/account/create', p),
60
+ installPolicy: (p) => this.http.post('/v1/wallet/session/solana/session/policy', p),
61
+ executePolicy: (p) => this.http.post('/v1/wallet/session/solana/session/policy/execute', p),
62
+ /** 新口径:创建 spending limit policy 交易(待多签审批)。 */
63
+ createPolicyTransaction: (p) => this.http.post('/v1/wallet/session/solana/session/policy/create-transaction', p),
64
+ /** settings / policy 交易提案:创建。 */
65
+ createProposal: (p) => this.http.post('/v1/wallet/session/solana/session/proposal', p),
66
+ /** settings / policy 交易提案:审批(threshold 达成即 Approved)。 */
67
+ approveProposal: (p) => this.http.post('/v1/wallet/session/solana/session/proposal/approve', p),
68
+ /** 新口径:异步执行已批准的 policy 交易。 */
69
+ executePolicyTransaction: (p) => this.http.post('/v1/wallet/session/solana/session/policy/execute-transaction', p),
70
+ /** 新口径:删除 policy(PolicyRemove)并回收其 rent。 */
71
+ removePolicy: (p) => this.http.post('/v1/wallet/session/solana/session/policy/remove', p),
72
+ /** 新口径:同步执行 spending limit policy。 */
73
+ executePolicyPayload: (p) => this.http.post('/v1/wallet/session/solana/session/policy/execute-payload', p),
74
+ /** 关闭废弃 settings 交易并回收 rent。 */
75
+ closeSettings: (p) => this.http.post('/v1/wallet/session/solana/settings/close', p),
76
+ /** 关闭 policy 交易并回收 transaction/proposal rent。 */
77
+ closeTransaction: (p) => this.http.post('/v1/wallet/session/solana/session/policy/close-transaction', p),
78
+ execute: (p) => this.http.post('/v1/wallet/session/solana/session/execute', p),
79
+ removeSigner: (p) => this.http.post('/v1/wallet/session/solana/session/remove-signer', p),
80
+ submit: (p) => this.http.post('/v1/wallet/session/solana/submit', p),
81
+ },
59
82
  };
60
83
  /** MPC(email 分片钱包)子域:canonical `/v1/wallet/mpc/*`。 */
61
84
  this.mpc = {
@@ -112,5 +135,33 @@ class WalletAPI {
112
135
  q.set('token', params.token);
113
136
  return this.http.get('/v1/wallet/balance?' + q.toString());
114
137
  }
138
+ /** 查询当前钱包在指定链的充值地址。 */
139
+ address(chain) {
140
+ return this.http.get('/v1/wallet/address?chain=' + encodeURIComponent(chain));
141
+ }
142
+ /** 交易流水(托管查库;`nc=true` 时直接扫链)。 */
143
+ transactions(p = {}) {
144
+ const q = new URLSearchParams();
145
+ if (p.page)
146
+ q.set('page', String(p.page));
147
+ if (p.limit)
148
+ q.set('limit', String(p.limit));
149
+ if (p.chain)
150
+ q.set('chain', p.chain);
151
+ if (p.type)
152
+ q.set('type', p.type);
153
+ if (p.nc)
154
+ q.set('nc', 'true');
155
+ const qs = q.toString();
156
+ return this.http.get('/v1/wallet/transactions' + (qs ? '?' + qs : ''));
157
+ }
158
+ /** 批量转账(需 admin 权限,B 端钱包签名不可用;建议用 `request` 直连或逐笔 `send`)。 */
159
+ batch(p) {
160
+ return this.http.post('/v1/wallet/batch', p);
161
+ }
162
+ /** 查询批量转账进度。 */
163
+ batchProgress(batchId) {
164
+ return this.http.get('/v1/wallet/batch/' + encodeURIComponent(batchId) + '/progress');
165
+ }
115
166
  }
116
167
  exports.WalletAPI = WalletAPI;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keelcodes/sdk",
3
- "version": "1.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Keel SDK — unified access to payment / wallet / data / account modules over https://keel.codes",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -14,8 +14,8 @@
14
14
  "default": "./dist/payment.js"
15
15
  },
16
16
  "./wallet": {
17
- "types": "./dist/wallet.d.ts",
18
- "default": "./dist/wallet.js"
17
+ "types": "./dist/wallet/index.d.ts",
18
+ "default": "./dist/wallet/index.js"
19
19
  },
20
20
  "./data": {
21
21
  "types": "./dist/data.d.ts",