@openzeppelin/relayer-plugin-channels 0.13.0 → 0.14.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/README.md +68 -1
- package/dist/client/channels-client.d.ts +15 -1
- package/dist/client/channels-client.d.ts.map +1 -1
- package/dist/client/channels-client.js +18 -0
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/types.d.ts +11 -0
- package/dist/client/types.d.ts.map +1 -1
- package/dist/plugin/constants.d.ts +4 -0
- package/dist/plugin/constants.d.ts.map +1 -1
- package/dist/plugin/constants.js +6 -1
- package/dist/plugin/handler.d.ts.map +1 -1
- package/dist/plugin/handler.js +27 -8
- package/dist/plugin/submit.d.ts +1 -1
- package/dist/plugin/submit.d.ts.map +1 -1
- package/dist/plugin/submit.js +31 -3
- package/dist/plugin/types.d.ts +5 -0
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/plugin/validation.d.ts.map +1 -1
- package/dist/plugin/validation.js +42 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,6 +37,8 @@ A plugin for OpenZeppelin Relayer that enables parallel transaction submission o
|
|
|
37
37
|
- [Submit with Transaction XDR](#submit-with-transaction-xdr)
|
|
38
38
|
- [Submit with Function and Auth](#submit-with-function-and-auth)
|
|
39
39
|
- [Parameters](#parameters)
|
|
40
|
+
- [Fire-and-Forget with skipWait](#fire-and-forget-with-skipwait)
|
|
41
|
+
- [Get Transaction by ID](#get-transaction-by-id)
|
|
40
42
|
- [Response](#response)
|
|
41
43
|
- [How It Works](#how-it-works)
|
|
42
44
|
- [Validation Rules](#validation-rules)
|
|
@@ -864,8 +866,73 @@ curl -X POST http://localhost:8080/api/v1/plugins/channels/call \
|
|
|
864
866
|
- `xdr` (string): Complete transaction envelope XDR (signed, not fee-bump)
|
|
865
867
|
- `func` (string): Soroban host function XDR (base64)
|
|
866
868
|
- `auth` (array): Array of Soroban authorization entry XDRs (base64)
|
|
869
|
+
- `skipWait` (boolean, optional): When `true`, returns immediately after submitting the transaction without waiting for confirmation. Defaults to `false`. Must be a boolean — non-boolean values (e.g., `"false"`, `1`) are rejected.
|
|
870
|
+
- `getTransaction` (object, optional): Poll for a transaction's status by ID. Cannot be combined with other parameters.
|
|
867
871
|
|
|
868
|
-
**Note**: Provide either `xdr` OR `func`+`auth`, not
|
|
872
|
+
**Note**: Provide either `xdr` OR `func`+`auth` OR `getTransaction`, not a combination.
|
|
873
|
+
|
|
874
|
+
### Fire-and-Forget with `skipWait`
|
|
875
|
+
|
|
876
|
+
When `skipWait: true` is passed with an `xdr` or `func`+`auth` request, the plugin submits the transaction and returns immediately with status `"pending"` instead of waiting for on-chain confirmation. This is useful for high-throughput scenarios where the caller handles confirmation separately.
|
|
877
|
+
|
|
878
|
+
```bash
|
|
879
|
+
curl -X POST http://localhost:8080/api/v1/plugins/channels/call \
|
|
880
|
+
-H "Authorization: Bearer YOUR_API_KEY" \
|
|
881
|
+
-H "Content-Type: application/json" \
|
|
882
|
+
-d '{
|
|
883
|
+
"params": {
|
|
884
|
+
"xdr": "AAAAAgAAAAB...",
|
|
885
|
+
"skipWait": true
|
|
886
|
+
}
|
|
887
|
+
}'
|
|
888
|
+
```
|
|
889
|
+
|
|
890
|
+
Response:
|
|
891
|
+
|
|
892
|
+
```json
|
|
893
|
+
{
|
|
894
|
+
"success": true,
|
|
895
|
+
"data": {
|
|
896
|
+
"transactionId": "tx_123456",
|
|
897
|
+
"status": "pending",
|
|
898
|
+
"hash": null
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
```
|
|
902
|
+
|
|
903
|
+
Use the returned `transactionId` with `getTransaction` to poll for the final status.
|
|
904
|
+
|
|
905
|
+
### Get Transaction by ID
|
|
906
|
+
|
|
907
|
+
Poll for the status of a previously submitted transaction using its `transactionId`. This is typically used after a `skipWait` submission to check whether the transaction has been confirmed.
|
|
908
|
+
|
|
909
|
+
```bash
|
|
910
|
+
curl -X POST http://localhost:8080/api/v1/plugins/channels/call \
|
|
911
|
+
-H "Authorization: Bearer YOUR_API_KEY" \
|
|
912
|
+
-H "Content-Type: application/json" \
|
|
913
|
+
-d '{
|
|
914
|
+
"params": {
|
|
915
|
+
"getTransaction": {
|
|
916
|
+
"transactionId": "tx_123456"
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
}'
|
|
920
|
+
```
|
|
921
|
+
|
|
922
|
+
Response:
|
|
923
|
+
|
|
924
|
+
```json
|
|
925
|
+
{
|
|
926
|
+
"success": true,
|
|
927
|
+
"data": {
|
|
928
|
+
"transactionId": "tx_123456",
|
|
929
|
+
"status": "confirmed",
|
|
930
|
+
"hash": "1234567890abcdef..."
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
```
|
|
934
|
+
|
|
935
|
+
The `status` field reflects the transaction's current state (e.g., `"pending"`, `"sent"`, `"submitted"`, `"confirmed"`, `"failed"`, `"expired"`). The `hash` field is `null` until the transaction is submitted.
|
|
869
936
|
|
|
870
937
|
### Response
|
|
871
938
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChannelsClientConfig, ChannelsXdrRequest, ChannelsFuncAuthRequest, ChannelsTransactionResponse, ListChannelAccountsResponse, SetChannelAccountsResponse, GetFeeUsageResponse, GetFeeLimitResponse, SetFeeLimitResponse, DeleteFeeLimitResponse, GetStatsResponse } from './types';
|
|
1
|
+
import type { ChannelsClientConfig, ChannelsXdrRequest, ChannelsFuncAuthRequest, ChannelsGetTransactionRequest, ChannelsTransactionResponse, ListChannelAccountsResponse, SetChannelAccountsResponse, GetFeeUsageResponse, GetFeeLimitResponse, SetFeeLimitResponse, DeleteFeeLimitResponse, GetStatsResponse } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Client for interacting with the Channels plugin
|
|
4
4
|
*
|
|
@@ -57,6 +57,20 @@ export declare class ChannelsClient {
|
|
|
57
57
|
* });
|
|
58
58
|
*/
|
|
59
59
|
submitSorobanTransaction(request: ChannelsFuncAuthRequest): Promise<ChannelsTransactionResponse>;
|
|
60
|
+
/**
|
|
61
|
+
* Get a transaction by ID, typically used to poll after a skipWait submission
|
|
62
|
+
*
|
|
63
|
+
* @param request Request with transactionId
|
|
64
|
+
* @returns Transaction result with ID, hash, and status
|
|
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 result = await client.getTransaction({ transactionId: 'tx-123' });
|
|
71
|
+
* console.log(result.status); // 'confirmed', 'pending', etc.
|
|
72
|
+
*/
|
|
73
|
+
getTransaction(request: ChannelsGetTransactionRequest): Promise<ChannelsTransactionResponse>;
|
|
60
74
|
/**
|
|
61
75
|
* List currently configured channel accounts (requires adminSecret)
|
|
62
76
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channels-client.d.ts","sourceRoot":"","sources":["../../src/client/channels-client.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,uBAAuB,EACvB,2BAA2B,EAC3B,2BAA2B,EAC3B,0BAA0B,EAC1B,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EACtB,gBAAgB,EAEjB,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;IAiCxC;;;;;;;;;;;;;OAaG;IACG,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OA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UrE;;;;;;;;;;;;OAYG;IACG,QAAQ,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAS3C;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;IAO1B;;;;;;;OAOG;IAEH,OAAO,CAAC,eAAe;IAgBvB;;;;;;OAMG;IACH,OAAO,CAAC,gBAAgB;IAcxB;;;;;;OAMG;IACH,OAAO,CAAC,aAAa;IAUrB;;;;;;;;OAQG;YACW,IAAI;IAwBlB;;;;;;OAMG;YACW,QAAQ;CASvB"}
|
|
@@ -93,6 +93,24 @@ class ChannelsClient {
|
|
|
93
93
|
async submitSorobanTransaction(request) {
|
|
94
94
|
return this.call(request);
|
|
95
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Get a transaction by ID, typically used to poll after a skipWait submission
|
|
98
|
+
*
|
|
99
|
+
* @param request Request with transactionId
|
|
100
|
+
* @returns Transaction result with ID, hash, and status
|
|
101
|
+
* @throws {PluginTransportError} Network/HTTP failures
|
|
102
|
+
* @throws {PluginExecutionError} Plugin rejected the request
|
|
103
|
+
* @throws {PluginUnexpectedError} Malformed response or client-side errors
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* const result = await client.getTransaction({ transactionId: 'tx-123' });
|
|
107
|
+
* console.log(result.status); // 'confirmed', 'pending', etc.
|
|
108
|
+
*/
|
|
109
|
+
async getTransaction(request) {
|
|
110
|
+
return this.call({
|
|
111
|
+
getTransaction: { transactionId: request.transactionId },
|
|
112
|
+
});
|
|
113
|
+
}
|
|
96
114
|
/**
|
|
97
115
|
* List currently configured channel accounts (requires adminSecret)
|
|
98
116
|
*
|
package/dist/client/index.d.ts
CHANGED
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
* in both direct HTTP mode and OpenZeppelin Relayer mode.
|
|
6
6
|
*/
|
|
7
7
|
export { ChannelsClient } from './channels-client';
|
|
8
|
-
export { ChannelsClientConfig, DirectHttpConfig, RelayerConfig, ChannelsXdrRequest, ChannelsFuncAuthRequest, ChannelsTransactionResponse, ListChannelAccountsResponse, SetChannelAccountsResponse, GetFeeUsageResponse, GetFeeLimitResponse, SetFeeLimitResponse, DeleteFeeLimitResponse, GetStatsResponse, } from './types';
|
|
8
|
+
export { ChannelsClientConfig, DirectHttpConfig, RelayerConfig, ChannelsXdrRequest, ChannelsFuncAuthRequest, ChannelsGetTransactionRequest, ChannelsTransactionResponse, ListChannelAccountsResponse, SetChannelAccountsResponse, GetFeeUsageResponse, GetFeeLimitResponse, SetFeeLimitResponse, DeleteFeeLimitResponse, GetStatsResponse, } from './types';
|
|
9
9
|
export { PluginClientError, PluginTransportError, PluginExecutionError, PluginUnexpectedError } from './errors';
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,uBAAuB,EACvB,2BAA2B,EAC3B,2BAA2B,EAC3B,0BAA0B,EAC1B,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,uBAAuB,EACvB,6BAA6B,EAC7B,2BAA2B,EAC3B,2BAA2B,EAC3B,0BAA0B,EAC1B,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/client/types.d.ts
CHANGED
|
@@ -42,6 +42,8 @@ export type ChannelsClientConfig = DirectHttpConfig | RelayerConfig;
|
|
|
42
42
|
export interface ChannelsXdrRequest {
|
|
43
43
|
/** Complete signed transaction envelope XDR */
|
|
44
44
|
xdr: string;
|
|
45
|
+
/** When true, returns immediately after submission without waiting for confirmation */
|
|
46
|
+
skipWait?: boolean;
|
|
45
47
|
}
|
|
46
48
|
/**
|
|
47
49
|
* Transaction submission using Soroban function and authorization
|
|
@@ -51,6 +53,15 @@ export interface ChannelsFuncAuthRequest {
|
|
|
51
53
|
func: string;
|
|
52
54
|
/** Array of authorization entry XDRs (base64) */
|
|
53
55
|
auth: string[];
|
|
56
|
+
/** When true, returns immediately after submission without waiting for confirmation */
|
|
57
|
+
skipWait?: boolean;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Request to get a transaction by ID
|
|
61
|
+
*/
|
|
62
|
+
export interface ChannelsGetTransactionRequest {
|
|
63
|
+
/** Transaction ID returned from a previous submission */
|
|
64
|
+
transactionId: string;
|
|
54
65
|
}
|
|
55
66
|
/**
|
|
56
67
|
* Response from transaction submission
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,4CAA4C;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gEAA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AC;QAClB,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC;KAChB,CAAC;CACH;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,qBAAqB,CAAC,CAAC,CAAC,GAAG,mBAAmB,CAAC"}
|
|
@@ -40,6 +40,10 @@ export declare const SIMULATION: {
|
|
|
40
40
|
/** Minimum ledger margin required between latestLedger and auth signatureExpirationLedger. Must be > 1 since simulation already validates 1 ledger of validity. ~10s at ~5s/ledger. */
|
|
41
41
|
readonly MIN_SIGNATURE_EXPIRATION_LEDGER_BUFFER: 2;
|
|
42
42
|
};
|
|
43
|
+
export declare const TIMEOUT: {
|
|
44
|
+
readonly GLOBAL_TIMEOUT_MS: 30000;
|
|
45
|
+
readonly BUFFER_MS: 2000;
|
|
46
|
+
};
|
|
43
47
|
export declare const POLLING: {
|
|
44
48
|
readonly INTERVAL_MS: 1000;
|
|
45
49
|
readonly TIMEOUT_MS: 25000;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/plugin/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,eAAO,MAAM,WAAW;;;;;;;;;;CAUd,CAAC;AAGX,eAAO,MAAM,MAAM;;;;;;;CAOT,CAAC;AAGX,eAAO,MAAM,IAAI;;;;;CAOP,CAAC;AAGX,eAAO,MAAM,IAAI;;CAEP,CAAC;AAGX,eAAO,MAAM,UAAU;;;;;;IAMrB,uLAAuL;;CAE/K,CAAC;AAGX,eAAO,MAAM,OAAO;;;CAGV,CAAC;AAEX,eAAO,MAAM,GAAG;;CAGN,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/plugin/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,eAAO,MAAM,WAAW;;;;;;;;;;CAUd,CAAC;AAGX,eAAO,MAAM,MAAM;;;;;;;CAOT,CAAC;AAGX,eAAO,MAAM,IAAI;;;;;CAOP,CAAC;AAGX,eAAO,MAAM,IAAI;;CAEP,CAAC;AAGX,eAAO,MAAM,UAAU;;;;;;IAMrB,uLAAuL;;CAE/K,CAAC;AAGX,eAAO,MAAM,OAAO;;;CAGV,CAAC;AAGX,eAAO,MAAM,OAAO;;;CAGV,CAAC;AAEX,eAAO,MAAM,GAAG;;CAGN,CAAC"}
|
package/dist/plugin/constants.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Centralized constants for the channel accounts plugin.
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.FEE = exports.POLLING = exports.SIMULATION = exports.TIME = exports.POOL = exports.CONFIG = exports.HTTP_STATUS = void 0;
|
|
8
|
+
exports.FEE = exports.POLLING = exports.TIMEOUT = exports.SIMULATION = exports.TIME = exports.POOL = exports.CONFIG = exports.HTTP_STATUS = void 0;
|
|
9
9
|
// HTTP Status Codes
|
|
10
10
|
exports.HTTP_STATUS = {
|
|
11
11
|
BAD_REQUEST: 400,
|
|
@@ -50,6 +50,11 @@ exports.SIMULATION = {
|
|
|
50
50
|
/** Minimum ledger margin required between latestLedger and auth signatureExpirationLedger. Must be > 1 since simulation already validates 1 ledger of validity. ~10s at ~5s/ledger. */
|
|
51
51
|
MIN_SIGNATURE_EXPIRATION_LEDGER_BUFFER: 2,
|
|
52
52
|
};
|
|
53
|
+
// Global plugin timeout budget
|
|
54
|
+
exports.TIMEOUT = {
|
|
55
|
+
GLOBAL_TIMEOUT_MS: 30000,
|
|
56
|
+
BUFFER_MS: 2000,
|
|
57
|
+
};
|
|
53
58
|
// Polling for transactionWait
|
|
54
59
|
exports.POLLING = {
|
|
55
60
|
INTERVAL_MS: 1000,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/plugin/handler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAe,MAAM,2BAA2B,CAAC;AASvE,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/plugin/handler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAe,MAAM,2BAA2B,CAAC;AASvE,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AA2BxD;;;GAGG;AACH,wBAAgB,8BAA8B,CAC5C,EAAE,EAAE,WAAW,GACd;IAAE,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC;IAAC,IAAI,EAAE,GAAG,CAAC,yBAAyB,EAAE,CAAA;CAAE,GAAG,IAAI,CAkB1E;AA6RD;;GAEG;AACH,wBAAsB,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,CAElE"}
|
package/dist/plugin/handler.js
CHANGED
|
@@ -45,7 +45,7 @@ function extractFuncAuthFromUnsignedXdr(tx) {
|
|
|
45
45
|
auth: invokeHostFn.auth(),
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
-
async function handleXdrSubmit(xdrStr, ctx) {
|
|
48
|
+
async function handleXdrSubmit(xdrStr, ctx, skipWait) {
|
|
49
49
|
const tx = new stellar_sdk_1.Transaction(xdrStr, ctx.networkPassphrase);
|
|
50
50
|
// Unsigned XDR: extract func+auth and route through channel path
|
|
51
51
|
if (tx.signatures.length === 0) {
|
|
@@ -64,7 +64,7 @@ async function handleXdrSubmit(xdrStr, ctx) {
|
|
|
64
64
|
// Update acquireOptions with contractId from extracted func
|
|
65
65
|
const contractId = (0, fee_1.getContractIdFromFunc)(extracted.func);
|
|
66
66
|
const updatedOptions = { ...ctx.acquireOptions, contractId };
|
|
67
|
-
return handleFuncAuthSubmit(extracted.func, extracted.auth, { ...ctx, acquireOptions: updatedOptions });
|
|
67
|
+
return handleFuncAuthSubmit(extracted.func, extracted.auth, { ...ctx, acquireOptions: updatedOptions }, skipWait);
|
|
68
68
|
}
|
|
69
69
|
const validated = (0, tx_1.validateExistingTransactionForSubmitOnly)(tx);
|
|
70
70
|
const maxFee = (0, fee_1.calculateMaxFee)(validated, ctx.acquireOptions.limitedContracts, ctx.fees);
|
|
@@ -74,9 +74,9 @@ async function handleXdrSubmit(xdrStr, ctx) {
|
|
|
74
74
|
contractId,
|
|
75
75
|
isLimited: contractId ? ctx.acquireOptions.limitedContracts.has(contractId) : false,
|
|
76
76
|
};
|
|
77
|
-
return (0, submit_1.submitWithFeeBumpAndWait)(ctx.fundRelayer, validated.toXDR(), ctx.network, maxFee, ctx.api, ctx.tracker, submitContext);
|
|
77
|
+
return (0, submit_1.submitWithFeeBumpAndWait)(ctx.fundRelayer, validated.toXDR(), ctx.network, maxFee, ctx.api, ctx.startTime, ctx.tracker, submitContext, skipWait);
|
|
78
78
|
}
|
|
79
|
-
async function handleFuncAuthSubmit(func, auth, ctx) {
|
|
79
|
+
async function handleFuncAuthSubmit(func, auth, ctx, skipWait) {
|
|
80
80
|
// Simulate once — used for both read-only detection and transaction assembly
|
|
81
81
|
const simulation = await (0, simulation_1.simulateTransaction)(func, auth, ctx.fundAddress, ctx.fundRelayer, ctx.networkPassphrase);
|
|
82
82
|
if (simulation.isReadOnly) {
|
|
@@ -121,8 +121,15 @@ async function handleFuncAuthSubmit(func, auth, ctx) {
|
|
|
121
121
|
isLimited: contractId ? ctx.acquireOptions.limitedContracts.has(contractId) : false,
|
|
122
122
|
};
|
|
123
123
|
try {
|
|
124
|
-
const result = await (0, submit_1.submitWithFeeBumpAndWait)(ctx.fundRelayer, signedTx.toXDR(), ctx.network, maxFee, ctx.api, ctx.tracker, submitContext);
|
|
125
|
-
if (result.status === '
|
|
124
|
+
const result = await (0, submit_1.submitWithFeeBumpAndWait)(ctx.fundRelayer, signedTx.toXDR(), ctx.network, maxFee, ctx.api, ctx.startTime, ctx.tracker, submitContext, skipWait);
|
|
125
|
+
if (result.status === 'pending' || result.status === 'sent' || result.status === 'submitted') {
|
|
126
|
+
// extend lock and clear sequence
|
|
127
|
+
console.log(`[channels]: extending lock and clearing sequence`);
|
|
128
|
+
await ctx.pool.extendLock(poolLock);
|
|
129
|
+
await (0, sequence_1.clearSequence)(ctx.kv, ctx.network, channelInfo.address);
|
|
130
|
+
poolLock = undefined; // skip release in finally
|
|
131
|
+
}
|
|
132
|
+
else if (result.status === 'confirmed') {
|
|
126
133
|
await (0, sequence_1.commitSequence)(ctx.kv, ctx.network, channelInfo.address, sequence);
|
|
127
134
|
}
|
|
128
135
|
else {
|
|
@@ -147,6 +154,7 @@ async function handleFuncAuthSubmit(func, auth, ctx) {
|
|
|
147
154
|
}
|
|
148
155
|
}
|
|
149
156
|
async function channelAccounts(context) {
|
|
157
|
+
const startTime = Date.now();
|
|
150
158
|
const { api, kv, params, headers } = context;
|
|
151
159
|
// Management branch: handle and return immediately
|
|
152
160
|
if ((0, management_1.isManagementRequest)(params)) {
|
|
@@ -181,6 +189,16 @@ async function channelAccounts(context) {
|
|
|
181
189
|
console.debug(`[channels] Request type: ${request.type}, auth entries: ${request.type === 'func-auth' ? request.auth.length : 'N/A'}`);
|
|
182
190
|
// 2. Get fund relayer
|
|
183
191
|
const fundRelayer = api.useRelayer(config.fundRelayerId);
|
|
192
|
+
// 2a. Handle get-transaction early — no pool, channel, or simulation needed
|
|
193
|
+
if (request.type === 'get-transaction') {
|
|
194
|
+
const res = await fundRelayer.getTransaction({ transactionId: request.transactionId });
|
|
195
|
+
const stellar = res;
|
|
196
|
+
return {
|
|
197
|
+
transactionId: stellar.id,
|
|
198
|
+
status: stellar.status,
|
|
199
|
+
hash: stellar.hash ?? null,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
184
202
|
const fundInfo = await fundRelayer.getRelayer();
|
|
185
203
|
if (!fundInfo || !fundInfo.address) {
|
|
186
204
|
throw (0, relayer_sdk_1.pluginError)('Fund relayer not found', {
|
|
@@ -218,17 +236,18 @@ async function channelAccounts(context) {
|
|
|
218
236
|
fees,
|
|
219
237
|
tracker,
|
|
220
238
|
config,
|
|
239
|
+
startTime,
|
|
221
240
|
};
|
|
222
241
|
// 5. Branch by request type
|
|
223
242
|
if (request.type === 'xdr') {
|
|
224
243
|
console.log(`[channels] Flow: XDR submit-only`);
|
|
225
|
-
return await handleXdrSubmit(request.xdr, ctx);
|
|
244
|
+
return await handleXdrSubmit(request.xdr, ctx, request.skipWait);
|
|
226
245
|
}
|
|
227
246
|
// Extract contractId for func+auth flow
|
|
228
247
|
const contractId = (0, fee_1.getContractIdFromFunc)(request.func);
|
|
229
248
|
const funcAcquireOptions = { ...acquireOptions, contractId };
|
|
230
249
|
console.log(`[channels] Flow: func+auth with channel account`);
|
|
231
|
-
return await handleFuncAuthSubmit(request.func, request.auth, { ...ctx, acquireOptions: funcAcquireOptions });
|
|
250
|
+
return await handleFuncAuthSubmit(request.func, request.auth, { ...ctx, acquireOptions: funcAcquireOptions }, request.skipWait);
|
|
232
251
|
}
|
|
233
252
|
/**
|
|
234
253
|
* Main plugin handler exported for OpenZeppelin Relayer
|
package/dist/plugin/submit.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export declare function signWithChannelAndFund(transaction: Transaction, channel
|
|
|
25
25
|
/**
|
|
26
26
|
* Submit transaction with fee bump and wait for confirmation
|
|
27
27
|
*/
|
|
28
|
-
export declare function submitWithFeeBumpAndWait(fundRelayer: Relayer, signedXdr: string, network: 'testnet' | 'mainnet', maxFee: number, api: PluginAPI, tracker?: FeeTracker, context?: SubmitContext): Promise<ChannelAccountsResponse>;
|
|
28
|
+
export declare function submitWithFeeBumpAndWait(fundRelayer: Relayer, signedXdr: string, network: 'testnet' | 'mainnet', maxFee: number, api: PluginAPI, startTime: number, tracker?: FeeTracker, context?: SubmitContext, skipWait?: boolean): Promise<ChannelAccountsResponse>;
|
|
29
29
|
/** Try to decode a transaction result XDR from the reason string */
|
|
30
30
|
export declare function decodeTransactionResult(reason: string): DecodedTransactionResult | null;
|
|
31
31
|
export declare function buildStellarLabTransactionUrl(network: 'testnet' | 'mainnet', txHash: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"submit.d.ts","sourceRoot":"","sources":["../../src/plugin/submit.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAO,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAEL,OAAO,EAGP,SAAS,EACV,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,WAAW,aAAa;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,UAAU,wBAAwB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAC1C,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,OAAO,EACvB,YAAY,EAAE,OAAO,EACrB,cAAc,EAAE,MAAM,EACtB,YAAY,EAAE,MAAM,EACpB,iBAAiB,EAAE,MAAM,GACxB,OAAO,CAAC,WAAW,CAAC,CAuBtB;AAED;;GAEG;AACH,wBAAsB,wBAAwB,CAC5C,WAAW,EAAE,OAAO,EACpB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,SAAS,GAAG,SAAS,EAC9B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,SAAS,EACd,OAAO,CAAC,EAAE,UAAU,EACpB,OAAO,CAAC,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"submit.d.ts","sourceRoot":"","sources":["../../src/plugin/submit.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAO,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAEL,OAAO,EAGP,SAAS,EACV,MAAM,2BA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
|
43
43
|
* Submit transaction with fee bump and wait for confirmation
|
|
44
44
|
*/
|
|
45
|
-
async function submitWithFeeBumpAndWait(fundRelayer, signedXdr, network, maxFee, api, tracker, context) {
|
|
45
|
+
async function submitWithFeeBumpAndWait(fundRelayer, signedXdr, network, maxFee, api, startTime, tracker, context, skipWait) {
|
|
46
46
|
// Submit with fee bump
|
|
47
47
|
console.debug(`[channels] Sending fee bump tx: network=${network}, maxFee=${maxFee}, xdr_len=${signedXdr.length}`);
|
|
48
48
|
const payload = {
|
|
@@ -53,11 +53,39 @@ async function submitWithFeeBumpAndWait(fundRelayer, signedXdr, network, maxFee,
|
|
|
53
53
|
};
|
|
54
54
|
console.debug(`[channels] Relayer payload: ${JSON.stringify(payload)}`);
|
|
55
55
|
const submission = await fundRelayer.sendTransaction(payload);
|
|
56
|
+
// skipWait: return immediately after sendTransaction without waiting for confirmation
|
|
57
|
+
if (skipWait) {
|
|
58
|
+
console.debug(`[channels] skipWait enabled, returning pending result immediately`);
|
|
59
|
+
if (tracker) {
|
|
60
|
+
await tracker.recordUsage(maxFee);
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
transactionId: submission.id,
|
|
64
|
+
status: 'pending',
|
|
65
|
+
hash: submission.hash ?? null,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
// Compute dynamic timeout from remaining global budget
|
|
69
|
+
const elapsedMs = Date.now() - startTime;
|
|
70
|
+
const remainingMs = constants_1.TIMEOUT.GLOBAL_TIMEOUT_MS - constants_1.TIMEOUT.BUFFER_MS - elapsedMs;
|
|
71
|
+
if (remainingMs <= 0) {
|
|
72
|
+
throw (0, relayer_sdk_1.pluginError)('No time remaining for transaction wait', {
|
|
73
|
+
code: 'WAIT_TIMEOUT',
|
|
74
|
+
status: constants_1.HTTP_STATUS.GATEWAY_TIMEOUT,
|
|
75
|
+
details: {
|
|
76
|
+
id: submission.id,
|
|
77
|
+
hash: submission.hash ?? null,
|
|
78
|
+
elapsedMs,
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
const timeout = Math.min(remainingMs, constants_1.POLLING.TIMEOUT_MS);
|
|
83
|
+
console.debug(`[channels] Transaction wait: elapsed=${elapsedMs}ms, timeout=${timeout}ms`);
|
|
56
84
|
// Wait for confirmation
|
|
57
85
|
try {
|
|
58
86
|
const final = (await api.transactionWait(submission, {
|
|
59
|
-
interval:
|
|
60
|
-
timeout
|
|
87
|
+
interval: constants_1.POLLING.INTERVAL_MS,
|
|
88
|
+
timeout,
|
|
61
89
|
}));
|
|
62
90
|
// Check if transaction actually succeeded
|
|
63
91
|
if (final.status === 'failed') {
|
package/dist/plugin/types.d.ts
CHANGED
|
@@ -12,10 +12,15 @@ import type { xdr } from '@stellar/stellar-sdk';
|
|
|
12
12
|
export type ChannelAccountsRequest = {
|
|
13
13
|
type: 'xdr';
|
|
14
14
|
xdr: string;
|
|
15
|
+
skipWait: boolean;
|
|
15
16
|
} | {
|
|
16
17
|
type: 'func-auth';
|
|
17
18
|
func: xdr.HostFunction;
|
|
18
19
|
auth: xdr.SorobanAuthorizationEntry[];
|
|
20
|
+
skipWait: boolean;
|
|
21
|
+
} | {
|
|
22
|
+
type: 'get-transaction';
|
|
23
|
+
transactionId: string;
|
|
19
24
|
};
|
|
20
25
|
/**
|
|
21
26
|
* Plugin response format aligned with launchtube
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/plugin/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AACH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAEhD,MAAM,MAAM,sBAAsB,GAC9B;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/plugin/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;G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;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/plugin/validation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEjD,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,GAAG,GAAG,sBAAsB,
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/plugin/validation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEjD,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,GAAG,GAAG,sBAAsB,CA8H3E"}
|
|
@@ -19,6 +19,33 @@ function validateAndParseRequest(params) {
|
|
|
19
19
|
}
|
|
20
20
|
// Disallow any management-shaped keys leaking into here; management is handled earlier
|
|
21
21
|
const keys = Object.keys(params);
|
|
22
|
+
// Mode: getTransaction
|
|
23
|
+
if ('getTransaction' in params) {
|
|
24
|
+
const unknown = keys.filter((k) => k !== 'getTransaction');
|
|
25
|
+
if (unknown.length > 0) {
|
|
26
|
+
throw (0, relayer_sdk_1.pluginError)('`getTransaction` request must not include other parameters', {
|
|
27
|
+
code: 'INVALID_PARAMS',
|
|
28
|
+
status: constants_1.HTTP_STATUS.BAD_REQUEST,
|
|
29
|
+
details: { unknown },
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const gt = params.getTransaction;
|
|
33
|
+
if (!gt || typeof gt !== 'object' || typeof gt.transactionId !== 'string' || gt.transactionId.trim() === '') {
|
|
34
|
+
throw (0, relayer_sdk_1.pluginError)('`getTransaction.transactionId` must be a non-empty string', {
|
|
35
|
+
code: 'INVALID_PARAMS',
|
|
36
|
+
status: constants_1.HTTP_STATUS.BAD_REQUEST,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
const unknownInner = Object.keys(gt).filter((k) => k !== 'transactionId');
|
|
40
|
+
if (unknownInner.length > 0) {
|
|
41
|
+
throw (0, relayer_sdk_1.pluginError)('`getTransaction` must only contain `transactionId`', {
|
|
42
|
+
code: 'INVALID_PARAMS',
|
|
43
|
+
status: constants_1.HTTP_STATUS.BAD_REQUEST,
|
|
44
|
+
details: { unknown: unknownInner },
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return { type: 'get-transaction', transactionId: gt.transactionId.trim() };
|
|
48
|
+
}
|
|
22
49
|
// Mode: XDR
|
|
23
50
|
if ('xdr' in params) {
|
|
24
51
|
if (typeof params.xdr !== 'string' || params.xdr.trim() === '') {
|
|
@@ -28,7 +55,7 @@ function validateAndParseRequest(params) {
|
|
|
28
55
|
});
|
|
29
56
|
}
|
|
30
57
|
// Strict: cannot include func/auth when using xdr
|
|
31
|
-
const unknown = keys.filter((k) => !['xdr'].includes(k));
|
|
58
|
+
const unknown = keys.filter((k) => !['xdr', 'skipWait'].includes(k));
|
|
32
59
|
if (unknown.length > 0) {
|
|
33
60
|
throw (0, relayer_sdk_1.pluginError)('`xdr` request must not include other parameters', {
|
|
34
61
|
code: 'INVALID_PARAMS',
|
|
@@ -36,7 +63,13 @@ function validateAndParseRequest(params) {
|
|
|
36
63
|
details: { unknown },
|
|
37
64
|
});
|
|
38
65
|
}
|
|
39
|
-
|
|
66
|
+
if (params.skipWait !== undefined && typeof params.skipWait !== 'boolean') {
|
|
67
|
+
throw (0, relayer_sdk_1.pluginError)('`skipWait` must be a boolean', {
|
|
68
|
+
code: 'INVALID_PARAMS',
|
|
69
|
+
status: constants_1.HTTP_STATUS.BAD_REQUEST,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return { type: 'xdr', xdr: params.xdr.trim(), skipWait: params.skipWait === true };
|
|
40
73
|
}
|
|
41
74
|
// Mode: func+auth
|
|
42
75
|
if ('func' in params || 'auth' in params) {
|
|
@@ -74,7 +107,13 @@ function validateAndParseRequest(params) {
|
|
|
74
107
|
});
|
|
75
108
|
}
|
|
76
109
|
}
|
|
77
|
-
|
|
110
|
+
if (params.skipWait !== undefined && typeof params.skipWait !== 'boolean') {
|
|
111
|
+
throw (0, relayer_sdk_1.pluginError)('`skipWait` must be a boolean', {
|
|
112
|
+
code: 'INVALID_PARAMS',
|
|
113
|
+
status: constants_1.HTTP_STATUS.BAD_REQUEST,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return { type: 'func-auth', func, auth, skipWait: params.skipWait === true };
|
|
78
117
|
}
|
|
79
118
|
throw (0, relayer_sdk_1.pluginError)('Must pass either `xdr` or `func` and `auth`', {
|
|
80
119
|
code: 'INVALID_PARAMS',
|