@openzeppelin/relayer-plugin-channels 0.2.0 → 0.3.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/LICENSE +661 -21
- package/README.md +239 -60
- package/dist/client/channels-client.d.ts +142 -0
- package/dist/client/channels-client.d.ts.map +1 -0
- package/dist/client/channels-client.js +245 -0
- package/dist/client/errors.d.ts +47 -0
- package/dist/client/errors.d.ts.map +1 -0
- package/dist/client/errors.js +61 -0
- package/dist/client/index.d.ts +10 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +16 -0
- package/dist/client/types.d.ts +119 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +2 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -109
- package/dist/plugin/build.d.ts.map +1 -0
- package/dist/plugin/config.d.ts.map +1 -0
- package/dist/plugin/constants.d.ts.map +1 -0
- package/dist/plugin/fee.d.ts.map +1 -0
- package/dist/plugin/handler.d.ts +12 -0
- package/dist/plugin/handler.d.ts.map +1 -0
- package/dist/plugin/handler.js +117 -0
- package/dist/plugin/index.d.ts +7 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/index.js +10 -0
- package/dist/plugin/management.d.ts.map +1 -0
- package/dist/plugin/pool.d.ts.map +1 -0
- package/dist/plugin/simulation.d.ts.map +1 -0
- package/dist/plugin/submit.d.ts.map +1 -0
- package/dist/plugin/tx.d.ts.map +1 -0
- package/dist/plugin/types.d.ts.map +1 -0
- package/dist/plugin/validation.d.ts.map +1 -0
- package/package.json +3 -2
- package/dist/build.d.ts.map +0 -1
- package/dist/config.d.ts.map +0 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/fee.d.ts.map +0 -1
- package/dist/management.d.ts.map +0 -1
- package/dist/pool.d.ts.map +0 -1
- package/dist/simulation.d.ts.map +0 -1
- package/dist/submit.d.ts.map +0 -1
- package/dist/test/config.test.d.ts +0 -2
- package/dist/test/config.test.d.ts.map +0 -1
- package/dist/test/config.test.js +0 -43
- package/dist/test/fee.test.d.ts +0 -2
- package/dist/test/fee.test.d.ts.map +0 -1
- package/dist/test/fee.test.js +0 -34
- package/dist/test/helpers/fakeKV.d.ts +0 -17
- package/dist/test/helpers/fakeKV.d.ts.map +0 -1
- package/dist/test/helpers/fakeKV.js +0 -60
- package/dist/test/management.test.d.ts +0 -2
- package/dist/test/management.test.d.ts.map +0 -1
- package/dist/test/management.test.js +0 -66
- package/dist/test/pool.busy.test.d.ts +0 -2
- package/dist/test/pool.busy.test.d.ts.map +0 -1
- package/dist/test/pool.busy.test.js +0 -23
- package/dist/test/pool.test.d.ts +0 -2
- package/dist/test/pool.test.d.ts.map +0 -1
- package/dist/test/pool.test.js +0 -29
- package/dist/test/tx.test.d.ts +0 -2
- package/dist/test/tx.test.d.ts.map +0 -1
- package/dist/test/tx.test.js +0 -29
- package/dist/test/validation.test.d.ts +0 -2
- package/dist/test/validation.test.d.ts.map +0 -1
- package/dist/test/validation.test.js +0 -31
- package/dist/tx.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/validation.d.ts.map +0 -1
- /package/dist/{build.d.ts → plugin/build.d.ts} +0 -0
- /package/dist/{build.js → plugin/build.js} +0 -0
- /package/dist/{config.d.ts → plugin/config.d.ts} +0 -0
- /package/dist/{config.js → plugin/config.js} +0 -0
- /package/dist/{constants.d.ts → plugin/constants.d.ts} +0 -0
- /package/dist/{constants.js → plugin/constants.js} +0 -0
- /package/dist/{fee.d.ts → plugin/fee.d.ts} +0 -0
- /package/dist/{fee.js → plugin/fee.js} +0 -0
- /package/dist/{management.d.ts → plugin/management.d.ts} +0 -0
- /package/dist/{management.js → plugin/management.js} +0 -0
- /package/dist/{pool.d.ts → plugin/pool.d.ts} +0 -0
- /package/dist/{pool.js → plugin/pool.js} +0 -0
- /package/dist/{simulation.d.ts → plugin/simulation.d.ts} +0 -0
- /package/dist/{simulation.js → plugin/simulation.js} +0 -0
- /package/dist/{submit.d.ts → plugin/submit.d.ts} +0 -0
- /package/dist/{submit.js → plugin/submit.js} +0 -0
- /package/dist/{tx.d.ts → plugin/tx.d.ts} +0 -0
- /package/dist/{tx.js → plugin/tx.js} +0 -0
- /package/dist/{types.d.ts → plugin/types.d.ts} +0 -0
- /package/dist/{types.js → plugin/types.js} +0 -0
- /package/dist/{validation.d.ts → plugin/validation.d.ts} +0 -0
- /package/dist/{validation.js → plugin/validation.js} +0 -0
package/README.md
CHANGED
|
@@ -2,6 +2,44 @@
|
|
|
2
2
|
|
|
3
3
|
A plugin for OpenZeppelin Relayer that enables parallel transaction submission on Stellar using channel accounts with fee bumping. Channel accounts provide unique sequence numbers for parallel transaction submission, preventing sequence number conflicts.
|
|
4
4
|
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Quick Start](#quick-start)
|
|
8
|
+
- [Prerequisites](#prerequisites)
|
|
9
|
+
- [Installation & Setup](#installation--setup)
|
|
10
|
+
- [Install from npm](#1-install-from-npm-recommended)
|
|
11
|
+
- [Use a local build](#2-use-a-local-build-for-development--debugging)
|
|
12
|
+
- [Create the plugin wrapper](#create-the-plugin-wrapper)
|
|
13
|
+
- [Configure the Relayer](#configure-the-relayer)
|
|
14
|
+
- [Configure Environment Variables](#configure-environment-variables)
|
|
15
|
+
- [Initialize Channel Accounts](#initialize-channel-accounts)
|
|
16
|
+
- [Development](#development)
|
|
17
|
+
- [Overview](#overview)
|
|
18
|
+
- [Architecture](#architecture)
|
|
19
|
+
- [Management API](#management-api)
|
|
20
|
+
- [List Channel Accounts](#list-channel-accounts)
|
|
21
|
+
- [Set Channel Accounts](#set-channel-accounts)
|
|
22
|
+
- [Plugin Client](#plugin-client)
|
|
23
|
+
- [Installation](#installation)
|
|
24
|
+
- [Quick Start](#quick-start-1)
|
|
25
|
+
- [Client Modes](#client-modes)
|
|
26
|
+
- [Usage Examples](#usage-examples)
|
|
27
|
+
- [Error Handling](#error-handling)
|
|
28
|
+
- [Metadata and Debugging](#metadata-and-debugging)
|
|
29
|
+
- [TypeScript Types](#typescript-types)
|
|
30
|
+
- [Configuration Options](#configuration-options)
|
|
31
|
+
- [API Usage](#api-usage)
|
|
32
|
+
- [Submit with Transaction XDR](#submit-with-transaction-xdr)
|
|
33
|
+
- [Submit with Function and Auth](#submit-with-function-and-auth)
|
|
34
|
+
- [Parameters](#parameters)
|
|
35
|
+
- [Response](#response)
|
|
36
|
+
- [How It Works](#how-it-works)
|
|
37
|
+
- [Validation Rules](#validation-rules)
|
|
38
|
+
- [KV Schema](#kv-schema)
|
|
39
|
+
- [Error Codes](#error-codes)
|
|
40
|
+
- [Smoke Test Contract](#smoke-test-contract)
|
|
41
|
+
- [License](#license)
|
|
42
|
+
|
|
5
43
|
## Quick Start
|
|
6
44
|
|
|
7
45
|
**Want to get started quickly?** Check out the [Channels Plugin Example](https://github.com/OpenZeppelin/openzeppelin-relayer/tree/main/examples/channels-plugin-example) which includes a pre-configured relayer setup, Docker Compose configuration, and step-by-step instructions. This is the fastest way to get the Channels plugin up and running.
|
|
@@ -311,6 +349,207 @@ curl -X POST http://localhost:8080/api/v1/plugins/channels/call \
|
|
|
311
349
|
- All relayer IDs must exist in your OpenZeppelin Relayer configuration
|
|
312
350
|
- The `adminSecret` must match the `PLUGIN_ADMIN_SECRET` environment variable
|
|
313
351
|
|
|
352
|
+
## Plugin Client
|
|
353
|
+
|
|
354
|
+
The Channels plugin provides a TypeScript client for easy integration into your applications. The client automatically handles request/response formatting, error handling, and supports both relayer mode and direct HTTP mode.
|
|
355
|
+
|
|
356
|
+
### Installation
|
|
357
|
+
|
|
358
|
+
```bash
|
|
359
|
+
npm install @openzeppelin/relayer-plugin-channels
|
|
360
|
+
# or
|
|
361
|
+
pnpm add @openzeppelin/relayer-plugin-channels
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
### Quick Start
|
|
365
|
+
|
|
366
|
+
```typescript
|
|
367
|
+
import { ChannelsClient } from "@openzeppelin/relayer-plugin-channels";
|
|
368
|
+
|
|
369
|
+
// Connecting to OpenZeppelin's managed Channels service
|
|
370
|
+
const client = new ChannelsClient({
|
|
371
|
+
baseUrl: "https://channels.openzeppelin.com",
|
|
372
|
+
apiKey: "your-api-key",
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
// Connecting to your own Relayer with Channels plugin
|
|
376
|
+
const relayerClient = new ChannelsClient({
|
|
377
|
+
baseUrl: "http://localhost:8080",
|
|
378
|
+
pluginId: "channels",
|
|
379
|
+
apiKey: "your-relayer-api-key",
|
|
380
|
+
adminSecret: "your-admin-secret", // Optional: Required for management operations
|
|
381
|
+
});
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
### Configuration
|
|
385
|
+
|
|
386
|
+
**Managed Service**
|
|
387
|
+
|
|
388
|
+
When connecting to OpenZeppelin's managed Channels service (which runs behind Cloudflare and a load balancer), provide just the `baseUrl` and `apiKey`:
|
|
389
|
+
|
|
390
|
+
```typescript
|
|
391
|
+
// Mainnet
|
|
392
|
+
const client = new ChannelsClient({
|
|
393
|
+
baseUrl: "https://channels.openzeppelin.com",
|
|
394
|
+
apiKey: "your-api-key",
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
// Testnet
|
|
398
|
+
const testnetClient = new ChannelsClient({
|
|
399
|
+
baseUrl: "https://channels.openzeppelin.com/testnet",
|
|
400
|
+
apiKey: "your-api-key",
|
|
401
|
+
});
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
**Generate API Keys:**
|
|
405
|
+
|
|
406
|
+
- Testnet: https://channels.openzeppelin.com/testnet/gen
|
|
407
|
+
- Mainnet: https://channels.openzeppelin.com/gen
|
|
408
|
+
|
|
409
|
+
**Self-Hosted Relayer**
|
|
410
|
+
|
|
411
|
+
When connecting directly to your own OpenZeppelin Relayer instance, include the `pluginId`:
|
|
412
|
+
|
|
413
|
+
```typescript
|
|
414
|
+
const client = new ChannelsClient({
|
|
415
|
+
baseUrl: "http://localhost:8080",
|
|
416
|
+
pluginId: "channels",
|
|
417
|
+
apiKey: "your-relayer-api-key",
|
|
418
|
+
adminSecret: "your-admin-secret", // Optional: Required for management operations
|
|
419
|
+
});
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
The client automatically routes requests appropriately based on whether `pluginId` is provided
|
|
423
|
+
|
|
424
|
+
### Usage Examples
|
|
425
|
+
|
|
426
|
+
#### Submit Signed XDR Transaction
|
|
427
|
+
|
|
428
|
+
```typescript
|
|
429
|
+
// Submit a complete, signed transaction
|
|
430
|
+
const result = await client.submitTransaction({
|
|
431
|
+
xdr: "AAAAAgAAAAC...", // Complete transaction envelope XDR
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
console.log(result.hash); // Transaction hash
|
|
435
|
+
console.log(result.status); // Transaction status
|
|
436
|
+
console.log(result.transactionId); // Relayer transaction ID
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
#### Submit Soroban Function with Auth
|
|
440
|
+
|
|
441
|
+
```typescript
|
|
442
|
+
// Submit func+auth (uses channel accounts and simulation)
|
|
443
|
+
const result = await client.submitSorobanTransaction({
|
|
444
|
+
func: "AAAABAAAAAEAAAAGc3ltYm9s...", // Host function XDR (base64)
|
|
445
|
+
auth: ["AAAACAAAAAEAAAA..."], // Auth entry XDRs (base64)
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
console.log(result.hash);
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
#### List Channel Accounts (Management)
|
|
452
|
+
|
|
453
|
+
```typescript
|
|
454
|
+
// Initialize client with admin secret
|
|
455
|
+
const adminClient = new ChannelsClient({
|
|
456
|
+
baseUrl: "http://localhost:8080",
|
|
457
|
+
apiKey: "your-api-key",
|
|
458
|
+
pluginId: "channels",
|
|
459
|
+
adminSecret: "your-admin-secret", // Required for management operations
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
// List configured channel accounts
|
|
463
|
+
const accounts = await adminClient.listChannelAccounts();
|
|
464
|
+
console.log(accounts.relayerIds); // ['channel-001', 'channel-002', ...]
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
#### Set Channel Accounts (Management)
|
|
468
|
+
|
|
469
|
+
```typescript
|
|
470
|
+
// Configure channel accounts (requires adminSecret)
|
|
471
|
+
const result = await adminClient.setChannelAccounts([
|
|
472
|
+
"channel-001",
|
|
473
|
+
"channel-002",
|
|
474
|
+
"channel-003",
|
|
475
|
+
]);
|
|
476
|
+
|
|
477
|
+
console.log(result.ok); // true
|
|
478
|
+
console.log(result.appliedRelayerIds); // ['channel-001', 'channel-002', 'channel-003']
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
### Error Handling
|
|
482
|
+
|
|
483
|
+
The client provides three types of errors:
|
|
484
|
+
|
|
485
|
+
```typescript
|
|
486
|
+
import {
|
|
487
|
+
PluginTransportError,
|
|
488
|
+
PluginExecutionError,
|
|
489
|
+
PluginUnexpectedError,
|
|
490
|
+
} from "@openzeppelin/relayer-plugin-channels";
|
|
491
|
+
|
|
492
|
+
try {
|
|
493
|
+
const result = await client.submitTransaction({ xdr: "..." });
|
|
494
|
+
} catch (error) {
|
|
495
|
+
if (error instanceof PluginTransportError) {
|
|
496
|
+
// Network/HTTP failures (connection refused, timeout, 500/502/503)
|
|
497
|
+
console.error("Transport error:", error.message);
|
|
498
|
+
console.error("Status code:", error.statusCode);
|
|
499
|
+
} else if (error instanceof PluginExecutionError) {
|
|
500
|
+
// Plugin rejected the request (validation, business logic, on-chain failure)
|
|
501
|
+
console.error("Execution error:", error.message);
|
|
502
|
+
console.error("Details:", error.errorDetails);
|
|
503
|
+
} else if (error instanceof PluginUnexpectedError) {
|
|
504
|
+
// Client-side parsing/validation errors
|
|
505
|
+
console.error("Unexpected error:", error.message);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
### Metadata and Debugging
|
|
511
|
+
|
|
512
|
+
Responses include optional metadata (logs and traces) when the plugin is configured with `emit_logs` and `emit_traces`:
|
|
513
|
+
|
|
514
|
+
```typescript
|
|
515
|
+
const result = await client.submitTransaction({ xdr: "..." });
|
|
516
|
+
|
|
517
|
+
// Access metadata if available
|
|
518
|
+
if (result.metadata) {
|
|
519
|
+
console.log("Logs:", result.metadata.logs);
|
|
520
|
+
console.log("Traces:", result.metadata.traces);
|
|
521
|
+
}
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
### TypeScript Types
|
|
525
|
+
|
|
526
|
+
All request and response types are fully typed:
|
|
527
|
+
|
|
528
|
+
```typescript
|
|
529
|
+
import type {
|
|
530
|
+
ChannelsXdrRequest,
|
|
531
|
+
ChannelsFuncAuthRequest,
|
|
532
|
+
ChannelsTransactionResponse,
|
|
533
|
+
ListChannelAccountsResponse,
|
|
534
|
+
SetChannelAccountsResponse,
|
|
535
|
+
} from "@openzeppelin/relayer-plugin-channels";
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
### Configuration Options
|
|
539
|
+
|
|
540
|
+
```typescript
|
|
541
|
+
interface ChannelsClientConfig {
|
|
542
|
+
// Required
|
|
543
|
+
baseUrl: string; // Service or Relayer URL
|
|
544
|
+
apiKey: string; // API key for authentication
|
|
545
|
+
|
|
546
|
+
// Optional
|
|
547
|
+
pluginId?: string; // Include when connecting to a Relayer directly
|
|
548
|
+
adminSecret?: string; // Required for management operations
|
|
549
|
+
timeout?: number; // Request timeout in ms (default: 30000)
|
|
550
|
+
}
|
|
551
|
+
```
|
|
552
|
+
|
|
314
553
|
## API Usage
|
|
315
554
|
|
|
316
555
|
### Submit with Transaction XDR
|
|
@@ -442,63 +681,3 @@ Plugin error example:
|
|
|
442
681
|
## License
|
|
443
682
|
|
|
444
683
|
MIT
|
|
445
|
-
|
|
446
|
-
---
|
|
447
|
-
|
|
448
|
-
## Smoke Test Contract
|
|
449
|
-
|
|
450
|
-
This repo includes a minimal Soroban contract and smoke test script that exercise the Channels plugin with different authorization methods.
|
|
451
|
-
|
|
452
|
-
### Contract
|
|
453
|
-
|
|
454
|
-
- **Path**: `contracts/smoke-contract`
|
|
455
|
-
- **Functions**:
|
|
456
|
-
- `no_auth_bump(n: u32) -> u32` — No auth required; returns n+1
|
|
457
|
-
- `write_with_address_auth(addr: Address, value: u32)` — Requires address auth; writes value to storage
|
|
458
|
-
- `read_value(addr: Address) -> u32` — Reads stored value for address
|
|
459
|
-
|
|
460
|
-
Build/optimize/deploy with the Stellar CLI:
|
|
461
|
-
|
|
462
|
-
```bash
|
|
463
|
-
# Using helper script
|
|
464
|
-
bash contracts/smoke-contract/contract.sh build
|
|
465
|
-
bash contracts/smoke-contract/contract.sh optimize
|
|
466
|
-
bash contracts/smoke-contract/contract.sh deploy --network testnet --account test-account
|
|
467
|
-
```
|
|
468
|
-
|
|
469
|
-
### Smoke Test Script
|
|
470
|
-
|
|
471
|
-
- **Path**: `scripts/smoke.ts`
|
|
472
|
-
- **Requirements**:
|
|
473
|
-
- Node.js 18+
|
|
474
|
-
- Stellar CLI (`stellar`) configured with a key
|
|
475
|
-
- Channels plugin running at base URL
|
|
476
|
-
|
|
477
|
-
Environment variables:
|
|
478
|
-
|
|
479
|
-
```bash
|
|
480
|
-
export BASE_URL="http://localhost:8080" # relayer origin
|
|
481
|
-
export API_KEY="<relayer-api-key>" # required
|
|
482
|
-
export NETWORK="testnet" # or "mainnet"
|
|
483
|
-
export RPC_URL="https://soroban-testnet.stellar.org"
|
|
484
|
-
export ACCOUNT_NAME="test-account" # key in `stellar keys`
|
|
485
|
-
export CONTRACT_ID="CDXX..." # deployed smoke-contract
|
|
486
|
-
```
|
|
487
|
-
|
|
488
|
-
Run (args override env):
|
|
489
|
-
|
|
490
|
-
```bash
|
|
491
|
-
pnpm ts-node scripts/smoke.ts \
|
|
492
|
-
--api-key YOUR_API_KEY \
|
|
493
|
-
--account-name test-account \
|
|
494
|
-
--contract-id CDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
|
495
|
-
|
|
496
|
-
# Show all options in the script header
|
|
497
|
-
```
|
|
498
|
-
|
|
499
|
-
What it does:
|
|
500
|
-
|
|
501
|
-
- Health-checks the relayer
|
|
502
|
-
- XDR submit-only: signs a small self-payment and submits via fee bump
|
|
503
|
-
- func+auth (no auth): calls `no_auth_bump(42)` using a channel account
|
|
504
|
-
- func+auth (address auth): calls `write_with_address_auth(addr, 777)` with signed auth entries
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { ChannelsClientConfig, ChannelsXdrRequest, ChannelsFuncAuthRequest, ChannelsTransactionResponse, ListChannelAccountsResponse, SetChannelAccountsResponse } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Client for interacting with the Channels plugin
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* // Connecting to OpenZeppelin's managed Channels service
|
|
7
|
+
* const client = new ChannelsClient({
|
|
8
|
+
* baseUrl: 'https://channels.openzeppelin.com',
|
|
9
|
+
* apiKey: 'your-api-key',
|
|
10
|
+
* adminSecret: 'your-admin-secret', // Optional, for management operations
|
|
11
|
+
* });
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // Connecting to your own Relayer with Channels plugin
|
|
15
|
+
* const client = new ChannelsClient({
|
|
16
|
+
* baseUrl: 'http://localhost:8080',
|
|
17
|
+
* pluginId: 'channels',
|
|
18
|
+
* apiKey: 'your-relayer-api-key',
|
|
19
|
+
* adminSecret: 'your-admin-secret', // Optional, for management operations
|
|
20
|
+
* });
|
|
21
|
+
*/
|
|
22
|
+
export declare class ChannelsClient {
|
|
23
|
+
private readonly adminSecret?;
|
|
24
|
+
private readonly axiosClient?;
|
|
25
|
+
private readonly pluginsApi?;
|
|
26
|
+
private readonly pluginId?;
|
|
27
|
+
constructor(config: ChannelsClientConfig);
|
|
28
|
+
/**
|
|
29
|
+
* Submit a signed XDR transaction to the channel accounts service
|
|
30
|
+
*
|
|
31
|
+
* @param request Transaction request with signed XDR
|
|
32
|
+
* @returns Transaction result with ID, hash, and status
|
|
33
|
+
* @throws {PluginTransportError} Network/HTTP failures
|
|
34
|
+
* @throws {PluginExecutionError} Plugin rejected the request
|
|
35
|
+
* @throws {PluginUnexpectedError} Malformed response or client-side errors
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* const result = await client.submitTransaction({
|
|
39
|
+
* xdr: 'AAAAAgAAAAC...',
|
|
40
|
+
* });
|
|
41
|
+
*/
|
|
42
|
+
submitTransaction(request: ChannelsXdrRequest): Promise<ChannelsTransactionResponse>;
|
|
43
|
+
/**
|
|
44
|
+
* Submit a Soroban transaction using function and authorization entries
|
|
45
|
+
* This path uses channel accounts and includes automatic simulation
|
|
46
|
+
*
|
|
47
|
+
* @param request Transaction request with func and auth
|
|
48
|
+
* @returns Transaction result with ID, hash, and status
|
|
49
|
+
* @throws {PluginTransportError} Network/HTTP failures
|
|
50
|
+
* @throws {PluginExecutionError} Plugin rejected the request
|
|
51
|
+
* @throws {PluginUnexpectedError} Malformed response or client-side errors
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* const result = await client.submitSorobanTransaction({
|
|
55
|
+
* func: 'AAAABgAAAA...',
|
|
56
|
+
* auth: ['AAAABwAAAA...', 'AAAABwAAAA...'],
|
|
57
|
+
* });
|
|
58
|
+
*/
|
|
59
|
+
submitSorobanTransaction(request: ChannelsFuncAuthRequest): Promise<ChannelsTransactionResponse>;
|
|
60
|
+
/**
|
|
61
|
+
* List currently configured channel accounts (requires adminSecret)
|
|
62
|
+
*
|
|
63
|
+
* @returns List of channel account relayer IDs
|
|
64
|
+
* @throws {Error} If adminSecret not provided in config
|
|
65
|
+
* @throws {PluginTransportError} Network/HTTP failures
|
|
66
|
+
* @throws {PluginExecutionError} Plugin rejected the request
|
|
67
|
+
* @throws {PluginUnexpectedError} Malformed response or client-side errors
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* const accounts = await client.listChannelAccounts();
|
|
71
|
+
* console.log(accounts.relayerIds);
|
|
72
|
+
*/
|
|
73
|
+
listChannelAccounts(): Promise<ListChannelAccountsResponse>;
|
|
74
|
+
/**
|
|
75
|
+
* Configure channel accounts for the service (requires adminSecret)
|
|
76
|
+
*
|
|
77
|
+
* @param relayerIds Array of relayer IDs to use as channel accounts
|
|
78
|
+
* @returns Confirmation with applied relayer IDs
|
|
79
|
+
* @throws {Error} If adminSecret not provided in config
|
|
80
|
+
* @throws {PluginTransportError} Network/HTTP failures
|
|
81
|
+
* @throws {PluginExecutionError} Plugin rejected the request
|
|
82
|
+
* @throws {PluginUnexpectedError} Malformed response or client-side errors
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* const result = await client.setChannelAccounts([
|
|
86
|
+
* 'relayer-id-1',
|
|
87
|
+
* 'relayer-id-2',
|
|
88
|
+
* ]);
|
|
89
|
+
*/
|
|
90
|
+
setChannelAccounts(relayerIds: string[]): Promise<SetChannelAccountsResponse>;
|
|
91
|
+
/**
|
|
92
|
+
* Ensures adminSecret is configured
|
|
93
|
+
*
|
|
94
|
+
* @returns The admin secret value
|
|
95
|
+
* @throws {Error} If adminSecret not provided in config
|
|
96
|
+
*/
|
|
97
|
+
private requireAdminSecret;
|
|
98
|
+
/**
|
|
99
|
+
* Parses axios errors and extracts response body if available
|
|
100
|
+
*
|
|
101
|
+
* @param error The caught error from axios
|
|
102
|
+
* @returns Plugin response if available in error
|
|
103
|
+
* @throws {PluginTransportError} For network/transport errors
|
|
104
|
+
* @throws {PluginUnexpectedError} For unknown error types
|
|
105
|
+
*/
|
|
106
|
+
private parseAxiosError;
|
|
107
|
+
/**
|
|
108
|
+
* Validates that response has the expected plugin response structure
|
|
109
|
+
*
|
|
110
|
+
* @param responseBody The raw response body to validate
|
|
111
|
+
* @returns Validated plugin response
|
|
112
|
+
* @throws {PluginUnexpectedError} For invalid/malformed responses
|
|
113
|
+
*/
|
|
114
|
+
private validateResponse;
|
|
115
|
+
/**
|
|
116
|
+
* Merges metadata into the response data if present
|
|
117
|
+
*
|
|
118
|
+
* @param data The response data
|
|
119
|
+
* @param metadata Optional metadata (logs and traces)
|
|
120
|
+
* @returns Data with metadata merged if present
|
|
121
|
+
*/
|
|
122
|
+
private mergeMetadata;
|
|
123
|
+
/**
|
|
124
|
+
* Internal method to make a plugin call with automatic payload wrapping and response parsing
|
|
125
|
+
*
|
|
126
|
+
* @param params Request parameters
|
|
127
|
+
* @returns Parsed response data with optional metadata
|
|
128
|
+
* @throws {PluginTransportError} Network/HTTP failures
|
|
129
|
+
* @throws {PluginExecutionError} Plugin rejected the request
|
|
130
|
+
* @throws {PluginUnexpectedError} Malformed response or client-side errors
|
|
131
|
+
*/
|
|
132
|
+
private call;
|
|
133
|
+
/**
|
|
134
|
+
* Internal method to send the actual HTTP request
|
|
135
|
+
* Routes to either axios (direct HTTP) or PluginsApi (relayer) based on configuration
|
|
136
|
+
*
|
|
137
|
+
* @param payload The complete payload (already wrapped in {params})
|
|
138
|
+
* @returns Raw response from the service/relayer
|
|
139
|
+
*/
|
|
140
|
+
private sendCall;
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=channels-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channels-client.d.ts","sourceRoot":"","sources":["../../src/client/channels-client.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,uBAAuB,EACvB,2BAA2B,EAC3B,2BAA2B,EAC3B,0BAA0B,EAE3B,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAgB;IAC7C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAa;IACzC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAS;gBAEvB,MAAM,EAAE,oBAAoB;IA6BxC;;;;;;;;;;;;;OAaG;IACG,iBAAiB,CACrB,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,2BAA2B,CAAC;IAIvC;;;;;;;;;;;;;;;OAeG;IACG,wBAAwB,CAC5B,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,2BAA2B,CAAC;IAIvC;;;;;;;;;;;;OAYG;IACG,mBAAmB,IAAI,OAAO,CAAC,2BAA2B,CAAC;IASjE;;;;;;;;;;;;;;;OAeG;IACG,kBAAkB,CACtB,UAAU,EAAE,MAAM,EAAE,GACnB,OAAO,CAAC,0BAA0B,CAAC;IAUtC;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;IAS1B;;;;;;;OAOG;IAEH,OAAO,CAAC,eAAe;IAoBvB;;;;;;OAMG;IACH,OAAO,CAAC,gBAAgB;IAgBxB;;;;;;OAMG;IACH,OAAO,CAAC,aAAa;IAUrB;;;;;;;;OAQG;YACW,IAAI;IA0BlB;;;;;;OAMG;YACW,QAAQ;CAYvB"}
|