@forgezero/providers 0.1.22 → 0.1.24

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/git.d.ts ADDED
@@ -0,0 +1,192 @@
1
+ import { type FailureKind, type InvokeContext, type ProviderDefinition } from './index';
2
+ /**
3
+ * GitHub is one provider authority with two deliberately separate service
4
+ * bindings. OAuth Server receives only user-authorization methods; Git Connect
5
+ * receives only installation/repository methods. Both resolve the same
6
+ * provider instance and therefore the same Vault credential exactly once.
7
+ */
8
+ export interface GitHubUserAuthorizationRequest {
9
+ intent: 'signin' | 'signup' | 'invite' | 'recover' | 'session';
10
+ returnTo: string;
11
+ state: string;
12
+ codeChallenge: string;
13
+ }
14
+ export interface GitHubUserAuthorization {
15
+ url: string;
16
+ expiresAtTs: number;
17
+ }
18
+ export interface GitHubUserAuthorizationCompletion {
19
+ code: string;
20
+ state: string;
21
+ codeVerifier: string;
22
+ }
23
+ export interface GitHubVerifiedIdentity {
24
+ providerUserId: string;
25
+ email: string;
26
+ displayName?: string;
27
+ }
28
+ export interface GitHubUserGrant {
29
+ accessToken: string;
30
+ expiresAtTs?: number;
31
+ refreshToken?: string;
32
+ refreshTokenExpiresAtTs?: number;
33
+ }
34
+ export interface GitHubUserGrantRefreshRequest {
35
+ refreshToken: string;
36
+ }
37
+ export interface GitHubUserGrantRevokeRequest {
38
+ accessToken: string;
39
+ }
40
+ export interface GitInstallation {
41
+ id: string;
42
+ accountId: string;
43
+ accountLabel: string;
44
+ accountKind: 'user' | 'organization';
45
+ }
46
+ export interface GitRepository {
47
+ id: string;
48
+ fullName: string;
49
+ private: boolean;
50
+ defaultBranch: string;
51
+ cloneUrl: string;
52
+ }
53
+ export interface GitBranch {
54
+ name: string;
55
+ protected?: boolean;
56
+ }
57
+ export interface GitCloneCredential {
58
+ username: string;
59
+ token: string;
60
+ expiresAtTs: number;
61
+ }
62
+ export interface GitInstallationStartRequest {
63
+ returnTo: string;
64
+ state: string;
65
+ }
66
+ export interface GitInstallationStart {
67
+ url: string;
68
+ expiresAtTs: number;
69
+ }
70
+ export interface GitInstallationCompletionRequest {
71
+ installationId: string;
72
+ setupAction?: 'install' | 'update';
73
+ state: string;
74
+ }
75
+ export interface GitInstallationRequest {
76
+ installationId: string;
77
+ }
78
+ export interface GitRepositoryRequest {
79
+ installationId: string;
80
+ cursor?: string;
81
+ }
82
+ export interface GitBranchRequest {
83
+ installationId: string;
84
+ repository: string;
85
+ cursor?: string;
86
+ }
87
+ export interface GitCloneCredentialRequest {
88
+ installationId: string;
89
+ repository: string;
90
+ }
91
+ export interface GitWebhookVerificationRequest {
92
+ rawBody: Uint8Array;
93
+ signature: string;
94
+ deliveryId: string;
95
+ event: string;
96
+ }
97
+ export interface GitWebhookEvent {
98
+ deliveryId: string;
99
+ event: string;
100
+ payload: unknown;
101
+ }
102
+ export declare const githubAppConfigSchema: {
103
+ readonly type: "object";
104
+ readonly properties: {
105
+ readonly clientId: {
106
+ readonly type: "string";
107
+ readonly minLength: 10;
108
+ readonly maxLength: 128;
109
+ };
110
+ readonly appId: {
111
+ readonly type: "string";
112
+ readonly pattern: "^[1-9][0-9]{0,19}$";
113
+ };
114
+ readonly slug: {
115
+ readonly type: "string";
116
+ readonly pattern: "^[a-z0-9][a-z0-9-]{0,99}$";
117
+ };
118
+ readonly providerVersion: {
119
+ readonly type: "string";
120
+ readonly pattern: "^github-app:[a-z0-9][a-z0-9.-]{0,31}$";
121
+ };
122
+ readonly verifiedAtTs: {
123
+ readonly type: "integer";
124
+ readonly minimum: 1;
125
+ };
126
+ };
127
+ readonly required: readonly ["clientId", "appId", "slug", "providerVersion", "verifiedAtTs"];
128
+ readonly additionalProperties: false;
129
+ };
130
+ export declare const githubAppCredentialSchema: {
131
+ readonly type: "object";
132
+ readonly properties: {
133
+ readonly clientSecret: {
134
+ readonly type: "string";
135
+ readonly minLength: 20;
136
+ readonly maxLength: 512;
137
+ readonly writeOnly: true;
138
+ };
139
+ readonly privateKey: {
140
+ readonly type: "string";
141
+ readonly minLength: 800;
142
+ readonly maxLength: 32768;
143
+ readonly writeOnly: true;
144
+ };
145
+ readonly webhookSecret: {
146
+ readonly type: "string";
147
+ readonly minLength: 32;
148
+ readonly maxLength: 256;
149
+ readonly writeOnly: true;
150
+ };
151
+ };
152
+ readonly required: readonly ["clientSecret", "privateKey", "webhookSecret"];
153
+ readonly additionalProperties: false;
154
+ };
155
+ export declare const oauthServerService: import("./index").ServiceDefinition<"oauth-server", {
156
+ beginUserAuthorization: import("./index").ServiceMethodContract<GitHubUserAuthorizationRequest, GitHubUserAuthorization>;
157
+ completeUserAuthorization: import("./index").ServiceMethodContract<GitHubUserAuthorizationCompletion, GitHubUserGrant>;
158
+ readVerifiedIdentity: import("./index").ServiceMethodContract<GitHubUserGrant, GitHubVerifiedIdentity>;
159
+ refreshUserGrant: import("./index").ServiceMethodContract<GitHubUserGrantRefreshRequest, GitHubUserGrant>;
160
+ revokeUserGrant: import("./index").ServiceMethodContract<GitHubUserGrantRevokeRequest, void>;
161
+ }>;
162
+ export declare const gitConnectService: import("./index").ServiceDefinition<"git-connect", {
163
+ beginInstallation: import("./index").ServiceMethodContract<GitInstallationStartRequest, GitInstallationStart>;
164
+ completeInstallation: import("./index").ServiceMethodContract<GitInstallationCompletionRequest, GitInstallation>;
165
+ listInstallations: import("./index").ServiceMethodContract<Record<string, never>, readonly GitInstallation[]>;
166
+ listRepositories: import("./index").ServiceMethodContract<GitRepositoryRequest, readonly GitRepository[]>;
167
+ listBranches: import("./index").ServiceMethodContract<GitBranchRequest, readonly GitBranch[]>;
168
+ mintCloneCredential: import("./index").ServiceMethodContract<GitCloneCredentialRequest, GitCloneCredential>;
169
+ verifyWebhook: import("./index").ServiceMethodContract<GitWebhookVerificationRequest, GitWebhookEvent>;
170
+ disconnectInstallation: import("./index").ServiceMethodContract<GitInstallationRequest, void>;
171
+ }>;
172
+ export interface GitHubProviderAdapter {
173
+ beginUserAuthorization(context: InvokeContext, args: GitHubUserAuthorizationRequest): Promise<GitHubUserAuthorization>;
174
+ completeUserAuthorization(context: InvokeContext, args: GitHubUserAuthorizationCompletion): Promise<GitHubUserGrant>;
175
+ readVerifiedIdentity(context: InvokeContext, args: GitHubUserGrant): Promise<GitHubVerifiedIdentity>;
176
+ refreshUserGrant(context: InvokeContext, args: GitHubUserGrantRefreshRequest): Promise<GitHubUserGrant>;
177
+ revokeUserGrant(context: InvokeContext, args: GitHubUserGrantRevokeRequest): Promise<void>;
178
+ beginInstallation(context: InvokeContext, args: GitInstallationStartRequest): Promise<GitInstallationStart>;
179
+ completeInstallation(context: InvokeContext, args: GitInstallationCompletionRequest): Promise<GitInstallation>;
180
+ listInstallations(context: InvokeContext, args: Record<string, never>): Promise<readonly GitInstallation[]>;
181
+ listRepositories(context: InvokeContext, args: GitRepositoryRequest): Promise<readonly GitRepository[]>;
182
+ listBranches(context: InvokeContext, args: GitBranchRequest): Promise<readonly GitBranch[]>;
183
+ mintCloneCredential(context: InvokeContext, args: GitCloneCredentialRequest): Promise<GitCloneCredential>;
184
+ verifyWebhook(context: InvokeContext, args: GitWebhookVerificationRequest): Promise<GitWebhookEvent>;
185
+ disconnectInstallation(context: InvokeContext, args: GitInstallationRequest): Promise<void>;
186
+ }
187
+ /** Define the single GitHub App provider. No OAuth-App compatibility identity exists. */
188
+ export declare function defineGitHubProvider(args: {
189
+ version: string;
190
+ adapter: GitHubProviderAdapter;
191
+ classify?: (error: unknown) => FailureKind;
192
+ }): ProviderDefinition;
@@ -336,155 +336,87 @@ function createService(definition, methods, options = {}) {
336
336
  }
