@xkova/sdk 0.1.0-alpha.7 → 0.1.0-alpha.8
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 +105 -0
- package/dist/client.d.ts +4 -0
- package/dist/client.js +59 -1
- package/dist/generated/types.d.ts +7515 -4653
- package/dist/held-approval.d.ts +41 -0
- package/dist/held-approval.js +33 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/request-signing.js +6 -0
- package/dist/resources/treasury.d.ts +404 -0
- package/dist/resources/treasury.js +115 -0
- package/dist/resources/workforce-wallets.d.ts +34 -0
- package/dist/resources/workforce-wallets.js +19 -0
- package/dist/workforce-bff.d.ts +202 -0
- package/dist/workforce-bff.js +462 -0
- package/llms.txt +5 -0
- package/package.json +5 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Narrow a governance hold before reading a mutation's entity result.
|
|
3
|
+
*
|
|
4
|
+
* On a workspace with a seeded/configured governance requirement, a
|
|
5
|
+
* create-shaped mutation (for example, `createTreasuryCounterparty` or
|
|
6
|
+
* treasury signer changes) may not execute: it returns a `HeldApproval`
|
|
7
|
+
* (`{ status: 'pending_approval', pending_approval_request_id }`) instead of
|
|
8
|
+
* the entity. No entity is created. Independently eligible approvers complete
|
|
9
|
+
* the required approval, then the same call is reissued through normal policy.
|
|
10
|
+
*
|
|
11
|
+
* Narrow BEFORE reading entity fields:
|
|
12
|
+
*
|
|
13
|
+
* const res = await client.treasury.createCounterparty(body, opts);
|
|
14
|
+
* if (isHeldApproval(res)) {
|
|
15
|
+
* await waitForApproval(res.pending_approval_request_id); // your flow
|
|
16
|
+
* return client.treasury.createCounterparty(body, opts); // same request
|
|
17
|
+
* }
|
|
18
|
+
* res.id; // safely the entity now
|
|
19
|
+
*
|
|
20
|
+
* This helper grants no approval, signer authority or permission to retry a
|
|
21
|
+
* changed request. Existing entity-shaped responses are not governance holds.
|
|
22
|
+
*/
|
|
23
|
+
import type { components } from './generated/types.js';
|
|
24
|
+
export type HeldApproval = components['schemas']['HeldApproval'];
|
|
25
|
+
/** True when a mutation response is a governance hold rather than the entity. */
|
|
26
|
+
export declare function isHeldApproval(res: unknown): res is HeldApproval;
|
|
27
|
+
/**
|
|
28
|
+
* Thrown by `assertNotHeld` when a mutation was governance-held. Carries the
|
|
29
|
+
* approval request id so a script that does not implement the attest flow
|
|
30
|
+
* fails loudly with the pointer a human needs.
|
|
31
|
+
*/
|
|
32
|
+
export declare class XKOVAHeldApprovalError extends Error {
|
|
33
|
+
readonly pendingApprovalRequestId: string;
|
|
34
|
+
constructor(held: HeldApproval, action?: string);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Unwrap a `entity | HeldApproval` union for callers that treat a hold as
|
|
38
|
+
* exceptional (scripts, one-shot provisioning). Returns the entity, or throws
|
|
39
|
+
* `XKOVAHeldApprovalError` carrying the approval request id.
|
|
40
|
+
*/
|
|
41
|
+
export declare function assertNotHeld<T>(res: T | HeldApproval, action?: string): T;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** True when a mutation response is a governance hold rather than the entity. */
|
|
2
|
+
export function isHeldApproval(res) {
|
|
3
|
+
return (typeof res === 'object' &&
|
|
4
|
+
res !== null &&
|
|
5
|
+
res.status === 'pending_approval' &&
|
|
6
|
+
typeof res
|
|
7
|
+
.pending_approval_request_id === 'string');
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Thrown by `assertNotHeld` when a mutation was governance-held. Carries the
|
|
11
|
+
* approval request id so a script that does not implement the attest flow
|
|
12
|
+
* fails loudly with the pointer a human needs.
|
|
13
|
+
*/
|
|
14
|
+
export class XKOVAHeldApprovalError extends Error {
|
|
15
|
+
pendingApprovalRequestId;
|
|
16
|
+
constructor(held, action) {
|
|
17
|
+
super(`${action ?? 'The mutation'} was held for governance approval ` +
|
|
18
|
+
`(approval request ${held.pending_approval_request_id}). Attest the ` +
|
|
19
|
+
`request, then re-issue the same call.`);
|
|
20
|
+
this.name = 'XKOVAHeldApprovalError';
|
|
21
|
+
this.pendingApprovalRequestId = held.pending_approval_request_id;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Unwrap a `entity | HeldApproval` union for callers that treat a hold as
|
|
26
|
+
* exceptional (scripts, one-shot provisioning). Returns the entity, or throws
|
|
27
|
+
* `XKOVAHeldApprovalError` carrying the approval request id.
|
|
28
|
+
*/
|
|
29
|
+
export function assertNotHeld(res, action) {
|
|
30
|
+
if (isHeldApproval(res))
|
|
31
|
+
throw new XKOVAHeldApprovalError(res, action);
|
|
32
|
+
return res;
|
|
33
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { generateIdempotencyKey, withIdempotency } from './idempotency.js';
|
|
|
5
5
|
export { withRetry, type RetryPolicy } from './retry.js';
|
|
6
6
|
export { collectCursor, paginateCursor, type CursorPage, type PaginateCursorOptions, } from './cursor.js';
|
|
7
7
|
export { XKOVAApiError, XKOVAUploadError } from './errors.js';
|
|
8
|
+
export { isHeldApproval, assertNotHeld, XKOVAHeldApprovalError, type HeldApproval, } from './held-approval.js';
|
|
8
9
|
export { type PollOptions } from './resources/workflows.js';
|
|
9
10
|
export { type XKOVAMemberSessionContext } from './resources/account-holders.js';
|
|
10
11
|
export { verifyWebhookSignature, type VerifyWebhookSignatureResult } from './webhook.js';
|
package/dist/index.js
CHANGED
|
@@ -4,5 +4,6 @@ export { generateIdempotencyKey, withIdempotency } from './idempotency.js';
|
|
|
4
4
|
export { withRetry } from './retry.js';
|
|
5
5
|
export { collectCursor, paginateCursor, } from './cursor.js';
|
|
6
6
|
export { XKOVAApiError, XKOVAUploadError } from './errors.js';
|
|
7
|
+
export { isHeldApproval, assertNotHeld, XKOVAHeldApprovalError, } from './held-approval.js';
|
|
7
8
|
export { verifyWebhookSignature } from './webhook.js';
|
|
8
9
|
export { verifyInclusion, verifyConsistency, verifySth, } from './rwa-verify.js';
|
package/dist/request-signing.js
CHANGED
|
@@ -11,6 +11,10 @@ const CONDITIONAL_HEADERS = [
|
|
|
11
11
|
'idempotency-key',
|
|
12
12
|
'x-member-session-id',
|
|
13
13
|
'x-xkova-publishable-key',
|
|
14
|
+
'x-xkova-workforce-key',
|
|
15
|
+
'x-workforce-session',
|
|
16
|
+
'x-xkova-human-authorization',
|
|
17
|
+
'origin',
|
|
14
18
|
'x-account-holder-id',
|
|
15
19
|
'x-sender-wallet-id',
|
|
16
20
|
'x-sandbox-scenario',
|
|
@@ -78,6 +82,8 @@ export async function signXKOVARequest(input) {
|
|
|
78
82
|
function requiredComponents(headers, bodyPresent) {
|
|
79
83
|
const components = [...BASE_COMPONENTS];
|
|
80
84
|
for (const header of CONDITIONAL_HEADERS) {
|
|
85
|
+
if (header === 'origin' && !headers.has('x-xkova-workforce-key'))
|
|
86
|
+
continue;
|
|
81
87
|
if (headers.has(header) ||
|
|
82
88
|
(bodyPresent && (header === 'content-digest' || header === 'content-type'))) {
|
|
83
89
|
components.push(header);
|
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
/** Tenant treasury wallets and transfers. Signer authority is verified by the API. */
|
|
2
|
+
import { Resource, type ReqBody, type Query } from './base.js';
|
|
3
|
+
import type { XKOVAMutationOptions } from '../client.js';
|
|
4
|
+
export declare class TreasuryResource extends Resource {
|
|
5
|
+
listWallets(query?: Query<'listTreasuryWallets'>): Promise<{
|
|
6
|
+
data?: import("../generated/types.js").components["schemas"]["TreasuryWallet"][];
|
|
7
|
+
}>;
|
|
8
|
+
createWallet(body: ReqBody<'createTreasuryWallet'>, opts?: XKOVAMutationOptions): Promise<{
|
|
9
|
+
id: import("../generated/types.js").components["schemas"]["TreasuryWalletId"];
|
|
10
|
+
tenant_id: string;
|
|
11
|
+
chain_id: string;
|
|
12
|
+
chain: import("../generated/types.js").components["schemas"]["ChainDescriptor"];
|
|
13
|
+
address: string;
|
|
14
|
+
name: string;
|
|
15
|
+
threshold: number;
|
|
16
|
+
state: "deploying" | "active" | "decommissioned";
|
|
17
|
+
is_revenue_treasury: boolean;
|
|
18
|
+
signers: import("../generated/types.js").components["schemas"]["TreasurySigner"][];
|
|
19
|
+
deploy_tx_hash: string | null;
|
|
20
|
+
created_at: import("../generated/types.js").components["schemas"]["TimestampUtc"];
|
|
21
|
+
updated_at: import("../generated/types.js").components["schemas"]["TimestampUtc"];
|
|
22
|
+
}>;
|
|
23
|
+
getWallet(id: string): Promise<{
|
|
24
|
+
id: import("../generated/types.js").components["schemas"]["TreasuryWalletId"];
|
|
25
|
+
tenant_id: string;
|
|
26
|
+
chain_id: string;
|
|
27
|
+
chain: import("../generated/types.js").components["schemas"]["ChainDescriptor"];
|
|
28
|
+
address: string;
|
|
29
|
+
name: string;
|
|
30
|
+
threshold: number;
|
|
31
|
+
state: "deploying" | "active" | "decommissioned";
|
|
32
|
+
is_revenue_treasury: boolean;
|
|
33
|
+
signers: import("../generated/types.js").components["schemas"]["TreasurySigner"][];
|
|
34
|
+
deploy_tx_hash: string | null;
|
|
35
|
+
created_at: import("../generated/types.js").components["schemas"]["TimestampUtc"];
|
|
36
|
+
updated_at: import("../generated/types.js").components["schemas"]["TimestampUtc"];
|
|
37
|
+
}>;
|
|
38
|
+
walletBalance(id: string): Promise<{
|
|
39
|
+
treasury_wallet_id: import("../generated/types.js").components["schemas"]["TreasuryWalletId"];
|
|
40
|
+
chain_id: string;
|
|
41
|
+
balances: import("../generated/types.js").components["schemas"]["TreasuryBalance"][];
|
|
42
|
+
fetched_at: string;
|
|
43
|
+
}>;
|
|
44
|
+
listSigners(id: string): Promise<{
|
|
45
|
+
data?: import("../generated/types.js").components["schemas"]["TreasurySigner"][];
|
|
46
|
+
}>;
|
|
47
|
+
addSigner(id: string, body: ReqBody<'addTreasurySigner'>, opts?: XKOVAMutationOptions): Promise<{
|
|
48
|
+
status: "pending_approval";
|
|
49
|
+
pending_approval_request_id: import("../generated/types.js").components["schemas"]["ApprovalRequestId"];
|
|
50
|
+
} | {
|
|
51
|
+
wallet: import("../generated/types.js").components["schemas"]["TreasuryWallet"];
|
|
52
|
+
draft_transfer_id: import("../generated/types.js").components["schemas"]["TreasuryTransferId"];
|
|
53
|
+
}>;
|
|
54
|
+
changeThreshold(id: string, body: ReqBody<'changeTreasuryThreshold'>, opts?: XKOVAMutationOptions): Promise<{
|
|
55
|
+
status: "pending_approval";
|
|
56
|
+
pending_approval_request_id: import("../generated/types.js").components["schemas"]["ApprovalRequestId"];
|
|
57
|
+
} | {
|
|
58
|
+
wallet: import("../generated/types.js").components["schemas"]["TreasuryWallet"];
|
|
59
|
+
draft_transfer_id: import("../generated/types.js").components["schemas"]["TreasuryTransferId"];
|
|
60
|
+
}>;
|
|
61
|
+
listTransfers(walletId: string, query?: Query<'listTreasuryTransfers'>): Promise<{
|
|
62
|
+
data: unknown[];
|
|
63
|
+
next_cursor: string | null;
|
|
64
|
+
has_more: boolean;
|
|
65
|
+
} & {
|
|
66
|
+
data?: import("../generated/types.js").components["schemas"]["TreasuryTransfer"][];
|
|
67
|
+
}>;
|
|
68
|
+
draftTransfer(walletId: string, body: ReqBody<'draftTreasuryTransfer'>, opts?: XKOVAMutationOptions): Promise<{
|
|
69
|
+
id: import("../generated/types.js").components["schemas"]["TreasuryTransferId"];
|
|
70
|
+
treasury_wallet_id: import("../generated/types.js").components["schemas"]["TreasuryWalletId"];
|
|
71
|
+
chain: import("../generated/types.js").components["schemas"]["ChainDescriptor"];
|
|
72
|
+
initiated_by_staff_id: import("../generated/types.js").components["schemas"]["StaffId"];
|
|
73
|
+
kind: import("../generated/types.js").components["schemas"]["TreasuryTransferKind"];
|
|
74
|
+
to_address: string;
|
|
75
|
+
asset_token_address: string | null;
|
|
76
|
+
amount: string | null;
|
|
77
|
+
safe_nonce: string;
|
|
78
|
+
safe_tx_hash: string;
|
|
79
|
+
state: import("../generated/types.js").components["schemas"]["TreasuryTransferState"];
|
|
80
|
+
memo?: string | null;
|
|
81
|
+
tax_classification?: string | null;
|
|
82
|
+
counterparty_id?: import("../generated/types.js").components["schemas"]["TreasuryCounterpartyId"] | null;
|
|
83
|
+
signatures: import("../generated/types.js").components["schemas"]["TreasuryTransferSignature"][];
|
|
84
|
+
threshold: number;
|
|
85
|
+
threshold_met: boolean;
|
|
86
|
+
signing_context?: import("../generated/types.js").components["schemas"]["TreasuryTransferSigningContext"] | null;
|
|
87
|
+
execute_tx_hash: string | null;
|
|
88
|
+
failure_reason_code: string | null;
|
|
89
|
+
failure_reason_detail: string | null;
|
|
90
|
+
failure_retryable: boolean;
|
|
91
|
+
created_at: import("../generated/types.js").components["schemas"]["TimestampUtc"];
|
|
92
|
+
executed_at: string | null;
|
|
93
|
+
confirmed_at: string | null;
|
|
94
|
+
}>;
|
|
95
|
+
getTransfer(id: string, query?: Query<'getTreasuryTransfer'>): Promise<{
|
|
96
|
+
id: import("../generated/types.js").components["schemas"]["TreasuryTransferId"];
|
|
97
|
+
treasury_wallet_id: import("../generated/types.js").components["schemas"]["TreasuryWalletId"];
|
|
98
|
+
chain: import("../generated/types.js").components["schemas"]["ChainDescriptor"];
|
|
99
|
+
initiated_by_staff_id: import("../generated/types.js").components["schemas"]["StaffId"];
|
|
100
|
+
kind: import("../generated/types.js").components["schemas"]["TreasuryTransferKind"];
|
|
101
|
+
to_address: string;
|
|
102
|
+
asset_token_address: string | null;
|
|
103
|
+
amount: string | null;
|
|
104
|
+
safe_nonce: string;
|
|
105
|
+
safe_tx_hash: string;
|
|
106
|
+
state: import("../generated/types.js").components["schemas"]["TreasuryTransferState"];
|
|
107
|
+
memo?: string | null;
|
|
108
|
+
tax_classification?: string | null;
|
|
109
|
+
counterparty_id?: import("../generated/types.js").components["schemas"]["TreasuryCounterpartyId"] | null;
|
|
110
|
+
signatures: import("../generated/types.js").components["schemas"]["TreasuryTransferSignature"][];
|
|
111
|
+
threshold: number;
|
|
112
|
+
threshold_met: boolean;
|
|
113
|
+
signing_context?: import("../generated/types.js").components["schemas"]["TreasuryTransferSigningContext"] | null;
|
|
114
|
+
execute_tx_hash: string | null;
|
|
115
|
+
failure_reason_code: string | null;
|
|
116
|
+
failure_reason_detail: string | null;
|
|
117
|
+
failure_retryable: boolean;
|
|
118
|
+
created_at: import("../generated/types.js").components["schemas"]["TimestampUtc"];
|
|
119
|
+
executed_at: string | null;
|
|
120
|
+
confirmed_at: string | null;
|
|
121
|
+
}>;
|
|
122
|
+
submitTransferSignature(id: string, body: ReqBody<'submitTreasuryTransferSignature'>, opts?: XKOVAMutationOptions): Promise<{
|
|
123
|
+
id: import("../generated/types.js").components["schemas"]["TreasuryTransferId"];
|
|
124
|
+
treasury_wallet_id: import("../generated/types.js").components["schemas"]["TreasuryWalletId"];
|
|
125
|
+
chain: import("../generated/types.js").components["schemas"]["ChainDescriptor"];
|
|
126
|
+
initiated_by_staff_id: import("../generated/types.js").components["schemas"]["StaffId"];
|
|
127
|
+
kind: import("../generated/types.js").components["schemas"]["TreasuryTransferKind"];
|
|
128
|
+
to_address: string;
|
|
129
|
+
asset_token_address: string | null;
|
|
130
|
+
amount: string | null;
|
|
131
|
+
safe_nonce: string;
|
|
132
|
+
safe_tx_hash: string;
|
|
133
|
+
state: import("../generated/types.js").components["schemas"]["TreasuryTransferState"];
|
|
134
|
+
memo?: string | null;
|
|
135
|
+
tax_classification?: string | null;
|
|
136
|
+
counterparty_id?: import("../generated/types.js").components["schemas"]["TreasuryCounterpartyId"] | null;
|
|
137
|
+
signatures: import("../generated/types.js").components["schemas"]["TreasuryTransferSignature"][];
|
|
138
|
+
threshold: number;
|
|
139
|
+
threshold_met: boolean;
|
|
140
|
+
signing_context?: import("../generated/types.js").components["schemas"]["TreasuryTransferSigningContext"] | null;
|
|
141
|
+
execute_tx_hash: string | null;
|
|
142
|
+
failure_reason_code: string | null;
|
|
143
|
+
failure_reason_detail: string | null;
|
|
144
|
+
failure_retryable: boolean;
|
|
145
|
+
created_at: import("../generated/types.js").components["schemas"]["TimestampUtc"];
|
|
146
|
+
executed_at: string | null;
|
|
147
|
+
confirmed_at: string | null;
|
|
148
|
+
}>;
|
|
149
|
+
executeTransfer(id: string, opts?: XKOVAMutationOptions): Promise<{
|
|
150
|
+
id: import("../generated/types.js").components["schemas"]["TreasuryTransferId"];
|
|
151
|
+
treasury_wallet_id: import("../generated/types.js").components["schemas"]["TreasuryWalletId"];
|
|
152
|
+
chain: import("../generated/types.js").components["schemas"]["ChainDescriptor"];
|
|
153
|
+
initiated_by_staff_id: import("../generated/types.js").components["schemas"]["StaffId"];
|
|
154
|
+
kind: import("../generated/types.js").components["schemas"]["TreasuryTransferKind"];
|
|
155
|
+
to_address: string;
|
|
156
|
+
asset_token_address: string | null;
|
|
157
|
+
amount: string | null;
|
|
158
|
+
safe_nonce: string;
|
|
159
|
+
safe_tx_hash: string;
|
|
160
|
+
state: import("../generated/types.js").components["schemas"]["TreasuryTransferState"];
|
|
161
|
+
memo?: string | null;
|
|
162
|
+
tax_classification?: string | null;
|
|
163
|
+
counterparty_id?: import("../generated/types.js").components["schemas"]["TreasuryCounterpartyId"] | null;
|
|
164
|
+
signatures: import("../generated/types.js").components["schemas"]["TreasuryTransferSignature"][];
|
|
165
|
+
threshold: number;
|
|
166
|
+
threshold_met: boolean;
|
|
167
|
+
signing_context?: import("../generated/types.js").components["schemas"]["TreasuryTransferSigningContext"] | null;
|
|
168
|
+
execute_tx_hash: string | null;
|
|
169
|
+
failure_reason_code: string | null;
|
|
170
|
+
failure_reason_detail: string | null;
|
|
171
|
+
failure_retryable: boolean;
|
|
172
|
+
created_at: import("../generated/types.js").components["schemas"]["TimestampUtc"];
|
|
173
|
+
executed_at: string | null;
|
|
174
|
+
confirmed_at: string | null;
|
|
175
|
+
}>;
|
|
176
|
+
cancelTransfer(id: string, opts?: XKOVAMutationOptions): Promise<{
|
|
177
|
+
id: import("../generated/types.js").components["schemas"]["TreasuryTransferId"];
|
|
178
|
+
treasury_wallet_id: import("../generated/types.js").components["schemas"]["TreasuryWalletId"];
|
|
179
|
+
chain: import("../generated/types.js").components["schemas"]["ChainDescriptor"];
|
|
180
|
+
initiated_by_staff_id: import("../generated/types.js").components["schemas"]["StaffId"];
|
|
181
|
+
kind: import("../generated/types.js").components["schemas"]["TreasuryTransferKind"];
|
|
182
|
+
to_address: string;
|
|
183
|
+
asset_token_address: string | null;
|
|
184
|
+
amount: string | null;
|
|
185
|
+
safe_nonce: string;
|
|
186
|
+
safe_tx_hash: string;
|
|
187
|
+
state: import("../generated/types.js").components["schemas"]["TreasuryTransferState"];
|
|
188
|
+
memo?: string | null;
|
|
189
|
+
tax_classification?: string | null;
|
|
190
|
+
counterparty_id?: import("../generated/types.js").components["schemas"]["TreasuryCounterpartyId"] | null;
|
|
191
|
+
signatures: import("../generated/types.js").components["schemas"]["TreasuryTransferSignature"][];
|
|
192
|
+
threshold: number;
|
|
193
|
+
threshold_met: boolean;
|
|
194
|
+
signing_context?: import("../generated/types.js").components["schemas"]["TreasuryTransferSigningContext"] | null;
|
|
195
|
+
execute_tx_hash: string | null;
|
|
196
|
+
failure_reason_code: string | null;
|
|
197
|
+
failure_reason_detail: string | null;
|
|
198
|
+
failure_retryable: boolean;
|
|
199
|
+
created_at: import("../generated/types.js").components["schemas"]["TimestampUtc"];
|
|
200
|
+
executed_at: string | null;
|
|
201
|
+
confirmed_at: string | null;
|
|
202
|
+
}>;
|
|
203
|
+
decommissionWallet(id: string, opts?: XKOVAMutationOptions): Promise<void>;
|
|
204
|
+
designateRevenueWallet(id: string, opts?: XKOVAMutationOptions): Promise<{
|
|
205
|
+
status: "pending_approval";
|
|
206
|
+
pending_approval_request_id: import("../generated/types.js").components["schemas"]["ApprovalRequestId"];
|
|
207
|
+
} | {
|
|
208
|
+
id: import("../generated/types.js").components["schemas"]["TreasuryWalletId"];
|
|
209
|
+
tenant_id: string;
|
|
210
|
+
chain_id: string;
|
|
211
|
+
chain: import("../generated/types.js").components["schemas"]["ChainDescriptor"];
|
|
212
|
+
address: string;
|
|
213
|
+
name: string;
|
|
214
|
+
threshold: number;
|
|
215
|
+
state: "deploying" | "active" | "decommissioned";
|
|
216
|
+
is_revenue_treasury: boolean;
|
|
217
|
+
signers: import("../generated/types.js").components["schemas"]["TreasurySigner"][];
|
|
218
|
+
deploy_tx_hash: string | null;
|
|
219
|
+
created_at: import("../generated/types.js").components["schemas"]["TimestampUtc"];
|
|
220
|
+
updated_at: import("../generated/types.js").components["schemas"]["TimestampUtc"];
|
|
221
|
+
}>;
|
|
222
|
+
deleteSigner(id: string, staffId: string, opts?: XKOVAMutationOptions): Promise<{
|
|
223
|
+
status: "pending_approval";
|
|
224
|
+
pending_approval_request_id: import("../generated/types.js").components["schemas"]["ApprovalRequestId"];
|
|
225
|
+
} | {
|
|
226
|
+
wallet: import("../generated/types.js").components["schemas"]["TreasuryWallet"];
|
|
227
|
+
draft_transfer_id: import("../generated/types.js").components["schemas"]["TreasuryTransferId"];
|
|
228
|
+
}>;
|
|
229
|
+
walletTransactions(id: string, query?: Query<'getTreasuryWalletTransactions'>): Promise<{
|
|
230
|
+
data: unknown[];
|
|
231
|
+
next_cursor: string | null;
|
|
232
|
+
has_more: boolean;
|
|
233
|
+
} & {
|
|
234
|
+
data?: import("../generated/types.js").components["schemas"]["TreasuryTransfer"][];
|
|
235
|
+
}>;
|
|
236
|
+
listNftHoldings(walletId: string, query?: Query<'listTreasuryNftHoldings'>): Promise<{
|
|
237
|
+
data: import("../generated/types.js").components["schemas"]["TreasuryNftHolding"][];
|
|
238
|
+
next_cursor: string | null;
|
|
239
|
+
has_more: boolean;
|
|
240
|
+
}>;
|
|
241
|
+
draftNftTransfer(walletId: string, body: ReqBody<'draftTreasuryNftTransfer'>, opts?: XKOVAMutationOptions): Promise<{
|
|
242
|
+
id: import("../generated/types.js").components["schemas"]["TreasuryTransferId"];
|
|
243
|
+
treasury_wallet_id: import("../generated/types.js").components["schemas"]["TreasuryWalletId"];
|
|
244
|
+
chain: import("../generated/types.js").components["schemas"]["ChainDescriptor"];
|
|
245
|
+
initiated_by_staff_id: import("../generated/types.js").components["schemas"]["StaffId"];
|
|
246
|
+
kind: import("../generated/types.js").components["schemas"]["TreasuryTransferKind"];
|
|
247
|
+
to_address: string;
|
|
248
|
+
asset_token_address: string | null;
|
|
249
|
+
amount: string | null;
|
|
250
|
+
safe_nonce: string;
|
|
251
|
+
safe_tx_hash: string;
|
|
252
|
+
state: import("../generated/types.js").components["schemas"]["TreasuryTransferState"];
|
|
253
|
+
memo?: string | null;
|
|
254
|
+
tax_classification?: string | null;
|
|
255
|
+
counterparty_id?: import("../generated/types.js").components["schemas"]["TreasuryCounterpartyId"] | null;
|
|
256
|
+
signatures: import("../generated/types.js").components["schemas"]["TreasuryTransferSignature"][];
|
|
257
|
+
threshold: number;
|
|
258
|
+
threshold_met: boolean;
|
|
259
|
+
signing_context?: import("../generated/types.js").components["schemas"]["TreasuryTransferSigningContext"] | null;
|
|
260
|
+
execute_tx_hash: string | null;
|
|
261
|
+
failure_reason_code: string | null;
|
|
262
|
+
failure_reason_detail: string | null;
|
|
263
|
+
failure_retryable: boolean;
|
|
264
|
+
created_at: import("../generated/types.js").components["schemas"]["TimestampUtc"];
|
|
265
|
+
executed_at: string | null;
|
|
266
|
+
confirmed_at: string | null;
|
|
267
|
+
}>;
|
|
268
|
+
listAssets(query: Query<'listTreasuryAssets'>): Promise<{
|
|
269
|
+
data?: import("../generated/types.js").components["schemas"]["TreasuryAsset"][];
|
|
270
|
+
}>;
|
|
271
|
+
listCounterparties(query?: Query<'listTreasuryCounterparties'>): Promise<{
|
|
272
|
+
data: unknown[];
|
|
273
|
+
next_cursor: string | null;
|
|
274
|
+
has_more: boolean;
|
|
275
|
+
} & {
|
|
276
|
+
data?: import("../generated/types.js").components["schemas"]["TreasuryCounterparty"][];
|
|
277
|
+
}>;
|
|
278
|
+
createCounterparty(body: ReqBody<'createTreasuryCounterparty'>, opts?: XKOVAMutationOptions): Promise<{
|
|
279
|
+
status: "pending_approval";
|
|
280
|
+
pending_approval_request_id: import("../generated/types.js").components["schemas"]["ApprovalRequestId"];
|
|
281
|
+
} | {
|
|
282
|
+
id: import("../generated/types.js").components["schemas"]["TreasuryCounterpartyId"];
|
|
283
|
+
display_name: string;
|
|
284
|
+
legal_name: string | null;
|
|
285
|
+
tax_id: string | null;
|
|
286
|
+
tax_id_type: "ein" | "ssn" | "foreign" | "none";
|
|
287
|
+
classification_default: string | null;
|
|
288
|
+
addresses: import("../generated/types.js").components["schemas"]["TreasuryCounterpartyAddress"][];
|
|
289
|
+
created_at: import("../generated/types.js").components["schemas"]["TimestampUtc"];
|
|
290
|
+
updated_at: import("../generated/types.js").components["schemas"]["TimestampUtc"];
|
|
291
|
+
}>;
|
|
292
|
+
updateCounterparty(id: string, body: ReqBody<'updateTreasuryCounterparty'>, opts?: XKOVAMutationOptions): Promise<{
|
|
293
|
+
id: import("../generated/types.js").components["schemas"]["TreasuryCounterpartyId"];
|
|
294
|
+
display_name: string;
|
|
295
|
+
legal_name: string | null;
|
|
296
|
+
tax_id: string | null;
|
|
297
|
+
tax_id_type: "ein" | "ssn" | "foreign" | "none";
|
|
298
|
+
classification_default: string | null;
|
|
299
|
+
addresses: import("../generated/types.js").components["schemas"]["TreasuryCounterpartyAddress"][];
|
|
300
|
+
created_at: import("../generated/types.js").components["schemas"]["TimestampUtc"];
|
|
301
|
+
updated_at: import("../generated/types.js").components["schemas"]["TimestampUtc"];
|
|
302
|
+
}>;
|
|
303
|
+
addCounterpartyAddress(id: string, body: ReqBody<'addTreasuryCounterpartyAddress'>, opts?: XKOVAMutationOptions): Promise<{
|
|
304
|
+
id: import("../generated/types.js").components["schemas"]["TreasuryCounterpartyAddressId"];
|
|
305
|
+
chain_id: string;
|
|
306
|
+
address: string;
|
|
307
|
+
added_at: import("../generated/types.js").components["schemas"]["TimestampUtc"];
|
|
308
|
+
}>;
|
|
309
|
+
deleteCounterpartyAddress(id: string, addressId: string, opts?: XKOVAMutationOptions): Promise<void>;
|
|
310
|
+
listRevenueChanges(): Promise<{
|
|
311
|
+
data: import("../generated/types.js").components["schemas"]["RevenueTreasuryChange"][];
|
|
312
|
+
}>;
|
|
313
|
+
createRevenueChange(body: ReqBody<'createRevenueTreasuryChange'>, opts?: XKOVAMutationOptions): Promise<{
|
|
314
|
+
id: import("../generated/types.js").components["schemas"]["RevenueTreasuryChangeId"];
|
|
315
|
+
from_treasury_wallet_id: import("../generated/types.js").components["schemas"]["TreasuryWalletId"];
|
|
316
|
+
to_treasury_wallet_id: import("../generated/types.js").components["schemas"]["TreasuryWalletId"];
|
|
317
|
+
required_approvals: number;
|
|
318
|
+
signature_count: number;
|
|
319
|
+
state: "open" | "partially_approved" | "ready_to_apply" | "applied" | "cancelled";
|
|
320
|
+
signatures: import("../generated/types.js").components["schemas"]["RevenueTreasuryChangeSignature"][];
|
|
321
|
+
signing_context: {
|
|
322
|
+
[key: string]: unknown;
|
|
323
|
+
};
|
|
324
|
+
created_at: import("../generated/types.js").components["schemas"]["TimestampUtc"];
|
|
325
|
+
approved_at: string | null;
|
|
326
|
+
applied_at: string | null;
|
|
327
|
+
cancelled_at: string | null;
|
|
328
|
+
} | {
|
|
329
|
+
status: "pending_approval";
|
|
330
|
+
pending_approval_request_id: import("../generated/types.js").components["schemas"]["ApprovalRequestId"];
|
|
331
|
+
}>;
|
|
332
|
+
getRevenueChange(id: string): Promise<{
|
|
333
|
+
id: import("../generated/types.js").components["schemas"]["RevenueTreasuryChangeId"];
|
|
334
|
+
from_treasury_wallet_id: import("../generated/types.js").components["schemas"]["TreasuryWalletId"];
|
|
335
|
+
to_treasury_wallet_id: import("../generated/types.js").components["schemas"]["TreasuryWalletId"];
|
|
336
|
+
required_approvals: number;
|
|
337
|
+
signature_count: number;
|
|
338
|
+
state: "open" | "partially_approved" | "ready_to_apply" | "applied" | "cancelled";
|
|
339
|
+
signatures: import("../generated/types.js").components["schemas"]["RevenueTreasuryChangeSignature"][];
|
|
340
|
+
signing_context: {
|
|
341
|
+
[key: string]: unknown;
|
|
342
|
+
};
|
|
343
|
+
created_at: import("../generated/types.js").components["schemas"]["TimestampUtc"];
|
|
344
|
+
approved_at: string | null;
|
|
345
|
+
applied_at: string | null;
|
|
346
|
+
cancelled_at: string | null;
|
|
347
|
+
}>;
|
|
348
|
+
applyRevenueChange(id: string, opts?: XKOVAMutationOptions): Promise<{
|
|
349
|
+
id: import("../generated/types.js").components["schemas"]["RevenueTreasuryChangeId"];
|
|
350
|
+
from_treasury_wallet_id: import("../generated/types.js").components["schemas"]["TreasuryWalletId"];
|
|
351
|
+
to_treasury_wallet_id: import("../generated/types.js").components["schemas"]["TreasuryWalletId"];
|
|
352
|
+
required_approvals: number;
|
|
353
|
+
signature_count: number;
|
|
354
|
+
state: "open" | "partially_approved" | "ready_to_apply" | "applied" | "cancelled";
|
|
355
|
+
signatures: import("../generated/types.js").components["schemas"]["RevenueTreasuryChangeSignature"][];
|
|
356
|
+
signing_context: {
|
|
357
|
+
[key: string]: unknown;
|
|
358
|
+
};
|
|
359
|
+
created_at: import("../generated/types.js").components["schemas"]["TimestampUtc"];
|
|
360
|
+
approved_at: string | null;
|
|
361
|
+
applied_at: string | null;
|
|
362
|
+
cancelled_at: string | null;
|
|
363
|
+
}>;
|
|
364
|
+
cancelRevenueChange(id: string, opts?: XKOVAMutationOptions): Promise<{
|
|
365
|
+
id: import("../generated/types.js").components["schemas"]["RevenueTreasuryChangeId"];
|
|
366
|
+
from_treasury_wallet_id: import("../generated/types.js").components["schemas"]["TreasuryWalletId"];
|
|
367
|
+
to_treasury_wallet_id: import("../generated/types.js").components["schemas"]["TreasuryWalletId"];
|
|
368
|
+
required_approvals: number;
|
|
369
|
+
signature_count: number;
|
|
370
|
+
state: "open" | "partially_approved" | "ready_to_apply" | "applied" | "cancelled";
|
|
371
|
+
signatures: import("../generated/types.js").components["schemas"]["RevenueTreasuryChangeSignature"][];
|
|
372
|
+
signing_context: {
|
|
373
|
+
[key: string]: unknown;
|
|
374
|
+
};
|
|
375
|
+
created_at: import("../generated/types.js").components["schemas"]["TimestampUtc"];
|
|
376
|
+
approved_at: string | null;
|
|
377
|
+
applied_at: string | null;
|
|
378
|
+
cancelled_at: string | null;
|
|
379
|
+
}>;
|
|
380
|
+
signRevenueChange(id: string, body: ReqBody<'signRevenueTreasuryChange'>, opts?: XKOVAMutationOptions): Promise<{
|
|
381
|
+
id: import("../generated/types.js").components["schemas"]["RevenueTreasuryChangeId"];
|
|
382
|
+
from_treasury_wallet_id: import("../generated/types.js").components["schemas"]["TreasuryWalletId"];
|
|
383
|
+
to_treasury_wallet_id: import("../generated/types.js").components["schemas"]["TreasuryWalletId"];
|
|
384
|
+
required_approvals: number;
|
|
385
|
+
signature_count: number;
|
|
386
|
+
state: "open" | "partially_approved" | "ready_to_apply" | "applied" | "cancelled";
|
|
387
|
+
signatures: import("../generated/types.js").components["schemas"]["RevenueTreasuryChangeSignature"][];
|
|
388
|
+
signing_context: {
|
|
389
|
+
[key: string]: unknown;
|
|
390
|
+
};
|
|
391
|
+
created_at: import("../generated/types.js").components["schemas"]["TimestampUtc"];
|
|
392
|
+
approved_at: string | null;
|
|
393
|
+
applied_at: string | null;
|
|
394
|
+
cancelled_at: string | null;
|
|
395
|
+
}>;
|
|
396
|
+
tax1099Summary(query: Query<'getTax1099Summary'>): Promise<{
|
|
397
|
+
year: number;
|
|
398
|
+
counterparties: import("../generated/types.js").components["schemas"]["Tax1099SummaryRow"][];
|
|
399
|
+
}>;
|
|
400
|
+
/** 1099-MISC as raw CSV. */
|
|
401
|
+
tax1099Csv(query: Query<'getTax1099Csv'>): Promise<string>;
|
|
402
|
+
/** Treasury transactions as raw CSV. */
|
|
403
|
+
taxTransactionsCsv(query: Query<'getTaxTransactionsCsv'>): Promise<string>;
|
|
404
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/** Tenant treasury wallets and transfers. Signer authority is verified by the API. */
|
|
2
|
+
import { Resource } from './base.js';
|
|
3
|
+
export class TreasuryResource extends Resource {
|
|
4
|
+
// ── Wallets (Safes) ──────────────────────────────────────────────
|
|
5
|
+
listWallets(query = {}) {
|
|
6
|
+
return this.getJson('/treasury/wallets', query);
|
|
7
|
+
}
|
|
8
|
+
createWallet(body, opts) {
|
|
9
|
+
return this.postJson('/treasury/wallets', body, opts);
|
|
10
|
+
}
|
|
11
|
+
getWallet(id) {
|
|
12
|
+
return this.getJson(`/treasury/wallets/${this.enc(id)}`);
|
|
13
|
+
}
|
|
14
|
+
walletBalance(id) {
|
|
15
|
+
return this.getJson(`/treasury/wallets/${this.enc(id)}/balance`);
|
|
16
|
+
}
|
|
17
|
+
listSigners(id) {
|
|
18
|
+
return this.getJson(`/treasury/wallets/${this.enc(id)}/signers`);
|
|
19
|
+
}
|
|
20
|
+
addSigner(id, body, opts) {
|
|
21
|
+
return this.postJson(`/treasury/wallets/${this.enc(id)}/signers`, body, opts);
|
|
22
|
+
}
|
|
23
|
+
changeThreshold(id, body, opts) {
|
|
24
|
+
return this.postJson(`/treasury/wallets/${this.enc(id)}/threshold`, body, opts);
|
|
25
|
+
}
|
|
26
|
+
// ── Transfers (draft → sign → execute) ───────────────────────────
|
|
27
|
+
listTransfers(walletId, query = {}) {
|
|
28
|
+
return this.getJson(`/treasury/wallets/${this.enc(walletId)}/transfers`, query);
|
|
29
|
+
}
|
|
30
|
+
draftTransfer(walletId, body, opts) {
|
|
31
|
+
return this.postJson(`/treasury/wallets/${this.enc(walletId)}/transfers`, body, opts);
|
|
32
|
+
}
|
|
33
|
+
getTransfer(id, query = {}) {
|
|
34
|
+
return this.getJson(`/treasury/transfers/${this.enc(id)}`, query);
|
|
35
|
+
}
|
|
36
|
+
submitTransferSignature(id, body, opts) {
|
|
37
|
+
return this.postJson(`/treasury/transfers/${this.enc(id)}/signatures`, body, opts);
|
|
38
|
+
}
|
|
39
|
+
executeTransfer(id, opts) {
|
|
40
|
+
return this.postJson(`/treasury/transfers/${this.enc(id)}/execute`, undefined, opts);
|
|
41
|
+
}
|
|
42
|
+
cancelTransfer(id, opts) {
|
|
43
|
+
return this.postJson(`/treasury/transfers/${this.enc(id)}/cancel`, undefined, opts);
|
|
44
|
+
}
|
|
45
|
+
// ── Wallet lifecycle + NFT holdings ──────────────────────────────
|
|
46
|
+
decommissionWallet(id, opts) {
|
|
47
|
+
return this.postJson(`/treasury/wallets/${this.enc(id)}/decommission`, undefined, opts);
|
|
48
|
+
}
|
|
49
|
+
designateRevenueWallet(id, opts) {
|
|
50
|
+
return this.postJson(`/treasury/wallets/${this.enc(id)}/designate-revenue`, undefined, opts);
|
|
51
|
+
}
|
|
52
|
+
deleteSigner(id, staffId, opts) {
|
|
53
|
+
return this.deleteJson(`/treasury/wallets/${this.enc(id)}/signers/${this.enc(staffId)}`, opts);
|
|
54
|
+
}
|
|
55
|
+
walletTransactions(id, query = {}) {
|
|
56
|
+
return this.getJson(`/treasury/wallets/${this.enc(id)}/transactions`, query);
|
|
57
|
+
}
|
|
58
|
+
listNftHoldings(walletId, query = {}) {
|
|
59
|
+
return this.getJson(`/treasury/wallets/${this.enc(walletId)}/nft-holdings`, query);
|
|
60
|
+
}
|
|
61
|
+
draftNftTransfer(walletId, body, opts) {
|
|
62
|
+
return this.postJson(`/treasury/wallets/${this.enc(walletId)}/nft-transfers`, body, opts);
|
|
63
|
+
}
|
|
64
|
+
// ── Available assets ─────────────────────────────────────────────
|
|
65
|
+
listAssets(query) {
|
|
66
|
+
return this.getJson('/treasury/assets', query);
|
|
67
|
+
}
|
|
68
|
+
// ── Counterparties ───────────────────────────────────────────────
|
|
69
|
+
listCounterparties(query = {}) {
|
|
70
|
+
return this.getJson('/treasury/counterparties', query);
|
|
71
|
+
}
|
|
72
|
+
createCounterparty(body, opts) {
|
|
73
|
+
return this.postJson('/treasury/counterparties', body, opts);
|
|
74
|
+
}
|
|
75
|
+
updateCounterparty(id, body, opts) {
|
|
76
|
+
return this.patchJson(`/treasury/counterparties/${this.enc(id)}`, body, opts);
|
|
77
|
+
}
|
|
78
|
+
addCounterpartyAddress(id, body, opts) {
|
|
79
|
+
return this.postJson(`/treasury/counterparties/${this.enc(id)}/addresses`, body, opts);
|
|
80
|
+
}
|
|
81
|
+
deleteCounterpartyAddress(id, addressId, opts) {
|
|
82
|
+
return this.deleteJson(`/treasury/counterparties/${this.enc(id)}/addresses/${this.enc(addressId)}`, opts);
|
|
83
|
+
}
|
|
84
|
+
// ── Revenue-treasury change ceremonies ───────────────────────────
|
|
85
|
+
listRevenueChanges() {
|
|
86
|
+
return this.getJson('/treasury/revenue-changes');
|
|
87
|
+
}
|
|
88
|
+
createRevenueChange(body, opts) {
|
|
89
|
+
return this.postJson('/treasury/revenue-changes', body, opts);
|
|
90
|
+
}
|
|
91
|
+
getRevenueChange(id) {
|
|
92
|
+
return this.getJson(`/treasury/revenue-changes/${this.enc(id)}`);
|
|
93
|
+
}
|
|
94
|
+
applyRevenueChange(id, opts) {
|
|
95
|
+
return this.postJson(`/treasury/revenue-changes/${this.enc(id)}/apply`, undefined, opts);
|
|
96
|
+
}
|
|
97
|
+
cancelRevenueChange(id, opts) {
|
|
98
|
+
return this.postJson(`/treasury/revenue-changes/${this.enc(id)}/cancel`, undefined, opts);
|
|
99
|
+
}
|
|
100
|
+
signRevenueChange(id, body, opts) {
|
|
101
|
+
return this.postJson(`/treasury/revenue-changes/${this.enc(id)}/signatures`, body, opts);
|
|
102
|
+
}
|
|
103
|
+
// ── Tax exports ──────────────────────────────────────────────────
|
|
104
|
+
tax1099Summary(query) {
|
|
105
|
+
return this.getJson('/treasury/tax/1099-summary', query);
|
|
106
|
+
}
|
|
107
|
+
/** 1099-MISC as raw CSV. */
|
|
108
|
+
tax1099Csv(query) {
|
|
109
|
+
return this.getText('/treasury/tax/1099-misc.csv', query);
|
|
110
|
+
}
|
|
111
|
+
/** Treasury transactions as raw CSV. */
|
|
112
|
+
taxTransactionsCsv(query) {
|
|
113
|
+
return this.getText('/treasury/tax/transactions.csv', query);
|
|
114
|
+
}
|
|
115
|
+
}
|