@prktsol/prkt 1.0.0 → 1.0.1
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/.env.devnet.all-protocols.example +5 -0
- package/.env.example +7 -0
- package/CLI.md +24 -0
- package/CLI_QUICKSTART.md +16 -0
- package/README.md +59 -12
- package/dist/agent/AgentManager.d.ts +61 -0
- package/dist/agent/AgentRuntime.d.ts +28 -0
- package/dist/agent/DecisionEngine.d.ts +51 -0
- package/dist/agent/MockPriceFeed.d.ts +10 -0
- package/dist/agent/intents/types.d.ts +35 -0
- package/dist/agent/new-index.d.ts +9 -0
- package/dist/agent/policyFactory.d.ts +2 -0
- package/dist/agent/registry/AgentRegistry.d.ts +11 -0
- package/dist/agent/runner/AgentRunner.d.ts +51 -0
- package/dist/agent/runner/AgentRunner.js +59 -2
- package/dist/agent/strategies/MemoHeartbeatStrategy.d.ts +6 -0
- package/dist/agent/strategies/SimpleScriptedTransferStrategy.d.ts +12 -0
- package/dist/agent/strategies/TokenRebalancerStrategy.d.ts +13 -0
- package/dist/agent/strategies/TreasuryDistributorStrategy.d.ts +12 -0
- package/dist/agent/strategies/UniversalDeFiStrategy.d.ts +22 -0
- package/dist/agent/types/AgentContext.d.ts +28 -0
- package/dist/anchoring/SessionAnchor.d.ts +42 -0
- package/dist/anchoring/SessionAnchor.js +161 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +157 -16
- package/dist/cli/services/activityStore.d.ts +8 -0
- package/dist/cli/services/agentRegistry.d.ts +20 -0
- package/dist/cli/services/agentRuntime.d.ts +6 -0
- package/dist/cli/services/storagePaths.d.ts +8 -0
- package/dist/cli/services/strategyFactory.d.ts +5 -0
- package/dist/cli/services/walletCrypto.d.ts +12 -0
- package/dist/cli/services/walletRegistry.d.ts +26 -0
- package/dist/cli/types.d.ts +68 -0
- package/dist/cli/utils/completion.d.ts +4 -0
- package/dist/cli/utils/output.d.ts +5 -0
- package/dist/cli/utils/output.js +4 -1
- package/dist/compression/AuditLogManager.d.ts +9 -0
- package/dist/compression/AuditLogManager.js +86 -0
- package/dist/compression/PolicyAccountManager.d.ts +11 -0
- package/dist/compression/PolicyAccountManager.js +113 -0
- package/dist/compression/types.d.ts +20 -0
- package/dist/compression/types.js +2 -0
- package/dist/config/PRKTConfig.d.ts +17 -0
- package/dist/config/PRKTConfig.js +19 -0
- package/dist/config/agentPolicies.d.ts +14 -0
- package/dist/config/env.d.ts +39 -0
- package/dist/config/env.js +37 -0
- package/dist/config/policyPresets.d.ts +22 -0
- package/dist/core/balances/BalanceService.d.ts +14 -0
- package/dist/core/funding/DevnetFundingService.d.ts +38 -0
- package/dist/core/funding/DevnetFundingService.js +73 -6
- package/dist/core/idempotency/ExecutionIdempotencyGuard.d.ts +39 -0
- package/dist/core/index.d.ts +8 -0
- package/dist/core/rpc/RpcClient.d.ts +21 -0
- package/dist/core/rpc/RpcClient.js +35 -0
- package/dist/core/rpc/RpcFailoverClient.d.ts +42 -0
- package/dist/core/tokens/TokenService.d.ts +40 -0
- package/dist/core/transactions/PostTransactionVerifier.d.ts +47 -0
- package/dist/core/transactions/TransactionService.d.ts +46 -0
- package/dist/core/types/services.d.ts +27 -0
- package/dist/core/wallet/WalletManager.d.ts +21 -0
- package/dist/defi/DeFiCoordinator.d.ts +24 -0
- package/dist/defi/DeFiExecutor.d.ts +15 -0
- package/dist/defi/DeFiPolicyGuard.d.ts +7 -0
- package/dist/defi/adapters/JupiterAdapter.d.ts +5 -0
- package/dist/defi/adapters/KaminoAdapter.d.ts +6 -0
- package/dist/defi/adapters/MarinadeAdapter.d.ts +5 -0
- package/dist/defi/adapters/RaydiumAdapter.d.ts +20 -0
- package/dist/defi/kamino/kaminoInstructionCompat.d.ts +3 -0
- package/dist/defi/kamino/kaminoLiveConfig.d.ts +14 -0
- package/dist/defi/kamino/loadKaminoMarketWithFallback.d.ts +11 -0
- package/dist/defi/lp/LpInstructionBuilder.d.ts +15 -0
- package/dist/defi/lp/RaydiumLpInstructionBuilder.d.ts +28 -0
- package/dist/defi/lp/raydiumDevnetConfig.d.ts +11 -0
- package/dist/defi/protocols.d.ts +8 -0
- package/dist/defi/types.d.ts +65 -0
- package/dist/defi/universal/UniversalDeFiOrchestrator.d.ts +24 -0
- package/dist/defi/universal/UniversalDeFiOrchestrator.js +157 -0
- package/dist/defi/universal/adapters.d.ts +25 -0
- package/dist/defi/universal/index.d.ts +2 -0
- package/dist/defi/universal/liveExecutors.d.ts +23 -0
- package/dist/defi/universal/types.d.ts +45 -0
- package/dist/demo/scenarios/multiAgentDevnetScenario.d.ts +5 -0
- package/dist/demo/scripts/runMultiAgentDevnetDemo.d.ts +1 -0
- package/dist/dex/JupiterSwapClient.d.ts +28 -0
- package/dist/dex/SwapExecutor.d.ts +36 -0
- package/dist/errors/PRKTError.d.ts +15 -0
- package/dist/errors/PRKTError.js +38 -0
- package/dist/evm/EvmAdapter.d.ts +45 -0
- package/dist/evm/EvmAdapter.js +2 -0
- package/dist/evm/NeonWalletBridge.d.ts +9 -0
- package/dist/evm/NeonWalletBridge.js +40 -0
- package/dist/evm/adapters/AaveAdapter.d.ts +17 -0
- package/dist/evm/adapters/AaveAdapter.js +100 -0
- package/dist/evm/adapters/UniswapV3Adapter.d.ts +18 -0
- package/dist/evm/adapters/UniswapV3Adapter.js +146 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +35 -20
- package/dist/kora/KoraRpcClient.d.ts +14 -0
- package/dist/kora/KoraSigner.d.ts +22 -0
- package/dist/kora/KoraSigner.js +33 -10
- package/dist/kora/gaslessDemo.d.ts +9 -0
- package/dist/onchain/index.d.ts +2 -0
- package/dist/onchain/index.js +17 -0
- package/dist/onchain/policyGuardProgram.d.ts +86 -0
- package/dist/onchain/policyGuardProgram.js +248 -0
- package/dist/policy/PolicyGuard.d.ts +13 -0
- package/dist/policy/emergencyLock.d.ts +4 -0
- package/dist/policy/engine/PolicyEngine.d.ts +28 -0
- package/dist/policy/engine/PolicyEngine.js +109 -1
- package/dist/policy/errors.d.ts +3 -0
- package/dist/policy/index.d.ts +3 -0
- package/dist/policy/sandbox/SandboxExecutor.d.ts +44 -0
- package/dist/policy/sandbox/SandboxExecutor.js +245 -3
- package/dist/policy/types/policy.d.ts +55 -0
- package/dist/scripts/devnetFunding.d.ts +9 -0
- package/dist/scripts/devnetFunding.js +0 -1
- package/dist/scripts/devnetWalletPreflight.d.ts +8 -0
- package/dist/scripts/localnetCheck.d.ts +1 -0
- package/dist/scripts/managedAgentWallet.d.ts +34 -0
- package/dist/scripts/mode.d.ts +2 -0
- package/dist/scripts/releaseReadiness.d.ts +9 -0
- package/dist/scripts/runAgentUniversalDeFi.d.ts +1 -0
- package/dist/scripts/runAutonomousAgentWalletDevnet.d.ts +1 -0
- package/dist/scripts/runAutonomousAgentWalletDevnet.js +1 -1
- package/dist/scripts/runAutonomousPortfolioDevnet.d.ts +1 -0
- package/dist/scripts/runAutonomousPortfolioDevnet.js +1 -1
- package/dist/scripts/runBorrowStrategy.d.ts +1 -0
- package/dist/scripts/runDeFiSuite.d.ts +1 -0
- package/dist/scripts/runDemoRehearsal.d.ts +1 -0
- package/dist/scripts/runDemoRehearsal.js +39 -10
- package/dist/scripts/runDevnetFeatureMatrix.d.ts +43 -0
- package/dist/scripts/runDevnetFeatureMatrix.js +787 -0
- package/dist/scripts/runDevnetWalletDemo.d.ts +1 -0
- package/dist/scripts/runGaslessMemo.d.ts +1 -0
- package/dist/scripts/runGaslessMemo.js +9 -1
- package/dist/scripts/runGaslessWalletDemo.d.ts +1 -0
- package/dist/scripts/runGaslessWalletDemo.js +9 -1
- package/dist/scripts/runKaminoDevnet.d.ts +1 -0
- package/dist/scripts/runKaminoDevnet.js +82 -42
- package/dist/scripts/runLpStrategy.d.ts +1 -0
- package/dist/scripts/runMarinadeDevnet.d.ts +1 -0
- package/dist/scripts/runOnchainPolicyGuardDevnet.d.ts +1 -0
- package/dist/scripts/runOnchainPolicyGuardDevnet.js +113 -0
- package/dist/scripts/runOrcaLpDevnet.d.ts +1 -0
- package/dist/scripts/runRaydiumLpDevnet.d.ts +1 -0
- package/dist/scripts/runReleaseReadiness.d.ts +1 -0
- package/dist/scripts/runStakeStrategy.d.ts +1 -0
- package/dist/scripts/runStatus.d.ts +1 -0
- package/dist/scripts/runStatus.js +22 -0
- package/dist/scripts/runStressTest.d.ts +1 -0
- package/dist/scripts/runTradeLoop.d.ts +1 -0
- package/dist/scripts/runUniversalDeFiDemo.d.ts +1 -0
- package/dist/scripts/runYieldStrategy.d.ts +1 -0
- package/dist/scripts/runtimeFactory.d.ts +8 -0
- package/dist/scripts/shared.d.ts +3 -0
- package/dist/scripts/shared.js +1 -0
- package/dist/scripts/simulateAttack.d.ts +1 -0
- package/dist/scripts/simulateSwarm.d.ts +1 -0
- package/dist/simulation/attack.d.ts +8 -0
- package/dist/solana/memoLedger.d.ts +33 -0
- package/dist/solana/memoLedger.js +205 -0
- package/dist/solana/programs.d.ts +6 -0
- package/dist/spl/TokenWallet.d.ts +18 -0
- package/dist/types/policy.d.ts +23 -0
- package/dist/wallet/WalletManager.d.ts +1 -0
- package/dist/zk/PolicyCircuit.d.ts +48 -0
- package/dist/zk/PolicyCircuit.js +171 -0
- package/dist/zk/ProofAnchor.d.ts +33 -0
- package/dist/zk/ProofAnchor.js +109 -0
- package/dist/zkCompression/CompressedCommitmentAnchor.d.ts +31 -0
- package/dist/zkCompression/CompressedCommitmentAnchor.js +90 -0
- package/dist/zkCompression/CompressedDataAccount.d.ts +45 -0
- package/dist/zkCompression/CompressedDataAccount.js +349 -0
- package/dist/zkCompression/LocalPayloadRegistry.d.ts +23 -0
- package/dist/zkCompression/LocalPayloadRegistry.js +53 -0
- package/package.json +20 -4
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AuditEntry } from "./types";
|
|
2
|
+
export declare class AuditLogManager {
|
|
3
|
+
private readonly rpcEndpoint;
|
|
4
|
+
private static readonly auditRegistry;
|
|
5
|
+
constructor(rpcEndpoint: string);
|
|
6
|
+
appendAuditEntry(entry: AuditEntry, payer: import("@solana/web3.js").Keypair): Promise<string>;
|
|
7
|
+
fetchAuditLog(agentId: string, limit?: number): Promise<AuditEntry[]>;
|
|
8
|
+
private getStore;
|
|
9
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuditLogManager = void 0;
|
|
4
|
+
const crypto_1 = require("crypto");
|
|
5
|
+
const PRKTError_1 = require("../errors/PRKTError");
|
|
6
|
+
const CompressedDataAccount_1 = require("../zkCompression/CompressedDataAccount");
|
|
7
|
+
const AUDIT_ACCOUNT_DISCRIMINATOR = "PRKTAUD1";
|
|
8
|
+
class AuditLogManager {
|
|
9
|
+
rpcEndpoint;
|
|
10
|
+
static auditRegistry = new Map();
|
|
11
|
+
constructor(rpcEndpoint) {
|
|
12
|
+
this.rpcEndpoint = rpcEndpoint;
|
|
13
|
+
}
|
|
14
|
+
async appendAuditEntry(entry, payer) {
|
|
15
|
+
try {
|
|
16
|
+
const payload = serializeAuditEntry(entry);
|
|
17
|
+
const signature = await this.getStore().writeAccount({
|
|
18
|
+
discriminator: AUDIT_ACCOUNT_DISCRIMINATOR,
|
|
19
|
+
namespace: "prkt-audit",
|
|
20
|
+
parts: [entry.agentId, entry.timestamp.toString(), hashAuditEntry(entry)],
|
|
21
|
+
payer,
|
|
22
|
+
payload
|
|
23
|
+
});
|
|
24
|
+
const existing = AuditLogManager.auditRegistry.get(entry.agentId) ?? [];
|
|
25
|
+
existing.push(entry);
|
|
26
|
+
existing.sort((left, right) => left.timestamp - right.timestamp);
|
|
27
|
+
AuditLogManager.auditRegistry.set(entry.agentId, existing);
|
|
28
|
+
return signature.signature;
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
throw new PRKTError_1.CompressionError(`Failed to append audit entry: ${error}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async fetchAuditLog(agentId, limit) {
|
|
35
|
+
try {
|
|
36
|
+
const inMemory = AuditLogManager.auditRegistry.get(agentId);
|
|
37
|
+
if (inMemory && inMemory.length > 0) {
|
|
38
|
+
return [...inMemory].slice(-(limit ?? inMemory.length));
|
|
39
|
+
}
|
|
40
|
+
const records = await this.getStore().findAccountsByOwner({
|
|
41
|
+
discriminator: AUDIT_ACCOUNT_DISCRIMINATOR
|
|
42
|
+
});
|
|
43
|
+
const entries = records
|
|
44
|
+
.map((record) => record.payload)
|
|
45
|
+
.filter((payload) => !!payload && payload.a === agentId)
|
|
46
|
+
.map(deserializeAuditEntry)
|
|
47
|
+
.sort((left, right) => left.timestamp - right.timestamp);
|
|
48
|
+
AuditLogManager.auditRegistry.set(agentId, entries);
|
|
49
|
+
return limit ? entries.slice(-limit) : entries;
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
throw new PRKTError_1.CompressionError(`Failed to fetch audit log: ${error}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
getStore() {
|
|
56
|
+
return new CompressedDataAccount_1.CompressedDataAccount(this.rpcEndpoint);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.AuditLogManager = AuditLogManager;
|
|
60
|
+
function serializeAuditEntry(entry) {
|
|
61
|
+
return {
|
|
62
|
+
a: entry.agentId,
|
|
63
|
+
i: entry.intentType,
|
|
64
|
+
ok: entry.approved ? 1 : 0,
|
|
65
|
+
r: entry.rejectionReason,
|
|
66
|
+
s: entry.simulationResult,
|
|
67
|
+
t: entry.timestamp,
|
|
68
|
+
tx: entry.txSignature
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function deserializeAuditEntry(payload) {
|
|
72
|
+
return {
|
|
73
|
+
agentId: payload.a,
|
|
74
|
+
approved: payload.ok === 1,
|
|
75
|
+
intentType: payload.i,
|
|
76
|
+
rejectionReason: payload.r,
|
|
77
|
+
simulationResult: payload.s,
|
|
78
|
+
timestamp: payload.t,
|
|
79
|
+
txSignature: payload.tx
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function hashAuditEntry(entry) {
|
|
83
|
+
return (0, crypto_1.createHash)("sha256")
|
|
84
|
+
.update(JSON.stringify(serializeAuditEntry(entry)), "utf8")
|
|
85
|
+
.digest("hex");
|
|
86
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Keypair } from "@solana/web3.js";
|
|
2
|
+
import { CompressedPolicyState } from "./types";
|
|
3
|
+
export declare class PolicyAccountManager {
|
|
4
|
+
private readonly rpcEndpoint;
|
|
5
|
+
private static readonly policyRegistry;
|
|
6
|
+
constructor(rpcEndpoint: string);
|
|
7
|
+
createCompressedPolicyAccount(agentId: string, policy: Omit<CompressedPolicyState, "agentId">, payer: Keypair): Promise<string>;
|
|
8
|
+
fetchCompressedPolicyAccount(agentId: string): Promise<CompressedPolicyState>;
|
|
9
|
+
updateCompressedPolicyAccount(agentId: string, updates: Partial<CompressedPolicyState>, payer: Keypair): Promise<string>;
|
|
10
|
+
private getStore;
|
|
11
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PolicyAccountManager = void 0;
|
|
4
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
5
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
6
|
+
const PRKTError_1 = require("../errors/PRKTError");
|
|
7
|
+
const CompressedDataAccount_1 = require("../zkCompression/CompressedDataAccount");
|
|
8
|
+
const POLICY_ACCOUNT_DISCRIMINATOR = "PRKTPOL1";
|
|
9
|
+
class PolicyAccountManager {
|
|
10
|
+
rpcEndpoint;
|
|
11
|
+
static policyRegistry = new Map();
|
|
12
|
+
constructor(rpcEndpoint) {
|
|
13
|
+
this.rpcEndpoint = rpcEndpoint;
|
|
14
|
+
}
|
|
15
|
+
async createCompressedPolicyAccount(agentId, policy, payer) {
|
|
16
|
+
try {
|
|
17
|
+
const state = {
|
|
18
|
+
agentId,
|
|
19
|
+
...policy
|
|
20
|
+
};
|
|
21
|
+
const updatedAt = Date.now();
|
|
22
|
+
const record = await this.getStore().writeAccount({
|
|
23
|
+
discriminator: POLICY_ACCOUNT_DISCRIMINATOR,
|
|
24
|
+
namespace: "prkt-policy",
|
|
25
|
+
parts: [agentId, updatedAt.toString()],
|
|
26
|
+
payer,
|
|
27
|
+
payload: serializePolicy(state, updatedAt)
|
|
28
|
+
});
|
|
29
|
+
PolicyAccountManager.policyRegistry.set(agentId, state);
|
|
30
|
+
return record.signature;
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
throw new PRKTError_1.CompressionError(`Failed to create compressed policy account: ${error}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async fetchCompressedPolicyAccount(agentId) {
|
|
37
|
+
try {
|
|
38
|
+
const inMemory = PolicyAccountManager.policyRegistry.get(agentId);
|
|
39
|
+
if (inMemory) {
|
|
40
|
+
return inMemory;
|
|
41
|
+
}
|
|
42
|
+
const records = await this.getStore().findAccountsByOwner({
|
|
43
|
+
discriminator: POLICY_ACCOUNT_DISCRIMINATOR
|
|
44
|
+
});
|
|
45
|
+
const payload = records
|
|
46
|
+
.map((record) => record.payload)
|
|
47
|
+
.filter((value) => !!value && value.a === agentId)
|
|
48
|
+
.sort((left, right) => right.u - left.u)[0];
|
|
49
|
+
if (payload) {
|
|
50
|
+
const policy = deserializePolicy(payload);
|
|
51
|
+
PolicyAccountManager.policyRegistry.set(agentId, policy);
|
|
52
|
+
return policy;
|
|
53
|
+
}
|
|
54
|
+
throw new Error(`policy not found for ${agentId}`);
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
throw new PRKTError_1.CompressionError(`Failed to fetch compressed policy account: ${error}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async updateCompressedPolicyAccount(agentId, updates, payer) {
|
|
61
|
+
try {
|
|
62
|
+
const current = await this.fetchCompressedPolicyAccount(agentId);
|
|
63
|
+
const merged = {
|
|
64
|
+
...current,
|
|
65
|
+
...updates,
|
|
66
|
+
agentId,
|
|
67
|
+
dailySpendLimit: updates.dailySpendLimit ?? current.dailySpendLimit,
|
|
68
|
+
programAllowlist: updates.programAllowlist ?? current.programAllowlist,
|
|
69
|
+
spentToday: updates.spentToday ?? current.spentToday
|
|
70
|
+
};
|
|
71
|
+
const updatedAt = Date.now();
|
|
72
|
+
const record = await this.getStore().writeAccount({
|
|
73
|
+
discriminator: POLICY_ACCOUNT_DISCRIMINATOR,
|
|
74
|
+
namespace: "prkt-policy",
|
|
75
|
+
parts: [agentId, updatedAt.toString()],
|
|
76
|
+
payer,
|
|
77
|
+
payload: serializePolicy(merged, updatedAt)
|
|
78
|
+
});
|
|
79
|
+
PolicyAccountManager.policyRegistry.set(agentId, merged);
|
|
80
|
+
return record.signature;
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
throw new PRKTError_1.CompressionError(`Failed to update compressed policy account: ${error}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
getStore() {
|
|
87
|
+
return new CompressedDataAccount_1.CompressedDataAccount(this.rpcEndpoint);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.PolicyAccountManager = PolicyAccountManager;
|
|
91
|
+
function serializePolicy(policy, updatedAt) {
|
|
92
|
+
return {
|
|
93
|
+
a: policy.agentId,
|
|
94
|
+
d: policy.dailySpendLimit.toString(),
|
|
95
|
+
k: policy.killSwitchActive ? 1 : 0,
|
|
96
|
+
l: policy.programAllowlist.map((programId) => programId.toBase58()),
|
|
97
|
+
r: policy.lastResetTimestamp,
|
|
98
|
+
s: policy.sessionTTL,
|
|
99
|
+
t: policy.spentToday.toString(),
|
|
100
|
+
u: updatedAt
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function deserializePolicy(payload) {
|
|
104
|
+
return {
|
|
105
|
+
agentId: payload.a,
|
|
106
|
+
dailySpendLimit: new anchor_1.BN(payload.d),
|
|
107
|
+
killSwitchActive: payload.k === 1,
|
|
108
|
+
lastResetTimestamp: payload.r,
|
|
109
|
+
programAllowlist: payload.l.map((programId) => new web3_js_1.PublicKey(programId)),
|
|
110
|
+
sessionTTL: payload.s,
|
|
111
|
+
spentToday: new anchor_1.BN(payload.t)
|
|
112
|
+
};
|
|
113
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
import { BN } from "@coral-xyz/anchor";
|
|
3
|
+
export interface CompressedPolicyState {
|
|
4
|
+
agentId: string;
|
|
5
|
+
dailySpendLimit: BN;
|
|
6
|
+
sessionTTL: number;
|
|
7
|
+
programAllowlist: PublicKey[];
|
|
8
|
+
killSwitchActive: boolean;
|
|
9
|
+
spentToday: BN;
|
|
10
|
+
lastResetTimestamp: number;
|
|
11
|
+
}
|
|
12
|
+
export interface AuditEntry {
|
|
13
|
+
agentId: string;
|
|
14
|
+
timestamp: number;
|
|
15
|
+
intentType: string;
|
|
16
|
+
approved: boolean;
|
|
17
|
+
rejectionReason?: string;
|
|
18
|
+
simulationResult: string;
|
|
19
|
+
txSignature?: string;
|
|
20
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface PRKTConfig {
|
|
2
|
+
zkCompression: {
|
|
3
|
+
enabled: boolean;
|
|
4
|
+
rpcEndpoint: string;
|
|
5
|
+
};
|
|
6
|
+
dataAnchoring: {
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
};
|
|
9
|
+
zkPolicyProofs: {
|
|
10
|
+
enabled: boolean;
|
|
11
|
+
};
|
|
12
|
+
evmAdapters: {
|
|
13
|
+
enabled: boolean;
|
|
14
|
+
neonRpcEndpoint: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export declare const defaultPRKTConfig: PRKTConfig;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultPRKTConfig = void 0;
|
|
4
|
+
exports.defaultPRKTConfig = {
|
|
5
|
+
zkCompression: {
|
|
6
|
+
enabled: false,
|
|
7
|
+
rpcEndpoint: "https://devnet.helius-rpc.com/?api-key=" // Default placeholder or use env later
|
|
8
|
+
},
|
|
9
|
+
dataAnchoring: {
|
|
10
|
+
enabled: false
|
|
11
|
+
},
|
|
12
|
+
zkPolicyProofs: {
|
|
13
|
+
enabled: false
|
|
14
|
+
},
|
|
15
|
+
evmAdapters: {
|
|
16
|
+
enabled: false,
|
|
17
|
+
neonRpcEndpoint: "https://devnet.neonevm.org"
|
|
18
|
+
}
|
|
19
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PolicyConfig } from "../policy";
|
|
2
|
+
export declare function createDefaultPolicyConfig(input: {
|
|
3
|
+
agentId: string;
|
|
4
|
+
allowOpaqueProgramIds?: string[];
|
|
5
|
+
allowedCloseAccountDestinations?: string[];
|
|
6
|
+
allowedMints?: string[];
|
|
7
|
+
extraAllowedProgramIds?: string[];
|
|
8
|
+
allowedTransferDestinations?: string[];
|
|
9
|
+
approvalMode?: "sandbox" | "live";
|
|
10
|
+
maxSolPerTxLamports?: number;
|
|
11
|
+
maxSplPerTxRawAmount?: bigint;
|
|
12
|
+
maxTransactionsPerSession?: number;
|
|
13
|
+
maxTransactionsPerDay?: number;
|
|
14
|
+
}): PolicyConfig;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
export declare class EnvConfigError extends Error {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
export declare function getOptionalSecretKey(): Uint8Array | null;
|
|
6
|
+
export declare function getOptionalDevnetTreasurySecretKey(): Uint8Array | null;
|
|
7
|
+
export declare function getRpcUrl(): string;
|
|
8
|
+
export declare function getRpcFallbackUrl(): string | null;
|
|
9
|
+
export declare function getZkCompressionApiUrl(): string | null;
|
|
10
|
+
export declare function getZkProverUrl(): string | null;
|
|
11
|
+
export declare function getOnchainPolicyGuardProgramId(): string | null;
|
|
12
|
+
export declare function getImplementationPath(): string;
|
|
13
|
+
export declare function isDefensibleDevnetDemoMode(): boolean;
|
|
14
|
+
export declare function isNeonBroadcastEnabled(): boolean;
|
|
15
|
+
export declare function getKoraRpcUrl(): string;
|
|
16
|
+
export declare function isKoraMockMode(): boolean;
|
|
17
|
+
export declare function getJupiterApiBaseUrl(): string;
|
|
18
|
+
export declare function getRaydiumLpConfigPath(): string;
|
|
19
|
+
export declare function getKaminoLiveConfigPath(): string;
|
|
20
|
+
export declare function isLiveSwapPathEnabled(): boolean;
|
|
21
|
+
export declare function isLiveRaydiumLpEnabled(): boolean;
|
|
22
|
+
export declare function isLiveKaminoEnabled(): boolean;
|
|
23
|
+
export declare function isLiveMarinadeEnabled(): boolean;
|
|
24
|
+
export declare function isUniversalDeFiLiveFirstEnabled(): boolean;
|
|
25
|
+
export declare function getUsdcMintAddress(): string;
|
|
26
|
+
export declare function getExtraWhitelistedPrograms(): string[];
|
|
27
|
+
export declare function getPolicySessionTtlMinutes(): number;
|
|
28
|
+
export declare function getRemoteSignerConfig(): {
|
|
29
|
+
bearerToken: string;
|
|
30
|
+
publicKey: PublicKey;
|
|
31
|
+
url: string;
|
|
32
|
+
} | null;
|
|
33
|
+
export declare function detectClusterFromRpcUrl(rpcUrl: string): "mainnet-beta" | "devnet" | "testnet" | "localnet" | "unknown";
|
|
34
|
+
export declare function assertMintMatchesRpcCluster(input: {
|
|
35
|
+
mintAddress: string;
|
|
36
|
+
mintName: string;
|
|
37
|
+
rpcUrl: string;
|
|
38
|
+
}): void;
|
|
39
|
+
export declare function redactSecretForLogs(): string;
|
package/dist/config/env.js
CHANGED
|
@@ -8,6 +8,12 @@ exports.getOptionalSecretKey = getOptionalSecretKey;
|
|
|
8
8
|
exports.getOptionalDevnetTreasurySecretKey = getOptionalDevnetTreasurySecretKey;
|
|
9
9
|
exports.getRpcUrl = getRpcUrl;
|
|
10
10
|
exports.getRpcFallbackUrl = getRpcFallbackUrl;
|
|
11
|
+
exports.getZkCompressionApiUrl = getZkCompressionApiUrl;
|
|
12
|
+
exports.getZkProverUrl = getZkProverUrl;
|
|
13
|
+
exports.getOnchainPolicyGuardProgramId = getOnchainPolicyGuardProgramId;
|
|
14
|
+
exports.getImplementationPath = getImplementationPath;
|
|
15
|
+
exports.isDefensibleDevnetDemoMode = isDefensibleDevnetDemoMode;
|
|
16
|
+
exports.isNeonBroadcastEnabled = isNeonBroadcastEnabled;
|
|
11
17
|
exports.getKoraRpcUrl = getKoraRpcUrl;
|
|
12
18
|
exports.isKoraMockMode = isKoraMockMode;
|
|
13
19
|
exports.getJupiterApiBaseUrl = getJupiterApiBaseUrl;
|
|
@@ -48,6 +54,11 @@ const DEVNET_TREASURY_PRIVATE_KEY_ENV = "DEVNET_TREASURY_PRIVATE_KEY";
|
|
|
48
54
|
const REMOTE_SIGNER_URL_ENV = "REMOTE_SIGNER_URL";
|
|
49
55
|
const REMOTE_SIGNER_BEARER_TOKEN_ENV = "REMOTE_SIGNER_BEARER_TOKEN";
|
|
50
56
|
const REMOTE_SIGNER_PUBKEY_ENV = "REMOTE_SIGNER_PUBKEY";
|
|
57
|
+
const ZK_COMPRESSION_API_URL_ENV = "ZK_COMPRESSION_API_URL";
|
|
58
|
+
const ZK_PROVER_URL_ENV = "ZK_PROVER_URL";
|
|
59
|
+
const ONCHAIN_POLICY_GUARD_PROGRAM_ID_ENV = "ONCHAIN_POLICY_GUARD_PROGRAM_ID";
|
|
60
|
+
const IMPLEMENTATION_PATH_ENV = "IMPLEMENTATION_PATH";
|
|
61
|
+
const NEON_BROADCAST_ENABLED_ENV = "NEON_BROADCAST_ENABLED";
|
|
51
62
|
const MAINNET_USDC_MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
52
63
|
const DEVNET_USDC_MINT = "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU";
|
|
53
64
|
class EnvConfigError extends Error {
|
|
@@ -102,6 +113,32 @@ function getRpcFallbackUrl() {
|
|
|
102
113
|
const fallbackUrl = process.env[RPC_FALLBACK_ENV]?.trim();
|
|
103
114
|
return fallbackUrl && fallbackUrl.length > 0 ? fallbackUrl : null;
|
|
104
115
|
}
|
|
116
|
+
function getZkCompressionApiUrl() {
|
|
117
|
+
const value = process.env[ZK_COMPRESSION_API_URL_ENV]?.trim();
|
|
118
|
+
return value && value.length > 0 ? value : null;
|
|
119
|
+
}
|
|
120
|
+
function getZkProverUrl() {
|
|
121
|
+
const value = process.env[ZK_PROVER_URL_ENV]?.trim();
|
|
122
|
+
return value && value.length > 0 ? value : null;
|
|
123
|
+
}
|
|
124
|
+
function getOnchainPolicyGuardProgramId() {
|
|
125
|
+
const value = process.env[ONCHAIN_POLICY_GUARD_PROGRAM_ID_ENV]?.trim();
|
|
126
|
+
return value && value.length > 0 ? value : null;
|
|
127
|
+
}
|
|
128
|
+
function getImplementationPath() {
|
|
129
|
+
const value = process.env[IMPLEMENTATION_PATH_ENV]?.trim();
|
|
130
|
+
return value && value.length > 0 ? value : "strict_live";
|
|
131
|
+
}
|
|
132
|
+
function isDefensibleDevnetDemoMode() {
|
|
133
|
+
return getImplementationPath() === "defensible_devnet_demo";
|
|
134
|
+
}
|
|
135
|
+
function isNeonBroadcastEnabled() {
|
|
136
|
+
const rawValue = process.env[NEON_BROADCAST_ENABLED_ENV]?.trim().toLowerCase();
|
|
137
|
+
if (!rawValue) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
return rawValue === "true" || rawValue === "1";
|
|
141
|
+
}
|
|
105
142
|
function getKoraRpcUrl() {
|
|
106
143
|
const koraRpcUrl = process.env[KORA_RPC_ENV]?.trim();
|
|
107
144
|
return koraRpcUrl && koraRpcUrl.length > 0
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PolicyConfig } from "../policy";
|
|
2
|
+
import type { PolicyPresetName, StoredPolicyOverrides } from "../cli/types";
|
|
3
|
+
type PolicyPresetDefinition = {
|
|
4
|
+
description: string;
|
|
5
|
+
label: string;
|
|
6
|
+
build: (input: {
|
|
7
|
+
agentId: string;
|
|
8
|
+
}) => PolicyConfig;
|
|
9
|
+
};
|
|
10
|
+
export declare const POLICY_PRESETS: Record<PolicyPresetName, PolicyPresetDefinition>;
|
|
11
|
+
export declare const DEFAULT_POLICY_PRESET: PolicyPresetName;
|
|
12
|
+
export declare function listPolicyPresetSummaries(): Array<{
|
|
13
|
+
description: string;
|
|
14
|
+
label: string;
|
|
15
|
+
name: PolicyPresetName;
|
|
16
|
+
}>;
|
|
17
|
+
export declare function resolvePolicyConfig(input: {
|
|
18
|
+
agentId: string;
|
|
19
|
+
overrides?: StoredPolicyOverrides;
|
|
20
|
+
presetName: PolicyPresetName;
|
|
21
|
+
}): PolicyConfig;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
import { RpcClient } from "../rpc/RpcClient";
|
|
3
|
+
import { TokenService } from "../tokens/TokenService";
|
|
4
|
+
export declare class BalanceService {
|
|
5
|
+
private readonly rpcClient;
|
|
6
|
+
private readonly tokenService;
|
|
7
|
+
constructor(rpcClient: RpcClient, tokenService: TokenService);
|
|
8
|
+
getSolBalanceLamports(owner: PublicKey): Promise<number>;
|
|
9
|
+
getSolBalance(owner: PublicKey): Promise<number>;
|
|
10
|
+
getSplTokenBalance(input: {
|
|
11
|
+
owner: PublicKey;
|
|
12
|
+
mint: PublicKey;
|
|
13
|
+
}): Promise<number>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type PublicKey } from "@solana/web3.js";
|
|
2
|
+
import { BalanceService } from "../balances/BalanceService";
|
|
3
|
+
import { RpcClient } from "../rpc/RpcClient";
|
|
4
|
+
import { TransactionService } from "../transactions/TransactionService";
|
|
5
|
+
import { WalletManager } from "../wallet/WalletManager";
|
|
6
|
+
type FundingResult = {
|
|
7
|
+
signature: string;
|
|
8
|
+
source: "airdrop" | "hybrid" | "treasury-transfer";
|
|
9
|
+
};
|
|
10
|
+
export declare class DevnetFundingService {
|
|
11
|
+
private readonly rpcClient;
|
|
12
|
+
private readonly transactionService;
|
|
13
|
+
private readonly treasuryWallet;
|
|
14
|
+
constructor(rpcClient: RpcClient, transactionService: TransactionService, treasuryWallet?: WalletManager | null);
|
|
15
|
+
hasTreasuryWallet(): boolean;
|
|
16
|
+
getTreasuryPublicKey(): PublicKey | null;
|
|
17
|
+
ensureMinimumSol(input: {
|
|
18
|
+
airdropAmountSol?: number;
|
|
19
|
+
balanceService: BalanceService;
|
|
20
|
+
minimumSol: number;
|
|
21
|
+
recipient: PublicKey;
|
|
22
|
+
}): Promise<FundingResult | null>;
|
|
23
|
+
fundExactSol(input: {
|
|
24
|
+
amountSol: number;
|
|
25
|
+
recipient: PublicKey;
|
|
26
|
+
}): Promise<FundingResult>;
|
|
27
|
+
waitForMinimumBalance(input: {
|
|
28
|
+
attempts?: number;
|
|
29
|
+
balanceService: BalanceService;
|
|
30
|
+
minimumSol: number;
|
|
31
|
+
recipient: PublicKey;
|
|
32
|
+
}): Promise<number>;
|
|
33
|
+
private canUseTreasury;
|
|
34
|
+
private fundFromTreasury;
|
|
35
|
+
private fundFromTreasuryOrAirdrop;
|
|
36
|
+
private requestAirdrop;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
@@ -4,6 +4,7 @@ exports.DevnetFundingService = void 0;
|
|
|
4
4
|
const web3_js_1 = require("@solana/web3.js");
|
|
5
5
|
const env_1 = require("../../config/env");
|
|
6
6
|
const WalletManager_1 = require("../wallet/WalletManager");
|
|
7
|
+
const TREASURY_MINIMUM_REMAINING_LAMPORTS = Math.round(0.05 * web3_js_1.LAMPORTS_PER_SOL);
|
|
7
8
|
class DevnetFundingService {
|
|
8
9
|
rpcClient;
|
|
9
10
|
transactionService;
|
|
@@ -26,19 +27,24 @@ class DevnetFundingService {
|
|
|
26
27
|
}
|
|
27
28
|
const amountSol = roundSolAmount(input.minimumSol - currentBalance);
|
|
28
29
|
if (this.canUseTreasury(input.recipient)) {
|
|
29
|
-
return this.
|
|
30
|
+
return this.fundFromTreasuryOrAirdrop({
|
|
31
|
+
airdropAmountSol: input.airdropAmountSol ?? amountSol,
|
|
30
32
|
amountSol,
|
|
31
33
|
recipient: input.recipient
|
|
32
34
|
});
|
|
33
35
|
}
|
|
34
36
|
return this.requestAirdrop({
|
|
35
|
-
amountSol: input.airdropAmountSol ??
|
|
37
|
+
amountSol: input.airdropAmountSol ?? amountSol,
|
|
36
38
|
recipient: input.recipient
|
|
37
39
|
});
|
|
38
40
|
}
|
|
39
41
|
async fundExactSol(input) {
|
|
40
42
|
if (this.canUseTreasury(input.recipient)) {
|
|
41
|
-
return this.
|
|
43
|
+
return this.fundFromTreasuryOrAirdrop({
|
|
44
|
+
airdropAmountSol: input.amountSol,
|
|
45
|
+
amountSol: input.amountSol,
|
|
46
|
+
recipient: input.recipient
|
|
47
|
+
});
|
|
42
48
|
}
|
|
43
49
|
return this.requestAirdrop(input);
|
|
44
50
|
}
|
|
@@ -78,11 +84,72 @@ class DevnetFundingService {
|
|
|
78
84
|
source: "treasury-transfer"
|
|
79
85
|
};
|
|
80
86
|
}
|
|
87
|
+
async fundFromTreasuryOrAirdrop(input) {
|
|
88
|
+
try {
|
|
89
|
+
const treasuryLamports = await this.rpcClient.getBalance(this.treasuryWallet.publicKey, "confirmed");
|
|
90
|
+
const requestedLamports = Math.round(input.amountSol * web3_js_1.LAMPORTS_PER_SOL);
|
|
91
|
+
const transferableLamports = Math.max(0, treasuryLamports - TREASURY_MINIMUM_REMAINING_LAMPORTS);
|
|
92
|
+
if (transferableLamports >= requestedLamports) {
|
|
93
|
+
return await this.fundFromTreasury({
|
|
94
|
+
amountSol: input.amountSol,
|
|
95
|
+
recipient: input.recipient
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
if (transferableLamports > 0) {
|
|
99
|
+
await this.fundFromTreasury({
|
|
100
|
+
amountSol: transferableLamports / web3_js_1.LAMPORTS_PER_SOL,
|
|
101
|
+
recipient: input.recipient
|
|
102
|
+
});
|
|
103
|
+
const remainingLamports = requestedLamports - transferableLamports;
|
|
104
|
+
const airdropFunding = await this.requestAirdrop({
|
|
105
|
+
amountSol: remainingLamports / web3_js_1.LAMPORTS_PER_SOL,
|
|
106
|
+
recipient: input.recipient
|
|
107
|
+
});
|
|
108
|
+
return {
|
|
109
|
+
signature: airdropFunding.signature,
|
|
110
|
+
source: "hybrid"
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
// Fall through to full-faucet funding below.
|
|
116
|
+
}
|
|
117
|
+
return this.requestAirdrop({
|
|
118
|
+
amountSol: input.airdropAmountSol,
|
|
119
|
+
recipient: input.recipient
|
|
120
|
+
});
|
|
121
|
+
}
|
|
81
122
|
async requestAirdrop(input) {
|
|
82
|
-
|
|
83
|
-
|
|
123
|
+
let remainingLamports = Math.round(input.amountSol * web3_js_1.LAMPORTS_PER_SOL);
|
|
124
|
+
let lastSignature = "";
|
|
125
|
+
let lastError;
|
|
126
|
+
while (remainingLamports > 0) {
|
|
127
|
+
const requestLamports = Math.min(remainingLamports, web3_js_1.LAMPORTS_PER_SOL);
|
|
128
|
+
let requestSucceeded = false;
|
|
129
|
+
for (let attempt = 0; attempt < 5; attempt += 1) {
|
|
130
|
+
try {
|
|
131
|
+
lastSignature = await this.rpcClient.requestAirdrop(input.recipient, requestLamports);
|
|
132
|
+
await this.rpcClient.confirmTransaction(lastSignature, "confirmed");
|
|
133
|
+
remainingLamports -= requestLamports;
|
|
134
|
+
lastError = undefined;
|
|
135
|
+
requestSucceeded = true;
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
lastError = error;
|
|
140
|
+
await delay(1_500);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (!requestSucceeded) {
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (!lastSignature || remainingLamports > 0) {
|
|
148
|
+
const reason = lastError instanceof Error ? lastError.message : "unknown error";
|
|
149
|
+
throw new Error(`airdrop to ${input.recipient.toBase58()} failed: ${reason}`);
|
|
150
|
+
}
|
|
84
151
|
return {
|
|
85
|
-
signature,
|
|
152
|
+
signature: lastSignature,
|
|
86
153
|
source: "airdrop"
|
|
87
154
|
};
|
|
88
155
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prevents duplicate execution of the same intent by tracking unique execution IDs.
|
|
3
|
+
* Uses a bounded in-memory set with TTL-based expiry.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ExecutionIdempotencyGuard {
|
|
6
|
+
private readonly entries;
|
|
7
|
+
private readonly maxEntries;
|
|
8
|
+
private readonly ttlMs;
|
|
9
|
+
private cleanupCounter;
|
|
10
|
+
private readonly cleanupInterval;
|
|
11
|
+
constructor(options?: {
|
|
12
|
+
maxEntries?: number;
|
|
13
|
+
ttlMs?: number;
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* Generate a new unique execution ID.
|
|
17
|
+
*/
|
|
18
|
+
generateId(): string;
|
|
19
|
+
/**
|
|
20
|
+
* Attempt to acquire a lock for the given execution ID.
|
|
21
|
+
* Returns `true` on the first call for a given ID (execution allowed).
|
|
22
|
+
* Returns `false` if the ID has already been acquired (duplicate blocked).
|
|
23
|
+
*/
|
|
24
|
+
acquire(executionId: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Check whether an execution ID has already been acquired (without acquiring it).
|
|
27
|
+
*/
|
|
28
|
+
has(executionId: string): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Returns the number of active (non-expired) tracked entries.
|
|
31
|
+
*/
|
|
32
|
+
get size(): number;
|
|
33
|
+
/**
|
|
34
|
+
* Remove all tracked entries.
|
|
35
|
+
*/
|
|
36
|
+
clear(): void;
|
|
37
|
+
private maybeCleanup;
|
|
38
|
+
private evictOldest;
|
|
39
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { RpcClient } from "./rpc/RpcClient";
|
|
2
|
+
export { RpcFailoverClient } from "./rpc/RpcFailoverClient";
|
|
3
|
+
export { WalletManager } from "./wallet/WalletManager";
|
|
4
|
+
export { TransactionService } from "./transactions/TransactionService";
|
|
5
|
+
export { PostTransactionVerifier } from "./transactions/PostTransactionVerifier";
|
|
6
|
+
export { TokenService } from "./tokens/TokenService";
|
|
7
|
+
export { BalanceService } from "./balances/BalanceService";
|
|
8
|
+
export { ExecutionIdempotencyGuard } from "./idempotency/ExecutionIdempotencyGuard";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Connection, type Commitment, type ConfirmOptions, type PublicKey, type RpcResponseAndContext, type SignatureResult, type SimulatedTransactionResponse, type TransactionConfirmationStrategy, type VersionedTransaction } from "@solana/web3.js";
|
|
2
|
+
export declare class RpcClient {
|
|
3
|
+
readonly connection: Connection;
|
|
4
|
+
private readonly failoverClient;
|
|
5
|
+
constructor(rpcUrl?: string, commitment?: Commitment);
|
|
6
|
+
get rpcUrl(): string;
|
|
7
|
+
getLatestBlockhash(commitment?: Commitment): Promise<{
|
|
8
|
+
blockhash: string;
|
|
9
|
+
lastValidBlockHeight: number;
|
|
10
|
+
}>;
|
|
11
|
+
getBalance(publicKey: PublicKey, commitment?: Commitment): Promise<number>;
|
|
12
|
+
getTokenAccountBalance(publicKey: PublicKey, commitment?: Commitment): Promise<RpcResponseAndContext<import("@solana/web3.js").TokenAmount>>;
|
|
13
|
+
getAccountInfo(publicKey: PublicKey, commitment?: Commitment): Promise<import("@solana/web3.js").AccountInfo<Buffer<ArrayBufferLike>> | null>;
|
|
14
|
+
sendTransaction(transaction: VersionedTransaction, options?: ConfirmOptions): Promise<string>;
|
|
15
|
+
confirmTransaction(strategy: TransactionConfirmationStrategy | string, commitment?: Commitment): Promise<RpcResponseAndContext<SignatureResult>>;
|
|
16
|
+
simulateTransaction(transaction: VersionedTransaction, options?: {
|
|
17
|
+
commitment?: Commitment;
|
|
18
|
+
sigVerify?: boolean;
|
|
19
|
+
}): Promise<RpcResponseAndContext<SimulatedTransactionResponse>>;
|
|
20
|
+
requestAirdrop(publicKey: PublicKey, lamports: number): Promise<string>;
|
|
21
|
+
}
|