@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.
Files changed (92) hide show
  1. package/LICENSE +661 -21
  2. package/README.md +239 -60
  3. package/dist/client/channels-client.d.ts +142 -0
  4. package/dist/client/channels-client.d.ts.map +1 -0
  5. package/dist/client/channels-client.js +245 -0
  6. package/dist/client/errors.d.ts +47 -0
  7. package/dist/client/errors.d.ts.map +1 -0
  8. package/dist/client/errors.js +61 -0
  9. package/dist/client/index.d.ts +10 -0
  10. package/dist/client/index.d.ts.map +1 -0
  11. package/dist/client/index.js +16 -0
  12. package/dist/client/types.d.ts +119 -0
  13. package/dist/client/types.d.ts.map +1 -0
  14. package/dist/client/types.js +2 -0
  15. package/dist/index.d.ts +4 -4
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +20 -109
  18. package/dist/plugin/build.d.ts.map +1 -0
  19. package/dist/plugin/config.d.ts.map +1 -0
  20. package/dist/plugin/constants.d.ts.map +1 -0
  21. package/dist/plugin/fee.d.ts.map +1 -0
  22. package/dist/plugin/handler.d.ts +12 -0
  23. package/dist/plugin/handler.d.ts.map +1 -0
  24. package/dist/plugin/handler.js +117 -0
  25. package/dist/plugin/index.d.ts +7 -0
  26. package/dist/plugin/index.d.ts.map +1 -0
  27. package/dist/plugin/index.js +10 -0
  28. package/dist/plugin/management.d.ts.map +1 -0
  29. package/dist/plugin/pool.d.ts.map +1 -0
  30. package/dist/plugin/simulation.d.ts.map +1 -0
  31. package/dist/plugin/submit.d.ts.map +1 -0
  32. package/dist/plugin/tx.d.ts.map +1 -0
  33. package/dist/plugin/types.d.ts.map +1 -0
  34. package/dist/plugin/validation.d.ts.map +1 -0
  35. package/package.json +3 -2
  36. package/dist/build.d.ts.map +0 -1
  37. package/dist/config.d.ts.map +0 -1
  38. package/dist/constants.d.ts.map +0 -1
  39. package/dist/fee.d.ts.map +0 -1
  40. package/dist/management.d.ts.map +0 -1
  41. package/dist/pool.d.ts.map +0 -1
  42. package/dist/simulation.d.ts.map +0 -1
  43. package/dist/submit.d.ts.map +0 -1
  44. package/dist/test/config.test.d.ts +0 -2
  45. package/dist/test/config.test.d.ts.map +0 -1
  46. package/dist/test/config.test.js +0 -43
  47. package/dist/test/fee.test.d.ts +0 -2
  48. package/dist/test/fee.test.d.ts.map +0 -1
  49. package/dist/test/fee.test.js +0 -34
  50. package/dist/test/helpers/fakeKV.d.ts +0 -17
  51. package/dist/test/helpers/fakeKV.d.ts.map +0 -1
  52. package/dist/test/helpers/fakeKV.js +0 -60
  53. package/dist/test/management.test.d.ts +0 -2
  54. package/dist/test/management.test.d.ts.map +0 -1
  55. package/dist/test/management.test.js +0 -66
  56. package/dist/test/pool.busy.test.d.ts +0 -2
  57. package/dist/test/pool.busy.test.d.ts.map +0 -1
  58. package/dist/test/pool.busy.test.js +0 -23
  59. package/dist/test/pool.test.d.ts +0 -2
  60. package/dist/test/pool.test.d.ts.map +0 -1
  61. package/dist/test/pool.test.js +0 -29
  62. package/dist/test/tx.test.d.ts +0 -2
  63. package/dist/test/tx.test.d.ts.map +0 -1
  64. package/dist/test/tx.test.js +0 -29
  65. package/dist/test/validation.test.d.ts +0 -2
  66. package/dist/test/validation.test.d.ts.map +0 -1
  67. package/dist/test/validation.test.js +0 -31
  68. package/dist/tx.d.ts.map +0 -1
  69. package/dist/types.d.ts.map +0 -1
  70. package/dist/validation.d.ts.map +0 -1
  71. /package/dist/{build.d.ts → plugin/build.d.ts} +0 -0
  72. /package/dist/{build.js → plugin/build.js} +0 -0
  73. /package/dist/{config.d.ts → plugin/config.d.ts} +0 -0
  74. /package/dist/{config.js → plugin/config.js} +0 -0
  75. /package/dist/{constants.d.ts → plugin/constants.d.ts} +0 -0
  76. /package/dist/{constants.js → plugin/constants.js} +0 -0
  77. /package/dist/{fee.d.ts → plugin/fee.d.ts} +0 -0
  78. /package/dist/{fee.js → plugin/fee.js} +0 -0
  79. /package/dist/{management.d.ts → plugin/management.d.ts} +0 -0
  80. /package/dist/{management.js → plugin/management.js} +0 -0
  81. /package/dist/{pool.d.ts → plugin/pool.d.ts} +0 -0
  82. /package/dist/{pool.js → plugin/pool.js} +0 -0
  83. /package/dist/{simulation.d.ts → plugin/simulation.d.ts} +0 -0
  84. /package/dist/{simulation.js → plugin/simulation.js} +0 -0
  85. /package/dist/{submit.d.ts → plugin/submit.d.ts} +0 -0
  86. /package/dist/{submit.js → plugin/submit.js} +0 -0
  87. /package/dist/{tx.d.ts → plugin/tx.d.ts} +0 -0
  88. /package/dist/{tx.js → plugin/tx.js} +0 -0
  89. /package/dist/{types.d.ts → plugin/types.d.ts} +0 -0
  90. /package/dist/{types.js → plugin/types.js} +0 -0
  91. /package/dist/{validation.d.ts → plugin/validation.d.ts} +0 -0
  92. /package/dist/{validation.js → plugin/validation.js} +0 -0
