@capxul/sdk 1.0.0-alpha.6 → 1.0.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/dist/InMemoryAuthCacheAdapter-v5W-XB5M.mjs +457 -0
- package/dist/InMemoryAuthCacheAdapter-v5W-XB5M.mjs.map +1 -0
- package/dist/index-CTXgQ_xR.d.mts +158 -0
- package/dist/index-CTXgQ_xR.d.mts.map +1 -0
- package/dist/index.d.mts +1026 -227
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +6337 -4591
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.d.mts +3 -3
- package/dist/node/index.mjs +1 -2
- package/dist/node/index.mjs.map +1 -1
- package/dist/ports/safe-deployment.d.mts +1 -1
- package/dist/{safe-deployment-Vni46k3t.d.mts → safe-deployment-D3k9yndM.d.mts} +4 -5
- package/dist/safe-deployment-D3k9yndM.d.mts.map +1 -0
- package/dist/{signer-3-awyCio.d.mts → signer-DqDtJU1l.d.mts} +13 -13
- package/dist/signer-DqDtJU1l.d.mts.map +1 -0
- package/package.json +12 -11
- package/dist/InMemoryAuthCacheAdapter-BK-B_ERB.mjs +0 -113
- package/dist/InMemoryAuthCacheAdapter-BK-B_ERB.mjs.map +0 -1
- package/dist/safe-deployment-Vni46k3t.d.mts.map +0 -1
- package/dist/signer-3-awyCio.d.mts.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { a as
|
|
3
|
-
import {
|
|
4
|
-
import { Machine } from "@effect/experimental";
|
|
5
|
-
import { CapxulError, CapxulErrorCode, CapxulErrorDetails } from "@capxul/config";
|
|
6
|
-
import { Account, Account as Account$1, AccountId, Address, Address as Address$1, AllowedOrigin, AnonymousDistinctId, AppId, AuthSession, AuthSession as AuthSession$1, AuthUserId, AuthUserId as AuthUserId$1, ChainId, CountryCode, DeveloperApplication, DurationMs, Email, EpochMs, Money, Money as Money$1, OrgId, OrgId as OrgId$1, Profile as Profile$1, PublishableKey, PublishableKeyId, PublishableKeyRecord, RoleKey, RoleKey as RoleKey$1, RunId, SessionToken, SmartAccount as SmartAccount$1, SubAccount, SubAccount as SubAccount$1, SubAccountId, SubAccountId as SubAccountId$1 } from "@capxul/types";
|
|
7
|
-
import { TelemetryEvent, TelemetryGroupInput, TelemetryIdentifyInput } from "@capxul/observability";
|
|
1
|
+
import { A as SubAccount, C as PublishableKey, D as RunId, E as RoleKey, F as CapxulErrorDetails, I as FailureMode, N as CapxulError, O as SessionToken, P as CapxulErrorCode, S as Profile$1, T as PublishableKeyRecord, _ as EpochMs, a as AnonymousDistinctId, b as Money, c as AuthUserId, d as CountryCode, f as CurrencyCode, g as Email, h as DurationMs, i as AllowedOrigin, j as SubAccountId, k as SmartAccount$1, m as DocumentHash, n as AccountId, o as AppId, p as DeveloperApplication, r as Address, s as AuthSession, t as Account, u as ChainId, w as PublishableKeyId, x as OrgId } from "./index-CTXgQ_xR.mjs";
|
|
2
|
+
import { _ as CachedJwt, a as AccountProviderSource, c as eip1193AccountProvider, d as Profile, f as Session, h as AuthCachePort, i as AccountProvider, l as localPrivateKeyAccountProvider, n as Eip1193RequestProvider, o as AccountRequirement, p as SmartAccount, r as injectedWalletSigner, s as Eip1193Provider, t as CapxulSigner, u as CapxulResult } from "./signer-DqDtJU1l.mjs";
|
|
3
|
+
import { a as SafeDeploymentEvidence, n as SafeDeploymentConfig } from "./safe-deployment-D3k9yndM.mjs";
|
|
8
4
|
import { Hex } from "viem";
|
|
5
|
+
import { Context, Effect, Layer, Request } from "effect";
|
|
9
6
|
import { Schema } from "@effect/schema";
|
|
10
7
|
import { FunctionReference } from "convex/server";
|
|
8
|
+
import { Machine } from "@effect/experimental";
|
|
11
9
|
|
|
12
10
|
//#region src/ports/auth-client.d.ts
|
|
13
11
|
type AuthClientOperationOptions = {
|
|
@@ -41,8 +39,8 @@ declare class AuthClientError extends AuthClientError_base<{
|
|
|
41
39
|
interface AuthClientPort {
|
|
42
40
|
canSendOtp(input: CanSendOtpInput, options?: AuthClientOperationOptions): Effect.Effect<CanSendOtpStatus, AuthClientError>;
|
|
43
41
|
sendOtp(input: SendOtpInput, options?: AuthClientOperationOptions): Effect.Effect<void, AuthClientError>;
|
|
44
|
-
verifyOtp(input: VerifyOtpInput, options?: AuthClientOperationOptions): Effect.Effect<AuthSession
|
|
45
|
-
getSession(options?: AuthClientOperationOptions): Effect.Effect<AuthSession
|
|
42
|
+
verifyOtp(input: VerifyOtpInput, options?: AuthClientOperationOptions): Effect.Effect<AuthSession, AuthClientError>;
|
|
43
|
+
getSession(options?: AuthClientOperationOptions): Effect.Effect<AuthSession | null, AuthClientError>;
|
|
46
44
|
signOut(options?: AuthClientOperationOptions): Effect.Effect<void, AuthClientError>;
|
|
47
45
|
/**
|
|
48
46
|
* Fetches a Convex-aud JWT from `/api/auth/convex/token` (W7). Server mints
|
|
@@ -67,12 +65,48 @@ declare class ClockError extends ClockError_base<{
|
|
|
67
65
|
readonly cause: unknown;
|
|
68
66
|
}> {}
|
|
69
67
|
//#endregion
|
|
70
|
-
//#region src/
|
|
68
|
+
//#region ../observability/src/telemetry-port.d.ts
|
|
69
|
+
/**
|
|
70
|
+
* Context for reporting handled errors via `reportHandledError`.
|
|
71
|
+
* Carries structured metadata extracted from the error context.
|
|
72
|
+
*/
|
|
73
|
+
interface HandledErrorReportContext$1 {
|
|
74
|
+
readonly layer?: string;
|
|
75
|
+
readonly operation?: string;
|
|
76
|
+
readonly failure_mode?: FailureMode;
|
|
77
|
+
readonly provider?: string;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Canonical TelemetryPort interface. Every adapter (production, test, in-memory)
|
|
81
|
+
* implements this contract. All methods return `Effect<void, never>` —
|
|
82
|
+
* fire-and-forget, defects are caught and traced.
|
|
83
|
+
*/
|
|
71
84
|
interface TelemetryPort {
|
|
72
85
|
readonly emit: (event: TelemetryEvent) => Effect.Effect<void, never>;
|
|
73
86
|
readonly identify: (input: TelemetryIdentifyInput) => Effect.Effect<void, never>;
|
|
74
87
|
readonly group: (input: TelemetryGroupInput) => Effect.Effect<void, never>;
|
|
75
88
|
readonly reset: () => Effect.Effect<void, never>;
|
|
89
|
+
readonly reportHandledError?: (error: CapxulError, context?: HandledErrorReportContext$1) => Effect.Effect<void, never>;
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region ../observability/src/index.d.ts
|
|
93
|
+
declare const TELEMETRY_EVENT_NAMES: readonly ["auth_otp_requested", "auth_otp_delivered", "auth_otp_expired", "auth_verified", "auth_failed", "auth_signed_out", "provisioning_safe_created", "provisioning_safe_confirmed", "bootstrap_resolved", "bootstrap_failed", "account_balance_read", "account_balance_failed", "faucet_requested", "faucet_confirmed", "faucet_failed", "subaccount_created", "subaccount_renamed", "subaccount_deleted", "subaccount_op_failed", "transfer_requested", "transfer_confirmed", "transfer_failed", "org_create_started", "org_safe_created", "org_safe_confirmed", "org_roles_seeded", "org_created", "org_create_failed", "org_invite_sent", "org_invite_accepted", "org_role_granted", "org_member_active", "org_member_removed", "org_invite_expired", "org_role_grant_failed", "payment_requested", "payment_resolved", "payment_document_attached", "payment_submitted", "payment_settled", "payment_claimed", "payment_cancelled", "payment_redirected", "payment_failed", "stream_created", "stream_claimed", "stream_cancelled", "stream_completed", "stream_failed", "withdrawal_requested", "withdrawal_submitted", "withdrawal_settled", "withdrawal_failed"];
|
|
94
|
+
type TelemetryEventName = (typeof TELEMETRY_EVENT_NAMES)[number];
|
|
95
|
+
type TelemetryProps = Record<string, unknown>;
|
|
96
|
+
type TelemetryEvent = {
|
|
97
|
+
readonly name: TelemetryEventName;
|
|
98
|
+
readonly props?: TelemetryProps | undefined;
|
|
99
|
+
};
|
|
100
|
+
interface TelemetryIdentifyInput {
|
|
101
|
+
readonly distinctId: string;
|
|
102
|
+
readonly anonDistinctId?: AnonymousDistinctId;
|
|
103
|
+
readonly traits?: TelemetryProps;
|
|
104
|
+
readonly properties?: TelemetryProps;
|
|
105
|
+
}
|
|
106
|
+
interface TelemetryGroupInput {
|
|
107
|
+
readonly groupType: string;
|
|
108
|
+
readonly groupKey: string;
|
|
109
|
+
readonly properties?: TelemetryProps;
|
|
76
110
|
}
|
|
77
111
|
//#endregion
|
|
78
112
|
//#region src/flows/auth.d.ts
|
|
@@ -83,7 +117,7 @@ type AuthFlowState = "idle" | "sending_otp" | "otp_requested" | "verifying" | "a
|
|
|
83
117
|
interface AuthFlowContext {
|
|
84
118
|
readonly state: AuthFlowState;
|
|
85
119
|
readonly email: Email | null;
|
|
86
|
-
readonly session: AuthSession
|
|
120
|
+
readonly session: AuthSession | null;
|
|
87
121
|
readonly otpRequestedAt: EpochMs | null;
|
|
88
122
|
readonly anonDistinctId?: AnonymousDistinctId;
|
|
89
123
|
readonly error: CapxulError | null;
|
|
@@ -126,41 +160,6 @@ interface EnvPort {
|
|
|
126
160
|
readonly has: (key: EnvKey) => Effect.Effect<boolean, EnvError, never>;
|
|
127
161
|
}
|
|
128
162
|
//#endregion
|
|
129
|
-
//#region src/ports/evm-signer.d.ts
|
|
130
|
-
type HexString = `0x${string}`;
|
|
131
|
-
type UserOperationRequest = {
|
|
132
|
-
readonly sender: Address$1;
|
|
133
|
-
readonly chainId: ChainId;
|
|
134
|
-
readonly callData: HexString;
|
|
135
|
-
readonly nonce?: HexString;
|
|
136
|
-
readonly maxFeePerGas?: HexString;
|
|
137
|
-
readonly maxPriorityFeePerGas?: HexString;
|
|
138
|
-
readonly callGasLimit?: HexString;
|
|
139
|
-
readonly verificationGasLimit?: HexString;
|
|
140
|
-
readonly preVerificationGas?: HexString;
|
|
141
|
-
readonly paymasterAndData?: HexString;
|
|
142
|
-
};
|
|
143
|
-
type SignedUserOperation = UserOperationRequest & {
|
|
144
|
-
readonly sender: Address$1;
|
|
145
|
-
readonly signature: HexString;
|
|
146
|
-
readonly userOpHash: HexString;
|
|
147
|
-
};
|
|
148
|
-
declare const EvmSignerError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
|
|
149
|
-
readonly _tag: "EvmSignerError";
|
|
150
|
-
} & Readonly<A>;
|
|
151
|
-
declare class EvmSignerError extends EvmSignerError_base<{
|
|
152
|
-
readonly publicError: CapxulError;
|
|
153
|
-
readonly publicCode?: CapxulErrorCode;
|
|
154
|
-
readonly operation?: string;
|
|
155
|
-
readonly details?: CapxulErrorDetails;
|
|
156
|
-
readonly cause?: unknown;
|
|
157
|
-
}> {}
|
|
158
|
-
interface EvmSignerPort {
|
|
159
|
-
readonly getAddress: Effect.Effect<Address$1, EvmSignerError, never>;
|
|
160
|
-
readonly signMessage: (message: string | Uint8Array) => Effect.Effect<HexString, EvmSignerError, never>;
|
|
161
|
-
readonly signUserOp: (userOperation: UserOperationRequest) => Effect.Effect<SignedUserOperation, EvmSignerError, never>;
|
|
162
|
-
}
|
|
163
|
-
//#endregion
|
|
164
163
|
//#region src/ports/transport.d.ts
|
|
165
164
|
type TransportOperationKind = "query" | "mutation" | "action";
|
|
166
165
|
type TransportRequest<TArgs = unknown> = {
|
|
@@ -302,22 +301,22 @@ interface ConvexCallPort {
|
|
|
302
301
|
//#endregion
|
|
303
302
|
//#region src/ports/credentials.d.ts
|
|
304
303
|
type CreateApplicationInput = {
|
|
305
|
-
readonly authUserId: AuthUserId
|
|
304
|
+
readonly authUserId: AuthUserId;
|
|
306
305
|
readonly name: string;
|
|
307
306
|
readonly allowedOrigins: readonly AllowedOrigin[];
|
|
308
307
|
};
|
|
309
308
|
type MintKeyInput = {
|
|
310
309
|
readonly applicationId: AppId;
|
|
311
|
-
readonly authUserId: AuthUserId
|
|
310
|
+
readonly authUserId: AuthUserId;
|
|
312
311
|
};
|
|
313
312
|
type RotateKeyInput = {
|
|
314
313
|
readonly keyId: PublishableKeyId;
|
|
315
|
-
readonly authUserId: AuthUserId
|
|
314
|
+
readonly authUserId: AuthUserId;
|
|
316
315
|
readonly graceMs: DurationMs;
|
|
317
316
|
};
|
|
318
317
|
type RevokeKeyInput = {
|
|
319
318
|
readonly keyId: PublishableKeyId;
|
|
320
|
-
readonly authUserId: AuthUserId
|
|
319
|
+
readonly authUserId: AuthUserId;
|
|
321
320
|
};
|
|
322
321
|
type RotateKeyResult = {
|
|
323
322
|
readonly active: PublishableKeyRecord;
|
|
@@ -334,7 +333,7 @@ declare class CredentialsError extends CredentialsError_base<{
|
|
|
334
333
|
readonly details?: CapxulErrorDetails;
|
|
335
334
|
}> {}
|
|
336
335
|
interface CredentialsPort {
|
|
337
|
-
listApplications(authUserId: AuthUserId
|
|
336
|
+
listApplications(authUserId: AuthUserId): Effect.Effect<readonly DeveloperApplication[], CredentialsError>;
|
|
338
337
|
createApplication(input: CreateApplicationInput): Effect.Effect<DeveloperApplication, CredentialsError>;
|
|
339
338
|
mintPublishableKey(input: MintKeyInput): Effect.Effect<PublishableKeyRecord, CredentialsError>;
|
|
340
339
|
rotatePublishableKey(input: RotateKeyInput): Effect.Effect<RotateKeyResult, CredentialsError>;
|
|
@@ -343,16 +342,31 @@ interface CredentialsPort {
|
|
|
343
342
|
//#endregion
|
|
344
343
|
//#region src/ports/identity.d.ts
|
|
345
344
|
type CreateIdentityInput = {
|
|
346
|
-
readonly authUserId: AuthUserId
|
|
345
|
+
readonly authUserId: AuthUserId;
|
|
347
346
|
readonly email: Email;
|
|
348
347
|
readonly displayName?: string;
|
|
349
348
|
readonly country?: CountryCode;
|
|
350
349
|
};
|
|
351
350
|
type UpdateIdentityInput = {
|
|
352
|
-
readonly authUserId: AuthUserId
|
|
351
|
+
readonly authUserId: AuthUserId;
|
|
353
352
|
readonly displayName?: string;
|
|
354
353
|
readonly country?: CountryCode;
|
|
355
354
|
};
|
|
355
|
+
/**
|
|
356
|
+
* D-ONBOARD (#669) — the onboarding-complete identity write. Composes the
|
|
357
|
+
* existing create/update write into one idempotent upsert that ALSO sets the
|
|
358
|
+
* `onboarded` flag and persists the optional `withdrawalAddress` (the one
|
|
359
|
+
* allowed raw-0x class). `displayName` + `country` are required at onboarding
|
|
360
|
+
* time. The returned `Profile` is the existing branded shape — the onboarding
|
|
361
|
+
* flags live on the wire row and are not projected onto the read surface.
|
|
362
|
+
*/
|
|
363
|
+
type CompleteOnboardingIdentityInput = {
|
|
364
|
+
readonly authUserId: AuthUserId;
|
|
365
|
+
readonly email: Email;
|
|
366
|
+
readonly displayName: string;
|
|
367
|
+
readonly country: CountryCode;
|
|
368
|
+
readonly withdrawalAddress?: Address;
|
|
369
|
+
};
|
|
356
370
|
declare const IdentityError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
|
|
357
371
|
readonly _tag: "IdentityError";
|
|
358
372
|
} & Readonly<A>;
|
|
@@ -364,14 +378,16 @@ declare class IdentityError extends IdentityError_base<{
|
|
|
364
378
|
readonly details?: CapxulErrorDetails;
|
|
365
379
|
}> {}
|
|
366
380
|
interface IdentityPort {
|
|
367
|
-
loadByAuthUserId(authUserId: AuthUserId
|
|
381
|
+
loadByAuthUserId(authUserId: AuthUserId): Effect.Effect<Profile$1 | null, IdentityError, never>;
|
|
368
382
|
create(input: CreateIdentityInput): Effect.Effect<Profile$1, IdentityError, never>;
|
|
369
383
|
update(input: UpdateIdentityInput): Effect.Effect<Profile$1, IdentityError, never>;
|
|
384
|
+
/** D-ONBOARD (#669): idempotent upsert that marks the identity onboarded. */
|
|
385
|
+
completeOnboarding(input: CompleteOnboardingIdentityInput): Effect.Effect<Profile$1, IdentityError, never>;
|
|
370
386
|
}
|
|
371
387
|
//#endregion
|
|
372
388
|
//#region src/ports/smart-account.d.ts
|
|
373
389
|
type ProvisionInput = {
|
|
374
|
-
readonly authUserId: AuthUserId
|
|
390
|
+
readonly authUserId: AuthUserId;
|
|
375
391
|
readonly chainId: ChainId;
|
|
376
392
|
};
|
|
377
393
|
/**
|
|
@@ -389,9 +405,9 @@ type ProvisionInput = {
|
|
|
389
405
|
* `eth_getUserOperationReceipt(userOpHash)` to re-verify and derive.
|
|
390
406
|
*/
|
|
391
407
|
type ConfirmDeploymentInput = {
|
|
392
|
-
readonly authUserId: AuthUserId
|
|
408
|
+
readonly authUserId: AuthUserId;
|
|
393
409
|
readonly chainId: ChainId;
|
|
394
|
-
readonly safeAddress: Address
|
|
410
|
+
readonly safeAddress: Address;
|
|
395
411
|
readonly evidence: SafeDeploymentEvidence;
|
|
396
412
|
/**
|
|
397
413
|
* Optional live-E2E correlation id. This does not prove deployment; the
|
|
@@ -400,41 +416,16 @@ type ConfirmDeploymentInput = {
|
|
|
400
416
|
*/
|
|
401
417
|
readonly telemetryRunId?: RunId;
|
|
402
418
|
};
|
|
403
|
-
/**
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
readonly
|
|
411
|
-
readonly verificationGasLimit: string;
|
|
412
|
-
readonly preVerificationGas: string;
|
|
413
|
-
readonly maxFeePerGas: string;
|
|
414
|
-
readonly maxPriorityFeePerGas: string;
|
|
415
|
-
readonly paymaster: string;
|
|
416
|
-
readonly paymasterVerificationGasLimit?: string | undefined;
|
|
417
|
-
readonly paymasterPostOpGasLimit?: string | undefined;
|
|
418
|
-
readonly paymasterData: string;
|
|
419
|
-
};
|
|
420
|
-
/** Input to `SmartAccountPort.deployPrepare` (backend-orchestrated-deploy.md · #289). */
|
|
421
|
-
type DeployPrepareInput = {
|
|
422
|
-
readonly authUserId: AuthUserId$1;
|
|
423
|
-
readonly chainId: ChainId;
|
|
424
|
-
readonly telemetryRunId?: RunId;
|
|
425
|
-
};
|
|
426
|
-
/** Backend-built deployment UserOp + the EIP-712 SafeOp digest the CapxulSigner signs. */
|
|
427
|
-
type DeployPrepareResult = {
|
|
428
|
-
readonly digest: Hex;
|
|
429
|
-
readonly safeAddress: Address$1;
|
|
430
|
-
readonly userOp: DeploymentUserOpFields;
|
|
431
|
-
};
|
|
432
|
-
/** Input to `SmartAccountPort.deploySubmit` — the consumer-signed deployment UserOp. */
|
|
433
|
-
type DeploySubmitInput = {
|
|
434
|
-
readonly authUserId: AuthUserId$1;
|
|
419
|
+
/**
|
|
420
|
+
* Input to `SmartAccountPort.claim` (PRD #462). The authenticated session
|
|
421
|
+
* reports the browser-created signer address; the BACKEND builds and
|
|
422
|
+
* bootstrap-signs the claim userOp (deploy + swapOwner) — the consumer signs
|
|
423
|
+
* nothing at claim.
|
|
424
|
+
*/
|
|
425
|
+
type ClaimInput = {
|
|
426
|
+
readonly authUserId: AuthUserId;
|
|
435
427
|
readonly chainId: ChainId;
|
|
436
|
-
readonly
|
|
437
|
-
readonly signature: Hex;
|
|
428
|
+
readonly signerAddress: Address;
|
|
438
429
|
readonly telemetryRunId?: RunId;
|
|
439
430
|
};
|
|
440
431
|
declare const SmartAccountError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
|
|
@@ -448,8 +439,8 @@ declare class SmartAccountError extends SmartAccountError_base<{
|
|
|
448
439
|
readonly details?: CapxulErrorDetails;
|
|
449
440
|
}> {}
|
|
450
441
|
interface SmartAccountPort {
|
|
451
|
-
loadByAuthUserId(authUserId: AuthUserId
|
|
452
|
-
loadBySmartAccountAddress(address: Address
|
|
442
|
+
loadByAuthUserId(authUserId: AuthUserId): Effect.Effect<SmartAccount$1 | null, SmartAccountError, never>;
|
|
443
|
+
loadBySmartAccountAddress(address: Address): Effect.Effect<SmartAccount$1 | null, SmartAccountError, never>;
|
|
453
444
|
provision(input: ProvisionInput): Effect.Effect<SmartAccount$1, SmartAccountError, never>;
|
|
454
445
|
/**
|
|
455
446
|
* Persist on-chain Safe-deployment evidence. The backend re-verifies
|
|
@@ -462,42 +453,13 @@ interface SmartAccountPort {
|
|
|
462
453
|
*/
|
|
463
454
|
confirmDeployment(input: ConfirmDeploymentInput): Effect.Effect<SmartAccount$1, SmartAccountError, never>;
|
|
464
455
|
/**
|
|
465
|
-
*
|
|
466
|
-
*
|
|
467
|
-
* `
|
|
468
|
-
*
|
|
469
|
-
|
|
470
|
-
deployPrepare(input: DeployPrepareInput): Effect.Effect<DeployPrepareResult, SmartAccountError, never>;
|
|
471
|
-
/**
|
|
472
|
-
* Submit the signed deployment UserOperation through the bundler and confirm
|
|
473
|
-
* `deployedAt` on-chain (absorbing the `confirmDeployment` verify path).
|
|
474
|
-
* Returns the updated `SmartAccount` row.
|
|
456
|
+
* Claim the account (PRD #462): the backend builds, bootstrap-signs, and
|
|
457
|
+
* submits ONE sponsored userOp — deploy (when undeployed) + swapOwner
|
|
458
|
+
* (bootstrap → `signerAddress`). Idempotent; returns the updated row. When
|
|
459
|
+
* another claim is in flight the row comes back with `claimedAt: null` —
|
|
460
|
+
* callers poll lifecycle until the claim lands.
|
|
475
461
|
*/
|
|
476
|
-
|
|
477
|
-
}
|
|
478
|
-
//#endregion
|
|
479
|
-
//#region src/ports/binding.d.ts
|
|
480
|
-
type EmailBinding = {
|
|
481
|
-
readonly bindingId: string;
|
|
482
|
-
readonly signerAddress: Address$1;
|
|
483
|
-
readonly safeAddress: Address$1;
|
|
484
|
-
};
|
|
485
|
-
type EnsureBindingResolvedInput = {
|
|
486
|
-
readonly email: Email; /** Browser embedded wallet EOA when the client already configured Openfort Shield. */
|
|
487
|
-
readonly signerAddress?: Address$1;
|
|
488
|
-
};
|
|
489
|
-
declare const BindingError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
|
|
490
|
-
readonly _tag: "BindingError";
|
|
491
|
-
} & Readonly<A>;
|
|
492
|
-
declare class BindingError extends BindingError_base<{
|
|
493
|
-
readonly operation: string;
|
|
494
|
-
readonly publicCode: CapxulErrorCode;
|
|
495
|
-
readonly publicError: CapxulError;
|
|
496
|
-
readonly cause: unknown;
|
|
497
|
-
readonly details?: CapxulErrorDetails;
|
|
498
|
-
}> {}
|
|
499
|
-
interface BindingPort {
|
|
500
|
-
readonly ensureResolved: (input: EnsureBindingResolvedInput) => Effect.Effect<EmailBinding, BindingError>;
|
|
462
|
+
claim(input: ClaimInput): Effect.Effect<SmartAccount$1, SmartAccountError, never>;
|
|
501
463
|
}
|
|
502
464
|
//#endregion
|
|
503
465
|
//#region src/ports/account-read.d.ts
|
|
@@ -506,7 +468,7 @@ type ReadAccountBalanceInput = {
|
|
|
506
468
|
};
|
|
507
469
|
type FundFromFaucetInput = {
|
|
508
470
|
readonly chainId: ChainId;
|
|
509
|
-
readonly amount: Money
|
|
471
|
+
readonly amount: Money;
|
|
510
472
|
};
|
|
511
473
|
type FundFromFaucetResult = {
|
|
512
474
|
readonly txHash: string;
|
|
@@ -526,7 +488,7 @@ declare class AccountReadError extends AccountReadError_base<{
|
|
|
526
488
|
* live RPC `balanceOf` pull; the adapter lifts wire integers to `Money`.
|
|
527
489
|
*/
|
|
528
490
|
interface AccountReadPort {
|
|
529
|
-
readBalance(input: ReadAccountBalanceInput): Effect.Effect<Account
|
|
491
|
+
readBalance(input: ReadAccountBalanceInput): Effect.Effect<Account, AccountReadError, never>;
|
|
530
492
|
fundFromFaucet(input: FundFromFaucetInput): Effect.Effect<FundFromFaucetResult, AccountReadError, never>;
|
|
531
493
|
}
|
|
532
494
|
//#endregion
|
|
@@ -546,10 +508,10 @@ type CreateSubAccountInput = {
|
|
|
546
508
|
readonly name: string;
|
|
547
509
|
};
|
|
548
510
|
type SubAccountIdInput = {
|
|
549
|
-
readonly subAccountId: SubAccountId
|
|
511
|
+
readonly subAccountId: SubAccountId;
|
|
550
512
|
};
|
|
551
513
|
type RenameSubAccountInput = {
|
|
552
|
-
readonly subAccountId: SubAccountId
|
|
514
|
+
readonly subAccountId: SubAccountId;
|
|
553
515
|
readonly name: string;
|
|
554
516
|
};
|
|
555
517
|
/**
|
|
@@ -558,7 +520,7 @@ type RenameSubAccountInput = {
|
|
|
558
520
|
* specific sub-account, addressed by its `SubAccountId` (canon
|
|
559
521
|
* `account-balance-model.md` §5, §12).
|
|
560
522
|
*/
|
|
561
|
-
type TransferEndpoint = "main" | SubAccountId
|
|
523
|
+
type TransferEndpoint = "main" | SubAccountId;
|
|
562
524
|
/**
|
|
563
525
|
* Move money between two of the SAME Account's balances (canon §12). The
|
|
564
526
|
* backend resolves the Account from auth (v1 = one Account per user), so the
|
|
@@ -569,7 +531,7 @@ type TransferEndpoint = "main" | SubAccountId$1;
|
|
|
569
531
|
type TransferInput = {
|
|
570
532
|
readonly from: TransferEndpoint;
|
|
571
533
|
readonly to: TransferEndpoint;
|
|
572
|
-
readonly amount: Money
|
|
534
|
+
readonly amount: Money;
|
|
573
535
|
};
|
|
574
536
|
/**
|
|
575
537
|
* Result of a `transfer`: the recomputed `available` (`balanceOf − Σ`), plus
|
|
@@ -577,27 +539,29 @@ type TransferInput = {
|
|
|
577
539
|
* has no stored row, so its slot is `null`.
|
|
578
540
|
*/
|
|
579
541
|
type TransferResult = {
|
|
580
|
-
readonly available: Money
|
|
581
|
-
readonly from: SubAccount
|
|
582
|
-
readonly to: SubAccount
|
|
542
|
+
readonly available: Money;
|
|
543
|
+
readonly from: SubAccount | null;
|
|
544
|
+
readonly to: SubAccount | null;
|
|
583
545
|
};
|
|
584
546
|
interface SubAccountPort {
|
|
585
|
-
create(input: CreateSubAccountInput): Effect.Effect<SubAccount
|
|
586
|
-
get(input: SubAccountIdInput): Effect.Effect<SubAccount
|
|
547
|
+
create(input: CreateSubAccountInput): Effect.Effect<SubAccount, SubAccountError, never>;
|
|
548
|
+
get(input: SubAccountIdInput): Effect.Effect<SubAccount | null, SubAccountError, never>;
|
|
587
549
|
list(input: {
|
|
588
550
|
readonly accountId: AccountId;
|
|
589
|
-
}): Effect.Effect<readonly SubAccount
|
|
590
|
-
rename(input: RenameSubAccountInput): Effect.Effect<SubAccount
|
|
551
|
+
}): Effect.Effect<readonly SubAccount[], SubAccountError, never>;
|
|
552
|
+
rename(input: RenameSubAccountInput): Effect.Effect<SubAccount, SubAccountError, never>;
|
|
591
553
|
delete(input: SubAccountIdInput): Effect.Effect<void, SubAccountError, never>;
|
|
592
554
|
transfer(input: TransferInput): Effect.Effect<TransferResult, SubAccountError, never>;
|
|
593
555
|
}
|
|
594
556
|
//#endregion
|
|
595
557
|
//#region src/flows/types.d.ts
|
|
596
558
|
/**
|
|
597
|
-
* The full
|
|
559
|
+
* The full 13-port bundle that `assembleCapxulClient` (slice 5) consumes.
|
|
560
|
+
* (Was 15 before the dead local-signer port was retired; the deploy path
|
|
561
|
+
* now signs exclusively through `CapxulSigner`.)
|
|
598
562
|
*
|
|
599
563
|
* Each per-flow factory in slices 2-4 takes a narrowed subset, e.g.
|
|
600
|
-
* `AuthFlowPorts = Pick<FlowPorts, "authClient" | "
|
|
564
|
+
* `AuthFlowPorts = Pick<FlowPorts, "authClient" | "clock" | "telemetry">`.
|
|
601
565
|
* Slice 1 ships only the union; per Q6 each per-flow slice declares its
|
|
602
566
|
* own narrowed `Pick<FlowPorts, ...>` inside its flow file.
|
|
603
567
|
*/
|
|
@@ -606,12 +570,10 @@ interface FlowPorts {
|
|
|
606
570
|
readonly authCache: AuthCachePort;
|
|
607
571
|
readonly identity: IdentityPort;
|
|
608
572
|
readonly smartAccount: SmartAccountPort;
|
|
609
|
-
readonly binding: BindingPort;
|
|
610
573
|
readonly accountRead: AccountReadPort;
|
|
611
574
|
readonly subAccount: SubAccountPort;
|
|
612
575
|
readonly credentials: CredentialsPort;
|
|
613
576
|
readonly bootstrap: BootstrapPort;
|
|
614
|
-
readonly evmSigner: EvmSignerPort;
|
|
615
577
|
readonly clock: ClockPort;
|
|
616
578
|
readonly env: EnvPort;
|
|
617
579
|
readonly telemetry: TelemetryPort;
|
|
@@ -650,7 +612,7 @@ interface FlowPorts {
|
|
|
650
612
|
* convention, flow-shape composites stay co-located with their flow.
|
|
651
613
|
*/
|
|
652
614
|
interface ExternalSigner {
|
|
653
|
-
readonly address: Address
|
|
615
|
+
readonly address: Address;
|
|
654
616
|
readonly signedProof: string;
|
|
655
617
|
}
|
|
656
618
|
//#endregion
|
|
@@ -696,13 +658,11 @@ interface IdentityMethods {
|
|
|
696
658
|
}
|
|
697
659
|
//#endregion
|
|
698
660
|
//#region src/client/account-lane.d.ts
|
|
699
|
-
type ProvisioningFailureStep = "wallet" | "
|
|
661
|
+
type ProvisioningFailureStep = "wallet" | "identity" | "provision" | "deploy";
|
|
700
662
|
type ProvisioningPhase = {
|
|
701
663
|
readonly status: "idle";
|
|
702
664
|
} | {
|
|
703
665
|
readonly status: "wallet";
|
|
704
|
-
} | {
|
|
705
|
-
readonly status: "binding";
|
|
706
666
|
} | {
|
|
707
667
|
readonly status: "identity";
|
|
708
668
|
} | {
|
|
@@ -747,7 +707,7 @@ type AccountStatus = {
|
|
|
747
707
|
readonly requirement: AccountRequirement;
|
|
748
708
|
readonly chainId: number;
|
|
749
709
|
readonly source: AccountProviderSource;
|
|
750
|
-
readonly signerAddress: Address
|
|
710
|
+
readonly signerAddress: Address;
|
|
751
711
|
} | {
|
|
752
712
|
readonly status: "accountPrepared";
|
|
753
713
|
readonly requirement: AccountRequirement;
|
|
@@ -822,18 +782,11 @@ interface AccountInternalSurface {
|
|
|
822
782
|
retryProvisioning(): Promise<CapxulResult<ProvisioningPhase>>;
|
|
823
783
|
}
|
|
824
784
|
//#endregion
|
|
825
|
-
//#region src/client/binding.d.ts
|
|
826
|
-
interface BindingMethods {
|
|
827
|
-
readonly ensureResolved: (input: {
|
|
828
|
-
readonly email: string;
|
|
829
|
-
}) => Promise<CapxulResult<EmailBinding>>;
|
|
830
|
-
}
|
|
831
|
-
//#endregion
|
|
832
785
|
//#region src/client/accounts.d.ts
|
|
833
786
|
interface AccountsMethods {
|
|
834
787
|
read(options?: {
|
|
835
788
|
readonly signal?: AbortSignal;
|
|
836
|
-
}): Promise<CapxulResult<Account
|
|
789
|
+
}): Promise<CapxulResult<Account>>;
|
|
837
790
|
}
|
|
838
791
|
/**
|
|
839
792
|
* Faucet surface (dev-only). Deliberately OFF the public `AccountsMethods`;
|
|
@@ -841,30 +794,658 @@ interface AccountsMethods {
|
|
|
841
794
|
* The reference CLI uses it behind a test-env gate — consumers never see `fund`.
|
|
842
795
|
*/
|
|
843
796
|
interface AccountsFaucetMethods {
|
|
844
|
-
fund(amount: Money
|
|
797
|
+
fund(amount: Money, options?: {
|
|
845
798
|
readonly signal?: AbortSignal;
|
|
846
799
|
}): Promise<CapxulResult<{
|
|
847
800
|
readonly txHash: string;
|
|
848
801
|
}>>;
|
|
849
802
|
}
|
|
850
803
|
//#endregion
|
|
804
|
+
//#region ../wire/src/financial-ops.d.ts
|
|
805
|
+
declare const PaymentDocumentEnvelope: Schema.Union<[Schema.Struct<{
|
|
806
|
+
protocol: Schema.Literal<["capxul.payment-document"]>;
|
|
807
|
+
version: Schema.Literal<[1]>;
|
|
808
|
+
domain: Schema.Struct<{
|
|
809
|
+
name: Schema.Literal<["CapxulPayments"]>;
|
|
810
|
+
version: Schema.Literal<["1"]>;
|
|
811
|
+
chainId: Schema.Schema<ChainId, number, never>;
|
|
812
|
+
verifyingContract: Schema.Literal<["0xe740ea65521edc9bef0ea75d30b5334711db99f4"]>;
|
|
813
|
+
}>;
|
|
814
|
+
primaryType: Schema.Literal<["Memo"]>;
|
|
815
|
+
message: Schema.Struct<{
|
|
816
|
+
kind: Schema.Literal<[0]>;
|
|
817
|
+
reference: typeof Schema.String;
|
|
818
|
+
note: typeof Schema.String;
|
|
819
|
+
issuedAt: Schema.refine<number, Schema.Schema<number, number, never>>;
|
|
820
|
+
}>;
|
|
821
|
+
}>, Schema.Struct<{
|
|
822
|
+
protocol: Schema.Literal<["capxul.payment-document"]>;
|
|
823
|
+
version: Schema.Literal<[1]>;
|
|
824
|
+
domain: Schema.Struct<{
|
|
825
|
+
name: Schema.Literal<["CapxulPayments"]>;
|
|
826
|
+
version: Schema.Literal<["1"]>;
|
|
827
|
+
chainId: Schema.Schema<ChainId, number, never>;
|
|
828
|
+
verifyingContract: Schema.Literal<["0xe740ea65521edc9bef0ea75d30b5334711db99f4"]>;
|
|
829
|
+
}>;
|
|
830
|
+
primaryType: Schema.Literal<["Invoice"]>;
|
|
831
|
+
message: Schema.Struct<{
|
|
832
|
+
kind: Schema.Literal<[1]>;
|
|
833
|
+
invoiceNumber: typeof Schema.String;
|
|
834
|
+
payerRef: typeof Schema.String;
|
|
835
|
+
payeeRef: typeof Schema.String;
|
|
836
|
+
amount: Schema.refine<string, Schema.Schema<string, string, never>>;
|
|
837
|
+
currency: Schema.Schema<CurrencyCode, string, never>;
|
|
838
|
+
decimals: Schema.refine<number, Schema.Schema<number, number, never>>;
|
|
839
|
+
issuedAt: Schema.refine<number, Schema.Schema<number, number, never>>;
|
|
840
|
+
dueAt: Schema.refine<number, Schema.Schema<number, number, never>>;
|
|
841
|
+
lineItemsHash: Schema.Schema<DocumentHash, string, never>;
|
|
842
|
+
}>;
|
|
843
|
+
}>, Schema.Struct<{
|
|
844
|
+
protocol: Schema.Literal<["capxul.payment-document"]>;
|
|
845
|
+
version: Schema.Literal<[1]>;
|
|
846
|
+
domain: Schema.Struct<{
|
|
847
|
+
name: Schema.Literal<["CapxulPayments"]>;
|
|
848
|
+
version: Schema.Literal<["1"]>;
|
|
849
|
+
chainId: Schema.Schema<ChainId, number, never>;
|
|
850
|
+
verifyingContract: Schema.Literal<["0xe740ea65521edc9bef0ea75d30b5334711db99f4"]>;
|
|
851
|
+
}>;
|
|
852
|
+
primaryType: Schema.Literal<["Payslip"]>;
|
|
853
|
+
message: Schema.Struct<{
|
|
854
|
+
kind: Schema.Literal<[2]>;
|
|
855
|
+
employerRef: typeof Schema.String;
|
|
856
|
+
employeeRef: typeof Schema.String;
|
|
857
|
+
period: typeof Schema.String;
|
|
858
|
+
gross: Schema.refine<string, Schema.Schema<string, string, never>>;
|
|
859
|
+
net: Schema.refine<string, Schema.Schema<string, string, never>>;
|
|
860
|
+
currency: Schema.Schema<CurrencyCode, string, never>;
|
|
861
|
+
decimals: Schema.refine<number, Schema.Schema<number, number, never>>;
|
|
862
|
+
issuedAt: Schema.refine<number, Schema.Schema<number, number, never>>;
|
|
863
|
+
}>;
|
|
864
|
+
}>, Schema.Struct<{
|
|
865
|
+
protocol: Schema.Literal<["capxul.payment-document"]>;
|
|
866
|
+
version: Schema.Literal<[1]>;
|
|
867
|
+
domain: Schema.Struct<{
|
|
868
|
+
name: Schema.Literal<["CapxulPayments"]>;
|
|
869
|
+
version: Schema.Literal<["1"]>;
|
|
870
|
+
chainId: Schema.Schema<ChainId, number, never>;
|
|
871
|
+
verifyingContract: Schema.Literal<["0xe740ea65521edc9bef0ea75d30b5334711db99f4"]>;
|
|
872
|
+
}>;
|
|
873
|
+
primaryType: Schema.Literal<["Receipt"]>;
|
|
874
|
+
message: Schema.Struct<{
|
|
875
|
+
kind: Schema.Literal<[3]>;
|
|
876
|
+
reference: typeof Schema.String;
|
|
877
|
+
amount: Schema.refine<string, Schema.Schema<string, string, never>>;
|
|
878
|
+
currency: Schema.Schema<CurrencyCode, string, never>;
|
|
879
|
+
decimals: Schema.refine<number, Schema.Schema<number, number, never>>;
|
|
880
|
+
paidAt: Schema.refine<number, Schema.Schema<number, number, never>>;
|
|
881
|
+
note: typeof Schema.String;
|
|
882
|
+
}>;
|
|
883
|
+
}>, Schema.Struct<{
|
|
884
|
+
protocol: Schema.Literal<["capxul.payment-document"]>;
|
|
885
|
+
version: Schema.Literal<[1]>;
|
|
886
|
+
domain: Schema.Struct<{
|
|
887
|
+
name: Schema.Literal<["CapxulPayments"]>;
|
|
888
|
+
version: Schema.Literal<["1"]>;
|
|
889
|
+
chainId: Schema.Schema<ChainId, number, never>;
|
|
890
|
+
verifyingContract: Schema.Literal<["0xe740ea65521edc9bef0ea75d30b5334711db99f4"]>;
|
|
891
|
+
}>;
|
|
892
|
+
primaryType: Schema.Literal<["Withdrawal"]>;
|
|
893
|
+
message: Schema.Struct<{
|
|
894
|
+
kind: Schema.Literal<[4]>;
|
|
895
|
+
reference: typeof Schema.String;
|
|
896
|
+
amount: Schema.refine<string, Schema.Schema<string, string, never>>;
|
|
897
|
+
currency: Schema.Schema<CurrencyCode, string, never>;
|
|
898
|
+
decimals: Schema.refine<number, Schema.Schema<number, number, never>>;
|
|
899
|
+
destChain: Schema.Schema<ChainId, number, never>;
|
|
900
|
+
destAddress: Schema.refine<string, Schema.Schema<string, string, never>>;
|
|
901
|
+
settledAt: Schema.refine<number, Schema.Schema<number, number, never>>;
|
|
902
|
+
provider: typeof Schema.String;
|
|
903
|
+
note: typeof Schema.String;
|
|
904
|
+
}>;
|
|
905
|
+
}>]>;
|
|
906
|
+
/**
|
|
907
|
+
* #592 invoice line item. `quantity` is a positive integer; `unitMinor` is the
|
|
908
|
+
* per-unit price in integer minor units. The list is canonically hashed by
|
|
909
|
+
* `hashLineItems` (payment-document-hash.ts) into the Invoice `lineItemsHash`,
|
|
910
|
+
* and Σ(quantity × unitMinor) MUST equal the invoice `amount`. The hash binds
|
|
911
|
+
* the documentHash to the exact items; the sum-check makes the items add up to
|
|
912
|
+
* the amount due. See the payment-document spec (canon/mcp/financial-ops.md).
|
|
913
|
+
*/
|
|
914
|
+
declare const LineItem: Schema.Struct<{
|
|
915
|
+
description: typeof Schema.String;
|
|
916
|
+
quantity: Schema.refine<number, Schema.Schema<number, number, never>>;
|
|
917
|
+
unitMinor: Schema.refine<string, Schema.Schema<string, string, never>>;
|
|
918
|
+
}>;
|
|
919
|
+
type PaymentDocumentEnvelopeV1 = Schema.Schema.Type<typeof PaymentDocumentEnvelope>;
|
|
920
|
+
type LineItemV1 = Schema.Schema.Type<typeof LineItem>;
|
|
921
|
+
//#endregion
|
|
922
|
+
//#region ../wire/src/leak-safety.d.ts
|
|
923
|
+
declare const OnchainEvidenceBrand: unique symbol;
|
|
924
|
+
/**
|
|
925
|
+
* The branded `{ userOpHash, txHash }` pair. On-chain settlement evidence is
|
|
926
|
+
* INTERNAL — it flows on the server-internal channel only, never onto a wire
|
|
927
|
+
* Payment or any MCP tool output. The brand makes "this is internal evidence"
|
|
928
|
+
* a type, so a loose pair can't be passed where a wire field is expected.
|
|
929
|
+
*/
|
|
930
|
+
type OnchainEvidence = {
|
|
931
|
+
readonly userOpHash: string;
|
|
932
|
+
readonly txHash: string;
|
|
933
|
+
} & {
|
|
934
|
+
readonly [OnchainEvidenceBrand]: "OnchainEvidence";
|
|
935
|
+
};
|
|
936
|
+
//#endregion
|
|
937
|
+
//#region src/client/financial-ops.d.ts
|
|
938
|
+
type RecipientResolutionKind = "email" | "org" | "payee";
|
|
939
|
+
interface MeProfile {
|
|
940
|
+
readonly authUserId: string;
|
|
941
|
+
readonly email: string;
|
|
942
|
+
readonly displayName: string | null;
|
|
943
|
+
readonly personalSafeAddress: string;
|
|
944
|
+
}
|
|
945
|
+
interface DepositInstructions {
|
|
946
|
+
readonly accountKind: "personalSafe";
|
|
947
|
+
readonly chainId: number;
|
|
948
|
+
readonly network: "base-sepolia";
|
|
949
|
+
readonly currency: "USD";
|
|
950
|
+
readonly address: string;
|
|
951
|
+
readonly label: string;
|
|
952
|
+
}
|
|
953
|
+
interface RecipientResolution {
|
|
954
|
+
readonly kind: RecipientResolutionKind;
|
|
955
|
+
readonly recipient: string;
|
|
956
|
+
readonly label: string;
|
|
957
|
+
readonly safeAddress: string;
|
|
958
|
+
readonly payeeId?: string;
|
|
959
|
+
readonly orgId?: string;
|
|
960
|
+
readonly handle?: string;
|
|
961
|
+
readonly email?: string;
|
|
962
|
+
}
|
|
963
|
+
interface Payee {
|
|
964
|
+
readonly payeeId: string;
|
|
965
|
+
readonly label: string;
|
|
966
|
+
readonly recipientRef: string;
|
|
967
|
+
readonly handle: string | null;
|
|
968
|
+
readonly destinationKind: "email" | "org" | "payeeHandle";
|
|
969
|
+
readonly safeAddress: string;
|
|
970
|
+
readonly createdAt: number;
|
|
971
|
+
readonly updatedAt: number;
|
|
972
|
+
}
|
|
973
|
+
interface MeMethods {
|
|
974
|
+
get(options?: {
|
|
975
|
+
readonly signal?: AbortSignal;
|
|
976
|
+
}): Promise<CapxulResult<MeProfile>>;
|
|
977
|
+
depositInstructions(options?: {
|
|
978
|
+
readonly signal?: AbortSignal;
|
|
979
|
+
}): Promise<CapxulResult<DepositInstructions>>;
|
|
980
|
+
}
|
|
981
|
+
interface HandlesMethods {
|
|
982
|
+
resolve(handle: string, options?: {
|
|
983
|
+
readonly signal?: AbortSignal;
|
|
984
|
+
}): Promise<CapxulResult<RecipientResolution>>;
|
|
985
|
+
}
|
|
986
|
+
interface PayeesMethods {
|
|
987
|
+
create(input: {
|
|
988
|
+
readonly label: string;
|
|
989
|
+
readonly recipient: string;
|
|
990
|
+
readonly handle?: string;
|
|
991
|
+
}, options?: {
|
|
992
|
+
readonly signal?: AbortSignal;
|
|
993
|
+
}): Promise<CapxulResult<Payee>>;
|
|
994
|
+
get(payeeId: string, options?: {
|
|
995
|
+
readonly signal?: AbortSignal;
|
|
996
|
+
}): Promise<CapxulResult<Payee | null>>;
|
|
997
|
+
resolve(recipient: string, options?: {
|
|
998
|
+
readonly signal?: AbortSignal;
|
|
999
|
+
}): Promise<CapxulResult<RecipientResolution>>;
|
|
1000
|
+
}
|
|
1001
|
+
interface PaymentMoney {
|
|
1002
|
+
readonly currency: string;
|
|
1003
|
+
readonly value: string;
|
|
1004
|
+
readonly decimals: number;
|
|
1005
|
+
}
|
|
1006
|
+
type PaymentStatus = "pending" | "submitted" | "pending_claim" | "scheduled" | "streaming" | "settled" | "cancelled" | "redirected" | "expired" | "failed";
|
|
1007
|
+
type PaymentType = "unspecified" | "invoice" | "payroll" | "reimbursement";
|
|
1008
|
+
interface PaymentDocumentRef {
|
|
1009
|
+
readonly documentHash: string;
|
|
1010
|
+
readonly kind: "memo" | "invoice" | "payslip" | "receipt" | "withdrawal";
|
|
1011
|
+
readonly title?: string;
|
|
1012
|
+
readonly uri?: string;
|
|
1013
|
+
readonly issuedAt?: number;
|
|
1014
|
+
}
|
|
1015
|
+
type PaymentRelease = {
|
|
1016
|
+
readonly kind: "instant";
|
|
1017
|
+
} | {
|
|
1018
|
+
readonly kind: "scheduled";
|
|
1019
|
+
readonly at: number;
|
|
1020
|
+
} | {
|
|
1021
|
+
readonly kind: "stream";
|
|
1022
|
+
readonly startsAt: number;
|
|
1023
|
+
readonly endsAt: number;
|
|
1024
|
+
readonly cliffAt?: number;
|
|
1025
|
+
};
|
|
1026
|
+
interface Payment {
|
|
1027
|
+
readonly id: string;
|
|
1028
|
+
readonly status: PaymentStatus;
|
|
1029
|
+
readonly amount: PaymentMoney;
|
|
1030
|
+
readonly paymentType: PaymentType;
|
|
1031
|
+
readonly recipient: {
|
|
1032
|
+
readonly kind: "handle" | "email" | "payee" | "me" | "org" | "external_address";
|
|
1033
|
+
readonly label: string;
|
|
1034
|
+
readonly payeeId?: string;
|
|
1035
|
+
};
|
|
1036
|
+
readonly documents: readonly PaymentDocumentRef[];
|
|
1037
|
+
readonly release: PaymentRelease;
|
|
1038
|
+
readonly released: PaymentMoney;
|
|
1039
|
+
readonly availableToClaim: PaymentMoney;
|
|
1040
|
+
readonly createdAt: number;
|
|
1041
|
+
readonly updatedAt: number;
|
|
1042
|
+
}
|
|
1043
|
+
interface PaymentsPayInput {
|
|
1044
|
+
readonly to: string;
|
|
1045
|
+
readonly amount: PaymentMoney;
|
|
1046
|
+
/** Full EIP-712 document envelope; hashed + stored, committed on-chain. */
|
|
1047
|
+
readonly document?: PaymentDocumentEnvelopeV1;
|
|
1048
|
+
/**
|
|
1049
|
+
* Release clause (G3 · #546). Omitted ⇒ `instant` (the G2 direct-send path).
|
|
1050
|
+
* A `scheduled`/`stream` clause turns the payment into a Commitment
|
|
1051
|
+
* (escrow-vest-claim) backed by `CapxulPayments.createCommitment`.
|
|
1052
|
+
*/
|
|
1053
|
+
readonly release?: PaymentRelease;
|
|
1054
|
+
/**
|
|
1055
|
+
* #592: itemized line items backing an Invoice `document`. The backend asserts
|
|
1056
|
+
* `hashLineItems(lineItems) === document.lineItemsHash` AND `Σ(quantity ×
|
|
1057
|
+
* unitMinor) === document.amount`, then persists the list for itemized render.
|
|
1058
|
+
*/
|
|
1059
|
+
readonly lineItems?: readonly LineItemV1[];
|
|
1060
|
+
}
|
|
1061
|
+
/**
|
|
1062
|
+
* B3 withdraw / cash-out input. Stripe-shaped: `to` is the EXTERNAL 0x wallet
|
|
1063
|
+
* (the ONE place the SDK accepts a raw address — the pay lane never does),
|
|
1064
|
+
* `amount` is a Money, `document` is the REQUIRED kind:4 Withdrawal envelope
|
|
1065
|
+
* (carries the audit-visible destAddress). No chain / Safe / token / hash
|
|
1066
|
+
* custody substrate on the input. Returns a leak-safe `Payment` whose recipient
|
|
1067
|
+
* label is the redacted address — never the full 0x.
|
|
1068
|
+
*/
|
|
1069
|
+
interface PaymentsWithdrawInput {
|
|
1070
|
+
readonly to: string;
|
|
1071
|
+
readonly amount: PaymentMoney;
|
|
1072
|
+
readonly document: PaymentDocumentEnvelopeV1;
|
|
1073
|
+
}
|
|
1074
|
+
interface PaymentSettlementInput {
|
|
1075
|
+
readonly paymentId: string;
|
|
1076
|
+
readonly evidence: OnchainEvidence;
|
|
1077
|
+
}
|
|
1078
|
+
/**
|
|
1079
|
+
* Host-execution callback recording the on-chain escrow of a commitment
|
|
1080
|
+
* (G3 · #546): `createCommitment` returned `onchainCommitmentId`, escrowing
|
|
1081
|
+
* the total. `onchainCommitmentId` + the userOp/tx hashes are internal evidence,
|
|
1082
|
+
* never on the wire (internal channel only).
|
|
1083
|
+
*/
|
|
1084
|
+
interface CommitmentCreatedInput {
|
|
1085
|
+
readonly paymentId: string;
|
|
1086
|
+
readonly onchainCommitmentId: string;
|
|
1087
|
+
readonly evidence: OnchainEvidence;
|
|
1088
|
+
}
|
|
1089
|
+
/** Host-execution callback recording a recipient-side `claim` (G3 · #546). */
|
|
1090
|
+
interface CommitmentClaimInput {
|
|
1091
|
+
readonly paymentId: string;
|
|
1092
|
+
readonly evidence: OnchainEvidence;
|
|
1093
|
+
}
|
|
1094
|
+
/**
|
|
1095
|
+
* Host-execution callback recording a creator-side `cancel` (G3 · #546):
|
|
1096
|
+
* on-chain the unvested remainder returns to the creator; vested-unclaimed
|
|
1097
|
+
* stays the recipient's. An optional credit-note document is appended.
|
|
1098
|
+
*/
|
|
1099
|
+
interface CommitmentCancelInput {
|
|
1100
|
+
readonly paymentId: string;
|
|
1101
|
+
readonly evidence: OnchainEvidence;
|
|
1102
|
+
readonly document?: PaymentDocumentEnvelopeV1;
|
|
1103
|
+
}
|
|
1104
|
+
/**
|
|
1105
|
+
* Host-execution callback recording a pre-claim `redirect` to a new validated
|
|
1106
|
+
* recipient (G3 · #546). `to` is a validated recipient (handle/email/payee id),
|
|
1107
|
+
* never a raw address.
|
|
1108
|
+
*/
|
|
1109
|
+
interface CommitmentRedirectInput {
|
|
1110
|
+
readonly paymentId: string;
|
|
1111
|
+
readonly to: string;
|
|
1112
|
+
readonly evidence: OnchainEvidence;
|
|
1113
|
+
readonly document?: PaymentDocumentEnvelopeV1;
|
|
1114
|
+
}
|
|
1115
|
+
/**
|
|
1116
|
+
* Host-execution callback recording a settled ORG spend/payroll on the ONE
|
|
1117
|
+
* `payments` ledger (D3 · #565). An org spend is a KIND of Payment — it lands a
|
|
1118
|
+
* real `payments` row with `source:"org"` + `orgId` (no parallel `orgSpends`
|
|
1119
|
+
* table, no synthetic client-side fabrication). The signer-side host calls this
|
|
1120
|
+
* AFTER the on-chain Roles-modifier spend settles; `evidence` carries the
|
|
1121
|
+
* internal userOp/tx hashes (never wire fields). `recipient` is the validated
|
|
1122
|
+
* recipient ref label; `recipientSafeAddress` is internal evidence on the row.
|
|
1123
|
+
*/
|
|
1124
|
+
interface OrgPaymentRecordInput {
|
|
1125
|
+
readonly orgId: string;
|
|
1126
|
+
readonly recipientLabel: string;
|
|
1127
|
+
readonly recipientSafeAddress: string;
|
|
1128
|
+
readonly amount: PaymentMoney;
|
|
1129
|
+
readonly paymentType: PaymentType;
|
|
1130
|
+
readonly document?: PaymentDocumentEnvelopeV1;
|
|
1131
|
+
/** The org Safe the spend debited — bound as the `from` of the settlement transfer. */
|
|
1132
|
+
readonly orgSafeAddress: string;
|
|
1133
|
+
/**
|
|
1134
|
+
* 0-based occurrence among batch runs with the same (recipient, amount), so
|
|
1135
|
+
* each run binds to + de-dupes on its own on-chain `Transfer` (D3 · #565).
|
|
1136
|
+
*/
|
|
1137
|
+
readonly occurrenceIndex: number;
|
|
1138
|
+
readonly evidence: OnchainEvidence;
|
|
1139
|
+
}
|
|
1140
|
+
interface PaymentDocumentVerification {
|
|
1141
|
+
readonly documentHash: string;
|
|
1142
|
+
readonly ok: boolean;
|
|
1143
|
+
readonly derivedHash: string;
|
|
1144
|
+
readonly kind: "memo" | "invoice" | "payslip" | "receipt" | "withdrawal";
|
|
1145
|
+
}
|
|
1146
|
+
/**
|
|
1147
|
+
* #577 render-on-demand result. `html` is self-contained user-visible document
|
|
1148
|
+
* HTML (stylesheet + rendered document). The MCP `paymentDocuments.render` tool
|
|
1149
|
+
* exposes only `{documentHash, kind, ok}` to the model and returns `html` in an
|
|
1150
|
+
* audience:["user"] content block (#506 redaction matrix).
|
|
1151
|
+
*/
|
|
1152
|
+
interface PaymentDocumentRender {
|
|
1153
|
+
readonly documentHash: string;
|
|
1154
|
+
readonly ok: boolean;
|
|
1155
|
+
readonly kind: "memo" | "invoice" | "payslip" | "receipt" | "withdrawal";
|
|
1156
|
+
readonly html: string;
|
|
1157
|
+
}
|
|
1158
|
+
/**
|
|
1159
|
+
* Internal commitment execution reference (G3 · #546). The on-chain
|
|
1160
|
+
* `onchainCommitmentId` is internal evidence (like userOp/tx hashes) — it never
|
|
1161
|
+
* appears on the wire `Payment` or any MCP tool output, but the signer-side host
|
|
1162
|
+
* needs it to build a claim/cancel/redirect UserOp. This is the server-internal
|
|
1163
|
+
* channel that carries it (and the recipient Safe address for an auto-claim
|
|
1164
|
+
* relayer), never a consumer-facing surface.
|
|
1165
|
+
*/
|
|
1166
|
+
interface PaymentCommitmentRef {
|
|
1167
|
+
readonly paymentId: string;
|
|
1168
|
+
readonly onchainCommitmentId: string | null;
|
|
1169
|
+
readonly status: PaymentStatus;
|
|
1170
|
+
}
|
|
1171
|
+
/**
|
|
1172
|
+
* The host-execution + on-chain-evidence channel for Payments (D2 · #564).
|
|
1173
|
+
* SPLIT OFF the public `PaymentsMethods` so an external builder consuming
|
|
1174
|
+
* `@capxul/sdk` directly never sees the custody substrate. Reached only via
|
|
1175
|
+
* `client.payments._internal` (mirrors `client._internal.*`); the signer-side
|
|
1176
|
+
* host (the dev MCP edge / a self-custody integrator) drives it AFTER executing
|
|
1177
|
+
* a UserOp. Every input carries the `OnchainEvidence` brand — never a wire field.
|
|
1178
|
+
*/
|
|
1179
|
+
interface PaymentsInternalMethods {
|
|
1180
|
+
/** Report on-chain settlement evidence for an instant payment. */
|
|
1181
|
+
markSettled(input: PaymentSettlementInput, options?: {
|
|
1182
|
+
readonly signal?: AbortSignal;
|
|
1183
|
+
}): Promise<CapxulResult<Payment>>;
|
|
1184
|
+
/**
|
|
1185
|
+
* B3: report on-chain settlement evidence for a withdraw/cash-out. The
|
|
1186
|
+
* backend binds the userOp to a matching external `Transfer` before settling.
|
|
1187
|
+
*/
|
|
1188
|
+
markWithdrawalSettled(input: PaymentSettlementInput, options?: {
|
|
1189
|
+
readonly signal?: AbortSignal;
|
|
1190
|
+
}): Promise<CapxulResult<Payment>>;
|
|
1191
|
+
/**
|
|
1192
|
+
* Record the on-chain escrow of a commitment after `createCommitment` returns
|
|
1193
|
+
* its `onchainCommitmentId` (G3 · #546).
|
|
1194
|
+
*/
|
|
1195
|
+
markCommitmentCreated(input: CommitmentCreatedInput, options?: {
|
|
1196
|
+
readonly signal?: AbortSignal;
|
|
1197
|
+
}): Promise<CapxulResult<Payment>>;
|
|
1198
|
+
/**
|
|
1199
|
+
* Record a settled ORG spend/payroll on the one `payments` ledger
|
|
1200
|
+
* (D3 · #565) — `source:"org"` + `orgId`, read back as a leak-safe Payment.
|
|
1201
|
+
*/
|
|
1202
|
+
recordOrgPayment(input: OrgPaymentRecordInput, options?: {
|
|
1203
|
+
readonly signal?: AbortSignal;
|
|
1204
|
+
}): Promise<CapxulResult<Payment>>;
|
|
1205
|
+
/** Record a recipient-side `claim` after the on-chain claim UserOp settles. */
|
|
1206
|
+
claim(input: CommitmentClaimInput, options?: {
|
|
1207
|
+
readonly signal?: AbortSignal;
|
|
1208
|
+
}): Promise<CapxulResult<Payment>>;
|
|
1209
|
+
/** Record a creator-side `cancel` reclaiming only the unvested remainder. */
|
|
1210
|
+
cancel(input: CommitmentCancelInput, options?: {
|
|
1211
|
+
readonly signal?: AbortSignal;
|
|
1212
|
+
}): Promise<CapxulResult<Payment>>;
|
|
1213
|
+
/** Record a pre-claim `redirect` to a new validated recipient. */
|
|
1214
|
+
redirect(input: CommitmentRedirectInput, options?: {
|
|
1215
|
+
readonly signal?: AbortSignal;
|
|
1216
|
+
}): Promise<CapxulResult<Payment>>;
|
|
1217
|
+
/**
|
|
1218
|
+
* The on-chain commitment reference the signer-side host needs to build a
|
|
1219
|
+
* claim/cancel/redirect UserOp. `onchainCommitmentId` is internal evidence.
|
|
1220
|
+
*/
|
|
1221
|
+
commitmentRef(paymentId: string, options?: {
|
|
1222
|
+
readonly signal?: AbortSignal;
|
|
1223
|
+
}): Promise<CapxulResult<PaymentCommitmentRef | null>>;
|
|
1224
|
+
}
|
|
1225
|
+
/**
|
|
1226
|
+
* The PUBLIC, Stripe-shaped Payments surface (D2 · #564). Genus verbs only —
|
|
1227
|
+
* `pay` / `list` / `get`. No `userOpHash` / `txHash` / `onchainCommitmentId` /
|
|
1228
|
+
* `chainId` / `safeAddress`. Host-execution + on-chain evidence live on the
|
|
1229
|
+
* `_internal` channel below; an external builder never touches custody substrate.
|
|
1230
|
+
*/
|
|
1231
|
+
interface PaymentsMethods {
|
|
1232
|
+
pay(input: PaymentsPayInput, options?: {
|
|
1233
|
+
readonly signal?: AbortSignal;
|
|
1234
|
+
}): Promise<CapxulResult<Payment>>;
|
|
1235
|
+
/**
|
|
1236
|
+
* B3 withdraw / cash-out: send USDX from the user's custody Safe to an
|
|
1237
|
+
* external 0x wallet, minting a kind:4 Withdrawal document. Returns a
|
|
1238
|
+
* leak-safe `Payment` (recipient label is the redacted address).
|
|
1239
|
+
*/
|
|
1240
|
+
withdraw(input: PaymentsWithdrawInput, options?: {
|
|
1241
|
+
readonly signal?: AbortSignal;
|
|
1242
|
+
}): Promise<CapxulResult<Payment>>;
|
|
1243
|
+
list(options?: {
|
|
1244
|
+
readonly signal?: AbortSignal;
|
|
1245
|
+
}): Promise<CapxulResult<readonly Payment[]>>;
|
|
1246
|
+
get(paymentId: string, options?: {
|
|
1247
|
+
readonly signal?: AbortSignal;
|
|
1248
|
+
}): Promise<CapxulResult<Payment | null>>;
|
|
1249
|
+
/**
|
|
1250
|
+
* Host-execution + on-chain-evidence channel — off the public surface
|
|
1251
|
+
* (production-surface-policy.md pattern). Self-custody integrators drive this;
|
|
1252
|
+
* a Stripe-shaped consumer never does.
|
|
1253
|
+
*
|
|
1254
|
+
* @internal-use
|
|
1255
|
+
*/
|
|
1256
|
+
readonly _internal: PaymentsInternalMethods;
|
|
1257
|
+
}
|
|
1258
|
+
interface PaymentDocumentsMethods {
|
|
1259
|
+
verify(documentHash: string, options?: {
|
|
1260
|
+
readonly signal?: AbortSignal;
|
|
1261
|
+
}): Promise<CapxulResult<PaymentDocumentVerification>>;
|
|
1262
|
+
/**
|
|
1263
|
+
* #577: render-on-demand. Loads the owner's stored document by `documentHash`,
|
|
1264
|
+
* re-verifies its EIP-712 hash, and renders it to self-contained HTML using the
|
|
1265
|
+
* verified stored line items. Returns `{documentHash, kind, ok, html}`.
|
|
1266
|
+
*/
|
|
1267
|
+
render(documentHash: string, options?: {
|
|
1268
|
+
readonly signal?: AbortSignal;
|
|
1269
|
+
}): Promise<CapxulResult<PaymentDocumentRender>>;
|
|
1270
|
+
}
|
|
1271
|
+
type PaymentRequestStatus = "draft" | "sent" | "viewed" | "paid" | "expired" | "cancelled";
|
|
1272
|
+
interface PaymentRequest {
|
|
1273
|
+
readonly id: string;
|
|
1274
|
+
readonly status: PaymentRequestStatus;
|
|
1275
|
+
readonly amount: PaymentMoney;
|
|
1276
|
+
readonly reference: string;
|
|
1277
|
+
readonly memo: string | null;
|
|
1278
|
+
/** Fixed-amount payment link token (HITL #519: basic, not replay-hardened). */
|
|
1279
|
+
readonly linkToken: string;
|
|
1280
|
+
/** Minimal entitlement (HITL #501): true once paid. */
|
|
1281
|
+
readonly entitlementGranted: boolean;
|
|
1282
|
+
/** The Payment this receivable settled into (set on collect). */
|
|
1283
|
+
readonly settledPaymentId: string | null;
|
|
1284
|
+
/** The receipt document committed for this receivable (set on collect). */
|
|
1285
|
+
readonly receiptDocumentHash: string | null;
|
|
1286
|
+
readonly expiresAt: number | null;
|
|
1287
|
+
readonly createdAt: number;
|
|
1288
|
+
readonly updatedAt: number;
|
|
1289
|
+
}
|
|
1290
|
+
interface ReconciliationEntry {
|
|
1291
|
+
readonly paymentRequestId: string;
|
|
1292
|
+
readonly reference: string;
|
|
1293
|
+
readonly status: "paid" | "exception";
|
|
1294
|
+
readonly settledPaymentId: string | null;
|
|
1295
|
+
readonly receiptDocumentHash: string | null;
|
|
1296
|
+
}
|
|
1297
|
+
interface PaymentRequestsCreateInput {
|
|
1298
|
+
readonly amount: PaymentMoney;
|
|
1299
|
+
readonly reference: string;
|
|
1300
|
+
readonly memo?: string;
|
|
1301
|
+
/** Optional expiry (epoch ms). HITL #519: expiry policy is a basic timestamp. */
|
|
1302
|
+
readonly expiresAt?: number;
|
|
1303
|
+
}
|
|
1304
|
+
interface PaymentRequestsMethods {
|
|
1305
|
+
/** Open a receivable in `draft` with a fixed-amount payment link. */
|
|
1306
|
+
create(input: PaymentRequestsCreateInput, options?: {
|
|
1307
|
+
readonly signal?: AbortSignal;
|
|
1308
|
+
}): Promise<CapxulResult<PaymentRequest>>;
|
|
1309
|
+
markSent(paymentRequestId: string, options?: {
|
|
1310
|
+
readonly signal?: AbortSignal;
|
|
1311
|
+
}): Promise<CapxulResult<PaymentRequest>>;
|
|
1312
|
+
markViewed(paymentRequestId: string, options?: {
|
|
1313
|
+
readonly signal?: AbortSignal;
|
|
1314
|
+
}): Promise<CapxulResult<PaymentRequest>>;
|
|
1315
|
+
cancel(paymentRequestId: string, options?: {
|
|
1316
|
+
readonly signal?: AbortSignal;
|
|
1317
|
+
}): Promise<CapxulResult<PaymentRequest>>;
|
|
1318
|
+
/**
|
|
1319
|
+
* Collect the receivable (HERMETIC until a live inbound path exists): settle
|
|
1320
|
+
* it into the Payment ledger and mint a receipt linked by `documentHash`.
|
|
1321
|
+
*/
|
|
1322
|
+
collect(paymentRequestId: string, options?: {
|
|
1323
|
+
readonly signal?: AbortSignal;
|
|
1324
|
+
}): Promise<CapxulResult<PaymentRequest>>;
|
|
1325
|
+
list(options?: {
|
|
1326
|
+
readonly signal?: AbortSignal;
|
|
1327
|
+
}): Promise<CapxulResult<readonly PaymentRequest[]>>;
|
|
1328
|
+
get(paymentRequestId: string, options?: {
|
|
1329
|
+
readonly signal?: AbortSignal;
|
|
1330
|
+
}): Promise<CapxulResult<PaymentRequest | null>>;
|
|
1331
|
+
getByLink(linkToken: string, options?: {
|
|
1332
|
+
readonly signal?: AbortSignal;
|
|
1333
|
+
}): Promise<CapxulResult<PaymentRequest | null>>;
|
|
1334
|
+
/** Inbound reconciliation: paid / exception status per receivable. */
|
|
1335
|
+
reconcile(options?: {
|
|
1336
|
+
readonly signal?: AbortSignal;
|
|
1337
|
+
}): Promise<CapxulResult<readonly ReconciliationEntry[]>>;
|
|
1338
|
+
}
|
|
1339
|
+
type PaymentDraftStatus = "draft" | "simulated" | "approval_pending" | "approved" | "executed" | "cancelled" | "expired";
|
|
1340
|
+
/** The leak-safe, model-visible draft/approval (#506). */
|
|
1341
|
+
interface PaymentDraft {
|
|
1342
|
+
readonly id: string;
|
|
1343
|
+
readonly status: PaymentDraftStatus;
|
|
1344
|
+
readonly recipient: {
|
|
1345
|
+
readonly kind: string;
|
|
1346
|
+
readonly label: string;
|
|
1347
|
+
};
|
|
1348
|
+
readonly amount: PaymentMoney;
|
|
1349
|
+
readonly documentHash: string | null;
|
|
1350
|
+
/** The canonical-plan binding fingerprint (set at approvals.request). */
|
|
1351
|
+
readonly planHash: string | null;
|
|
1352
|
+
/** The opaque read-model version the draft was simulated against (stale-state). */
|
|
1353
|
+
readonly readModelVersion: string;
|
|
1354
|
+
readonly idempotencyKey: string;
|
|
1355
|
+
readonly policyDecision: "allow" | "deny";
|
|
1356
|
+
readonly expiresAt: number | null;
|
|
1357
|
+
readonly settledPaymentId: string | null;
|
|
1358
|
+
readonly createdAt: number;
|
|
1359
|
+
readonly updatedAt: number;
|
|
1360
|
+
}
|
|
1361
|
+
interface WorkbenchDraftInput {
|
|
1362
|
+
readonly clientId: string;
|
|
1363
|
+
readonly audience: string;
|
|
1364
|
+
readonly scopes: readonly string[];
|
|
1365
|
+
readonly to: string;
|
|
1366
|
+
readonly amount: PaymentMoney;
|
|
1367
|
+
readonly document?: PaymentDocumentEnvelopeV1;
|
|
1368
|
+
readonly idempotencyKey: string;
|
|
1369
|
+
/** Untrusted connector/model suggestion blob (default-deny taint). */
|
|
1370
|
+
readonly tainted?: Record<string, unknown>;
|
|
1371
|
+
}
|
|
1372
|
+
interface WorkbenchMintResult {
|
|
1373
|
+
readonly approvalToken: string;
|
|
1374
|
+
readonly planHash: string;
|
|
1375
|
+
readonly expiresAt: number;
|
|
1376
|
+
}
|
|
1377
|
+
interface WorkbenchExecuteInput {
|
|
1378
|
+
readonly draftId: string;
|
|
1379
|
+
readonly clientId: string;
|
|
1380
|
+
readonly approvalToken: string;
|
|
1381
|
+
readonly readModelVersion: string;
|
|
1382
|
+
readonly userOpHash: string;
|
|
1383
|
+
readonly txHash: string;
|
|
1384
|
+
}
|
|
1385
|
+
/**
|
|
1386
|
+
* The decomposed workbench (G6 · #549). The edge PROPOSES (draft → simulate →
|
|
1387
|
+
* request); the BACKEND mints the one-time plan-bound token via the human's
|
|
1388
|
+
* browser (`mint`); `execute` consumes it. `mint` is the human step — the edge
|
|
1389
|
+
* normally only reaches `request`, then hands the human a browser URL.
|
|
1390
|
+
*/
|
|
1391
|
+
interface WorkbenchMethods {
|
|
1392
|
+
draft(input: WorkbenchDraftInput, options?: {
|
|
1393
|
+
readonly signal?: AbortSignal;
|
|
1394
|
+
}): Promise<CapxulResult<PaymentDraft>>;
|
|
1395
|
+
simulate(draftId: string, options?: {
|
|
1396
|
+
readonly signal?: AbortSignal;
|
|
1397
|
+
}): Promise<CapxulResult<PaymentDraft>>;
|
|
1398
|
+
requestApproval(draftId: string, options?: {
|
|
1399
|
+
readonly signal?: AbortSignal;
|
|
1400
|
+
}): Promise<CapxulResult<PaymentDraft>>;
|
|
1401
|
+
/**
|
|
1402
|
+
* THE HUMAN STEP: mint the one-time approval token (browser/approval app).
|
|
1403
|
+
* F2 (#549): the backend gates minting on a human-origin `capability` the
|
|
1404
|
+
* agent/edge does NOT possess (`CAPXUL_APPROVAL_CAPABILITY`); only the
|
|
1405
|
+
* apps/approve browser app passes it. The edge/SDK lane cannot self-approve.
|
|
1406
|
+
*/
|
|
1407
|
+
mint(draftId: string, capability: string, options?: {
|
|
1408
|
+
readonly signal?: AbortSignal;
|
|
1409
|
+
}): Promise<CapxulResult<WorkbenchMintResult>>;
|
|
1410
|
+
execute(input: WorkbenchExecuteInput, options?: {
|
|
1411
|
+
readonly signal?: AbortSignal;
|
|
1412
|
+
}): Promise<CapxulResult<Payment>>;
|
|
1413
|
+
status(draftId: string, options?: {
|
|
1414
|
+
readonly signal?: AbortSignal;
|
|
1415
|
+
}): Promise<CapxulResult<PaymentDraft | null>>;
|
|
1416
|
+
cancel(draftId: string, options?: {
|
|
1417
|
+
readonly signal?: AbortSignal;
|
|
1418
|
+
}): Promise<CapxulResult<PaymentDraft>>;
|
|
1419
|
+
}
|
|
1420
|
+
interface FinancialOpsMethods {
|
|
1421
|
+
readonly me: MeMethods;
|
|
1422
|
+
readonly handles: HandlesMethods;
|
|
1423
|
+
readonly payees: PayeesMethods;
|
|
1424
|
+
readonly payments: PaymentsMethods;
|
|
1425
|
+
readonly paymentDocuments: PaymentDocumentsMethods;
|
|
1426
|
+
/** Receivables surface (G5 · #548). */
|
|
1427
|
+
readonly paymentRequests: PaymentRequestsMethods;
|
|
1428
|
+
/** Decomposed workbench + trust substrate (G6 · #549). */
|
|
1429
|
+
readonly workbench: WorkbenchMethods;
|
|
1430
|
+
}
|
|
1431
|
+
//#endregion
|
|
851
1432
|
//#region src/client/sub-accounts.d.ts
|
|
852
1433
|
interface SubAccountsMethods {
|
|
853
1434
|
create(accountId: AccountId, input: {
|
|
854
1435
|
readonly name: string;
|
|
855
1436
|
}, options?: {
|
|
856
1437
|
readonly signal?: AbortSignal;
|
|
857
|
-
}): Promise<CapxulResult<SubAccount
|
|
858
|
-
get(subAccountId: SubAccountId
|
|
1438
|
+
}): Promise<CapxulResult<SubAccount>>;
|
|
1439
|
+
get(subAccountId: SubAccountId, options?: {
|
|
859
1440
|
readonly signal?: AbortSignal;
|
|
860
|
-
}): Promise<CapxulResult<SubAccount
|
|
1441
|
+
}): Promise<CapxulResult<SubAccount | null>>;
|
|
861
1442
|
list(accountId: AccountId, options?: {
|
|
862
1443
|
readonly signal?: AbortSignal;
|
|
863
|
-
}): Promise<CapxulResult<readonly SubAccount
|
|
864
|
-
rename(subAccountId: SubAccountId
|
|
1444
|
+
}): Promise<CapxulResult<readonly SubAccount[]>>;
|
|
1445
|
+
rename(subAccountId: SubAccountId, name: string, options?: {
|
|
865
1446
|
readonly signal?: AbortSignal;
|
|
866
|
-
}): Promise<CapxulResult<SubAccount
|
|
867
|
-
delete(subAccountId: SubAccountId
|
|
1447
|
+
}): Promise<CapxulResult<SubAccount>>;
|
|
1448
|
+
delete(subAccountId: SubAccountId, options?: {
|
|
868
1449
|
readonly signal?: AbortSignal;
|
|
869
1450
|
}): Promise<CapxulResult<void>>;
|
|
870
1451
|
transfer(input: TransferInput, options?: {
|
|
@@ -873,49 +1454,68 @@ interface SubAccountsMethods {
|
|
|
873
1454
|
}
|
|
874
1455
|
//#endregion
|
|
875
1456
|
//#region src/client/org-spend-gate.d.ts
|
|
876
|
-
|
|
1457
|
+
/**
|
|
1458
|
+
* The role's allowed recipients. The address form backs the S4 `spend` path
|
|
1459
|
+
* (recipient is a resolved `Address`); the string form backs the G4
|
|
1460
|
+
* `spendViaPayments` / `batchPayroll` path, whose recipient is a VALIDATED REF
|
|
1461
|
+
* (handle/email/payee/org) compared in the same ref space as the role's set.
|
|
1462
|
+
* Comparison is case-insensitive over the raw string value either way.
|
|
1463
|
+
*/
|
|
1464
|
+
type SpendGateRecipients = "anyone" | readonly (Address | string)[];
|
|
877
1465
|
type SpendGateSubAccountScope = {
|
|
878
1466
|
readonly scope: "all";
|
|
879
1467
|
} | {
|
|
880
1468
|
readonly scope: "only";
|
|
881
|
-
readonly subAccountIds: readonly SubAccountId
|
|
1469
|
+
readonly subAccountIds: readonly SubAccountId[];
|
|
882
1470
|
};
|
|
883
1471
|
//#endregion
|
|
884
1472
|
//#region src/ports/org.d.ts
|
|
1473
|
+
/**
|
|
1474
|
+
* The minimal `{from, to, amount}` spend shape the authority read keys off
|
|
1475
|
+
* (D3 #565). The legacy address-keyed `OrgSpendInput`/`org.spend` lane was
|
|
1476
|
+
* hard-removed when `orgSpends` folded into the one `payments` ledger; the
|
|
1477
|
+
* leak-safe ref-based lane (`spendViaPayments`/`batchPayroll`) constructs this
|
|
1478
|
+
* internally and enforces the real validated recipient on the gate.
|
|
1479
|
+
*/
|
|
1480
|
+
type OrgSpendShape = {
|
|
1481
|
+
readonly from: SubAccountId;
|
|
1482
|
+
readonly to: Address;
|
|
1483
|
+
readonly amount: Money;
|
|
1484
|
+
};
|
|
885
1485
|
type CreateOrgPortInput = {
|
|
886
1486
|
readonly input: CreateOrgInput;
|
|
887
1487
|
};
|
|
888
1488
|
type ReadOrgTreasuryInput = {
|
|
889
|
-
readonly orgId: OrgId
|
|
1489
|
+
readonly orgId: OrgId;
|
|
890
1490
|
};
|
|
891
1491
|
type ListOrgsInput = Record<never, never>;
|
|
892
1492
|
type ListOrgRolesInput = {
|
|
893
|
-
readonly orgId: OrgId
|
|
1493
|
+
readonly orgId: OrgId;
|
|
894
1494
|
};
|
|
895
1495
|
type ListOrgMembersInput = {
|
|
896
|
-
readonly orgId: OrgId
|
|
1496
|
+
readonly orgId: OrgId;
|
|
897
1497
|
};
|
|
898
1498
|
type InviteOrgMemberInput = {
|
|
899
|
-
readonly orgId: OrgId
|
|
1499
|
+
readonly orgId: OrgId;
|
|
900
1500
|
readonly input: InviteMemberInput;
|
|
901
1501
|
};
|
|
902
1502
|
type DetectPendingOrgInvitationsInput = Record<never, never>;
|
|
903
1503
|
type DetectPendingOrgInvitationsResult$1 = {
|
|
904
|
-
readonly matched: readonly OrgId
|
|
1504
|
+
readonly matched: readonly OrgId[];
|
|
905
1505
|
};
|
|
906
1506
|
type DeployOrgRolesInput = {
|
|
907
|
-
readonly orgId: OrgId
|
|
1507
|
+
readonly orgId: OrgId;
|
|
908
1508
|
};
|
|
909
1509
|
type OrgRolesDeploymentResult = {
|
|
910
|
-
readonly orgId: OrgId
|
|
1510
|
+
readonly orgId: OrgId;
|
|
911
1511
|
readonly roles: readonly RoleView[];
|
|
912
1512
|
};
|
|
913
1513
|
type GrantOrgRoleInput = {
|
|
914
|
-
readonly orgId: OrgId
|
|
1514
|
+
readonly orgId: OrgId;
|
|
915
1515
|
readonly input: AssignRoleInput;
|
|
916
1516
|
};
|
|
917
1517
|
type RevokeOrgRoleInput = {
|
|
918
|
-
readonly orgId: OrgId
|
|
1518
|
+
readonly orgId: OrgId;
|
|
919
1519
|
readonly input: RemoveMemberInput;
|
|
920
1520
|
};
|
|
921
1521
|
type OrgSpendAuthority = {
|
|
@@ -929,16 +1529,10 @@ type OrgSpendAuthority = {
|
|
|
929
1529
|
readonly role?: string;
|
|
930
1530
|
};
|
|
931
1531
|
type ReadOrgSpendAuthorityInput = {
|
|
932
|
-
readonly orgId: OrgId
|
|
933
|
-
readonly input:
|
|
1532
|
+
readonly orgId: OrgId;
|
|
1533
|
+
readonly input: OrgSpendShape;
|
|
934
1534
|
readonly amountRaw: string;
|
|
935
1535
|
};
|
|
936
|
-
type SubmitOrgSpendInput = {
|
|
937
|
-
readonly orgId: OrgId$1;
|
|
938
|
-
readonly input: OrgSpendInput;
|
|
939
|
-
readonly amountRaw: string;
|
|
940
|
-
readonly authority: OrgSpendAuthority;
|
|
941
|
-
};
|
|
942
1536
|
declare const OrgError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
|
|
943
1537
|
readonly _tag: "OrgError";
|
|
944
1538
|
} & Readonly<A>;
|
|
@@ -957,7 +1551,7 @@ declare class OrgError extends OrgError_base<{
|
|
|
957
1551
|
*/
|
|
958
1552
|
interface OrgPort {
|
|
959
1553
|
createOrg(input: CreateOrgPortInput): Effect.Effect<OrgView, OrgError, never>;
|
|
960
|
-
readTreasury(input: ReadOrgTreasuryInput): Effect.Effect<Account
|
|
1554
|
+
readTreasury(input: ReadOrgTreasuryInput): Effect.Effect<Account, OrgError, never>;
|
|
961
1555
|
listOrgs(input: ListOrgsInput): Effect.Effect<readonly OrgView[], OrgError, never>;
|
|
962
1556
|
listRoles(input: ListOrgRolesInput): Effect.Effect<readonly RoleView[], OrgError, never>;
|
|
963
1557
|
listMembers(input: ListOrgMembersInput): Effect.Effect<readonly MemberView[], OrgError, never>;
|
|
@@ -969,9 +1563,34 @@ interface OrgRolesDeploymentPort {
|
|
|
969
1563
|
grantRole(input: GrantOrgRoleInput): Effect.Effect<MemberView, OrgError, never>;
|
|
970
1564
|
revokeRole(input: RevokeOrgRoleInput): Effect.Effect<void, OrgError, never>;
|
|
971
1565
|
}
|
|
1566
|
+
type SubmitOrgSpendViaPaymentsInput = {
|
|
1567
|
+
readonly orgId: OrgId;
|
|
1568
|
+
readonly input: OrgSpendViaPaymentsInput;
|
|
1569
|
+
readonly amountRaw: string;
|
|
1570
|
+
readonly authority: OrgSpendAuthority;
|
|
1571
|
+
};
|
|
1572
|
+
type SubmitOrgBatchPayrollInput = {
|
|
1573
|
+
readonly orgId: OrgId;
|
|
1574
|
+
readonly from: OrgSpendViaPaymentsInput["from"];
|
|
1575
|
+
readonly runs: readonly {
|
|
1576
|
+
readonly run: OrgPayrollRun;
|
|
1577
|
+
readonly amountRaw: string;
|
|
1578
|
+
}[];
|
|
1579
|
+
readonly authorities: readonly OrgSpendAuthority[];
|
|
1580
|
+
};
|
|
972
1581
|
interface OrgSpendPort {
|
|
973
1582
|
readSpendAuthority(input: ReadOrgSpendAuthorityInput): Effect.Effect<OrgSpendAuthority, OrgError, never>;
|
|
974
|
-
|
|
1583
|
+
/**
|
|
1584
|
+
* Leak-safe org spend (G4 · #547; D3 #565 — the one ledger of record): execute
|
|
1585
|
+
* the spend through the payments engine (Roles modifier → CapxulPayments),
|
|
1586
|
+
* write a real `payments` row (`source:"org"`) and read it back as a `Payment`
|
|
1587
|
+
* — the wire carries no `txHash` / Safe / userOp internals. Optional so a
|
|
1588
|
+
* hermetic adapter without a payments-submit lane still compiles; absent ⇒ the
|
|
1589
|
+
* program falls back to a deterministic hermetic `Payment`.
|
|
1590
|
+
*/
|
|
1591
|
+
submitSpendViaPayments?(input: SubmitOrgSpendViaPaymentsInput): Effect.Effect<Payment, OrgError, never>;
|
|
1592
|
+
/** Leak-safe org payroll batch (G4 · #547): one MultiSend, one Payment per run. */
|
|
1593
|
+
submitBatchPayroll?(input: SubmitOrgBatchPayrollInput): Effect.Effect<readonly Payment[], OrgError, never>;
|
|
975
1594
|
}
|
|
976
1595
|
//#endregion
|
|
977
1596
|
//#region src/client/org.d.ts
|
|
@@ -991,12 +1610,12 @@ type MemberStatus = "pending" | "pending_safe" | "pending_grant" | "active" | "r
|
|
|
991
1610
|
* brand.
|
|
992
1611
|
*/
|
|
993
1612
|
type OrgView = {
|
|
994
|
-
readonly id: OrgId
|
|
1613
|
+
readonly id: OrgId;
|
|
995
1614
|
readonly name: string;
|
|
996
1615
|
readonly handle: string;
|
|
997
|
-
readonly safeAddress: Address
|
|
1616
|
+
readonly safeAddress: Address; /** The viewing member's own role label within this org. */
|
|
998
1617
|
readonly role: string; /** The Org treasury — the real M2 Account over the Org Safe (D3). */
|
|
999
|
-
readonly treasury: Account
|
|
1618
|
+
readonly treasury: Account;
|
|
1000
1619
|
};
|
|
1001
1620
|
/**
|
|
1002
1621
|
* One member of an Org (canon §C1 "Members" — name/email, role, status; D7/D8).
|
|
@@ -1005,12 +1624,12 @@ type OrgView = {
|
|
|
1005
1624
|
* yet provisioned a personal Safe). `email` is the universal entry point (D8).
|
|
1006
1625
|
*/
|
|
1007
1626
|
type MemberView = {
|
|
1008
|
-
readonly orgId: OrgId
|
|
1627
|
+
readonly orgId: OrgId;
|
|
1009
1628
|
readonly email: Email;
|
|
1010
1629
|
readonly name: string | null; /** Member-identity key (D7). `null` until the invitee provisions a Safe. */
|
|
1011
|
-
readonly personalSafeAddress: Address
|
|
1630
|
+
readonly personalSafeAddress: Address | null; /** The member's role label (maps deterministically to the on-chain `roleKey`, D9). */
|
|
1012
1631
|
readonly role: string;
|
|
1013
|
-
readonly roleKey: RoleKey
|
|
1632
|
+
readonly roleKey: RoleKey | null;
|
|
1014
1633
|
readonly status: MemberStatus;
|
|
1015
1634
|
readonly grantTxHash: string | null;
|
|
1016
1635
|
readonly revokeTxHash: string | null;
|
|
@@ -1022,9 +1641,9 @@ type MemberView = {
|
|
|
1022
1641
|
* (the Owner role).
|
|
1023
1642
|
*/
|
|
1024
1643
|
type RoleSpendCap = {
|
|
1025
|
-
readonly perTx?: Money
|
|
1026
|
-
readonly perDay?: Money
|
|
1027
|
-
readonly toRecipients?: "anyone" | readonly Address
|
|
1644
|
+
readonly perTx?: Money;
|
|
1645
|
+
readonly perDay?: Money;
|
|
1646
|
+
readonly toRecipients?: "anyone" | readonly Address[];
|
|
1028
1647
|
};
|
|
1029
1648
|
/**
|
|
1030
1649
|
* The Capxul-owned Role DSL definition (D4). `label` becomes the sticky
|
|
@@ -1036,7 +1655,7 @@ type RoleDefinition = {
|
|
|
1036
1655
|
readonly label: string;
|
|
1037
1656
|
readonly spend?: RoleSpendCap;
|
|
1038
1657
|
readonly subAccounts?: {
|
|
1039
|
-
readonly scope: "all" | readonly SubAccountId
|
|
1658
|
+
readonly scope: "all" | readonly SubAccountId[];
|
|
1040
1659
|
};
|
|
1041
1660
|
readonly canManageMembers?: boolean;
|
|
1042
1661
|
readonly canManageRoles?: boolean;
|
|
@@ -1047,9 +1666,9 @@ type RoleDefinition = {
|
|
|
1047
1666
|
* is the full Role DSL entry.
|
|
1048
1667
|
*/
|
|
1049
1668
|
type RoleView = {
|
|
1050
|
-
readonly orgId: OrgId
|
|
1669
|
+
readonly orgId: OrgId;
|
|
1051
1670
|
readonly label: string;
|
|
1052
|
-
readonly roleKey: RoleKey
|
|
1671
|
+
readonly roleKey: RoleKey;
|
|
1053
1672
|
readonly definition: RoleDefinition;
|
|
1054
1673
|
};
|
|
1055
1674
|
/** Built-in role templates that seed a new Org at creation (D6). */
|
|
@@ -1084,7 +1703,7 @@ type InviteMemberInput = {
|
|
|
1084
1703
|
* mirror.
|
|
1085
1704
|
*/
|
|
1086
1705
|
type RemoveMemberInput = {
|
|
1087
|
-
readonly memberSafeAddress: Address
|
|
1706
|
+
readonly memberSafeAddress: Address;
|
|
1088
1707
|
};
|
|
1089
1708
|
/**
|
|
1090
1709
|
* Input to `org(orgId).assignRole` (S3, D7/D9). Keyed on the member's personal
|
|
@@ -1092,26 +1711,48 @@ type RemoveMemberInput = {
|
|
|
1092
1711
|
* label maps deterministically to the on-chain `roleKey`.
|
|
1093
1712
|
*/
|
|
1094
1713
|
type AssignRoleInput = {
|
|
1095
|
-
readonly memberSafeAddress: Address
|
|
1714
|
+
readonly memberSafeAddress: Address;
|
|
1096
1715
|
readonly role: string;
|
|
1097
1716
|
};
|
|
1098
1717
|
/**
|
|
1099
|
-
* Input to `org(orgId).
|
|
1100
|
-
*
|
|
1101
|
-
*
|
|
1102
|
-
*
|
|
1718
|
+
* Input to `org(orgId).spendViaPayments` (G4 · #547). The LEAK-SAFE org spend:
|
|
1719
|
+
* delegates `org.spend` to the payments engine WITH the member's org role
|
|
1720
|
+
* authority and returns a `Payment`, not a `txHash`. `to` is a VALIDATED
|
|
1721
|
+
* recipient ref (handle / email / payee id / org handle) — never a raw
|
|
1722
|
+
* `Address` (the legacy address-keyed `org.spend` lane was hard-removed in D3
|
|
1723
|
+
* #565 when `orgSpends` was folded into the one `payments` ledger).
|
|
1724
|
+
* `from` is the Level-2 sub-account envelope the spend draws from (D5).
|
|
1103
1725
|
*/
|
|
1104
|
-
type
|
|
1105
|
-
/**
|
|
1106
|
-
readonly to:
|
|
1107
|
-
readonly amount: Money
|
|
1726
|
+
type OrgSpendViaPaymentsInput = {
|
|
1727
|
+
readonly from: SubAccountId; /** Validated recipient ref (handle/email/payee/org) — never a raw address. */
|
|
1728
|
+
readonly to: string;
|
|
1729
|
+
readonly amount: Money; /** Full EIP-712 payment document; hashed + stored, committed on-chain. */
|
|
1730
|
+
readonly document?: PaymentDocumentEnvelopeV1;
|
|
1731
|
+
readonly paymentType?: PaymentType;
|
|
1108
1732
|
};
|
|
1109
|
-
/**
|
|
1110
|
-
|
|
1111
|
-
|
|
1733
|
+
/**
|
|
1734
|
+
* One run in an `org(orgId).batchPayroll` batch (G4 · #547): a validated
|
|
1735
|
+
* recipient, an amount, and an optional payslip document. Each run is gated
|
|
1736
|
+
* independently against the role's per-tx / per-day / recipient conditions.
|
|
1737
|
+
*/
|
|
1738
|
+
type OrgPayrollRun = {
|
|
1739
|
+
/** Validated recipient ref (handle/email/payee/org) — never a raw address. */readonly to: string;
|
|
1740
|
+
readonly amount: Money; /** The payslip — an EIP-712 payment document, committed by `documentHash`. */
|
|
1741
|
+
readonly payslip?: PaymentDocumentEnvelopeV1;
|
|
1742
|
+
};
|
|
1743
|
+
/**
|
|
1744
|
+
* Input to `org(orgId).batchPayroll` (G4 · #547). Pays N employees in one
|
|
1745
|
+
* MultiSend through the Roles modifier; each carries a payslip and settles as
|
|
1746
|
+
* `paymentType = payroll`. Every run is gated; an over-cap run REJECTS the
|
|
1747
|
+
* whole batch (no partial treasury drain). Returns one leak-safe `Payment` per
|
|
1748
|
+
* run.
|
|
1749
|
+
*/
|
|
1750
|
+
type OrgBatchPayrollInput = {
|
|
1751
|
+
readonly from: SubAccountId;
|
|
1752
|
+
readonly runs: readonly OrgPayrollRun[];
|
|
1112
1753
|
};
|
|
1113
1754
|
type DetectPendingOrgInvitationsResult = {
|
|
1114
|
-
readonly matched: readonly OrgId
|
|
1755
|
+
readonly matched: readonly OrgId[];
|
|
1115
1756
|
};
|
|
1116
1757
|
/**
|
|
1117
1758
|
* Entity-scoped Org method bundle, returned by `capxul.org(orgId)`. Every
|
|
@@ -1123,7 +1764,7 @@ interface OrgScopedMethods {
|
|
|
1123
1764
|
/** The Org treasury — the real M2 Account over the Org Safe (D3). */
|
|
1124
1765
|
treasury(options?: {
|
|
1125
1766
|
readonly signal?: AbortSignal;
|
|
1126
|
-
}): Promise<CapxulResult<Account
|
|
1767
|
+
}): Promise<CapxulResult<Account>>;
|
|
1127
1768
|
members(options?: {
|
|
1128
1769
|
readonly signal?: AbortSignal;
|
|
1129
1770
|
}): Promise<CapxulResult<readonly MemberView[]>>;
|
|
@@ -1142,9 +1783,23 @@ interface OrgScopedMethods {
|
|
|
1142
1783
|
assignRole(input: AssignRoleInput, options?: {
|
|
1143
1784
|
readonly signal?: AbortSignal;
|
|
1144
1785
|
}): Promise<CapxulResult<MemberView>>;
|
|
1145
|
-
|
|
1786
|
+
/**
|
|
1787
|
+
* Leak-safe org spend (G4 · #547; D3 #565 — the one ledger of record): execute
|
|
1788
|
+
* the spend through the payments engine with the member's org role authority
|
|
1789
|
+
* and return a `Payment` (no `to: Address`, no `txHash`, no Safe / userOp
|
|
1790
|
+
* internals). Writes a real `payments` row (`source:"org"`).
|
|
1791
|
+
*/
|
|
1792
|
+
spendViaPayments(input: OrgSpendViaPaymentsInput, options?: {
|
|
1793
|
+
readonly signal?: AbortSignal;
|
|
1794
|
+
}): Promise<CapxulResult<Payment>>;
|
|
1795
|
+
/**
|
|
1796
|
+
* Org payroll batch (G4 · #547): pay N employees in one MultiSend through the
|
|
1797
|
+
* Roles modifier, each with a payslip. Every run is gated; an over-cap run
|
|
1798
|
+
* rejects the whole batch. Returns one leak-safe `Payment` per run.
|
|
1799
|
+
*/
|
|
1800
|
+
batchPayroll(input: OrgBatchPayrollInput, options?: {
|
|
1146
1801
|
readonly signal?: AbortSignal;
|
|
1147
|
-
}): Promise<CapxulResult<
|
|
1802
|
+
}): Promise<CapxulResult<readonly Payment[]>>;
|
|
1148
1803
|
}
|
|
1149
1804
|
type OrgsMethod = {
|
|
1150
1805
|
(options?: {
|
|
@@ -1164,7 +1819,52 @@ interface OrgMethods {
|
|
|
1164
1819
|
}): Promise<CapxulResult<OrgView>>;
|
|
1165
1820
|
readonly orgs: OrgsMethod;
|
|
1166
1821
|
/** Resolve the entity-scoped bundle for a specific Org (D13). */
|
|
1167
|
-
org(orgId: OrgId
|
|
1822
|
+
org(orgId: OrgId): OrgScopedMethods;
|
|
1823
|
+
}
|
|
1824
|
+
//#endregion
|
|
1825
|
+
//#region src/client/onboarding.d.ts
|
|
1826
|
+
/**
|
|
1827
|
+
* Input to `capxul.onboarding.completePersonal`. `displayName` + `country`
|
|
1828
|
+
* (ISO-3166, persisted to `identities.country`) are required; `withdrawalAddress`
|
|
1829
|
+
* is the OPTIONAL cash-out destination — a `0x`-prefixed 20-byte address string
|
|
1830
|
+
* (the one allowed raw-0x class), validated + normalized at the boundary.
|
|
1831
|
+
*/
|
|
1832
|
+
type CompletePersonalOnboardingInput = {
|
|
1833
|
+
readonly displayName: string;
|
|
1834
|
+
readonly country: string;
|
|
1835
|
+
readonly withdrawalAddress?: string;
|
|
1836
|
+
};
|
|
1837
|
+
/**
|
|
1838
|
+
* Input to `capxul.onboarding.completeOrganization`. `handle` is the org slug
|
|
1839
|
+
* (`createOrg` requires it); `ownerDisplayName` is the founder's personal
|
|
1840
|
+
* identity profile.
|
|
1841
|
+
*/
|
|
1842
|
+
type CompleteOrganizationOnboardingInput = {
|
|
1843
|
+
readonly organizationName: string;
|
|
1844
|
+
readonly handle: string;
|
|
1845
|
+
readonly country: string;
|
|
1846
|
+
readonly ownerDisplayName: string;
|
|
1847
|
+
};
|
|
1848
|
+
/** Result of `completePersonal` — the post-onboarding readiness snapshot. */
|
|
1849
|
+
type CompletePersonalOnboardingResult = {
|
|
1850
|
+
readonly lifecycle: AccountLifecycle;
|
|
1851
|
+
};
|
|
1852
|
+
/** Result of `completeOrganization` — the created org + readiness snapshot. */
|
|
1853
|
+
type CompleteOrganizationOnboardingResult = {
|
|
1854
|
+
readonly org: OrgView;
|
|
1855
|
+
readonly lifecycle: AccountLifecycle;
|
|
1856
|
+
};
|
|
1857
|
+
/**
|
|
1858
|
+
* Onboarding method bundle, exposed at `client.onboarding`. Exactly two verbs;
|
|
1859
|
+
* the choreography lives in `flows/onboarding.ts`.
|
|
1860
|
+
*/
|
|
1861
|
+
interface OnboardingMethods {
|
|
1862
|
+
completePersonal(input: CompletePersonalOnboardingInput, options?: {
|
|
1863
|
+
readonly signal?: AbortSignal;
|
|
1864
|
+
}): Promise<CapxulResult<CompletePersonalOnboardingResult>>;
|
|
1865
|
+
completeOrganization(input: CompleteOrganizationOnboardingInput, options?: {
|
|
1866
|
+
readonly signal?: AbortSignal;
|
|
1867
|
+
}): Promise<CapxulResult<CompleteOrganizationOnboardingResult>>;
|
|
1168
1868
|
}
|
|
1169
1869
|
//#endregion
|
|
1170
1870
|
//#region src/client/create-capxul-client.d.ts
|
|
@@ -1178,13 +1878,37 @@ interface CapxulClient {
|
|
|
1178
1878
|
* namespace with `provision` + `deploySafe` lands in sibling #161.
|
|
1179
1879
|
*/
|
|
1180
1880
|
readonly account: AccountMethods;
|
|
1181
|
-
/** Email address binding resolution (#338). */
|
|
1182
|
-
readonly binding: BindingMethods;
|
|
1183
1881
|
/**
|
|
1184
1882
|
* Consumer-facing logical Account money read (M2 Slice S1a · #265).
|
|
1185
1883
|
* Returns `{ balance, available }` as `Money` — never wei or token units.
|
|
1186
1884
|
*/
|
|
1187
1885
|
readonly accounts: AccountsMethods;
|
|
1886
|
+
readonly me: MeMethods;
|
|
1887
|
+
readonly handles: HandlesMethods;
|
|
1888
|
+
readonly payees: PayeesMethods;
|
|
1889
|
+
/**
|
|
1890
|
+
* Direct Payments surface (G2 · #545). `pay` records a validated-recipient
|
|
1891
|
+
* payment; `list`/`get` read the ledger; `markSettled` is the host-execution
|
|
1892
|
+
* callback. The MCP `draft → simulate → approve → execute` workbench is G6.
|
|
1893
|
+
*/
|
|
1894
|
+
readonly payments: PaymentsMethods;
|
|
1895
|
+
/** Payment document verification (G2 · #545): re-derive the EIP-712 hash. */
|
|
1896
|
+
readonly paymentDocuments: PaymentDocumentsMethods;
|
|
1897
|
+
/**
|
|
1898
|
+
* Receivables surface (G5 · #548). `create` opens a `PaymentRequest` with a
|
|
1899
|
+
* fixed-amount link; `markSent`/`markViewed`/`cancel` move the funnel;
|
|
1900
|
+
* `collect` settles the receivable into the Payment ledger + mints a receipt
|
|
1901
|
+
* linked by `documentHash`; `list`/`get`/`getByLink`/`reconcile` read it.
|
|
1902
|
+
*/
|
|
1903
|
+
readonly paymentRequests: PaymentRequestsMethods;
|
|
1904
|
+
/**
|
|
1905
|
+
* Decomposed workbench + trust substrate (G6 · #549). The MCP
|
|
1906
|
+
* `draft → simulate → approvals.request → execute` workbench: the edge
|
|
1907
|
+
* PROPOSES, the BACKEND mints a one-time plan-bound approval token via the
|
|
1908
|
+
* human's browser (#510), and `execute` consumes it. Taint / idempotency /
|
|
1909
|
+
* stale-state / scope guards are enforced backend-side.
|
|
1910
|
+
*/
|
|
1911
|
+
readonly workbench: WorkbenchMethods;
|
|
1188
1912
|
/** Sub-account lifecycle (M2 Slice S2a · #267). Transfer lands in S2b. */
|
|
1189
1913
|
readonly subAccounts: SubAccountsMethods;
|
|
1190
1914
|
/**
|
|
@@ -1197,8 +1921,14 @@ interface CapxulClient {
|
|
|
1197
1921
|
readonly createOrg: OrgMethods["createOrg"];
|
|
1198
1922
|
readonly orgs: OrgMethods["orgs"];
|
|
1199
1923
|
readonly org: OrgMethods["org"];
|
|
1200
|
-
/**
|
|
1201
|
-
|
|
1924
|
+
/**
|
|
1925
|
+
* Onboarding domain surface (D-ONBOARD · #669). `completePersonal` /
|
|
1926
|
+
* `completeOrganization` bridge the post-OTP auth → provision bookends:
|
|
1927
|
+
* persist the first identity profile (+ org), then trigger the existing
|
|
1928
|
+
* provisioning lane. Pre-scope — the on-ramp before the D-RELATE actor
|
|
1929
|
+
* scopes. `lifecycle.status` is the single routing source of truth.
|
|
1930
|
+
*/
|
|
1931
|
+
readonly onboarding: OnboardingMethods;
|
|
1202
1932
|
/**
|
|
1203
1933
|
* Internal observation namespace. Consumers MUST NOT drive the actor
|
|
1204
1934
|
* directly — use the method bundles instead.
|
|
@@ -1207,17 +1937,23 @@ interface CapxulClient {
|
|
|
1207
1937
|
*/
|
|
1208
1938
|
readonly _internal: {
|
|
1209
1939
|
readonly authActor: AuthFlowObserver;
|
|
1940
|
+
/**
|
|
1941
|
+
* Resolved bootstrap for this client instance (chain, auth URLs, etc.).
|
|
1942
|
+
* Off the public surface per production-surface-policy.md (#31).
|
|
1943
|
+
*/
|
|
1944
|
+
readonly bootstrap: BootstrapResolution;
|
|
1210
1945
|
/**
|
|
1211
1946
|
* Dev-only faucet bundle (production-surface-policy.md). `fund` lives here,
|
|
1212
1947
|
* NOT on the public `client.accounts` surface.
|
|
1213
1948
|
*/
|
|
1214
|
-
readonly accounts: AccountsFaucetMethods;
|
|
1949
|
+
readonly accounts: AccountsFaucetMethods; /** Telemetry port for error reporting. Used by React hooks to report errors before throwing. */
|
|
1950
|
+
readonly telemetry?: TelemetryPort;
|
|
1215
1951
|
readonly close?: () => Promise<void>;
|
|
1216
1952
|
};
|
|
1217
1953
|
}
|
|
1218
1954
|
interface CreateCapxulClientInput {
|
|
1219
1955
|
/**
|
|
1220
|
-
* The
|
|
1956
|
+
* The 13-port `FlowPorts` bundle. The factory narrows this to the
|
|
1221
1957
|
* 3-port AuthFlow subset (`authClient`, `clock`, `telemetry`) for
|
|
1222
1958
|
* the flow internally, and uses additional ports (`identity`,
|
|
1223
1959
|
* `smartAccount`) for the method bundles.
|
|
@@ -1281,7 +2017,31 @@ interface CreateCapxulClientInput {
|
|
|
1281
2017
|
readonly orgSpendPort?: OrgSpendPort;
|
|
1282
2018
|
readonly orgDeploymentConfig?: SafeDeploymentConfig;
|
|
1283
2019
|
}
|
|
1284
|
-
|
|
2020
|
+
//#endregion
|
|
2021
|
+
//#region src/adapters/auth-cache/BrowserAuthCacheAdapter.d.ts
|
|
2022
|
+
interface BrowserStorageShape {
|
|
2023
|
+
getItem(key: string): string | null;
|
|
2024
|
+
setItem(key: string, value: string): void;
|
|
2025
|
+
removeItem(key: string): void;
|
|
2026
|
+
}
|
|
2027
|
+
//#endregion
|
|
2028
|
+
//#region src/dev-signer.d.ts
|
|
2029
|
+
interface DevPrivateKeySignerInput {
|
|
2030
|
+
/** Dev-only derivation seed (e.g. `VITE_CAPXUL_DEV_SIGNER_SEED`). Throwaway keys only. */
|
|
2031
|
+
readonly seed: string;
|
|
2032
|
+
/** Explicit email — skips the auth-cache lookup (tests, node harnesses). */
|
|
2033
|
+
readonly email?: string;
|
|
2034
|
+
/** Storage holding the cached session. Defaults to browser `localStorage`. */
|
|
2035
|
+
readonly storage?: BrowserStorageShape;
|
|
2036
|
+
}
|
|
2037
|
+
/** Deterministic dev private key for an email under a seed. Exported for probes. */
|
|
2038
|
+
declare function deriveDevPrivateKey(seed: string, email: string): Hex;
|
|
2039
|
+
/**
|
|
2040
|
+
* Browser-safe dev signer. Lazy: the email (and so the key) is resolved at
|
|
2041
|
+
* each `getAddress()` / `signUserOpHash()` from the cached session, so the
|
|
2042
|
+
* same signer instance follows whichever user is signed in.
|
|
2043
|
+
*/
|
|
2044
|
+
declare function devPrivateKeySigner(input: DevPrivateKeySignerInput): CapxulSigner;
|
|
1285
2045
|
//#endregion
|
|
1286
2046
|
//#region src/adapters/openfort/embedded-wallet-port.d.ts
|
|
1287
2047
|
/**
|
|
@@ -1320,13 +2080,25 @@ interface OpenfortEmbeddedSignerInput {
|
|
|
1320
2080
|
declare function openfortEmbeddedSignerFromWallet(input: {
|
|
1321
2081
|
readonly embeddedWallet: OpenfortEmbeddedWalletApi;
|
|
1322
2082
|
readonly ensureWalletReady?: () => Promise<void>;
|
|
1323
|
-
}):
|
|
2083
|
+
}): OpenfortEmbeddedSigner;
|
|
1324
2084
|
/**
|
|
1325
2085
|
* Browser `CapxulSigner` backed by an Openfort embedded wallet (#335).
|
|
1326
2086
|
* Signs the backend's SafeOp digest via raw `signMessage` (no EIP-191 prefix)
|
|
1327
2087
|
* and verifies recovery before the backend submits.
|
|
1328
2088
|
*/
|
|
1329
|
-
|
|
2089
|
+
type OpenfortEmbeddedSigner = CapxulSigner & {
|
|
2090
|
+
/** Drop cached `getAddress()` so the next read hits the embedded wallet again. */readonly resetAddressCache: () => void;
|
|
2091
|
+
};
|
|
2092
|
+
declare function openfortEmbeddedSigner(input: OpenfortEmbeddedSignerInput): OpenfortEmbeddedSigner;
|
|
2093
|
+
/**
|
|
2094
|
+
* Canonical name for the embedded-wallet `CapxulSigner` constructor
|
|
2095
|
+
* (backend-orchestrated-deploy.md). The embedded-wallet (passkey / Openfort)
|
|
2096
|
+
* member of the named constructor trio `localPrivateKeySigner` /
|
|
2097
|
+
* `injectedWalletSigner` / `embeddedSigner`. Takes the provider-agnostic
|
|
2098
|
+
* `OpenfortEmbeddedWalletPort` (getAddress + signRawDigest); the Openfort-API
|
|
2099
|
+
* convenience wrapper is `openfortEmbeddedSignerFromWallet`.
|
|
2100
|
+
*/
|
|
2101
|
+
declare const embeddedSigner: typeof openfortEmbeddedSigner;
|
|
1330
2102
|
//#endregion
|
|
1331
2103
|
//#region src/production.d.ts
|
|
1332
2104
|
/**
|
|
@@ -1358,5 +2130,32 @@ interface CapxulClientInput {
|
|
|
1358
2130
|
/** Consumer-facing factory — accepts only production-meaningful inputs (#326). */
|
|
1359
2131
|
declare function createCapxulClient(input: CapxulClientInput): Promise<CapxulResult<CapxulClient>>;
|
|
1360
2132
|
//#endregion
|
|
1361
|
-
|
|
2133
|
+
//#region src/telemetry/capture-exception.d.ts
|
|
2134
|
+
interface HandledErrorReportContext {
|
|
2135
|
+
readonly layer?: string;
|
|
2136
|
+
readonly operation?: string;
|
|
2137
|
+
readonly provider?: string;
|
|
2138
|
+
readonly capxul_error_code?: string;
|
|
2139
|
+
readonly failure_mode?: FailureMode;
|
|
2140
|
+
}
|
|
2141
|
+
/**
|
|
2142
|
+
* Capture an error as a `$exception` event through the telemetry port,
|
|
2143
|
+
* formatted for PostHog Error Tracking.
|
|
2144
|
+
*
|
|
2145
|
+
* Parses stack traces into `$exception_list` format, extracts structured
|
|
2146
|
+
* metadata from CapxulError objects, and supplements with context props.
|
|
2147
|
+
* Fire-and-forget: telemetry defects are silently swallowed.
|
|
2148
|
+
* Returns `Effect<void, never>` for use in Effect pipelines; the underlying
|
|
2149
|
+
* adapter work is synchronous, so callers outside Effect contexts can
|
|
2150
|
+
* use `Effect.runSync`.
|
|
2151
|
+
*/
|
|
2152
|
+
declare function captureException(telemetry: TelemetryPort, error: unknown, context?: HandledErrorReportContext): Effect.Effect<void, never>;
|
|
2153
|
+
/**
|
|
2154
|
+
* Synchronous fire-and-forget capture. Runs the Effect inline with
|
|
2155
|
+
* `Effect.runSync` so callers outside an Effect context (e.g. React
|
|
2156
|
+
* hooks before throwing) can report errors without awaiting.
|
|
2157
|
+
*/
|
|
2158
|
+
declare function captureExceptionSync(telemetry: TelemetryPort, error: unknown, context?: HandledErrorReportContext): void;
|
|
2159
|
+
//#endregion
|
|
2160
|
+
export { type Account, type AccountLifecycle, type AccountMethods, type AccountProvider, type AccountProviderSource, type AccountRequirement, type AccountSetupStep, type AccountsMethods, type Address, type AssignRoleInput, type AuthMethods, type AuthSession, type AuthUserId, type CapxulClient, type CapxulClientInput, type CapxulResult, type CapxulSigner, type CompleteOrganizationOnboardingInput, type CompleteOrganizationOnboardingResult, type CompletePersonalOnboardingInput, type CompletePersonalOnboardingResult, type CreateCapxulClientInput, type CreateOrgInput, type DepositInstructions, type DetectPendingOrgInvitationsResult, type DevPrivateKeySignerInput, type Eip1193Provider, type Eip1193RequestProvider, type FinancialOpsMethods, type HandledErrorReportContext, type HandlesMethods, type IdentityMethods, type InviteMemberInput, type MeMethods, type MeProfile, type MemberStatus, type MemberView, type Money, type OnboardingMethods, type OpenfortEmbeddedSignerInput, type OpenfortEmbeddedWalletApi, type OpenfortEmbeddedWalletPort, type OrgBatchPayrollInput, type OrgId, type OrgMethods, type OrgPayrollRun, type OrgScopedMethods, type OrgSpendViaPaymentsInput, type OrgTemplate, type OrgView, type Payee, type PayeesMethods, type Payment, type PaymentDocumentRef, type PaymentDocumentRender, type PaymentDocumentVerification, type PaymentDocumentsMethods, type PaymentDraft, type PaymentDraftStatus, type PaymentMoney, type PaymentRelease, type PaymentRequest, type PaymentRequestStatus, type PaymentRequestsCreateInput, type PaymentRequestsMethods, type PaymentSettlementInput, type PaymentStatus, type PaymentType, type PaymentsMethods, type PaymentsPayInput, type PaymentsWithdrawInput, type Profile, type RecipientResolution, type RecipientResolutionKind, type ReconciliationEntry, type RemoveMemberInput, type RoleDefinition, type RoleKey, type RoleSpendCap, type RoleView, type Session, type SmartAccount, type SmartAccountMethods, type SubAccount, type SubAccountId, type SubAccountsMethods, type TelemetryPort, type TransferEndpoint, type TransferInput, type TransferResult, type WorkbenchDraftInput, type WorkbenchExecuteInput, type WorkbenchMethods, type WorkbenchMintResult, captureException, captureExceptionSync, createCapxulClient, deriveDevPrivateKey, devPrivateKeySigner, eip1193AccountProvider, embeddedSigner, injectedWalletSigner, isSettingUpLifecycle, localPrivateKeyAccountProvider, openfortEmbeddedSigner, openfortEmbeddedSignerFromWallet, openfortEmbeddedWalletPort };
|
|
1362
2161
|
//# sourceMappingURL=index.d.mts.map
|