@openzeppelin/relayer-plugin-channels 0.3.1 → 0.4.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 CHANGED
@@ -210,7 +210,6 @@ Set the required environment variables for the plugin:
210
210
  ```bash
211
211
  # Required environment variables
212
212
  export STELLAR_NETWORK="testnet" # or "mainnet"
213
- export SOROBAN_RPC_URL="https://soroban-testnet.stellar.org"
214
213
  export FUND_RELAYER_ID="channels-fund"
215
214
  export PLUGIN_ADMIN_SECRET="your-secret-here" # Required for management API
216
215
 
@@ -1 +1 @@
1
- {"version":3,"file":"channels-client.d.ts","sourceRoot":"","sources":["../../src/client/channels-client.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,uBAAuB,EACvB,2BAA2B,EAC3B,2BAA2B,EAC3B,0BAA0B,EAE3B,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAgB;IAC7C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAa;IACzC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAS;gBAEvB,MAAM,EAAE,oBAAoB;IA6BxC;;;;;;;;;;;;;OAaG;IACG,iBAAiB,CACrB,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,2BAA2B,CAAC;IAIvC;;;;;;;;;;;;;;;OAeG;IACG,wBAAwB,CAC5B,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,2BAA2B,CAAC;IAIvC;;;;;;;;;;;;OAYG;IACG,mBAAmB,IAAI,OAAO,CAAC,2BAA2B,CAAC;IASjE;;;;;;;;;;;;;;;OAeG;IACG,kBAAkB,CACtB,UAAU,EAAE,MAAM,EAAE,GACnB,OAAO,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e;IAoBvB;;;;;;OAMG;IACH,OAAO,CAAC,gBAAgB;IAgBxB;;;;;;OAMG;IACH,OAAO,CAAC,aAAa;IAUrB;;;;;;;;OAQG;YACW,IAAI;IA6BlB;;;;;;OAMG;YACW,QAAQ;CAYvB"}
@@ -221,7 +221,10 @@ class ChannelsClient {
221
221
  const response = this.validateResponse(responseBody);
222
222
  // Handle execution errors
223
223
  if (!response.success) {
224
- throw new errors_1.PluginExecutionError(response.error || "Plugin execution failed", response.data);
224
+ const errorDetails = response.metadata
225
+ ? { ...response.data, metadata: response.metadata }
226
+ : response.data;
227
+ throw new errors_1.PluginExecutionError(response.error || "Plugin execution failed", errorDetails);
225
228
  }
226
229
  // Return data with metadata if present
227
230
  return this.mergeMetadata(response.data, response.metadata);
@@ -110,6 +110,10 @@ export interface PluginResponseError {
110
110
  success: false;
111
111
  error: string;
112
112
  data?: any;
113
+ metadata?: {
114
+ logs?: LogEntry[];
115
+ traces?: any[];
116
+ };
113
117
  }
114
118
  /**
115
119
  * Discriminated union type for all plugin responses
@@ -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,gEAAgE;IAChE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB,uCAAuC;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,WAAW,CAAC,EAAE,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CAAC,EAAE,GAAG,EAAE,CAAC;KAChB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,KAAK,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,QAAQ,CAAC,EAAE;QACT,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC;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"}
@@ -6,7 +6,6 @@
6
6
  export interface ChannelAccountsConfig {
7
7
  fundRelayerId: string;
8
8
  network: "testnet" | "mainnet";
9
- rpcUrl: string;
10
9
  }
11
10
  /**
12
11
  * Load configuration from environment variables
@@ -20,10 +19,6 @@ export declare function getNetworkPassphrase(network: "testnet" | "mainnet"): st
20
19
  * Get the per-channel lock TTL in seconds (default 30)
21
20
  */
22
21
  export declare function getLockTtlSeconds(): number;
23
- /**
24
- * Get the max fee for fee bump transactions
25
- */
26
- export declare function getMaxFee(): number;
27
22
  /**
28
23
  * Get the admin secret for management API
29
24
  */
@@ -1 +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"}
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;CAChC;AAcD;;GAEG;AACH,wBAAgB,UAAU,IAAI,qBAAqB,CAelD;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,cAAc,IAAI,MAAM,GAAG,SAAS,CAKnD"}
@@ -8,7 +8,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.loadConfig = loadConfig;
9
9
  exports.getNetworkPassphrase = getNetworkPassphrase;
10
10
  exports.getLockTtlSeconds = getLockTtlSeconds;
11
- exports.getMaxFee = getMaxFee;
12
11
  exports.getAdminSecret = getAdminSecret;
13
12
  const stellar_sdk_1 = require("@stellar/stellar-sdk");
14
13
  const relayer_sdk_1 = require("@openzeppelin/relayer-sdk");
@@ -36,11 +35,9 @@ function loadConfig() {
36
35
  });
37
36
  }
38
37
  const fundRelayerId = requireEnv("FUND_RELAYER_ID");
39
- const rpcUrl = requireEnv("SOROBAN_RPC_URL");
40
38
  return {
41
39
  fundRelayerId,
42
40
  network: networkRaw,
43
- rpcUrl,
44
41
  };
45
42
  }
46
43
  /**
@@ -64,19 +61,6 @@ function getLockTtlSeconds() {
64
61
  }
65
62
  return Math.floor(n);
66
63
  }
67
- /**
68
- * Get the max fee for fee bump transactions
69
- */
70
- function getMaxFee() {
71
- const raw = process.env.MAX_FEE;
72
- if (!raw)
73
- return constants_1.CONFIG.DEFAULT_MAX_FEE;
74
- const n = Number(raw);
75
- if (!Number.isFinite(n) || n <= 0) {
76
- return constants_1.CONFIG.DEFAULT_MAX_FEE;
77
- }
78
- return Math.floor(n);
79
- }
80
64
  /**
81
65
  * Get the admin secret for management API
82
66
  */
@@ -17,7 +17,6 @@ export declare const CONFIG: {
17
17
  readonly DEFAULT_LOCK_TTL_SECONDS: 30;
18
18
  readonly MIN_LOCK_TTL_SECONDS: 10;
19
19
  readonly MAX_LOCK_TTL_SECONDS: 30;
20
- readonly DEFAULT_MAX_FEE: 1000000;
21
20
  };
22
21
  export declare const POOL: {
23
22
  readonly MUTEX_TTL_SECONDS: 1;
@@ -41,6 +40,6 @@ export declare const POLLING: {
41
40
  export declare const FEE: {
42
41
  readonly MIN_BASE_FEE: 205;
43
42
  readonly MAX_BASE_FEE: 605;
44
- readonly RESOURCE_FEE_OFFSET: 60000;
43
+ readonly NON_SOROBAN_FEE: 100000;
45
44
  };
46
45
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +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"}
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;;;;CAIT,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;;;;CAKN,CAAC"}
@@ -22,7 +22,6 @@ exports.CONFIG = {
22
22
  DEFAULT_LOCK_TTL_SECONDS: 30,
23
23
  MIN_LOCK_TTL_SECONDS: 10,
24
24
  MAX_LOCK_TTL_SECONDS: 30,
25
- DEFAULT_MAX_FEE: 1000000,
26
25
  };
27
26
  // Pool Constants
28
27
  exports.POOL = {
@@ -52,5 +51,6 @@ exports.POLLING = {
52
51
  exports.FEE = {
53
52
  MIN_BASE_FEE: 205,
54
53
  MAX_BASE_FEE: 605,
55
- RESOURCE_FEE_OFFSET: 60000,
54
+ // For non-Soroban txs: 100,000 stroops (0.01 XLM) per Stellar best practice
55
+ NON_SOROBAN_FEE: 100000,
56
56
  };
@@ -2,9 +2,8 @@
2
2
  * fee.ts
3
3
  *
4
4
  * Dynamic fee calculation for fee bump submissions.
5
- * - For Soroban transactions, use resourceFee + random inclusion fee
6
- * - For non-Soroban, add a fixed offset for safety
7
- * - Optionally clamp to env MAX_FEE via config helper
5
+ * - For Soroban transactions: use resourceFee + random inclusion fee
6
+ * - For non-Soroban: use NON_SOROBAN_FEE
8
7
  */
9
8
  import { Transaction } from "@stellar/stellar-sdk";
10
9
  export declare function calculateMaxFee(transaction: Transaction): number;
@@ -1 +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"}
1
+ {"version":3,"file":"fee.d.ts","sourceRoot":"","sources":["../../src/plugin/fee.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAO,MAAM,sBAAsB,CAAC;AAGxD,wBAAgB,eAAe,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAsBhE"}
@@ -3,15 +3,13 @@
3
3
  * fee.ts
4
4
  *
5
5
  * Dynamic fee calculation for fee bump submissions.
6
- * - For Soroban transactions, use resourceFee + random inclusion fee
7
- * - For non-Soroban, add a fixed offset for safety
8
- * - Optionally clamp to env MAX_FEE via config helper
6
+ * - For Soroban transactions: use resourceFee + random inclusion fee
7
+ * - For non-Soroban: use NON_SOROBAN_FEE
9
8
  */
10
9
  Object.defineProperty(exports, "__esModule", { value: true });
11
10
  exports.calculateMaxFee = calculateMaxFee;
12
11
  const stellar_sdk_1 = require("@stellar/stellar-sdk");
13
12
  const constants_1 = require("./constants");
14
- const config_1 = require("./config");
15
13
  function calculateMaxFee(transaction) {
16
14
  const envelope = transaction.toEnvelope();
17
15
  let resourceFee = 0n;
@@ -22,17 +20,11 @@ function calculateMaxFee(transaction) {
22
20
  }
23
21
  }
24
22
  const baseInclusion = getRandomInt(constants_1.FEE.MIN_BASE_FEE, constants_1.FEE.MAX_BASE_FEE);
25
- let dynamic = resourceFee > 0n
23
+ const fee = resourceFee > 0n
26
24
  ? resourceFee + BigInt(baseInclusion)
27
- : BigInt(constants_1.FEE.RESOURCE_FEE_OFFSET + baseInclusion);
28
- // Optional cap from env
29
- const cap = (0, config_1.getMaxFee)();
30
- if (typeof cap === "number" && Number.isFinite(cap) && cap > 0) {
31
- if (dynamic > BigInt(cap))
32
- dynamic = BigInt(cap);
33
- }
34
- console.debug(`[channels] Calculated max_fee: ${Number(dynamic)} stroops (resourceFee: ${resourceFee}, baseInclusion: ${baseInclusion})`);
35
- return Number(dynamic);
25
+ : BigInt(constants_1.FEE.NON_SOROBAN_FEE + baseInclusion);
26
+ console.debug(`[channels] Calculated max_fee: ${Number(fee)} stroops (resourceFee: ${resourceFee}, baseInclusion: ${baseInclusion})`);
27
+ return Number(fee);
36
28
  }
37
29
  function getRandomInt(min, max) {
38
30
  const mn = Math.ceil(min);
@@ -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;AAgLvE;;GAEG;AACH,wBAAsB,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,CAGlE"}
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;AA6KvE;;GAEG;AACH,wBAAsB,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,CAGlE"}
@@ -24,7 +24,7 @@ async function handleXdrSubmit(xdrStr, fundRelayer, network, networkPassphrase,
24
24
  const maxFee = (0, fee_1.calculateMaxFee)(validated);
25
25
  return (0, submit_1.submitWithFeeBumpAndWait)(fundRelayer, validated.toXDR(), network, maxFee, api);
26
26
  }
27
- async function handleFuncAuthSubmit(func, auth, api, pool, fundRelayer, fundAddress, network, networkPassphrase, rpc) {
27
+ async function handleFuncAuthSubmit(func, auth, api, pool, fundRelayer, fundAddress, network, networkPassphrase) {
28
28
  let poolLock;
29
29
  try {
30
30
  poolLock = await pool.acquire();
@@ -49,7 +49,7 @@ async function handleFuncAuthSubmit(func, auth, api, pool, fundRelayer, fundAddr
49
49
  },
50
50
  });
51
51
  }
52
- const built = await (0, simulation_1.simulateAndBuildWithChannel)(func, auth, { address: channelInfo.address, sequence: channelStatus.sequence_number }, fundAddress, rpc, networkPassphrase);
52
+ const built = await (0, simulation_1.simulateAndBuildWithChannel)(func, auth, { address: channelInfo.address, sequence: channelStatus.sequence_number }, fundAddress, fundRelayer, networkPassphrase);
53
53
  const signedTx = await (0, submit_1.signWithChannelAndFund)(built, channelRelayer, fundRelayer, channelInfo.address, fundAddress, networkPassphrase);
54
54
  const maxFee = (0, fee_1.calculateMaxFee)(signedTx);
55
55
  return await (0, submit_1.submitWithFeeBumpAndWait)(fundRelayer, signedTx.toXDR(), network, maxFee, api);
@@ -70,7 +70,6 @@ async function channelAccounts(context) {
70
70
  const config = (0, config_1.loadConfig)();
71
71
  const pool = new pool_1.ChannelPool(config.network, kv);
72
72
  const networkPassphrase = (0, config_1.getNetworkPassphrase)(config.network);
73
- const rpc = new stellar_sdk_1.SorobanRpc.Server(config.rpcUrl);
74
73
  try {
75
74
  // 1. Validate and parse request (xdr OR func+auth)
76
75
  const request = (0, validation_1.validateAndParseRequest)(params);
@@ -102,7 +101,7 @@ async function channelAccounts(context) {
102
101
  return await handleXdrSubmit(request.xdr, fundRelayer, config.network, networkPassphrase, api);
103
102
  }
104
103
  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);
104
+ return await handleFuncAuthSubmit(request.func, request.auth, api, pool, fundRelayer, fundInfo.address, config.network, networkPassphrase);
106
105
  }
107
106
  finally {
108
107
  // Nothing to cleanup here; func-auth path releases locks internally
@@ -5,10 +5,11 @@
5
5
  * and the fund account as the operation source. Returns an unsigned inner
6
6
  * transaction with sorobanData and correct fee set to the resource fee.
7
7
  */
8
- import { SorobanRpc, Transaction, xdr } from "@stellar/stellar-sdk";
8
+ import { Transaction, xdr } from "@stellar/stellar-sdk";
9
+ import { Relayer } from "@openzeppelin/relayer-sdk";
9
10
  export interface ChannelAccount {
10
11
  address: string;
11
12
  sequence: string;
12
13
  }
13
- export declare function simulateAndBuildWithChannel(func: xdr.HostFunction, auth: xdr.SorobanAuthorizationEntry[] | undefined, channel: ChannelAccount, _fundAddress: string, rpc: SorobanRpc.Server, networkPassphrase: string): Promise<Transaction>;
14
+ export declare function simulateAndBuildWithChannel(func: xdr.HostFunction, auth: xdr.SorobanAuthorizationEntry[] | undefined, channel: ChannelAccount, _fundAddress: string, relayer: Relayer, networkPassphrase: string): Promise<Transaction>;
14
15
  //# sourceMappingURL=simulation.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"simulation.d.ts","sourceRoot":"","sources":["../../src/plugin/simulation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAIL,WAAW,EAEX,GAAG,EACJ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAGL,OAAO,EACR,MAAM,2BAA2B,CAAC;AAGnC,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,OAAO,EAAE,OAAO,EAChB,iBAAiB,EAAE,MAAM,GACxB,OAAO,CAAC,WAAW,CAAC,CA8FtB"}
@@ -11,7 +11,7 @@ exports.simulateAndBuildWithChannel = simulateAndBuildWithChannel;
11
11
  const stellar_sdk_1 = require("@stellar/stellar-sdk");
12
12
  const relayer_sdk_1 = require("@openzeppelin/relayer-sdk");
13
13
  const constants_1 = require("./constants");
14
- async function simulateAndBuildWithChannel(func, auth, channel, _fundAddress, rpc, networkPassphrase) {
14
+ async function simulateAndBuildWithChannel(func, auth, channel, _fundAddress, relayer, networkPassphrase) {
15
15
  const now = Math.floor(Date.now() / 1000);
16
16
  console.debug(`[channels] Building tx: channel=${channel.address}, seq=${channel.sequence}, auth_count=${auth?.length ?? 0}`);
17
17
  // Build inner transaction (source = channel, op source = fund)
@@ -29,9 +29,49 @@ async function simulateAndBuildWithChannel(func, auth, channel, _fundAddress, rp
29
29
  // No explicit source: default to transaction source (channel account)
30
30
  }))
31
31
  .build();
32
- // Prepare transaction (attaches sorobanData/resources, preserves provided auth)
32
+ let rpcResponse;
33
33
  try {
34
- const prepared = await rpc.prepareTransaction(transaction);
34
+ rpcResponse = await relayer.rpc({
35
+ jsonrpc: "2.0",
36
+ id: Math.floor(Math.random() * 1e8).toString(),
37
+ method: "simulateTransaction",
38
+ params: {
39
+ transaction: transaction.toXDR(),
40
+ },
41
+ });
42
+ }
43
+ catch (err) {
44
+ throw (0, relayer_sdk_1.pluginError)("Simulation network request failed", {
45
+ code: "SIMULATION_NETWORK_ERROR",
46
+ status: constants_1.HTTP_STATUS.BAD_GATEWAY,
47
+ details: {
48
+ message: err instanceof Error ? err.message : String(err),
49
+ },
50
+ });
51
+ }
52
+ if (rpcResponse.error) {
53
+ const { code, message, description, data } = rpcResponse.error;
54
+ throw (0, relayer_sdk_1.pluginError)("Simulation RPC execution failed", {
55
+ code: "SIMULATION_RPC_FAILURE",
56
+ status: constants_1.HTTP_STATUS.BAD_REQUEST,
57
+ details: {
58
+ rpcCode: code,
59
+ message,
60
+ description: description || data,
61
+ },
62
+ });
63
+ }
64
+ try {
65
+ // Format simulation result for SDK's assembleTransaction
66
+ const simResult = {
67
+ id: String(rpcResponse.id ?? "1"),
68
+ ...rpcResponse.result,
69
+ };
70
+ console.debug(`[channels] Simulation result:`, JSON.stringify(simResult, null, 2));
71
+ // Use SDK's assembleTransaction to apply simulation results
72
+ const prepared = stellar_sdk_1.rpc
73
+ .assembleTransaction(transaction, simResult)
74
+ .build();
35
75
  const resourceFee = prepared
36
76
  .toEnvelope()
37
77
  .v1()
@@ -42,11 +82,13 @@ async function simulateAndBuildWithChannel(func, auth, channel, _fundAddress, rp
42
82
  console.debug(`[channels] Simulation complete: resourceFee=${resourceFee}`);
43
83
  return prepared;
44
84
  }
45
- catch (e) {
46
- throw (0, relayer_sdk_1.pluginError)("Simulation failed", {
85
+ catch (err) {
86
+ throw (0, relayer_sdk_1.pluginError)("Simulation result processing failed", {
47
87
  code: "SIMULATION_FAILED",
48
- status: constants_1.HTTP_STATUS.BAD_REQUEST,
49
- details: { error: e instanceof Error ? e.message : String(e) },
88
+ status: constants_1.HTTP_STATUS.INTERNAL_SERVER_ERROR,
89
+ details: {
90
+ message: err instanceof Error ? err.message : String(err),
91
+ },
50
92
  });
51
93
  }
52
94
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openzeppelin/relayer-plugin-channels",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "OpenZeppelin Relayer Plugin for Stellar Channel Accounts",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -20,7 +20,7 @@
20
20
  "license": "MIT",
21
21
  "dependencies": {
22
22
  "@openzeppelin/relayer-sdk": "^1.7.0",
23
- "@stellar/stellar-sdk": "^11.2.0",
23
+ "@stellar/stellar-sdk": "^14.3.3",
24
24
  "@actions/exec": "^1.1.1",
25
25
  "axios": "^1.6.0"
26
26
  },