337
337
  };
338
338
  }
339
- var VERSION = "0.1.22";
339
+ var VERSION = "0.1.24";
340
340
 
341
- // src/chain.ts
342
- var hexToNumber = (value) => Number(BigInt(value));
343
- var TERMINAL_PATTERNS = [
344
- "already known",
345
- "nonce too low",
346
- "already imported",
347
- "replacement transaction underpriced",
348
- "intrinsic gas too low",
349
- "insufficient funds",
350
- "exceeds block gas limit",
351
- "invalid sender",
352
- "execution reverted"
353
- ];
354
- var evmRpc = defineSingleMethodProvider({
355
- id: "evm-rpc",
356
- method: "request",
357
- label: "EVM JSON-RPC node",
358
- multiInstance: true,
359
- credentials: {
360
- type: "object",
361
- properties: {
362
- url: { type: "string", writeOnly: true },
363
- bearer: { type: "string", writeOnly: true }
364
- },
365
- required: ["url"],
366
- additionalProperties: false
367
- },
368
- config: {
369
- type: "object",
370
- properties: {
371
- chainId: { type: "integer" },
372
- maxLogRange: { type: "integer" },
373
- timeoutMs: { type: "integer" }
374
- },
375
- required: ["chainId"],
376
- additionalProperties: false
341
+ // src/git.ts
342
+ var githubAppConfigSchema = {
343
+ type: "object",
344
+ properties: {
345
+ clientId: { type: "string", minLength: 10, maxLength: 128 },
346
+ appId: { type: "string", pattern: "^[1-9][0-9]{0,19}$" },
347
+ slug: { type: "string", pattern: "^[a-z0-9][a-z0-9-]{0,99}$" },
348
+ providerVersion: { type: "string", pattern: "^github-app:[a-z0-9][a-z0-9.-]{0,31}$" },
349
+ verifiedAtTs: { type: "integer", minimum: 1 }
377
350
  },
378
- async invoke(context, call) {
379
- const config = context.config;
380
- const url = await context.secret("url");
381
- const bearer = await context.secret("bearer").catch(() => {
382
- return;
383
- });
384
- const rpc = async (method, params) => {
385
- const response = await fetch(url, {
386
- method: "POST",
387
- headers: {
388
- "content-type": "application/json",
389
- ...bearer ? { authorization: `Bearer ${bearer}` } : {}
390
- },
391
- body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }),
392
- signal: context.signal ?? AbortSignal.timeout(config.timeoutMs ?? 15000)
393
- });
394
- if (!response.ok) {
395
- throw new ProviderError("RPC_HTTP", `${method}: HTTP ${response.status}`, {
396
- status: response.status
397
- });
398
- }
399
- const body = await response.json();
400
- if (body.error) {
401
- throw new ProviderError("RPC_ERROR", `${method}: ${body.error.message ?? "error"}`, {
402
- code: body.error.code
403
- });
404
- }
405
- if (body.result === undefined) {
406
- throw new ProviderError("RPC_EMPTY", `${method}: no result`);
407
- }
408
- return body.result;
409
- };
410
- switch (call.op) {
411
- case "head":
412
- return { op: "head", block: hexToNumber(await rpc("eth_blockNumber", [])) };
413
- case "balance":
414
- return {
415
- op: "balance",
416
- wei: BigInt(await rpc("eth_getBalance", [call.address, call.block ?? "latest"]))
417
- };
418
- case "call":
419
- return {
420
- op: "call",
421
- data: await rpc("eth_call", [
422
- { to: call.to, data: call.data },
423
- call.block ?? "latest"
424
- ])
425
- };
426
- case "logs": {
427
- const span = call.toBlock - call.fromBlock + 1;
428
- const cap = config.maxLogRange ?? 2000;
429
- if (span > cap) {
430
- throw new ProviderError("RPC_RANGE_TOO_WIDE", `Asked for ${span} blocks; this node allows ${cap}. Split the range.`);
431
- }
432
- const logs = await rpc("eth_getLogs", [
433
- {
434
- fromBlock: `0x${call.fromBlock.toString(16)}`,
435
- toBlock: `0x${call.toBlock.toString(16)}`,
436
- ...call.address ? { address: call.address } : {},
437
- ...call.topics ? { topics: call.topics } : {}
438
- }
439
- ]);
440
- return {
441
- op: "logs",
442
- logs: logs.map((log) => ({
443
- transactionHash: log.transactionHash,
444
- logIndex: hexToNumber(log.logIndex),
445
- blockNumber: hexToNumber(log.blockNumber),
446
- address: log.address,
447
- topics: log.topics,
448
- data: log.data
449
- }))
450
- };
451
- }
452
- case "nonce":
453
- return {
454
- op: "nonce",
455
- nonce: BigInt(await rpc("eth_getTransactionCount", [call.address, call.block ?? "pending"]))
456
- };
457
- case "send":
458
- return { op: "send", hash: await rpc("eth_sendRawTransaction", [call.raw]) };
459
- case "receipt": {
460
- const receipt = await rpc("eth_getTransactionReceipt", [call.hash]);
461
- if (!receipt)
462
- return { op: "receipt", receipt: null };
463
- return {
464
- op: "receipt",
465
- receipt: {
466
- hash: call.hash,
467
- blockNumber: hexToNumber(receipt.blockNumber ?? "0x0"),
468
- success: receipt.status === "0x1"
469
- }
470
- };
471
- }
472
- }
351
+ required: ["clientId", "appId", "slug", "providerVersion", "verifiedAtTs"],
352
+ additionalProperties: false
353
+ };
354
+ var githubAppCredentialSchema = {
355
+ type: "object",
356
+ properties: {
357
+ clientSecret: { type: "string", minLength: 20, maxLength: 512, writeOnly: true },
358
+ privateKey: { type: "string", minLength: 800, maxLength: 32768, writeOnly: true },
359
+ webhookSecret: { type: "string", minLength: 32, maxLength: 256, writeOnly: true }
473
360
  },
474
- classify(error) {
475
- const message = String(error?.message ?? "").toLowerCase();
476
- const details = error.details;
477
- if (TERMINAL_PATTERNS.some((pattern) => message.includes(pattern)))
478
- return "terminal";
479
- if (message.includes("split the range"))
480
- return "terminal";
481
- if (details?.code === -32602)
482
- return "terminal";
483
- if (details?.status === 429 || message.includes("rate limit") || message.includes("too many"))
484
- return "backoff";
485
- return "retryable";
361
+ required: ["clientSecret", "privateKey", "webhookSecret"],
362
+ additionalProperties: false
363
+ };
364
+ var oauthServerService = defineService({
365
+ key: "oauth-server",
366
+ methods: {
367
+ beginUserAuthorization: serviceMethod(),
368
+ completeUserAuthorization: serviceMethod(),
369
+ readVerifiedIdentity: serviceMethod(),
370
+ refreshUserGrant: serviceMethod(),
371
+ revokeUserGrant: serviceMethod()
486
372
  }
487
373
  });
374
+ var gitConnectService = defineService({
375
+ key: "git-connect",
376
+ methods: {
377
+ beginInstallation: serviceMethod(),
378
+ completeInstallation: serviceMethod(),
379
+ listInstallations: serviceMethod(),
380
+ listRepositories: serviceMethod(),
381
+ listBranches: serviceMethod(),
382
+ mintCloneCredential: serviceMethod(),
383
+ verifyWebhook: serviceMethod(),
384
+ disconnectInstallation: serviceMethod()
385
+ }
386
+ });
387
+ function defineGitHubProvider(args) {
388
+ const classify = args.classify ?? (() => "retryable");
389
+ const branch = (invoke) => defineProviderMethodBranches({
390
+ currentVersion: args.version,
391
+ versions: { [args.version]: { version: args.version, lifecycle: "current", invoke, classify } }
392
+ });
393
+ return defineProvider({
394
+ id: "github",
395
+ label: "GitHub App",
396
+ multiInstance: false,
397
+ credentials: githubAppCredentialSchema,
398
+ config: githubAppConfigSchema,
399
+ methods: {
400
+ beginUserAuthorization: branch(args.adapter.beginUserAuthorization),
401
+ completeUserAuthorization: branch(args.adapter.completeUserAuthorization),
402
+ readVerifiedIdentity: branch(args.adapter.readVerifiedIdentity),
403
+ refreshUserGrant: branch(args.adapter.refreshUserGrant),
404
+ revokeUserGrant: branch(args.adapter.revokeUserGrant),
405
+ beginInstallation: branch(args.adapter.beginInstallation),
406
+ completeInstallation: branch(args.adapter.completeInstallation),
407
+ listInstallations: branch(args.adapter.listInstallations),
408
+ listRepositories: branch(args.adapter.listRepositories),
409
+ listBranches: branch(args.adapter.listBranches),
410
+ mintCloneCredential: branch(args.adapter.mintCloneCredential),
411
+ verifyWebhook: branch(args.adapter.verifyWebhook),
412
+ disconnectInstallation: branch(args.adapter.disconnectInstallation)
413
+ }
414
+ });
415
+ }
488
416
  export {
489
- evmRpc
417
+ oauthServerService,
418
+ githubAppCredentialSchema,
419
+ githubAppConfigSchema,
420
+ gitConnectService,
421
+ defineGitHubProvider
490
422
  };
package/dist/http.js CHANGED
@@ -336,7 +336,7 @@ function createService(definition, methods, options = {}) {
336
336
  }
337
337
  };
338
338
  }
339
- var VERSION = "0.1.22";
339
+ var VERSION = "0.1.24";
340
340
 
341
341
  // src/http.ts
342
342
  class BudgetExhausted extends ProviderError {
package/dist/index.d.ts CHANGED
@@ -303,5 +303,5 @@ export interface EmailBatchResult {
303
303
  };
304
304
  results: readonly EmailBatchItemResult[];
305
305
  }
306
- export declare const VERSION = "0.1.22";
306
+ export declare const VERSION = "0.1.24";
307
307
  export {};
package/dist/index.js CHANGED
@@ -336,7 +336,7 @@ function createService(definition, methods, options = {}) {
336
336
  }
337
337
  };