package/dist/index.js CHANGED
@@ -2,114 +2,25 @@
2
2
  /**
3
3
  * index.ts
4
4
  *
5
- * Main entry point for the channel accounts plugin.
6
- * Orchestrates the transaction processing pipeline using channel accounts with fee bumping.
5
+ * Main entry point for the @openzeppelin/relayer-plugin-channels package
6
+ * Re-exports both the client (for external use) and the plugin handler
7
7
  */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.handler = handler;
10
- const relayer_sdk_1 = require("@openzeppelin/relayer-sdk");
11
- const pool_1 = require("./pool");
12
- const config_1 = require("./config");
13
- const validation_1 = require("./validation");
14
- const management_1 = require("./management");
15
- const submit_1 = require("./submit");
16
- const constants_1 = require("./constants");
17
- const stellar_sdk_1 = require("@stellar/stellar-sdk");
18
- const simulation_1 = require("./simulation");
19
- const fee_1 = require("./fee");
20
- const tx_1 = require("./tx");
21
- async function handleXdrSubmit(xdrStr, fundRelayer, network, networkPassphrase, api) {
22
- const tx = new stellar_sdk_1.Transaction(xdrStr, networkPassphrase);
23
- const validated = (0, tx_1.validateExistingTransactionForSubmitOnly)(tx);
24
- const maxFee = (0, fee_1.calculateMaxFee)(validated);
25
- return (0, submit_1.submitWithFeeBumpAndWait)(fundRelayer, validated.toXDR(), network, maxFee, api);
26
- }
27
- async function handleFuncAuthSubmit(func, auth, api, pool, fundRelayer, fundAddress, network, networkPassphrase, rpc) {
28
- let poolLock;
29
- try {
30
- poolLock = await pool.acquire();
31
- const channelRelayer = api.useRelayer(poolLock.relayerId);
32
- const channelInfo = await channelRelayer.getRelayer();
33
- console.log(`[channels] Acquired channel: ${poolLock.relayerId}`);
34
- if (!channelInfo || !channelInfo.address) {
35
- throw (0, relayer_sdk_1.pluginError)("Channel relayer not found", {
36
- code: "RELAYER_UNAVAILABLE",
37
- status: constants_1.HTTP_STATUS.BAD_GATEWAY,
38
- details: { relayerId: poolLock.relayerId },
39
- });
40
- }
41
- const channelStatus = await channelRelayer.getRelayerStatus();
42
- if (channelStatus.network_type !== "stellar") {
43
- throw (0, relayer_sdk_1.pluginError)("Channel relayer network type must be stellar", {
44
- code: "UNSUPPORTED_NETWORK",
45
- status: constants_1.HTTP_STATUS.BAD_REQUEST,
46
- details: {
47
- network_type: channelStatus.network_type,
48
- relayerId: poolLock.relayerId,
49
- },
50
- });
51
- }
52
- const built = await (0, simulation_1.simulateAndBuildWithChannel)(func, auth, { address: channelInfo.address, sequence: channelStatus.sequence_number }, fundAddress, rpc, networkPassphrase);
53
- const signedTx = await (0, submit_1.signWithChannelAndFund)(built, channelRelayer, fundRelayer, channelInfo.address, fundAddress, networkPassphrase);
54
- const maxFee = (0, fee_1.calculateMaxFee)(signedTx);
55
- return await (0, submit_1.submitWithFeeBumpAndWait)(fundRelayer, signedTx.toXDR(), network, maxFee, api);
56
- }
57
- finally {
58
- if (poolLock) {
59
- await pool.release(poolLock);
60
- }
61
- }
62
- }
63
- async function channelAccounts(context) {
64
- const { api, kv, params } = context;
65
- // Management branch: handle and return immediately
66
- if ((0, management_1.isManagementRequest)(params)) {
67
- return await (0, management_1.handleManagement)(context);
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
68
13
  }
69
- // Load config and initialize per-request dependencies
70
- const config = (0, config_1.loadConfig)();
71
- const pool = new pool_1.ChannelPool(config.network, kv);
72
- const networkPassphrase = (0, config_1.getNetworkPassphrase)(config.network);
73
- const rpc = new stellar_sdk_1.SorobanRpc.Server(config.rpcUrl);
74
- try {
75
- // 1. Validate and parse request (xdr OR func+auth)
76
- const request = (0, validation_1.validateAndParseRequest)(params);
77
- console.debug(`[channels] Request type: ${request.type}, auth entries: ${request.type === "func-auth" ? request.auth.length : "N/A"}`);
78
- // 2. Get fund relayer
79
- const fundRelayer = api.useRelayer(config.fundRelayerId);
80
- const fundInfo = await fundRelayer.getRelayer();
81
- if (!fundInfo || !fundInfo.address) {
82
- throw (0, relayer_sdk_1.pluginError)("Fund relayer not found", {
83
- code: "RELAYER_UNAVAILABLE",
84
- status: constants_1.HTTP_STATUS.BAD_GATEWAY,
85
- details: { relayerId: config.fundRelayerId },
86
- });
87
- }
88
- const fundStatus = await fundRelayer.getRelayerStatus();
89
- if (fundStatus.network_type !== "stellar") {
90
- throw (0, relayer_sdk_1.pluginError)("Fund relayer network type must be stellar", {
91
- code: "UNSUPPORTED_NETWORK",
92
- status: constants_1.HTTP_STATUS.BAD_REQUEST,
93
- details: {
94
- network_type: fundStatus.network_type,
95
- relayerId: config.fundRelayerId,
96
- },
97
- });
98
- }
99
- // 3. Branch by request type
100
- if (request.type === "xdr") {
101
- console.log(`[channels] Flow: XDR submit-only`);
102
- return await handleXdrSubmit(request.xdr, fundRelayer, config.network, networkPassphrase, api);
103
- }
104
- console.log(`[channels] Flow: func+auth with channel account`);
105
- return await handleFuncAuthSubmit(request.func, request.auth, api, pool, fundRelayer, fundInfo.address, config.network, networkPassphrase, rpc);
106
- }
107
- finally {
108
- // Nothing to cleanup here; func-auth path releases locks internally
109
- }
110
- }
111
- // Error-catching wrapper and main export
112
- async function handler(context) {
113
- const result = await channelAccounts(context);
114
- return result;
115
- }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ // Export client for external consumers
24
+ __exportStar(require("./client"), exports);
25
+ // Export plugin handler for the OpenZeppelin Relayer
26
+ __exportStar(require("./plugin"), exports);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/plugin/build.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAe,MAAM,sBAAsB,CAAC;AAIhE,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,aAAa,GAAG,WAAW,CA6GrE"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/plugin/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,SAAS,GAAG,SAAS,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC;CAChB;AAcD;;GAEG;AACH,wBAAgB,UAAU,IAAI,qBAAqB,CAiBlD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,CAE3E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAY1C;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAQlC;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,GAAG,SAAS,CAKnD"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/plugin/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,eAAO,MAAM,WAAW;;;;;;;;;CASd,CAAC;AAGX,eAAO,MAAM,MAAM;;;;;CAKT,CAAC;AAGX,eAAO,MAAM,IAAI;;;;;CAOP,CAAC;AAGX,eAAO,MAAM,IAAI;;CAEP,CAAC;AAGX,eAAO,MAAM,UAAU;;;;;CAKb,CAAC;AAGX,eAAO,MAAM,OAAO;;;CAGV,CAAC;AAEX,eAAO,MAAM,GAAG;;;;CAIN,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fee.d.ts","sourceRoot":"","sources":["../../src/plugin/fee.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAO,MAAM,sBAAsB,CAAC;AAIxD,wBAAgB,eAAe,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CA2BhE"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * handler.ts
3
+ *
4
+ * Main handler for the channel accounts plugin.
5
+ * Orchestrates the transaction processing pipeline using channel accounts with fee bumping.
6
+ */
7
+ import { PluginContext } from "@openzeppelin/relayer-sdk";
8
+ /**
9
+ * Main plugin handler exported for OpenZeppelin Relayer
10
+ */
11
+ export declare function handler(context: PluginContext): Promise<any>;
12
+ //# sourceMappingURL=handler.d.ts.map
@@ -0,0 +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;AAgLvE;;GAEG;AACH,wBAAsB,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,CAGlE"}
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ /**
3
+ * handler.ts
4
+ *
5
+ * Main handler for the channel accounts plugin.
6
+ * Orchestrates the transaction processing pipeline using channel accounts with fee bumping.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.handler = handler;
10
+ const relayer_sdk_1 = require("@openzeppelin/relayer-sdk");
11
+ const pool_1 = require("./pool");
12
+ const config_1 = require("./config");
13
+ const validation_1 = require("./validation");
14
+ const management_1 = require("./management");
15
+ const submit_1 = require("./submit");
16
+ const constants_1 = require("./constants");
17
+ const stellar_sdk_1 = require("@stellar/stellar-sdk");
18
+ const simulation_1 = require("./simulation");
19
+ const fee_1 = require("./fee");
20
+ const tx_1 = require("./tx");
21
+ async function handleXdrSubmit(xdrStr, fundRelayer, network, networkPassphrase, api) {
22
+ const tx = new stellar_sdk_1.Transaction(xdrStr, networkPassphrase);
23
+ const validated = (0, tx_1.validateExistingTransactionForSubmitOnly)(tx);
24
+ const maxFee = (0, fee_1.calculateMaxFee)(validated);
25
+ return (0, submit_1.submitWithFeeBumpAndWait)(fundRelayer, validated.toXDR(), network, maxFee, api);
26
+ }
27
+ async function handleFuncAuthSubmit(func, auth, api, pool, fundRelayer, fundAddress, network, networkPassphrase, rpc) {
28
+ let poolLock;
29
+ try {
30
+ poolLock = await pool.acquire();
31
+ const channelRelayer = api.useRelayer(poolLock.relayerId);
32
+ const channelInfo = await channelRelayer.getRelayer();
33
+ console.log(`[channels] Acquired channel: ${poolLock.relayerId}`);
34
+ if (!channelInfo || !channelInfo.address) {
35
+ throw (0, relayer_sdk_1.pluginError)("Channel relayer not found", {
36
+ code: "RELAYER_UNAVAILABLE",
37
+ status: constants_1.HTTP_STATUS.BAD_GATEWAY,
38
+ details: { relayerId: poolLock.relayerId },
39
+ });
40
+ }
41
+ const channelStatus = await channelRelayer.getRelayerStatus();
42
+ if (channelStatus.network_type !== "stellar") {
43
+ throw (0, relayer_sdk_1.pluginError)("Channel relayer network type must be stellar", {
44
+ code: "UNSUPPORTED_NETWORK",
45
+ status: constants_1.HTTP_STATUS.BAD_REQUEST,
46
+ details: {
47
+ network_type: channelStatus.network_type,
48
+ relayerId: poolLock.relayerId,
49
+ },
50
+ });
51
+ }
52
+ const built = await (0, simulation_1.simulateAndBuildWithChannel)(func, auth, { address: channelInfo.address, sequence: channelStatus.sequence_number }, fundAddress, rpc, networkPassphrase);
53
+ const signedTx = await (0, submit_1.signWithChannelAndFund)(built, channelRelayer, fundRelayer, channelInfo.address, fundAddress, networkPassphrase);
54
+ const maxFee = (0, fee_1.calculateMaxFee)(signedTx);
55
+ return await (0, submit_1.submitWithFeeBumpAndWait)(fundRelayer, signedTx.toXDR(), network, maxFee, api);
56
+ }
57
+ finally {
58
+ if (poolLock) {
59
+ await pool.release(poolLock);
60
+ }
61
+ }
62
+ }
63
+ async function channelAccounts(context) {
64
+ const { api, kv, params } = context;
65
+ // Management branch: handle and return immediately
66
+ if ((0, management_1.isManagementRequest)(params)) {
67
+ return await (0, management_1.handleManagement)(context);
68
+ }
69
+ // Load config and initialize per-request dependencies
70
+ const config = (0, config_1.loadConfig)();
71
+ const pool = new pool_1.ChannelPool(config.network, kv);
72
+ const networkPassphrase = (0, config_1.getNetworkPassphrase)(config.network);
73
+ const rpc = new stellar_sdk_1.SorobanRpc.Server(config.rpcUrl);
74
+ try {
75
+ // 1. Validate and parse request (xdr OR func+auth)
76
+ const request = (0, validation_1.validateAndParseRequest)(params);
77
+ console.debug(`[channels] Request type: ${request.type}, auth entries: ${request.type === "func-auth" ? request.auth.length : "N/A"}`);
78
+ // 2. Get fund relayer
79
+ const fundRelayer = api.useRelayer(config.fundRelayerId);
80
+ const fundInfo = await fundRelayer.getRelayer();
81
+ if (!fundInfo || !fundInfo.address) {
82
+ throw (0, relayer_sdk_1.pluginError)("Fund relayer not found", {
83
+ code: "RELAYER_UNAVAILABLE",
84
+ status: constants_1.HTTP_STATUS.BAD_GATEWAY,
85
+ details: { relayerId: config.fundRelayerId },
86
+ });
87
+ }
88
+ const fundStatus = await fundRelayer.getRelayerStatus();
89
+ if (fundStatus.network_type !== "stellar") {
90
+ throw (0, relayer_sdk_1.pluginError)("Fund relayer network type must be stellar", {
91
+ code: "UNSUPPORTED_NETWORK",
92
+ status: constants_1.HTTP_STATUS.BAD_REQUEST,
93
+ details: {
94
+ network_type: fundStatus.network_type,
95
+ relayerId: config.fundRelayerId,
96
+ },
97
+ });
98
+ }
99
+ // 3. Branch by request type
100
+ if (request.type === "xdr") {
101
+ console.log(`[channels] Flow: XDR submit-only`);
102
+ return await handleXdrSubmit(request.xdr, fundRelayer, config.network, networkPassphrase, api);
103
+ }
104
+ console.log(`[channels] Flow: func+auth with channel account`);
105
+ return await handleFuncAuthSubmit(request.func, request.auth, api, pool, fundRelayer, fundInfo.address, config.network, networkPassphrase, rpc);
106
+ }
107
+ finally {
108
+ // Nothing to cleanup here; func-auth path releases locks internally
109
+ }
110
+ }
111
+ /**
112
+ * Main plugin handler exported for OpenZeppelin Relayer
113
+ */
114
+ async function handler(context) {
115
+ const result = await channelAccounts(context);
116
+ return result;
117
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Plugin module exports
3
+ *
4
+ * Exports the main handler function for the Channels plugin
5
+ */
6
+ export { handler } from "./handler";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ /**
3
+ * Plugin module exports
4
+ *
5
+ * Exports the main handler function for the Channels plugin
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.handler = void 0;
9
+ var handler_1 = require("./handler");
10
+ Object.defineProperty(exports, "handler", { enumerable: true, get: function () { return handler_1.handler; } });
@@ -0,0 +1 @@
1
+ {"version":3,"file":"management.d.ts","sourceRoot":"","sources":["../../src/plugin/management.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAiB,MAAM,2BAA2B,CAAC;AAe9E,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAOxD;AAED,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,CAiC3E"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../src/plugin/pool.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAe,MAAM,2BAA2B,CAAC;AAKvE,MAAM,MAAM,QAAQ,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAI5D,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAwB;IAChD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IACvC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAS;IAC3C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAgB;gBAEvB,OAAO,EAAE,SAAS,GAAG,SAAS,EAAE,EAAE,EAAE,aAAa;IAQ7D,4CAA4C;IACtC,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC;YAuBpB,eAAe;YASf,iBAAiB;IAwB/B,oCAAoC;IAC9B,OAAO,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAY5C,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,OAAO;YAID,mBAAmB;CAWlC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simulation.d.ts","sourceRoot":"","sources":["../../src/plugin/simulation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAGL,UAAU,EACV,WAAW,EAEX,GAAG,EACJ,MAAM,sBAAsB,CAAC;AAI9B,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAsB,2BAA2B,CAC/C,IAAI,EAAE,GAAG,CAAC,YAAY,EACtB,IAAI,EAAE,GAAG,CAAC,yBAAyB,EAAE,GAAG,SAAS,EACjD,OAAO,EAAE,cAAc,EACvB,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,UAAU,CAAC,MAAM,EACtB,iBAAiB,EAAE,MAAM,GACxB,OAAO,CAAC,WAAW,CAAC,CA8CtB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"submit.d.ts","sourceRoot":"","sources":["../../src/plugin/submit.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAEL,OAAO,EAGP,SAAS,EACV,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAElD;;;;;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,CA2BtB;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,GACb,OAAO,CAAC,uBAAuB,CAAC,CAwDlC"}
@@ -0,0 +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"}
@@ -0,0 +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,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"}
@@ -0,0 +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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openzeppelin/relayer-plugin-channels",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "OpenZeppelin Relayer Plugin for Stellar Channel Accounts",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -21,7 +21,8 @@
21
21
  "dependencies": {
22
22
  "@openzeppelin/relayer-sdk": "^1.6.0",
23
23
  "@stellar/stellar-sdk": "^11.2.0",
24
- "@actions/exec": "^1.1.1"
24
+ "@actions/exec": "^1.1.1",
25
+ "axios": "^1.6.0"
25
26
  },
26
27
  "devDependencies": {
27
28
  "@changesets/cli": "^2.27.7",
@@ -1 +0,0 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAe,MAAM,sBAAsB,CAAC;AAIhE,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,aAAa,GAAG,WAAW,CA6GrE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,SAAS,GAAG,SAAS,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC;CAChB;AAcD;;GAEG;AACH,wBAAgB,UAAU,IAAI,qBAAqB,CAiBlD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,CAE3E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAY1C;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAQlC;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,GAAG,SAAS,CAKnD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,eAAO,MAAM,WAAW;;;;;;;;;CASd,CAAC;AAGX,eAAO,MAAM,MAAM;;;;;CAKT,CAAC;AAGX,eAAO,MAAM,IAAI;;;;;CAOP,CAAC;AAGX,eAAO,MAAM,IAAI;;CAEP,CAAC;AAGX,eAAO,MAAM,UAAU;;;;;CAKb,CAAC;AAGX,eAAO,MAAM,OAAO;;;CAGV,CAAC;AAEX,eAAO,MAAM,GAAG;;;;CAIN,CAAC"}
package/dist/fee.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"fee.d.ts","sourceRoot":"","sources":["../src/fee.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAO,MAAM,sBAAsB,CAAC;AAIxD,wBAAgB,eAAe,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CA2BhE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"management.d.ts","sourceRoot":"","sources":["../src/management.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAiB,MAAM,2BAA2B,CAAC;AAe9E,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAOxD;AAED,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,CAiC3E"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../src/pool.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAe,MAAM,2BAA2B,CAAC;AAKvE,MAAM,MAAM,QAAQ,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAI5D,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAwB;IAChD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IACvC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAS;IAC3C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAgB;gBAEvB,OAAO,EAAE,SAAS,GAAG,SAAS,EAAE,EAAE,EAAE,aAAa;IAQ7D,4CAA4C;IACtC,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC;YAuBpB,eAAe;YASf,iBAAiB;IAwB/B,oCAAoC;IAC9B,OAAO,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAY5C,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,OAAO;YAID,mBAAmB;CAWlC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"simulation.d.ts","sourceRoot":"","sources":["../src/simulation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAGL,UAAU,EACV,WAAW,EAEX,GAAG,EACJ,MAAM,sBAAsB,CAAC;AAI9B,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAsB,2BAA2B,CAC/C,IAAI,EAAE,GAAG,CAAC,YAAY,EACtB,IAAI,EAAE,GAAG,CAAC,yBAAyB,EAAE,GAAG,SAAS,EACjD,OAAO,EAAE,cAAc,EACvB,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,UAAU,CAAC,MAAM,EACtB,iBAAiB,EAAE,MAAM,GACxB,OAAO,CAAC,WAAW,CAAC,CA8CtB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"submit.d.ts","sourceRoot":"","sources":["../src/submit.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAEL,OAAO,EAGP,SAAS,EACV,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAElD;;;;;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,CA2BtB;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,GACb,OAAO,CAAC,uBAAuB,CAAC,CAwDlC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=config.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.test.d.ts","sourceRoot":"","sources":["../../src/test/config.test.ts"],"names":[],"mappings":""}
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const vitest_1 = require("vitest");
4
- const stellar_sdk_1 = require("@stellar/stellar-sdk");
5
- const config_1 = require("../config");
6
- const env = process.env;
7
- (0, vitest_1.describe)("config", () => {
8
- (0, vitest_1.beforeEach)(() => {
9
- process.env = { ...env };
10
- });
11
- (0, vitest_1.afterEach)(() => {
12
- process.env = env;
13
- });
14
- (0, vitest_1.test)("loadConfig reads required env", () => {
15
- process.env.STELLAR_NETWORK = "testnet";
16
- process.env.SOROBAN_RPC_URL = "http://localhost:9999";
17
- process.env.FUND_RELAYER_ID = "fund-relayer";
18
- const cfg = (0, config_1.loadConfig)();
19
- (0, vitest_1.expect)(cfg.network).toBe("testnet");
20
- (0, vitest_1.expect)(cfg.rpcUrl).toBe("http://localhost:9999");
21
- (0, vitest_1.expect)(cfg.fundRelayerId).toBe("fund-relayer");
22
- });
23
- (0, vitest_1.test)("network passphrase", () => {
24
- (0, vitest_1.expect)((0, config_1.getNetworkPassphrase)("testnet")).toBe(stellar_sdk_1.Networks.TESTNET);
25
- (0, vitest_1.expect)((0, config_1.getNetworkPassphrase)("mainnet")).toBe(stellar_sdk_1.Networks.PUBLIC);
26
- });
27
- (0, vitest_1.test)("lock ttl bounds", () => {
28
- delete process.env.LOCK_TTL_SECONDS;
29
- (0, vitest_1.expect)((0, config_1.getLockTtlSeconds)()).toBe(30);
30
- process.env.LOCK_TTL_SECONDS = "5";
31
- (0, vitest_1.expect)((0, config_1.getLockTtlSeconds)()).toBe(30);
32
- process.env.LOCK_TTL_SECONDS = "10";
33
- (0, vitest_1.expect)((0, config_1.getLockTtlSeconds)()).toBe(10);
34
- process.env.LOCK_TTL_SECONDS = "29";
35
- (0, vitest_1.expect)((0, config_1.getLockTtlSeconds)()).toBe(29);
36
- });
37
- (0, vitest_1.test)("max fee env", () => {
38
- delete process.env.MAX_FEE;
39
- (0, vitest_1.expect)(typeof (0, config_1.getMaxFee)()).toBe("number");
40
- process.env.MAX_FEE = "12345";
41
- (0, vitest_1.expect)((0, config_1.getMaxFee)()).toBe(12345);
42
- });
43
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=fee.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fee.test.d.ts","sourceRoot":"","sources":["../../src/test/fee.test.ts"],"names":[],"mappings":""}
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const vitest_1 = require("vitest");
4
- const fee_1 = require("../fee");
5
- const stellar_sdk_1 = require("@stellar/stellar-sdk");
6
- (0, vitest_1.describe)("fee", () => {
7
- const passphrase = stellar_sdk_1.Networks.TESTNET;
8
- function buildSimpleTx() {
9
- const acc = new stellar_sdk_1.Account("GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF", "1");
10
- return new stellar_sdk_1.TransactionBuilder(acc, {
11
- fee: "100",
12
- networkPassphrase: passphrase,
13
- })
14
- .setTimeout(30)
15
- .build();
16
- }
17
- (0, vitest_1.test)("non-soroban uses offset + base", () => {
18
- const orig = Math.random;
19
- Math.random = () => 0; // pick min base fee
20
- const tx = buildSimpleTx();
21
- const fee = (0, fee_1.calculateMaxFee)(tx);
22
- (0, vitest_1.expect)(typeof fee).toBe("number");
23
- (0, vitest_1.expect)(fee).toBeGreaterThan(0);
24
- Math.random = orig;
25
- });
26
- (0, vitest_1.test)("clamps to MAX_FEE when set", () => {
27
- const tx = buildSimpleTx();
28
- const old = process.env.MAX_FEE;
29
- process.env.MAX_FEE = "1000";
30
- const fee = (0, fee_1.calculateMaxFee)(tx);
31
- (0, vitest_1.expect)(fee).toBeLessThanOrEqual(1000);
32
- process.env.MAX_FEE = old;
33
- });
34
- });
@@ -1,17 +0,0 @@
1
- import type { PluginKVStore } from "@openzeppelin/relayer-sdk";
2
- export declare class FakeKV implements PluginKVStore {
3
- private store;
4
- get<T = any>(key: string): Promise<T | null>;
5
- set(key: string, value: any, opts?: {
6
- ttlSec?: number;
7
- }): Promise<boolean>;
8
- del(key: string): Promise<boolean>;
9
- exists(key: string): Promise<boolean>;
10
- withLock<T>(key: string, fn: () => Promise<T>, opts?: {
11
- ttlSec?: number;
12
- onBusy?: "throw" | "skip";
13
- }): Promise<T | null>;
14
- listKeys(_pattern?: string): Promise<string[]>;
15
- clear(): Promise<number>;
16
- }
17
- //# sourceMappingURL=fakeKV.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fakeKV.d.ts","sourceRoot":"","sources":["../../../src/test/helpers/fakeKV.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAI/D,qBAAa,MAAO,YAAW,aAAa;IAC1C,OAAO,CAAC,KAAK,CAA4B;IAEnC,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAW5C,GAAG,CACP,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,GAAG,EACV,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GACzB,OAAO,CAAC,OAAO,CAAC;IASb,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIlC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKrC,QAAQ,CAAC,CAAC,EACd,GAAG,EAAE,MAAM,EACX,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;KAAE,GACpD,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAgBd,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAI9C,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;CAK/B"}
@@ -1,60 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FakeKV = void 0;
4
- class FakeKV {
5
- constructor() {
6
- this.store = new Map();
7
- }
8
- async get(key) {
9
- const now = Date.now();
10
- const e = this.store.get(key);
11
- if (!e)
12
- return null;
13
- if (e.expiresAt && e.expiresAt <= now) {
14
- this.store.delete(key);
15
- return null;
16
- }
17
- return e.value;
18
- }
19
- async set(key, value, opts) {
20
- const entry = { value };
21
- if (opts?.ttlSec && opts.ttlSec > 0) {
22
- entry.expiresAt = Date.now() + opts.ttlSec * 1000;
23
- }
24
- this.store.set(key, entry);
25
- return true;
26
- }
27
- async del(key) {
28
- return this.store.delete(key);
29
- }
30
- async exists(key) {
31
- const v = await this.get(key);
32
- return v !== null && v !== undefined;
33
- }
34
- async withLock(key, fn, opts) {
35
- // Simple, non-reentrant lock for testing; not robust
36
- if (await this.exists(key)) {
37
- if (opts?.onBusy === "skip")
38
- return null;
39
- throw new Error("lock busy");
40
- }
41
- // Respect requested TTL to better emulate production behavior
42
- const ttl = opts?.ttlSec && opts.ttlSec > 0 ? opts.ttlSec : 1;
43
- await this.set(key, { token: "lock" }, { ttlSec: ttl });
44
- try {
45
- return await fn();
46
- }
47
- finally {
48
- await this.del(key);
49
- }
50
- }
51
- async listKeys(_pattern) {
52
- return Array.from(this.store.keys());
53
- }
54
- async clear() {
55
- const n = this.store.size;
56
- this.store.clear();
57
- return n;
58
- }
59
- }
60
- exports.FakeKV = FakeKV;
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=management.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"management.test.d.ts","sourceRoot":"","sources":["../../src/test/management.test.ts"],"names":[],"mappings":""}