@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.
Files changed (50) hide show
  1. package/README.md +79 -43
  2. package/dist/client/channels-client.d.ts +1 -1
  3. package/dist/client/channels-client.d.ts.map +1 -1
  4. package/dist/client/channels-client.js +20 -21
  5. package/dist/client/errors.d.ts +1 -1
  6. package/dist/client/errors.js +12 -9
  7. package/dist/client/index.d.ts +3 -3
  8. package/dist/client/index.d.ts.map +1 -1
  9. package/dist/client/types.d.ts +1 -1
  10. package/dist/index.d.ts +2 -2
  11. package/dist/plugin/build.d.ts +1 -1
  12. package/dist/plugin/build.d.ts.map +1 -1
  13. package/dist/plugin/build.js +11 -17
  14. package/dist/plugin/config.d.ts +4 -2
  15. package/dist/plugin/config.d.ts.map +1 -1
  16. package/dist/plugin/config.js +43 -13
  17. package/dist/plugin/constants.d.ts +1 -2
  18. package/dist/plugin/constants.d.ts.map +1 -1
  19. package/dist/plugin/constants.js +2 -3
  20. package/dist/plugin/fee-tracking.d.ts +2 -2
  21. package/dist/plugin/fee-tracking.d.ts.map +1 -1
  22. package/dist/plugin/fee-tracking.js +4 -9
  23. package/dist/plugin/fee.d.ts +16 -5
  24. package/dist/plugin/fee.d.ts.map +1 -1
  25. package/dist/plugin/fee.js +52 -14
  26. package/dist/plugin/handler.d.ts +10 -1
  27. package/dist/plugin/handler.d.ts.map +1 -1
  28. package/dist/plugin/handler.js +87 -52
  29. package/dist/plugin/index.d.ts +1 -1
  30. package/dist/plugin/management.d.ts +1 -1
  31. package/dist/plugin/management.d.ts.map +1 -1
  32. package/dist/plugin/management.js +53 -79
  33. package/dist/plugin/pool.d.ts +8 -3
  34. package/dist/plugin/pool.d.ts.map +1 -1
  35. package/dist/plugin/pool.js +45 -17
  36. package/dist/plugin/simulation.d.ts +4 -2
  37. package/dist/plugin/simulation.d.ts.map +1 -1
  38. package/dist/plugin/simulation.js +41 -33
  39. package/dist/plugin/submit.d.ts +7 -5
  40. package/dist/plugin/submit.d.ts.map +1 -1
  41. package/dist/plugin/submit.js +23 -13
  42. package/dist/plugin/tx.d.ts +1 -1
  43. package/dist/plugin/tx.d.ts.map +1 -1
  44. package/dist/plugin/tx.js +6 -8
  45. package/dist/plugin/types.d.ts +4 -4
  46. package/dist/plugin/types.d.ts.map +1 -1
  47. package/dist/plugin/validation.d.ts +1 -1
  48. package/dist/plugin/validation.d.ts.map +1 -1
  49. package/dist/plugin/validation.js +26 -27
  50. package/package.json +1 -1
@@ -3,6 +3,6 @@
3
3
  *
4
4
  * Transaction validation helpers for the XDR submit-only path.
5
5
  */
6
- import { Transaction } from "@stellar/stellar-sdk";
6
+ import { Transaction } from '@stellar/stellar-sdk';
7
7
  export declare function validateExistingTransactionForSubmitOnly(tx: Transaction): Transaction;
8
8
  //# sourceMappingURL=tx.d.ts.map
@@ -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,CACtD,EAAE,EAAE,WAAW,GACd,WAAW,CA6Cb"}
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)("Input must be a regular transaction envelope (fee-bump not allowed)", {
19
- code: "INVALID_ENVELOPE_TYPE",
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)("Transaction fee must be equal to the resource fee", {
29
- code: "FEE_MISMATCH",
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: "TIMEBOUNDS_TOO_FAR",
38
+ code: 'TIMEBOUNDS_TOO_FAR',
41
39
  status: constants_1.HTTP_STATUS.BAD_REQUEST,
42
40
  });
43
41
  }
@@ -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 "@stellar/stellar-sdk";
11
+ import type { xdr } from '@stellar/stellar-sdk';
12
12
  export type ChannelAccountsRequest = {
13
- type: "xdr";
13
+ type: 'xdr';
14
14
  xdr: string;
15
15
  } | {
16
- type: "func-auth";
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: "listChannelAccounts" | "setChannelAccounts";
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;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC;IACvB,IAAI,EAAE,GAAG,CAAC,yBAAyB,EAAE,CAAC;CACvC,CAAC;AAEN;;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,EAA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AAM,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 "./types";
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,CAyF3E"}
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 !== "object") {
15
- throw (0, relayer_sdk_1.pluginError)("Invalid request: params must be an object", {
16
- code: "INVALID_PARAMS",
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 ("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",
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) => !["xdr"].includes(k));
31
+ const unknown = keys.filter((k) => !['xdr'].includes(k));
32
32
  if (unknown.length > 0) {
33
- throw (0, relayer_sdk_1.pluginError)("`xdr` request must not include other parameters", {
34
- code: "INVALID_PARAMS",
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: "xdr", xdr: params.xdr.trim() };
39
+ return { type: 'xdr', xdr: params.xdr.trim() };
40
40
  }
41
41
  // Mode: func+auth
42
- if ("func" in params || "auth" in params) {
42
+ if ('func' in params || 'auth' in params) {
43
43
  if (!params.func || !params.auth) {
44
- throw (0, relayer_sdk_1.pluginError)("`func` and `auth` are both required when omitting `xdr`", {
45
- code: "INVALID_PARAMS",
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, "base64");
53
+ func = stellar_sdk_1.xdr.HostFunction.fromXDR(params.func, 'base64');
54
54
  if (!Array.isArray(params.auth)) {
55
- throw new Error("auth must be an array of base64 strings");
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, "base64"));
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)("Invalid `func` or `auth` encoding", {
61
- code: "INVALID_PARAMS",
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
- stellar_sdk_1.xdr.SorobanCredentialsType.sorobanCredentialsSourceAccount()) {
71
- throw (0, relayer_sdk_1.pluginError)("Detached address credentials required: source-account credentials are incompatible with relayer-managed channel accounts", {
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: "source-account credentials not allowed" },
73
+ details: { reason: 'source-account credentials not allowed' },
75
74
  });
76
75
  }
77
76
  }
78
- return { type: "func-auth", func, auth };
77
+ return { type: 'func-auth', func, auth };
79
78
  }
80
- throw (0, relayer_sdk_1.pluginError)("Must pass either `xdr` or `func` and `auth`", {
81
- code: "INVALID_PARAMS",
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openzeppelin/relayer-plugin-channels",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "OpenZeppelin Relayer Plugin for Stellar Channel Accounts",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",