@sherwoodagent/cli 0.19.1 → 0.22.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chat-WKOSUZXO.js → chat-JYAJMP4D.js} +42 -16
- package/dist/chat-JYAJMP4D.js.map +1 -0
- package/dist/{chunk-CTLEZZO7.js → chunk-4Y6Y4SVH.js} +43 -33
- package/dist/chunk-4Y6Y4SVH.js.map +1 -0
- package/dist/chunk-ASJTFFZH.js +485 -0
- package/dist/chunk-ASJTFFZH.js.map +1 -0
- package/dist/{chunk-SZ5QQJGA.js → chunk-B42ZCCZ7.js} +54 -2
- package/dist/chunk-B42ZCCZ7.js.map +1 -0
- package/dist/{chunk-QT7BUKWR.js → chunk-G7JQRLQE.js} +141 -37
- package/dist/chunk-G7JQRLQE.js.map +1 -0
- package/dist/{chunk-LHDWONBI.js → chunk-JR5K5WVR.js} +45 -6
- package/dist/chunk-JR5K5WVR.js.map +1 -0
- package/dist/{chunk-TAAEMX3L.js → chunk-LVPBJ7MI.js} +2 -2
- package/dist/{chunk-XR2ZUO4R.js → chunk-QGZUMIVO.js} +2 -2
- package/dist/{chunk-P4J6FKAP.js → chunk-VO6DCRWV.js} +36 -64
- package/dist/chunk-VO6DCRWV.js.map +1 -0
- package/dist/chunk-W2ZUPR3W.js +64 -0
- package/dist/chunk-W2ZUPR3W.js.map +1 -0
- package/dist/{chunk-YJAMY25R.js → chunk-Y7LS6DEF.js} +26 -39
- package/dist/chunk-Y7LS6DEF.js.map +1 -0
- package/dist/{client-3AAXAX4C.js → client-SCIY6SUP.js} +12 -4
- package/dist/{config-IDAHD7S3.js → config-BGS5MX4D.js} +10 -2
- package/dist/{cron-SKYKVZ6K.js → cron-EOULYO3R.js} +8 -3
- package/dist/cron-EOULYO3R.js.map +1 -0
- package/dist/{eas-JE3NQCXE.js → eas-X5UIEM6D.js} +14 -8
- package/dist/{governor-J3W67NXA.js → governor-ZKRSAHG4.js} +6 -6
- package/dist/index.js +1599 -392
- package/dist/index.js.map +1 -1
- package/dist/{network-DBUZ7GRF.js → network-UTSOP7EF.js} +3 -3
- package/dist/research-SJ6D3L2B.js +14 -0
- package/dist/{research-47YMVW3N.js → research-ZW6XVTGZ.js} +20 -15
- package/dist/research-ZW6XVTGZ.js.map +1 -0
- package/dist/session-XAW5UIXP.js +17 -0
- package/dist/session-XAW5UIXP.js.map +1 -0
- package/dist/{session-Q2WRYXYF.js → session-XZNKLK3I.js} +17 -66
- package/dist/session-XZNKLK3I.js.map +1 -0
- package/dist/{trade-D6VT5MLQ.js → trade-OJM5HNHL.js} +139 -68
- package/dist/trade-OJM5HNHL.js.map +1 -0
- package/dist/xmtp-XKHXATPQ.js +278 -0
- package/dist/xmtp-XKHXATPQ.js.map +1 -0
- package/package.json +7 -2
- package/dist/chat-WKOSUZXO.js.map +0 -1
- package/dist/chunk-CTLEZZO7.js.map +0 -1
- package/dist/chunk-I7CKBBOG.js +0 -129
- package/dist/chunk-I7CKBBOG.js.map +0 -1
- package/dist/chunk-LHDWONBI.js.map +0 -1
- package/dist/chunk-P4J6FKAP.js.map +0 -1
- package/dist/chunk-QT7BUKWR.js.map +0 -1
- package/dist/chunk-SZ5QQJGA.js.map +0 -1
- package/dist/chunk-YJAMY25R.js.map +0 -1
- package/dist/cron-SKYKVZ6K.js.map +0 -1
- package/dist/research-47YMVW3N.js.map +0 -1
- package/dist/research-DZINC4N4.js +0 -14
- package/dist/session-Q2WRYXYF.js.map +0 -1
- package/dist/trade-D6VT5MLQ.js.map +0 -1
- package/dist/xmtp-7DF7UG66.js +0 -367
- package/dist/xmtp-7DF7UG66.js.map +0 -1
- /package/dist/{chunk-TAAEMX3L.js.map → chunk-LVPBJ7MI.js.map} +0 -0
- /package/dist/{chunk-XR2ZUO4R.js.map → chunk-QGZUMIVO.js.map} +0 -0
- /package/dist/{client-3AAXAX4C.js.map → client-SCIY6SUP.js.map} +0 -0
- /package/dist/{config-IDAHD7S3.js.map → config-BGS5MX4D.js.map} +0 -0
- /package/dist/{eas-JE3NQCXE.js.map → eas-X5UIEM6D.js.map} +0 -0
- /package/dist/{governor-J3W67NXA.js.map → governor-ZKRSAHG4.js.map} +0 -0
- /package/dist/{network-DBUZ7GRF.js.map → network-UTSOP7EF.js.map} +0 -0
- /package/dist/{research-DZINC4N4.js.map → research-SJ6D3L2B.js.map} +0 -0
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getChain,
|
|
3
|
+
getRpcUrl
|
|
4
|
+
} from "./chunk-LVPBJ7MI.js";
|
|
5
|
+
import {
|
|
6
|
+
loadConfig
|
|
7
|
+
} from "./chunk-B42ZCCZ7.js";
|
|
8
|
+
|
|
9
|
+
// src/lib/client.ts
|
|
10
|
+
import { createPublicClient, createWalletClient, http } from "viem";
|
|
11
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
12
|
+
|
|
13
|
+
// src/lib/errors.ts
|
|
14
|
+
import { decodeErrorResult, BaseError } from "viem";
|
|
15
|
+
var CONTRACT_ERRORS_ABI = [
|
|
16
|
+
// ── SyndicateVault ──
|
|
17
|
+
{ type: "error", name: "InvalidOwner", inputs: [] },
|
|
18
|
+
{ type: "error", name: "InvalidExecutorImpl", inputs: [] },
|
|
19
|
+
{ type: "error", name: "NotActiveAgent", inputs: [] },
|
|
20
|
+
{ type: "error", name: "SimulationFailed", inputs: [] },
|
|
21
|
+
{ type: "error", name: "InvalidDepositor", inputs: [] },
|
|
22
|
+
{ type: "error", name: "DepositorAlreadyApproved", inputs: [] },
|
|
23
|
+
{ type: "error", name: "DepositorNotApproved", inputs: [] },
|
|
24
|
+
{ type: "error", name: "NotApprovedDepositor", inputs: [] },
|
|
25
|
+
{ type: "error", name: "AgentAlreadyRegistered", inputs: [] },
|
|
26
|
+
{ type: "error", name: "AgentNotActive", inputs: [] },
|
|
27
|
+
{ type: "error", name: "InvalidAgentRegistry", inputs: [] },
|
|
28
|
+
{ type: "error", name: "NotAgentOwner", inputs: [] },
|
|
29
|
+
{ type: "error", name: "NotGovernor", inputs: [] },
|
|
30
|
+
{ type: "error", name: "RedemptionsLocked", inputs: [] },
|
|
31
|
+
{ type: "error", name: "DepositsLocked", inputs: [] },
|
|
32
|
+
{ type: "error", name: "InvalidAgentAddress", inputs: [] },
|
|
33
|
+
{ type: "error", name: "TransferFailed", inputs: [] },
|
|
34
|
+
{ type: "error", name: "ZeroAddress", inputs: [] },
|
|
35
|
+
{ type: "error", name: "CannotRescueAsset", inputs: [] },
|
|
36
|
+
{ type: "error", name: "NotFactory", inputs: [] },
|
|
37
|
+
// ── SyndicateGovernor ──
|
|
38
|
+
{ type: "error", name: "VaultNotRegistered", inputs: [] },
|
|
39
|
+
{ type: "error", name: "VaultAlreadyRegistered", inputs: [] },
|
|
40
|
+
{ type: "error", name: "NotRegisteredAgent", inputs: [] },
|
|
41
|
+
{ type: "error", name: "PerformanceFeeTooHigh", inputs: [] },
|
|
42
|
+
{ type: "error", name: "StrategyDurationTooLong", inputs: [] },
|
|
43
|
+
{ type: "error", name: "StrategyDurationTooShort", inputs: [] },
|
|
44
|
+
{ type: "error", name: "EmptyExecuteCalls", inputs: [] },
|
|
45
|
+
{ type: "error", name: "EmptySettlementCalls", inputs: [] },
|
|
46
|
+
{ type: "error", name: "NotWithinVotingPeriod", inputs: [] },
|
|
47
|
+
{ type: "error", name: "NoVotingPower", inputs: [] },
|
|
48
|
+
{ type: "error", name: "AlreadyVoted", inputs: [] },
|
|
49
|
+
{ type: "error", name: "ProposalNotFound", inputs: [] },
|
|
50
|
+
{ type: "error", name: "ProposalNotApproved", inputs: [] },
|
|
51
|
+
{ type: "error", name: "ExecutionWindowExpired", inputs: [] },
|
|
52
|
+
{ type: "error", name: "StrategyAlreadyActive", inputs: [] },
|
|
53
|
+
{ type: "error", name: "CooldownNotElapsed", inputs: [] },
|
|
54
|
+
{ type: "error", name: "ProposalNotExecuted", inputs: [] },
|
|
55
|
+
{ type: "error", name: "ProposalNotCancellable", inputs: [] },
|
|
56
|
+
{ type: "error", name: "NotProposer", inputs: [] },
|
|
57
|
+
{ type: "error", name: "InvalidVotingPeriod", inputs: [] },
|
|
58
|
+
{ type: "error", name: "InvalidExecutionWindow", inputs: [] },
|
|
59
|
+
{ type: "error", name: "InvalidVetoThresholdBps", inputs: [] },
|
|
60
|
+
{ type: "error", name: "InvalidMaxPerformanceFeeBps", inputs: [] },
|
|
61
|
+
{ type: "error", name: "InvalidStrategyDurationBounds", inputs: [] },
|
|
62
|
+
{ type: "error", name: "InvalidCooldownPeriod", inputs: [] },
|
|
63
|
+
{ type: "error", name: "InvalidVault", inputs: [] },
|
|
64
|
+
{ type: "error", name: "NotVaultOwner", inputs: [] },
|
|
65
|
+
{ type: "error", name: "StrategyDurationNotElapsed", inputs: [] },
|
|
66
|
+
{ type: "error", name: "InvalidProtocolFeeBps", inputs: [] },
|
|
67
|
+
{ type: "error", name: "InvalidProtocolFeeRecipient", inputs: [] },
|
|
68
|
+
{ type: "error", name: "NotCoProposer", inputs: [] },
|
|
69
|
+
{ type: "error", name: "CollaborationExpired", inputs: [] },
|
|
70
|
+
{ type: "error", name: "AlreadyApproved", inputs: [] },
|
|
71
|
+
{ type: "error", name: "InvalidSplits", inputs: [] },
|
|
72
|
+
{ type: "error", name: "TooManyCoProposers", inputs: [] },
|
|
73
|
+
{ type: "error", name: "SplitTooLow", inputs: [] },
|
|
74
|
+
{ type: "error", name: "LeadSplitTooLow", inputs: [] },
|
|
75
|
+
{ type: "error", name: "DuplicateCoProposer", inputs: [] },
|
|
76
|
+
{ type: "error", name: "NotDraftState", inputs: [] },
|
|
77
|
+
{ type: "error", name: "InvalidCollaborationWindow", inputs: [] },
|
|
78
|
+
{ type: "error", name: "NotAuthorized", inputs: [] },
|
|
79
|
+
{ type: "error", name: "InvalidMaxCoProposers", inputs: [] },
|
|
80
|
+
{ type: "error", name: "Reentrancy", inputs: [] },
|
|
81
|
+
// ── GovernorParameters (timelock) ──
|
|
82
|
+
{ type: "error", name: "ChangeAlreadyPending", inputs: [] },
|
|
83
|
+
{ type: "error", name: "NoChangePending", inputs: [] },
|
|
84
|
+
{ type: "error", name: "ChangeNotReady", inputs: [] },
|
|
85
|
+
{ type: "error", name: "InvalidParameterChangeDelay", inputs: [] },
|
|
86
|
+
{ type: "error", name: "InvalidParameterKey", inputs: [] },
|
|
87
|
+
// ── SyndicateFactory ──
|
|
88
|
+
{ type: "error", name: "InvalidVaultImpl", inputs: [] },
|
|
89
|
+
{ type: "error", name: "InvalidENSRegistrar", inputs: [] },
|
|
90
|
+
{ type: "error", name: "SubdomainTooShort", inputs: [] },
|
|
91
|
+
{ type: "error", name: "SubdomainTaken", inputs: [] },
|
|
92
|
+
{ type: "error", name: "NotCreator", inputs: [] },
|
|
93
|
+
{ type: "error", name: "InvalidGovernor", inputs: [] },
|
|
94
|
+
{ type: "error", name: "InsufficientCreationFee", inputs: [] },
|
|
95
|
+
{ type: "error", name: "InvalidFeeToken", inputs: [] },
|
|
96
|
+
{ type: "error", name: "ManagementFeeTooHigh", inputs: [] },
|
|
97
|
+
{ type: "error", name: "UpgradesDisabled", inputs: [] },
|
|
98
|
+
{ type: "error", name: "VaultNotDeployed", inputs: [] },
|
|
99
|
+
{ type: "error", name: "StrategyActive", inputs: [] },
|
|
100
|
+
// ── BaseStrategy ──
|
|
101
|
+
{ type: "error", name: "AlreadyInitialized", inputs: [] },
|
|
102
|
+
{ type: "error", name: "NotVault", inputs: [] },
|
|
103
|
+
{ type: "error", name: "NotExecuted", inputs: [] },
|
|
104
|
+
{ type: "error", name: "AlreadyExecuted", inputs: [] },
|
|
105
|
+
{ type: "error", name: "AlreadySettled", inputs: [] },
|
|
106
|
+
// ── MoonwellSupplyStrategy / WstETHMoonwellStrategy ──
|
|
107
|
+
{ type: "error", name: "InvalidAmount", inputs: [] },
|
|
108
|
+
{ type: "error", name: "MintFailed", inputs: [] },
|
|
109
|
+
{ type: "error", name: "RedeemFailed", inputs: [] },
|
|
110
|
+
// ── AerodromeLPStrategy ──
|
|
111
|
+
{ type: "error", name: "GaugeMismatch", inputs: [] },
|
|
112
|
+
// ── WstETHMoonwellStrategy / VeniceInferenceStrategy ──
|
|
113
|
+
{ type: "error", name: "SwapFailed", inputs: [] },
|
|
114
|
+
{ type: "error", name: "AlreadySettledParams", inputs: [] },
|
|
115
|
+
// ── VeniceInferenceStrategy ──
|
|
116
|
+
{ type: "error", name: "NoAgent", inputs: [] }
|
|
117
|
+
];
|
|
118
|
+
var ERROR_MESSAGES = {
|
|
119
|
+
// Vault — permissions / state
|
|
120
|
+
InvalidOwner: "The caller is not the vault owner.",
|
|
121
|
+
NotActiveAgent: "Your wallet is not registered as an active agent on this vault. Ask the creator to run: sherwood syndicate approve --agent-id <id> --wallet <your-address>",
|
|
122
|
+
NotApprovedDepositor: "Your address is not on the depositor whitelist. Ask the vault creator to approve you.",
|
|
123
|
+
NotGovernor: "This operation can only be called by the governor contract.",
|
|
124
|
+
NotFactory: "This operation can only be called by the factory contract.",
|
|
125
|
+
RedemptionsLocked: "Redemptions are locked while a strategy is executing. Wait for the proposal to be settled.",
|
|
126
|
+
DepositsLocked: "Deposits are locked while an active proposal exists. Wait for settlement.",
|
|
127
|
+
InvalidDepositor: "Invalid depositor address.",
|
|
128
|
+
DepositorAlreadyApproved: "This depositor is already on the whitelist.",
|
|
129
|
+
DepositorNotApproved: "This depositor is not on the whitelist.",
|
|
130
|
+
AgentAlreadyRegistered: "This agent wallet is already registered on the vault.",
|
|
131
|
+
AgentNotActive: "This agent is registered but not active.",
|
|
132
|
+
InvalidAgentRegistry: "Agent registry address is invalid.",
|
|
133
|
+
NotAgentOwner: "You do not own this ERC-8004 agent identity NFT.",
|
|
134
|
+
InvalidAgentAddress: "Invalid agent wallet address (cannot be zero).",
|
|
135
|
+
InvalidExecutorImpl: "Executor implementation address is invalid.",
|
|
136
|
+
SimulationFailed: "Transaction simulation failed \u2014 the batch calls would revert onchain.",
|
|
137
|
+
TransferFailed: "ERC-20 token transfer failed. Check token balance and approvals.",
|
|
138
|
+
ZeroAddress: "A required address parameter is the zero address.",
|
|
139
|
+
CannotRescueAsset: "Cannot rescue the vault's underlying asset \u2014 use redeem() instead.",
|
|
140
|
+
// Governor — proposal lifecycle
|
|
141
|
+
VaultNotRegistered: "This vault is not registered with the governor. The factory registers vaults automatically on creation.",
|
|
142
|
+
VaultAlreadyRegistered: "This vault is already registered with the governor.",
|
|
143
|
+
NotRegisteredAgent: "Your wallet is not a registered agent on this vault. Register first via: sherwood syndicate approve",
|
|
144
|
+
PerformanceFeeTooHigh: "Performance fee exceeds the governor's maxPerformanceFeeBps. Check: sherwood governor info",
|
|
145
|
+
StrategyDurationTooLong: "Strategy duration exceeds the governor's maxStrategyDuration. Check: sherwood governor info",
|
|
146
|
+
StrategyDurationTooShort: "Strategy duration is below the governor's minStrategyDuration. Check: sherwood governor info",
|
|
147
|
+
EmptyExecuteCalls: "Proposal must include at least one execute call.",
|
|
148
|
+
EmptySettlementCalls: "Proposal must include at least one settlement call.",
|
|
149
|
+
NotWithinVotingPeriod: "Voting period has not started or has already ended. Check: sherwood proposal show <id>",
|
|
150
|
+
NoVotingPower: "You have no voting power (zero vault shares at the snapshot time).",
|
|
151
|
+
AlreadyVoted: "You have already voted on this proposal.",
|
|
152
|
+
ProposalNotFound: "Proposal does not exist. Check the proposal ID.",
|
|
153
|
+
ProposalNotApproved: "Proposal is not in Approved state. It may still be in voting or was rejected.",
|
|
154
|
+
ExecutionWindowExpired: "The execution window has closed. The proposal is now Expired.",
|
|
155
|
+
StrategyAlreadyActive: "Another strategy is currently executing on this vault. Settle it first before executing a new proposal.",
|
|
156
|
+
CooldownNotElapsed: "A proposal was recently settled. Wait for the cooldown period to elapse. Check: sherwood governor info",
|
|
157
|
+
ProposalNotExecuted: "Proposal has not been executed yet. Execute it first.",
|
|
158
|
+
ProposalNotCancellable: "This proposal cannot be cancelled in its current state.",
|
|
159
|
+
NotProposer: "Only the original proposer can perform this action.",
|
|
160
|
+
StrategyDurationNotElapsed: "Strategy duration has not elapsed yet. Only the proposer can settle early.",
|
|
161
|
+
// Governor — parameter validation
|
|
162
|
+
InvalidVotingPeriod: "Voting period is outside allowed bounds (check governor constants).",
|
|
163
|
+
InvalidExecutionWindow: "Execution window is outside allowed bounds.",
|
|
164
|
+
InvalidVetoThresholdBps: "Veto threshold must be between the allowed bounds (in bps).",
|
|
165
|
+
InvalidMaxPerformanceFeeBps: "Max performance fee is outside allowed bounds.",
|
|
166
|
+
InvalidStrategyDurationBounds: "Strategy duration bounds are invalid (min must be < max).",
|
|
167
|
+
InvalidCooldownPeriod: "Cooldown period is outside allowed bounds.",
|
|
168
|
+
InvalidVault: "Invalid vault address.",
|
|
169
|
+
NotVaultOwner: "Only the vault owner can perform this action.",
|
|
170
|
+
InvalidProtocolFeeBps: "Protocol fee exceeds the 10% maximum (1000 bps).",
|
|
171
|
+
InvalidProtocolFeeRecipient: "Protocol fee recipient must be set before enabling protocol fees.",
|
|
172
|
+
// Governor — collaborative proposals
|
|
173
|
+
NotCoProposer: "You are not listed as a co-proposer on this proposal.",
|
|
174
|
+
CollaborationExpired: "The collaboration window has expired.",
|
|
175
|
+
AlreadyApproved: "This co-proposer has already approved.",
|
|
176
|
+
InvalidSplits: "Co-proposer fee splits must sum correctly with the lead proposer split.",
|
|
177
|
+
TooManyCoProposers: "Exceeds the maximum number of co-proposers. Check: sherwood governor info",
|
|
178
|
+
SplitTooLow: "A co-proposer's fee split is below the minimum.",
|
|
179
|
+
LeadSplitTooLow: "The lead proposer's fee split is below the minimum.",
|
|
180
|
+
DuplicateCoProposer: "Duplicate co-proposer address in the list.",
|
|
181
|
+
NotDraftState: "Proposal must be in Draft state for this operation.",
|
|
182
|
+
InvalidCollaborationWindow: "Collaboration window is outside allowed bounds.",
|
|
183
|
+
NotAuthorized: "You are not authorized to perform this action.",
|
|
184
|
+
InvalidMaxCoProposers: "Max co-proposers value is outside allowed bounds.",
|
|
185
|
+
Reentrancy: "Reentrancy detected \u2014 this call cannot be made during another call.",
|
|
186
|
+
// Governor — parameter timelock
|
|
187
|
+
ChangeAlreadyPending: "A parameter change is already pending for this parameter. Finalize or cancel it first.",
|
|
188
|
+
NoChangePending: "No parameter change is pending for this key.",
|
|
189
|
+
ChangeNotReady: "Parameter change timelock has not elapsed yet. Wait for the delay to pass, then finalize.",
|
|
190
|
+
InvalidParameterChangeDelay: "Parameter change delay is outside allowed bounds.",
|
|
191
|
+
InvalidParameterKey: "Unknown parameter key.",
|
|
192
|
+
// Factory
|
|
193
|
+
InvalidVaultImpl: "Vault implementation address is invalid.",
|
|
194
|
+
InvalidENSRegistrar: "ENS registrar address is invalid.",
|
|
195
|
+
SubdomainTooShort: "Subdomain must be at least 3 characters.",
|
|
196
|
+
SubdomainTaken: "This subdomain is already taken. Choose a different name.",
|
|
197
|
+
NotCreator: "Only the syndicate creator can perform this action.",
|
|
198
|
+
InvalidGovernor: "Governor address is invalid.",
|
|
199
|
+
InsufficientCreationFee: "Insufficient creation fee. Check the required fee amount.",
|
|
200
|
+
InvalidFeeToken: "Invalid fee token address.",
|
|
201
|
+
ManagementFeeTooHigh: "Management fee exceeds the maximum allowed.",
|
|
202
|
+
UpgradesDisabled: "Vault upgrades are currently disabled by the factory owner.",
|
|
203
|
+
VaultNotDeployed: "Vault has not been deployed yet.",
|
|
204
|
+
StrategyActive: "Cannot perform this action while a strategy is actively executing.",
|
|
205
|
+
// Strategy — base
|
|
206
|
+
AlreadyInitialized: "This strategy clone was already initialized. Deploy a fresh clone.",
|
|
207
|
+
NotVault: "Only the vault can call this strategy function.",
|
|
208
|
+
NotExecuted: "Strategy has not been executed yet.",
|
|
209
|
+
AlreadyExecuted: "Strategy has already been executed.",
|
|
210
|
+
AlreadySettled: "Strategy has already been settled.",
|
|
211
|
+
// Strategy — Moonwell / WstETH
|
|
212
|
+
InvalidAmount: "Invalid amount \u2014 must be greater than zero.",
|
|
213
|
+
MintFailed: "Moonwell cToken mint failed. The underlying supply may have hit the market cap.",
|
|
214
|
+
RedeemFailed: "Moonwell cToken redeem failed. Check that sufficient liquidity is available.",
|
|
215
|
+
// Strategy — Aerodrome
|
|
216
|
+
GaugeMismatch: "Aerodrome gauge does not match the expected pool.",
|
|
217
|
+
// Strategy — WstETH / Venice
|
|
218
|
+
SwapFailed: "Token swap failed. Check slippage tolerance and pool liquidity.",
|
|
219
|
+
AlreadySettledParams: "Settlement parameters have already been set.",
|
|
220
|
+
// Strategy — Venice
|
|
221
|
+
NoAgent: "No agent is registered on the vault. Register an agent first."
|
|
222
|
+
};
|
|
223
|
+
function decodeContractError(data) {
|
|
224
|
+
try {
|
|
225
|
+
const decoded = decodeErrorResult({
|
|
226
|
+
abi: CONTRACT_ERRORS_ABI,
|
|
227
|
+
data
|
|
228
|
+
});
|
|
229
|
+
const message = ERROR_MESSAGES[decoded.errorName] || `Contract error: ${decoded.errorName}`;
|
|
230
|
+
return { name: decoded.errorName, message };
|
|
231
|
+
} catch {
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
function extractRevertData(err) {
|
|
236
|
+
if (!(err instanceof BaseError)) return null;
|
|
237
|
+
const revertError = err.walk((e) => {
|
|
238
|
+
return e.data !== void 0;
|
|
239
|
+
});
|
|
240
|
+
if (revertError) {
|
|
241
|
+
const data = revertError.data;
|
|
242
|
+
if (typeof data === "string" && data.startsWith("0x")) {
|
|
243
|
+
return data;
|
|
244
|
+
}
|
|
245
|
+
if (typeof data === "object" && data?.data && typeof data.data === "string") {
|
|
246
|
+
return data.data;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
const msg = err.message || "";
|
|
250
|
+
const match = msg.match(/(?:signature|data)\s*"?(0x[0-9a-fA-F]+)"?/);
|
|
251
|
+
if (match) return match[1];
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
254
|
+
var KNOWN_REVERT_STRINGS = {
|
|
255
|
+
"ERC20: transfer amount exceeds balance": "Insufficient token balance for this transfer.",
|
|
256
|
+
"ERC20: transfer amount exceeds allowance": "Token allowance insufficient. An approval step may have been skipped.",
|
|
257
|
+
"ERC20: insufficient allowance": "Token allowance insufficient. An approval step may have been skipped.",
|
|
258
|
+
"Ownable: caller is not the owner": "Only the contract owner can call this function.",
|
|
259
|
+
"Pausable: paused": "The contract is currently paused."
|
|
260
|
+
};
|
|
261
|
+
function formatContractError(err) {
|
|
262
|
+
const revertData = extractRevertData(err);
|
|
263
|
+
if (revertData && revertData.length >= 10) {
|
|
264
|
+
const decoded = decodeContractError(revertData);
|
|
265
|
+
if (decoded) return decoded.message;
|
|
266
|
+
}
|
|
267
|
+
const rawMsg = err instanceof Error ? err.message : String(err);
|
|
268
|
+
for (const [pattern, message] of Object.entries(KNOWN_REVERT_STRINGS)) {
|
|
269
|
+
if (rawMsg.includes(pattern)) return message;
|
|
270
|
+
}
|
|
271
|
+
if (rawMsg.includes("replacement transaction underpriced")) {
|
|
272
|
+
return "A previous transaction is stuck. The CLI retried with higher gas but the error persists. Try again in a moment.";
|
|
273
|
+
}
|
|
274
|
+
if (rawMsg.includes("nonce too low") || rawMsg.includes("NONCE_EXPIRED")) {
|
|
275
|
+
return "Transaction nonce conflict \u2014 a previous transaction is still pending. Wait a moment and retry.";
|
|
276
|
+
}
|
|
277
|
+
if (rawMsg.includes("insufficient funds for gas")) {
|
|
278
|
+
return "Insufficient ETH for gas fees. Top up your wallet with ETH on Base.";
|
|
279
|
+
}
|
|
280
|
+
let cleaned = rawMsg.replace(/ContractFunctionRevertedError:\s*/g, "").replace(/Docs:\s*https:\/\/\S+/g, "").replace(/Version:\s*viem@\S+/g, "").replace(/Request Arguments:[\s\S]*$/m, "").replace(/Contract Call:[\s\S]*?(?=\n\n|\n[A-Z]|$)/m, "").trim();
|
|
281
|
+
const sigMatch = cleaned.match(/signature[:\s]+"?(0x[0-9a-fA-F]{8,})"?/);
|
|
282
|
+
if (sigMatch) {
|
|
283
|
+
const decoded = decodeContractError(sigMatch[1]);
|
|
284
|
+
if (decoded) return decoded.message;
|
|
285
|
+
cleaned = `Contract reverted with unknown error selector ${sigMatch[1]}. Check the transaction on Basescan for details.`;
|
|
286
|
+
}
|
|
287
|
+
return cleaned;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// src/lib/client.ts
|
|
291
|
+
var _publicClient = null;
|
|
292
|
+
var _walletClient = null;
|
|
293
|
+
function getPrivateKey() {
|
|
294
|
+
const config = loadConfig();
|
|
295
|
+
if (config.privateKey) {
|
|
296
|
+
const k = config.privateKey;
|
|
297
|
+
return k.startsWith("0x") ? k : `0x${k}`;
|
|
298
|
+
}
|
|
299
|
+
const env = process.env.PRIVATE_KEY;
|
|
300
|
+
if (env) {
|
|
301
|
+
return env.startsWith("0x") ? env : `0x${env}`;
|
|
302
|
+
}
|
|
303
|
+
throw new Error(
|
|
304
|
+
"Private key not found. Run 'sherwood config set --private-key <key>' or set PRIVATE_KEY env var."
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
function getPublicClient() {
|
|
308
|
+
const chain = getChain();
|
|
309
|
+
if (_publicClient && _publicClient.chain?.id !== chain.id) {
|
|
310
|
+
_publicClient = null;
|
|
311
|
+
}
|
|
312
|
+
if (!_publicClient) {
|
|
313
|
+
_publicClient = createPublicClient({
|
|
314
|
+
chain,
|
|
315
|
+
transport: http(getRpcUrl())
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
return _publicClient;
|
|
319
|
+
}
|
|
320
|
+
function getWalletClient() {
|
|
321
|
+
const chain = getChain();
|
|
322
|
+
if (_walletClient && _walletClient.chain?.id !== chain.id) {
|
|
323
|
+
_walletClient = null;
|
|
324
|
+
}
|
|
325
|
+
if (!_walletClient) {
|
|
326
|
+
const account = privateKeyToAccount(getPrivateKey());
|
|
327
|
+
_walletClient = createWalletClient({
|
|
328
|
+
account,
|
|
329
|
+
chain,
|
|
330
|
+
transport: http(getRpcUrl())
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
return _walletClient;
|
|
334
|
+
}
|
|
335
|
+
function resetClients() {
|
|
336
|
+
_publicClient = null;
|
|
337
|
+
_walletClient = null;
|
|
338
|
+
}
|
|
339
|
+
function getAccount() {
|
|
340
|
+
return privateKeyToAccount(getPrivateKey());
|
|
341
|
+
}
|
|
342
|
+
async function estimateFeesWithBuffer() {
|
|
343
|
+
const client = getPublicClient();
|
|
344
|
+
const { maxFeePerGas, maxPriorityFeePerGas } = await client.estimateFeesPerGas();
|
|
345
|
+
return {
|
|
346
|
+
maxFeePerGas: maxFeePerGas * 120n / 100n,
|
|
347
|
+
maxPriorityFeePerGas: maxPriorityFeePerGas * 120n / 100n
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
var MAX_RETRIES = 3;
|
|
351
|
+
var RETRY_DELAY_MS = 1500;
|
|
352
|
+
var STUCK_NONCE_CONFIRM_DELAY_MS = 2500;
|
|
353
|
+
var GAS_BUMP_NUMERATOR = 110n;
|
|
354
|
+
var GAS_BUMP_DENOMINATOR = 100n;
|
|
355
|
+
function isUnderpricedError(msg) {
|
|
356
|
+
return msg.includes("replacement transaction underpriced");
|
|
357
|
+
}
|
|
358
|
+
function isNonceStaleError(msg) {
|
|
359
|
+
return msg.includes("nonce too low") || msg.includes("NONCE_EXPIRED");
|
|
360
|
+
}
|
|
361
|
+
function isRetryableError(err) {
|
|
362
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
363
|
+
return isUnderpricedError(msg) || isNonceStaleError(msg);
|
|
364
|
+
}
|
|
365
|
+
function bumpFees(fees) {
|
|
366
|
+
return {
|
|
367
|
+
maxFeePerGas: fees.maxFeePerGas * GAS_BUMP_NUMERATOR / GAS_BUMP_DENOMINATOR,
|
|
368
|
+
maxPriorityFeePerGas: fees.maxPriorityFeePerGas * GAS_BUMP_NUMERATOR / GAS_BUMP_DENOMINATOR
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
async function detectStuckNonce() {
|
|
372
|
+
const client = getPublicClient();
|
|
373
|
+
const address = getAccount().address;
|
|
374
|
+
const [confirmed, pending] = await Promise.all([
|
|
375
|
+
client.getTransactionCount({ address, blockTag: "latest" }),
|
|
376
|
+
client.getTransactionCount({ address, blockTag: "pending" })
|
|
377
|
+
]);
|
|
378
|
+
if (pending <= confirmed) return null;
|
|
379
|
+
await new Promise((r) => setTimeout(r, STUCK_NONCE_CONFIRM_DELAY_MS));
|
|
380
|
+
const [confirmed2, pending2] = await Promise.all([
|
|
381
|
+
client.getTransactionCount({ address, blockTag: "latest" }),
|
|
382
|
+
client.getTransactionCount({ address, blockTag: "pending" })
|
|
383
|
+
]);
|
|
384
|
+
return pending2 > confirmed2 ? confirmed2 : null;
|
|
385
|
+
}
|
|
386
|
+
async function unstickWalletSingle() {
|
|
387
|
+
const stuckNonce = await detectStuckNonce();
|
|
388
|
+
if (stuckNonce === null) {
|
|
389
|
+
throw new Error("No stuck nonce detected \u2014 wallet is clean.");
|
|
390
|
+
}
|
|
391
|
+
console.warn(` Unsticking wallet: replacing stuck tx at nonce ${stuckNonce}...`);
|
|
392
|
+
const wallet = getWalletClient();
|
|
393
|
+
const account = getAccount();
|
|
394
|
+
const { maxFeePerGas, maxPriorityFeePerGas } = await estimateFeesWithBuffer();
|
|
395
|
+
const hash = await wallet.sendTransaction({
|
|
396
|
+
account,
|
|
397
|
+
chain: wallet.chain,
|
|
398
|
+
to: account.address,
|
|
399
|
+
value: 0n,
|
|
400
|
+
nonce: stuckNonce,
|
|
401
|
+
maxFeePerGas: maxFeePerGas * 5n,
|
|
402
|
+
maxPriorityFeePerGas: maxPriorityFeePerGas * 5n
|
|
403
|
+
});
|
|
404
|
+
const client = getPublicClient();
|
|
405
|
+
await client.waitForTransactionReceipt({ hash });
|
|
406
|
+
console.warn(` Wallet unstuck (nonce ${stuckNonce} replaced).`);
|
|
407
|
+
return hash;
|
|
408
|
+
}
|
|
409
|
+
async function unstickWallet() {
|
|
410
|
+
const hashes = [];
|
|
411
|
+
while (await detectStuckNonce() !== null) {
|
|
412
|
+
hashes.push(await unstickWalletSingle());
|
|
413
|
+
}
|
|
414
|
+
if (hashes.length === 0) {
|
|
415
|
+
throw new Error("No stuck nonce detected \u2014 wallet is clean.");
|
|
416
|
+
}
|
|
417
|
+
return hashes;
|
|
418
|
+
}
|
|
419
|
+
async function withRetry(send, txParams) {
|
|
420
|
+
const client = getPublicClient();
|
|
421
|
+
const account = getAccount();
|
|
422
|
+
let fees = await estimateFeesWithBuffer();
|
|
423
|
+
while (await detectStuckNonce() !== null) {
|
|
424
|
+
await unstickWalletSingle();
|
|
425
|
+
}
|
|
426
|
+
let nonce = await client.getTransactionCount({ address: account.address, blockTag: "pending" });
|
|
427
|
+
for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
|
|
428
|
+
try {
|
|
429
|
+
return await send({ ...txParams, ...fees, nonce });
|
|
430
|
+
} catch (err) {
|
|
431
|
+
if (attempt >= MAX_RETRIES || !isRetryableError(err)) {
|
|
432
|
+
throw new Error(formatContractError(err));
|
|
433
|
+
}
|
|
434
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
435
|
+
console.warn(` Retry ${attempt + 1}/${MAX_RETRIES}: ${isNonceStaleError(msg) ? "refreshing nonce" : "bumping gas"}...`);
|
|
436
|
+
await new Promise((r) => setTimeout(r, RETRY_DELAY_MS));
|
|
437
|
+
if (isNonceStaleError(msg)) {
|
|
438
|
+
nonce = await client.getTransactionCount({ address: account.address, blockTag: "pending" });
|
|
439
|
+
} else {
|
|
440
|
+
fees = bumpFees(fees);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
throw new Error("withRetry: exhausted retries");
|
|
445
|
+
}
|
|
446
|
+
async function sendTxWithRetry(txParams) {
|
|
447
|
+
const wallet = getWalletClient();
|
|
448
|
+
return withRetry((p) => wallet.sendTransaction(p), txParams);
|
|
449
|
+
}
|
|
450
|
+
async function writeContractWithRetry(txParams) {
|
|
451
|
+
const wallet = getWalletClient();
|
|
452
|
+
return withRetry((p) => wallet.writeContract(p), txParams);
|
|
453
|
+
}
|
|
454
|
+
async function waitForReceipt(hash) {
|
|
455
|
+
const client = getPublicClient();
|
|
456
|
+
try {
|
|
457
|
+
return await client.waitForTransactionReceipt({ hash });
|
|
458
|
+
} catch (err) {
|
|
459
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
460
|
+
if (msg.includes("timeout") || msg.includes("Timed out")) {
|
|
461
|
+
if (await detectStuckNonce() !== null) {
|
|
462
|
+
console.warn(` Tx ${hash} appears stuck \u2014 attempting to unstick wallet...`);
|
|
463
|
+
while (await detectStuckNonce() !== null) {
|
|
464
|
+
await unstickWalletSingle();
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
throw err;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
export {
|
|
473
|
+
formatContractError,
|
|
474
|
+
getPublicClient,
|
|
475
|
+
getWalletClient,
|
|
476
|
+
resetClients,
|
|
477
|
+
getAccount,
|
|
478
|
+
estimateFeesWithBuffer,
|
|
479
|
+
detectStuckNonce,
|
|
480
|
+
unstickWallet,
|
|
481
|
+
sendTxWithRetry,
|
|
482
|
+
writeContractWithRetry,
|
|
483
|
+
waitForReceipt
|
|
484
|
+
};
|
|
485
|
+
//# sourceMappingURL=chunk-ASJTFFZH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/client.ts","../src/lib/errors.ts"],"sourcesContent":["/**\n * viem client factory — resolves chain and RPC from the network module.\n * Private key is read from ~/.sherwood/config.json (set via `sherwood config set --private-key`),\n * with PRIVATE_KEY env var as fallback.\n */\n\n// dotenv loaded at entrypoint\nimport type { Hex, TransactionReceipt } from \"viem\";\nimport { createPublicClient, createWalletClient, http } from \"viem\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport { getChain, getRpcUrl } from \"./network.js\";\nimport { loadConfig } from \"./config.js\";\nimport { formatContractError } from \"./errors.js\";\nexport { formatContractError } from \"./errors.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nlet _publicClient: any = null;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nlet _walletClient: any = null;\n\n/**\n * Resolve the private key: config → env → error.\n */\nfunction getPrivateKey(): `0x${string}` {\n // 1. Config (~/.sherwood/config.json)\n const config = loadConfig();\n if (config.privateKey) {\n const k = config.privateKey;\n return (k.startsWith(\"0x\") ? k : `0x${k}`) as `0x${string}`;\n }\n\n // 2. Env var fallback\n const env = process.env.PRIVATE_KEY;\n if (env) {\n return (env.startsWith(\"0x\") ? env : `0x${env}`) as `0x${string}`;\n }\n\n throw new Error(\n \"Private key not found. Run 'sherwood config set --private-key <key>' or set PRIVATE_KEY env var.\",\n );\n}\n\nexport function getPublicClient() {\n const chain = getChain();\n // Auto-invalidate if network changed since last creation\n if (_publicClient && _publicClient.chain?.id !== chain.id) {\n _publicClient = null;\n }\n if (!_publicClient) {\n _publicClient = createPublicClient({\n chain,\n transport: http(getRpcUrl()),\n });\n }\n return _publicClient as ReturnType<typeof createPublicClient>;\n}\n\nexport function getWalletClient() {\n const chain = getChain();\n // Auto-invalidate if network changed since last creation\n if (_walletClient && _walletClient.chain?.id !== chain.id) {\n _walletClient = null;\n }\n if (!_walletClient) {\n const account = privateKeyToAccount(getPrivateKey());\n _walletClient = createWalletClient({\n account,\n chain,\n transport: http(getRpcUrl()),\n });\n }\n return _walletClient as ReturnType<typeof createWalletClient>;\n}\n\n/**\n * Reset cached clients. Required for tests that call setNetwork()\n * after a client was already created.\n */\nexport function resetClients() {\n _publicClient = null;\n _walletClient = null;\n}\n\nexport function getAccount() {\n return privateKeyToAccount(getPrivateKey());\n}\n\n/**\n * Estimate EIP-1559 fees with a 20% buffer to avoid stuck txs on Base gas spikes.\n */\nexport async function estimateFeesWithBuffer() {\n const client = getPublicClient();\n const { maxFeePerGas, maxPriorityFeePerGas } =\n await client.estimateFeesPerGas();\n return {\n maxFeePerGas: (maxFeePerGas * 120n) / 100n,\n maxPriorityFeePerGas: (maxPriorityFeePerGas * 120n) / 100n,\n };\n}\n\n// ── Nonce management + retry helpers ──\n//\n// Handles: nonce collisions, underpriced replacements, stuck pending txs.\n// Gas bump ceiling: base * 1.2 (buffer) * 1.1^3 (max retries) ≈ 1.6x base fee.\n\nconst MAX_RETRIES = 3;\nconst RETRY_DELAY_MS = 1500; // backoff between retries\nconst STUCK_NONCE_CONFIRM_DELAY_MS = 2500; // staleness check delay\nconst GAS_BUMP_NUMERATOR = 110n;\nconst GAS_BUMP_DENOMINATOR = 100n;\n\nfunction isUnderpricedError(msg: string): boolean {\n return msg.includes(\"replacement transaction underpriced\");\n}\n\nfunction isNonceStaleError(msg: string): boolean {\n return msg.includes(\"nonce too low\") || msg.includes(\"NONCE_EXPIRED\");\n}\n\nfunction isRetryableError(err: unknown): boolean {\n const msg = err instanceof Error ? err.message : String(err);\n return isUnderpricedError(msg) || isNonceStaleError(msg);\n}\n\nfunction bumpFees(fees: { maxFeePerGas: bigint; maxPriorityFeePerGas: bigint }) {\n return {\n maxFeePerGas: (fees.maxFeePerGas * GAS_BUMP_NUMERATOR) / GAS_BUMP_DENOMINATOR,\n maxPriorityFeePerGas: (fees.maxPriorityFeePerGas * GAS_BUMP_NUMERATOR) / GAS_BUMP_DENOMINATOR,\n };\n}\n\n// ── Stuck nonce detection ──\n\n/**\n * Check if the wallet has a stuck nonce (pending tx count > confirmed tx count).\n * Returns the stuck nonce number, or null if the wallet is clean.\n *\n * Includes a staleness guard: if pending > confirmed, waits ~2.5s and re-checks\n * to avoid false positives from propagation delays.\n */\nexport async function detectStuckNonce(): Promise<number | null> {\n const client = getPublicClient();\n const address = getAccount().address;\n const [confirmed, pending] = await Promise.all([\n client.getTransactionCount({ address, blockTag: \"latest\" }),\n client.getTransactionCount({ address, blockTag: \"pending\" }),\n ]);\n if (pending <= confirmed) return null;\n\n // Staleness guard: re-check after a short delay to avoid false positives\n await new Promise((r) => setTimeout(r, STUCK_NONCE_CONFIRM_DELAY_MS));\n const [confirmed2, pending2] = await Promise.all([\n client.getTransactionCount({ address, blockTag: \"latest\" }),\n client.getTransactionCount({ address, blockTag: \"pending\" }),\n ]);\n return pending2 > confirmed2 ? confirmed2 : null;\n}\n\n/**\n * Clear a single stuck nonce by sending a 0-value self-transfer with aggressively bumped gas.\n * Uses 5x the buffered fee estimate to guarantee replacement even if the original tx\n * was sent during a gas spike (EIP-1559 requires >= 110% of original maxPriorityFeePerGas).\n */\nasync function unstickWalletSingle(): Promise<Hex> {\n const stuckNonce = await detectStuckNonce();\n if (stuckNonce === null) {\n throw new Error(\"No stuck nonce detected — wallet is clean.\");\n }\n\n console.warn(` Unsticking wallet: replacing stuck tx at nonce ${stuckNonce}...`);\n const wallet = getWalletClient();\n const account = getAccount();\n\n // Use 5x gas buffer to guarantee replacement even for txs sent during gas spikes\n const { maxFeePerGas, maxPriorityFeePerGas } = await estimateFeesWithBuffer();\n const hash = await wallet.sendTransaction({\n account,\n chain: wallet.chain,\n to: account.address,\n value: 0n,\n nonce: stuckNonce,\n maxFeePerGas: maxFeePerGas * 5n,\n maxPriorityFeePerGas: maxPriorityFeePerGas * 5n,\n });\n\n const client = getPublicClient();\n await client.waitForTransactionReceipt({ hash });\n console.warn(` Wallet unstuck (nonce ${stuckNonce} replaced).`);\n return hash;\n}\n\n/**\n * Unstick a wallet by clearing ALL stuck nonces, not just the first one.\n * Loops until pending == confirmed nonce count.\n */\nexport async function unstickWallet(): Promise<Hex[]> {\n const hashes: Hex[] = [];\n while ((await detectStuckNonce()) !== null) {\n hashes.push(await unstickWalletSingle());\n }\n if (hashes.length === 0) {\n throw new Error(\"No stuck nonce detected — wallet is clean.\");\n }\n return hashes;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype TxSender = (params: any) => Promise<Hex>;\n\n/**\n * Shared retry loop: explicit nonce + EIP-1559 fee buffer + gas-bump on underpriced errors.\n * On \"nonce too low\" / \"NONCE_EXPIRED\", re-fetches nonce from pending state before retrying.\n * Also detects stuck nonces before sending and auto-unsticks the wallet.\n */\nasync function withRetry(send: TxSender, txParams: Record<string, unknown>): Promise<Hex> {\n const client = getPublicClient();\n const account = getAccount();\n let fees = await estimateFeesWithBuffer();\n\n // Auto-detect and clear ALL stuck nonces before attempting the tx\n while ((await detectStuckNonce()) !== null) {\n await unstickWalletSingle();\n }\n\n let nonce = await client.getTransactionCount({ address: account.address, blockTag: \"pending\" });\n\n for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {\n try {\n return await send({ ...txParams, ...fees, nonce });\n } catch (err) {\n if (attempt >= MAX_RETRIES || !isRetryableError(err)) {\n // Decode contract revert into a human-readable message before throwing\n throw new Error(formatContractError(err));\n }\n\n const msg = err instanceof Error ? err.message : String(err);\n console.warn(` Retry ${attempt + 1}/${MAX_RETRIES}: ${isNonceStaleError(msg) ? \"refreshing nonce\" : \"bumping gas\"}...`);\n\n // Backoff between retries to let mempool settle\n await new Promise((r) => setTimeout(r, RETRY_DELAY_MS));\n\n if (isNonceStaleError(msg)) {\n // Fresh nonce = fresh tx, no replacement needed — only bump fees for underpriced errors\n nonce = await client.getTransactionCount({ address: account.address, blockTag: \"pending\" });\n } else {\n fees = bumpFees(fees);\n }\n }\n }\n throw new Error(\"withRetry: exhausted retries\");\n}\n\n/**\n * Send a raw transaction with automatic gas-bump retry on nonce/underpriced errors.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport async function sendTxWithRetry(txParams: Record<string, any>): Promise<Hex> {\n const wallet = getWalletClient();\n return withRetry((p) => wallet.sendTransaction(p), txParams);\n}\n\n/**\n * Call writeContract with automatic gas-bump retry on nonce/underpriced errors.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport async function writeContractWithRetry(txParams: Record<string, any>): Promise<Hex> {\n const wallet = getWalletClient();\n return withRetry((p) => wallet.writeContract(p), txParams);\n}\n\n/**\n * Wait for a tx receipt. On timeout, checks for stuck nonce and auto-unsticks.\n *\n * **Important**: After unsticking, the error is still re-thrown because the original\n * tx is lost. Callers should use `writeContractWithRetry` / `sendTxWithRetry` which\n * re-fetch nonces automatically. Do NOT manually retry after this throws — use the\n * retry-aware wrappers instead.\n */\nexport async function waitForReceipt(hash: Hex): Promise<TransactionReceipt> {\n const client = getPublicClient();\n try {\n return await client.waitForTransactionReceipt({ hash });\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (err: any) {\n // If receipt wait times out, check for stuck nonce\n const msg = err instanceof Error ? err.message : String(err);\n if (msg.includes(\"timeout\") || msg.includes(\"Timed out\")) {\n if ((await detectStuckNonce()) !== null) {\n console.warn(` Tx ${hash} appears stuck — attempting to unstick wallet...`);\n while ((await detectStuckNonce()) !== null) {\n await unstickWalletSingle();\n }\n }\n }\n throw err;\n }\n}\n","/**\n * Contract error decoding — turns raw reverts into human-readable messages.\n *\n * Uses viem's decodeErrorResult() against a combined ABI of all custom errors\n * from SyndicateVault, SyndicateGovernor, GovernorParameters, SyndicateFactory,\n * and strategy contracts.\n */\n\nimport { type Hex, decodeErrorResult, BaseError } from \"viem\";\n\n// ── Combined error-only ABI for decoding ──\n\nexport const CONTRACT_ERRORS_ABI = [\n // ── SyndicateVault ──\n { type: \"error\", name: \"InvalidOwner\", inputs: [] },\n { type: \"error\", name: \"InvalidExecutorImpl\", inputs: [] },\n { type: \"error\", name: \"NotActiveAgent\", inputs: [] },\n { type: \"error\", name: \"SimulationFailed\", inputs: [] },\n { type: \"error\", name: \"InvalidDepositor\", inputs: [] },\n { type: \"error\", name: \"DepositorAlreadyApproved\", inputs: [] },\n { type: \"error\", name: \"DepositorNotApproved\", inputs: [] },\n { type: \"error\", name: \"NotApprovedDepositor\", inputs: [] },\n { type: \"error\", name: \"AgentAlreadyRegistered\", inputs: [] },\n { type: \"error\", name: \"AgentNotActive\", inputs: [] },\n { type: \"error\", name: \"InvalidAgentRegistry\", inputs: [] },\n { type: \"error\", name: \"NotAgentOwner\", inputs: [] },\n { type: \"error\", name: \"NotGovernor\", inputs: [] },\n { type: \"error\", name: \"RedemptionsLocked\", inputs: [] },\n { type: \"error\", name: \"DepositsLocked\", inputs: [] },\n { type: \"error\", name: \"InvalidAgentAddress\", inputs: [] },\n { type: \"error\", name: \"TransferFailed\", inputs: [] },\n { type: \"error\", name: \"ZeroAddress\", inputs: [] },\n { type: \"error\", name: \"CannotRescueAsset\", inputs: [] },\n { type: \"error\", name: \"NotFactory\", inputs: [] },\n\n // ── SyndicateGovernor ──\n { type: \"error\", name: \"VaultNotRegistered\", inputs: [] },\n { type: \"error\", name: \"VaultAlreadyRegistered\", inputs: [] },\n { type: \"error\", name: \"NotRegisteredAgent\", inputs: [] },\n { type: \"error\", name: \"PerformanceFeeTooHigh\", inputs: [] },\n { type: \"error\", name: \"StrategyDurationTooLong\", inputs: [] },\n { type: \"error\", name: \"StrategyDurationTooShort\", inputs: [] },\n { type: \"error\", name: \"EmptyExecuteCalls\", inputs: [] },\n { type: \"error\", name: \"EmptySettlementCalls\", inputs: [] },\n { type: \"error\", name: \"NotWithinVotingPeriod\", inputs: [] },\n { type: \"error\", name: \"NoVotingPower\", inputs: [] },\n { type: \"error\", name: \"AlreadyVoted\", inputs: [] },\n { type: \"error\", name: \"ProposalNotFound\", inputs: [] },\n { type: \"error\", name: \"ProposalNotApproved\", inputs: [] },\n { type: \"error\", name: \"ExecutionWindowExpired\", inputs: [] },\n { type: \"error\", name: \"StrategyAlreadyActive\", inputs: [] },\n { type: \"error\", name: \"CooldownNotElapsed\", inputs: [] },\n { type: \"error\", name: \"ProposalNotExecuted\", inputs: [] },\n { type: \"error\", name: \"ProposalNotCancellable\", inputs: [] },\n { type: \"error\", name: \"NotProposer\", inputs: [] },\n { type: \"error\", name: \"InvalidVotingPeriod\", inputs: [] },\n { type: \"error\", name: \"InvalidExecutionWindow\", inputs: [] },\n { type: \"error\", name: \"InvalidVetoThresholdBps\", inputs: [] },\n { type: \"error\", name: \"InvalidMaxPerformanceFeeBps\", inputs: [] },\n { type: \"error\", name: \"InvalidStrategyDurationBounds\", inputs: [] },\n { type: \"error\", name: \"InvalidCooldownPeriod\", inputs: [] },\n { type: \"error\", name: \"InvalidVault\", inputs: [] },\n { type: \"error\", name: \"NotVaultOwner\", inputs: [] },\n { type: \"error\", name: \"StrategyDurationNotElapsed\", inputs: [] },\n { type: \"error\", name: \"InvalidProtocolFeeBps\", inputs: [] },\n { type: \"error\", name: \"InvalidProtocolFeeRecipient\", inputs: [] },\n { type: \"error\", name: \"NotCoProposer\", inputs: [] },\n { type: \"error\", name: \"CollaborationExpired\", inputs: [] },\n { type: \"error\", name: \"AlreadyApproved\", inputs: [] },\n { type: \"error\", name: \"InvalidSplits\", inputs: [] },\n { type: \"error\", name: \"TooManyCoProposers\", inputs: [] },\n { type: \"error\", name: \"SplitTooLow\", inputs: [] },\n { type: \"error\", name: \"LeadSplitTooLow\", inputs: [] },\n { type: \"error\", name: \"DuplicateCoProposer\", inputs: [] },\n { type: \"error\", name: \"NotDraftState\", inputs: [] },\n { type: \"error\", name: \"InvalidCollaborationWindow\", inputs: [] },\n { type: \"error\", name: \"NotAuthorized\", inputs: [] },\n { type: \"error\", name: \"InvalidMaxCoProposers\", inputs: [] },\n { type: \"error\", name: \"Reentrancy\", inputs: [] },\n\n // ── GovernorParameters (timelock) ──\n { type: \"error\", name: \"ChangeAlreadyPending\", inputs: [] },\n { type: \"error\", name: \"NoChangePending\", inputs: [] },\n { type: \"error\", name: \"ChangeNotReady\", inputs: [] },\n { type: \"error\", name: \"InvalidParameterChangeDelay\", inputs: [] },\n { type: \"error\", name: \"InvalidParameterKey\", inputs: [] },\n\n // ── SyndicateFactory ──\n { type: \"error\", name: \"InvalidVaultImpl\", inputs: [] },\n { type: \"error\", name: \"InvalidENSRegistrar\", inputs: [] },\n { type: \"error\", name: \"SubdomainTooShort\", inputs: [] },\n { type: \"error\", name: \"SubdomainTaken\", inputs: [] },\n { type: \"error\", name: \"NotCreator\", inputs: [] },\n { type: \"error\", name: \"InvalidGovernor\", inputs: [] },\n { type: \"error\", name: \"InsufficientCreationFee\", inputs: [] },\n { type: \"error\", name: \"InvalidFeeToken\", inputs: [] },\n { type: \"error\", name: \"ManagementFeeTooHigh\", inputs: [] },\n { type: \"error\", name: \"UpgradesDisabled\", inputs: [] },\n { type: \"error\", name: \"VaultNotDeployed\", inputs: [] },\n { type: \"error\", name: \"StrategyActive\", inputs: [] },\n\n // ── BaseStrategy ──\n { type: \"error\", name: \"AlreadyInitialized\", inputs: [] },\n { type: \"error\", name: \"NotVault\", inputs: [] },\n { type: \"error\", name: \"NotExecuted\", inputs: [] },\n { type: \"error\", name: \"AlreadyExecuted\", inputs: [] },\n { type: \"error\", name: \"AlreadySettled\", inputs: [] },\n\n // ── MoonwellSupplyStrategy / WstETHMoonwellStrategy ──\n { type: \"error\", name: \"InvalidAmount\", inputs: [] },\n { type: \"error\", name: \"MintFailed\", inputs: [] },\n { type: \"error\", name: \"RedeemFailed\", inputs: [] },\n\n // ── AerodromeLPStrategy ──\n { type: \"error\", name: \"GaugeMismatch\", inputs: [] },\n\n // ── WstETHMoonwellStrategy / VeniceInferenceStrategy ──\n { type: \"error\", name: \"SwapFailed\", inputs: [] },\n { type: \"error\", name: \"AlreadySettledParams\", inputs: [] },\n\n // ── VeniceInferenceStrategy ──\n { type: \"error\", name: \"NoAgent\", inputs: [] },\n] as const;\n\n// ── Human-readable error messages ──\n\nconst ERROR_MESSAGES: Record<string, string> = {\n // Vault — permissions / state\n InvalidOwner: \"The caller is not the vault owner.\",\n NotActiveAgent: \"Your wallet is not registered as an active agent on this vault. Ask the creator to run: sherwood syndicate approve --agent-id <id> --wallet <your-address>\",\n NotApprovedDepositor: \"Your address is not on the depositor whitelist. Ask the vault creator to approve you.\",\n NotGovernor: \"This operation can only be called by the governor contract.\",\n NotFactory: \"This operation can only be called by the factory contract.\",\n RedemptionsLocked: \"Redemptions are locked while a strategy is executing. Wait for the proposal to be settled.\",\n DepositsLocked: \"Deposits are locked while an active proposal exists. Wait for settlement.\",\n InvalidDepositor: \"Invalid depositor address.\",\n DepositorAlreadyApproved: \"This depositor is already on the whitelist.\",\n DepositorNotApproved: \"This depositor is not on the whitelist.\",\n AgentAlreadyRegistered: \"This agent wallet is already registered on the vault.\",\n AgentNotActive: \"This agent is registered but not active.\",\n InvalidAgentRegistry: \"Agent registry address is invalid.\",\n NotAgentOwner: \"You do not own this ERC-8004 agent identity NFT.\",\n InvalidAgentAddress: \"Invalid agent wallet address (cannot be zero).\",\n InvalidExecutorImpl: \"Executor implementation address is invalid.\",\n SimulationFailed: \"Transaction simulation failed — the batch calls would revert onchain.\",\n TransferFailed: \"ERC-20 token transfer failed. Check token balance and approvals.\",\n ZeroAddress: \"A required address parameter is the zero address.\",\n CannotRescueAsset: \"Cannot rescue the vault's underlying asset — use redeem() instead.\",\n\n // Governor — proposal lifecycle\n VaultNotRegistered: \"This vault is not registered with the governor. The factory registers vaults automatically on creation.\",\n VaultAlreadyRegistered: \"This vault is already registered with the governor.\",\n NotRegisteredAgent: \"Your wallet is not a registered agent on this vault. Register first via: sherwood syndicate approve\",\n PerformanceFeeTooHigh: \"Performance fee exceeds the governor's maxPerformanceFeeBps. Check: sherwood governor info\",\n StrategyDurationTooLong: \"Strategy duration exceeds the governor's maxStrategyDuration. Check: sherwood governor info\",\n StrategyDurationTooShort: \"Strategy duration is below the governor's minStrategyDuration. Check: sherwood governor info\",\n EmptyExecuteCalls: \"Proposal must include at least one execute call.\",\n EmptySettlementCalls: \"Proposal must include at least one settlement call.\",\n NotWithinVotingPeriod: \"Voting period has not started or has already ended. Check: sherwood proposal show <id>\",\n NoVotingPower: \"You have no voting power (zero vault shares at the snapshot time).\",\n AlreadyVoted: \"You have already voted on this proposal.\",\n ProposalNotFound: \"Proposal does not exist. Check the proposal ID.\",\n ProposalNotApproved: \"Proposal is not in Approved state. It may still be in voting or was rejected.\",\n ExecutionWindowExpired: \"The execution window has closed. The proposal is now Expired.\",\n StrategyAlreadyActive: \"Another strategy is currently executing on this vault. Settle it first before executing a new proposal.\",\n CooldownNotElapsed: \"A proposal was recently settled. Wait for the cooldown period to elapse. Check: sherwood governor info\",\n ProposalNotExecuted: \"Proposal has not been executed yet. Execute it first.\",\n ProposalNotCancellable: \"This proposal cannot be cancelled in its current state.\",\n NotProposer: \"Only the original proposer can perform this action.\",\n StrategyDurationNotElapsed: \"Strategy duration has not elapsed yet. Only the proposer can settle early.\",\n\n // Governor — parameter validation\n InvalidVotingPeriod: \"Voting period is outside allowed bounds (check governor constants).\",\n InvalidExecutionWindow: \"Execution window is outside allowed bounds.\",\n InvalidVetoThresholdBps: \"Veto threshold must be between the allowed bounds (in bps).\",\n InvalidMaxPerformanceFeeBps: \"Max performance fee is outside allowed bounds.\",\n InvalidStrategyDurationBounds: \"Strategy duration bounds are invalid (min must be < max).\",\n InvalidCooldownPeriod: \"Cooldown period is outside allowed bounds.\",\n InvalidVault: \"Invalid vault address.\",\n NotVaultOwner: \"Only the vault owner can perform this action.\",\n InvalidProtocolFeeBps: \"Protocol fee exceeds the 10% maximum (1000 bps).\",\n InvalidProtocolFeeRecipient: \"Protocol fee recipient must be set before enabling protocol fees.\",\n\n // Governor — collaborative proposals\n NotCoProposer: \"You are not listed as a co-proposer on this proposal.\",\n CollaborationExpired: \"The collaboration window has expired.\",\n AlreadyApproved: \"This co-proposer has already approved.\",\n InvalidSplits: \"Co-proposer fee splits must sum correctly with the lead proposer split.\",\n TooManyCoProposers: \"Exceeds the maximum number of co-proposers. Check: sherwood governor info\",\n SplitTooLow: \"A co-proposer's fee split is below the minimum.\",\n LeadSplitTooLow: \"The lead proposer's fee split is below the minimum.\",\n DuplicateCoProposer: \"Duplicate co-proposer address in the list.\",\n NotDraftState: \"Proposal must be in Draft state for this operation.\",\n InvalidCollaborationWindow: \"Collaboration window is outside allowed bounds.\",\n NotAuthorized: \"You are not authorized to perform this action.\",\n InvalidMaxCoProposers: \"Max co-proposers value is outside allowed bounds.\",\n Reentrancy: \"Reentrancy detected — this call cannot be made during another call.\",\n\n // Governor — parameter timelock\n ChangeAlreadyPending: \"A parameter change is already pending for this parameter. Finalize or cancel it first.\",\n NoChangePending: \"No parameter change is pending for this key.\",\n ChangeNotReady: \"Parameter change timelock has not elapsed yet. Wait for the delay to pass, then finalize.\",\n InvalidParameterChangeDelay: \"Parameter change delay is outside allowed bounds.\",\n InvalidParameterKey: \"Unknown parameter key.\",\n\n // Factory\n InvalidVaultImpl: \"Vault implementation address is invalid.\",\n InvalidENSRegistrar: \"ENS registrar address is invalid.\",\n SubdomainTooShort: \"Subdomain must be at least 3 characters.\",\n SubdomainTaken: \"This subdomain is already taken. Choose a different name.\",\n NotCreator: \"Only the syndicate creator can perform this action.\",\n InvalidGovernor: \"Governor address is invalid.\",\n InsufficientCreationFee: \"Insufficient creation fee. Check the required fee amount.\",\n InvalidFeeToken: \"Invalid fee token address.\",\n ManagementFeeTooHigh: \"Management fee exceeds the maximum allowed.\",\n UpgradesDisabled: \"Vault upgrades are currently disabled by the factory owner.\",\n VaultNotDeployed: \"Vault has not been deployed yet.\",\n StrategyActive: \"Cannot perform this action while a strategy is actively executing.\",\n\n // Strategy — base\n AlreadyInitialized: \"This strategy clone was already initialized. Deploy a fresh clone.\",\n NotVault: \"Only the vault can call this strategy function.\",\n NotExecuted: \"Strategy has not been executed yet.\",\n AlreadyExecuted: \"Strategy has already been executed.\",\n AlreadySettled: \"Strategy has already been settled.\",\n\n // Strategy — Moonwell / WstETH\n InvalidAmount: \"Invalid amount — must be greater than zero.\",\n MintFailed: \"Moonwell cToken mint failed. The underlying supply may have hit the market cap.\",\n RedeemFailed: \"Moonwell cToken redeem failed. Check that sufficient liquidity is available.\",\n\n // Strategy — Aerodrome\n GaugeMismatch: \"Aerodrome gauge does not match the expected pool.\",\n\n // Strategy — WstETH / Venice\n SwapFailed: \"Token swap failed. Check slippage tolerance and pool liquidity.\",\n AlreadySettledParams: \"Settlement parameters have already been set.\",\n\n // Strategy — Venice\n NoAgent: \"No agent is registered on the vault. Register an agent first.\",\n};\n\n// ── Decoding ──\n\n/**\n * Attempt to decode a hex revert selector into a human-readable error message.\n * Returns null if the selector doesn't match any known contract error.\n */\nexport function decodeContractError(data: Hex): { name: string; message: string } | null {\n try {\n const decoded = decodeErrorResult({\n abi: CONTRACT_ERRORS_ABI,\n data,\n });\n const message = ERROR_MESSAGES[decoded.errorName] || `Contract error: ${decoded.errorName}`;\n return { name: decoded.errorName, message };\n } catch {\n return null;\n }\n}\n\n/**\n * Extract a hex error selector from a viem error's walk chain.\n * viem wraps contract call reverts in ContractFunctionRevertedError which\n * contains a `data` field with the raw 4-byte (or longer) revert payload.\n */\nfunction extractRevertData(err: unknown): Hex | null {\n if (!(err instanceof BaseError)) return null;\n\n // Walk the viem error chain to find revert data\n const revertError = err.walk((e) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (e as any).data !== undefined;\n });\n\n if (revertError) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const data = (revertError as any).data;\n // data can be the hex string directly, or an object with a data field\n if (typeof data === \"string\" && data.startsWith(\"0x\")) {\n return data as Hex;\n }\n if (typeof data === \"object\" && data?.data && typeof data.data === \"string\") {\n return data.data as Hex;\n }\n }\n\n // Fallback: extract 0x + hex from the error message (e.g. \"reverted with 0x62df0545\")\n const msg = err.message || \"\";\n const match = msg.match(/(?:signature|data)\\s*\"?(0x[0-9a-fA-F]+)\"?/);\n if (match) return match[1] as Hex;\n\n return null;\n}\n\n// ── Known common EVM / ERC-20 revert strings ──\n\nconst KNOWN_REVERT_STRINGS: Record<string, string> = {\n \"ERC20: transfer amount exceeds balance\": \"Insufficient token balance for this transfer.\",\n \"ERC20: transfer amount exceeds allowance\": \"Token allowance insufficient. An approval step may have been skipped.\",\n \"ERC20: insufficient allowance\": \"Token allowance insufficient. An approval step may have been skipped.\",\n \"Ownable: caller is not the owner\": \"Only the contract owner can call this function.\",\n \"Pausable: paused\": \"The contract is currently paused.\",\n};\n\n/**\n * Format any caught error into a user-friendly message.\n *\n * Tries (in order):\n * 1. Decode custom error selector from our contract ABIs\n * 2. Match known EVM/ERC-20 revert reason strings\n * 3. Identify nonce / gas issues with actionable advice\n * 4. Fall back to the raw error message\n */\nexport function formatContractError(err: unknown): string {\n // 1. Try to decode custom contract error\n const revertData = extractRevertData(err);\n if (revertData && revertData.length >= 10) {\n const decoded = decodeContractError(revertData);\n if (decoded) return decoded.message;\n }\n\n const rawMsg = err instanceof Error ? err.message : String(err);\n\n // 2. Check for known revert reason strings\n for (const [pattern, message] of Object.entries(KNOWN_REVERT_STRINGS)) {\n if (rawMsg.includes(pattern)) return message;\n }\n\n // 3. Nonce / gas issues — already handled by retry, but surface clearly if they bubble up\n if (rawMsg.includes(\"replacement transaction underpriced\")) {\n return \"A previous transaction is stuck. The CLI retried with higher gas but the error persists. Try again in a moment.\";\n }\n if (rawMsg.includes(\"nonce too low\") || rawMsg.includes(\"NONCE_EXPIRED\")) {\n return \"Transaction nonce conflict — a previous transaction is still pending. Wait a moment and retry.\";\n }\n if (rawMsg.includes(\"insufficient funds for gas\")) {\n return \"Insufficient ETH for gas fees. Top up your wallet with ETH on Base.\";\n }\n\n // 4. Clean up common viem wrapper noise\n // Strip \"ContractFunctionRevertedError:\" prefix and \"Docs:\" links\n let cleaned = rawMsg\n .replace(/ContractFunctionRevertedError:\\s*/g, \"\")\n .replace(/Docs:\\s*https:\\/\\/\\S+/g, \"\")\n .replace(/Version:\\s*viem@\\S+/g, \"\")\n .replace(/Request Arguments:[\\s\\S]*$/m, \"\")\n .replace(/Contract Call:[\\s\\S]*?(?=\\n\\n|\\n[A-Z]|$)/m, \"\")\n .trim();\n\n // If we still have \"reverted with the following signature: 0x...\" try one more decode\n const sigMatch = cleaned.match(/signature[:\\s]+\"?(0x[0-9a-fA-F]{8,})\"?/);\n if (sigMatch) {\n const decoded = decodeContractError(sigMatch[1] as Hex);\n if (decoded) return decoded.message;\n // If we can't decode it, at least explain what it is\n cleaned = `Contract reverted with unknown error selector ${sigMatch[1]}. Check the transaction on Basescan for details.`;\n }\n\n return cleaned;\n}\n"],"mappings":";;;;;;;;;AAQA,SAAS,oBAAoB,oBAAoB,YAAY;AAC7D,S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
|
+
function addSyndicate(chainId, membership) {
|
|
88
|
+
const config = loadConfig();
|
|
89
|
+
const cid = String(chainId);
|
|
90
|
+
if (!config.syndicates) config.syndicates = {};
|
|
91
|
+
if (!config.syndicates[cid]) config.syndicates[cid] = [];
|
|
92
|
+
const idx = config.syndicates[cid].findIndex(
|
|
93
|
+
(s) => s.subdomain === membership.subdomain
|
|
94
|
+
);
|
|
95
|
+
if (idx >= 0) {
|
|
96
|
+
config.syndicates[cid][idx] = membership;
|
|
97
|
+
} else {
|
|
98
|
+
config.syndicates[cid].push(membership);
|
|
99
|
+
}
|
|
100
|
+
if (!config.primarySyndicate) config.primarySyndicate = {};
|
|
101
|
+
if (!config.primarySyndicate[cid]) {
|
|
102
|
+
config.primarySyndicate[cid] = membership.subdomain;
|
|
103
|
+
}
|
|
104
|
+
saveConfig(config);
|
|
105
|
+
}
|
|
106
|
+
function getSyndicates(chainId) {
|
|
107
|
+
const config = loadConfig();
|
|
108
|
+
return config.syndicates?.[String(chainId)] ?? [];
|
|
109
|
+
}
|
|
110
|
+
function setPrimarySyndicate(chainId, subdomain) {
|
|
111
|
+
const config = loadConfig();
|
|
112
|
+
if (!config.primarySyndicate) config.primarySyndicate = {};
|
|
113
|
+
config.primarySyndicate[String(chainId)] = subdomain;
|
|
114
|
+
saveConfig(config);
|
|
115
|
+
}
|
|
116
|
+
function getPrimarySyndicate(chainId) {
|
|
117
|
+
const config = loadConfig();
|
|
118
|
+
const cid = String(chainId);
|
|
119
|
+
const primarySubdomain = config.primarySyndicate?.[cid];
|
|
120
|
+
if (primarySubdomain && config.syndicates?.[cid]) {
|
|
121
|
+
const found = config.syndicates[cid].find(
|
|
122
|
+
(s) => s.subdomain === primarySubdomain
|
|
123
|
+
);
|
|
124
|
+
if (found) return found;
|
|
125
|
+
}
|
|
126
|
+
if (config.syndicates?.[cid]?.length) {
|
|
127
|
+
return config.syndicates[cid][0];
|
|
128
|
+
}
|
|
129
|
+
const vault = config.contracts?.[cid]?.vault;
|
|
130
|
+
if (vault) {
|
|
131
|
+
return { subdomain: "", vault, role: "creator" };
|
|
132
|
+
}
|
|
133
|
+
return void 0;
|
|
134
|
+
}
|
|
87
135
|
|
|
88
136
|
export {
|
|
89
137
|
loadConfig,
|
|
@@ -103,6 +151,10 @@ export {
|
|
|
103
151
|
getChainContracts,
|
|
104
152
|
getNotifyTo,
|
|
105
153
|
setNotifyTo,
|
|
106
|
-
setChainContract
|
|
154
|
+
setChainContract,
|
|
155
|
+
addSyndicate,
|
|
156
|
+
getSyndicates,
|
|
157
|
+
setPrimarySyndicate,
|
|
158
|
+
getPrimarySyndicate
|
|
107
159
|
};
|
|
108
|
-
//# sourceMappingURL=chunk-
|
|
160
|
+
//# sourceMappingURL=chunk-B42ZCCZ7.js.map
|