@grimoirelabs/core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builders/expressions.d.ts +33 -0
- package/dist/builders/expressions.d.ts.map +1 -0
- package/dist/builders/expressions.js +57 -0
- package/dist/builders/expressions.js.map +1 -0
- package/dist/builders/index.d.ts +44 -0
- package/dist/builders/index.d.ts.map +1 -0
- package/dist/builders/index.js +32 -0
- package/dist/builders/index.js.map +1 -0
- package/dist/builders/spell-builder.d.ts +124 -0
- package/dist/builders/spell-builder.d.ts.map +1 -0
- package/dist/builders/spell-builder.js +299 -0
- package/dist/builders/spell-builder.js.map +1 -0
- package/dist/builders/step-builder.d.ts +212 -0
- package/dist/builders/step-builder.d.ts.map +1 -0
- package/dist/builders/step-builder.js +499 -0
- package/dist/builders/step-builder.js.map +1 -0
- package/dist/compiler/expression-parser.d.ts +14 -0
- package/dist/compiler/expression-parser.d.ts.map +1 -0
- package/dist/compiler/expression-parser.js +460 -0
- package/dist/compiler/expression-parser.js.map +1 -0
- package/dist/compiler/grimoire/ast.d.ts +450 -0
- package/dist/compiler/grimoire/ast.d.ts.map +1 -0
- package/dist/compiler/grimoire/ast.js +19 -0
- package/dist/compiler/grimoire/ast.js.map +1 -0
- package/dist/compiler/grimoire/errors.d.ts +65 -0
- package/dist/compiler/grimoire/errors.d.ts.map +1 -0
- package/dist/compiler/grimoire/errors.js +86 -0
- package/dist/compiler/grimoire/errors.js.map +1 -0
- package/dist/compiler/grimoire/index.d.ts +24 -0
- package/dist/compiler/grimoire/index.d.ts.map +1 -0
- package/dist/compiler/grimoire/index.js +63 -0
- package/dist/compiler/grimoire/index.js.map +1 -0
- package/dist/compiler/grimoire/parser.d.ts +135 -0
- package/dist/compiler/grimoire/parser.d.ts.map +1 -0
- package/dist/compiler/grimoire/parser.js +2148 -0
- package/dist/compiler/grimoire/parser.js.map +1 -0
- package/dist/compiler/grimoire/tokenizer.d.ts +59 -0
- package/dist/compiler/grimoire/tokenizer.d.ts.map +1 -0
- package/dist/compiler/grimoire/tokenizer.js +509 -0
- package/dist/compiler/grimoire/tokenizer.js.map +1 -0
- package/dist/compiler/grimoire/transformer.d.ts +71 -0
- package/dist/compiler/grimoire/transformer.d.ts.map +1 -0
- package/dist/compiler/grimoire/transformer.js +1011 -0
- package/dist/compiler/grimoire/transformer.js.map +1 -0
- package/dist/compiler/index.d.ts +45 -0
- package/dist/compiler/index.d.ts.map +1 -0
- package/dist/compiler/index.js +97 -0
- package/dist/compiler/index.js.map +1 -0
- package/dist/compiler/ir-generator.d.ts +16 -0
- package/dist/compiler/ir-generator.d.ts.map +1 -0
- package/dist/compiler/ir-generator.js +997 -0
- package/dist/compiler/ir-generator.js.map +1 -0
- package/dist/compiler/validator.d.ts +15 -0
- package/dist/compiler/validator.d.ts.map +1 -0
- package/dist/compiler/validator.js +401 -0
- package/dist/compiler/validator.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime/circuit-breaker.d.ts +59 -0
- package/dist/runtime/circuit-breaker.d.ts.map +1 -0
- package/dist/runtime/circuit-breaker.js +155 -0
- package/dist/runtime/circuit-breaker.js.map +1 -0
- package/dist/runtime/context.d.ts +92 -0
- package/dist/runtime/context.d.ts.map +1 -0
- package/dist/runtime/context.js +219 -0
- package/dist/runtime/context.js.map +1 -0
- package/dist/runtime/error-classifier.d.ts +16 -0
- package/dist/runtime/error-classifier.d.ts.map +1 -0
- package/dist/runtime/error-classifier.js +38 -0
- package/dist/runtime/error-classifier.js.map +1 -0
- package/dist/runtime/expression-evaluator.d.ts +36 -0
- package/dist/runtime/expression-evaluator.d.ts.map +1 -0
- package/dist/runtime/expression-evaluator.js +391 -0
- package/dist/runtime/expression-evaluator.js.map +1 -0
- package/dist/runtime/index.d.ts +12 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +11 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/interpreter.d.ts +59 -0
- package/dist/runtime/interpreter.d.ts.map +1 -0
- package/dist/runtime/interpreter.js +414 -0
- package/dist/runtime/interpreter.js.map +1 -0
- package/dist/runtime/skills/registry.d.ts +11 -0
- package/dist/runtime/skills/registry.d.ts.map +1 -0
- package/dist/runtime/skills/registry.js +73 -0
- package/dist/runtime/skills/registry.js.map +1 -0
- package/dist/runtime/sqlite-state-store.d.ts +28 -0
- package/dist/runtime/sqlite-state-store.d.ts.map +1 -0
- package/dist/runtime/sqlite-state-store.js +180 -0
- package/dist/runtime/sqlite-state-store.js.map +1 -0
- package/dist/runtime/state-store.d.ts +52 -0
- package/dist/runtime/state-store.d.ts.map +1 -0
- package/dist/runtime/state-store.js +32 -0
- package/dist/runtime/state-store.js.map +1 -0
- package/dist/runtime/steps/action.d.ts +17 -0
- package/dist/runtime/steps/action.d.ts.map +1 -0
- package/dist/runtime/steps/action.js +430 -0
- package/dist/runtime/steps/action.js.map +1 -0
- package/dist/runtime/steps/advisory.d.ts +28 -0
- package/dist/runtime/steps/advisory.d.ts.map +1 -0
- package/dist/runtime/steps/advisory.js +209 -0
- package/dist/runtime/steps/advisory.js.map +1 -0
- package/dist/runtime/steps/compute.d.ts +9 -0
- package/dist/runtime/steps/compute.d.ts.map +1 -0
- package/dist/runtime/steps/compute.js +74 -0
- package/dist/runtime/steps/compute.js.map +1 -0
- package/dist/runtime/steps/conditional.d.ts +14 -0
- package/dist/runtime/steps/conditional.d.ts.map +1 -0
- package/dist/runtime/steps/conditional.js +58 -0
- package/dist/runtime/steps/conditional.js.map +1 -0
- package/dist/runtime/steps/emit.d.ts +9 -0
- package/dist/runtime/steps/emit.d.ts.map +1 -0
- package/dist/runtime/steps/emit.js +70 -0
- package/dist/runtime/steps/emit.js.map +1 -0
- package/dist/runtime/steps/halt.d.ts +9 -0
- package/dist/runtime/steps/halt.d.ts.map +1 -0
- package/dist/runtime/steps/halt.js +19 -0
- package/dist/runtime/steps/halt.js.map +1 -0
- package/dist/runtime/steps/loop.d.ts +14 -0
- package/dist/runtime/steps/loop.d.ts.map +1 -0
- package/dist/runtime/steps/loop.js +109 -0
- package/dist/runtime/steps/loop.js.map +1 -0
- package/dist/runtime/steps/parallel.d.ts +9 -0
- package/dist/runtime/steps/parallel.d.ts.map +1 -0
- package/dist/runtime/steps/parallel.js +87 -0
- package/dist/runtime/steps/parallel.js.map +1 -0
- package/dist/runtime/steps/pipeline.d.ts +9 -0
- package/dist/runtime/steps/pipeline.d.ts.map +1 -0
- package/dist/runtime/steps/pipeline.js +125 -0
- package/dist/runtime/steps/pipeline.js.map +1 -0
- package/dist/runtime/steps/try.d.ts +13 -0
- package/dist/runtime/steps/try.d.ts.map +1 -0
- package/dist/runtime/steps/try.js +222 -0
- package/dist/runtime/steps/try.js.map +1 -0
- package/dist/runtime/steps/wait.d.ts +9 -0
- package/dist/runtime/steps/wait.d.ts.map +1 -0
- package/dist/runtime/steps/wait.js +38 -0
- package/dist/runtime/steps/wait.js.map +1 -0
- package/dist/types/actions.d.ts +162 -0
- package/dist/types/actions.d.ts.map +1 -0
- package/dist/types/actions.js +5 -0
- package/dist/types/actions.js.map +1 -0
- package/dist/types/execution.d.ts +276 -0
- package/dist/types/execution.d.ts.map +1 -0
- package/dist/types/execution.js +5 -0
- package/dist/types/execution.js.map +1 -0
- package/dist/types/expressions.d.ts +100 -0
- package/dist/types/expressions.d.ts.map +1 -0
- package/dist/types/expressions.js +48 -0
- package/dist/types/expressions.js.map +1 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/ir.d.ts +187 -0
- package/dist/types/ir.d.ts.map +1 -0
- package/dist/types/ir.js +5 -0
- package/dist/types/ir.js.map +1 -0
- package/dist/types/policy.d.ts +123 -0
- package/dist/types/policy.d.ts.map +1 -0
- package/dist/types/policy.js +5 -0
- package/dist/types/policy.js.map +1 -0
- package/dist/types/primitives.d.ts +76 -0
- package/dist/types/primitives.d.ts.map +1 -0
- package/dist/types/primitives.js +10 -0
- package/dist/types/primitives.js.map +1 -0
- package/dist/types/steps.d.ts +226 -0
- package/dist/types/steps.d.ts.map +1 -0
- package/dist/types/steps.js +5 -0
- package/dist/types/steps.js.map +1 -0
- package/dist/venues/index.d.ts +6 -0
- package/dist/venues/index.d.ts.map +1 -0
- package/dist/venues/index.js +26 -0
- package/dist/venues/index.js.map +1 -0
- package/dist/venues/types.d.ts +40 -0
- package/dist/venues/types.d.ts.map +1 -0
- package/dist/venues/types.js +5 -0
- package/dist/venues/types.js.map +1 -0
- package/dist/wallet/executor.d.ts +109 -0
- package/dist/wallet/executor.d.ts.map +1 -0
- package/dist/wallet/executor.js +354 -0
- package/dist/wallet/executor.js.map +1 -0
- package/dist/wallet/index.d.ts +14 -0
- package/dist/wallet/index.d.ts.map +1 -0
- package/dist/wallet/index.js +13 -0
- package/dist/wallet/index.js.map +1 -0
- package/dist/wallet/keystore.d.ts +44 -0
- package/dist/wallet/keystore.d.ts.map +1 -0
- package/dist/wallet/keystore.js +296 -0
- package/dist/wallet/keystore.js.map +1 -0
- package/dist/wallet/provider.d.ts +111 -0
- package/dist/wallet/provider.d.ts.map +1 -0
- package/dist/wallet/provider.js +309 -0
- package/dist/wallet/provider.js.map +1 -0
- package/dist/wallet/tx-builder.d.ts +85 -0
- package/dist/wallet/tx-builder.d.ts.map +1 -0
- package/dist/wallet/tx-builder.js +290 -0
- package/dist/wallet/tx-builder.js.map +1 -0
- package/dist/wallet/types.d.ts +116 -0
- package/dist/wallet/types.d.ts.map +1 -0
- package/dist/wallet/types.js +86 -0
- package/dist/wallet/types.js.map +1 -0
- package/package.json +39 -0
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RPC Provider management
|
|
3
|
+
*
|
|
4
|
+
* Handles connection to blockchain nodes with:
|
|
5
|
+
* - Automatic fallback to backup URLs
|
|
6
|
+
* - Retry with exponential backoff
|
|
7
|
+
* - Gas price estimation
|
|
8
|
+
*/
|
|
9
|
+
import { http, createPublicClient } from "viem";
|
|
10
|
+
import { arbitrum, base, mainnet, optimism, polygon, sepolia } from "viem/chains";
|
|
11
|
+
/** HyperEVM chain definition */
|
|
12
|
+
const hyperEVM = {
|
|
13
|
+
id: 999,
|
|
14
|
+
name: "HyperEVM",
|
|
15
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
16
|
+
rpcUrls: {
|
|
17
|
+
default: { http: ["https://rpc.hyperliquid.xyz/evm"] },
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
/** Map chain IDs to viem chain objects */
|
|
21
|
+
const VIEM_CHAINS = {
|
|
22
|
+
1: mainnet,
|
|
23
|
+
10: optimism,
|
|
24
|
+
137: polygon,
|
|
25
|
+
42161: arbitrum,
|
|
26
|
+
8453: base,
|
|
27
|
+
999: hyperEVM,
|
|
28
|
+
11155111: sepolia,
|
|
29
|
+
};
|
|
30
|
+
/** Default provider configurations */
|
|
31
|
+
const DEFAULT_CONFIGS = {
|
|
32
|
+
1: {
|
|
33
|
+
chainId: 1,
|
|
34
|
+
rpcUrl: "https://eth.llamarpc.com",
|
|
35
|
+
fallbackUrls: ["https://rpc.ankr.com/eth", "https://ethereum.publicnode.com"],
|
|
36
|
+
timeout: 30000,
|
|
37
|
+
retries: 3,
|
|
38
|
+
},
|
|
39
|
+
10: {
|
|
40
|
+
chainId: 10,
|
|
41
|
+
rpcUrl: "https://mainnet.optimism.io",
|
|
42
|
+
fallbackUrls: ["https://rpc.ankr.com/optimism"],
|
|
43
|
+
timeout: 30000,
|
|
44
|
+
retries: 3,
|
|
45
|
+
},
|
|
46
|
+
137: {
|
|
47
|
+
chainId: 137,
|
|
48
|
+
rpcUrl: "https://polygon-rpc.com",
|
|
49
|
+
fallbackUrls: ["https://rpc.ankr.com/polygon"],
|
|
50
|
+
timeout: 30000,
|
|
51
|
+
retries: 3,
|
|
52
|
+
},
|
|
53
|
+
42161: {
|
|
54
|
+
chainId: 42161,
|
|
55
|
+
rpcUrl: "https://arb1.arbitrum.io/rpc",
|
|
56
|
+
fallbackUrls: ["https://rpc.ankr.com/arbitrum"],
|
|
57
|
+
timeout: 30000,
|
|
58
|
+
retries: 3,
|
|
59
|
+
},
|
|
60
|
+
8453: {
|
|
61
|
+
chainId: 8453,
|
|
62
|
+
rpcUrl: "https://mainnet.base.org",
|
|
63
|
+
fallbackUrls: ["https://base.llamarpc.com"],
|
|
64
|
+
timeout: 30000,
|
|
65
|
+
retries: 3,
|
|
66
|
+
},
|
|
67
|
+
999: {
|
|
68
|
+
chainId: 999,
|
|
69
|
+
rpcUrl: "https://rpc.hyperliquid.xyz/evm",
|
|
70
|
+
timeout: 30000,
|
|
71
|
+
retries: 3,
|
|
72
|
+
},
|
|
73
|
+
11155111: {
|
|
74
|
+
chainId: 11155111,
|
|
75
|
+
rpcUrl: "https://rpc.sepolia.org",
|
|
76
|
+
fallbackUrls: ["https://ethereum-sepolia.publicnode.com"],
|
|
77
|
+
timeout: 30000,
|
|
78
|
+
retries: 3,
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Provider wrapper with fallback and retry support
|
|
83
|
+
*/
|
|
84
|
+
export class Provider {
|
|
85
|
+
client;
|
|
86
|
+
config;
|
|
87
|
+
currentUrlIndex = 0;
|
|
88
|
+
constructor(config) {
|
|
89
|
+
this.config = {
|
|
90
|
+
...config,
|
|
91
|
+
timeout: config.timeout ?? 30000,
|
|
92
|
+
retries: config.retries ?? 3,
|
|
93
|
+
};
|
|
94
|
+
const chain = VIEM_CHAINS[config.chainId];
|
|
95
|
+
if (!chain) {
|
|
96
|
+
throw new Error(`Unsupported chain ID: ${config.chainId}`);
|
|
97
|
+
}
|
|
98
|
+
this.client = createPublicClient({
|
|
99
|
+
chain,
|
|
100
|
+
transport: http(config.rpcUrl, {
|
|
101
|
+
timeout: this.config.timeout,
|
|
102
|
+
retryCount: this.config.retries,
|
|
103
|
+
}),
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Get the chain ID
|
|
108
|
+
*/
|
|
109
|
+
get chainId() {
|
|
110
|
+
return this.config.chainId;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Get the current RPC URL
|
|
114
|
+
*/
|
|
115
|
+
get rpcUrl() {
|
|
116
|
+
const urls = [this.config.rpcUrl, ...(this.config.fallbackUrls ?? [])];
|
|
117
|
+
return urls[this.currentUrlIndex] ?? this.config.rpcUrl;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Get underlying viem client
|
|
121
|
+
*/
|
|
122
|
+
getClient() {
|
|
123
|
+
return this.client;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Get the current block number
|
|
127
|
+
*/
|
|
128
|
+
async getBlockNumber() {
|
|
129
|
+
return await this.withRetry(() => this.client.getBlockNumber());
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Get the balance of an address
|
|
133
|
+
*/
|
|
134
|
+
async getBalance(address) {
|
|
135
|
+
return await this.withRetry(() => this.client.getBalance({ address: address }));
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Get the nonce for an address
|
|
139
|
+
*/
|
|
140
|
+
async getNonce(address) {
|
|
141
|
+
return await this.withRetry(() => this.client.getTransactionCount({ address: address }));
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Estimate gas for a transaction
|
|
145
|
+
*/
|
|
146
|
+
async estimateGas(tx) {
|
|
147
|
+
return await this.withRetry(() => this.client.estimateGas({
|
|
148
|
+
to: tx.to,
|
|
149
|
+
data: tx.data,
|
|
150
|
+
value: tx.value,
|
|
151
|
+
account: tx.from,
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Get current gas prices (EIP-1559)
|
|
156
|
+
*/
|
|
157
|
+
async getGasPrices() {
|
|
158
|
+
const block = (await this.withRetry(() => this.client.getBlock({ blockTag: "latest" })));
|
|
159
|
+
const baseFee = block.baseFeePerGas ?? 0n;
|
|
160
|
+
// Default priority fee of 1.5 gwei, or use oracle if available
|
|
161
|
+
const priorityFee = 1500000000n; // 1.5 gwei
|
|
162
|
+
return {
|
|
163
|
+
maxFeePerGas: baseFee * 2n + priorityFee,
|
|
164
|
+
maxPriorityFeePerGas: priorityFee,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Get full gas estimate for a transaction
|
|
169
|
+
*/
|
|
170
|
+
async getGasEstimate(tx) {
|
|
171
|
+
const [gasLimit, gasPrices] = await Promise.all([this.estimateGas(tx), this.getGasPrices()]);
|
|
172
|
+
// Add 20% buffer to gas limit
|
|
173
|
+
const bufferedGasLimit = (gasLimit * 120n) / 100n;
|
|
174
|
+
return {
|
|
175
|
+
gasLimit: bufferedGasLimit,
|
|
176
|
+
maxFeePerGas: gasPrices.maxFeePerGas,
|
|
177
|
+
maxPriorityFeePerGas: gasPrices.maxPriorityFeePerGas,
|
|
178
|
+
estimatedCost: bufferedGasLimit * gasPrices.maxFeePerGas,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Read contract data
|
|
183
|
+
*/
|
|
184
|
+
async readContract(params) {
|
|
185
|
+
return await this.withRetry(() => this.client.readContract({
|
|
186
|
+
address: params.address,
|
|
187
|
+
abi: params.abi,
|
|
188
|
+
functionName: params.functionName,
|
|
189
|
+
args: params.args,
|
|
190
|
+
}));
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Wait for a transaction receipt
|
|
194
|
+
*/
|
|
195
|
+
async waitForTransaction(hash, confirmations = 1) {
|
|
196
|
+
return await this.withRetry(() => this.client.waitForTransactionReceipt({
|
|
197
|
+
hash: hash,
|
|
198
|
+
confirmations,
|
|
199
|
+
}));
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Execute with retry and fallback
|
|
203
|
+
*/
|
|
204
|
+
async withRetry(fn) {
|
|
205
|
+
const urls = [this.config.rpcUrl, ...(this.config.fallbackUrls ?? [])];
|
|
206
|
+
let lastError = null;
|
|
207
|
+
for (let urlIndex = 0; urlIndex < urls.length; urlIndex++) {
|
|
208
|
+
for (let attempt = 0; attempt < (this.config.retries ?? 3); attempt++) {
|
|
209
|
+
try {
|
|
210
|
+
return await fn();
|
|
211
|
+
}
|
|
212
|
+
catch (error) {
|
|
213
|
+
lastError = error;
|
|
214
|
+
// If this is a rate limit or connection error, try next URL
|
|
215
|
+
if (this.shouldSwitchProvider(error)) {
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
// Exponential backoff
|
|
219
|
+
if (attempt < (this.config.retries ?? 3) - 1) {
|
|
220
|
+
await this.sleep(2 ** attempt * 1000);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
// Try next URL
|
|
225
|
+
if (urlIndex < urls.length - 1) {
|
|
226
|
+
this.switchToUrl(urlIndex + 1);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
throw lastError ?? new Error("All retry attempts failed");
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Check if we should switch to a different provider
|
|
233
|
+
*/
|
|
234
|
+
shouldSwitchProvider(error) {
|
|
235
|
+
if (error instanceof Error) {
|
|
236
|
+
const message = error.message.toLowerCase();
|
|
237
|
+
return (message.includes("rate limit") ||
|
|
238
|
+
message.includes("too many requests") ||
|
|
239
|
+
message.includes("connection refused") ||
|
|
240
|
+
message.includes("econnrefused") ||
|
|
241
|
+
message.includes("timeout"));
|
|
242
|
+
}
|
|
243
|
+
return false;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Switch to a different RPC URL
|
|
247
|
+
*/
|
|
248
|
+
switchToUrl(index) {
|
|
249
|
+
const urls = [this.config.rpcUrl, ...(this.config.fallbackUrls ?? [])];
|
|
250
|
+
if (index >= urls.length)
|
|
251
|
+
return;
|
|
252
|
+
this.currentUrlIndex = index;
|
|
253
|
+
const chain = VIEM_CHAINS[this.config.chainId];
|
|
254
|
+
this.client = createPublicClient({
|
|
255
|
+
chain,
|
|
256
|
+
transport: http(urls[index], {
|
|
257
|
+
timeout: this.config.timeout,
|
|
258
|
+
retryCount: this.config.retries,
|
|
259
|
+
}),
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Sleep for a duration
|
|
264
|
+
*/
|
|
265
|
+
sleep(ms) {
|
|
266
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Create a provider for a specific chain
|
|
271
|
+
*/
|
|
272
|
+
export function createProvider(chainId, rpcUrl) {
|
|
273
|
+
const defaultConfig = DEFAULT_CONFIGS[chainId];
|
|
274
|
+
if (!defaultConfig && !rpcUrl) {
|
|
275
|
+
throw new Error(`No default configuration for chain ${chainId}. Please provide an RPC URL.`);
|
|
276
|
+
}
|
|
277
|
+
const config = {
|
|
278
|
+
chainId,
|
|
279
|
+
rpcUrl: rpcUrl ?? defaultConfig?.rpcUrl ?? "",
|
|
280
|
+
fallbackUrls: defaultConfig?.fallbackUrls,
|
|
281
|
+
timeout: defaultConfig?.timeout ?? 30000,
|
|
282
|
+
retries: defaultConfig?.retries ?? 3,
|
|
283
|
+
};
|
|
284
|
+
return new Provider(config);
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Format wei to human-readable string
|
|
288
|
+
*/
|
|
289
|
+
export function formatWei(wei, decimals = 18) {
|
|
290
|
+
const divisor = 10n ** BigInt(decimals);
|
|
291
|
+
const integerPart = wei / divisor;
|
|
292
|
+
const fractionalPart = wei % divisor;
|
|
293
|
+
if (fractionalPart === 0n) {
|
|
294
|
+
return integerPart.toString();
|
|
295
|
+
}
|
|
296
|
+
const fractionalStr = fractionalPart.toString().padStart(decimals, "0");
|
|
297
|
+
const trimmed = fractionalStr.replace(/0+$/, "");
|
|
298
|
+
return `${integerPart}.${trimmed}`;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Format gas cost to USD (rough estimate)
|
|
302
|
+
*/
|
|
303
|
+
export function formatGasCostUsd(gasUsed, gasPrice, ethPriceUsd = 2000) {
|
|
304
|
+
const costWei = gasUsed * gasPrice;
|
|
305
|
+
const costEth = Number(costWei) / 1e18;
|
|
306
|
+
const costUsd = costEth * ethPriceUsd;
|
|
307
|
+
return `$${costUsd.toFixed(2)}`;
|
|
308
|
+
}
|
|
309
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/wallet/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,IAAI,EAA+B,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAC7E,OAAO,EAAc,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAI9F,gCAAgC;AAChC,MAAM,QAAQ,GAAU;IACtB,EAAE,EAAE,GAAG;IACP,IAAI,EAAE,UAAU;IAChB,cAAc,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC9D,OAAO,EAAE;QACP,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,iCAAiC,CAAC,EAAE;KACvD;CACF,CAAC;AAEF,0CAA0C;AAC1C,MAAM,WAAW,GAA0B;IACzC,CAAC,EAAE,OAAO;IACV,EAAE,EAAE,QAAQ;IACZ,GAAG,EAAE,OAAO;IACZ,KAAK,EAAE,QAAQ;IACf,IAAI,EAAE,IAAI;IACV,GAAG,EAAE,QAAQ;IACb,QAAQ,EAAE,OAAO;CAClB,CAAC;AAEF,sCAAsC;AACtC,MAAM,eAAe,GAAmC;IACtD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5
|
+
* - ERC20 operations (transfer, approve)
|
|
6
|
+
* - Swap operations
|
|
7
|
+
* - Lending operations (deposit, withdraw)
|
|
8
|
+
*/
|
|
9
|
+
import type { Action } from "../types/actions.js";
|
|
10
|
+
import type { Address } from "../types/primitives.js";
|
|
11
|
+
import type { Provider } from "./provider.js";
|
|
12
|
+
import type { GasEstimate, TransactionRequest } from "./types.js";
|
|
13
|
+
/** Built transaction with metadata */
|
|
14
|
+
export interface BuiltTransaction {
|
|
15
|
+
/** The transaction request */
|
|
16
|
+
tx: TransactionRequest;
|
|
17
|
+
/** Human-readable description */
|
|
18
|
+
description: string;
|
|
19
|
+
/** Gas estimate */
|
|
20
|
+
gasEstimate?: GasEstimate;
|
|
21
|
+
/** Action this transaction executes */
|
|
22
|
+
action: Action;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Transaction builder class
|
|
26
|
+
*/
|
|
27
|
+
export declare class TransactionBuilder {
|
|
28
|
+
private provider;
|
|
29
|
+
private fromAddress;
|
|
30
|
+
constructor(provider: Provider, fromAddress: Address);
|
|
31
|
+
/**
|
|
32
|
+
* Build a transaction from an action
|
|
33
|
+
*/
|
|
34
|
+
buildAction(action: Action): Promise<BuiltTransaction>;
|
|
35
|
+
/**
|
|
36
|
+
* Build a transfer transaction (native ETH or ERC20)
|
|
37
|
+
*/
|
|
38
|
+
buildTransfer(action: Action): Promise<BuiltTransaction>;
|
|
39
|
+
/**
|
|
40
|
+
* Build an ERC20 approve transaction
|
|
41
|
+
*/
|
|
42
|
+
buildApprove(action: Action): Promise<BuiltTransaction>;
|
|
43
|
+
/**
|
|
44
|
+
* Build a swap transaction (placeholder - requires venue adapter)
|
|
45
|
+
*/
|
|
46
|
+
buildSwap(action: Action): Promise<BuiltTransaction>;
|
|
47
|
+
/**
|
|
48
|
+
* Build a lending deposit transaction (placeholder - requires venue adapter)
|
|
49
|
+
*/
|
|
50
|
+
buildLend(action: Action): Promise<BuiltTransaction>;
|
|
51
|
+
/**
|
|
52
|
+
* Build a withdrawal transaction (placeholder - requires venue adapter)
|
|
53
|
+
*/
|
|
54
|
+
buildWithdraw(action: Action): Promise<BuiltTransaction>;
|
|
55
|
+
/**
|
|
56
|
+
* Build a raw transaction
|
|
57
|
+
*/
|
|
58
|
+
buildRaw(to: Address, data: string, value?: bigint, description?: string): Promise<BuiltTransaction>;
|
|
59
|
+
/**
|
|
60
|
+
* Check ERC20 allowance
|
|
61
|
+
*/
|
|
62
|
+
checkAllowance(tokenAddress: Address, spenderAddress: Address): Promise<bigint>;
|
|
63
|
+
/**
|
|
64
|
+
* Check ERC20 balance
|
|
65
|
+
*/
|
|
66
|
+
checkBalance(tokenAddress: Address): Promise<bigint>;
|
|
67
|
+
/**
|
|
68
|
+
* Get token decimals
|
|
69
|
+
*/
|
|
70
|
+
getTokenDecimals(tokenAddress: Address): Promise<number>;
|
|
71
|
+
/**
|
|
72
|
+
* Get token symbol
|
|
73
|
+
*/
|
|
74
|
+
getTokenSymbol(tokenAddress: Address): Promise<string>;
|
|
75
|
+
/**
|
|
76
|
+
* Resolve asset symbol to address
|
|
77
|
+
* TODO: Implement proper asset registry
|
|
78
|
+
*/
|
|
79
|
+
private resolveAssetAddress;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Create a transaction builder
|
|
83
|
+
*/
|
|
84
|
+
export declare function createTransactionBuilder(provider: Provider, fromAddress: Address): TransactionBuilder;
|
|
85
|
+
//# sourceMappingURL=tx-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tx-builder.d.ts","sourceRoot":"","sources":["../../src/wallet/tx-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,KA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