338
338
  }
339
- var VERSION = "0.1.22";
339
+ var VERSION = "0.1.24";
340
340
  export {
341
341
  staticConfig,
342
342
  serviceMethod,
package/dist/pool.js CHANGED
@@ -336,7 +336,7 @@ function createService(definition, methods, options = {}) {
336
336
  }
337
337
  };
338
338
  }
339
- var VERSION = "0.1.22";
339
+ var VERSION = "0.1.24";
340
340
 
341
341
  // src/http.ts
342
342
  class BudgetExhausted extends ProviderError {
package/dist/storage.js CHANGED
@@ -336,7 +336,7 @@ function createService(definition, methods, options = {}) {
336
336
  }
337
337
  };
338
338
  }
339
- var VERSION = "0.1.22";
339
+ var VERSION = "0.1.24";
340
340
 
341
341
  // src/storage.ts
342
342
  var encoder = new TextEncoder;
@@ -336,7 +336,7 @@ function createService(definition, methods, options = {}) {
336
336
  }
337
337
  };
338
338
  }
339
- var VERSION = "0.1.22";
339
+ var VERSION = "0.1.24";
340
340
 
341
341
  // src/translation.ts
342
342
  var GOOGLE_ENDPOINT = "https://generativelanguage.googleapis.com/v1beta/models";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forgezero/providers",
