@usesigil/kit 0.8.1 → 0.11.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 +350 -164
- 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.map +1 -1
- package/dist/balance-tracker.js +2 -1
- 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 +52 -18
- 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/codes.d.ts +8 -2
- package/dist/errors/codes.d.ts.map +1 -1
- package/dist/errors/codes.js +6 -0
- package/dist/errors/codes.js.map +1 -1
- package/dist/errors/context.d.ts +17 -1
- package/dist/errors/context.d.ts.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.map +1 -1
- package/dist/errors/walk.js +2 -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/hooks.d.ts +114 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +118 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +17 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -17
- package/dist/index.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/plugin.d.ts +110 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +119 -0
- package/dist/plugin.js.map +1 -0
- 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.map +1 -1
- package/dist/priority-fees.js +3 -2
- package/dist/priority-fees.js.map +1 -1
- package/dist/react/index.d.ts +69 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +118 -0
- package/dist/react/index.js.map +1 -0
- package/dist/seal.d.ts +113 -15
- package/dist/seal.d.ts.map +1 -1
- package/dist/seal.js +269 -10
- package/dist/seal.js.map +1 -1
- package/dist/shield.d.ts.map +1 -1
- package/dist/shield.js +8 -7
- package/dist/shield.js.map +1 -1
- package/dist/sigil.d.ts +187 -0
- package/dist/sigil.d.ts.map +1 -0
- package/dist/sigil.js +194 -0
- package/dist/sigil.js.map +1 -0
- package/dist/tee/verify.d.ts.map +1 -1
- package/dist/tee/verify.js +6 -5
- 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/types.d.ts +3 -31
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +45 -106
- package/dist/types.js.map +1 -1
- package/dist/vault-handle.d.ts +123 -0
- package/dist/vault-handle.d.ts.map +1 -0
- package/dist/vault-handle.js +136 -0
- package/dist/vault-handle.js.map +1 -0
- 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 +21 -3
package/dist/presets.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Vault creation presets —
|
|
2
|
+
* Vault creation presets — two axes:
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* 1. VAULT_PRESETS: use-case templates (jupiter-swap-bot, perps-trader,
|
|
5
|
+
* lending-optimizer, full-access). Policy + capability configuration
|
|
6
|
+
* for a specific agent role. Used by the dashboard "Quick Setup" cards.
|
|
7
|
+
*
|
|
8
|
+
* 2. SAFETY_PRESETS: timelock + cap defaults (development, production).
|
|
9
|
+
* Orthogonal to use-case — either preset can be composed with any
|
|
10
|
+
* VAULT_PRESET to produce a complete CreateVaultOptions.
|
|
7
11
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
12
|
+
* Runtime fields (rpc, network, owner, agent, feeDestination, vaultId)
|
|
13
|
+
* are NOT included in either axis — the caller supplies those.
|
|
10
14
|
*/
|
|
11
15
|
import type { Address } from "./kit-adapter.js";
|
|
12
16
|
import type { CreateVaultOptions } from "./create-vault.js";
|
|
@@ -120,4 +124,67 @@ export declare function listPresets(): PresetName[];
|
|
|
120
124
|
* ```
|
|
121
125
|
*/
|
|
122
126
|
export declare function presetToCreateVaultFields(name: PresetName): Pick<CreateVaultOptions, "permissions" | "dailySpendingCapUsd" | "maxTransactionSizeUsd" | "maxSlippageBps" | "protocolMode" | "protocols" | "maxLeverageBps" | "maxConcurrentPositions">;
|
|
127
|
+
/**
|
|
128
|
+
* Fields a safety preset can fill. `null` means "caller must supply" —
|
|
129
|
+
* the production preset leaves caps explicit on purpose to force thought
|
|
130
|
+
* about the vault's blast radius before deployment.
|
|
131
|
+
*/
|
|
132
|
+
export interface SafetyPresetFields {
|
|
133
|
+
/** Timelock duration in seconds — owner-initiated policy changes wait this long. */
|
|
134
|
+
timelockDuration: number;
|
|
135
|
+
/** Per-agent spending cap in USD base units, or null if caller must supply. */
|
|
136
|
+
spendingLimitUsd: UsdBaseUnits | null;
|
|
137
|
+
/** Vault-wide daily cap in USD base units, or null if caller must supply. */
|
|
138
|
+
dailySpendingCapUsd: UsdBaseUnits | null;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* SAFETY_PRESETS — timelock + cap bundles for common deployment contexts.
|
|
142
|
+
*
|
|
143
|
+
* `development` — short timelock and small caps for throwaway devnet
|
|
144
|
+
* vaults. The low caps keep a compromised agent's blast radius under
|
|
145
|
+
* $500/day, and the 30-min timelock keeps iteration fast. Suitable for
|
|
146
|
+
* CI runs and live testing.
|
|
147
|
+
*
|
|
148
|
+
* `production` — a 24-hour timelock to give operators time to notice
|
|
149
|
+
* and cancel unexpected policy changes. Caps are deliberately left as
|
|
150
|
+
* `null` — the consumer must supply them explicitly, which forces a
|
|
151
|
+
* conversation about the vault's blast radius before the first real tx.
|
|
152
|
+
*/
|
|
153
|
+
export declare const SAFETY_PRESETS: {
|
|
154
|
+
readonly development: {
|
|
155
|
+
readonly timelockDuration: 1800;
|
|
156
|
+
readonly spendingLimitUsd: UsdBaseUnits;
|
|
157
|
+
readonly dailySpendingCapUsd: UsdBaseUnits;
|
|
158
|
+
};
|
|
159
|
+
readonly production: {
|
|
160
|
+
readonly timelockDuration: 86400;
|
|
161
|
+
readonly spendingLimitUsd: null;
|
|
162
|
+
readonly dailySpendingCapUsd: null;
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
export type SafetyPresetName = keyof typeof SAFETY_PRESETS;
|
|
166
|
+
/**
|
|
167
|
+
* Compose a safety preset with explicit overrides. Overrides win on
|
|
168
|
+
* every field, so callers of `applySafetyPreset("production", { ... })`
|
|
169
|
+
* can narrow the `null` caps with real values while keeping the
|
|
170
|
+
* production timelock.
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* const fields = applySafetyPreset("production", {
|
|
174
|
+
* spendingLimitUsd: usd(1_000_000_000n),
|
|
175
|
+
* dailySpendingCapUsd: usd(10_000_000_000n),
|
|
176
|
+
* });
|
|
177
|
+
* // → { timelockDuration: 86400, spendingLimitUsd: 1_000_000_000n, dailySpendingCapUsd: 10_000_000_000n }
|
|
178
|
+
*/
|
|
179
|
+
export declare function applySafetyPreset(name: SafetyPresetName, overrides?: Partial<SafetyPresetFields>): SafetyPresetFields;
|
|
180
|
+
/**
|
|
181
|
+
* Ergonomic guard: if a safety preset has `null` caps (production), the
|
|
182
|
+
* consumer must resolve them before calling createVault. This helper
|
|
183
|
+
* narrows the preset type to its fully-resolved form or throws.
|
|
184
|
+
*/
|
|
185
|
+
export declare function requireResolvedSafetyPreset(preset: SafetyPresetFields): {
|
|
186
|
+
timelockDuration: number;
|
|
187
|
+
spendingLimitUsd: UsdBaseUnits;
|
|
188
|
+
dailySpendingCapUsd: UsdBaseUnits;
|
|
189
|
+
};
|
|
123
190
|
//# sourceMappingURL=presets.d.ts.map
|
package/dist/presets.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presets.d.ts","sourceRoot":"","sources":["../src/presets.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"presets.d.ts","sourceRoot":"","sources":["../src/presets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,OAAO,EAA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AW,kBAAkB;IACjC,oFAAoF;IACpF,gBAAgB,EAAE,MAAM,CAAC;IACzB,+EAA+E;IAC/E,gBAAgB,EAAE,YAAY,GAAG,IAAI,CAAC;IACtC,6EAA6E;IAC7E,mBAAmB,EAAE,YAAY,GAAG,IAAI,CAAC;CAC1C;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;CAW4B,CAAC;AAExD,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,cAAc,CAAC;AAE3D;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,gBAAgB,EACtB,SAAS,GAAE,OAAO,CAAC,kBAAkB,CAAM,GAC1C,kBAAkB,CAQpB;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,kBAAkB,GAAG;IACvE,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,YAAY,CAAC;IAC/B,mBAAmB,EAAE,YAAY,CAAC;CACnC,CAeA"}
|
package/dist/presets.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Vault creation presets —
|
|
2
|
+
* Vault creation presets — two axes:
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* 1. VAULT_PRESETS: use-case templates (jupiter-swap-bot, perps-trader,
|
|
5
|
+
* lending-optimizer, full-access). Policy + capability configuration
|
|
6
|
+
* for a specific agent role. Used by the dashboard "Quick Setup" cards.
|
|
7
|
+
*
|
|
8
|
+
* 2. SAFETY_PRESETS: timelock + cap defaults (development, production).
|
|
9
|
+
* Orthogonal to use-case — either preset can be composed with any
|
|
10
|
+
* VAULT_PRESET to produce a complete CreateVaultOptions.
|
|
7
11
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
12
|
+
* Runtime fields (rpc, network, owner, agent, feeDestination, vaultId)
|
|
13
|
+
* are NOT included in either axis — the caller supplies those.
|
|
10
14
|
*/
|
|
11
15
|
import { usd } from "./types.js";
|
|
12
16
|
import { FULL_CAPABILITY, PROTOCOL_MODE_ALL, PROTOCOL_MODE_ALLOWLIST, JUPITER_PROGRAM_ADDRESS, } from "./types.js";
|
|
@@ -113,4 +117,69 @@ export function presetToCreateVaultFields(name) {
|
|
|
113
117
|
maxConcurrentPositions: preset.maxConcurrentPositions,
|
|
114
118
|
};
|
|
115
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* SAFETY_PRESETS — timelock + cap bundles for common deployment contexts.
|
|
122
|
+
*
|
|
123
|
+
* `development` — short timelock and small caps for throwaway devnet
|
|
124
|
+
* vaults. The low caps keep a compromised agent's blast radius under
|
|
125
|
+
* $500/day, and the 30-min timelock keeps iteration fast. Suitable for
|
|
126
|
+
* CI runs and live testing.
|
|
127
|
+
*
|
|
128
|
+
* `production` — a 24-hour timelock to give operators time to notice
|
|
129
|
+
* and cancel unexpected policy changes. Caps are deliberately left as
|
|
130
|
+
* `null` — the consumer must supply them explicitly, which forces a
|
|
131
|
+
* conversation about the vault's blast radius before the first real tx.
|
|
132
|
+
*/
|
|
133
|
+
export const SAFETY_PRESETS = {
|
|
134
|
+
development: {
|
|
135
|
+
timelockDuration: 1800, // 30 min
|
|
136
|
+
spendingLimitUsd: usd(100000000n), // $100/agent
|
|
137
|
+
dailySpendingCapUsd: usd(500000000n), // $500/day vault-wide
|
|
138
|
+
},
|
|
139
|
+
production: {
|
|
140
|
+
timelockDuration: 86400, // 24 hours
|
|
141
|
+
spendingLimitUsd: null,
|
|
142
|
+
dailySpendingCapUsd: null,
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Compose a safety preset with explicit overrides. Overrides win on
|
|
147
|
+
* every field, so callers of `applySafetyPreset("production", { ... })`
|
|
148
|
+
* can narrow the `null` caps with real values while keeping the
|
|
149
|
+
* production timelock.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* const fields = applySafetyPreset("production", {
|
|
153
|
+
* spendingLimitUsd: usd(1_000_000_000n),
|
|
154
|
+
* dailySpendingCapUsd: usd(10_000_000_000n),
|
|
155
|
+
* });
|
|
156
|
+
* // → { timelockDuration: 86400, spendingLimitUsd: 1_000_000_000n, dailySpendingCapUsd: 10_000_000_000n }
|
|
157
|
+
*/
|
|
158
|
+
export function applySafetyPreset(name, overrides = {}) {
|
|
159
|
+
const preset = SAFETY_PRESETS[name];
|
|
160
|
+
return {
|
|
161
|
+
timelockDuration: overrides.timelockDuration ?? preset.timelockDuration,
|
|
162
|
+
spendingLimitUsd: overrides.spendingLimitUsd ?? preset.spendingLimitUsd,
|
|
163
|
+
dailySpendingCapUsd: overrides.dailySpendingCapUsd ?? preset.dailySpendingCapUsd,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Ergonomic guard: if a safety preset has `null` caps (production), the
|
|
168
|
+
* consumer must resolve them before calling createVault. This helper
|
|
169
|
+
* narrows the preset type to its fully-resolved form or throws.
|
|
170
|
+
*/
|
|
171
|
+
export function requireResolvedSafetyPreset(preset) {
|
|
172
|
+
if (preset.spendingLimitUsd === null || preset.dailySpendingCapUsd === null) {
|
|
173
|
+
throw new Error(`Safety preset has unresolved caps. The "production" preset ` +
|
|
174
|
+
`intentionally leaves spendingLimitUsd and dailySpendingCapUsd ` +
|
|
175
|
+
`null so the caller supplies them explicitly. Pass both to ` +
|
|
176
|
+
`applySafetyPreset("production", { ... }) before using the ` +
|
|
177
|
+
`result with createVault.`);
|
|
178
|
+
}
|
|
179
|
+
return {
|
|
180
|
+
timelockDuration: preset.timelockDuration,
|
|
181
|
+
spendingLimitUsd: preset.spendingLimitUsd,
|
|
182
|
+
dailySpendingCapUsd: preset.dailySpendingCapUsd,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
116
185
|
//# sourceMappingURL=presets.js.map
|
package/dist/presets.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presets.js","sourceRoot":"","sources":["../src/presets.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"presets.js","sourceRoot":"","sources":["../src/presets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,EAAE,GAAG,EAAqB,MAAM,YAAY,CAAC;AACpD,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,YAAY,CAAC;AAEpB,gFAAgF;AAEhF,MAAM,mBAAmB,GACvB,8CAAyD,CAAC;AAC5D,MAAM,oBAAoB,GACxB,6CAAwD,CAAC;AAC3D,MAAM,mBAAmB,GACvB,6CAAwD,CAAC;AA4C3D,+EAA+E;AAE/E,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,kBAAkB,EAAE;QAClB,KAAK,EAAE,kBAAkB;QACzB,WAAW,EACT,mGAAmG;QACrG,UAAU,EAAE,eAAe;QAC3B,WAAW,EAAE,eAAe;QAC5B,mBAAmB,EAAE,GAAG,CAAC,UAAY,CAAC,EAAE,OAAO;QAC/C,qBAAqB,EAAE,GAAG,CAAC,UAAY,CAAC,EAAE,OAAO;QACjD,cAAc,EAAE,GAAG,EAAE,KAAK;QAC1B,YAAY,EAAE,uBAAuB;QACrC,SAAS,EAAE,CAAC,uBAAuB,CAAC;QACpC,cAAc,EAAE,CAAC;QACjB,sBAAsB,EAAE,CAAC;KAC1B;IACD,cAAc,EAAE;QACd,KAAK,EAAE,cAAc;QACrB,WAAW,EACT,yFAAyF;QAC3F,UAAU,EAAE,eAAe;QAC3B,WAAW,EAAE,eAAe;QAC5B,mBAAmB,EAAE,GAAG,CAAC,WAAc,CAAC,EAAE,SAAS;QACnD,qBAAqB,EAAE,GAAG,CAAC,WAAc,CAAC,EAAE,SAAS;QACrD,cAAc,EAAE,GAAG,EAAE,KAAK;QAC1B,YAAY,EAAE,uBAAuB;QACrC,SAAS,EAAE,CAAC,uBAAuB,EAAE,mBAAmB,CAAC;QACz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G;AACH,MAAM,UAAU,2BAA2B,CAAC,MAA0B;IAKpE,IAAI,MAAM,CAAC,gBAAgB,KAAK,IAAI,IAAI,MAAM,CAAC,mBAAmB,KAAK,IAAI,EAAE,CAAC;QAC5E,MAAM,IAAI,KAAK,CACb,6DAA6D;YAC3D,gEAAgE;YAChE,4DAA4D;YAC5D,4DAA4D;YAC5D,0BAA0B,CAC7B,CAAC;IACJ,CAAC;IACD,OAAO;QACL,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;QACzC,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;QACzC,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;KAChD,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"priority-fees.d.ts","sourceRoot":"","sources":["../src/priority-fees.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"priority-fees.d.ts","sourceRoot":"","sources":["../src/priority-fees.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAUvE,eAAO,MAAM,iBAAiB,SAAU,CAAC;AACzC,eAAO,MAAM,eAAe,SAAU,CAAC;AACvC,eAAO,MAAM,oBAAoB,SAAU,CAAC;AAC5C,eAAO,MAAM,cAAc,SAAU,CAAC;AACtC,eAAO,MAAM,eAAe,SAAU,CAAC;AACvC,eAAO,MAAM,QAAQ,SAAU,CAAC;AAChC,eAAO,MAAM,cAAc,SAAU,CAAC;AACtC,eAAO,MAAM,mBAAmB,SAAU,CAAC;AAC3C,eAAO,MAAM,iBAAiB,SAAU,CAAC;AACzC,eAAO,MAAM,eAAe,SAAU,CAAC;AAEvC;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,gBAAgB,EAAE,WAAW,EAAE,GAAG,MAAM,CAkB1E;AAID,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;AAEpE,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,QAAQ,CAAC;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,YAAY,CAAC,EAAE,aAAa,CAAC;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAqBD;;;;;;GAMG;AACH,qBAAa,oBAAoB;IAM7B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,GAAG;IANtB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA8B;IACrD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAwC;IAC9D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;gBAGhB,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,GAAG,CAAC,YAAY,CAAC,GAAG,IAAI,EAC9C,MAAM,CAAC,EAAE,iBAAiB;IAiBtB,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;YAmCxC,cAAc;YA6Cd,WAAW;CA+B1B"}
|
package/dist/priority-fees.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* 3-layer fallback: Helius → Kit RPC → static.
|
|
6
6
|
*/
|
|
7
7
|
import { redactCause } from "./network-errors.js";
|
|
8
|
+
import { getSigilModuleLogger } from "./logger.js";
|
|
8
9
|
import { SUPPORTED_PROTOCOLS } from "./types.js";
|
|
9
10
|
// Jupiter multi-hop needs special handling (>2 instructions = multi-hop)
|
|
10
11
|
const JUPITER_PROGRAM = "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4";
|
|
@@ -146,7 +147,7 @@ export class PriorityFeeEstimator {
|
|
|
146
147
|
// default fee with no visibility. A warn is cheap and makes API
|
|
147
148
|
// shape drift detectable in production.
|
|
148
149
|
const cause = redactCause(err);
|
|
149
|
-
|
|
150
|
+
getSigilModuleLogger().warn(`[priority-fees] Helius estimate failed — falling back: ${cause.message ?? cause.name ?? cause.code ?? "unknown"}`);
|
|
150
151
|
return null;
|
|
151
152
|
}
|
|
152
153
|
}
|
|
@@ -171,7 +172,7 @@ export class PriorityFeeEstimator {
|
|
|
171
172
|
// Same rationale as the Helius path — log so a failing RPC doesn't
|
|
172
173
|
// silently push users to the fallback fee without trace.
|
|
173
174
|
const cause = redactCause(err);
|
|
174
|
-
|
|
175
|
+
getSigilModuleLogger().warn(`[priority-fees] RPC getRecentPrioritizationFees failed — falling back: ${cause.message ?? cause.name ?? cause.code ?? "unknown"}`);
|
|
175
176
|
return null;
|
|
176
177
|
}
|
|
177
178
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"priority-fees.js","sourceRoot":"","sources":["../src/priority-fees.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,yEAAyE;AACzE,MAAM,eAAe,GAAG,6CAA6C,CAAC;AAEtE,+EAA+E;AAE/E,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAC;AACzC,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC;AACvC,MAAM,CAAC,MAAM,oBAAoB,GAAG,OAAO,CAAC;AAC5C,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC;AACtC,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC;AACvC,MAAM,CAAC,MAAM,QAAQ,GAAG,OAAO,CAAC;AAChC,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC;AACtC,MAAM,CAAC,MA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CACpB,IAAI,CAAC,IAAI,CAAC,CAAC,UAAU,GAAG,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,EACjD,MAAM,CAAC,MAAM,GAAG,CAAC,CAClB,CAAC;YAEF,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACtB,mEAAmE;YACnE,yDAAyD;YACzD,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;YAC/B,oBAAoB,EAAE,CAAC,IAAI,CACzB,0EAA0E,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,IAAI,SAAS,EAAE,CACnI,CAAC;YACF,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @usesigil/kit/react — React hooks for Sigil vault state.
|
|
3
|
+
*
|
|
4
|
+
* Four TanStack Query wrappers around `SigilVault` methods:
|
|
5
|
+
* - `useVaultBudget(vault)` — useQuery wrapping vault.budget()
|
|
6
|
+
* - `useVaultState(vault)` — useQuery wrapping the agent-side
|
|
7
|
+
* state-resolver primitive
|
|
8
|
+
* - `useOverview(vault, opts?)` — useQuery wrapping vault.overview()
|
|
9
|
+
* (owner-only; throws if called on an agent-only handle)
|
|
10
|
+
* - `useExecute(vault)` — useMutation wrapping vault.execute()
|
|
11
|
+
*
|
|
12
|
+
* Peer dependencies are **optional**: React and `@tanstack/react-query`
|
|
13
|
+
* are declared as peer deps in `package.json` under `peerDependenciesMeta`
|
|
14
|
+
* with `optional: true`. Consumers who don't use React never install them
|
|
15
|
+
* and never see a warning. Consumers who do import this subpath must
|
|
16
|
+
* install both.
|
|
17
|
+
*
|
|
18
|
+
* Query keys: every query key is namespaced under `"sigil"` so a
|
|
19
|
+
* consumer's existing TanStack cache never collides with SDK keys.
|
|
20
|
+
* Keys are derived from `vault.address` so multi-vault apps share keys
|
|
21
|
+
* per-vault without manual namespacing.
|
|
22
|
+
*
|
|
23
|
+
* Cache invalidation: the SDK does NOT call `queryClient.invalidateQueries`
|
|
24
|
+
* on its own. After an `execute()` mutation, the consumer decides which
|
|
25
|
+
* queries to refetch — typically `useExecute` is wrapped with a custom
|
|
26
|
+
* `onSuccess` that invalidates the specific vault keys.
|
|
27
|
+
*/
|
|
28
|
+
import type { SigilVault } from "../vault-handle.js";
|
|
29
|
+
import type { GetOverviewOptions } from "../dashboard/types.js";
|
|
30
|
+
/**
|
|
31
|
+
* Build a stable query key for a vault-bound query. Namespaced under
|
|
32
|
+
* `"sigil"` so the keys never collide with consumer app keys.
|
|
33
|
+
*/
|
|
34
|
+
export declare function sigilQueryKey(vault: SigilVault, sub: "state" | "budget" | "overview"): readonly unknown[];
|
|
35
|
+
/**
|
|
36
|
+
* `useVaultBudget(vault)` — read the vault's current rolling-24h
|
|
37
|
+
* budget via TanStack Query. Cheap call — re-runs as often as the
|
|
38
|
+
* query's `staleTime` allows (TQ default: 0ms).
|
|
39
|
+
*
|
|
40
|
+
* Returns the raw TQ `UseQueryResult<ResolvedBudget>` so consumers
|
|
41
|
+
* can read `.data`, `.isLoading`, `.error`, etc.
|
|
42
|
+
*/
|
|
43
|
+
export declare function useVaultBudget(vault: SigilVault): any;
|
|
44
|
+
/**
|
|
45
|
+
* `useVaultState(vault)` — alias for `useVaultBudget` today; kept as
|
|
46
|
+
* a separate hook so Sprint 3 can swap in a richer state resolver
|
|
47
|
+
* without changing the consumer call shape.
|
|
48
|
+
*/
|
|
49
|
+
export declare function useVaultState(vault: SigilVault): any;
|
|
50
|
+
/**
|
|
51
|
+
* `useOverview(vault, opts?)` — read the full `OverviewData` via
|
|
52
|
+
* `OwnerClient.getOverview()`. Requires an owner signer on the
|
|
53
|
+
* handle — the query throws `SIGIL_ERROR__SDK__OWNER_REQUIRED` when
|
|
54
|
+
* called on an agent-only handle. TanStack surfaces the throw via
|
|
55
|
+
* `result.error`.
|
|
56
|
+
*/
|
|
57
|
+
export declare function useOverview(vault: SigilVault, opts?: GetOverviewOptions): any;
|
|
58
|
+
/**
|
|
59
|
+
* `useExecute(vault)` — TanStack mutation wrapping `vault.execute`.
|
|
60
|
+
* Usage:
|
|
61
|
+
* const { mutate, mutateAsync, isPending } = useExecute(vault);
|
|
62
|
+
* mutate({ instructions: [...], opts: { tokenMint, amount, ... } });
|
|
63
|
+
*
|
|
64
|
+
* Consumer is responsible for `queryClient.invalidateQueries` on
|
|
65
|
+
* success — the SDK does not force a refetch of any specific keys,
|
|
66
|
+
* so the consumer's cache hygiene stays under their control.
|
|
67
|
+
*/
|
|
68
|
+
export declare function useExecute(vault: SigilVault): any;
|
|
69
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AA6BH,OAAO,KAAK,EAAE,UAAU,EAA4B,MAAM,oBAAoB,CAAC;AAI/E,OAAO,KAAK,EAAgB,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAI9E;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,UAAU,EACjB,GAAG,EAAE,OAAO,GAAG,QAAQ,GAAG,UAAU,GACnC,SAAS,OAAO,EAAE,CAEpB;AAID;;;;;;;GAOG;AAEH,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,GAAG,CAMrD;AAED;;;;GAIG;AAEH,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,GAAG,CAMpD;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,UAAU,EACjB,IAAI,CAAC,EAAE,kBAAkB,GAExB,GAAG,CAML;AAED;;;;;;;;;GASG;AAEH,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,GAAG,CAUjD"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @usesigil/kit/react — React hooks for Sigil vault state.
|
|
3
|
+
*
|
|
4
|
+
* Four TanStack Query wrappers around `SigilVault` methods:
|
|
5
|
+
* - `useVaultBudget(vault)` — useQuery wrapping vault.budget()
|
|
6
|
+
* - `useVaultState(vault)` — useQuery wrapping the agent-side
|
|
7
|
+
* state-resolver primitive
|
|
8
|
+
* - `useOverview(vault, opts?)` — useQuery wrapping vault.overview()
|
|
9
|
+
* (owner-only; throws if called on an agent-only handle)
|
|
10
|
+
* - `useExecute(vault)` — useMutation wrapping vault.execute()
|
|
11
|
+
*
|
|
12
|
+
* Peer dependencies are **optional**: React and `@tanstack/react-query`
|
|
13
|
+
* are declared as peer deps in `package.json` under `peerDependenciesMeta`
|
|
14
|
+
* with `optional: true`. Consumers who don't use React never install them
|
|
15
|
+
* and never see a warning. Consumers who do import this subpath must
|
|
16
|
+
* install both.
|
|
17
|
+
*
|
|
18
|
+
* Query keys: every query key is namespaced under `"sigil"` so a
|
|
19
|
+
* consumer's existing TanStack cache never collides with SDK keys.
|
|
20
|
+
* Keys are derived from `vault.address` so multi-vault apps share keys
|
|
21
|
+
* per-vault without manual namespacing.
|
|
22
|
+
*
|
|
23
|
+
* Cache invalidation: the SDK does NOT call `queryClient.invalidateQueries`
|
|
24
|
+
* on its own. After an `execute()` mutation, the consumer decides which
|
|
25
|
+
* queries to refetch — typically `useExecute` is wrapped with a custom
|
|
26
|
+
* `onSuccess` that invalidates the specific vault keys.
|
|
27
|
+
*/
|
|
28
|
+
// ─── Peer-dep shim ──────────────────────────────────────────────────────────
|
|
29
|
+
//
|
|
30
|
+
// We can't `import { useQuery }` statically because doing so would make
|
|
31
|
+
// `@tanstack/react-query` a hard dependency at module-load time — a
|
|
32
|
+
// consumer who uses `@usesigil/kit` without touching `/react` would
|
|
33
|
+
// see a resolution error on every kit import. Instead, this subpath
|
|
34
|
+
// imports TanStack lazily via `require()` at the use site, inside the
|
|
35
|
+
// hook body. Each hook calls a one-time dynamic import that throws a
|
|
36
|
+
// clear error if the peer dep isn't installed.
|
|
37
|
+
function requireTanstack() {
|
|
38
|
+
try {
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
40
|
+
return require("@tanstack/react-query");
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
throw new Error("@usesigil/kit/react requires `@tanstack/react-query` as a peer dependency. " +
|
|
44
|
+
"Install it via `npm install @tanstack/react-query react` and retry.");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// ─── Query-key helpers ──────────────────────────────────────────────────────
|
|
48
|
+
/**
|
|
49
|
+
* Build a stable query key for a vault-bound query. Namespaced under
|
|
50
|
+
* `"sigil"` so the keys never collide with consumer app keys.
|
|
51
|
+
*/
|
|
52
|
+
export function sigilQueryKey(vault, sub) {
|
|
53
|
+
return ["sigil", vault.address, sub];
|
|
54
|
+
}
|
|
55
|
+
// ─── Hooks ──────────────────────────────────────────────────────────────────
|
|
56
|
+
/**
|
|
57
|
+
* `useVaultBudget(vault)` — read the vault's current rolling-24h
|
|
58
|
+
* budget via TanStack Query. Cheap call — re-runs as often as the
|
|
59
|
+
* query's `staleTime` allows (TQ default: 0ms).
|
|
60
|
+
*
|
|
61
|
+
* Returns the raw TQ `UseQueryResult<ResolvedBudget>` so consumers
|
|
62
|
+
* can read `.data`, `.isLoading`, `.error`, etc.
|
|
63
|
+
*/
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
65
|
+
export function useVaultBudget(vault) {
|
|
66
|
+
const { useQuery } = requireTanstack();
|
|
67
|
+
return useQuery({
|
|
68
|
+
queryKey: sigilQueryKey(vault, "budget"),
|
|
69
|
+
queryFn: () => vault.budget(),
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* `useVaultState(vault)` — alias for `useVaultBudget` today; kept as
|
|
74
|
+
* a separate hook so Sprint 3 can swap in a richer state resolver
|
|
75
|
+
* without changing the consumer call shape.
|
|
76
|
+
*/
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
78
|
+
export function useVaultState(vault) {
|
|
79
|
+
const { useQuery } = requireTanstack();
|
|
80
|
+
return useQuery({
|
|
81
|
+
queryKey: sigilQueryKey(vault, "state"),
|
|
82
|
+
queryFn: () => vault.budget(),
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* `useOverview(vault, opts?)` — read the full `OverviewData` via
|
|
87
|
+
* `OwnerClient.getOverview()`. Requires an owner signer on the
|
|
88
|
+
* handle — the query throws `SIGIL_ERROR__SDK__OWNER_REQUIRED` when
|
|
89
|
+
* called on an agent-only handle. TanStack surfaces the throw via
|
|
90
|
+
* `result.error`.
|
|
91
|
+
*/
|
|
92
|
+
export function useOverview(vault, opts) {
|
|
93
|
+
const { useQuery } = requireTanstack();
|
|
94
|
+
return useQuery({
|
|
95
|
+
queryKey: [...sigilQueryKey(vault, "overview"), opts ?? null],
|
|
96
|
+
queryFn: () => vault.overview(opts),
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* `useExecute(vault)` — TanStack mutation wrapping `vault.execute`.
|
|
101
|
+
* Usage:
|
|
102
|
+
* const { mutate, mutateAsync, isPending } = useExecute(vault);
|
|
103
|
+
* mutate({ instructions: [...], opts: { tokenMint, amount, ... } });
|
|
104
|
+
*
|
|
105
|
+
* Consumer is responsible for `queryClient.invalidateQueries` on
|
|
106
|
+
* success — the SDK does not force a refetch of any specific keys,
|
|
107
|
+
* so the consumer's cache hygiene stays under their control.
|
|
108
|
+
*/
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
110
|
+
export function useExecute(vault) {
|
|
111
|
+
const { useMutation } = requireTanstack();
|
|
112
|
+
return useMutation({
|
|
113
|
+
mutationFn: async (args) => {
|
|
114
|
+
return vault.execute(args.instructions, args.opts);
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAKH,+EAA+E;AAC/E,EAAE;AACF,wEAAwE;AACxE,oEAAoE;AACpE,oEAAoE;AACpE,oEAAoE;AACpE,sEAAsE;AACtE,qEAAqE;AACrE,+CAA+C;AAE/C,SAAS,eAAe;IACtB,IAAI,CAAC;QACH,iEAAiE;QACjE,OAAO,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAC1C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,6EAA6E;YAC3E,qEAAqE,CACxE,CAAC;IACJ,CAAC;AACH,CAAC;AAUD,+EAA+E;AAE/E;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC3B,KAAiB,EACjB,GAAoC;IAEpC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,GAAG,CAAU,CAAC;AAChD,CAAC;AAED,+EAA+E;AAE/E;;;;;;;GAOG;AACH,8DAA8D;AAC9D,MAAM,UAAU,cAAc,CAAC,KAAiB;IAC9C,MAAM,EAAE,QAAQ,EAAE,GAAG,eAAe,EAAE,CAAC;IACvC,OAAO,QAAQ,CAAC;QACd,QAAQ,EAAE,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC;QACxC,OAAO,EAAE,GAA4B,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE;KACvD,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,8DAA8D;AAC9D,MAAM,UAAU,aAAa,CAAC,KAAiB;IAC7C,MAAM,EAAE,QAAQ,EAAE,GAAG,eAAe,EAAE,CAAC;IACvC,OAAO,QAAQ,CAAC;QACd,QAAQ,EAAE,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC;QACvC,OAAO,EAAE,GAA4B,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE;KACvD,CAAC,CAAC;AACL,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CACzB,KAAiB,EACjB,IAAyB;IAGzB,MAAM,EAAE,QAAQ,EAAE,GAAG,eAAe,EAAE,CAAC;IACvC,OAAO,QAAQ,CAAC;QACd,QAAQ,EAAE,CAAC,GAAG,aAAa,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE,IAAI,IAAI,IAAI,CAAU;QACtE,OAAO,EAAE,GAA0B,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;KAC3D,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;GASG;AACH,8DAA8D;AAC9D,MAAM,UAAU,UAAU,CAAC,KAAiB;IAC1C,MAAM,EAAE,WAAW,EAAE,GAAG,eAAe,EAAE,CAAC;IAC1C,OAAO,WAAW,CAAC;QACjB,UAAU,EAAE,KAAK,EAAE,IAGlB,EAA0B,EAAE;YAC3B,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QACrD,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
package/dist/seal.d.ts
CHANGED
|
@@ -79,6 +79,18 @@ export interface SealParams {
|
|
|
79
79
|
maxCacheAgeMs?: number;
|
|
80
80
|
/** Additional agent ATA → vault ATA replacements for multi-token DeFi routes. */
|
|
81
81
|
additionalAtaReplacements?: Map<Address, Address>;
|
|
82
|
+
/**
|
|
83
|
+
* Sprint 2 (B3): optional lifecycle hooks. Observe-only except
|
|
84
|
+
* `onBeforeBuild` which may return `{ skipSeal: true, reason }` to
|
|
85
|
+
* cleanly abort before any RPC. Hook throws are caught and logged
|
|
86
|
+
* via `getSigilModuleLogger().warn` — they do NOT propagate.
|
|
87
|
+
*/
|
|
88
|
+
hooks?: import("./hooks.js").SealHooks;
|
|
89
|
+
/**
|
|
90
|
+
* Sprint 2 (B3): stable correlation ID. When omitted, `seal()`
|
|
91
|
+
* generates one via `newCorrelationId()` at the top of the call.
|
|
92
|
+
*/
|
|
93
|
+
correlationId?: string;
|
|
82
94
|
}
|
|
83
95
|
export interface SealResult {
|
|
84
96
|
ok: true;
|
|
@@ -125,6 +137,50 @@ export interface SigilClientConfig {
|
|
|
125
137
|
tokenMint: Address;
|
|
126
138
|
amount: bigint;
|
|
127
139
|
}) => void;
|
|
140
|
+
/**
|
|
141
|
+
* Structured logger for SDK-internal diagnostics (ALT cache warnings,
|
|
142
|
+
* RPC retries, shield advisories, etc.). When provided to
|
|
143
|
+
* `SigilClient.create()`, it is installed via `setSigilModuleLogger()`
|
|
144
|
+
* so every leaf utility in the SDK routes output through it.
|
|
145
|
+
*
|
|
146
|
+
* Default: `NOOP_LOGGER` — no output.
|
|
147
|
+
*
|
|
148
|
+
* For local development, pass `createConsoleLogger()`. For production,
|
|
149
|
+
* wrap your preferred structured logger (pino, bunyan, OpenTelemetry)
|
|
150
|
+
* in the `SigilLogger` interface shape.
|
|
151
|
+
*/
|
|
152
|
+
logger?: import("./logger.js").SigilLogger;
|
|
153
|
+
/**
|
|
154
|
+
* Skip the `getGenesisHash()` network assertion at client construction.
|
|
155
|
+
*
|
|
156
|
+
* **Do not set this in production.** The assertion prevents a very
|
|
157
|
+
* common misconfiguration — pointing a mainnet-built SDK instance at a
|
|
158
|
+
* devnet RPC (or vice versa) — from reaching transaction submission,
|
|
159
|
+
* where it would silently succeed against the wrong cluster and drain
|
|
160
|
+
* funds that weren't supposed to move.
|
|
161
|
+
*
|
|
162
|
+
* Opt-outs are provided only for two narrow cases:
|
|
163
|
+
* - Local Surfpool / LiteSVM test harnesses whose genesis hash does
|
|
164
|
+
* not match the canonical devnet or mainnet hashes.
|
|
165
|
+
* - CI jobs where the RPC is stubbed entirely.
|
|
166
|
+
*
|
|
167
|
+
* When set to `true`, a deprecation-tier warning is emitted via the
|
|
168
|
+
* injected logger so the bypass is observable in audit trails.
|
|
169
|
+
*/
|
|
170
|
+
skipGenesisAssertion?: boolean;
|
|
171
|
+
/**
|
|
172
|
+
* Sprint 2 (B3): client-level seal hooks. Fire on every `seal()` +
|
|
173
|
+
* `executeAndConfirm()` call. Compose with per-call hooks
|
|
174
|
+
* (`ClientSealOpts.hooks`) via `composeHooks(clientHooks, perCall)`
|
|
175
|
+
* — client hooks run first.
|
|
176
|
+
*/
|
|
177
|
+
hooks?: import("./hooks.js").SealHooks;
|
|
178
|
+
/**
|
|
179
|
+
* Sprint 2 (B4): policy plugins. Run in registration order inside
|
|
180
|
+
* `seal()` pre-flight after `resolveVaultState`; first rejection
|
|
181
|
+
* throws `SigilSdkDomainError(SIGIL_ERROR__SDK__PLUGIN_REJECTED)`.
|
|
182
|
+
*/
|
|
183
|
+
plugins?: readonly import("./plugin.js").SigilPolicyPlugin[];
|
|
128
184
|
}
|
|
129
185
|
/**
|
|
130
186
|
* Options for `client.seal()`.
|
|
@@ -145,6 +201,16 @@ export interface ClientSealOpts {
|
|
|
145
201
|
cachedState?: ResolvedVaultState;
|
|
146
202
|
maxCacheAgeMs?: number;
|
|
147
203
|
additionalAtaReplacements?: Map<Address, Address>;
|
|
204
|
+
/**
|
|
205
|
+
* Sprint 2 (B3): per-call hooks. Compose with client-level hooks
|
|
206
|
+
* (`SigilClientConfig.hooks`) — client hooks run first, then per-call.
|
|
207
|
+
*/
|
|
208
|
+
hooks?: import("./hooks.js").SealHooks;
|
|
209
|
+
/**
|
|
210
|
+
* Sprint 2 (B3): stable correlation ID for trace correlation.
|
|
211
|
+
* Defaults to a fresh `newCorrelationId()` if omitted.
|
|
212
|
+
*/
|
|
213
|
+
correlationId?: string;
|
|
148
214
|
}
|
|
149
215
|
export interface ExecuteResult {
|
|
150
216
|
signature: string;
|
|
@@ -206,20 +272,12 @@ export interface SigilClientApi {
|
|
|
206
272
|
* ```
|
|
207
273
|
*/
|
|
208
274
|
export declare function createSigilClient(config: SigilClientConfig): SigilClientApi;
|
|
209
|
-
/**
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
* Migration:
|
|
216
|
-
* ```ts
|
|
217
|
-
* // Before:
|
|
218
|
-
* const client = new SigilClient({ rpc, vault, agent, network });
|
|
219
|
-
* // After:
|
|
220
|
-
* const client = createSigilClient({ rpc, vault, agent, network });
|
|
221
|
-
* ```
|
|
222
|
-
*/
|
|
275
|
+
/** Canonical devnet genesis hash — Solana cluster identifier. */
|
|
276
|
+
export declare const SOLANA_DEVNET_GENESIS_HASH = "EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG";
|
|
277
|
+
/** Canonical mainnet-beta genesis hash — Solana cluster identifier. */
|
|
278
|
+
export declare const SOLANA_MAINNET_GENESIS_HASH = "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d";
|
|
279
|
+
/** @internal — exposed for test resets only. */
|
|
280
|
+
export declare function _resetGenesisHashCache(): void;
|
|
223
281
|
export declare class SigilClient {
|
|
224
282
|
private readonly blockhashCacheInstance;
|
|
225
283
|
private readonly altCacheInstance;
|
|
@@ -228,7 +286,47 @@ export declare class SigilClient {
|
|
|
228
286
|
readonly vault: Address;
|
|
229
287
|
readonly agent: TransactionSigner;
|
|
230
288
|
readonly network: "devnet" | "mainnet";
|
|
231
|
-
|
|
289
|
+
/**
|
|
290
|
+
* Private constructor — Sprint 2 carryover.
|
|
291
|
+
*
|
|
292
|
+
* Sprint 1 deprecated `new SigilClient(config)` in favor of the
|
|
293
|
+
* async factory `SigilClient.create(config)` which runs the
|
|
294
|
+
* genesis-hash assertion. Sprint 2 completes the migration by
|
|
295
|
+
* making the constructor `private`: external callers now get a TS
|
|
296
|
+
* compile error, and the runtime guard below throws on JS consumers
|
|
297
|
+
* that cast through `any` to bypass the compile-time check.
|
|
298
|
+
*
|
|
299
|
+
* The class remains exported so:
|
|
300
|
+
* - `SigilClient.create()` static factory still works.
|
|
301
|
+
* - `instanceof SigilClient` checks in tests still resolve.
|
|
302
|
+
* - The type `SigilClient` is still a first-class position.
|
|
303
|
+
*
|
|
304
|
+
* @internal — construction token is a module-private symbol only
|
|
305
|
+
* `SigilClient.create()` holds a reference to.
|
|
306
|
+
*/
|
|
307
|
+
private constructor();
|
|
308
|
+
/**
|
|
309
|
+
* Async factory — constructs a `SigilClient` and asserts the RPC's
|
|
310
|
+
* genesis hash matches the configured `network`. Preferred entry
|
|
311
|
+
* point for production use.
|
|
312
|
+
*
|
|
313
|
+
* Throws `SigilRpcError` if:
|
|
314
|
+
* - the RPC fails 3 consecutive `getGenesisHash()` attempts, or
|
|
315
|
+
* - the returned genesis hash does not match the canonical devnet /
|
|
316
|
+
* mainnet hash.
|
|
317
|
+
*
|
|
318
|
+
* Set `config.skipGenesisAssertion: true` to bypass for local test
|
|
319
|
+
* harnesses (Surfpool, LiteSVM) — a warning is emitted in that case.
|
|
320
|
+
*
|
|
321
|
+
* @example
|
|
322
|
+
* ```ts
|
|
323
|
+
* const client = await SigilClient.create({
|
|
324
|
+
* rpc, vault, agent, network: "devnet",
|
|
325
|
+
* logger: createConsoleLogger(),
|
|
326
|
+
* });
|
|
327
|
+
* ```
|
|
328
|
+
*/
|
|
329
|
+
static create(config: SigilClientConfig): Promise<SigilClient>;
|
|
232
330
|
/**
|
|
233
331
|
* Seal DeFi instructions with Sigil security.
|
|
234
332
|
*
|