@sovereign-sdk/web3 0.12.3 → 0.12.5

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/dist/index.js CHANGED
@@ -1,39 +1,10 @@
1
1
  "use strict";
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
- var __defProps = Object.defineProperties;
5
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
8
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
6
  var __getProtoOf = Object.getPrototypeOf;
10
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
11
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
- var __spreadValues = (a, b) => {
14
- for (var prop in b || (b = {}))
15
- if (__hasOwnProp.call(b, prop))
16
- __defNormalProp(a, prop, b[prop]);
17
- if (__getOwnPropSymbols)
18
- for (var prop of __getOwnPropSymbols(b)) {
19
- if (__propIsEnum.call(b, prop))
20
- __defNormalProp(a, prop, b[prop]);
21
- }
22
- return a;
23
- };
24
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
- var __objRest = (source, exclude) => {
26
- var target = {};
27
- for (var prop in source)
28
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
29
- target[prop] = source[prop];
30
- if (source != null && __getOwnPropSymbols)
31
- for (var prop of __getOwnPropSymbols(source)) {
32
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
33
- target[prop] = source[prop];
34
- }
35
- return target;
36
- };
37
8
  var __export = (target, all) => {
38
9
  for (var name in all)
39
10
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -55,26 +26,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
55
26
  mod
56
27
  ));
57
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
58
- var __async = (__this, __arguments, generator) => {
59
- return new Promise((resolve, reject) => {
60
- var fulfilled = (value) => {
61
- try {
62
- step(generator.next(value));
63
- } catch (e) {
64
- reject(e);
65
- }
66
- };
67
- var rejected = (value) => {
68
- try {
69
- step(generator.throw(value));
70
- } catch (e) {
71
- reject(e);
72
- }
73
- };
74
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
75
- step((generator = generator.apply(__this, __arguments)).next());
76
- });
77
- };
78
29
 
79
30
  // src/index.ts
80
31
  var src_exports = {};
@@ -147,7 +98,6 @@ function httpToWebSocket(url) {
147
98
  }
148
99
  var _subscriptions = {};
