@openzeppelin/relayer-plugin-channels 0.5.0 → 0.7.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 +79 -43
- package/dist/client/channels-client.d.ts +1 -1
- package/dist/client/channels-client.d.ts.map +1 -1
- package/dist/client/channels-client.js +20 -21
- package/dist/client/errors.d.ts +1 -1
- package/dist/client/errors.js +12 -9
- package/dist/client/index.d.ts +3 -3
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/types.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/plugin/build.d.ts +1 -1
- package/dist/plugin/build.d.ts.map +1 -1
- package/dist/plugin/build.js +11 -17
- package/dist/plugin/config.d.ts +4 -2
- package/dist/plugin/config.d.ts.map +1 -1
- package/dist/plugin/config.js +43 -13
- package/dist/plugin/constants.d.ts +1 -2
- package/dist/plugin/constants.d.ts.map +1 -1
- package/dist/plugin/constants.js +2 -3
- package/dist/plugin/fee-tracking.d.ts +2 -2
- package/dist/plugin/fee-tracking.d.ts.map +1 -1
- package/dist/plugin/fee-tracking.js +4 -9
- package/dist/plugin/fee.d.ts +16 -5
- package/dist/plugin/fee.d.ts.map +1 -1
- package/dist/plugin/fee.js +52 -14
- package/dist/plugin/handler.d.ts +10 -1
- package/dist/plugin/handler.d.ts.map +1 -1
- package/dist/plugin/handler.js +87 -52
- package/dist/plugin/index.d.ts +1 -1
- package/dist/plugin/management.d.ts +1 -1
- package/dist/plugin/management.d.ts.map +1 -1
- package/dist/plugin/management.js +53 -79
- package/dist/plugin/pool.d.ts +8 -3
- package/dist/plugin/pool.d.ts.map +1 -1
- package/dist/plugin/pool.js +45 -17
- package/dist/plugin/simulation.d.ts +4 -2
- package/dist/plugin/simulation.d.ts.map +1 -1
- package/dist/plugin/simulation.js +41 -33
- package/dist/plugin/submit.d.ts +7 -5
- package/dist/plugin/submit.d.ts.map +1 -1
- package/dist/plugin/submit.js +23 -13
- package/dist/plugin/tx.d.ts +1 -1
- package/dist/plugin/tx.d.ts.map +1 -1
- package/dist/plugin/tx.js +6 -8
- package/dist/plugin/types.d.ts +4 -4
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/plugin/validation.d.ts +1 -1
- package/dist/plugin/validation.d.ts.map +1 -1
- package/dist/plugin/validation.js +26 -27
- package/package.json +1 -1
package/dist/plugin/tx.d.ts
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Transaction validation helpers for the XDR submit-only path.
|
|
5
5
|
*/
|
|
6
|
-
import { Transaction } from
|
|
6
|
+
import { Transaction } from '@stellar/stellar-sdk';
|
|
7
7
|
export declare function validateExistingTransactionForSubmitOnly(tx: Transaction): Transaction;
|
|
8
8
|
//# sourceMappingURL=tx.d.ts.map
|
package/dist/plugin/tx.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tx.d.ts","sourceRoot":"","sources":["../../src/plugin/tx.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAO,MAAM,sBAAsB,CAAC;AAIxD,wBAAgB,wCAAwC,
|
|
1
|
+
{"version":3,"file":"tx.d.ts","sourceRoot":"","sources":["../../src/plugin/tx.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAO,MAAM,sBAAsB,CAAC;AAIxD,wBAAgB,wCAAwC,CAAC,EAAE,EAAE,WAAW,GAAG,WAAW,CAsCrF"}
|
package/dist/plugin/tx.js
CHANGED
|
@@ -15,8 +15,8 @@ function validateExistingTransactionForSubmitOnly(tx) {
|
|
|
15
15
|
const envelope = tx.toEnvelope();
|
|
16
16
|
const kind = envelope.switch();
|
|
17
17
|
if (kind !== stellar_sdk_1.xdr.EnvelopeType.envelopeTypeTx()) {
|
|
18
|
-
throw (0, relayer_sdk_1.pluginError)(
|
|
19
|
-
code:
|
|
18
|
+
throw (0, relayer_sdk_1.pluginError)('Input must be a regular transaction envelope (fee-bump not allowed)', {
|
|
19
|
+
code: 'INVALID_ENVELOPE_TYPE',
|
|
20
20
|
status: constants_1.HTTP_STATUS.BAD_REQUEST,
|
|
21
21
|
});
|
|
22
22
|
}
|
|
@@ -25,19 +25,17 @@ function validateExistingTransactionForSubmitOnly(tx) {
|
|
|
25
25
|
if (sorobanData) {
|
|
26
26
|
const resourceFee = sorobanData.resourceFee().toBigInt();
|
|
27
27
|
if (BigInt(tx.fee) > resourceFee + 201n) {
|
|
28
|
-
throw (0, relayer_sdk_1.pluginError)(
|
|
29
|
-
code:
|
|
28
|
+
throw (0, relayer_sdk_1.pluginError)('Transaction fee must be equal to the resource fee', {
|
|
29
|
+
code: 'FEE_MISMATCH',
|
|
30
30
|
status: constants_1.HTTP_STATUS.BAD_REQUEST,
|
|
31
31
|
details: { fee: tx.fee, resourceFee: resourceFee.toString() },
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
// Time bounds sanity
|
|
36
|
-
if (tx.timeBounds?.maxTime &&
|
|
37
|
-
Number(tx.timeBounds.maxTime) - now >
|
|
38
|
-
constants_1.SIMULATION.MAX_FUTURE_TIME_BOUND_SECONDS) {
|
|
36
|
+
if (tx.timeBounds?.maxTime && Number(tx.timeBounds.maxTime) - now > constants_1.SIMULATION.MAX_FUTURE_TIME_BOUND_SECONDS) {
|
|
39
37
|
throw (0, relayer_sdk_1.pluginError)(`Transaction \`timeBounds.maxTime\` too far into the future. Must be no greater than ${constants_1.SIMULATION.MAX_FUTURE_TIME_BOUND_SECONDS} seconds`, {
|
|
40
|
-
code:
|
|
38
|
+
code: 'TIMEBOUNDS_TOO_FAR',
|
|
41
39
|
status: constants_1.HTTP_STATUS.BAD_REQUEST,
|
|
42
40
|
});
|
|
43
41
|
}
|
package/dist/plugin/types.d.ts
CHANGED
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
* - Submit-only: signed regular transaction XDR
|
|
9
9
|
* - Channel build: func + auth (always simulated)
|
|
10
10
|
*/
|
|
11
|
-
import type { xdr } from
|
|
11
|
+
import type { xdr } from '@stellar/stellar-sdk';
|
|
12
12
|
export type ChannelAccountsRequest = {
|
|
13
|
-
type:
|
|
13
|
+
type: 'xdr';
|
|
14
14
|
xdr: string;
|
|
15
15
|
} | {
|
|
16
|
-
type:
|
|
16
|
+
type: 'func-auth';
|
|
17
17
|
func: xdr.HostFunction;
|
|
18
18
|
auth: xdr.SorobanAuthorizationEntry[];
|
|
19
19
|
};
|
|
@@ -31,7 +31,7 @@ export interface ChannelAccountsResponse {
|
|
|
31
31
|
export interface ManagementRequest {
|
|
32
32
|
management: {
|
|
33
33
|
adminSecret: string;
|
|
34
|
-
action:
|
|
34
|
+
action: 'listChannelAccounts' | 'setChannelAccounts';
|
|
35
35
|
relayerIds?: string[];
|
|
36
36
|
};
|
|
37
37
|
}
|
|
@@ -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,GAC5B;
|
|
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,GAC5B;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC;IAAC,IAAI,EAAE,GAAG,CAAC,yBAAyB,EAAE,CAAA;CAAE,CAAC;AAEzF;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE;QACV,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,EAAE,qBAAqB,GAAG,oBAAoB,CAAC;QACrD,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;KACvB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,EAAE,EAAE,OAAO,CAAC;IACZ,iBAAiB,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
* Request validation and parsing for the Channel Accounts plugin.
|
|
5
5
|
* Supports either a signed XDR or func+auth.
|
|
6
6
|
*/
|
|
7
|
-
import { ChannelAccountsRequest } from
|
|
7
|
+
import { ChannelAccountsRequest } from './types';
|
|
8
8
|
export declare function validateAndParseRequest(params: any): ChannelAccountsRequest;
|
|
9
9
|
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -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,CAiF3E"}
|
|
@@ -11,38 +11,38 @@ const stellar_sdk_1 = require("@stellar/stellar-sdk");
|
|
|
11
11
|
const relayer_sdk_1 = require("@openzeppelin/relayer-sdk");
|
|
12
12
|
const constants_1 = require("./constants");
|
|
13
13
|
function validateAndParseRequest(params) {
|
|
14
|
-
if (!params || typeof params !==
|
|
15
|
-
throw (0, relayer_sdk_1.pluginError)(
|
|
16
|
-
code:
|
|
14
|
+
if (!params || typeof params !== 'object') {
|
|
15
|
+
throw (0, relayer_sdk_1.pluginError)('Invalid request: params must be an object', {
|
|
16
|
+
code: 'INVALID_PARAMS',
|
|
17
17
|
status: constants_1.HTTP_STATUS.BAD_REQUEST,
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
// Disallow any management-shaped keys leaking into here; management is handled earlier
|
|
21
21
|
const keys = Object.keys(params);
|
|
22
22
|
// Mode: XDR
|
|
23
|
-
if (
|
|
24
|
-
if (typeof params.xdr !==
|
|
25
|
-
throw (0, relayer_sdk_1.pluginError)(
|
|
26
|
-
code:
|
|
23
|
+
if ('xdr' in params) {
|
|
24
|
+
if (typeof params.xdr !== 'string' || params.xdr.trim() === '') {
|
|
25
|
+
throw (0, relayer_sdk_1.pluginError)('`xdr` must be a non-empty base64 string', {
|
|
26
|
+
code: 'INVALID_PARAMS',
|
|
27
27
|
status: constants_1.HTTP_STATUS.BAD_REQUEST,
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
// Strict: cannot include func/auth when using xdr
|
|
31
|
-
const unknown = keys.filter((k) => ![
|
|
31
|
+
const unknown = keys.filter((k) => !['xdr'].includes(k));
|
|
32
32
|
if (unknown.length > 0) {
|
|
33
|
-
throw (0, relayer_sdk_1.pluginError)(
|
|
34
|
-
code:
|
|
33
|
+
throw (0, relayer_sdk_1.pluginError)('`xdr` request must not include other parameters', {
|
|
34
|
+
code: 'INVALID_PARAMS',
|
|
35
35
|
status: constants_1.HTTP_STATUS.BAD_REQUEST,
|
|
36
36
|
details: { unknown },
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
-
return { type:
|
|
39
|
+
return { type: 'xdr', xdr: params.xdr.trim() };
|
|
40
40
|
}
|
|
41
41
|
// Mode: func+auth
|
|
42
|
-
if (
|
|
42
|
+
if ('func' in params || 'auth' in params) {
|
|
43
43
|
if (!params.func || !params.auth) {
|
|
44
|
-
throw (0, relayer_sdk_1.pluginError)(
|
|
45
|
-
code:
|
|
44
|
+
throw (0, relayer_sdk_1.pluginError)('`func` and `auth` are both required when omitting `xdr`', {
|
|
45
|
+
code: 'INVALID_PARAMS',
|
|
46
46
|
status: constants_1.HTTP_STATUS.BAD_REQUEST,
|
|
47
47
|
});
|
|
48
48
|
}
|
|
@@ -50,15 +50,15 @@ function validateAndParseRequest(params) {
|
|
|
50
50
|
let func;
|
|
51
51
|
let auth = [];
|
|
52
52
|
try {
|
|
53
|
-
func = stellar_sdk_1.xdr.HostFunction.fromXDR(params.func,
|
|
53
|
+
func = stellar_sdk_1.xdr.HostFunction.fromXDR(params.func, 'base64');
|
|
54
54
|
if (!Array.isArray(params.auth)) {
|
|
55
|
-
throw new Error(
|
|
55
|
+
throw new Error('auth must be an array of base64 strings');
|
|
56
56
|
}
|
|
57
|
-
auth = params.auth.map((a) => stellar_sdk_1.xdr.SorobanAuthorizationEntry.fromXDR(a,
|
|
57
|
+
auth = params.auth.map((a) => stellar_sdk_1.xdr.SorobanAuthorizationEntry.fromXDR(a, 'base64'));
|
|
58
58
|
}
|
|
59
59
|
catch (e) {
|
|
60
|
-
throw (0, relayer_sdk_1.pluginError)(
|
|
61
|
-
code:
|
|
60
|
+
throw (0, relayer_sdk_1.pluginError)('Invalid `func` or `auth` encoding', {
|
|
61
|
+
code: 'INVALID_PARAMS',
|
|
62
62
|
status: constants_1.HTTP_STATUS.BAD_REQUEST,
|
|
63
63
|
details: { message: e instanceof Error ? e.message : String(e) },
|
|
64
64
|
});
|
|
@@ -66,19 +66,18 @@ function validateAndParseRequest(params) {
|
|
|
66
66
|
// Reject SourceAccount credentials: incompatible with relayer-managed channel source
|
|
67
67
|
for (const entry of auth) {
|
|
68
68
|
const credType = entry.credentials().switch();
|
|
69
|
-
if (credType ===
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
code: "INVALID_PARAMS",
|
|
69
|
+
if (credType === stellar_sdk_1.xdr.SorobanCredentialsType.sorobanCredentialsSourceAccount()) {
|
|
70
|
+
throw (0, relayer_sdk_1.pluginError)('Detached address credentials required: source-account credentials are incompatible with relayer-managed channel accounts', {
|
|
71
|
+
code: 'INVALID_PARAMS',
|
|
73
72
|
status: constants_1.HTTP_STATUS.BAD_REQUEST,
|
|
74
|
-
details: { reason:
|
|
73
|
+
details: { reason: 'source-account credentials not allowed' },
|
|
75
74
|
});
|
|
76
75
|
}
|
|
77
76
|
}
|
|
78
|
-
return { type:
|
|
77
|
+
return { type: 'func-auth', func, auth };
|
|
79
78
|
}
|
|
80
|
-
throw (0, relayer_sdk_1.pluginError)(
|
|
81
|
-
code:
|
|
79
|
+
throw (0, relayer_sdk_1.pluginError)('Must pass either `xdr` or `func` and `auth`', {
|
|
80
|
+
code: 'INVALID_PARAMS',
|
|
82
81
|
status: constants_1.HTTP_STATUS.BAD_REQUEST,
|
|
83
82
|
});
|
|
84
83
|
}
|