3
- "version": "0.1.22",
3
+ "version": "0.1.24",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -15,10 +15,6 @@
15
15
  "types": "./dist/email.d.ts",
16
16
  "default": "./dist/email.js"
17
17
  },
18
- "./chain": {
19
- "types": "./dist/chain.d.ts",
20
- "default": "./dist/chain.js"
21
- },
22
18
  "./database": {
23
19
  "types": "./dist/database.d.ts",
24
20
  "default": "./dist/database.js"
@@ -35,10 +31,6 @@
35
31
  "types": "./dist/pool.d.ts",
36
32
  "default": "./dist/pool.js"
37
33
  },
38
- "./binance": {
39
- "types": "./dist/binance.d.ts",
40
- "default": "./dist/binance.js"
41
- },
42
34
  "./translation": {
43
35
  "types": "./dist/translation.d.ts",
44
36
  "default": "./dist/translation.js"
@@ -46,6 +38,14 @@
46
38
  "./realtime": {
47
39
  "types": "./dist/realtime.d.ts",
48
40
  "default": "./dist/realtime.js"
41
+ },
42
+ "./git": {
43
+ "types": "./dist/git.d.ts",
44
+ "default": "./dist/git.js"
45
+ },
46
+ "./billing": {
47
+ "types": "./dist/billing.d.ts",
48
+ "default": "./dist/billing.js"
49
49
  }
50
50
  },
