@usesigil/kit 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +158 -145
- package/dist/alt-config.d.ts +4 -2
- package/dist/alt-config.d.ts.map +1 -1
- package/dist/alt-config.js +4 -2
- package/dist/alt-config.js.map +1 -1
- package/dist/alt-loader.d.ts.map +1 -1
- package/dist/alt-loader.js +2 -1
- package/dist/alt-loader.js.map +1 -1
- package/dist/balance-tracker.d.ts +7 -0
- package/dist/balance-tracker.d.ts.map +1 -1
- package/dist/balance-tracker.js +26 -9
- package/dist/balance-tracker.js.map +1 -1
- package/dist/create-vault.d.ts +40 -3
- package/dist/create-vault.d.ts.map +1 -1
- package/dist/create-vault.js +45 -7
- package/dist/create-vault.js.map +1 -1
- package/dist/dashboard/discover.d.ts.map +1 -1
- package/dist/dashboard/discover.js +2 -1
- package/dist/dashboard/discover.js.map +1 -1
- package/dist/dashboard/from-json.d.ts +1 -0
- package/dist/dashboard/from-json.d.ts.map +1 -1
- package/dist/dashboard/from-json.js +3 -1
- package/dist/dashboard/from-json.js.map +1 -1
- package/dist/dashboard/mutations.d.ts.map +1 -1
- package/dist/dashboard/mutations.js +2 -1
- package/dist/dashboard/mutations.js.map +1 -1
- package/dist/dashboard/reads.d.ts.map +1 -1
- package/dist/dashboard/reads.js +5 -4
- package/dist/dashboard/reads.js.map +1 -1
- package/dist/errors/public.d.ts +24 -0
- package/dist/errors/public.d.ts.map +1 -0
- package/dist/errors/public.js +30 -0
- package/dist/errors/public.js.map +1 -0
- package/dist/errors/walk.d.ts +8 -0
- package/dist/errors/walk.d.ts.map +1 -1
- package/dist/errors/walk.js +12 -1
- package/dist/errors/walk.js.map +1 -1
- package/dist/helpers/ata.d.ts +73 -0
- package/dist/helpers/ata.d.ts.map +1 -0
- package/dist/helpers/ata.js +107 -0
- package/dist/helpers/ata.js.map +1 -0
- package/dist/helpers/parse-usd.d.ts +43 -0
- package/dist/helpers/parse-usd.d.ts.map +1 -0
- package/dist/helpers/parse-usd.js +81 -0
- package/dist/helpers/parse-usd.js.map +1 -0
- package/dist/helpers/validate-cap-aggregate.d.ts +41 -0
- package/dist/helpers/validate-cap-aggregate.d.ts.map +1 -0
- package/dist/helpers/validate-cap-aggregate.js +61 -0
- package/dist/helpers/validate-cap-aggregate.js.map +1 -0
- package/dist/index.d.ts +12 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -5
- package/dist/index.js.map +1 -1
- package/dist/integrations/compose-errors.d.ts.map +1 -1
- package/dist/integrations/compose-errors.js +15 -1
- package/dist/integrations/compose-errors.js.map +1 -1
- package/dist/logger.d.ts +77 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +153 -0
- package/dist/logger.js.map +1 -0
- package/dist/math-utils.d.ts +5 -0
- package/dist/math-utils.d.ts.map +1 -1
- package/dist/math-utils.js +7 -0
- package/dist/math-utils.js.map +1 -1
- package/dist/presets.d.ts +73 -6
- package/dist/presets.d.ts.map +1 -1
- package/dist/presets.js +75 -6
- package/dist/presets.js.map +1 -1
- package/dist/priority-fees.d.ts +3 -0
- package/dist/priority-fees.d.ts.map +1 -1
- package/dist/priority-fees.js +14 -37
- package/dist/priority-fees.js.map +1 -1
- package/dist/seal.d.ts +85 -6
- package/dist/seal.d.ts.map +1 -1
- package/dist/seal.js +199 -9
- package/dist/seal.js.map +1 -1
- package/dist/shield.d.ts.map +1 -1
- package/dist/shield.js +10 -9
- package/dist/shield.js.map +1 -1
- package/dist/tee/verify.d.ts.map +1 -1
- package/dist/tee/verify.js +11 -10
- package/dist/tee/verify.js.map +1 -1
- package/dist/transaction-executor.d.ts.map +1 -1
- package/dist/transaction-executor.js +3 -2
- package/dist/transaction-executor.js.map +1 -1
- package/dist/x402/shielded-fetch.d.ts.map +1 -1
- package/dist/x402/shielded-fetch.js +7 -4
- package/dist/x402/shielded-fetch.js.map +1 -1
- package/package.json +6 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/errors/public.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EACL,kCAAkC,EAClC,mCAAmC,EACnC,wCAAwC,EACxC,oCAAoC,GACrC,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,oCAAoC,EACpC,oCAAoC,EACpC,8BAA8B,GAC/B,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,mCAAmC,EACnC,oCAAoC,EACpC,wCAAwC,GACzC,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,mCAAmC,EACnC,iCAAiC,EACjC,8BAA8B,EAC9B,sCAAsC,EACtC,yBAAyB,GAC1B,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,gCAAgC,EAChC,gCAAgC,EAChC,iCAAiC,EACjC,gCAAgC,EAChC,oCAAoC,EACpC,qCAAqC,EACrC,uCAAuC,EACvC,iCAAiC,EACjC,gCAAgC,EAChC,uCAAuC,EACvC,kCAAkC,EAClC,sCAAsC,EACtC,8BAA8B,EAC9B,uCAAuC,EACvC,gCAAgC,EAChC,mCAAmC,EACnC,sCAAsC,EACtC,sCAAsC,EACtC,uCAAuC,EACvC,mCAAmC,EACnC,8BAA8B,EAC9B,mCAAmC,EACnC,+BAA+B,EAC/B,kCAAkC,EAClC,6BAA6B,EAC7B,yBAAyB,GAC1B,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,2BAA2B,EAC3B,sCAAsC,EACtC,mCAAmC,EACnC,gCAAgC,EAChC,8BAA8B,EAC9B,8BAA8B,EAC9B,sCAAsC,GACvC,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAQ3D,YAAY,EACV,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @usesigil/kit/errors — public error-code subpath.
|
|
3
|
+
*
|
|
4
|
+
* Explicit named re-exports of every `SIGIL_ERROR__*` discriminant defined in
|
|
5
|
+
* `./codes.ts`. Importing from this subpath (rather than from the package
|
|
6
|
+
* root) keeps consumer bundles small — the root barrel should not re-export
|
|
7
|
+
* these once Sprint 1 of the SDK redesign lands.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* import { SIGIL_ERROR__SDK__CAP_EXCEEDED } from "@usesigil/kit/errors";
|
|
11
|
+
*
|
|
12
|
+
* This file is the public contract. If a new error domain or discriminant
|
|
13
|
+
* is added in `./codes.ts`, it must be re-exported here (or the test
|
|
14
|
+
* `tests/errors/public-subpath.test.ts` will fail).
|
|
15
|
+
*/
|
|
16
|
+
// Shield domain — policy enforcement (4)
|
|
17
|
+
export { SIGIL_ERROR__SHIELD__POLICY_DENIED, SIGIL_ERROR__SHIELD__CONFIG_INVALID, SIGIL_ERROR__SHIELD__RATE_LIMIT_EXCEEDED, SIGIL_ERROR__SHIELD__SESSION_BINDING, } from "./codes.js";
|
|
18
|
+
// TEE domain — attestation + custody (3)
|
|
19
|
+
export { SIGIL_ERROR__TEE__ATTESTATION_FAILED, SIGIL_ERROR__TEE__CERT_CHAIN_INVALID, SIGIL_ERROR__TEE__PCR_MISMATCH, } from "./codes.js";
|
|
20
|
+
// Compose domain — DeFi instruction composition (3)
|
|
21
|
+
export { SIGIL_ERROR__COMPOSE__MISSING_PARAM, SIGIL_ERROR__COMPOSE__INVALID_BIGINT, SIGIL_ERROR__COMPOSE__UNSUPPORTED_ACTION, } from "./codes.js";
|
|
22
|
+
// x402 domain — HTTP 402 payments (5)
|
|
23
|
+
export { SIGIL_ERROR__X402__HEADER_MALFORMED, SIGIL_ERROR__X402__PAYMENT_FAILED, SIGIL_ERROR__X402__UNSUPPORTED, SIGIL_ERROR__X402__DESTINATION_BLOCKED, SIGIL_ERROR__X402__REPLAY, } from "./codes.js";
|
|
24
|
+
// SDK domain — config + runtime + state (26)
|
|
25
|
+
export { SIGIL_ERROR__SDK__INVALID_CONFIG, SIGIL_ERROR__SDK__INVALID_PARAMS, SIGIL_ERROR__SDK__INVALID_NETWORK, SIGIL_ERROR__SDK__INVALID_AMOUNT, SIGIL_ERROR__SDK__INVALID_CAPABILITY, SIGIL_ERROR__SDK__INVALID_ACTION_TYPE, SIGIL_ERROR__SDK__OWNER_AGENT_COLLISION, SIGIL_ERROR__SDK__VAULT_NOT_FOUND, SIGIL_ERROR__SDK__VAULT_INACTIVE, SIGIL_ERROR__SDK__VAULT_SLOTS_EXHAUSTED, SIGIL_ERROR__SDK__POLICY_NOT_FOUND, SIGIL_ERROR__SDK__AGENT_NOT_REGISTERED, SIGIL_ERROR__SDK__AGENT_PAUSED, SIGIL_ERROR__SDK__AGENT_ZERO_CAPABILITY, SIGIL_ERROR__SDK__SIGNER_INVALID, SIGIL_ERROR__SDK__SIGNATURE_INVALID, SIGIL_ERROR__SDK__SPL_TOKEN_OP_BLOCKED, SIGIL_ERROR__SDK__PROTOCOL_NOT_ALLOWED, SIGIL_ERROR__SDK__PROTOCOL_NOT_TARGETED, SIGIL_ERROR__SDK__INSTRUCTION_COUNT, SIGIL_ERROR__SDK__CAP_EXCEEDED, SIGIL_ERROR__SDK__ATA_NON_CANONICAL, SIGIL_ERROR__SDK__ALT_INTEGRITY, SIGIL_ERROR__SDK__ALT_NOT_DEPLOYED, SIGIL_ERROR__SDK__SEAL_FAILED, SIGIL_ERROR__SDK__UNKNOWN, } from "./codes.js";
|
|
26
|
+
// RPC domain — transport + simulation (7)
|
|
27
|
+
export { SIGIL_ERROR__RPC__TX_FAILED, SIGIL_ERROR__RPC__CONFIRMATION_TIMEOUT, SIGIL_ERROR__RPC__SIMULATION_FAILED, SIGIL_ERROR__RPC__DRAIN_DETECTED, SIGIL_ERROR__RPC__TX_TOO_LARGE, SIGIL_ERROR__RPC__RATE_LIMITED, SIGIL_ERROR__RPC__INSTRUCTION_REQUIRED, } from "./codes.js";
|
|
28
|
+
// Program domain — on-chain Anchor errors surfaced to the SDK (1)
|
|
29
|
+
export { SIGIL_ERROR__PROGRAM__GENERIC } from "./codes.js";
|
|
30
|
+
//# sourceMappingURL=public.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public.js","sourceRoot":"","sources":["../../src/errors/public.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,yCAAyC;AACzC,OAAO,EACL,kCAAkC,EAClC,mCAAmC,EACnC,wCAAwC,EACxC,oCAAoC,GACrC,MAAM,YAAY,CAAC;AAEpB,yCAAyC;AACzC,OAAO,EACL,oCAAoC,EACpC,oCAAoC,EACpC,8BAA8B,GAC/B,MAAM,YAAY,CAAC;AAEpB,oDAAoD;AACpD,OAAO,EACL,mCAAmC,EACnC,oCAAoC,EACpC,wCAAwC,GACzC,MAAM,YAAY,CAAC;AAEpB,sCAAsC;AACtC,OAAO,EACL,mCAAmC,EACnC,iCAAiC,EACjC,8BAA8B,EAC9B,sCAAsC,EACtC,yBAAyB,GAC1B,MAAM,YAAY,CAAC;AAEpB,6CAA6C;AAC7C,OAAO,EACL,gCAAgC,EAChC,gCAAgC,EAChC,iCAAiC,EACjC,gCAAgC,EAChC,oCAAoC,EACpC,qCAAqC,EACrC,uCAAuC,EACvC,iCAAiC,EACjC,gCAAgC,EAChC,uCAAuC,EACvC,kCAAkC,EAClC,sCAAsC,EACtC,8BAA8B,EAC9B,uCAAuC,EACvC,gCAAgC,EAChC,mCAAmC,EACnC,sCAAsC,EACtC,sCAAsC,EACtC,uCAAuC,EACvC,mCAAmC,EACnC,8BAA8B,EAC9B,mCAAmC,EACnC,+BAA+B,EAC/B,kCAAkC,EAClC,6BAA6B,EAC7B,yBAAyB,GAC1B,MAAM,YAAY,CAAC;AAEpB,0CAA0C;AAC1C,OAAO,EACL,2BAA2B,EAC3B,sCAAsC,EACtC,mCAAmC,EACnC,gCAAgC,EAChC,8BAA8B,EAC9B,8BAA8B,EAC9B,sCAAsC,GACvC,MAAM,YAAY,CAAC;AAEpB,kEAAkE;AAClE,OAAO,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/errors/walk.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reset the depth-fuse warning flag. Call in test `beforeEach` to ensure
|
|
3
|
+
* each test can independently verify fuse behavior without cross-test
|
|
4
|
+
* suppression. (H2 audit fix — silent-failure-hunter.)
|
|
5
|
+
*
|
|
6
|
+
* @internal Exported for testing only. Not part of the public API.
|
|
7
|
+
*/
|
|
8
|
+
export declare function resetWalkFuse(): void;
|
|
1
9
|
export declare function walk(err: unknown): Error;
|
|
2
10
|
export declare function walk(err: unknown, fn: (e: unknown) => boolean): Error | null;
|
|
3
11
|
//# sourceMappingURL=walk.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"walk.d.ts","sourceRoot":"","sources":["../../src/errors/walk.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"walk.d.ts","sourceRoot":"","sources":["../../src/errors/walk.ts"],"names":[],"mappings":"AAsBA;;;;;;GAMG;AACH,wBAAgB,aAAa,IAAI,IAAI,CAEpC;AAYD,wBAAgB,IAAI,CAAC,GAAG,EAAE,OAAO,GAAG,KAAK,CAAC;AAC1C,wBAAgB,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,OAAO,GAAG,KAAK,GAAG,IAAI,CAAC"}
|
package/dist/errors/walk.js
CHANGED
|
@@ -15,13 +15,24 @@
|
|
|
15
15
|
* `cause: { code: "ECONNRESET" }` shape) by passing them to fn before
|
|
16
16
|
* bailing. Previously these were silently dropped from the search.
|
|
17
17
|
*/
|
|
18
|
+
import { getSigilModuleLogger } from "../logger.js";
|
|
18
19
|
const MAX_WALK_DEPTH = 32;
|
|
19
20
|
let depthFuseWarned = false;
|
|
21
|
+
/**
|
|
22
|
+
* Reset the depth-fuse warning flag. Call in test `beforeEach` to ensure
|
|
23
|
+
* each test can independently verify fuse behavior without cross-test
|
|
24
|
+
* suppression. (H2 audit fix — silent-failure-hunter.)
|
|
25
|
+
*
|
|
26
|
+
* @internal Exported for testing only. Not part of the public API.
|
|
27
|
+
*/
|
|
28
|
+
export function resetWalkFuse() {
|
|
29
|
+
depthFuseWarned = false;
|
|
30
|
+
}
|
|
20
31
|
function warnFuseTrip() {
|
|
21
32
|
if (depthFuseWarned)
|
|
22
33
|
return;
|
|
23
34
|
depthFuseWarned = true;
|
|
24
|
-
|
|
35
|
+
getSigilModuleLogger().warn(`[@usesigil/kit/walk] cause-chain depth exceeded ${MAX_WALK_DEPTH} levels — ` +
|
|
25
36
|
`chain truncated. If this is a real chain (not a cycle), file an issue at ` +
|
|
26
37
|
`https://github.com/Sigil-Trade/sigil/issues with reproduction.`);
|
|
27
38
|
}
|
package/dist/errors/walk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"walk.js","sourceRoot":"","sources":["../../src/errors/walk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,cAAc,GAAG,EAAE,CAAC;AAC1B,IAAI,eAAe,GAAG,KAAK,CAAC;AAE5B,SAAS,YAAY;IACnB,IAAI,eAAe;QAAE,OAAO;IAC5B,eAAe,GAAG,IAAI,CAAC;IACvB,
|
|
1
|
+
{"version":3,"file":"walk.js","sourceRoot":"","sources":["../../src/errors/walk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,cAAc,GAAG,EAAE,CAAC;AAC1B,IAAI,eAAe,GAAG,KAAK,CAAC;AAE5B;;;;;;GAMG;AACH,MAAM,UAAU,aAAa;IAC3B,eAAe,GAAG,KAAK,CAAC;AAC1B,CAAC;AAED,SAAS,YAAY;IACnB,IAAI,eAAe;QAAE,OAAO;IAC5B,eAAe,GAAG,IAAI,CAAC;IACvB,oBAAoB,EAAE,CAAC,IAAI,CACzB,mDAAmD,cAAc,YAAY;QAC3E,2EAA2E;QAC3E,gEAAgE,CACnE,CAAC;AACJ,CAAC;AAID,MAAM,UAAU,IAAI,CAAC,GAAY,EAAE,EAA4B;IAC7D,kFAAkF;IAClF,IAAI,EAAE,EAAE,CAAC;QACP,OAAO,aAAa,CAAC,GAAG,EAAE,EAAE,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;IAC9C,CAAC;IACD,oCAAoC;IACpC,OAAO,QAAQ,CAAC,GAAG,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,aAAa,CACpB,GAAY,EACZ,EAA2B,EAC3B,OAAqB,EACrB,KAAa;IAEb,IAAI,KAAK,IAAI,cAAc,EAAE,CAAC;QAC5B,YAAY,EAAE,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAClC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACjB,uEAAuE;IACvE,oEAAoE;IACpE,0CAA0C;IAC1C,IAAI,EAAE,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IACxE,IAAI,GAAG,YAAY,KAAK,IAAI,GAAG,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACpD,OAAO,aAAa,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,QAAQ,CAAC,GAAY,EAAE,OAAqB,EAAE,KAAa;IAClE,oEAAoE;IACpE,IAAI,CAAC,CAAC,GAAG,YAAY,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,IAAI,KAAK,CAAC,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC;IACtE,CAAC;IACD,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IACjC,IAAI,KAAK,IAAI,cAAc,EAAE,CAAC;QAC5B,YAAY,EAAE,CAAC;QACf,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACjB,IAAI,GAAG,CAAC,KAAK,KAAK,SAAS,IAAI,GAAG,CAAC,KAAK,KAAK,GAAG,EAAE,CAAC;QACjD,OAAO,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* initializeVaultAtas — build ATA `CreateIdempotent` instructions for a
|
|
3
|
+
* Sigil vault with a caller-asserted allowlist check.
|
|
4
|
+
*
|
|
5
|
+
* **This is not a security gate.** The real security surface is the
|
|
6
|
+
* on-chain program: Sigil's `validate_and_authorize` path checks the
|
|
7
|
+
* vault-policy allowlist against every mint touched by the DeFi
|
|
8
|
+
* instructions that actually execute. `initializeVaultAtas` is a
|
|
9
|
+
* thin authoring helper — it builds correct ATA-program instructions
|
|
10
|
+
* AND performs a client-side sanity check that each `mint` is in the
|
|
11
|
+
* `allowedMints` list the caller already decided is valid.
|
|
12
|
+
*
|
|
13
|
+
* The allowlist is **caller-supplied** on purpose: this helper has no
|
|
14
|
+
* RPC dependency, so it can be used inside `createVault` pipelines
|
|
15
|
+
* where the policy object is in memory but not yet on-chain. Callers
|
|
16
|
+
* who already have a resolved `PolicyConfig` should pass
|
|
17
|
+
* `allowedMints: policy.allowedDestinations` (plus any stablecoin mints
|
|
18
|
+
* the owner is wiring up). Callers who pass `allowedMints: mints`
|
|
19
|
+
* (tautological) get no safety value from this helper — they're only
|
|
20
|
+
* using it for the manual instruction-building.
|
|
21
|
+
*
|
|
22
|
+
* The historical naming tied this helper to "F8 closure"; that framing
|
|
23
|
+
* was misleading. F8 is closed by the on-chain protocol, not by this
|
|
24
|
+
* function. Keep the name for API stability; the docstring is the
|
|
25
|
+
* contract.
|
|
26
|
+
*
|
|
27
|
+
* ATA instructions are built manually (following the pattern in
|
|
28
|
+
* `src/x402/transfer-builder.ts`) rather than via `@solana-program/token`
|
|
29
|
+
* to keep `@usesigil/kit` a zero-SPL-dep package.
|
|
30
|
+
*
|
|
31
|
+
* Dedup: repeated mints in the input are merged (the resulting instruction
|
|
32
|
+
* list has one entry per unique mint). Empty input returns an empty list
|
|
33
|
+
* without throwing — a vault that needs no ATAs is a valid configuration.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* // Typical usage: allowedMints derived from the vault's policy.
|
|
37
|
+
* const ixs = await initializeVaultAtas({
|
|
38
|
+
* vault: vaultPda,
|
|
39
|
+
* payer: ownerSigner.address,
|
|
40
|
+
* mints: [USDC_MINT_DEVNET, USDT_MINT_DEVNET],
|
|
41
|
+
* allowedMints: [
|
|
42
|
+
* ...policy.allowedDestinations,
|
|
43
|
+
* USDC_MINT_DEVNET,
|
|
44
|
+
* USDT_MINT_DEVNET,
|
|
45
|
+
* ],
|
|
46
|
+
* });
|
|
47
|
+
* // → [ createIdempotent(USDC ATA), createIdempotent(USDT ATA) ]
|
|
48
|
+
*/
|
|
49
|
+
import type { Address, Instruction } from "../kit-adapter.js";
|
|
50
|
+
export interface InitializeVaultAtasParams {
|
|
51
|
+
/** The vault PDA that will own the ATAs. */
|
|
52
|
+
vault: Address;
|
|
53
|
+
/**
|
|
54
|
+
* Funding account — pays the rent for each new ATA and signs the tx.
|
|
55
|
+
* Typically the owner's wallet during `createVault`, or any signer that
|
|
56
|
+
* holds enough SOL to cover ATA rent.
|
|
57
|
+
*/
|
|
58
|
+
payer: Address;
|
|
59
|
+
/**
|
|
60
|
+
* Mints to initialize ATAs for. Duplicates are deduplicated.
|
|
61
|
+
* Empty array returns an empty instruction list.
|
|
62
|
+
*/
|
|
63
|
+
mints: readonly Address[];
|
|
64
|
+
/**
|
|
65
|
+
* Client-side allowlist. Every entry in `mints` must be present in
|
|
66
|
+
* `allowedMints`, or the call throws `SPL_TOKEN_OP_BLOCKED`.
|
|
67
|
+
* Typically populated from `PolicyConfig.allowedDestinations` plus
|
|
68
|
+
* recognized stablecoin mints the owner is wiring up.
|
|
69
|
+
*/
|
|
70
|
+
allowedMints: readonly Address[];
|
|
71
|
+
}
|
|
72
|
+
export declare function initializeVaultAtas(params: InitializeVaultAtasParams): Promise<Instruction[]>;
|
|
73
|
+
//# sourceMappingURL=ata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ata.d.ts","sourceRoot":"","sources":["../../src/helpers/ata.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAoB9D,MAAM,WAAW,yBAAyB;IACxC,4CAA4C;IAC5C,KAAK,EAAE,OAAO,CAAC;IACf;;;;OAIG;IACH,KAAK,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,KAAK,EAAE,SAAS,OAAO,EAAE,CAAC;IAC1B;;;;;OAKG;IACH,YAAY,EAAE,SAAS,OAAO,EAAE,CAAC;CAClC;AAED,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,yBAAyB,GAChC,OAAO,CAAC,WAAW,EAAE,CAAC,CAqCxB"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* initializeVaultAtas — build ATA `CreateIdempotent` instructions for a
|
|
3
|
+
* Sigil vault with a caller-asserted allowlist check.
|
|
4
|
+
*
|
|
5
|
+
* **This is not a security gate.** The real security surface is the
|
|
6
|
+
* on-chain program: Sigil's `validate_and_authorize` path checks the
|
|
7
|
+
* vault-policy allowlist against every mint touched by the DeFi
|
|
8
|
+
* instructions that actually execute. `initializeVaultAtas` is a
|
|
9
|
+
* thin authoring helper — it builds correct ATA-program instructions
|
|
10
|
+
* AND performs a client-side sanity check that each `mint` is in the
|
|
11
|
+
* `allowedMints` list the caller already decided is valid.
|
|
12
|
+
*
|
|
13
|
+
* The allowlist is **caller-supplied** on purpose: this helper has no
|
|
14
|
+
* RPC dependency, so it can be used inside `createVault` pipelines
|
|
15
|
+
* where the policy object is in memory but not yet on-chain. Callers
|
|
16
|
+
* who already have a resolved `PolicyConfig` should pass
|
|
17
|
+
* `allowedMints: policy.allowedDestinations` (plus any stablecoin mints
|
|
18
|
+
* the owner is wiring up). Callers who pass `allowedMints: mints`
|
|
19
|
+
* (tautological) get no safety value from this helper — they're only
|
|
20
|
+
* using it for the manual instruction-building.
|
|
21
|
+
*
|
|
22
|
+
* The historical naming tied this helper to "F8 closure"; that framing
|
|
23
|
+
* was misleading. F8 is closed by the on-chain protocol, not by this
|
|
24
|
+
* function. Keep the name for API stability; the docstring is the
|
|
25
|
+
* contract.
|
|
26
|
+
*
|
|
27
|
+
* ATA instructions are built manually (following the pattern in
|
|
28
|
+
* `src/x402/transfer-builder.ts`) rather than via `@solana-program/token`
|
|
29
|
+
* to keep `@usesigil/kit` a zero-SPL-dep package.
|
|
30
|
+
*
|
|
31
|
+
* Dedup: repeated mints in the input are merged (the resulting instruction
|
|
32
|
+
* list has one entry per unique mint). Empty input returns an empty list
|
|
33
|
+
* without throwing — a vault that needs no ATAs is a valid configuration.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* // Typical usage: allowedMints derived from the vault's policy.
|
|
37
|
+
* const ixs = await initializeVaultAtas({
|
|
38
|
+
* vault: vaultPda,
|
|
39
|
+
* payer: ownerSigner.address,
|
|
40
|
+
* mints: [USDC_MINT_DEVNET, USDT_MINT_DEVNET],
|
|
41
|
+
* allowedMints: [
|
|
42
|
+
* ...policy.allowedDestinations,
|
|
43
|
+
* USDC_MINT_DEVNET,
|
|
44
|
+
* USDT_MINT_DEVNET,
|
|
45
|
+
* ],
|
|
46
|
+
* });
|
|
47
|
+
* // → [ createIdempotent(USDC ATA), createIdempotent(USDT ATA) ]
|
|
48
|
+
*/
|
|
49
|
+
import { AccountRole } from "../kit-adapter.js";
|
|
50
|
+
import { TOKEN_PROGRAM_ADDRESS, ATA_PROGRAM_ADDRESS, SYSTEM_PROGRAM_ADDRESS, } from "../types.js";
|
|
51
|
+
import { deriveAta } from "../tokens.js";
|
|
52
|
+
import { SigilSdkDomainError } from "../errors/sdk.js";
|
|
53
|
+
import { SIGIL_ERROR__SDK__SPL_TOKEN_OP_BLOCKED } from "../errors/codes.js";
|
|
54
|
+
/**
|
|
55
|
+
* Associated Token Program — `CreateIdempotent` instruction discriminator.
|
|
56
|
+
*
|
|
57
|
+
* Layout: a single byte. No args, no additional data. Creates the ATA if
|
|
58
|
+
* it doesn't exist; no-ops if it does. Source: ATA program
|
|
59
|
+
* `processor.rs` variant `CreateIdempotent = 1`.
|
|
60
|
+
*/
|
|
61
|
+
const CREATE_IDEMPOTENT_DISCRIMINATOR = 1;
|
|
62
|
+
export async function initializeVaultAtas(params) {
|
|
63
|
+
const { vault, payer, mints, allowedMints } = params;
|
|
64
|
+
if (mints.length === 0)
|
|
65
|
+
return [];
|
|
66
|
+
// Build the allowlist as a Set for O(1) membership test. Addresses are
|
|
67
|
+
// base58 strings, which compare by value. No normalization needed.
|
|
68
|
+
const allowed = new Set(allowedMints);
|
|
69
|
+
// Validate every mint before issuing any PDA derivation — fail-fast.
|
|
70
|
+
for (const mint of mints) {
|
|
71
|
+
if (!allowed.has(mint)) {
|
|
72
|
+
throw new SigilSdkDomainError(SIGIL_ERROR__SDK__SPL_TOKEN_OP_BLOCKED, `Mint ${mint} is not in the policy allowlist. ` +
|
|
73
|
+
`initializeVaultAtas only creates ATAs for mints the vault's ` +
|
|
74
|
+
`policy explicitly permits. Add this mint to the policy's ` +
|
|
75
|
+
`allowedDestinations before calling, or pass a broader ` +
|
|
76
|
+
`allowedMints list (e.g. [...policy.allowedDestinations, USDC_MINT_DEVNET]).`, { context: { mint, allowedMints: [...allowed] } });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Deduplicate by mint — a caller passing the same mint twice should not
|
|
80
|
+
// produce two identical createIdempotent instructions in the same tx.
|
|
81
|
+
const uniqueMints = Array.from(new Set(mints));
|
|
82
|
+
// Derive ATAs in parallel and build one CreateIdempotent ix per mint.
|
|
83
|
+
const instructions = await Promise.all(uniqueMints.map(async (mint) => {
|
|
84
|
+
const ata = await deriveAta(vault, mint);
|
|
85
|
+
return buildCreateIdempotentIx({ payer, ata, owner: vault, mint });
|
|
86
|
+
}));
|
|
87
|
+
return instructions;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Build a raw `CreateIdempotent` instruction for the ATA program.
|
|
91
|
+
* Pulled into a helper to keep the main function readable.
|
|
92
|
+
*/
|
|
93
|
+
function buildCreateIdempotentIx(args) {
|
|
94
|
+
return {
|
|
95
|
+
programAddress: ATA_PROGRAM_ADDRESS,
|
|
96
|
+
accounts: [
|
|
97
|
+
{ address: args.payer, role: AccountRole.WRITABLE_SIGNER },
|
|
98
|
+
{ address: args.ata, role: AccountRole.WRITABLE },
|
|
99
|
+
{ address: args.owner, role: AccountRole.READONLY },
|
|
100
|
+
{ address: args.mint, role: AccountRole.READONLY },
|
|
101
|
+
{ address: SYSTEM_PROGRAM_ADDRESS, role: AccountRole.READONLY },
|
|
102
|
+
{ address: TOKEN_PROGRAM_ADDRESS, role: AccountRole.READONLY },
|
|
103
|
+
],
|
|
104
|
+
data: new Uint8Array([CREATE_IDEMPOTENT_DISCRIMINATOR]),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=ata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ata.js","sourceRoot":"","sources":["../../src/helpers/ata.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,sCAAsC,EAAE,MAAM,oBAAoB,CAAC;AAE5E;;;;;;GAMG;AACH,MAAM,+BAA+B,GAAG,CAAC,CAAC;AAyB1C,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,MAAiC;IAEjC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;IAErD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAElC,uEAAuE;IACvE,mEAAmE;IACnE,MAAM,OAAO,GAAG,IAAI,GAAG,CAAS,YAAY,CAAC,CAAC;IAE9C,qEAAqE;IACrE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,mBAAmB,CAC3B,sCAAsC,EACtC,QAAQ,IAAI,mCAAmC;gBAC7C,8DAA8D;gBAC9D,2DAA2D;gBAC3D,wDAAwD;gBACxD,6EAA6E,EAC/E,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,GAAG,OAAO,CAAC,EAAW,EAAE,CAC3D,CAAC;QACJ,CAAC;IACH,CAAC;IAED,wEAAwE;IACxE,sEAAsE;IACtE,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAS,KAAK,CAAC,CAAc,CAAC;IAEpE,sEAAsE;IACtE,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,GAAG,CACpC,WAAW,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QAC7B,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACzC,OAAO,uBAAuB,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACrE,CAAC,CAAC,CACH,CAAC;IAEF,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;;GAGG;AACH,SAAS,uBAAuB,CAAC,IAKhC;IACC,OAAO;QACL,cAAc,EAAE,mBAAmB;QACnC,QAAQ,EAAE;YACR,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,WAAW,CAAC,eAAe,EAAE;YAC1D,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,WAAW,CAAC,QAAQ,EAAE;YACjD,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,WAAW,CAAC,QAAQ,EAAE;YACnD,EAAE,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,QAAQ,EAAE;YAClD,EAAE,OAAO,EAAE,sBAAsB,EAAE,IAAI,EAAE,WAAW,CAAC,QAAQ,EAAE;YAC/D,EAAE,OAAO,EAAE,qBAAqB,EAAE,IAAI,EAAE,WAAW,CAAC,QAAQ,EAAE;SAC/D;QACD,IAAI,EAAE,IAAI,UAAU,CAAC,CAAC,+BAA+B,CAAC,CAAC;KACxD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* parseUsd — strict USD-string parser that returns 6-decimal base units.
|
|
3
|
+
*
|
|
4
|
+
* Rationale: consumers frequently need to express dollar amounts ("$500",
|
|
5
|
+
* "$0.01") in UI surfaces, CLIs, and config files. Parsing those strings
|
|
6
|
+
* with `parseFloat` or `Number(...)` introduces floating-point rounding
|
|
7
|
+
* errors that compound into cap-enforcement bugs on-chain. This helper
|
|
8
|
+
* uses a strict regex and BigInt arithmetic only — no floating-point path
|
|
9
|
+
* exists at any step.
|
|
10
|
+
*
|
|
11
|
+
* Grammar (regex `^\$(0|[1-9]\d{0,14})(\.\d{1,6})?$`):
|
|
12
|
+
* - Leading literal `$` is required
|
|
13
|
+
* - Whole part: `0` alone, OR a 1-15 digit number with no leading zero
|
|
14
|
+
* (`$01` / `$007` are rejected as typos; `$0` / `$0.5` are valid)
|
|
15
|
+
* - 15 digits max × 10^6 scale = 10^21, well within BigInt range
|
|
16
|
+
* - Optional fractional part: `.` + 1–6 digits (matches USD_DECIMALS = 6)
|
|
17
|
+
* - No thousands separators, no exponent notation, no sign, no whitespace
|
|
18
|
+
*
|
|
19
|
+
* Output: bigint in 6-decimal USD base units (`$1 → 1_000_000n`).
|
|
20
|
+
*
|
|
21
|
+
* Errors: throws `SigilSdkDomainError` with code
|
|
22
|
+
* `SIGIL_ERROR__SDK__INVALID_AMOUNT` for any malformed input. The error
|
|
23
|
+
* `.context` carries the original input string to aid debugging.
|
|
24
|
+
*
|
|
25
|
+
* Examples:
|
|
26
|
+
* parseUsd("$0") // → 0n
|
|
27
|
+
* parseUsd("$0.01") // → 10_000n
|
|
28
|
+
* parseUsd("$1") // → 1_000_000n
|
|
29
|
+
* parseUsd("$1.5") // → 1_500_000n
|
|
30
|
+
* parseUsd("$100.000001") // → 100_000_001n
|
|
31
|
+
* parseUsd("$999999999999999")// → 999_999_999_999_999_000_000n
|
|
32
|
+
* parseUsd("1.0") // throws — missing "$"
|
|
33
|
+
* parseUsd("$1,000") // throws — commas not allowed
|
|
34
|
+
* parseUsd("$1e3") // throws — exponent not allowed
|
|
35
|
+
* parseUsd("$1.1234567") // throws — > 6 decimals
|
|
36
|
+
* parseUsd("$-1") // throws — negative not allowed
|
|
37
|
+
*
|
|
38
|
+
* @param input USD-denominated string, including literal leading "$"
|
|
39
|
+
* @returns `bigint` in 6-decimal base units (USD_DECIMALS = 6)
|
|
40
|
+
* @throws {SigilSdkDomainError} code SIGIL_ERROR__SDK__INVALID_AMOUNT
|
|
41
|
+
*/
|
|
42
|
+
export declare function parseUsd(input: string): bigint;
|
|
43
|
+
//# sourceMappingURL=parse-usd.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-usd.d.ts","sourceRoot":"","sources":["../../src/helpers/parse-usd.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAmBH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAoC9C"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* parseUsd — strict USD-string parser that returns 6-decimal base units.
|
|
3
|
+
*
|
|
4
|
+
* Rationale: consumers frequently need to express dollar amounts ("$500",
|
|
5
|
+
* "$0.01") in UI surfaces, CLIs, and config files. Parsing those strings
|
|
6
|
+
* with `parseFloat` or `Number(...)` introduces floating-point rounding
|
|
7
|
+
* errors that compound into cap-enforcement bugs on-chain. This helper
|
|
8
|
+
* uses a strict regex and BigInt arithmetic only — no floating-point path
|
|
9
|
+
* exists at any step.
|
|
10
|
+
*
|
|
11
|
+
* Grammar (regex `^\$(0|[1-9]\d{0,14})(\.\d{1,6})?$`):
|
|
12
|
+
* - Leading literal `$` is required
|
|
13
|
+
* - Whole part: `0` alone, OR a 1-15 digit number with no leading zero
|
|
14
|
+
* (`$01` / `$007` are rejected as typos; `$0` / `$0.5` are valid)
|
|
15
|
+
* - 15 digits max × 10^6 scale = 10^21, well within BigInt range
|
|
16
|
+
* - Optional fractional part: `.` + 1–6 digits (matches USD_DECIMALS = 6)
|
|
17
|
+
* - No thousands separators, no exponent notation, no sign, no whitespace
|
|
18
|
+
*
|
|
19
|
+
* Output: bigint in 6-decimal USD base units (`$1 → 1_000_000n`).
|
|
20
|
+
*
|
|
21
|
+
* Errors: throws `SigilSdkDomainError` with code
|
|
22
|
+
* `SIGIL_ERROR__SDK__INVALID_AMOUNT` for any malformed input. The error
|
|
23
|
+
* `.context` carries the original input string to aid debugging.
|
|
24
|
+
*
|
|
25
|
+
* Examples:
|
|
26
|
+
* parseUsd("$0") // → 0n
|
|
27
|
+
* parseUsd("$0.01") // → 10_000n
|
|
28
|
+
* parseUsd("$1") // → 1_000_000n
|
|
29
|
+
* parseUsd("$1.5") // → 1_500_000n
|
|
30
|
+
* parseUsd("$100.000001") // → 100_000_001n
|
|
31
|
+
* parseUsd("$999999999999999")// → 999_999_999_999_999_000_000n
|
|
32
|
+
* parseUsd("1.0") // throws — missing "$"
|
|
33
|
+
* parseUsd("$1,000") // throws — commas not allowed
|
|
34
|
+
* parseUsd("$1e3") // throws — exponent not allowed
|
|
35
|
+
* parseUsd("$1.1234567") // throws — > 6 decimals
|
|
36
|
+
* parseUsd("$-1") // throws — negative not allowed
|
|
37
|
+
*
|
|
38
|
+
* @param input USD-denominated string, including literal leading "$"
|
|
39
|
+
* @returns `bigint` in 6-decimal base units (USD_DECIMALS = 6)
|
|
40
|
+
* @throws {SigilSdkDomainError} code SIGIL_ERROR__SDK__INVALID_AMOUNT
|
|
41
|
+
*/
|
|
42
|
+
import { SigilSdkDomainError } from "../errors/sdk.js";
|
|
43
|
+
import { SIGIL_ERROR__SDK__INVALID_AMOUNT } from "../errors/codes.js";
|
|
44
|
+
// USD_DECIMALS = 6 — hardcoded here to keep parse-usd.ts dependency-free
|
|
45
|
+
// from the larger types barrel. Must stay in sync with
|
|
46
|
+
// programs/sigil/src/state/mod.rs:224 and sdk/kit/src/types.ts USD_DECIMALS.
|
|
47
|
+
const USD_DECIMALS = 6;
|
|
48
|
+
const USD_BASE = 1000000n; // 10 ** USD_DECIMALS
|
|
49
|
+
// Strict format:
|
|
50
|
+
// - Leading literal `$`
|
|
51
|
+
// - Whole part: either "0" OR a 1-15 digit number that doesn't start with 0.
|
|
52
|
+
// Prevents `$00`, `$01`, `$007` from silently parsing — those are almost
|
|
53
|
+
// always typos, never intentional amounts.
|
|
54
|
+
// - Optional `.` + 1–6 decimal digits (capture group 2 includes the dot)
|
|
55
|
+
const USD_REGEX = /^\$(0|[1-9]\d{0,14})(\.\d{1,6})?$/;
|
|
56
|
+
export function parseUsd(input) {
|
|
57
|
+
if (typeof input !== "string") {
|
|
58
|
+
throw new SigilSdkDomainError(SIGIL_ERROR__SDK__INVALID_AMOUNT, `parseUsd expected a string, received ${typeof input}`, { context: { input: String(input) } });
|
|
59
|
+
}
|
|
60
|
+
const match = input.match(USD_REGEX);
|
|
61
|
+
if (match === null) {
|
|
62
|
+
throw new SigilSdkDomainError(SIGIL_ERROR__SDK__INVALID_AMOUNT, `Invalid USD amount: "${input}". ` +
|
|
63
|
+
`Expected format "$<whole>[.<fraction>]" — ` +
|
|
64
|
+
`up to 15 whole digits, up to ${USD_DECIMALS} fractional digits, ` +
|
|
65
|
+
`no commas, no exponent, no sign, no whitespace.`, { context: { input } });
|
|
66
|
+
}
|
|
67
|
+
const [, whole, fractionPart] = match;
|
|
68
|
+
// `whole` is guaranteed non-empty (regex `\d{1,15}`).
|
|
69
|
+
const wholeBig = BigInt(whole);
|
|
70
|
+
let result = wholeBig * USD_BASE;
|
|
71
|
+
if (fractionPart !== undefined) {
|
|
72
|
+
// fractionPart includes the leading dot: ".5", ".000001"
|
|
73
|
+
const fractionDigits = fractionPart.slice(1);
|
|
74
|
+
// Pad fractionDigits to exactly USD_DECIMALS digits (right-pad with 0).
|
|
75
|
+
// "5" → "500000"; "000001" → "000001"
|
|
76
|
+
const padded = fractionDigits.padEnd(USD_DECIMALS, "0");
|
|
77
|
+
result += BigInt(padded);
|
|
78
|
+
}
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=parse-usd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-usd.js","sourceRoot":"","sources":["../../src/helpers/parse-usd.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,CAAC;AAEtE,yEAAyE;AACzE,uDAAuD;AACvD,6EAA6E;AAC7E,MAAM,YAAY,GAAG,CAAC,CAAC;AACvB,MAAM,QAAQ,GAAG,QAAU,CAAC,CAAC,qBAAqB;AAElD,iBAAiB;AACjB,0BAA0B;AAC1B,+EAA+E;AAC/E,6EAA6E;AAC7E,+CAA+C;AAC/C,2EAA2E;AAC3E,MAAM,SAAS,GAAG,mCAAmC,CAAC;AAEtD,MAAM,UAAU,QAAQ,CAAC,KAAa;IACpC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,IAAI,mBAAmB,CAC3B,gCAAgC,EAChC,wCAAwC,OAAO,KAAK,EAAE,EACtD,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAW,EAAE,CAC/C,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACrC,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,MAAM,IAAI,mBAAmB,CAC3B,gCAAgC,EAChC,wBAAwB,KAAK,KAAK;YAChC,4CAA4C;YAC5C,gCAAgC,YAAY,sBAAsB;YAClE,iDAAiD,EACnD,EAAE,OAAO,EAAE,EAAE,KAAK,EAAW,EAAE,CAChC,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,EAAE,KAAK,EAAE,YAAY,CAAC,GAAG,KAAK,CAAC;IACtC,sDAAsD;IACtD,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAM,CAAC,CAAC;IAChC,IAAI,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAEjC,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAC/B,yDAAyD;QACzD,MAAM,cAAc,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC7C,wEAAwE;QACxE,sCAAsC;QACtC,MAAM,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;QACxD,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* validateAgentCapAggregate — enforce sum of agent per-agent caps ≤ vault
|
|
3
|
+
* daily cap.
|
|
4
|
+
*
|
|
5
|
+
* Rationale: D12 closes Pentester finding F3 ("$100/agent × 10 agents =
|
|
6
|
+
* $1,000 rolling — vault daily cap $500"). The on-chain program enforces
|
|
7
|
+
* the vault-wide cap and the per-agent cap as separate checks, but both
|
|
8
|
+
* are satisfied simultaneously when the sum of per-agent caps exceeds
|
|
9
|
+
* the vault cap — any single agent inside its own limit can still
|
|
10
|
+
* contribute to a combined burn above the vault ceiling. Blocking this
|
|
11
|
+
* in the SDK before any of `createVault`, `registerAgent`, or
|
|
12
|
+
* `queueAgentPermissionsUpdate` sends the instruction keeps the UX
|
|
13
|
+
* honest: the consumer sees the problem during setup, not at cap time.
|
|
14
|
+
*
|
|
15
|
+
* Called at two entry points:
|
|
16
|
+
* 1. `createVault` (A8) with `existingAgentCaps: []` — validates the
|
|
17
|
+
* initial agent's cap against the new vault's daily cap.
|
|
18
|
+
* 2. `addAgent` / `queueAgentPermissionsUpdate` (Sprint 2) with
|
|
19
|
+
* `existingAgentCaps` populated from the current vault state.
|
|
20
|
+
*
|
|
21
|
+
* A cap of `0n` means the agent is Observer-class and has no spending
|
|
22
|
+
* budget of its own — it contributes zero to the aggregate and is
|
|
23
|
+
* always valid regardless of the existing caps' sum.
|
|
24
|
+
*
|
|
25
|
+
* @throws {SigilSdkDomainError} SIGIL_ERROR__SDK__CAP_EXCEEDED when
|
|
26
|
+
* `sum(existingAgentCaps) + newAgentCap > vaultDailyCap`.
|
|
27
|
+
*/
|
|
28
|
+
export interface ValidateAgentCapAggregateParams {
|
|
29
|
+
/** Vault-wide daily spending cap in USD base units (6-decimal). */
|
|
30
|
+
vaultDailyCap: bigint;
|
|
31
|
+
/**
|
|
32
|
+
* Per-agent caps for every agent already registered on the vault.
|
|
33
|
+
* Empty on first agent (fresh `createVault`); populated from
|
|
34
|
+
* resolved vault state on subsequent `addAgent` calls.
|
|
35
|
+
*/
|
|
36
|
+
existingAgentCaps: readonly bigint[];
|
|
37
|
+
/** Per-agent cap for the agent being added or updated. */
|
|
38
|
+
newAgentCap: bigint;
|
|
39
|
+
}
|
|
40
|
+
export declare function validateAgentCapAggregate(params: ValidateAgentCapAggregateParams): void;
|
|
41
|
+
//# sourceMappingURL=validate-cap-aggregate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-cap-aggregate.d.ts","sourceRoot":"","sources":["../../src/helpers/validate-cap-aggregate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAKH,MAAM,WAAW,+BAA+B;IAC9C,mEAAmE;IACnE,aAAa,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,0DAA0D;IAC1D,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,+BAA+B,GACtC,IAAI,CA4CN"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* validateAgentCapAggregate — enforce sum of agent per-agent caps ≤ vault
|
|
3
|
+
* daily cap.
|
|
4
|
+
*
|
|
5
|
+
* Rationale: D12 closes Pentester finding F3 ("$100/agent × 10 agents =
|
|
6
|
+
* $1,000 rolling — vault daily cap $500"). The on-chain program enforces
|
|
7
|
+
* the vault-wide cap and the per-agent cap as separate checks, but both
|
|
8
|
+
* are satisfied simultaneously when the sum of per-agent caps exceeds
|
|
9
|
+
* the vault cap — any single agent inside its own limit can still
|
|
10
|
+
* contribute to a combined burn above the vault ceiling. Blocking this
|
|
11
|
+
* in the SDK before any of `createVault`, `registerAgent`, or
|
|
12
|
+
* `queueAgentPermissionsUpdate` sends the instruction keeps the UX
|
|
13
|
+
* honest: the consumer sees the problem during setup, not at cap time.
|
|
14
|
+
*
|
|
15
|
+
* Called at two entry points:
|
|
16
|
+
* 1. `createVault` (A8) with `existingAgentCaps: []` — validates the
|
|
17
|
+
* initial agent's cap against the new vault's daily cap.
|
|
18
|
+
* 2. `addAgent` / `queueAgentPermissionsUpdate` (Sprint 2) with
|
|
19
|
+
* `existingAgentCaps` populated from the current vault state.
|
|
20
|
+
*
|
|
21
|
+
* A cap of `0n` means the agent is Observer-class and has no spending
|
|
22
|
+
* budget of its own — it contributes zero to the aggregate and is
|
|
23
|
+
* always valid regardless of the existing caps' sum.
|
|
24
|
+
*
|
|
25
|
+
* @throws {SigilSdkDomainError} SIGIL_ERROR__SDK__CAP_EXCEEDED when
|
|
26
|
+
* `sum(existingAgentCaps) + newAgentCap > vaultDailyCap`.
|
|
27
|
+
*/
|
|
28
|
+
import { SigilSdkDomainError } from "../errors/sdk.js";
|
|
29
|
+
import { SIGIL_ERROR__SDK__CAP_EXCEEDED } from "../errors/codes.js";
|
|
30
|
+
export function validateAgentCapAggregate(params) {
|
|
31
|
+
const { vaultDailyCap, existingAgentCaps, newAgentCap } = params;
|
|
32
|
+
// Reject negative inputs early — bigint doesn't prevent them, but
|
|
33
|
+
// every cap on the system is a magnitude value.
|
|
34
|
+
if (vaultDailyCap < 0n || newAgentCap < 0n) {
|
|
35
|
+
throw new SigilSdkDomainError(SIGIL_ERROR__SDK__CAP_EXCEEDED, `validateAgentCapAggregate received negative input — ` +
|
|
36
|
+
`vaultDailyCap=${vaultDailyCap}, newAgentCap=${newAgentCap}. ` +
|
|
37
|
+
`Caps are unsigned magnitudes.`, { context: { vaultDailyCap, newAgentCap } });
|
|
38
|
+
}
|
|
39
|
+
for (const c of existingAgentCaps) {
|
|
40
|
+
if (c < 0n) {
|
|
41
|
+
throw new SigilSdkDomainError(SIGIL_ERROR__SDK__CAP_EXCEEDED, `validateAgentCapAggregate received a negative existingAgentCap (${c}).`, { context: { existingAgentCaps: [...existingAgentCaps] } });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
let sum = newAgentCap;
|
|
45
|
+
for (const cap of existingAgentCaps)
|
|
46
|
+
sum += cap;
|
|
47
|
+
if (sum > vaultDailyCap) {
|
|
48
|
+
throw new SigilSdkDomainError(SIGIL_ERROR__SDK__CAP_EXCEEDED, `Aggregate per-agent cap (${sum} in 6-decimal USD base units) ` +
|
|
49
|
+
`exceeds vault daily cap (${vaultDailyCap}). Sum of all agents' ` +
|
|
50
|
+
`spendingLimitUsd must be ≤ dailySpendingCapUsd to prevent ` +
|
|
51
|
+
`concurrent-burn attacks where each agent stays within its own ` +
|
|
52
|
+
`limit but the combined outflow breaches the vault's ceiling.`, {
|
|
53
|
+
context: {
|
|
54
|
+
vaultCap: vaultDailyCap,
|
|
55
|
+
sum,
|
|
56
|
+
agents: [...existingAgentCaps, newAgentCap],
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=validate-cap-aggregate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-cap-aggregate.js","sourceRoot":"","sources":["../../src/helpers/validate-cap-aggregate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AAepE,MAAM,UAAU,yBAAyB,CACvC,MAAuC;IAEvC,MAAM,EAAE,aAAa,EAAE,iBAAiB,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IAEjE,kEAAkE;IAClE,gDAAgD;IAChD,IAAI,aAAa,GAAG,EAAE,IAAI,WAAW,GAAG,EAAE,EAAE,CAAC;QAC3C,MAAM,IAAI,mBAAmB,CAC3B,8BAA8B,EAC9B,sDAAsD;YACpD,iBAAiB,aAAa,iBAAiB,WAAW,IAAI;YAC9D,+BAA+B,EACjC,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,WAAW,EAAW,EAAE,CACrD,CAAC;IACJ,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,iBAAiB,EAAE,CAAC;QAClC,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;YACX,MAAM,IAAI,mBAAmB,CAC3B,8BAA8B,EAC9B,mEAAmE,CAAC,IAAI,EACxE,EAAE,OAAO,EAAE,EAAE,iBAAiB,EAAE,CAAC,GAAG,iBAAiB,CAAC,EAAW,EAAE,CACpE,CAAC;QACJ,CAAC;IACH,CAAC;IAED,IAAI,GAAG,GAAG,WAAW,CAAC;IACtB,KAAK,MAAM,GAAG,IAAI,iBAAiB;QAAE,GAAG,IAAI,GAAG,CAAC;IAEhD,IAAI,GAAG,GAAG,aAAa,EAAE,CAAC;QACxB,MAAM,IAAI,mBAAmB,CAC3B,8BAA8B,EAC9B,4BAA4B,GAAG,gCAAgC;YAC7D,4BAA4B,aAAa,wBAAwB;YACjE,4DAA4D;YAC5D,gEAAgE;YAChE,8DAA8D,EAChE;YACE,OAAO,EAAE;gBACP,QAAQ,EAAE,aAAa;gBACvB,GAAG;gBACH,MAAM,EAAE,CAAC,GAAG,iBAAiB,EAAE,WAAW,CAAC;aACnC;SACX,CACF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from "./generated/index.js";
|
|
2
|
-
export { SIGIL_PROGRAM_ADDRESS, FEE_RATE_DENOMINATOR, PROTOCOL_FEE_RATE, MAX_DEVELOPER_FEE_RATE, PROTOCOL_TREASURY, USD_DECIMALS, type UsdBaseUnits, type CapabilityTier, type Slot, usd, capability, slot, MAX_AGENTS_PER_VAULT, MAX_ALLOWED_PROTOCOLS, FULL_CAPABILITY, FULL_PERMISSIONS, MAX_ESCROW_DURATION, TOKEN_PROGRAM_ADDRESS, TOKEN_2022_PROGRAM_ADDRESS, ATA_PROGRAM_ADDRESS, COMPUTE_BUDGET_PROGRAM_ADDRESS, SYSTEM_PROGRAM_ADDRESS, MAX_SLIPPAGE_BPS, EPOCH_DURATION, NUM_EPOCHS, PROTOCOL_MODE_ALL, PROTOCOL_MODE_ALLOWLIST, PROTOCOL_MODE_DENYLIST, USDC_MINT_DEVNET, USDC_MINT_MAINNET, USDT_MINT_DEVNET, USDT_MINT_MAINNET, JUPITER_PROGRAM_ADDRESS, RECOGNIZED_DEFI_PROGRAMS, isStablecoinMint, parseActionType, isSpendingAction, getPositionEffect, validateNetwork, normalizeNetwork, toInstruction, OVERLAY_EPOCH_DURATION, OVERLAY_NUM_EPOCHS, ROLLING_WINDOW_SECONDS, U64_MAX, } from "./types.js";
|
|
1
|
+
export * from "./generated/accounts/index.js";
|
|
2
|
+
export { SIGIL_PROGRAM_ADDRESS, FEE_RATE_DENOMINATOR, PROTOCOL_FEE_RATE, MAX_DEVELOPER_FEE_RATE, PROTOCOL_TREASURY, USD_DECIMALS, type UsdBaseUnits, type CapabilityTier, type Slot, usd, capability, slot, MAX_AGENTS_PER_VAULT, MAX_ALLOWED_PROTOCOLS, FULL_CAPABILITY, FULL_PERMISSIONS, MAX_ESCROW_DURATION, TOKEN_PROGRAM_ADDRESS, TOKEN_2022_PROGRAM_ADDRESS, ATA_PROGRAM_ADDRESS, COMPUTE_BUDGET_PROGRAM_ADDRESS, SYSTEM_PROGRAM_ADDRESS, SUPPORTED_PROTOCOLS, type ProtocolMeta, MAX_SLIPPAGE_BPS, EPOCH_DURATION, NUM_EPOCHS, PROTOCOL_MODE_ALL, PROTOCOL_MODE_ALLOWLIST, PROTOCOL_MODE_DENYLIST, USDC_MINT_DEVNET, USDC_MINT_MAINNET, USDT_MINT_DEVNET, USDT_MINT_MAINNET, JUPITER_PROGRAM_ADDRESS, RECOGNIZED_DEFI_PROGRAMS, isStablecoinMint, parseActionType, isSpendingAction, getPositionEffect, validateNetwork, normalizeNetwork, toInstruction, OVERLAY_EPOCH_DURATION, OVERLAY_NUM_EPOCHS, ROLLING_WINDOW_SECONDS, U64_MAX, } from "./types.js";
|
|
3
3
|
export type { Network, NetworkInput, PositionEffect } from "./types.js";
|
|
4
4
|
export { resolveVaultState, resolveVaultStateForOwner, resolveVaultBudget, getRolling24hUsd, getAgentRolling24hUsd, getProtocolSpend, getSpendingHistory, bytesToAddress, findVaultsByOwner, findEscrowsByVault, findSessionsByVault, getPendingPolicyForVault, getPendingConstraintsForVault, } from "./state-resolver.js";
|
|
5
5
|
export type { EffectiveBudget, ProtocolBudget, SpendingEpoch, ResolvedVaultState, ResolvedVaultStateForOwner, ResolvedBudget, VaultLocator,
|
|
@@ -58,8 +58,13 @@ export type { SigilClientApi } from "./seal.js";
|
|
|
58
58
|
export type { SealParams, SealResult, SigilClientConfig, ClientSealOpts, ExecuteResult, } from "./seal.js";
|
|
59
59
|
export { createVault, createAndSendVault } from "./create-vault.js";
|
|
60
60
|
export type { CreateVaultOptions, CreateVaultResult, CreateAndSendVaultOptions, CreateAndSendVaultResult, } from "./create-vault.js";
|
|
61
|
-
export { VAULT_PRESETS, getPreset, listPresets, presetToCreateVaultFields, } from "./presets.js";
|
|
62
|
-
export type { VaultPreset, PresetName } from "./presets.js";
|
|
61
|
+
export { VAULT_PRESETS, getPreset, listPresets, presetToCreateVaultFields, SAFETY_PRESETS, applySafetyPreset, requireResolvedSafetyPreset, } from "./presets.js";
|
|
62
|
+
export type { VaultPreset, PresetName, SafetyPresetFields, SafetyPresetName, } from "./presets.js";
|
|
63
|
+
export { parseUsd } from "./helpers/parse-usd.js";
|
|
64
|
+
export { initializeVaultAtas, type InitializeVaultAtasParams, } from "./helpers/ata.js";
|
|
65
|
+
export { validateAgentCapAggregate, type ValidateAgentCapAggregateParams, } from "./helpers/validate-cap-aggregate.js";
|
|
66
|
+
export { NOOP_LOGGER, createConsoleLogger, resolveLogger, setSigilModuleLogger, getSigilModuleLogger, type SigilLogger, } from "./logger.js";
|
|
67
|
+
export { SOLANA_DEVNET_GENESIS_HASH, SOLANA_MAINNET_GENESIS_HASH, } from "./seal.js";
|
|
63
68
|
export { buildOwnerTransaction } from "./owner-transaction.js";
|
|
64
69
|
export type { BuildOwnerTransactionParams, OwnerTransactionResult, } from "./owner-transaction.js";
|
|
65
70
|
export { mapPoliciesToVaultParams, findNextVaultId, inscribe, withVault, } from "./inscribe.js";
|
|
@@ -76,7 +81,7 @@ export { ShieldConfigError } from "./core/index.js";
|
|
|
76
81
|
export { evaluatePolicy, enforcePolicy, recordTransaction, } from "./core/index.js";
|
|
77
82
|
export { KNOWN_PROTOCOLS, KNOWN_TOKENS, SYSTEM_PROGRAMS, getTokenInfo, getProtocolName, isKnownProtocol, isSystemProgram, } from "./core/index.js";
|
|
78
83
|
export type { ShieldStorage, SpendEntry, TxEntry } from "./core/index.js";
|
|
79
|
-
export { SigilError as SigilKitError, SigilShieldError, SigilTeeError, SigilX402Error, SigilComposeError, SigilSdkDomainError, SigilRpcError, SIGIL_KIT_VERSION, walk as walkSigilCause, type SigilErrorParameters, type SigilErrorCode, type SigilShieldErrorCode, type SigilTeeErrorCode, type SigilComposeErrorCode, type SigilX402ErrorCode, type SigilSdkErrorCode, type SigilRpcErrorCode, type SigilProgramErrorCode, type SigilErrorContext,
|
|
84
|
+
export { SigilError as SigilKitError, SigilShieldError, SigilTeeError, SigilX402Error, SigilComposeError, SigilSdkDomainError, SigilRpcError, SIGIL_KIT_VERSION, walk as walkSigilCause, type SigilErrorParameters, type SigilErrorCode, type SigilShieldErrorCode, type SigilTeeErrorCode, type SigilComposeErrorCode, type SigilX402ErrorCode, type SigilSdkErrorCode, type SigilRpcErrorCode, type SigilProgramErrorCode, type SigilErrorContext, } from "./errors/index.js";
|
|
80
85
|
/** Per-module discriminated union of x402 errors (viem ErrorType pattern). */
|
|
81
86
|
export type X402ErrorType = import("./x402/errors.js").X402ParseError | import("./x402/errors.js").X402PaymentError | import("./x402/errors.js").X402UnsupportedError | import("./x402/errors.js").X402DestinationBlockedError | import("./x402/errors.js").X402ReplayError;
|
|
82
87
|
/** Per-module discriminated union of TEE errors. */
|
|
@@ -97,6 +102,8 @@ export type ShieldErrorType = import("./core/errors.js").ShieldDeniedError | imp
|
|
|
97
102
|
export type SealErrorType = import("./agent-errors.js").SigilSdkError | import("./core/errors.js").ShieldDeniedError | import("./tee/wallet-types.js").TeeAttestationError | Error;
|
|
98
103
|
/** Per-module discriminated union for OwnerClient (dashboard reads + mutations). */
|
|
99
104
|
export type DashboardErrorType = import("./agent-errors.js").SigilSdkError | import("./core/errors.js").ShieldDeniedError | Error;
|
|
105
|
+
export { createOwnerClient, OwnerClient } from "./dashboard/index.js";
|
|
106
|
+
export type { OwnerClientConfig } from "./dashboard/types.js";
|
|
100
107
|
export { getVaultPnL, getVaultPnLFromState, getVaultTokenBalances, getBalancePnL, BalanceSnapshotStore, } from "./balance-tracker.js";
|
|
101
108
|
export type { TokenBalance, BalanceSnapshot, VaultPnL, BalancePnL, } from "./balance-tracker.js";
|
|
102
109
|
//# sourceMappingURL=index.d.ts.map
|