149
100
  function subscribe(url, callback) {
150
- var _a;
151
101
  const subscription = _subscriptions[url];
152
102
  if (!subscription) {
153
103
  const websocket = new import_partysocket.WebSocket(url, [], { WebSocket: import_isomorphic_ws.default });
@@ -157,9 +107,8 @@ function subscribe(url, callback) {
157
107
  callbacks: [callback]
158
108
  };
159
109
  websocket.addEventListener("message", (message) => {
160
- var _a2;
161
110
  const data = JSON.parse(message.data);
162
- const callbacks = (_a2 = _subscriptions[url]) == null ? void 0 : _a2.callbacks;
111
+ const callbacks = _subscriptions[url]?.callbacks;
163
112
  if (callbacks) {
164
113
  for (const cb of callbacks) {
165
114
  cb(data);
@@ -173,7 +122,7 @@ function subscribe(url, callback) {
173
122
  } else {
174
123
  subscription.callbacks.push(callback);
175
124
  }
176
- const callbackIndex = ((_a = _subscriptions[url]) == null ? void 0 : _a.callbacks.length) - 1;
125
+ const callbackIndex = _subscriptions[url]?.callbacks.length - 1;
177
126
  return {
178
127
  get url() {
179
128
  return url;
@@ -223,12 +172,10 @@ var Rollup = class {
223
172
  * @param publicKey - The public key to dedup.
224
173
  * TODO: How to add param for generation explicitly
225
174
  */
226
- dedup(publicKey) {
227
- return __async(this, null, function* () {
228
- const credentialId = (0, import_utils2.bytesToHex)(publicKey);
229
- const response = yield this.rollup.addresses.dedup(credentialId);
230
- return response;
231
- });
175
+ async dedup(publicKey) {
176
+ const credentialId = (0, import_utils2.bytesToHex)(publicKey);
177
+ const response = await this.rollup.addresses.dedup(credentialId);
178
+ return response;
232
179
  }
233
180
  /**
234
181
  * Submits a transaction to the rollup.
@@ -239,30 +186,29 @@ var Rollup = class {
239
186
  * @param transaction - The transaction to submit.
240
187
  * @param {SovereignClient.RequestOptions} options - The options for the request.
241
188
  */
242
- submitTransaction(transaction, options) {
243
- return __async(this, null, function* () {
244
- const serializer = yield this.serializer();
245
- const serializedTx = serializer.serializeTx(transaction);
246
- const _a = options || {}, { body: _, query: __, path } = _a, requestOptions = __objRest(_a, ["body", "query", "path"]);
247
- const txSubmissionEndpoint = path || this._config.txSubmissionEndpoint;
248
- return this.http.post(txSubmissionEndpoint, __spreadValues({
249
- body: { body: import_js_base64.Base64.fromUint8Array(serializedTx) }
250
- }, requestOptions)).catch((e) => __async(this, null, function* () {
251
- if (isVersionMismatchError(e)) {
252
- const oldVersion = (0, import_utils2.bytesToHex)(yield this.chainHash());
253
- const { schema, chain_hash: newVersion } = yield this.rollup.schema();
254
- this._chainHash = (0, import_utils2.hexToBytes)(newVersion);
255
- this._serializer = this._config.getSerializer(schema);
256
- if (`0x${oldVersion}` !== newVersion) {
257
- throw new VersionMismatchError(
258
- "Schema version mismatch when submitting transaction",
259
- newVersion,
260
- oldVersion
261
- );
262
- }
189
+ async submitTransaction(transaction, options) {
190
+ const serializer = await this.serializer();
191
+ const serializedTx = serializer.serializeTx(transaction);
192
+ const { body: _, query: __, path, ...requestOptions } = options || {};
193
+ const txSubmissionEndpoint = path || this._config.txSubmissionEndpoint;
194
+ return this.http.post(txSubmissionEndpoint, {
195
+ body: { body: import_js_base64.Base64.fromUint8Array(serializedTx) },
196
+ ...requestOptions
197
+ }).catch(async (e) => {
198
+ if (isVersionMismatchError(e)) {
199
+ const oldVersion = (0, import_utils2.bytesToHex)(await this.chainHash());
200
+ const { schema, chain_hash: newVersion } = await this.rollup.schema();
201
+ this._chainHash = (0, import_utils2.hexToBytes)(newVersion);
202
+ this._serializer = this._config.getSerializer(schema);
203
+ if (`0x${oldVersion}` !== newVersion) {
204
+ throw new VersionMismatchError(
205
+ "Schema version mismatch when submitting transaction",
206
+ newVersion,
207
+ oldVersion
208
+ );
263
209
  }
264
- throw e;
265
- }));
210
+ }
211
+ throw e;
266
212
  });
267
213
  }
268
214
  /**
@@ -274,12 +220,10 @@ var Rollup = class {
274
220
  * @param {SovereignClient.RequestOptions} options - The options for the request.
275
221
  * @param endpoint - Optional endpoint override. If not specified, uses the rollup's configured txSubmissionEndpoint.
276
222
  */
277
- signAndSubmitTransaction(_0, _1, _2) {
278
- return __async(this, arguments, function* (unsignedTx, { signer }, options) {
279
- const tx = yield this.signTransaction(unsignedTx, signer);
280
- const result = yield this.submitTransaction(tx, options);
281
- return { transaction: tx, response: result };
282
- });
223
+ async signAndSubmitTransaction(unsignedTx, { signer }, options) {
224
+ const tx = await this.signTransaction(unsignedTx, signer);
225
+ const result = await this.submitTransaction(tx, options);
226
+ return { transaction: tx, response: result };
283
227
  }
284
228
  /**
285
229
  * Performs a runtime call transaction.
@@ -289,22 +233,20 @@ var Rollup = class {
289
233
  * @param {CallParams<S>} params - The params for submitting a runtime call transaction.
290
234
  * @param {SovereignClient.RequestOptions} options - The options for the request.
291
235
  */
292
- call(_0, _1, _2) {
293
- return __async(this, arguments, function* (runtimeCall, { signer, overrides }, options) {
294
- const context = {
295
- runtimeCall,
296
- rollup: this,
297
- overrides: overrides != null ? overrides : {}
298
- };
299
- const unsignedTx = yield this._typeBuilder.unsignedTransaction(context);
300
- return this.signAndSubmitTransaction(
301
- unsignedTx,
302
- {
303
- signer
304
- },
305
- options
306
- );
307
- });
236
+ async call(runtimeCall, { signer, overrides }, options) {
237
+ const context = {
238
+ runtimeCall,
239
+ rollup: this,
240
+ overrides: overrides ?? {}
241
+ };
242
+ const unsignedTx = await this._typeBuilder.unsignedTransaction(context);
243
+ return this.signAndSubmitTransaction(
244
+ unsignedTx,
245
+ {
246
+ signer
247
+ },
248
+ options
249
+ );
308
250
  }
309
251
  /**
310
252
  * Prepares a runtime call by creating and signing a transaction without submitting it.
@@ -317,16 +259,14 @@ var Rollup = class {
317
259
  * @param params.overrides - Optional overrides for the unsigned transaction.
318
260
  * @returns A promise that resolves to the signed transaction.
319
261
  */
320
- prepareCall(_0, _1) {
321
- return __async(this, arguments, function* (runtimeCall, { signer, overrides }) {
322
- const context = {
323
- runtimeCall,
324
- rollup: this,
325
- overrides: overrides != null ? overrides : {}
326
- };
327
- const unsignedTx = yield this._typeBuilder.unsignedTransaction(context);
328
- return this.signTransaction(unsignedTx, signer);
329
- });
262
+ async prepareCall(runtimeCall, { signer, overrides }) {
263
+ const context = {
264
+ runtimeCall,
265
+ rollup: this,
266
+ overrides: overrides ?? {}
267
+ };
268
+ const unsignedTx = await this._typeBuilder.unsignedTransaction(context);
269
+ return this.signTransaction(unsignedTx, signer);
330
270
  }
331
271
  /**
332
272
  * Signs an unsigned transaction using the provided signer.
@@ -337,23 +277,21 @@ var Rollup = class {
337
277
  * @param signer - The signer to use for signing the transaction.
338
278
  * @returns A promise that resolves to the signed transaction.
339
279
  */
340
- signTransaction(unsignedTx, signer) {
341
- return __async(this, null, function* () {
342
- const serializer = yield this.serializer();
343
- const serializedUnsignedTx = serializer.serializeUnsignedTx(unsignedTx);
344
- const chainHash = yield this.chainHash();
345
- const signature = yield signer.sign(
346
- new Uint8Array([...serializedUnsignedTx, ...chainHash])
347
- );
348
- const publicKey = yield signer.publicKey();
349
- const context = {
350
- unsignedTx,
351
- sender: publicKey,
352
- signature,
353
- rollup: this
354
- };
355
- return this._typeBuilder.transaction(context);
356
- });
280
+ async signTransaction(unsignedTx, signer) {
281
+ const serializer = await this.serializer();
282
+ const serializedUnsignedTx = serializer.serializeUnsignedTx(unsignedTx);
283
+ const chainHash = await this.chainHash();
284
+ const signature = await signer.sign(
285
+ new Uint8Array([...serializedUnsignedTx, ...chainHash])
286
+ );
287
+ const publicKey = await signer.publicKey();
288
+ const context = {
289
+ unsignedTx,
290
+ sender: publicKey,
291
+ signature,
292
+ rollup: this
293
+ };
294
+ return this._typeBuilder.transaction(context);
357
295
  }
358
296
  /**
359
297
  * Create a subscription to events emitted over websockets by the rollup.
@@ -367,15 +305,13 @@ var Rollup = class {
367
305
  * @param timeout - Request timeout in milliseconds.
368
306
  * @returns `true` if the rollup is considered healthy otherwise `false`.
369
307
  */
370
- healthcheck(timeout = 5e3) {
371
- return __async(this, null, function* () {
372
- try {
373
- yield this.http.get("/healthcheck", { timeout, maxRetries: 1 });
374
- return true;
375
- } catch (e) {
376
- return !(e instanceof import_client.default.APIConnectionError);
377
- }
378
- });
308
+ async healthcheck(timeout = 5e3) {
309
+ try {
310
+ await this.http.get("/healthcheck", { timeout, maxRetries: 1 });
311
+ return true;
312
+ } catch (e) {
313
+ return !(e instanceof import_client.default.APIConnectionError);
314
+ }
379
315
  }
380
316
  /**
381
317
  * A ledger client that can be used to query the ledger.
@@ -407,13 +343,11 @@ var Rollup = class {
407
343
  * The serializer for the rollup.
408
344
  * Can be used to serialize transactions, runtime calls, etc.
409
345
  */
410
- serializer() {
411
- return __async(this, null, function* () {
412
- if (this._serializer) return this._serializer;
413
- const { schema } = yield this.rollup.schema();
414
- this._serializer = this._config.getSerializer(schema);
415
- return this._serializer;
416
- });
346
+ async serializer() {
347
+ if (this._serializer) return this._serializer;
348
+ const { schema } = await this.rollup.schema();
349
+ this._serializer = this._config.getSerializer(schema);
350
+ return this._serializer;
417
351
  }
418
352
  /**
419
353
  * The context for the rollup.
@@ -421,20 +355,17 @@ var Rollup = class {
421
355
  get context() {
422
356
  return this._config.context;
423
357
  }
424
- chainHash() {
425
- return __async(this, null, function* () {
426
- if (this._chainHash) return this._chainHash;
427
- const { chain_hash } = yield this.rollup.schema();
428
- this._chainHash = (0, import_utils2.hexToBytes)(chain_hash);
429
- return this._chainHash;
430
- });
358
+ async chainHash() {
359
+ if (this._chainHash) return this._chainHash;
360
+ const { chain_hash } = await this.rollup.schema();
361
+ this._chainHash = (0, import_utils2.hexToBytes)(chain_hash);
362
+ return this._chainHash;
431
363
  }
432
364
  };
433
365
  function isVersionMismatchError(e) {
434
- var _a, _b, _c;
435
366
  if (
436
367
  // biome-ignore lint/suspicious/noExplicitAny: yolo
437
- (_c = (_b = (_a = e.error) == null ? void 0 : _a.details) == null ? void 0 : _b.error) == null ? void 0 : _c.includes("Signature verification failed")
368
+ e.error?.details?.error?.includes("Signature verification failed")
438
369
  ) {
439
370
  return true;
440
371
  }
@@ -445,42 +376,42 @@ function isVersionMismatchError(e) {
445
376
  var import_client2 = __toESM(require("@sovereign-sdk/client"));
446
377
  var import_serializers = require("@sovereign-sdk/serializers");
447
378
  var import_utils3 = require("@sovereign-sdk/utils");
448
- var useOrFetchUniqueness = (_0) => __async(void 0, [_0], function* ({
379
+ var useOrFetchUniqueness = async ({
449
380
  overrides
450
- }) {
451
- if (overrides == null ? void 0 : overrides.uniqueness) {
381
+ }) => {
382
+ if (overrides?.uniqueness) {
452
383
  return overrides.uniqueness;
453
384
  }
454
385
  return { generation: Date.now() };
455
- });
386
+ };
456
387
  function standardTypeBuilder() {
457
388
  return {
458
- unsignedTransaction(context) {
459
- return __async(this, null, function* () {
460
- const { rollup, runtimeCall } = context;
461
- const _a2 = context.overrides, { uniqueness: _ } = _a2, overrides = __objRest(_a2, ["uniqueness"]);
462
- const uniqueness = yield useOrFetchUniqueness(context);
463
- const details = __spreadValues(__spreadValues({}, rollup.context.defaultTxDetails), overrides.details);
464
- return {
465
- runtime_call: runtimeCall,
466
- uniqueness,
467
- details
468
- };
469
- });
389
+ async unsignedTransaction(context) {
390
+ const { rollup, runtimeCall } = context;
391
+ const { uniqueness: _, ...overrides } = context.overrides;
392
+ const uniqueness = await useOrFetchUniqueness(context);
393
+ const details = {
394
+ ...rollup.context.defaultTxDetails,
395
+ ...overrides.details
396
+ };
397
+ return {
398
+ runtime_call: runtimeCall,
399
+ uniqueness,
400
+ details
401
+ };
470
402
  },
471
- transaction(_0) {
472
- return __async(this, arguments, function* ({
473
- sender,
474
- signature,
475
- unsignedTx
476
- }) {
477
- return {
478
- V0: __spreadValues({
479
- pub_key: (0, import_utils3.bytesToHex)(sender),
480
- signature: (0, import_utils3.bytesToHex)(signature)
481
- }, unsignedTx)
482
- };
483
- });
403
+ async transaction({
404
+ sender,
405
+ signature,
406
+ unsignedTx
407
+ }) {
408
+ return {
409
+ V0: {
410
+ pub_key: (0, import_utils3.bytesToHex)(sender),
411
+ signature: (0, import_utils3.bytesToHex)(signature),
412
+ ...unsignedTx
413
+ }
414
+ };
484
415
  }
485
416
  };
486
417
  }
@@ -492,13 +423,11 @@ var StandardRollup = class extends Rollup {
492
423
  *
493
424
  * @param runtimeMessage - The runtime message to call.
494
425
  */
495
- simulate(_0, _1) {
496
- return __async(this, arguments, function* (runtimeMessage, { signer }) {
497
- const publicKey = yield signer.publicKey();
498
- const sender = (0, import_utils3.bytesToHex)(publicKey);
499
- const call = runtimeMessage;
500
- return this.rollup.simulate({ sender, call });
501
- });
426
+ async simulate(runtimeMessage, { signer }) {
427
+ const publicKey = await signer.publicKey();
428
+ const sender = (0, import_utils3.bytesToHex)(publicKey);
429
+ const call = runtimeMessage;
430
+ return this.rollup.simulate({ sender, call });
502
431
  }
503
432
  };
504
433
  var DEFAULT_TX_DETAILS = {
@@ -506,36 +435,38 @@ var DEFAULT_TX_DETAILS = {
506
435
  max_fee: "100000000",
507
436
  gas_limit: null
508
437
  };
509
- function buildContext(client, context) {
510
- return __async(this, null, function* () {
511
- const defaultTxDetails = __spreadValues(__spreadValues({}, DEFAULT_TX_DETAILS), context == null ? void 0 : context.defaultTxDetails);
512
- if (!defaultTxDetails.chain_id) {
513
- const { chain_id } = yield client.rollup.constants();
514
- defaultTxDetails.chain_id = chain_id;
515
- }
516
- return {
517
- defaultTxDetails
518
- };
519
- });
438
+ async function buildContext(client, context) {
439
+ const defaultTxDetails = {
440
+ ...DEFAULT_TX_DETAILS,
441
+ ...context?.defaultTxDetails
442
+ };
443
+ if (!defaultTxDetails.chain_id) {
444
+ const { chain_id } = await client.rollup.constants();
445
+ defaultTxDetails.chain_id = chain_id;
446
+ }
447
+ return {
448
+ defaultTxDetails
449
+ };
520
450
  }
521
- function createStandardRollup(rollupConfig, typeBuilderOverrides) {
522
- return __async(this, null, function* () {
523
- var _a, _b, _c;
524
- const config = rollupConfig != null ? rollupConfig : {};
525
- const client = (_a = config.client) != null ? _a : new import_client2.default({ baseURL: config.url });
526
- const getSerializer = (_b = config.getSerializer) != null ? _b : (schema) => new import_serializers.JsSerializer(schema);
527
- const context = yield buildContext(client, config.context);
528
- const txSubmissionEndpoint = (_c = config.txSubmissionEndpoint) != null ? _c : "/sequencer/txs";
529
- return new StandardRollup(
530
- __spreadProps(__spreadValues({}, config), {
531
- client,
532
- getSerializer,
533
- context,
534
- txSubmissionEndpoint
535
- }),
536
- __spreadValues(__spreadValues({}, standardTypeBuilder()), typeBuilderOverrides)
537
- );
538
- });
451
+ async function createStandardRollup(rollupConfig, typeBuilderOverrides) {
452
+ const config = rollupConfig ?? {};
453
+ const client = config.client ?? new import_client2.default({ baseURL: config.url });
454
+ const getSerializer = config.getSerializer ?? ((schema) => new import_serializers.JsSerializer(schema));
455
+ const context = await buildContext(client, config.context);
456
+ const txSubmissionEndpoint = config.txSubmissionEndpoint ?? "/sequencer/txs";
457
+ return new StandardRollup(
458
+ {
459
+ ...config,
460
+ client,
461
+ getSerializer,
462
+ context,
463
+ txSubmissionEndpoint
464
+ },
465
+ {
466
+ ...standardTypeBuilder(),
467
+ ...typeBuilderOverrides
468
+ }
469
+ );
539
470
  }
540
471
 
541
472
  // src/rollup/solana-signable-rollup.ts
@@ -588,120 +519,104 @@ var SolanaSignableRollup = class {
588
519
  /**
589
520
  * Submits serialized data to the Solana endpoint.
590
521
  */
591
- submitSerializedMessage(serializedMessage) {
592
- return __async(this, null, function* () {
593
- return yield this.inner.http.post(
594
- this.solanaEndpoint,
595
- {
596
- body: import_js_base642.Base64.fromUint8Array(serializedMessage)
597
- }
598
- );
599
- });
522
+ async submitSerializedMessage(serializedMessage) {
523
+ return await this.inner.http.post(
524
+ this.solanaEndpoint,
525
+ {
526
+ body: import_js_base642.Base64.fromUint8Array(serializedMessage)
527
+ }
528
+ );
600
529
  }
601
530
  /**
602
531
  * Submits a Solana offchain message to the rollup.
603
532
  */
604
- submitSolanaMessage(solanaMessage) {
605
- return __async(this, null, function* () {
606
- const serializedMessage = this.serializeSolanaMessage(solanaMessage);
607
- return this.submitSerializedMessage(serializedMessage);
608
- });
533
+ async submitSolanaMessage(solanaMessage) {
534
+ const serializedMessage = this.serializeSolanaMessage(solanaMessage);
535
+ return this.submitSerializedMessage(serializedMessage);
609
536
  }
610
537
  /**
611
538
  * Submits a Solana spec-compliant message to the rollup.
612
539
  */
613
- submitSolanaSpecMessage(solanaMessage) {
614
- return __async(this, null, function* () {
615
- const serializedMessage = this.serializeSolanaSpecMessage(solanaMessage);
616
- return this.submitSerializedMessage(serializedMessage);
617
- });
540
+ async submitSolanaSpecMessage(solanaMessage) {
541
+ const serializedMessage = this.serializeSolanaSpecMessage(solanaMessage);
542
+ return this.submitSerializedMessage(serializedMessage);
618
543
  }
619
544
  /**
620
545
  * Helper to build an unsigned transaction using the standard type builder.
621
546
  */
622
- buildUnsignedTransaction(runtimeCall, overrides) {
623
- return __async(this, null, function* () {
624
- return this.typeBuilder.unsignedTransaction({
625
- runtimeCall,
626
- overrides: overrides != null ? overrides : {},
627
- rollup: this.inner
628
- });
547
+ async buildUnsignedTransaction(runtimeCall, overrides) {
548
+ return this.typeBuilder.unsignedTransaction({
549
+ runtimeCall,
550
+ overrides: overrides ?? {},
551
+ rollup: this.inner
629
552
  });
630
553
  }
631
554
  /**
632
555
  * Helper to build a transaction result object.
633
556
  */
634
- buildTransactionResult(response, unsignedTx, pubkey, signature) {
635
- return __async(this, null, function* () {
636
- const transaction = yield this.typeBuilder.transaction({
637
- unsignedTx,
638
- sender: pubkey,
639
- signature,
640
- rollup: this.inner
641
- });
642
- return { response, transaction };
557
+ async buildTransactionResult(response, unsignedTx, pubkey, signature) {
558
+ const transaction = await this.typeBuilder.transaction({
559
+ unsignedTx,
560
+ sender: pubkey,
561
+ signature,
562
+ rollup: this.inner
643
563
  });
564
+ return { response, transaction };
644
565
  }
645
566
  /**
646
567
  * Helper to create and serialize a SolanaOffchainUnsignedTransaction to JSON bytes.
647
568
  */
648
- createSolanaJsonBytes(unsignedTx) {
649
- return __async(this, null, function* () {
650
- const serializer = yield this.inner.serializer();
651
- const schema = serializer.schema;
652
- const chainName = schema.chain_name || "";
653
- const solanaUnsignedTx = {
654
- runtime_call: unsignedTx.runtime_call,
655
- uniqueness: unsignedTx.uniqueness,
656
- details: unsignedTx.details,
657
- chain_name: chainName
658
- };
659
- return new TextEncoder().encode(JSON.stringify(solanaUnsignedTx));
660
- });
569
+ async createSolanaJsonBytes(unsignedTx) {
570
+ const serializer = await this.inner.serializer();
571
+ const schema = serializer.schema;
572
+ const chainName = schema.chain_data.chain_name || "";
573
+ const solanaUnsignedTx = {
574
+ runtime_call: unsignedTx.runtime_call,
575
+ uniqueness: unsignedTx.uniqueness,
576
+ details: unsignedTx.details,
577
+ chain_name: chainName
578
+ };
579
+ return new TextEncoder().encode(JSON.stringify(solanaUnsignedTx));
661
580
  }
662
581
  /**
663
582
  * Signs an unsigned transaction using Solana offchain simple signing and submits it.
664
583
  * Returns the transaction result in the same format as standard rollup.
665
584
  */
666
- signWithSolanaSimpleAndSubmit(unsignedTx, signer) {
667
- return __async(this, null, function* () {
668
- const jsonBytes = yield this.createSolanaJsonBytes(unsignedTx);
669
- const pubkey = yield signer.publicKey();
670
- const chainHash = yield this.inner.chainHash();
671
- const signature = yield signer.sign(jsonBytes);
672
- const solanaMessage = {
673
- signed_message: jsonBytes,
674
- chain_hash: chainHash,
675
- pubkey,
676
- signature
677
- };
678
- const response = yield this.submitSolanaMessage(solanaMessage);
679
- return this.buildTransactionResult(response, unsignedTx, pubkey, signature);
680
- });
585
+ async signWithSolanaSimpleAndSubmit(unsignedTx, signer) {
586
+ const jsonBytes = await this.createSolanaJsonBytes(unsignedTx);
587
+ const pubkey = await signer.publicKey();
588
+ const chainHash = await this.inner.chainHash();
589
+ const signature = await signer.sign(jsonBytes);
590
+ const solanaMessage = {
591
+ signed_message: jsonBytes,
592
+ chain_hash: chainHash,
593
+ pubkey,
594
+ signature
595
+ };
596
+ const response = await this.submitSolanaMessage(solanaMessage);
597
+ return this.buildTransactionResult(response, unsignedTx, pubkey, signature);
681
598
  }
682
599
  /**
683
600
  * Signs an unsigned transaction using Solana spec-compliant signing and submits it.
684
601
  * Returns the transaction result in the same format as standard rollup.
685
602
  */
686
- signWithSolanaSpecAndSubmit(unsignedTx, signer) {
687
- return __async(this, null, function* () {
688
- const jsonBytes = yield this.createSolanaJsonBytes(unsignedTx);
689
- const pubkey = yield signer.publicKey();
690
- const chainHash = yield this.inner.chainHash();
691
- const preamble = createSolanaPreamble(pubkey, chainHash, jsonBytes.length);
692
- const signedMessageWithPreamble = new Uint8Array(
693
- preamble.length + jsonBytes.length
694
- );
695
- signedMessageWithPreamble.set(preamble, 0);
696
- signedMessageWithPreamble.set(jsonBytes, preamble.length);
697
- const signature = yield signer.sign(signedMessageWithPreamble);
698
- const solanaMessage = {
699
- signed_message_with_preamble: signedMessageWithPreamble,
700
- signature
701
- };
702
- const response = yield this.submitSolanaSpecMessage(solanaMessage);
703
- return this.buildTransactionResult(response, unsignedTx, pubkey, signature);
704
- });
603
+ async signWithSolanaSpecAndSubmit(unsignedTx, signer) {
604
+ const jsonBytes = await this.createSolanaJsonBytes(unsignedTx);
605
+ const pubkey = await signer.publicKey();
606
+ const chainHash = await this.inner.chainHash();
607
+ const preamble = createSolanaPreamble(pubkey, chainHash, jsonBytes.length);
608
+ const signedMessageWithPreamble = new Uint8Array(
609
+ preamble.length + jsonBytes.length
610
+ );
611
+ signedMessageWithPreamble.set(preamble, 0);
612
+ signedMessageWithPreamble.set(jsonBytes, preamble.length);
613
+ const signature = await signer.sign(signedMessageWithPreamble);
614
+ const solanaMessage = {
615
+ signed_message_with_preamble: signedMessageWithPreamble,
616
+ signature
617
+ };
618
+ const response = await this.submitSolanaSpecMessage(solanaMessage);
619
+ return this.buildTransactionResult(response, unsignedTx, pubkey, signature);
705
620
  }
706
621
  /**
707
622
  * Performs a runtime call transaction with the specified authenticator.
@@ -711,37 +626,35 @@ var SolanaSignableRollup = class {
711
626
  * @param options - Optional request options
712
627
  * @returns The transaction result including hash and transaction object
713
628
  */
714
- call(runtimeCall, params, options) {
715
- return __async(this, null, function* () {
716
- const authenticator = params.authenticator === "solanaAuto" ? this.getAutoAuthenticator(params.signer) : params.authenticator;
717
- switch (authenticator) {
718
- case "standard":
719
- return this.inner.call(
720
- runtimeCall,
721
- {
722
- signer: params.signer,
723
- overrides: params.overrides
724
- },
725
- options
726
- );
727
- case "solanaSimple": {
728
- const unsignedTx = yield this.buildUnsignedTransaction(
729
- runtimeCall,
730
- params.overrides
731
- );
732
- return this.signWithSolanaSimpleAndSubmit(unsignedTx, params.signer);
733
- }
734
- case "solana": {
735
- const unsignedTx = yield this.buildUnsignedTransaction(
736
- runtimeCall,
737
- params.overrides
738
- );
739
- return this.signWithSolanaSpecAndSubmit(unsignedTx, params.signer);
740
- }
741
- default:
742
- throw new Error(`Unsupported authenticator: ${authenticator}`);
629
+ async call(runtimeCall, params, options) {
630
+ const authenticator = params.authenticator === "solanaAuto" ? this.getAutoAuthenticator(params.signer) : params.authenticator;
631
+ switch (authenticator) {
632
+ case "standard":
633
+ return this.inner.call(
634
+ runtimeCall,
635
+ {
636
+ signer: params.signer,
637
+ overrides: params.overrides
638
+ },
639
+ options
640
+ );
641
+ case "solanaSimple": {
642
+ const unsignedTx = await this.buildUnsignedTransaction(
643
+ runtimeCall,
644
+ params.overrides
645
+ );
646
+ return this.signWithSolanaSimpleAndSubmit(unsignedTx, params.signer);
743
647
  }
744
- });
648
+ case "solana": {
649
+ const unsignedTx = await this.buildUnsignedTransaction(
650
+ runtimeCall,
651
+ params.overrides
652
+ );
653
+ return this.signWithSolanaSpecAndSubmit(unsignedTx, params.signer);
654
+ }
655
+ default:
656
+ throw new Error(`Unsupported authenticator: ${authenticator}`);
657
+ }
745
658
  }
746
659
  /**
747
660
  * Signs and submits a transaction with the specified authenticator.
@@ -751,26 +664,24 @@ var SolanaSignableRollup = class {
751
664
  * @param options - Optional request options
752
665
  * @returns The transaction result
753
666
  */
754
- signAndSubmitTransaction(unsignedTx, params, options) {
755
- return __async(this, null, function* () {
756
- const authenticator = params.authenticator === "solanaAuto" ? this.getAutoAuthenticator(params.signer) : params.authenticator;
757
- switch (authenticator) {
758
- case "standard":
759
- return this.inner.signAndSubmitTransaction(
760
- unsignedTx,
761
- {
762
- signer: params.signer
763
- },
764
- options
765
- );
766
- case "solanaSimple":
767
- return this.signWithSolanaSimpleAndSubmit(unsignedTx, params.signer);
768
- case "solana":
769
- return this.signWithSolanaSpecAndSubmit(unsignedTx, params.signer);
770
- default:
771
- throw new Error(`Unsupported authenticator: ${authenticator}`);
772
- }
773
- });
667
+ async signAndSubmitTransaction(unsignedTx, params, options) {
668
+ const authenticator = params.authenticator === "solanaAuto" ? this.getAutoAuthenticator(params.signer) : params.authenticator;
669
+ switch (authenticator) {
670
+ case "standard":
671
+ return this.inner.signAndSubmitTransaction(
672
+ unsignedTx,
673
+ {
674
+ signer: params.signer
675
+ },
676
+ options
677
+ );
678
+ case "solanaSimple":
679
+ return this.signWithSolanaSimpleAndSubmit(unsignedTx, params.signer);
680
+ case "solana":
681
+ return this.signWithSolanaSpecAndSubmit(unsignedTx, params.signer);
682
+ default:
683
+ throw new Error(`Unsupported authenticator: ${authenticator}`);
684
+ }
774
685
  }
775
686
  /**
776
687
  * Submits a transaction with the specified authenticator.
@@ -780,51 +691,39 @@ var SolanaSignableRollup = class {
780
691
  * @param options - Optional request options
781
692
  * @returns The transaction response
782
693
  */
783
- submitTransaction(transaction, authenticator, options) {
784
- return __async(this, null, function* () {
785
- switch (authenticator) {
786
- case "standard":
787
- return this.inner.submitTransaction(
788
- transaction,
789
- options
790
- );
791
- case "solanaSimple": {
792
- const solanaMessage = transaction;
793
- return yield this.submitSolanaMessage(solanaMessage);
794
- }
795
- case "solana": {
796
- const solanaMessage = transaction;
797
- return yield this.submitSolanaSpecMessage(solanaMessage);
798
- }
799
- default:
800
- throw new Error(`Unsupported authenticator: ${authenticator}`);
694
+ async submitTransaction(transaction, authenticator, options) {
695
+ switch (authenticator) {
696
+ case "standard":
697
+ return this.inner.submitTransaction(
698
+ transaction,
699
+ options
700
+ );
701
+ case "solanaSimple": {
702
+ const solanaMessage = transaction;
703
+ return await this.submitSolanaMessage(solanaMessage);
801
704
  }
802
- });
705
+ case "solana": {
706
+ const solanaMessage = transaction;
707
+ return await this.submitSolanaSpecMessage(solanaMessage);
708
+ }
709
+ default:
710
+ throw new Error(`Unsupported authenticator: ${authenticator}`);
711
+ }
803
712
  }
804
- simulate(runtimeMessage, params) {
805
- return __async(this, null, function* () {
806
- return this.inner.simulate(runtimeMessage, params);
807
- });
713
+ async simulate(runtimeMessage, params) {
714
+ return this.inner.simulate(runtimeMessage, params);
808
715
  }
809
- dedup(address) {
810
- return __async(this, null, function* () {
811
- return this.inner.dedup(address);
812
- });
716
+ async dedup(address) {
717
+ return this.inner.dedup(address);
813
718
  }
814
- serializer() {
815
- return __async(this, null, function* () {
816
- return this.inner.serializer();
817
- });
719
+ async serializer() {
720
+ return this.inner.serializer();
818
721
  }
819
- chainHash() {
820
- return __async(this, null, function* () {
821
- return this.inner.chainHash();
822
- });
722
+ async chainHash() {
723
+ return this.inner.chainHash();
823
724
  }
824
- healthcheck(timeout) {
825
- return __async(this, null, function* () {
826
- return this.inner.healthcheck(timeout);
827
- });
725
+ async healthcheck(timeout) {
726
+ return this.inner.healthcheck(timeout);
828
727
  }
829
728
  subscribe(type, callback) {
830
729
  return this.inner.subscribe(type, callback);
@@ -899,11 +798,9 @@ var SolanaSignableRollup = class {
899
798
  return buffer;
900
799
  }
901
800
  };
902
- function createSolanaSignableRollup(rollupConfig, solanaEndpoint = "/sequencer/accept-solana-offchain-tx") {
903
- return __async(this, null, function* () {
904
- const standardRollup = yield createStandardRollup(rollupConfig);
905
- return new SolanaSignableRollup(standardRollup, solanaEndpoint);
906
- });
801
+ async function createSolanaSignableRollup(rollupConfig, solanaEndpoint = "/sequencer/accept-solana-offchain-tx") {
802
+ const standardRollup = await createStandardRollup(rollupConfig);
803
+ return new SolanaSignableRollup(standardRollup, solanaEndpoint);
907
804
  }
908
805
 
909
806
  // src/index.ts