51
51
  "scripts": {
@@ -85,6 +85,6 @@
85
85
  "LICENSE"
86
86
  ],
87
87
  "dependencies": {
88
- "@forgezero/runtime": "^0.1.14"
88
+ "@forgezero/runtime": "^0.1.15"
89
89
  }
90
90
  }
package/dist/binance.d.ts DELETED
@@ -1,27 +0,0 @@
1
- import { VenueError, type VenueAdapter, type MarketType, type OrderStatus } from '@forgezero/runtime/finance/venues';
2
- export interface BinanceCredentials {
3
- apiKey: string;
4
- apiSecret: string;
5
- }
6
- export interface BinanceOptions {
7
- credentials: BinanceCredentials;
8
- /** Override for testnet, or for a test. */
9
- hosts?: Partial<Record<MarketType, string>>;
10
- fetch?: typeof globalThis.fetch;
11
- /**
12
- * How far a request may be delayed before Binance refuses it.
13
- *
14
- * 5s rather than the 60s maximum. A signed order that arrives a minute late
15
- * is an order placed into a market that has moved, and accepting it is worse
16
- * than being told to retry.
17
- */
18
- recvWindowMs?: number;
19
- now?: () => number;
20
- }
21
- /** Binance spells `BTC/USDT` as `BTCUSDT`. Denormalised here and nowhere else. */
22
- export declare const binanceSymbol: (symbol: string) => string;
23
- /** Binance statuses → ours. An unknown one is `rejected`, never silently `accepted`. */
24
- export declare function toOrderStatus(status: string): OrderStatus;
25
- export declare function createBinanceAdapter(options: BinanceOptions): VenueAdapter;
26
- /** Turn a Binance error into something that names the actual cause. */
27
- export declare function readBinanceError(error: unknown): VenueError | undefined;
package/dist/chain.d.ts DELETED
@@ -1,99 +0,0 @@
1
- /**
2
- * A blockchain node, behind the same failover every other service gets.
3
- *
4
- * Reading a chain is a PROVIDER problem, not a runtime one, and the distinction
5
- * is not bookkeeping. A node needs a credential, it rate-limits, it goes down,
6
- * and the answer when it does is to ask a different one — which is precisely
7
- * what the registry already does for email and storage. Deriving an address
8
- * needs none of that and lives in `runtime/finance/custody`.
9
- *
10
- * ## Why several nodes is the normal case, not a luxury
11
- *
12
- * Public RPC endpoints are rate-limited and unreliable, and paid ones have
13
- * outages like anything else. A deposit scanner that stops when one endpoint is
14
- * down stops CREDITING DEPOSITS, and the user's money is on the chain the whole
15
- * time. Priority and health belong here so a scanner never has to know which
16
- * node answered.
17
- *
18
- * ## The classification is the load-bearing part
19
- *
20
- * terminal our request is malformed, or the chain rejected the transaction
21
- * on its merits. Every node will say the same thing, and asking
22
- * three of them buries the real reason under two duplicates.
23
- * backoff rate limited. The node is healthy and we are asking too fast;
24
- * striking it would punish the one that is working.
25
- * retryable this node is behind, broken, or its key is bad. The next may
26
- * be fine.
27
- *
28
- * "Already known" and "nonce too low" are the interesting cases. Both mean the
29
- * transaction is ALREADY IN FLIGHT, so they are terminal rather than retryable:
30
- * rebroadcasting through another node cannot help, and treating them as failure
31
- * is how a sweep gets sent twice.
32
- */
33
- export type ChainCall = {
34
- op: 'head';
35
- } | {
36
- op: 'balance';
37
- address: string;
38
- block?: string;
39
- } | {
40
- op: 'call';
41
- to: string;
42
- data: string;
43
- block?: string;
44
- } | {
45
- op: 'logs';
46
- fromBlock: number;
47
- toBlock: number;
48
- address?: string;
49
- topics?: (string | string[] | null)[];
50
- } | {
51
- op: 'nonce';
52
- address: string;
53
- block?: 'pending' | 'latest';
54
- } | {
55
- op: 'send';
56
- raw: string;
57
- } | {
58
- op: 'receipt';
59
- hash: string;
60
- };
61
- export interface ChainLog {
62
- transactionHash: string;
63
- logIndex: number;
64
- blockNumber: number;
65
- address: string;
66
- topics: string[];
67
- data: string;
68
- }
69
- export interface ChainReceipt {
70
- hash: string;
71
- blockNumber: number;
72
- /** True only when the chain executed it successfully. */
73
- success: boolean;
74
- }
75
- export type ChainResult = {
76
- op: 'head';
77
- block: number;
78
- } | {
79
- op: 'balance';
80
- wei: bigint;
81
- } | {
82
- op: 'call';
83
- data: string;
84
- } | {
85
- op: 'logs';
86
- logs: ChainLog[];
87
- } | {
88
- op: 'nonce';
89
- nonce: bigint;
90
- } | {
91
- op: 'send';
92
- hash: string;
93
- }
94
- /** `null` when the transaction has not mined yet — not an error. */
95
- | {
96
- op: 'receipt';
97
- receipt: ChainReceipt | null;
98
- };
99
- export declare const evmRpc: import("./index").ProviderDefinition<Record<"request", import("./index").ProviderMethodSpec<ChainCall, ChainResult>>>;