@sovereign-sdk/web3 0.9.1 → 0.11.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/dist/index.d.mts CHANGED
@@ -159,6 +159,13 @@ type RollupConfig<C extends RollupContext> = {
159
159
  * Arbitrary context that is associated with the rollup.
160
160
  */
161
161
  context: C;
162
+ /**
163
+ * The endpoint path for submitting transactions.
164
+ * Defaults to "/sequencer/txs", the standard Sovereign SDK endpoint.
165
+ * Can be overridden if your rollup is configured to expose non-standard endpoints in
166
+ * order to support multiple different transaction encoding or authentication schemes.
167
+ */
168
+ txSubmissionEndpoint: string;
162
169
  };
163
170
  /**
164
171
  * The result of signing and submitting a transaction.
@@ -212,12 +219,16 @@ declare class Rollup<S extends BaseTypeSpec, C extends RollupContext> {
212
219
  /**
213
220
  * Retrieve dedup information about the provided address.
214
221
  *
215
- * @param address - The public key to dedup.
222
+ * @param publicKey - The public key to dedup.
223
+ * TODO: How to add param for generation explicitly
216
224
  */
217
- dedup(address: Uint8Array): Promise<S["Dedup"]>;
225
+ dedup(publicKey: Uint8Array): Promise<S["Dedup"]>;
218
226
  /**
219
227
  * Submits a transaction to the rollup.
220
228
  *
229
+ * The endpoint used for submission can be overridden via the options.path parameter.
230
+ * If not specified, the rollup's configured txSubmissionEndpoint will be used.
231
+ *
221
232
  * @param transaction - The transaction to submit.
222
233
  * @param {SovereignClient.RequestOptions} options - The options for the request.
223
234
  */
@@ -229,6 +240,7 @@ declare class Rollup<S extends BaseTypeSpec, C extends RollupContext> {
229
240
  * @param unsignedTx - The unsigned transaction to sign and submit.
230
241
  * @param {SignerParams} params - The params for signing and submitting the transaction.
231
242
  * @param {SovereignClient.RequestOptions} options - The options for the request.
243
+ * @param endpoint - Optional endpoint override. If not specified, uses the rollup's configured txSubmissionEndpoint.
232
244
  */
233
245
  signAndSubmitTransaction(unsignedTx: S["UnsignedTransaction"], { signer }: SignerParams, options?: SovereignClient__default.RequestOptions): Promise<TransactionResult<S["Transaction"]>>;
234
246
  /**
@@ -240,6 +252,28 @@ declare class Rollup<S extends BaseTypeSpec, C extends RollupContext> {
240
252
  * @param {SovereignClient.RequestOptions} options - The options for the request.
241
253
  */
242
254
  call(runtimeCall: S["RuntimeCall"], { signer, overrides }: CallParams<S>, options?: SovereignClient__default.RequestOptions): Promise<TransactionResult<S["Transaction"]>>;
255
+ /**
256
+ * Prepares a runtime call by creating and signing a transaction without submitting it.
257
+ * This is useful for scenarios where you need the signed transaction for later submission
258
+ * or for analysis purposes.
259
+ *
260
+ * @param runtimeCall - The runtime message to prepare.
261
+ * @param params - The parameters for preparing the call.
262
+ * @param params.signer - The signer to use for signing the transaction.
263
+ * @param params.overrides - Optional overrides for the unsigned transaction.
264
+ * @returns A promise that resolves to the signed transaction.
265
+ */
266
+ prepareCall(runtimeCall: S["RuntimeCall"], { signer, overrides }: CallParams<S>): Promise<S["Transaction"]>;
267
+ /**
268
+ * Signs an unsigned transaction using the provided signer.
269
+ * Creates a signature by combining the serialized unsigned transaction with the chain hash,
270
+ * then constructs a fully signed transaction.
271
+ *
272
+ * @param unsignedTx - The unsigned transaction to sign.
273
+ * @param signer - The signer to use for signing the transaction.
274
+ * @returns A promise that resolves to the signed transaction.
275
+ */
276
+ signTransaction(unsignedTx: S["UnsignedTransaction"], signer: Signer): Promise<S["Transaction"]>;
243
277
  /**
244
278
  * Create a subscription to events emitted over websockets by the rollup.
245
279
  */
@@ -287,23 +321,24 @@ type TxDetails = {
287
321
  gas_limit: number[] | null;
288
322
  chain_id: number;
289
323
  };
324
+ type Generation = {
325
+ generation: number;
326
+ };
327
+ type Nonce = {
328
+ nonce: number;
329
+ };
330
+ type Uniqueness = Nonce | Generation;
290
331
  type UnsignedTransaction<RuntimeCall> = {
291
332
  runtime_call: RuntimeCall;
292
- generation: number;
333
+ uniqueness: Uniqueness;
293
334
  details: TxDetails;
294
335
  };
295
336
  type TransactionV0<RuntimeCall> = {
296
- pub_key: {
297
- pub_key: Uint8Array;
298
- };
299
- signature: {
300
- msg_sig: Uint8Array;
301
- };
337
+ pub_key: HexString;
338
+ signature: HexString;
302
339
  } & UnsignedTransaction<RuntimeCall>;
303
340
  type Transaction<RuntimeCall> = {
304
- versioned_tx: {
305
- V0: TransactionV0<RuntimeCall>;
306
- };
341
+ V0: TransactionV0<RuntimeCall>;
307
342
  };
308
343
  type Dedup = {
309
344
  nonce: number;
@@ -321,14 +356,7 @@ declare function standardTypeBuilder<S extends StandardRollupSpec<unknown>>(): T
321
356
  /**
322
357
  * The parameters for simulating a runtime call transaction.
323
358
  */
324
- type SimulateParams = {
325
- /**
326
- * The transaction details to use for the simulation.
327
- */
328
- txDetails: TxDetails;
329
- /** The generation of the transaction for uniquness purposes. */
330
- generation?: number;
331
- } & SignerParams;
359
+ type SimulateParams = Omit<SovereignClient__default.RollupSimulateParams, "call" | "sender"> & SignerParams;
332
360
  declare class StandardRollup<RuntimeCall> extends Rollup<StandardRollupSpec<RuntimeCall>, StandardRollupContext> {
333
361
  /**
334
362
  * Simulates a runtime call transaction.
@@ -337,7 +365,7 @@ declare class StandardRollup<RuntimeCall> extends Rollup<StandardRollupSpec<Runt
337
365
  *
338
366
  * @param runtimeMessage - The runtime message to call.
339
367
  */
340
- simulate(runtimeMessage: StandardRollupSpec<RuntimeCall>["RuntimeCall"], { signer, txDetails, generation: overrideGeneration }: SimulateParams): Promise<SovereignClient__default.Rollup.SimulateExecutionResponse>;
368
+ simulate(runtimeMessage: StandardRollupSpec<RuntimeCall>["RuntimeCall"], { signer }: SimulateParams): Promise<SovereignClient__default.Rollup.RollupSimulateResponse>;
341
369
  }
342
370
  declare const DEFAULT_TX_DETAILS: Omit<TxDetails, "chain_id">;
343
371
  declare function createStandardRollup<RuntimeCall, C extends StandardRollupContext = StandardRollupContext>(rollupConfig?: Partial<RollupConfig<DeepPartial<C>>>, typeBuilderOverrides?: Partial<TypeBuilder<StandardRollupSpec<RuntimeCall>, C>>): Promise<StandardRollup<RuntimeCall>>;
@@ -362,4 +390,4 @@ declare class SchemaError extends SovereignError {
362
390
  constructor(message: string, reason: string, schema: object);
363
391
  }
364
392
 
365
- export { type BaseTypeSpec, type CallParams, DEFAULT_TX_DETAILS, type Dedup, type EventPayload, InvalidRollupConfigError, Rollup, type RollupConfig, type RollupContext, type RollupTypeSpec, SchemaError, type SignerParams, type SimulateParams, SovereignError, StandardRollup, type StandardRollupContext, type StandardRollupSpec, type Subscription, type Transaction, type TransactionContext, type TransactionResult, type TransactionV0, type TxDetails, type TypeBuilder, type UnsignedTransaction, type UnsignedTransactionContext, VersionMismatchError, addressFromPublicKey, createStandardRollup, standardTypeBuilder };
393
+ export { type BaseTypeSpec, type CallParams, DEFAULT_TX_DETAILS, type Dedup, type EventPayload, type Generation, InvalidRollupConfigError, type Nonce, Rollup, type RollupConfig, type RollupContext, type RollupTypeSpec, SchemaError, type SignerParams, type SimulateParams, SovereignError, StandardRollup, type StandardRollupContext, type StandardRollupSpec, type Subscription, type Transaction, type TransactionContext, type TransactionResult, type TransactionV0, type TxDetails, type TypeBuilder, type Uniqueness, type UnsignedTransaction, type UnsignedTransactionContext, VersionMismatchError, addressFromPublicKey, createStandardRollup, standardTypeBuilder };
package/dist/index.d.ts CHANGED
@@ -159,6 +159,13 @@ type RollupConfig<C extends RollupContext> = {
159
159
  * Arbitrary context that is associated with the rollup.
160
160
  */
161
161
  context: C;
162
+ /**
163
+ * The endpoint path for submitting transactions.
164
+ * Defaults to "/sequencer/txs", the standard Sovereign SDK endpoint.
165
+ * Can be overridden if your rollup is configured to expose non-standard endpoints in
166
+ * order to support multiple different transaction encoding or authentication schemes.
167
+ */
168
+ txSubmissionEndpoint: string;
162
169
  };
163
170
  /**
164
171
  * The result of signing and submitting a transaction.
@@ -212,12 +219,16 @@ declare class Rollup<S extends BaseTypeSpec, C extends RollupContext> {
212
219
  /**
213
220
  * Retrieve dedup information about the provided address.
214
221
  *
215
- * @param address - The public key to dedup.
222
+ * @param publicKey - The public key to dedup.
223
+ * TODO: How to add param for generation explicitly
216
224
  */
217
- dedup(address: Uint8Array): Promise<S["Dedup"]>;
225
+ dedup(publicKey: Uint8Array): Promise<S["Dedup"]>;
218
226
  /**
219
227
  * Submits a transaction to the rollup.
220
228
  *
229
+ * The endpoint used for submission can be overridden via the options.path parameter.
230
+ * If not specified, the rollup's configured txSubmissionEndpoint will be used.
231
+ *
221
232
  * @param transaction - The transaction to submit.
222
233
  * @param {SovereignClient.RequestOptions} options - The options for the request.
223
234
  */
@@ -229,6 +240,7 @@ declare class Rollup<S extends BaseTypeSpec, C extends RollupContext> {
229
240
  * @param unsignedTx - The unsigned transaction to sign and submit.
230
241
  * @param {SignerParams} params - The params for signing and submitting the transaction.
231
242
  * @param {SovereignClient.RequestOptions} options - The options for the request.
243
+ * @param endpoint - Optional endpoint override. If not specified, uses the rollup's configured txSubmissionEndpoint.
232
244
  */
233
245
  signAndSubmitTransaction(unsignedTx: S["UnsignedTransaction"], { signer }: SignerParams, options?: SovereignClient__default.RequestOptions): Promise<TransactionResult<S["Transaction"]>>;
234
246
  /**
@@ -240,6 +252,28 @@ declare class Rollup<S extends BaseTypeSpec, C extends RollupContext> {
240
252
  * @param {SovereignClient.RequestOptions} options - The options for the request.
241
253
  */
242
254
  call(runtimeCall: S["RuntimeCall"], { signer, overrides }: CallParams<S>, options?: SovereignClient__default.RequestOptions): Promise<TransactionResult<S["Transaction"]>>;
255
+ /**
256
+ * Prepares a runtime call by creating and signing a transaction without submitting it.
257
+ * This is useful for scenarios where you need the signed transaction for later submission
258
+ * or for analysis purposes.
259
+ *
260
+ * @param runtimeCall - The runtime message to prepare.
261
+ * @param params - The parameters for preparing the call.
262
+ * @param params.signer - The signer to use for signing the transaction.
263
+ * @param params.overrides - Optional overrides for the unsigned transaction.
264
+ * @returns A promise that resolves to the signed transaction.
265
+ */
266
+ prepareCall(runtimeCall: S["RuntimeCall"], { signer, overrides }: CallParams<S>): Promise<S["Transaction"]>;
267
+ /**
268
+ * Signs an unsigned transaction using the provided signer.
269
+ * Creates a signature by combining the serialized unsigned transaction with the chain hash,
270
+ * then constructs a fully signed transaction.
271
+ *
272
+ * @param unsignedTx - The unsigned transaction to sign.
273
+ * @param signer - The signer to use for signing the transaction.
274
+ * @returns A promise that resolves to the signed transaction.
275
+ */
276
+ signTransaction(unsignedTx: S["UnsignedTransaction"], signer: Signer): Promise<S["Transaction"]>;
243
277
  /**
244
278
  * Create a subscription to events emitted over websockets by the rollup.
245
279
  */
@@ -287,23 +321,24 @@ type TxDetails = {
287
321
  gas_limit: number[] | null;
288
322
  chain_id: number;
289
323
  };
324
+ type Generation = {
325
+ generation: number;
326
+ };
327
+ type Nonce = {
328
+ nonce: number;
329
+ };
330
+ type Uniqueness = Nonce | Generation;
290
331
  type UnsignedTransaction<RuntimeCall> = {
291
332
  runtime_call: RuntimeCall;
292
- generation: number;
333
+ uniqueness: Uniqueness;
293
334
  details: TxDetails;
294
335
  };
295
336
  type TransactionV0<RuntimeCall> = {
296
- pub_key: {
297
- pub_key: Uint8Array;
298
- };
299
- signature: {
300
- msg_sig: Uint8Array;
301
- };
337
+ pub_key: HexString;
338
+ signature: HexString;
302
339
  } & UnsignedTransaction<RuntimeCall>;
303
340
  type Transaction<RuntimeCall> = {
304
- versioned_tx: {
305
- V0: TransactionV0<RuntimeCall>;
306
- };
341
+ V0: TransactionV0<RuntimeCall>;
307
342
  };
308
343
  type Dedup = {
309
344
  nonce: number;
@@ -321,14 +356,7 @@ declare function standardTypeBuilder<S extends StandardRollupSpec<unknown>>(): T
321
356
  /**
322
357
  * The parameters for simulating a runtime call transaction.
323
358
  */
324
- type SimulateParams = {
325
- /**
326
- * The transaction details to use for the simulation.
327
- */
328
- txDetails: TxDetails;
329
- /** The generation of the transaction for uniquness purposes. */
330
- generation?: number;
331
- } & SignerParams;
359
+ type SimulateParams = Omit<SovereignClient__default.RollupSimulateParams, "call" | "sender"> & SignerParams;
332
360
  declare class StandardRollup<RuntimeCall> extends Rollup<StandardRollupSpec<RuntimeCall>, StandardRollupContext> {
333
361
  /**
334
362
  * Simulates a runtime call transaction.
@@ -337,7 +365,7 @@ declare class StandardRollup<RuntimeCall> extends Rollup<StandardRollupSpec<Runt
337
365
  *
338
366
  * @param runtimeMessage - The runtime message to call.
339
367
  */
340
- simulate(runtimeMessage: StandardRollupSpec<RuntimeCall>["RuntimeCall"], { signer, txDetails, generation: overrideGeneration }: SimulateParams): Promise<SovereignClient__default.Rollup.SimulateExecutionResponse>;
368
+ simulate(runtimeMessage: StandardRollupSpec<RuntimeCall>["RuntimeCall"], { signer }: SimulateParams): Promise<SovereignClient__default.Rollup.RollupSimulateResponse>;
341
369
  }
342
370
  declare const DEFAULT_TX_DETAILS: Omit<TxDetails, "chain_id">;
343
371
  declare function createStandardRollup<RuntimeCall, C extends StandardRollupContext = StandardRollupContext>(rollupConfig?: Partial<RollupConfig<DeepPartial<C>>>, typeBuilderOverrides?: Partial<TypeBuilder<StandardRollupSpec<RuntimeCall>, C>>): Promise<StandardRollup<RuntimeCall>>;
@@ -362,4 +390,4 @@ declare class SchemaError extends SovereignError {
362
390
  constructor(message: string, reason: string, schema: object);
363
391
  }
364
392
 
365
- export { type BaseTypeSpec, type CallParams, DEFAULT_TX_DETAILS, type Dedup, type EventPayload, InvalidRollupConfigError, Rollup, type RollupConfig, type RollupContext, type RollupTypeSpec, SchemaError, type SignerParams, type SimulateParams, SovereignError, StandardRollup, type StandardRollupContext, type StandardRollupSpec, type Subscription, type Transaction, type TransactionContext, type TransactionResult, type TransactionV0, type TxDetails, type TypeBuilder, type UnsignedTransaction, type UnsignedTransactionContext, VersionMismatchError, addressFromPublicKey, createStandardRollup, standardTypeBuilder };
393
+ export { type BaseTypeSpec, type CallParams, DEFAULT_TX_DETAILS, type Dedup, type EventPayload, type Generation, InvalidRollupConfigError, type Nonce, Rollup, type RollupConfig, type RollupContext, type RollupTypeSpec, SchemaError, type SignerParams, type SimulateParams, SovereignError, StandardRollup, type StandardRollupContext, type StandardRollupSpec, type Subscription, type Transaction, type TransactionContext, type TransactionResult, type TransactionV0, type TxDetails, type TypeBuilder, type Uniqueness, type UnsignedTransaction, type UnsignedTransactionContext, VersionMismatchError, addressFromPublicKey, createStandardRollup, standardTypeBuilder };
package/dist/index.js CHANGED
@@ -156,7 +156,12 @@ function subscribe(url, callback) {
156
156
  websocket.addEventListener("message", (message) => {
157
157
  var _a2;
158
158
  const data = JSON.parse(message.data);
159
- (_a2 = _subscriptions[url]) == null ? void 0 : _a2.callbacks.forEach((cb) => cb(data));
159
+ const callbacks = (_a2 = _subscriptions[url]) == null ? void 0 : _a2.callbacks;
160
+ if (callbacks) {
161
+ for (const cb of callbacks) {
162
+ cb(data);
163
+ }
164
+ }
160
165
  });
161
166
  websocket.addEventListener(
162
167
  "error",
@@ -212,17 +217,22 @@ var Rollup = class {
212
217
  /**
213
218
  * Retrieve dedup information about the provided address.
214
219
  *
215
- * @param address - The public key to dedup.
220
+ * @param publicKey - The public key to dedup.
221
+ * TODO: How to add param for generation explicitly
216
222
  */
217
- dedup(address) {
223
+ dedup(publicKey) {
218
224
  return __async(this, null, function* () {
219
- const response = yield this.rollup.addresses.dedup((0, import_utils2.bytesToHex)(address));
225
+ const credentialId = (0, import_utils2.bytesToHex)(publicKey);
226
+ const response = yield this.rollup.addresses.dedup(credentialId);
220
227
  return response;
221
228
  });
222
229
  }
223
230
  /**
224
231
  * Submits a transaction to the rollup.
225
232
  *
233
+ * The endpoint used for submission can be overridden via the options.path parameter.
234
+ * If not specified, the rollup's configured txSubmissionEndpoint will be used.
235
+ *
226
236
  * @param transaction - The transaction to submit.
227
237
  * @param {SovereignClient.RequestOptions} options - The options for the request.
228
238
  */
@@ -230,10 +240,14 @@ var Rollup = class {
230
240
  return __async(this, null, function* () {
231
241
  const serializer = yield this.serializer();
232
242
  const serializedTx = serializer.serializeTx(transaction);
233
- return this.sequencer.txs.create({ body: import_js_base64.Base64.fromUint8Array(serializedTx) }, options).catch((e) => __async(this, null, function* () {
243
+ const _a = options || {}, { body: _, query: __, path } = _a, requestOptions = __objRest(_a, ["body", "query", "path"]);
244
+ const txSubmissionEndpoint = path || this._config.txSubmissionEndpoint;
245
+ return this.http.post(txSubmissionEndpoint, __spreadValues({
246
+ body: { body: import_js_base64.Base64.fromUint8Array(serializedTx) }
247
+ }, requestOptions)).catch((e) => __async(this, null, function* () {
234
248
  if (isVersionMismatchError(e)) {
235
249
  const oldVersion = (0, import_utils2.bytesToHex)(yield this.chainHash());
236
- const { schema, chain_hash: newVersion } = yield this.rollup.schema.retrieve();
250
+ const { schema, chain_hash: newVersion } = yield this.rollup.schema();
237
251
  this._chainHash = (0, import_utils2.hexToBytes)(newVersion);
238
252
  this._serializer = this._config.getSerializer(schema);
239
253
  if (oldVersion !== newVersion) {
@@ -255,23 +269,11 @@ var Rollup = class {
255
269
  * @param unsignedTx - The unsigned transaction to sign and submit.
256
270
  * @param {SignerParams} params - The params for signing and submitting the transaction.
257
271
  * @param {SovereignClient.RequestOptions} options - The options for the request.
272
+ * @param endpoint - Optional endpoint override. If not specified, uses the rollup's configured txSubmissionEndpoint.
258
273
  */
259
274
  signAndSubmitTransaction(_0, _1, _2) {
260
275
  return __async(this, arguments, function* (unsignedTx, { signer }, options) {
261
- const serializer = yield this.serializer();
262
- const serializedUnsignedTx = serializer.serializeUnsignedTx(unsignedTx);
263
- const chainHash = yield this.chainHash();
264
- const signature = yield signer.sign(
265
- new Uint8Array([...serializedUnsignedTx, ...chainHash])
266
- );
267
- const publicKey = yield signer.publicKey();
268
- const context = {
269
- unsignedTx,
270
- sender: publicKey,
271
- signature,
272
- rollup: this
273
- };
274
- const tx = yield this._typeBuilder.transaction(context);
276
+ const tx = yield this.signTransaction(unsignedTx, signer);
275
277
  const result = yield this.submitTransaction(tx, options);
276
278
  return { transaction: tx, response: result };
277
279
  });
@@ -301,6 +303,55 @@ var Rollup = class {
301
303
  );
302
304
  });
303
305
  }
306
+ /**
307
+ * Prepares a runtime call by creating and signing a transaction without submitting it.
308
+ * This is useful for scenarios where you need the signed transaction for later submission
309
+ * or for analysis purposes.
310
+ *
311
+ * @param runtimeCall - The runtime message to prepare.
312
+ * @param params - The parameters for preparing the call.
313
+ * @param params.signer - The signer to use for signing the transaction.
314
+ * @param params.overrides - Optional overrides for the unsigned transaction.
315
+ * @returns A promise that resolves to the signed transaction.
316
+ */
317
+ prepareCall(_0, _1) {
318
+ return __async(this, arguments, function* (runtimeCall, { signer, overrides }) {
319
+ const context = {
320
+ runtimeCall,
321
+ rollup: this,
322
+ overrides: overrides != null ? overrides : {}
323
+ };
324
+ const unsignedTx = yield this._typeBuilder.unsignedTransaction(context);
325
+ return this.signTransaction(unsignedTx, signer);
326
+ });
327
+ }
328
+ /**
329
+ * Signs an unsigned transaction using the provided signer.
330
+ * Creates a signature by combining the serialized unsigned transaction with the chain hash,
331
+ * then constructs a fully signed transaction.
332
+ *
333
+ * @param unsignedTx - The unsigned transaction to sign.
334
+ * @param signer - The signer to use for signing the transaction.
335
+ * @returns A promise that resolves to the signed transaction.
336
+ */
337
+ signTransaction(unsignedTx, signer) {
338
+ return __async(this, null, function* () {
339
+ const serializer = yield this.serializer();
340
+ const serializedUnsignedTx = serializer.serializeUnsignedTx(unsignedTx);
341
+ const chainHash = yield this.chainHash();
342
+ const signature = yield signer.sign(
343
+ new Uint8Array([...serializedUnsignedTx, ...chainHash])
344
+ );
345
+ const publicKey = yield signer.publicKey();
346
+ const context = {
347
+ unsignedTx,
348
+ sender: publicKey,
349
+ signature,
350
+ rollup: this
351
+ };
352
+ return this._typeBuilder.transaction(context);
353
+ });
354
+ }
304
355
  /**
305
356
  * Create a subscription to events emitted over websockets by the rollup.
306
357
  */
@@ -356,7 +407,7 @@ var Rollup = class {
356
407
  serializer() {
357
408
  return __async(this, null, function* () {
358
409
  if (this._serializer) return this._serializer;
359
- const { schema } = yield this.rollup.schema.retrieve();
410
+ const { schema } = yield this.rollup.schema();
360
411
  this._serializer = this._config.getSerializer(schema);
361
412
  return this._serializer;
362
413
  });
@@ -370,7 +421,7 @@ var Rollup = class {
370
421
  chainHash() {
371
422
  return __async(this, null, function* () {
372
423
  if (this._chainHash) return this._chainHash;
373
- const { chain_hash } = yield this.rollup.schema.retrieve();
424
+ const { chain_hash } = yield this.rollup.schema();
374
425
  this._chainHash = (0, import_utils2.hexToBytes)(chain_hash);
375
426
  return this._chainHash;
376
427
  });
@@ -391,25 +442,25 @@ function isVersionMismatchError(e) {
391
442
  var import_client2 = __toESM(require("@sovereign-sdk/client"));
392
443
  var import_serializers = require("@sovereign-sdk/serializers");
393
444
  var import_utils3 = require("@sovereign-sdk/utils");
394
- var useOrFetchGeneration = (_0) => __async(void 0, [_0], function* ({
445
+ var useOrFetchUniqueness = (_0) => __async(void 0, [_0], function* ({
395
446
  overrides
396
447
  }) {
397
- if ((overrides == null ? void 0 : overrides.generation) !== void 0 && overrides.generation >= 0) {
398
- return overrides.generation;
448
+ if (overrides == null ? void 0 : overrides.uniqueness) {
449
+ return overrides.uniqueness;
399
450
  }
400
- return Date.now();
451
+ return { generation: Date.now() };
401
452
  });
402
453
  function standardTypeBuilder() {
403
454
  return {
404
455
  unsignedTransaction(context) {
405
456
  return __async(this, null, function* () {
406
457
  const { rollup, runtimeCall } = context;
407
- const _a2 = context.overrides, { generation: _ } = _a2, overrides = __objRest(_a2, ["generation"]);
408
- const generation = yield useOrFetchGeneration(context);
458
+ const _a2 = context.overrides, { uniqueness: _ } = _a2, overrides = __objRest(_a2, ["uniqueness"]);
459
+ const uniqueness = yield useOrFetchUniqueness(context);
409
460
  const details = __spreadValues(__spreadValues({}, rollup.context.defaultTxDetails), overrides.details);
410
461
  return {
411
462
  runtime_call: runtimeCall,
412
- generation,
463
+ uniqueness,
413
464
  details
414
465
  };
415
466
  });
@@ -421,16 +472,10 @@ function standardTypeBuilder() {
421
472
  unsignedTx
422
473
  }) {
423
474
  return {
424
- versioned_tx: {
425
- V0: __spreadValues({
426
- pub_key: {
427
- pub_key: sender
428
- },
429
- signature: {
430
- msg_sig: signature
431
- }
432
- }, unsignedTx)
433
- }
475
+ V0: __spreadValues({
476
+ pub_key: (0, import_utils3.bytesToHex)(sender),
477
+ signature: (0, import_utils3.bytesToHex)(signature)
478
+ }, unsignedTx)
434
479
  };
435
480
  });
436
481
  }
@@ -445,26 +490,11 @@ var StandardRollup = class extends Rollup {
445
490
  * @param runtimeMessage - The runtime message to call.
446
491
  */
447
492
  simulate(_0, _1) {
448
- return __async(this, arguments, function* (runtimeMessage, { signer, txDetails, generation: overrideGeneration }) {
449
- const serializer = yield this.serializer();
450
- const runtimeCall = serializer.serializeRuntimeCall(runtimeMessage);
493
+ return __async(this, arguments, function* (runtimeMessage, { signer }) {
451
494
  const publicKey = yield signer.publicKey();
452
- const generation = yield useOrFetchGeneration({
453
- rollup: this,
454
- overrides: { generation: overrideGeneration }
455
- });
456
- const response = yield this.rollup.simulate({
457
- body: {
458
- details: __spreadProps(__spreadValues({}, txDetails), {
459
- // simulate needs this field as `undefined` currently
460
- gas_limit: txDetails.gas_limit || void 0
461
- }),
462
- encoded_call_message: (0, import_utils3.bytesToHex)(runtimeCall),
463
- generation,
464
- sender_pub_key: (0, import_utils3.bytesToHex)(publicKey)
465
- }
466
- });
467
- return response;
495
+ const sender = (0, import_utils3.bytesToHex)(publicKey);
496
+ const call = runtimeMessage;
497
+ return this.rollup.simulate({ sender, call });
468
498
  });
469
499
  }
470
500
  };
@@ -477,7 +507,7 @@ function buildContext(client, context) {
477
507
  return __async(this, null, function* () {
478
508
  const defaultTxDetails = __spreadValues(__spreadValues({}, DEFAULT_TX_DETAILS), context == null ? void 0 : context.defaultTxDetails);
479
509
  if (!defaultTxDetails.chain_id) {
480
- const { chain_id } = yield client.rollup.constants.retrieve();
510
+ const { chain_id } = yield client.rollup.constants();
481
511
  defaultTxDetails.chain_id = chain_id;
482
512
  }
483
513
  return {
@@ -487,13 +517,19 @@ function buildContext(client, context) {
487
517
  }
488
518
  function createStandardRollup(rollupConfig, typeBuilderOverrides) {
489
519
  return __async(this, null, function* () {
490
- var _a, _b;
520
+ var _a, _b, _c;
491
521
  const config = rollupConfig != null ? rollupConfig : {};
492
522
  const client = (_a = config.client) != null ? _a : new import_client2.default({ baseURL: config.url });
493
523
  const getSerializer = (_b = config.getSerializer) != null ? _b : (schema) => new import_serializers.JsSerializer(schema);
494
524
  const context = yield buildContext(client, config.context);
525
+ const txSubmissionEndpoint = (_c = config.txSubmissionEndpoint) != null ? _c : "/sequencer/txs";
495
526
  return new StandardRollup(
496
- __spreadProps(__spreadValues({}, config), { client, getSerializer, context }),
527
+ __spreadProps(__spreadValues({}, config), {
528
+ client,
529
+ getSerializer,
530
+ context,
531
+ txSubmissionEndpoint
532
+ }),
497
533
  __spreadValues(__spreadValues({}, standardTypeBuilder()), typeBuilderOverrides)
498
534
  );
499
535
  });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/addresses.ts","../src/rollup/rollup.ts","../src/errors.ts","../src/subscriptions.ts","../src/rollup/standard-rollup.ts"],"sourcesContent":["export * from \"./addresses\";\nexport * from \"./rollup\";\nexport * from \"./errors\";\nexport * from \"./type-spec\";\nexport { type EventPayload, Subscription } from \"./subscriptions\";\nexport * as SovereignClient from \"@sovereign-sdk/client\";\n","import { type HexString, ensureBytes } from \"@sovereign-sdk/utils\";\nimport { bech32m } from \"bech32\";\n\n/**\n * Encodes a public key as a bech32m address with the given human-readable part (hrp).\n *\n * @param publicKey - The public key to encode, as a hex string or Uint8Array.\n * @param hrp - The human-readable part for the bech32m address (e.g., \"sov\").\n * @param concatPublicKey - Optional. If provided, only the first `concatPublicKey` bytes of the public key are used.\n * @returns The bech32m-encoded address as a string.\n * @throws {Error} If the public key is not a valid hex string or Uint8Array.\n */\nexport function addressFromPublicKey(\n publicKey: HexString | Uint8Array,\n hrp: string,\n concatPublicKey = 28,\n): string {\n let publicKeyBytes = ensureBytes(publicKey);\n\n if (concatPublicKey !== publicKey.length) {\n publicKeyBytes = publicKeyBytes.slice(0, concatPublicKey);\n }\n\n const words = bech32m.toWords(publicKeyBytes);\n return bech32m.encode(hrp, words);\n}\n","import SovereignClient from \"@sovereign-sdk/client\";\nimport type { APIError } from \"@sovereign-sdk/client\";\nimport type { RollupSchema, Serializer } from \"@sovereign-sdk/serializers\";\nimport type { Signer } from \"@sovereign-sdk/signers\";\nimport { bytesToHex, hexToBytes } from \"@sovereign-sdk/utils\";\nimport { Base64 } from \"js-base64\";\nimport { VersionMismatchError } from \"../errors\";\nimport {\n type Subscription,\n type SubscriptionToCallbackMap,\n createSubscription,\n} from \"../subscriptions\";\nimport type { BaseTypeSpec } from \"../type-spec\";\nimport type { DeepPartial } from \"../utils\";\n\nexport type UnsignedTransactionContext<\n S extends BaseTypeSpec,\n C extends RollupContext,\n> = {\n runtimeCall: S[\"RuntimeCall\"];\n // Provides the ability to override the generation data instead of retrieving it automatically.\n overrides: DeepPartial<S[\"UnsignedTransaction\"]>;\n rollup: Rollup<S, C>;\n};\n\nexport type TransactionContext<\n S extends BaseTypeSpec,\n C extends RollupContext,\n> = {\n unsignedTx: S[\"UnsignedTransaction\"];\n sender: Uint8Array;\n signature: Uint8Array;\n rollup: Rollup<S, C>;\n};\n\nexport type TypeBuilder<S extends BaseTypeSpec, C extends RollupContext> = {\n unsignedTransaction: (\n context: UnsignedTransactionContext<S, C>,\n ) => Promise<S[\"UnsignedTransaction\"]>;\n\n transaction: (context: TransactionContext<S, C>) => Promise<S[\"Transaction\"]>;\n};\n\n/**\n * Arbitrary context that is associated with the rollup.\n */\nexport type RollupContext = Record<string, unknown>;\n\n/**\n * The configuration for a rollup client.\n */\nexport type RollupConfig<C extends RollupContext> = {\n /**\n * The base URL of the rollup full node API.\n */\n url?: string;\n /**\n * The Sovereign SDK client to use for the rollup.\n * If not provided, the default client will be used using {@link PartialRollupConfig.url}.\n */\n client: SovereignClient;\n /**\n * Creates the serializer instance to use for the rollup.\n *\n * This can be called more than once, for example if the chain hash changes (i.e a new rollup version)\n * is detected then it will be called again with the new rollup schema.\n */\n getSerializer: (schema: RollupSchema) => Serializer;\n /**\n * Arbitrary context that is associated with the rollup.\n */\n context: C;\n};\n\n/**\n * The result of signing and submitting a transaction.\n *\n * @template Tx The type of the transaction\n */\nexport type TransactionResult<Tx> = {\n /**\n * The response from the sequencer.\n */\n response: SovereignClient.Sequencer.TxCreateResponse;\n /**\n * The transaction that was submitted.\n */\n transaction: Tx;\n};\n\n/**\n * The parameters for signing and submitting a transaction.\n */\nexport type SignerParams = {\n /**\n * The signer to use for signing the transaction.\n */\n signer: Signer;\n};\n\n/**\n * The parameters for calling executing a runtime call transaction.\n */\nexport type CallParams<S extends BaseTypeSpec> = {\n overrides?: DeepPartial<S[\"UnsignedTransaction\"]>;\n} & SignerParams;\n\n/**\n * A generic rollup client.\n *\n * @template S - The type specification for the rollup.\n * If not provided, the base type specification will be used which uses `any` for all types.\n * @template C - The context for the rollup.\n */\nexport class Rollup<S extends BaseTypeSpec, C extends RollupContext> {\n private readonly _config: RollupConfig<C>;\n private readonly _typeBuilder: TypeBuilder<S, C>;\n private _chainHash?: Uint8Array;\n private _serializer?: Serializer;\n\n /**\n * Creates a new rollup client.\n *\n * @param config - The configuration for the rollup client.\n * @param typeBuilder - The type builder for the rollup.\n */\n constructor(config: RollupConfig<C>, typeBuilder: TypeBuilder<S, C>) {\n this._config = config;\n this._typeBuilder = typeBuilder;\n }\n\n /**\n * Retrieve dedup information about the provided address.\n *\n * @param address - The public key to dedup.\n */\n async dedup(address: Uint8Array): Promise<S[\"Dedup\"]> {\n const response = await this.rollup.addresses.dedup(bytesToHex(address));\n return response as S[\"Dedup\"];\n }\n\n /**\n * Submits a transaction to the rollup.\n *\n * @param transaction - The transaction to submit.\n * @param {SovereignClient.RequestOptions} options - The options for the request.\n */\n async submitTransaction(\n transaction: S[\"Transaction\"],\n options?: SovereignClient.RequestOptions,\n ): Promise<SovereignClient.Sequencer.TxCreateResponse> {\n const serializer = await this.serializer();\n const serializedTx = serializer.serializeTx(transaction);\n\n return this.sequencer.txs\n .create({ body: Base64.fromUint8Array(serializedTx) }, options)\n .catch(async (e) => {\n if (isVersionMismatchError(e as APIError)) {\n const oldVersion = bytesToHex(await this.chainHash());\n const { schema, chain_hash: newVersion } =\n await this.rollup.schema.retrieve();\n this._chainHash = hexToBytes(newVersion);\n this._serializer = this._config.getSerializer(schema);\n\n if (oldVersion !== newVersion) {\n throw new VersionMismatchError(\n \"Schema version mismatch when submitting transaction\",\n newVersion,\n oldVersion,\n );\n }\n }\n throw e;\n });\n }\n\n /**\n * Signs and submits a transaction to the rollup.\n * Utilizes the provided signer to sign the transaction.\n *\n * @param unsignedTx - The unsigned transaction to sign and submit.\n * @param {SignerParams} params - The params for signing and submitting the transaction.\n * @param {SovereignClient.RequestOptions} options - The options for the request.\n */\n async signAndSubmitTransaction(\n unsignedTx: S[\"UnsignedTransaction\"],\n { signer }: SignerParams,\n options?: SovereignClient.RequestOptions,\n ): Promise<TransactionResult<S[\"Transaction\"]>> {\n const serializer = await this.serializer();\n const serializedUnsignedTx = serializer.serializeUnsignedTx(unsignedTx);\n const chainHash = await this.chainHash();\n const signature = await signer.sign(\n new Uint8Array([...serializedUnsignedTx, ...chainHash]),\n );\n const publicKey = await signer.publicKey();\n const context = {\n unsignedTx,\n sender: publicKey,\n signature,\n rollup: this,\n };\n const tx = await this._typeBuilder.transaction(context);\n const result = await this.submitTransaction(tx, options);\n\n return { transaction: tx, response: result };\n }\n\n /**\n * Performs a runtime call transaction.\n * Utilizes the provided signer to sign the transaction.\n *\n * @param runtimeCall - The runtime message to call.\n * @param {CallParams<S>} params - The params for submitting a runtime call transaction.\n * @param {SovereignClient.RequestOptions} options - The options for the request.\n */\n async call(\n runtimeCall: S[\"RuntimeCall\"],\n { signer, overrides }: CallParams<S>,\n options?: SovereignClient.RequestOptions,\n ): Promise<TransactionResult<S[\"Transaction\"]>> {\n const context = {\n runtimeCall,\n rollup: this,\n overrides: overrides ?? ({} as DeepPartial<S[\"UnsignedTransaction\"]>),\n };\n const unsignedTx = await this._typeBuilder.unsignedTransaction(context);\n\n return this.signAndSubmitTransaction(\n unsignedTx,\n {\n signer,\n },\n options,\n );\n }\n\n /**\n * Create a subscription to events emitted over websockets by the rollup.\n */\n subscribe<T extends keyof SubscriptionToCallbackMap>(\n type: T,\n callback: SubscriptionToCallbackMap[T],\n ): Subscription {\n return createSubscription(type, callback, this.http);\n }\n\n /**\n * Performs a healthcheck against the rollup to determine if it is currently healthy.\n *\n * @param timeout - Request timeout in milliseconds.\n * @returns `true` if the rollup is considered healthy otherwise `false`.\n */\n async healthcheck(timeout = 5000): Promise<boolean> {\n try {\n await this.http.get(\"/healthcheck\", { timeout, maxRetries: 1 });\n return true;\n } catch (e) {\n return !(e instanceof SovereignClient.APIConnectionError);\n }\n }\n\n /**\n * A ledger client that can be used to query the ledger.\n */\n get ledger(): SovereignClient.Ledger {\n return this.http.ledger;\n }\n\n /**\n * A sequencer client that can be used to submit transactions & batches to the rollup.\n */\n get sequencer(): SovereignClient.Sequencer {\n return this.http.sequencer;\n }\n\n /**\n * A rollup client that can be used to perform operations on the rollup.\n */\n get rollup(): SovereignClient.Rollup {\n return this.http.rollup;\n }\n\n /**\n * A client that can be used to perform HTTP requests to the Sovereign API.\n * This can be used as an escape hatch to execute arbitrary requests to the Sovereign API\n * if the operation is not supported by `ledger`, `sequencer`, or `rollup` clients.\n */\n get http(): SovereignClient {\n return this._config.client;\n }\n\n /**\n * The serializer for the rollup.\n * Can be used to serialize transactions, runtime calls, etc.\n */\n async serializer(): Promise<Serializer> {\n if (this._serializer) return this._serializer;\n const { schema } = await this.rollup.schema.retrieve();\n this._serializer = this._config.getSerializer(schema);\n return this._serializer;\n }\n\n /**\n * The context for the rollup.\n */\n get context(): C {\n return this._config.context;\n }\n\n async chainHash(): Promise<Uint8Array> {\n if (this._chainHash) return this._chainHash;\n const { chain_hash } = await this.rollup.schema.retrieve();\n this._chainHash = hexToBytes(chain_hash);\n return this._chainHash;\n }\n}\n\nfunction isVersionMismatchError(e: APIError): boolean {\n if (\n // biome-ignore lint/suspicious/noExplicitAny: yolo\n (e.error as any)?.details?.error?.includes(\"Signature verification failed\")\n ) {\n return true;\n }\n\n return false;\n}\n","/**\n * Base error class for Sovereign SDK Web3.\n */\nexport class SovereignError extends Error {\n constructor(message: string) {\n super(message);\n\n this.name = this.constructor.name;\n this.stack = new Error().stack;\n }\n}\n\nexport class InvalidRollupConfigError extends SovereignError {}\n\nexport class VersionMismatchError extends SovereignError {\n public readonly newVersion: string;\n public readonly currentVersion: string;\n public readonly retryable: boolean;\n\n constructor(message: string, newVersion: string, currentVersion: string) {\n super(message);\n\n this.newVersion = newVersion;\n this.currentVersion = currentVersion;\n this.retryable = newVersion !== currentVersion;\n }\n}\n\nexport class SchemaError extends SovereignError {\n public readonly schema: object;\n public readonly reason: string;\n\n constructor(message: string, reason: string, schema: object) {\n super(`${message}: ${reason}`);\n\n this.reason = reason;\n this.schema = schema;\n }\n}\n","import type SovereignSDK from \"@sovereign-sdk/client\";\nimport IsoWebSocket from \"isomorphic-ws\";\nimport { WebSocket } from \"partysocket\";\nimport { SovereignError } from \"./errors\";\n\ntype Url = string;\n\nexport function httpToWebSocket(url: string) {\n return url.replace(/^http(s?):\\/\\//, (_, s) => `ws${s}://`);\n}\n\nexport type Subscription = {\n /** Url providing the subscription. */\n url: Url;\n /** Unsubscribe this subscription. */\n unsubscribe: () => void;\n};\n\ntype SubscriptionEntry = {\n websocket: WebSocket;\n // biome-ignore lint/suspicious/noExplicitAny: allow\n callbacks: Array<(...args: any[]) => void>;\n};\n\nexport const _subscriptions: Record<Url, SubscriptionEntry> = {};\n\n/** Subscribe to the provided websocket url & call the provided callback on messages received. */\nexport function subscribe(\n url: Url,\n // biome-ignore lint/suspicious/noExplicitAny: allow\n callback: (...args: any[]) => void,\n): Subscription {\n const subscription = _subscriptions[url];\n\n if (!subscription) {\n const websocket = new WebSocket(url, [], { WebSocket: IsoWebSocket });\n // bun compatibility: https://github.com/partykit/partykit/issues/774\n websocket.binaryType = \"arraybuffer\";\n\n _subscriptions[url] = {\n websocket,\n callbacks: [callback],\n };\n\n websocket.addEventListener(\"message\", (message) => {\n const data = JSON.parse(message.data);\n _subscriptions[url]?.callbacks.forEach((cb) => cb(data));\n });\n websocket.addEventListener(\"error\", (e) =>\n console.log(\"Websocket error\", e),\n );\n } else {\n subscription.callbacks.push(callback);\n }\n\n const callbackIndex = _subscriptions[url]?.callbacks.length - 1;\n\n return {\n get url() {\n return url;\n },\n unsubscribe() {\n const subscription = _subscriptions[url];\n\n if (!subscription) {\n return;\n }\n\n subscription.callbacks.splice(callbackIndex, 1);\n\n if (!subscription.callbacks.length) {\n subscription.websocket.close();\n delete _subscriptions[url];\n }\n },\n };\n}\n\nexport type EventPayload = {\n tx_hash: string;\n type: \"event\";\n number: number;\n key: string;\n value: Record<string, unknown>;\n module: {\n type: \"moduleRef\";\n name: string;\n };\n};\n\nexport interface SubscriptionToCallbackMap {\n events: (event: EventPayload) => Promise<void>;\n}\n\nexport function createSubscription<T extends keyof SubscriptionToCallbackMap>(\n subscription: T,\n callback: SubscriptionToCallbackMap[T],\n client: SovereignSDK,\n): Subscription {\n switch (subscription) {\n case \"events\": {\n const url = client.buildURL(\"/sequencer/events/ws\", {});\n return subscribe(\n httpToWebSocket(url),\n callback as SubscriptionToCallbackMap[\"events\"],\n );\n }\n default:\n throw new SovereignError(`Invalid subscription type '${subscription}'`);\n }\n}\n","import SovereignClient from \"@sovereign-sdk/client\";\nimport { JsSerializer } from \"@sovereign-sdk/serializers\";\nimport { bytesToHex } from \"@sovereign-sdk/utils\";\nimport type { DeepPartial } from \"../utils\";\nimport {\n Rollup,\n type RollupConfig,\n type SignerParams,\n type TransactionContext,\n type TypeBuilder,\n type UnsignedTransactionContext,\n} from \"./rollup\";\n\nexport type TxDetails = {\n max_priority_fee_bips: number;\n max_fee: string;\n gas_limit: number[] | null;\n chain_id: number;\n};\n\nexport type UnsignedTransaction<RuntimeCall> = {\n runtime_call: RuntimeCall;\n generation: number;\n details: TxDetails;\n};\n\nexport type TransactionV0<RuntimeCall> = {\n pub_key: { pub_key: Uint8Array };\n signature: { msg_sig: Uint8Array };\n} & UnsignedTransaction<RuntimeCall>;\n\nexport type Transaction<RuntimeCall> = {\n versioned_tx: { V0: TransactionV0<RuntimeCall> };\n};\n\nexport type Dedup = {\n nonce: number;\n};\n\nexport type StandardRollupContext = {\n defaultTxDetails: TxDetails;\n};\n\nexport type StandardRollupSpec<RuntimeCall> = {\n UnsignedTransaction: UnsignedTransaction<RuntimeCall>;\n Transaction: Transaction<RuntimeCall>;\n RuntimeCall: RuntimeCall;\n Dedup: Dedup;\n};\n\nconst useOrFetchGeneration = async <S extends StandardRollupSpec<unknown>>({\n overrides,\n}: Omit<\n UnsignedTransactionContext<S, StandardRollupContext>,\n \"runtimeCall\"\n>) => {\n if (overrides?.generation !== undefined && overrides.generation >= 0) {\n return overrides.generation;\n }\n\n return Date.now();\n};\n\nexport function standardTypeBuilder<\n S extends StandardRollupSpec<unknown>,\n>(): TypeBuilder<S, StandardRollupContext> {\n return {\n async unsignedTransaction(\n context: UnsignedTransactionContext<S, StandardRollupContext>,\n ) {\n const { rollup, runtimeCall } = context;\n const { generation: _, ...overrides } = context.overrides;\n const generation = await useOrFetchGeneration(context);\n const details: TxDetails = {\n ...rollup.context.defaultTxDetails,\n ...overrides.details,\n };\n\n return {\n runtime_call: runtimeCall,\n generation,\n details,\n };\n },\n async transaction({\n sender,\n signature,\n unsignedTx,\n }: TransactionContext<S, StandardRollupContext>) {\n return {\n versioned_tx: {\n V0: {\n pub_key: {\n pub_key: sender,\n },\n signature: {\n msg_sig: signature,\n },\n ...unsignedTx,\n },\n },\n };\n },\n };\n}\n\n/**\n * The parameters for simulating a runtime call transaction.\n */\nexport type SimulateParams = {\n /**\n * The transaction details to use for the simulation.\n */\n txDetails: TxDetails;\n\n /** The generation of the transaction for uniquness purposes. */\n generation?: number;\n} & SignerParams;\n\nexport class StandardRollup<RuntimeCall> extends Rollup<\n StandardRollupSpec<RuntimeCall>,\n StandardRollupContext\n> {\n /**\n * Simulates a runtime call transaction.\n *\n * This method can be useful to estimate the gas cost of a runtime call transaction.\n *\n * @param runtimeMessage - The runtime message to call.\n */\n async simulate(\n runtimeMessage: StandardRollupSpec<RuntimeCall>[\"RuntimeCall\"],\n { signer, txDetails, generation: overrideGeneration }: SimulateParams,\n ): Promise<SovereignClient.Rollup.SimulateExecutionResponse> {\n const serializer = await this.serializer();\n const runtimeCall = serializer.serializeRuntimeCall(runtimeMessage);\n const publicKey = await signer.publicKey();\n const generation = await useOrFetchGeneration({\n rollup: this,\n overrides: { generation: overrideGeneration },\n });\n const response = await this.rollup.simulate({\n body: {\n details: {\n ...txDetails,\n // simulate needs this field as `undefined` currently\n gas_limit: txDetails.gas_limit || undefined,\n },\n encoded_call_message: bytesToHex(runtimeCall),\n generation,\n sender_pub_key: bytesToHex(publicKey),\n },\n });\n\n return response;\n }\n}\n\nexport const DEFAULT_TX_DETAILS: Omit<TxDetails, \"chain_id\"> = {\n max_priority_fee_bips: 0,\n max_fee: \"100000000\",\n gas_limit: null,\n};\n\nasync function buildContext<C extends StandardRollupContext>(\n client: SovereignClient,\n context?: DeepPartial<C>,\n): Promise<C> {\n const defaultTxDetails = {\n ...DEFAULT_TX_DETAILS,\n ...context?.defaultTxDetails,\n };\n\n if (!defaultTxDetails.chain_id) {\n const { chain_id } = await client.rollup.constants.retrieve();\n\n defaultTxDetails.chain_id = chain_id;\n }\n\n return {\n defaultTxDetails,\n } as C;\n}\n\nexport async function createStandardRollup<\n RuntimeCall,\n C extends StandardRollupContext = StandardRollupContext,\n>(\n rollupConfig?: Partial<RollupConfig<DeepPartial<C>>>,\n typeBuilderOverrides?: Partial<\n TypeBuilder<StandardRollupSpec<RuntimeCall>, C>\n >,\n) {\n const config = rollupConfig ?? {};\n const client = config.client ?? new SovereignClient({ baseURL: config.url });\n const getSerializer =\n config.getSerializer ?? ((schema) => new JsSerializer(schema));\n const context = await buildContext<C>(client, config.context);\n\n return new StandardRollup<RuntimeCall>(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,UAC5C;AAAA,UACA,oBAAgB,0BAAW,SAAS;AAAA,QACtC;AAAA,MACF,CAAC;AAED,aAAO;AAAA,IACT;AAAA;AACF;AAEO,IAAM,qBAAkD;AAAA,EAC7D,uBAAuB;AAAA,EACvB,SAAS;AAAA,EACT,WAAW;AACb;AAEA,SAAe,aACb,QACA,SACY;AAAA;AACZ,UAAM,mBAAmB,kCACpB,qBACA,mCAAS;AAGd,QAAI,CAAC,iBAAiB,UAAU;AAC9B,YAAM,EAAE,SAAS,IAAI,MAAM,OAAO,OAAO,UAAU,SAAS;AAE5D,uBAAiB,WAAW;AAAA,IAC9B;AAEA,WAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF;AAAA;AAEA,SAAsB,qBAIpB,cACA,sBAGA;AAAA;AAhMF;AAiME,UAAM,SAAS,sCAAgB,CAAC;AAChC,UAAM,UAAS,YAAO,WAAP,YAAiB,IAAI,eAAAC,QAAgB,EAAE,SAAS,OAAO,IAAI,CAAC;AAC3E,UAAM,iBACJ,YAAO,kBAAP,YAAyB,CAAC,WAAW,IAAI,gCAAa,MAAM;AAC9D,UAAM,UAAU,MAAM,aAAgB,QAAQ,OAAO,OAAO;AAE5D,WAAO,IAAI;AAAA,MACT,iCAAK,SAAL,EAAa,QAAQ,eAAe,QAAQ;AAAA,MAC5C,kCACK,oBAAoB,IACpB;AAAA,IAEP;AAAA,EACF;AAAA;;;ALzMA,IAAAC,mBAAiC;","names":["SovereignClient","import_utils","IsoWebSocket","_a","subscription","SovereignClient","import_client","import_utils","_a","SovereignClient","SovereignClient"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/addresses.ts","../src/rollup/rollup.ts","../src/errors.ts","../src/subscriptions.ts","../src/rollup/standard-rollup.ts"],"sourcesContent":["export * from \"./addresses\";\nexport * from \"./rollup\";\nexport * from \"./errors\";\nexport * from \"./type-spec\";\nexport { type EventPayload, Subscription } from \"./subscriptions\";\nexport * as SovereignClient from \"@sovereign-sdk/client\";\n","import { type HexString, ensureBytes } from \"@sovereign-sdk/utils\";\nimport { bech32m } from \"bech32\";\n\n/**\n * Encodes a public key as a bech32m address with the given human-readable part (hrp).\n *\n * @param publicKey - The public key to encode, as a hex string or Uint8Array.\n * @param hrp - The human-readable part for the bech32m address (e.g., \"sov\").\n * @param concatPublicKey - Optional. If provided, only the first `concatPublicKey` bytes of the public key are used.\n * @returns The bech32m-encoded address as a string.\n * @throws {Error} If the public key is not a valid hex string or Uint8Array.\n */\nexport function addressFromPublicKey(\n publicKey: HexString | Uint8Array,\n hrp: string,\n concatPublicKey = 28,\n): string {\n let publicKeyBytes = ensureBytes(publicKey);\n\n if (concatPublicKey !== publicKey.length) {\n publicKeyBytes = publicKeyBytes.slice(0, concatPublicKey);\n }\n\n const words = bech32m.toWords(publicKeyBytes);\n return bech32m.encode(hrp, words);\n}\n","import SovereignClient from \"@sovereign-sdk/client\";\nimport type { APIError } from \"@sovereign-sdk/client\";\nimport type { RollupSchema, Serializer } from \"@sovereign-sdk/serializers\";\nimport type { Signer } from \"@sovereign-sdk/signers\";\nimport { bytesToHex, hexToBytes } from \"@sovereign-sdk/utils\";\nimport { Base64 } from \"js-base64\";\nimport { VersionMismatchError } from \"../errors\";\nimport {\n type Subscription,\n type SubscriptionToCallbackMap,\n createSubscription,\n} from \"../subscriptions\";\nimport type { BaseTypeSpec } from \"../type-spec\";\nimport type { DeepPartial } from \"../utils\";\n\nexport type UnsignedTransactionContext<\n S extends BaseTypeSpec,\n C extends RollupContext,\n> = {\n runtimeCall: S[\"RuntimeCall\"];\n // Provides the ability to override the generation data instead of retrieving it automatically.\n overrides: DeepPartial<S[\"UnsignedTransaction\"]>;\n rollup: Rollup<S, C>;\n};\n\nexport type TransactionContext<\n S extends BaseTypeSpec,\n C extends RollupContext,\n> = {\n unsignedTx: S[\"UnsignedTransaction\"];\n sender: Uint8Array;\n signature: Uint8Array;\n rollup: Rollup<S, C>;\n};\n\nexport type TypeBuilder<S extends BaseTypeSpec, C extends RollupContext> = {\n unsignedTransaction: (\n context: UnsignedTransactionContext<S, C>,\n ) => Promise<S[\"UnsignedTransaction\"]>;\n\n transaction: (context: TransactionContext<S, C>) => Promise<S[\"Transaction\"]>;\n};\n\n/**\n * Arbitrary context that is associated with the rollup.\n */\nexport type RollupContext = Record<string, unknown>;\n\n/**\n * The configuration for a rollup client.\n */\nexport type RollupConfig<C extends RollupContext> = {\n /**\n * The base URL of the rollup full node API.\n */\n url?: string;\n /**\n * The Sovereign SDK client to use for the rollup.\n * If not provided, the default client will be used using {@link PartialRollupConfig.url}.\n */\n client: SovereignClient;\n /**\n * Creates the serializer instance to use for the rollup.\n *\n * This can be called more than once, for example if the chain hash changes (i.e a new rollup version)\n * is detected then it will be called again with the new rollup schema.\n */\n getSerializer: (schema: RollupSchema) => Serializer;\n /**\n * Arbitrary context that is associated with the rollup.\n */\n context: C;\n /**\n * The endpoint path for submitting transactions.\n * Defaults to \"/sequencer/txs\", the standard Sovereign SDK endpoint.\n * Can be overridden if your rollup is configured to expose non-standard endpoints in\n * order to support multiple different transaction encoding or authentication schemes.\n */\n txSubmissionEndpoint: string;\n};\n\n/**\n * The result of signing and submitting a transaction.\n *\n * @template Tx The type of the transaction\n */\nexport type TransactionResult<Tx> = {\n /**\n * The response from the sequencer.\n */\n response: SovereignClient.Sequencer.TxCreateResponse;\n /**\n * The transaction that was submitted.\n */\n transaction: Tx;\n};\n\n/**\n * The parameters for signing and submitting a transaction.\n */\nexport type SignerParams = {\n /**\n * The signer to use for signing the transaction.\n */\n signer: Signer;\n};\n\n/**\n * The parameters for calling executing a runtime call transaction.\n */\nexport type CallParams<S extends BaseTypeSpec> = {\n overrides?: DeepPartial<S[\"UnsignedTransaction\"]>;\n} & SignerParams;\n\n/**\n * A generic rollup client.\n *\n * @template S - The type specification for the rollup.\n * If not provided, the base type specification will be used which uses `any` for all types.\n * @template C - The context for the rollup.\n */\nexport class Rollup<S extends BaseTypeSpec, C extends RollupContext> {\n private readonly _config: RollupConfig<C>;\n private readonly _typeBuilder: TypeBuilder<S, C>;\n private _chainHash?: Uint8Array;\n private _serializer?: Serializer;\n\n /**\n * Creates a new rollup client.\n *\n * @param config - The configuration for the rollup client.\n * @param typeBuilder - The type builder for the rollup.\n */\n constructor(config: RollupConfig<C>, typeBuilder: TypeBuilder<S, C>) {\n this._config = config;\n this._typeBuilder = typeBuilder;\n }\n\n /**\n * Retrieve dedup information about the provided address.\n *\n * @param publicKey - The public key to dedup.\n * TODO: How to add param for generation explicitly\n */\n async dedup(publicKey: Uint8Array): Promise<S[\"Dedup\"]> {\n // for public key credential id is just its bytes representation\n const credentialId = bytesToHex(publicKey);\n const response = await this.rollup.addresses.dedup(credentialId);\n return response as S[\"Dedup\"];\n }\n\n /**\n * Submits a transaction to the rollup.\n *\n * The endpoint used for submission can be overridden via the options.path parameter.\n * If not specified, the rollup's configured txSubmissionEndpoint will be used.\n *\n * @param transaction - The transaction to submit.\n * @param {SovereignClient.RequestOptions} options - The options for the request.\n */\n async submitTransaction(\n transaction: S[\"Transaction\"],\n options?: SovereignClient.RequestOptions,\n ): Promise<SovereignClient.Sequencer.TxCreateResponse> {\n const serializer = await this.serializer();\n const serializedTx = serializer.serializeTx(transaction);\n // Stainless RequestOptions is generic internally, causing issues for `body` and `query`.\n // That's fine since we supply the `body` and transaction submission doesn't take query parameters.\n // So we hack around this by destructuring them out.\n const { body: _, query: __, path, ...requestOptions } = options || {};\n const txSubmissionEndpoint = path || this._config.txSubmissionEndpoint;\n\n return this.http\n .post<SovereignClient.Sequencer.TxCreateResponse>(txSubmissionEndpoint, {\n body: { body: Base64.fromUint8Array(serializedTx) },\n ...requestOptions,\n })\n .catch(async (e) => {\n if (isVersionMismatchError(e as APIError)) {\n const oldVersion = bytesToHex(await this.chainHash());\n const { schema, chain_hash: newVersion } = await this.rollup.schema();\n this._chainHash = hexToBytes(newVersion);\n this._serializer = this._config.getSerializer(schema);\n\n if (oldVersion !== newVersion) {\n throw new VersionMismatchError(\n \"Schema version mismatch when submitting transaction\",\n newVersion,\n oldVersion,\n );\n }\n }\n throw e;\n });\n }\n\n /**\n * Signs and submits a transaction to the rollup.\n * Utilizes the provided signer to sign the transaction.\n *\n * @param unsignedTx - The unsigned transaction to sign and submit.\n * @param {SignerParams} params - The params for signing and submitting the transaction.\n * @param {SovereignClient.RequestOptions} options - The options for the request.\n * @param endpoint - Optional endpoint override. If not specified, uses the rollup's configured txSubmissionEndpoint.\n */\n async signAndSubmitTransaction(\n unsignedTx: S[\"UnsignedTransaction\"],\n { signer }: SignerParams,\n options?: SovereignClient.RequestOptions,\n ): Promise<TransactionResult<S[\"Transaction\"]>> {\n const tx = await this.signTransaction(unsignedTx, signer);\n const result = await this.submitTransaction(tx, options);\n\n return { transaction: tx, response: result };\n }\n\n /**\n * Performs a runtime call transaction.\n * Utilizes the provided signer to sign the transaction.\n *\n * @param runtimeCall - The runtime message to call.\n * @param {CallParams<S>} params - The params for submitting a runtime call transaction.\n * @param {SovereignClient.RequestOptions} options - The options for the request.\n */\n async call(\n runtimeCall: S[\"RuntimeCall\"],\n { signer, overrides }: CallParams<S>,\n options?: SovereignClient.RequestOptions,\n ): Promise<TransactionResult<S[\"Transaction\"]>> {\n const context = {\n runtimeCall,\n rollup: this,\n overrides: overrides ?? ({} as DeepPartial<S[\"UnsignedTransaction\"]>),\n };\n const unsignedTx = await this._typeBuilder.unsignedTransaction(context);\n\n return this.signAndSubmitTransaction(\n unsignedTx,\n {\n signer,\n },\n options,\n );\n }\n\n /**\n * Prepares a runtime call by creating and signing a transaction without submitting it.\n * This is useful for scenarios where you need the signed transaction for later submission\n * or for analysis purposes.\n *\n * @param runtimeCall - The runtime message to prepare.\n * @param params - The parameters for preparing the call.\n * @param params.signer - The signer to use for signing the transaction.\n * @param params.overrides - Optional overrides for the unsigned transaction.\n * @returns A promise that resolves to the signed transaction.\n */\n async prepareCall(\n runtimeCall: S[\"RuntimeCall\"],\n { signer, overrides }: CallParams<S>,\n ): Promise<S[\"Transaction\"]> {\n const context = {\n runtimeCall,\n rollup: this,\n overrides: overrides ?? ({} as DeepPartial<S[\"UnsignedTransaction\"]>),\n };\n const unsignedTx = await this._typeBuilder.unsignedTransaction(context);\n return this.signTransaction(unsignedTx, signer);\n }\n\n /**\n * Signs an unsigned transaction using the provided signer.\n * Creates a signature by combining the serialized unsigned transaction with the chain hash,\n * then constructs a fully signed transaction.\n *\n * @param unsignedTx - The unsigned transaction to sign.\n * @param signer - The signer to use for signing the transaction.\n * @returns A promise that resolves to the signed transaction.\n */\n async signTransaction(\n unsignedTx: S[\"UnsignedTransaction\"],\n signer: Signer,\n ): Promise<S[\"Transaction\"]> {\n const serializer = await this.serializer();\n const serializedUnsignedTx = serializer.serializeUnsignedTx(unsignedTx);\n const chainHash = await this.chainHash();\n const signature = await signer.sign(\n new Uint8Array([...serializedUnsignedTx, ...chainHash]),\n );\n const publicKey = await signer.publicKey();\n const context = {\n unsignedTx,\n sender: publicKey,\n signature,\n rollup: this,\n };\n return this._typeBuilder.transaction(context);\n }\n\n /**\n * Create a subscription to events emitted over websockets by the rollup.\n */\n subscribe<T extends keyof SubscriptionToCallbackMap>(\n type: T,\n callback: SubscriptionToCallbackMap[T],\n ): Subscription {\n return createSubscription(type, callback, this.http);\n }\n\n /**\n * Performs a healthcheck against the rollup to determine if it is currently healthy.\n *\n * @param timeout - Request timeout in milliseconds.\n * @returns `true` if the rollup is considered healthy otherwise `false`.\n */\n async healthcheck(timeout = 5000): Promise<boolean> {\n try {\n await this.http.get(\"/healthcheck\", { timeout, maxRetries: 1 });\n return true;\n } catch (e) {\n return !(e instanceof SovereignClient.APIConnectionError);\n }\n }\n\n /**\n * A ledger client that can be used to query the ledger.\n */\n get ledger(): SovereignClient.Ledger {\n return this.http.ledger;\n }\n\n /**\n * A sequencer client that can be used to submit transactions & batches to the rollup.\n */\n get sequencer(): SovereignClient.Sequencer {\n return this.http.sequencer;\n }\n\n /**\n * A rollup client that can be used to perform operations on the rollup.\n */\n get rollup(): SovereignClient.Rollup {\n return this.http.rollup;\n }\n\n /**\n * A client that can be used to perform HTTP requests to the Sovereign API.\n * This can be used as an escape hatch to execute arbitrary requests to the Sovereign API\n * if the operation is not supported by `ledger`, `sequencer`, or `rollup` clients.\n */\n get http(): SovereignClient {\n return this._config.client;\n }\n\n /**\n * The serializer for the rollup.\n * Can be used to serialize transactions, runtime calls, etc.\n */\n async serializer(): Promise<Serializer> {\n if (this._serializer) return this._serializer;\n const { schema } = await this.rollup.schema();\n this._serializer = this._config.getSerializer(schema);\n return this._serializer;\n }\n\n /**\n * The context for the rollup.\n */\n get context(): C {\n return this._config.context;\n }\n\n async chainHash(): Promise<Uint8Array> {\n if (this._chainHash) return this._chainHash;\n const { chain_hash } = await this.rollup.schema();\n this._chainHash = hexToBytes(chain_hash);\n return this._chainHash;\n }\n}\n\nfunction isVersionMismatchError(e: APIError): boolean {\n if (\n // biome-ignore lint/suspicious/noExplicitAny: yolo\n (e.error as any)?.details?.error?.includes(\"Signature verification failed\")\n ) {\n return true;\n }\n\n return false;\n}\n","/**\n * Base error class for Sovereign SDK Web3.\n */\nexport class SovereignError extends Error {\n constructor(message: string) {\n super(message);\n\n this.name = this.constructor.name;\n this.stack = new Error().stack;\n }\n}\n\nexport class InvalidRollupConfigError extends SovereignError {}\n\nexport class VersionMismatchError extends SovereignError {\n public readonly newVersion: string;\n public readonly currentVersion: string;\n public readonly retryable: boolean;\n\n constructor(message: string, newVersion: string, currentVersion: string) {\n super(message);\n\n this.newVersion = newVersion;\n this.currentVersion = currentVersion;\n this.retryable = newVersion !== currentVersion;\n }\n}\n\nexport class SchemaError extends SovereignError {\n public readonly schema: object;\n public readonly reason: string;\n\n constructor(message: string, reason: string, schema: object) {\n super(`${message}: ${reason}`);\n\n this.reason = reason;\n this.schema = schema;\n }\n}\n","import type SovereignSDK from \"@sovereign-sdk/client\";\nimport IsoWebSocket from \"isomorphic-ws\";\nimport { WebSocket } from \"partysocket\";\nimport { SovereignError } from \"./errors\";\n\ntype Url = string;\n\nexport function httpToWebSocket(url: string) {\n return url.replace(/^http(s?):\\/\\//, (_, s) => `ws${s}://`);\n}\n\nexport type Subscription = {\n /** Url providing the subscription. */\n url: Url;\n /** Unsubscribe this subscription. */\n unsubscribe: () => void;\n};\n\ntype SubscriptionEntry = {\n websocket: WebSocket;\n // biome-ignore lint/suspicious/noExplicitAny: allow\n callbacks: Array<(...args: any[]) => void>;\n};\n\nexport const _subscriptions: Record<Url, SubscriptionEntry> = {};\n\n/** Subscribe to the provided websocket url & call the provided callback on messages received. */\nexport function subscribe(\n url: Url,\n // biome-ignore lint/suspicious/noExplicitAny: allow\n callback: (...args: any[]) => void,\n): Subscription {\n const subscription = _subscriptions[url];\n\n if (!subscription) {\n const websocket = new WebSocket(url, [], { WebSocket: IsoWebSocket });\n // bun compatibility: https://github.com/partykit/partykit/issues/774\n websocket.binaryType = \"arraybuffer\";\n\n _subscriptions[url] = {\n websocket,\n callbacks: [callback],\n };\n\n websocket.addEventListener(\"message\", (message) => {\n const data = JSON.parse(message.data);\n const callbacks = _subscriptions[url]?.callbacks;\n if (callbacks) {\n for (const cb of callbacks) {\n cb(data);\n }\n }\n });\n websocket.addEventListener(\"error\", (e) =>\n console.log(\"Websocket error\", e),\n );\n } else {\n subscription.callbacks.push(callback);\n }\n\n const callbackIndex = _subscriptions[url]?.callbacks.length - 1;\n\n return {\n get url() {\n return url;\n },\n unsubscribe() {\n const subscription = _subscriptions[url];\n\n if (!subscription) {\n return;\n }\n\n subscription.callbacks.splice(callbackIndex, 1);\n\n if (!subscription.callbacks.length) {\n subscription.websocket.close();\n delete _subscriptions[url];\n }\n },\n };\n}\n\nexport type EventPayload = {\n tx_hash: string;\n type: \"event\";\n number: number;\n key: string;\n value: Record<string, unknown>;\n module: {\n type: \"moduleRef\";\n name: string;\n };\n};\n\nexport interface SubscriptionToCallbackMap {\n events: (event: EventPayload) => Promise<void>;\n}\n\nexport function createSubscription<T extends keyof SubscriptionToCallbackMap>(\n subscription: T,\n callback: SubscriptionToCallbackMap[T],\n client: SovereignSDK,\n): Subscription {\n switch (subscription) {\n case \"events\": {\n const url = client.buildURL(\"/sequencer/events/ws\", {});\n return subscribe(\n httpToWebSocket(url),\n callback as SubscriptionToCallbackMap[\"events\"],\n );\n }\n default:\n throw new SovereignError(`Invalid subscription type '${subscription}'`);\n }\n}\n","import SovereignClient from \"@sovereign-sdk/client\";\nimport { JsSerializer } from \"@sovereign-sdk/serializers\";\nimport { type HexString, bytesToHex } from \"@sovereign-sdk/utils\";\nimport type { DeepPartial } from \"../utils\";\nimport {\n Rollup,\n type RollupConfig,\n type SignerParams,\n type TransactionContext,\n type TypeBuilder,\n type UnsignedTransactionContext,\n} from \"./rollup\";\n\nexport type TxDetails = {\n max_priority_fee_bips: number;\n max_fee: string;\n gas_limit: number[] | null;\n chain_id: number;\n};\n\nexport type Generation = { generation: number };\nexport type Nonce = { nonce: number };\nexport type Uniqueness = Nonce | Generation;\n\nexport type UnsignedTransaction<RuntimeCall> = {\n runtime_call: RuntimeCall;\n uniqueness: Uniqueness;\n details: TxDetails;\n};\n\nexport type TransactionV0<RuntimeCall> = {\n pub_key: HexString;\n signature: HexString;\n} & UnsignedTransaction<RuntimeCall>;\n\nexport type Transaction<RuntimeCall> = {\n V0: TransactionV0<RuntimeCall>;\n};\n\nexport type Dedup = {\n nonce: number;\n};\n\nexport type StandardRollupContext = {\n defaultTxDetails: TxDetails;\n};\n\nexport type StandardRollupSpec<RuntimeCall> = {\n UnsignedTransaction: UnsignedTransaction<RuntimeCall>;\n Transaction: Transaction<RuntimeCall>;\n RuntimeCall: RuntimeCall;\n Dedup: Dedup;\n};\n\nconst useOrFetchUniqueness = async <S extends StandardRollupSpec<unknown>>({\n overrides,\n}: Omit<\n UnsignedTransactionContext<S, StandardRollupContext>,\n \"runtimeCall\"\n>) => {\n if (overrides?.uniqueness) {\n return overrides.uniqueness;\n }\n\n return { generation: Date.now() };\n};\n\nexport function standardTypeBuilder<\n S extends StandardRollupSpec<unknown>,\n>(): TypeBuilder<S, StandardRollupContext> {\n return {\n async unsignedTransaction(\n context: UnsignedTransactionContext<S, StandardRollupContext>,\n ) {\n const { rollup, runtimeCall } = context;\n const { uniqueness: _, ...overrides } = context.overrides;\n const uniqueness = await useOrFetchUniqueness(context);\n const details: TxDetails = {\n ...rollup.context.defaultTxDetails,\n ...overrides.details,\n };\n\n return {\n runtime_call: runtimeCall,\n uniqueness,\n details,\n } as S[\"UnsignedTransaction\"];\n },\n async transaction({\n sender,\n signature,\n unsignedTx,\n }: TransactionContext<S, StandardRollupContext>) {\n return {\n V0: {\n pub_key: bytesToHex(sender),\n signature: bytesToHex(signature),\n ...unsignedTx,\n },\n };\n },\n };\n}\n\n/**\n * The parameters for simulating a runtime call transaction.\n */\nexport type SimulateParams = Omit<\n SovereignClient.RollupSimulateParams,\n \"call\" | \"sender\"\n> &\n SignerParams;\n\nexport class StandardRollup<RuntimeCall> extends Rollup<\n StandardRollupSpec<RuntimeCall>,\n StandardRollupContext\n> {\n /**\n * Simulates a runtime call transaction.\n *\n * This method can be useful to estimate the gas cost of a runtime call transaction.\n *\n * @param runtimeMessage - The runtime message to call.\n */\n async simulate(\n runtimeMessage: StandardRollupSpec<RuntimeCall>[\"RuntimeCall\"],\n { signer }: SimulateParams,\n ): Promise<SovereignClient.Rollup.RollupSimulateResponse> {\n const publicKey = await signer.publicKey();\n const sender = bytesToHex(publicKey);\n const call = runtimeMessage as { [key: string]: unknown };\n\n return this.rollup.simulate({ sender, call });\n }\n}\n\nexport const DEFAULT_TX_DETAILS: Omit<TxDetails, \"chain_id\"> = {\n max_priority_fee_bips: 0,\n max_fee: \"100000000\",\n gas_limit: null,\n};\n\nasync function buildContext<C extends StandardRollupContext>(\n client: SovereignClient,\n context?: DeepPartial<C>,\n): Promise<C> {\n const defaultTxDetails = {\n ...DEFAULT_TX_DETAILS,\n ...context?.defaultTxDetails,\n };\n\n if (!defaultTxDetails.chain_id) {\n const { chain_id } = await client.rollup.constants();\n\n defaultTxDetails.chain_id = chain_id;\n }\n\n return {\n defaultTxDetails,\n } as C;\n}\n\nexport async function createStandardRollup<\n RuntimeCall,\n C extends StandardRollupContext = StandardRollupContext,\n>(\n rollupConfig?: Partial<RollupConfig<DeepPartial<C>>>,\n typeBuilderOverrides?: Partial<\n TypeBuilder<StandardRollupSpec<RuntimeCall>, C>\n >,\n) {\n const config = rollupConfig ?? {};\n const client = config.client ?? new SovereignClient({ baseURL: config.url });\n const getSerializer =\n config.getSerializer ?? ((schema) => new JsSerializer(schema));\n const context = await buildContext<C>(client, config.context);\n\n // Default to the standard transaction submission endpoint\n const txSubmissionEndpoint = config.txSubmissionEndpoint ?? \"/sequencer/txs\";\n\n return new StandardRollup<RuntimeCall>(\n {\n ...config,\n client,\n getSerializer,\n context,\n txSubmissionEndpoint,\n },\n {\n ...standardTypeBuilder(),\n ...typeBuilderOverrides,\n },\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAA4C;AAC5C,oBAAwB;AAWjB,SAAS,qBACd,WACA,KACA,kBAAkB,IACV;AACR,MAAI,qBAAiB,0BAAY,SAAS;AAE1C,MAAI,oBAAoB,UAAU,QAAQ;AACxC,qBAAiB,eAAe,MAAM,GAAG,eAAe;AAAA,EAC1D;AAEA,QAAM,QAAQ,sBAAQ,QAAQ,cAAc;AAC5C,SAAO,sBAAQ,OAAO,KAAK,KAAK;AAClC;;;ACzBA,oBAA4B;AAI5B,IAAAC,gBAAuC;AACvC,uBAAuB;;;ACFhB,IAAM,iBAAN,cAA6B,MAAM;AAAA,EACxC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AAEb,SAAK,OAAO,KAAK,YAAY;AAC7B,SAAK,QAAQ,IAAI,MAAM,EAAE;AAAA,EAC3B;AACF;AAEO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B,cACA,sBAGA;AAAA;AA1KF;AA2KE,UAAM,SAAS,sCAAgB,CAAC;AAChC,UAAM,UAAS,YAAO,WAAP,YAAiB,IAAI,eAAAC,QAAgB,EAAE,SAAS,OAAO,IAAI,CAAC;AAC3E,UAAM,iBACJ,YAAO,kBAAP,YAAyB,CAAC,WAAW,IAAI,gCAAa,MAAM;AAC9D,UAAM,UAAU,MAAM,aAAgB,QAAQ,OAAO,OAAO;AAG5D,UAAM,wBAAuB,YAAO,yBAAP,YAA+B;AAE5D,WAAO,IAAI;AAAA,MACT,iCACK,SADL;AAAA,QAEE;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACA,kCACK,oBAAoB,IACpB;AAAA,IAEP;AAAA,EACF;AAAA;;;AL5LA,IAAAC,mBAAiC;","names":["SovereignClient","import_utils","IsoWebSocket","_a","subscription","SovereignClient","import_client","import_utils","_a","SovereignClient","SovereignClient"]}
package/dist/index.mjs CHANGED
@@ -113,7 +113,12 @@ function subscribe(url, callback) {
113
113
  websocket.addEventListener("message", (message) => {
114
114
  var _a2;
115
115
  const data = JSON.parse(message.data);
116
- (_a2 = _subscriptions[url]) == null ? void 0 : _a2.callbacks.forEach((cb) => cb(data));
116
+ const callbacks = (_a2 = _subscriptions[url]) == null ? void 0 : _a2.callbacks;
117
+ if (callbacks) {
118
+ for (const cb of callbacks) {
119
+ cb(data);
120
+ }
121
+ }
117
122
  });
118
123
  websocket.addEventListener(
119
124
  "error",
@@ -169,17 +174,22 @@ var Rollup = class {
169
174
  /**
170
175
  * Retrieve dedup information about the provided address.
171
176
  *
172
- * @param address - The public key to dedup.
177
+ * @param publicKey - The public key to dedup.
178
+ * TODO: How to add param for generation explicitly
173
179
  */
174
- dedup(address) {
180
+ dedup(publicKey) {
175
181
  return __async(this, null, function* () {
176
- const response = yield this.rollup.addresses.dedup(bytesToHex(address));
182
+ const credentialId = bytesToHex(publicKey);
183
+ const response = yield this.rollup.addresses.dedup(credentialId);
177
184
  return response;
178
185
  });
179
186
  }
180
187
  /**
181
188
  * Submits a transaction to the rollup.
182
189
  *
190
+ * The endpoint used for submission can be overridden via the options.path parameter.
191
+ * If not specified, the rollup's configured txSubmissionEndpoint will be used.
192
+ *
183
193
  * @param transaction - The transaction to submit.
184
194
  * @param {SovereignClient.RequestOptions} options - The options for the request.
185
195
  */
@@ -187,10 +197,14 @@ var Rollup = class {
187
197
  return __async(this, null, function* () {
188
198
  const serializer = yield this.serializer();
189
199
  const serializedTx = serializer.serializeTx(transaction);
190
- return this.sequencer.txs.create({ body: Base64.fromUint8Array(serializedTx) }, options).catch((e) => __async(this, null, function* () {
200
+ const _a = options || {}, { body: _, query: __, path } = _a, requestOptions = __objRest(_a, ["body", "query", "path"]);
201
+ const txSubmissionEndpoint = path || this._config.txSubmissionEndpoint;
202
+ return this.http.post(txSubmissionEndpoint, __spreadValues({
203
+ body: { body: Base64.fromUint8Array(serializedTx) }
204
+ }, requestOptions)).catch((e) => __async(this, null, function* () {
191
205
  if (isVersionMismatchError(e)) {
192
206
  const oldVersion = bytesToHex(yield this.chainHash());
193
- const { schema, chain_hash: newVersion } = yield this.rollup.schema.retrieve();
207
+ const { schema, chain_hash: newVersion } = yield this.rollup.schema();
194
208
  this._chainHash = hexToBytes(newVersion);
195
209
  this._serializer = this._config.getSerializer(schema);
196
210
  if (oldVersion !== newVersion) {
@@ -212,23 +226,11 @@ var Rollup = class {
212
226
  * @param unsignedTx - The unsigned transaction to sign and submit.
213
227
  * @param {SignerParams} params - The params for signing and submitting the transaction.
214
228
  * @param {SovereignClient.RequestOptions} options - The options for the request.
229
+ * @param endpoint - Optional endpoint override. If not specified, uses the rollup's configured txSubmissionEndpoint.
215
230
  */
216
231
  signAndSubmitTransaction(_0, _1, _2) {
217
232
  return __async(this, arguments, function* (unsignedTx, { signer }, options) {
218
- const serializer = yield this.serializer();
219
- const serializedUnsignedTx = serializer.serializeUnsignedTx(unsignedTx);
220
- const chainHash = yield this.chainHash();
221
- const signature = yield signer.sign(
222
- new Uint8Array([...serializedUnsignedTx, ...chainHash])
223
- );
224
- const publicKey = yield signer.publicKey();
225
- const context = {
226
- unsignedTx,
227
- sender: publicKey,
228
- signature,
229
- rollup: this
230
- };
231
- const tx = yield this._typeBuilder.transaction(context);
233
+ const tx = yield this.signTransaction(unsignedTx, signer);
232
234
  const result = yield this.submitTransaction(tx, options);
233
235
  return { transaction: tx, response: result };
234
236
  });
@@ -258,6 +260,55 @@ var Rollup = class {
258
260
  );
259
261
  });
260
262
  }
263
+ /**
264
+ * Prepares a runtime call by creating and signing a transaction without submitting it.
265
+ * This is useful for scenarios where you need the signed transaction for later submission
266
+ * or for analysis purposes.
267
+ *
268
+ * @param runtimeCall - The runtime message to prepare.
269
+ * @param params - The parameters for preparing the call.
270
+ * @param params.signer - The signer to use for signing the transaction.
271
+ * @param params.overrides - Optional overrides for the unsigned transaction.
272
+ * @returns A promise that resolves to the signed transaction.
273
+ */
274
+ prepareCall(_0, _1) {
275
+ return __async(this, arguments, function* (runtimeCall, { signer, overrides }) {
276
+ const context = {
277
+ runtimeCall,
278
+ rollup: this,
279
+ overrides: overrides != null ? overrides : {}
280
+ };
281
+ const unsignedTx = yield this._typeBuilder.unsignedTransaction(context);
282
+ return this.signTransaction(unsignedTx, signer);
283
+ });
284
+ }
285
+ /**
286
+ * Signs an unsigned transaction using the provided signer.
287
+ * Creates a signature by combining the serialized unsigned transaction with the chain hash,
288
+ * then constructs a fully signed transaction.
289
+ *
290
+ * @param unsignedTx - The unsigned transaction to sign.
291
+ * @param signer - The signer to use for signing the transaction.
292
+ * @returns A promise that resolves to the signed transaction.
293
+ */
294
+ signTransaction(unsignedTx, signer) {
295
+ return __async(this, null, function* () {
296
+ const serializer = yield this.serializer();
297
+ const serializedUnsignedTx = serializer.serializeUnsignedTx(unsignedTx);
298
+ const chainHash = yield this.chainHash();
299
+ const signature = yield signer.sign(
300
+ new Uint8Array([...serializedUnsignedTx, ...chainHash])
301
+ );
302
+ const publicKey = yield signer.publicKey();
303
+ const context = {
304
+ unsignedTx,
305
+ sender: publicKey,
306
+ signature,
307
+ rollup: this
308
+ };
309
+ return this._typeBuilder.transaction(context);
310
+ });
311
+ }
261
312
  /**
262
313
  * Create a subscription to events emitted over websockets by the rollup.
263
314
  */
@@ -313,7 +364,7 @@ var Rollup = class {
313
364
  serializer() {
314
365
  return __async(this, null, function* () {
315
366
  if (this._serializer) return this._serializer;
316
- const { schema } = yield this.rollup.schema.retrieve();
367
+ const { schema } = yield this.rollup.schema();
317
368
  this._serializer = this._config.getSerializer(schema);
318
369
  return this._serializer;
319
370
  });
@@ -327,7 +378,7 @@ var Rollup = class {
327
378
  chainHash() {
328
379
  return __async(this, null, function* () {
329
380
  if (this._chainHash) return this._chainHash;
330
- const { chain_hash } = yield this.rollup.schema.retrieve();
381
+ const { chain_hash } = yield this.rollup.schema();
331
382
  this._chainHash = hexToBytes(chain_hash);
332
383
  return this._chainHash;
333
384
  });
@@ -348,25 +399,25 @@ function isVersionMismatchError(e) {
348
399
  import SovereignClient2 from "@sovereign-sdk/client";
349
400
  import { JsSerializer } from "@sovereign-sdk/serializers";
350
401
  import { bytesToHex as bytesToHex2 } from "@sovereign-sdk/utils";
351
- var useOrFetchGeneration = (_0) => __async(void 0, [_0], function* ({
402
+ var useOrFetchUniqueness = (_0) => __async(void 0, [_0], function* ({
352
403
  overrides
353
404
  }) {
354
- if ((overrides == null ? void 0 : overrides.generation) !== void 0 && overrides.generation >= 0) {
355
- return overrides.generation;
405
+ if (overrides == null ? void 0 : overrides.uniqueness) {
406
+ return overrides.uniqueness;
356
407
  }
357
- return Date.now();
408
+ return { generation: Date.now() };
358
409
  });
359
410
  function standardTypeBuilder() {
360
411
  return {
361
412
  unsignedTransaction(context) {
362
413
  return __async(this, null, function* () {
363
414
  const { rollup, runtimeCall } = context;
364
- const _a2 = context.overrides, { generation: _ } = _a2, overrides = __objRest(_a2, ["generation"]);
365
- const generation = yield useOrFetchGeneration(context);
415
+ const _a2 = context.overrides, { uniqueness: _ } = _a2, overrides = __objRest(_a2, ["uniqueness"]);
416
+ const uniqueness = yield useOrFetchUniqueness(context);
366
417
  const details = __spreadValues(__spreadValues({}, rollup.context.defaultTxDetails), overrides.details);
367
418
  return {
368
419
  runtime_call: runtimeCall,
369
- generation,
420
+ uniqueness,
370
421
  details
371
422
  };
372
423
  });
@@ -378,16 +429,10 @@ function standardTypeBuilder() {
378
429
  unsignedTx
379
430
  }) {
380
431
  return {
381
- versioned_tx: {
382
- V0: __spreadValues({
383
- pub_key: {
384
- pub_key: sender
385
- },
386
- signature: {
387
- msg_sig: signature
388
- }
389
- }, unsignedTx)
390
- }
432
+ V0: __spreadValues({
433
+ pub_key: bytesToHex2(sender),
434
+ signature: bytesToHex2(signature)
435
+ }, unsignedTx)
391
436
  };
392
437
  });
393
438
  }
@@ -402,26 +447,11 @@ var StandardRollup = class extends Rollup {
402
447
  * @param runtimeMessage - The runtime message to call.
403
448
  */
404
449
  simulate(_0, _1) {
405
- return __async(this, arguments, function* (runtimeMessage, { signer, txDetails, generation: overrideGeneration }) {
406
- const serializer = yield this.serializer();
407
- const runtimeCall = serializer.serializeRuntimeCall(runtimeMessage);
450
+ return __async(this, arguments, function* (runtimeMessage, { signer }) {
408
451
  const publicKey = yield signer.publicKey();
409
- const generation = yield useOrFetchGeneration({
410
- rollup: this,
411
- overrides: { generation: overrideGeneration }
412
- });
413
- const response = yield this.rollup.simulate({
414
- body: {
415
- details: __spreadProps(__spreadValues({}, txDetails), {
416
- // simulate needs this field as `undefined` currently
417
- gas_limit: txDetails.gas_limit || void 0
418
- }),
419
- encoded_call_message: bytesToHex2(runtimeCall),
420
- generation,
421
- sender_pub_key: bytesToHex2(publicKey)
422
- }
423
- });
424
- return response;
452
+ const sender = bytesToHex2(publicKey);
453
+ const call = runtimeMessage;
454
+ return this.rollup.simulate({ sender, call });
425
455
  });
426
456
  }
427
457
  };
@@ -434,7 +464,7 @@ function buildContext(client, context) {
434
464
  return __async(this, null, function* () {
435
465
  const defaultTxDetails = __spreadValues(__spreadValues({}, DEFAULT_TX_DETAILS), context == null ? void 0 : context.defaultTxDetails);
436
466
  if (!defaultTxDetails.chain_id) {
437
- const { chain_id } = yield client.rollup.constants.retrieve();
467
+ const { chain_id } = yield client.rollup.constants();
438
468
  defaultTxDetails.chain_id = chain_id;
439
469
  }
440
470
  return {
@@ -444,13 +474,19 @@ function buildContext(client, context) {
444
474
  }
445
475
  function createStandardRollup(rollupConfig, typeBuilderOverrides) {
446
476
  return __async(this, null, function* () {
447
- var _a, _b;
477
+ var _a, _b, _c;
448
478
  const config = rollupConfig != null ? rollupConfig : {};
449
479
  const client = (_a = config.client) != null ? _a : new SovereignClient2({ baseURL: config.url });
450
480
  const getSerializer = (_b = config.getSerializer) != null ? _b : (schema) => new JsSerializer(schema);
451
481
  const context = yield buildContext(client, config.context);
482
+ const txSubmissionEndpoint = (_c = config.txSubmissionEndpoint) != null ? _c : "/sequencer/txs";
452
483
  return new StandardRollup(
453
- __spreadProps(__spreadValues({}, config), { client, getSerializer, context }),
484
+ __spreadProps(__spreadValues({}, config), {
485
+ client,
486
+ getSerializer,
487
+ context,
488
+ txSubmissionEndpoint
489
+ }),
454
490
  __spreadValues(__spreadValues({}, standardTypeBuilder()), typeBuilderOverrides)
455
491
  );
456
492
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/addresses.ts","../src/rollup/rollup.ts","../src/errors.ts","../src/subscriptions.ts","../src/rollup/standard-rollup.ts","../src/index.ts"],"sourcesContent":["import { type HexString, ensureBytes } from \"@sovereign-sdk/utils\";\nimport { bech32m } from \"bech32\";\n\n/**\n * Encodes a public key as a bech32m address with the given human-readable part (hrp).\n *\n * @param publicKey - The public key to encode, as a hex string or Uint8Array.\n * @param hrp - The human-readable part for the bech32m address (e.g., \"sov\").\n * @param concatPublicKey - Optional. If provided, only the first `concatPublicKey` bytes of the public key are used.\n * @returns The bech32m-encoded address as a string.\n * @throws {Error} If the public key is not a valid hex string or Uint8Array.\n */\nexport function addressFromPublicKey(\n publicKey: HexString | Uint8Array,\n hrp: string,\n concatPublicKey = 28,\n): string {\n let publicKeyBytes = ensureBytes(publicKey);\n\n if (concatPublicKey !== publicKey.length) {\n publicKeyBytes = publicKeyBytes.slice(0, concatPublicKey);\n }\n\n const words = bech32m.toWords(publicKeyBytes);\n return bech32m.encode(hrp, words);\n}\n","import SovereignClient from \"@sovereign-sdk/client\";\nimport type { APIError } from \"@sovereign-sdk/client\";\nimport type { RollupSchema, Serializer } from \"@sovereign-sdk/serializers\";\nimport type { Signer } from \"@sovereign-sdk/signers\";\nimport { bytesToHex, hexToBytes } from \"@sovereign-sdk/utils\";\nimport { Base64 } from \"js-base64\";\nimport { VersionMismatchError } from \"../errors\";\nimport {\n type Subscription,\n type SubscriptionToCallbackMap,\n createSubscription,\n} from \"../subscriptions\";\nimport type { BaseTypeSpec } from \"../type-spec\";\nimport type { DeepPartial } from \"../utils\";\n\nexport type UnsignedTransactionContext<\n S extends BaseTypeSpec,\n C extends RollupContext,\n> = {\n runtimeCall: S[\"RuntimeCall\"];\n // Provides the ability to override the generation data instead of retrieving it automatically.\n overrides: DeepPartial<S[\"UnsignedTransaction\"]>;\n rollup: Rollup<S, C>;\n};\n\nexport type TransactionContext<\n S extends BaseTypeSpec,\n C extends RollupContext,\n> = {\n unsignedTx: S[\"UnsignedTransaction\"];\n sender: Uint8Array;\n signature: Uint8Array;\n rollup: Rollup<S, C>;\n};\n\nexport type TypeBuilder<S extends BaseTypeSpec, C extends RollupContext> = {\n unsignedTransaction: (\n context: UnsignedTransactionContext<S, C>,\n ) => Promise<S[\"UnsignedTransaction\"]>;\n\n transaction: (context: TransactionContext<S, C>) => Promise<S[\"Transaction\"]>;\n};\n\n/**\n * Arbitrary context that is associated with the rollup.\n */\nexport type RollupContext = Record<string, unknown>;\n\n/**\n * The configuration for a rollup client.\n */\nexport type RollupConfig<C extends RollupContext> = {\n /**\n * The base URL of the rollup full node API.\n */\n url?: string;\n /**\n * The Sovereign SDK client to use for the rollup.\n * If not provided, the default client will be used using {@link PartialRollupConfig.url}.\n */\n client: SovereignClient;\n /**\n * Creates the serializer instance to use for the rollup.\n *\n * This can be called more than once, for example if the chain hash changes (i.e a new rollup version)\n * is detected then it will be called again with the new rollup schema.\n */\n getSerializer: (schema: RollupSchema) => Serializer;\n /**\n * Arbitrary context that is associated with the rollup.\n */\n context: C;\n};\n\n/**\n * The result of signing and submitting a transaction.\n *\n * @template Tx The type of the transaction\n */\nexport type TransactionResult<Tx> = {\n /**\n * The response from the sequencer.\n */\n response: SovereignClient.Sequencer.TxCreateResponse;\n /**\n * The transaction that was submitted.\n */\n transaction: Tx;\n};\n\n/**\n * The parameters for signing and submitting a transaction.\n */\nexport type SignerParams = {\n /**\n * The signer to use for signing the transaction.\n */\n signer: Signer;\n};\n\n/**\n * The parameters for calling executing a runtime call transaction.\n */\nexport type CallParams<S extends BaseTypeSpec> = {\n overrides?: DeepPartial<S[\"UnsignedTransaction\"]>;\n} & SignerParams;\n\n/**\n * A generic rollup client.\n *\n * @template S - The type specification for the rollup.\n * If not provided, the base type specification will be used which uses `any` for all types.\n * @template C - The context for the rollup.\n */\nexport class Rollup<S extends BaseTypeSpec, C extends RollupContext> {\n private readonly _config: RollupConfig<C>;\n private readonly _typeBuilder: TypeBuilder<S, C>;\n private _chainHash?: Uint8Array;\n private _serializer?: Serializer;\n\n /**\n * Creates a new rollup client.\n *\n * @param config - The configuration for the rollup client.\n * @param typeBuilder - The type builder for the rollup.\n */\n constructor(config: RollupConfig<C>, typeBuilder: TypeBuilder<S, C>) {\n this._config = config;\n this._typeBuilder = typeBuilder;\n }\n\n /**\n * Retrieve dedup information about the provided address.\n *\n * @param address - The public key to dedup.\n */\n async dedup(address: Uint8Array): Promise<S[\"Dedup\"]> {\n const response = await this.rollup.addresses.dedup(bytesToHex(address));\n return response as S[\"Dedup\"];\n }\n\n /**\n * Submits a transaction to the rollup.\n *\n * @param transaction - The transaction to submit.\n * @param {SovereignClient.RequestOptions} options - The options for the request.\n */\n async submitTransaction(\n transaction: S[\"Transaction\"],\n options?: SovereignClient.RequestOptions,\n ): Promise<SovereignClient.Sequencer.TxCreateResponse> {\n const serializer = await this.serializer();\n const serializedTx = serializer.serializeTx(transaction);\n\n return this.sequencer.txs\n .create({ body: Base64.fromUint8Array(serializedTx) }, options)\n .catch(async (e) => {\n if (isVersionMismatchError(e as APIError)) {\n const oldVersion = bytesToHex(await this.chainHash());\n const { schema, chain_hash: newVersion } =\n await this.rollup.schema.retrieve();\n this._chainHash = hexToBytes(newVersion);\n this._serializer = this._config.getSerializer(schema);\n\n if (oldVersion !== newVersion) {\n throw new VersionMismatchError(\n \"Schema version mismatch when submitting transaction\",\n newVersion,\n oldVersion,\n );\n }\n }\n throw e;\n });\n }\n\n /**\n * Signs and submits a transaction to the rollup.\n * Utilizes the provided signer to sign the transaction.\n *\n * @param unsignedTx - The unsigned transaction to sign and submit.\n * @param {SignerParams} params - The params for signing and submitting the transaction.\n * @param {SovereignClient.RequestOptions} options - The options for the request.\n */\n async signAndSubmitTransaction(\n unsignedTx: S[\"UnsignedTransaction\"],\n { signer }: SignerParams,\n options?: SovereignClient.RequestOptions,\n ): Promise<TransactionResult<S[\"Transaction\"]>> {\n const serializer = await this.serializer();\n const serializedUnsignedTx = serializer.serializeUnsignedTx(unsignedTx);\n const chainHash = await this.chainHash();\n const signature = await signer.sign(\n new Uint8Array([...serializedUnsignedTx, ...chainHash]),\n );\n const publicKey = await signer.publicKey();\n const context = {\n unsignedTx,\n sender: publicKey,\n signature,\n rollup: this,\n };\n const tx = await this._typeBuilder.transaction(context);\n const result = await this.submitTransaction(tx, options);\n\n return { transaction: tx, response: result };\n }\n\n /**\n * Performs a runtime call transaction.\n * Utilizes the provided signer to sign the transaction.\n *\n * @param runtimeCall - The runtime message to call.\n * @param {CallParams<S>} params - The params for submitting a runtime call transaction.\n * @param {SovereignClient.RequestOptions} options - The options for the request.\n */\n async call(\n runtimeCall: S[\"RuntimeCall\"],\n { signer, overrides }: CallParams<S>,\n options?: SovereignClient.RequestOptions,\n ): Promise<TransactionResult<S[\"Transaction\"]>> {\n const context = {\n runtimeCall,\n rollup: this,\n overrides: overrides ?? ({} as DeepPartial<S[\"UnsignedTransaction\"]>),\n };\n const unsignedTx = await this._typeBuilder.unsignedTransaction(context);\n\n return this.signAndSubmitTransaction(\n unsignedTx,\n {\n signer,\n },\n options,\n );\n }\n\n /**\n * Create a subscription to events emitted over websockets by the rollup.\n */\n subscribe<T extends keyof SubscriptionToCallbackMap>(\n type: T,\n callback: SubscriptionToCallbackMap[T],\n ): Subscription {\n return createSubscription(type, callback, this.http);\n }\n\n /**\n * Performs a healthcheck against the rollup to determine if it is currently healthy.\n *\n * @param timeout - Request timeout in milliseconds.\n * @returns `true` if the rollup is considered healthy otherwise `false`.\n */\n async healthcheck(timeout = 5000): Promise<boolean> {\n try {\n await this.http.get(\"/healthcheck\", { timeout, maxRetries: 1 });\n return true;\n } catch (e) {\n return !(e instanceof SovereignClient.APIConnectionError);\n }\n }\n\n /**\n * A ledger client that can be used to query the ledger.\n */\n get ledger(): SovereignClient.Ledger {\n return this.http.ledger;\n }\n\n /**\n * A sequencer client that can be used to submit transactions & batches to the rollup.\n */\n get sequencer(): SovereignClient.Sequencer {\n return this.http.sequencer;\n }\n\n /**\n * A rollup client that can be used to perform operations on the rollup.\n */\n get rollup(): SovereignClient.Rollup {\n return this.http.rollup;\n }\n\n /**\n * A client that can be used to perform HTTP requests to the Sovereign API.\n * This can be used as an escape hatch to execute arbitrary requests to the Sovereign API\n * if the operation is not supported by `ledger`, `sequencer`, or `rollup` clients.\n */\n get http(): SovereignClient {\n return this._config.client;\n }\n\n /**\n * The serializer for the rollup.\n * Can be used to serialize transactions, runtime calls, etc.\n */\n async serializer(): Promise<Serializer> {\n if (this._serializer) return this._serializer;\n const { schema } = await this.rollup.schema.retrieve();\n this._serializer = this._config.getSerializer(schema);\n return this._serializer;\n }\n\n /**\n * The context for the rollup.\n */\n get context(): C {\n return this._config.context;\n }\n\n async chainHash(): Promise<Uint8Array> {\n if (this._chainHash) return this._chainHash;\n const { chain_hash } = await this.rollup.schema.retrieve();\n this._chainHash = hexToBytes(chain_hash);\n return this._chainHash;\n }\n}\n\nfunction isVersionMismatchError(e: APIError): boolean {\n if (\n // biome-ignore lint/suspicious/noExplicitAny: yolo\n (e.error as any)?.details?.error?.includes(\"Signature verification failed\")\n ) {\n return true;\n }\n\n return false;\n}\n","/**\n * Base error class for Sovereign SDK Web3.\n */\nexport class SovereignError extends Error {\n constructor(message: string) {\n super(message);\n\n this.name = this.constructor.name;\n this.stack = new Error().stack;\n }\n}\n\nexport class InvalidRollupConfigError extends SovereignError {}\n\nexport class VersionMismatchError extends SovereignError {\n public readonly newVersion: string;\n public readonly currentVersion: string;\n public readonly retryable: boolean;\n\n constructor(message: string, newVersion: string, currentVersion: string) {\n super(message);\n\n this.newVersion = newVersion;\n this.currentVersion = currentVersion;\n this.retryable = newVersion !== currentVersion;\n }\n}\n\nexport class SchemaError extends SovereignError {\n public readonly schema: object;\n public readonly reason: string;\n\n constructor(message: string, reason: string, schema: object) {\n super(`${message}: ${reason}`);\n\n this.reason = reason;\n this.schema = schema;\n }\n}\n","import type SovereignSDK from \"@sovereign-sdk/client\";\nimport IsoWebSocket from \"isomorphic-ws\";\nimport { WebSocket } from \"partysocket\";\nimport { SovereignError } from \"./errors\";\n\ntype Url = string;\n\nexport function httpToWebSocket(url: string) {\n return url.replace(/^http(s?):\\/\\//, (_, s) => `ws${s}://`);\n}\n\nexport type Subscription = {\n /** Url providing the subscription. */\n url: Url;\n /** Unsubscribe this subscription. */\n unsubscribe: () => void;\n};\n\ntype SubscriptionEntry = {\n websocket: WebSocket;\n // biome-ignore lint/suspicious/noExplicitAny: allow\n callbacks: Array<(...args: any[]) => void>;\n};\n\nexport const _subscriptions: Record<Url, SubscriptionEntry> = {};\n\n/** Subscribe to the provided websocket url & call the provided callback on messages received. */\nexport function subscribe(\n url: Url,\n // biome-ignore lint/suspicious/noExplicitAny: allow\n callback: (...args: any[]) => void,\n): Subscription {\n const subscription = _subscriptions[url];\n\n if (!subscription) {\n const websocket = new WebSocket(url, [], { WebSocket: IsoWebSocket });\n // bun compatibility: https://github.com/partykit/partykit/issues/774\n websocket.binaryType = \"arraybuffer\";\n\n _subscriptions[url] = {\n websocket,\n callbacks: [callback],\n };\n\n websocket.addEventListener(\"message\", (message) => {\n const data = JSON.parse(message.data);\n _subscriptions[url]?.callbacks.forEach((cb) => cb(data));\n });\n websocket.addEventListener(\"error\", (e) =>\n console.log(\"Websocket error\", e),\n );\n } else {\n subscription.callbacks.push(callback);\n }\n\n const callbackIndex = _subscriptions[url]?.callbacks.length - 1;\n\n return {\n get url() {\n return url;\n },\n unsubscribe() {\n const subscription = _subscriptions[url];\n\n if (!subscription) {\n return;\n }\n\n subscription.callbacks.splice(callbackIndex, 1);\n\n if (!subscription.callbacks.length) {\n subscription.websocket.close();\n delete _subscriptions[url];\n }\n },\n };\n}\n\nexport type EventPayload = {\n tx_hash: string;\n type: \"event\";\n number: number;\n key: string;\n value: Record<string, unknown>;\n module: {\n type: \"moduleRef\";\n name: string;\n };\n};\n\nexport interface SubscriptionToCallbackMap {\n events: (event: EventPayload) => Promise<void>;\n}\n\nexport function createSubscription<T extends keyof SubscriptionToCallbackMap>(\n subscription: T,\n callback: SubscriptionToCallbackMap[T],\n client: SovereignSDK,\n): Subscription {\n switch (subscription) {\n case \"events\": {\n const url = client.buildURL(\"/sequencer/events/ws\", {});\n return subscribe(\n httpToWebSocket(url),\n callback as SubscriptionToCallbackMap[\"events\"],\n );\n }\n default:\n throw new SovereignError(`Invalid subscription type '${subscription}'`);\n }\n}\n","import SovereignClient from \"@sovereign-sdk/client\";\nimport { JsSerializer } from \"@sovereign-sdk/serializers\";\nimport { bytesToHex } from \"@sovereign-sdk/utils\";\nimport type { DeepPartial } from \"../utils\";\nimport {\n Rollup,\n type RollupConfig,\n type SignerParams,\n type TransactionContext,\n type TypeBuilder,\n type UnsignedTransactionContext,\n} from \"./rollup\";\n\nexport type TxDetails = {\n max_priority_fee_bips: number;\n max_fee: string;\n gas_limit: number[] | null;\n chain_id: number;\n};\n\nexport type UnsignedTransaction<RuntimeCall> = {\n runtime_call: RuntimeCall;\n generation: number;\n details: TxDetails;\n};\n\nexport type TransactionV0<RuntimeCall> = {\n pub_key: { pub_key: Uint8Array };\n signature: { msg_sig: Uint8Array };\n} & UnsignedTransaction<RuntimeCall>;\n\nexport type Transaction<RuntimeCall> = {\n versioned_tx: { V0: TransactionV0<RuntimeCall> };\n};\n\nexport type Dedup = {\n nonce: number;\n};\n\nexport type StandardRollupContext = {\n defaultTxDetails: TxDetails;\n};\n\nexport type StandardRollupSpec<RuntimeCall> = {\n UnsignedTransaction: UnsignedTransaction<RuntimeCall>;\n Transaction: Transaction<RuntimeCall>;\n RuntimeCall: RuntimeCall;\n Dedup: Dedup;\n};\n\nconst useOrFetchGeneration = async <S extends StandardRollupSpec<unknown>>({\n overrides,\n}: Omit<\n UnsignedTransactionContext<S, StandardRollupContext>,\n \"runtimeCall\"\n>) => {\n if (overrides?.generation !== undefined && overrides.generation >= 0) {\n return overrides.generation;\n }\n\n return Date.now();\n};\n\nexport function standardTypeBuilder<\n S extends StandardRollupSpec<unknown>,\n>(): TypeBuilder<S, StandardRollupContext> {\n return {\n async unsignedTransaction(\n context: UnsignedTransactionContext<S, StandardRollupContext>,\n ) {\n const { rollup, runtimeCall } = context;\n const { generation: _, ...overrides } = context.overrides;\n const generation = await useOrFetchGeneration(context);\n const details: TxDetails = {\n ...rollup.context.defaultTxDetails,\n ...overrides.details,\n };\n\n return {\n runtime_call: runtimeCall,\n generation,\n details,\n };\n },\n async transaction({\n sender,\n signature,\n unsignedTx,\n }: TransactionContext<S, StandardRollupContext>) {\n return {\n versioned_tx: {\n V0: {\n pub_key: {\n pub_key: sender,\n },\n signature: {\n msg_sig: signature,\n },\n ...unsignedTx,\n },\n },\n };\n },\n };\n}\n\n/**\n * The parameters for simulating a runtime call transaction.\n */\nexport type SimulateParams = {\n /**\n * The transaction details to use for the simulation.\n */\n txDetails: TxDetails;\n\n /** The generation of the transaction for uniquness purposes. */\n generation?: number;\n} & SignerParams;\n\nexport class StandardRollup<RuntimeCall> extends Rollup<\n StandardRollupSpec<RuntimeCall>,\n StandardRollupContext\n> {\n /**\n * Simulates a runtime call transaction.\n *\n * This method can be useful to estimate the gas cost of a runtime call transaction.\n *\n * @param runtimeMessage - The runtime message to call.\n */\n async simulate(\n runtimeMessage: StandardRollupSpec<RuntimeCall>[\"RuntimeCall\"],\n { signer, txDetails, generation: overrideGeneration }: SimulateParams,\n ): Promise<SovereignClient.Rollup.SimulateExecutionResponse> {\n const serializer = await this.serializer();\n const runtimeCall = serializer.serializeRuntimeCall(runtimeMessage);\n const publicKey = await signer.publicKey();\n const generation = await useOrFetchGeneration({\n rollup: this,\n overrides: { generation: overrideGeneration },\n });\n const response = await this.rollup.simulate({\n body: {\n details: {\n ...txDetails,\n // simulate needs this field as `undefined` currently\n gas_limit: txDetails.gas_limit || undefined,\n },\n encoded_call_message: bytesToHex(runtimeCall),\n generation,\n sender_pub_key: bytesToHex(publicKey),\n },\n });\n\n return response;\n }\n}\n\nexport const DEFAULT_TX_DETAILS: Omit<TxDetails, \"chain_id\"> = {\n max_priority_fee_bips: 0,\n max_fee: \"100000000\",\n gas_limit: null,\n};\n\nasync function buildContext<C extends StandardRollupContext>(\n client: SovereignClient,\n context?: DeepPartial<C>,\n): Promise<C> {\n const defaultTxDetails = {\n ...DEFAULT_TX_DETAILS,\n ...context?.defaultTxDetails,\n };\n\n if (!defaultTxDetails.chain_id) {\n const { chain_id } = await client.rollup.constants.retrieve();\n\n defaultTxDetails.chain_id = chain_id;\n }\n\n return {\n defaultTxDetails,\n } as C;\n}\n\nexport async function createStandardRollup<\n RuntimeCall,\n C extends StandardRollupContext = StandardRollupContext,\n>(\n rollupConfig?: Partial<RollupConfig<DeepPartial<C>>>,\n typeBuilderOverrides?: Partial<\n TypeBuilder<StandardRollupSpec<RuntimeCall>, C>\n >,\n) {\n const config = rollupConfig ?? {};\n const client = config.client ?? new SovereignClient({ baseURL: config.url });\n const getSerializer =\n config.getSerializer ?? ((schema) => new JsSerializer(schema));\n const context = await buildContext<C>(client, config.context);\n\n return new StandardRollup<RuntimeCall>(\n { ...config, client, getSerializer, context },\n {\n ...standardTypeBuilder(),\n ...typeBuilderOverrides,\n },\n );\n}\n","export * from \"./addresses\";\nexport * from \"./rollup\";\nexport * from \"./errors\";\nexport * from \"./type-spec\";\nexport { type EventPayload, Subscription } from \"./subscriptions\";\nexport * as SovereignClient from \"@sovereign-sdk/client\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAyB,mBAAmB;AAC5C,SAAS,eAAe;AAWjB,SAAS,qBACd,WACA,KACA,kBAAkB,IACV;AACR,MAAI,iBAAiB,YAAY,SAAS;AAE1C,MAAI,oBAAoB,UAAU,QAAQ;AACxC,qBAAiB,eAAe,MAAM,GAAG,eAAe;AAAA,EAC1D;AAEA,QAAM,QAAQ,QAAQ,QAAQ,cAAc;AAC5C,SAAO,QAAQ,OAAO,KAAK,KAAK;AAClC;;;ACzBA,OAAO,qBAAqB;AAI5B,SAAS,YAAY,kBAAkB;AACvC,SAAS,cAAc;;;ACFhB,IAAM,iBAAN,cAA6B,MAAM;AAAA,EACxC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AAEb,SAAK,OAAO,KAAK,YAAY;AAC7B,SAAK,QAAQ,IAAI,MAAM,EAAE;AAAA,EAC3B;AACF;AAEO,IAAM,2BAAN,cAAuC,eAAe;AAAC;AAEvD,IAAM,uBAAN,cAAmC,eAAe;AAAA,EAKvD,YAAY,SAAiB,YAAoB,gBAAwB;AACvE,UAAM,OAAO;AAEb,SAAK,aAAa;AAClB,SAAK,iBAAiB;AACtB,SAAK,YAAY,eAAe;AAAA,EAClC;AACF;AAEO,IAAM,cAAN,cAA0B,eAAe;AAAA,EAI9C,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,MAC9C,CAAC;AACD,YAAM,WAAW,MAAM,KAAK,OAAO,SAAS;AAAA,QAC1C,MAAM;AAAA,UACJ,SAAS,iCACJ,YADI;AAAA;AAAA,YAGP,WAAW,UAAU,aAAa;AAAA,UACpC;AAAA,UACA,sBAAsBC,YAAW,WAAW;AAAA,UAC5C;AAAA,UACA,gBAAgBA,YAAW,SAAS;AAAA,QACtC;AAAA,MACF,CAAC;AAED,aAAO;AAAA,IACT;AAAA;AACF;AAEO,IAAM,qBAAkD;AAAA,EAC7D,uBAAuB;AAAA,EACvB,SAAS;AAAA,EACT,WAAW;AACb;AAEA,SAAe,aACb,QACA,SACY;AAAA;AACZ,UAAM,mBAAmB,kCACpB,qBACA,mCAAS;AAGd,QAAI,CAAC,iBAAiB,UAAU;AAC9B,YAAM,EAAE,SAAS,IAAI,MAAM,OAAO,OAAO,UAAU,SAAS;AAE5D,uBAAiB,WAAW;AAAA,IAC9B;AAEA,WAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF;AAAA;AAEA,SAAsB,qBAIpB,cACA,sBAGA;AAAA;AAhMF;AAiME,UAAM,SAAS,sCAAgB,CAAC;AAChC,UAAM,UAAS,YAAO,WAAP,YAAiB,IAAIC,iBAAgB,EAAE,SAAS,OAAO,IAAI,CAAC;AAC3E,UAAM,iBACJ,YAAO,kBAAP,YAAyB,CAAC,WAAW,IAAI,aAAa,MAAM;AAC9D,UAAM,UAAU,MAAM,aAAgB,QAAQ,OAAO,OAAO;AAE5D,WAAO,IAAI;AAAA,MACT,iCAAK,SAAL,EAAa,QAAQ,eAAe,QAAQ;AAAA,MAC5C,kCACK,oBAAoB,IACpB;AAAA,IAEP;AAAA,EACF;AAAA;;;ACzMA,YAAYC,sBAAqB;","names":["_a","subscription","SovereignClient","bytesToHex","_a","bytesToHex","SovereignClient","SovereignClient"]}
1
+ {"version":3,"sources":["../src/addresses.ts","../src/rollup/rollup.ts","../src/errors.ts","../src/subscriptions.ts","../src/rollup/standard-rollup.ts","../src/index.ts"],"sourcesContent":["import { type HexString, ensureBytes } from \"@sovereign-sdk/utils\";\nimport { bech32m } from \"bech32\";\n\n/**\n * Encodes a public key as a bech32m address with the given human-readable part (hrp).\n *\n * @param publicKey - The public key to encode, as a hex string or Uint8Array.\n * @param hrp - The human-readable part for the bech32m address (e.g., \"sov\").\n * @param concatPublicKey - Optional. If provided, only the first `concatPublicKey` bytes of the public key are used.\n * @returns The bech32m-encoded address as a string.\n * @throws {Error} If the public key is not a valid hex string or Uint8Array.\n */\nexport function addressFromPublicKey(\n publicKey: HexString | Uint8Array,\n hrp: string,\n concatPublicKey = 28,\n): string {\n let publicKeyBytes = ensureBytes(publicKey);\n\n if (concatPublicKey !== publicKey.length) {\n publicKeyBytes = publicKeyBytes.slice(0, concatPublicKey);\n }\n\n const words = bech32m.toWords(publicKeyBytes);\n return bech32m.encode(hrp, words);\n}\n","import SovereignClient from \"@sovereign-sdk/client\";\nimport type { APIError } from \"@sovereign-sdk/client\";\nimport type { RollupSchema, Serializer } from \"@sovereign-sdk/serializers\";\nimport type { Signer } from \"@sovereign-sdk/signers\";\nimport { bytesToHex, hexToBytes } from \"@sovereign-sdk/utils\";\nimport { Base64 } from \"js-base64\";\nimport { VersionMismatchError } from \"../errors\";\nimport {\n type Subscription,\n type SubscriptionToCallbackMap,\n createSubscription,\n} from \"../subscriptions\";\nimport type { BaseTypeSpec } from \"../type-spec\";\nimport type { DeepPartial } from \"../utils\";\n\nexport type UnsignedTransactionContext<\n S extends BaseTypeSpec,\n C extends RollupContext,\n> = {\n runtimeCall: S[\"RuntimeCall\"];\n // Provides the ability to override the generation data instead of retrieving it automatically.\n overrides: DeepPartial<S[\"UnsignedTransaction\"]>;\n rollup: Rollup<S, C>;\n};\n\nexport type TransactionContext<\n S extends BaseTypeSpec,\n C extends RollupContext,\n> = {\n unsignedTx: S[\"UnsignedTransaction\"];\n sender: Uint8Array;\n signature: Uint8Array;\n rollup: Rollup<S, C>;\n};\n\nexport type TypeBuilder<S extends BaseTypeSpec, C extends RollupContext> = {\n unsignedTransaction: (\n context: UnsignedTransactionContext<S, C>,\n ) => Promise<S[\"UnsignedTransaction\"]>;\n\n transaction: (context: TransactionContext<S, C>) => Promise<S[\"Transaction\"]>;\n};\n\n/**\n * Arbitrary context that is associated with the rollup.\n */\nexport type RollupContext = Record<string, unknown>;\n\n/**\n * The configuration for a rollup client.\n */\nexport type RollupConfig<C extends RollupContext> = {\n /**\n * The base URL of the rollup full node API.\n */\n url?: string;\n /**\n * The Sovereign SDK client to use for the rollup.\n * If not provided, the default client will be used using {@link PartialRollupConfig.url}.\n */\n client: SovereignClient;\n /**\n * Creates the serializer instance to use for the rollup.\n *\n * This can be called more than once, for example if the chain hash changes (i.e a new rollup version)\n * is detected then it will be called again with the new rollup schema.\n */\n getSerializer: (schema: RollupSchema) => Serializer;\n /**\n * Arbitrary context that is associated with the rollup.\n */\n context: C;\n /**\n * The endpoint path for submitting transactions.\n * Defaults to \"/sequencer/txs\", the standard Sovereign SDK endpoint.\n * Can be overridden if your rollup is configured to expose non-standard endpoints in\n * order to support multiple different transaction encoding or authentication schemes.\n */\n txSubmissionEndpoint: string;\n};\n\n/**\n * The result of signing and submitting a transaction.\n *\n * @template Tx The type of the transaction\n */\nexport type TransactionResult<Tx> = {\n /**\n * The response from the sequencer.\n */\n response: SovereignClient.Sequencer.TxCreateResponse;\n /**\n * The transaction that was submitted.\n */\n transaction: Tx;\n};\n\n/**\n * The parameters for signing and submitting a transaction.\n */\nexport type SignerParams = {\n /**\n * The signer to use for signing the transaction.\n */\n signer: Signer;\n};\n\n/**\n * The parameters for calling executing a runtime call transaction.\n */\nexport type CallParams<S extends BaseTypeSpec> = {\n overrides?: DeepPartial<S[\"UnsignedTransaction\"]>;\n} & SignerParams;\n\n/**\n * A generic rollup client.\n *\n * @template S - The type specification for the rollup.\n * If not provided, the base type specification will be used which uses `any` for all types.\n * @template C - The context for the rollup.\n */\nexport class Rollup<S extends BaseTypeSpec, C extends RollupContext> {\n private readonly _config: RollupConfig<C>;\n private readonly _typeBuilder: TypeBuilder<S, C>;\n private _chainHash?: Uint8Array;\n private _serializer?: Serializer;\n\n /**\n * Creates a new rollup client.\n *\n * @param config - The configuration for the rollup client.\n * @param typeBuilder - The type builder for the rollup.\n */\n constructor(config: RollupConfig<C>, typeBuilder: TypeBuilder<S, C>) {\n this._config = config;\n this._typeBuilder = typeBuilder;\n }\n\n /**\n * Retrieve dedup information about the provided address.\n *\n * @param publicKey - The public key to dedup.\n * TODO: How to add param for generation explicitly\n */\n async dedup(publicKey: Uint8Array): Promise<S[\"Dedup\"]> {\n // for public key credential id is just its bytes representation\n const credentialId = bytesToHex(publicKey);\n const response = await this.rollup.addresses.dedup(credentialId);\n return response as S[\"Dedup\"];\n }\n\n /**\n * Submits a transaction to the rollup.\n *\n * The endpoint used for submission can be overridden via the options.path parameter.\n * If not specified, the rollup's configured txSubmissionEndpoint will be used.\n *\n * @param transaction - The transaction to submit.\n * @param {SovereignClient.RequestOptions} options - The options for the request.\n */\n async submitTransaction(\n transaction: S[\"Transaction\"],\n options?: SovereignClient.RequestOptions,\n ): Promise<SovereignClient.Sequencer.TxCreateResponse> {\n const serializer = await this.serializer();\n const serializedTx = serializer.serializeTx(transaction);\n // Stainless RequestOptions is generic internally, causing issues for `body` and `query`.\n // That's fine since we supply the `body` and transaction submission doesn't take query parameters.\n // So we hack around this by destructuring them out.\n const { body: _, query: __, path, ...requestOptions } = options || {};\n const txSubmissionEndpoint = path || this._config.txSubmissionEndpoint;\n\n return this.http\n .post<SovereignClient.Sequencer.TxCreateResponse>(txSubmissionEndpoint, {\n body: { body: Base64.fromUint8Array(serializedTx) },\n ...requestOptions,\n })\n .catch(async (e) => {\n if (isVersionMismatchError(e as APIError)) {\n const oldVersion = bytesToHex(await this.chainHash());\n const { schema, chain_hash: newVersion } = await this.rollup.schema();\n this._chainHash = hexToBytes(newVersion);\n this._serializer = this._config.getSerializer(schema);\n\n if (oldVersion !== newVersion) {\n throw new VersionMismatchError(\n \"Schema version mismatch when submitting transaction\",\n newVersion,\n oldVersion,\n );\n }\n }\n throw e;\n });\n }\n\n /**\n * Signs and submits a transaction to the rollup.\n * Utilizes the provided signer to sign the transaction.\n *\n * @param unsignedTx - The unsigned transaction to sign and submit.\n * @param {SignerParams} params - The params for signing and submitting the transaction.\n * @param {SovereignClient.RequestOptions} options - The options for the request.\n * @param endpoint - Optional endpoint override. If not specified, uses the rollup's configured txSubmissionEndpoint.\n */\n async signAndSubmitTransaction(\n unsignedTx: S[\"UnsignedTransaction\"],\n { signer }: SignerParams,\n options?: SovereignClient.RequestOptions,\n ): Promise<TransactionResult<S[\"Transaction\"]>> {\n const tx = await this.signTransaction(unsignedTx, signer);\n const result = await this.submitTransaction(tx, options);\n\n return { transaction: tx, response: result };\n }\n\n /**\n * Performs a runtime call transaction.\n * Utilizes the provided signer to sign the transaction.\n *\n * @param runtimeCall - The runtime message to call.\n * @param {CallParams<S>} params - The params for submitting a runtime call transaction.\n * @param {SovereignClient.RequestOptions} options - The options for the request.\n */\n async call(\n runtimeCall: S[\"RuntimeCall\"],\n { signer, overrides }: CallParams<S>,\n options?: SovereignClient.RequestOptions,\n ): Promise<TransactionResult<S[\"Transaction\"]>> {\n const context = {\n runtimeCall,\n rollup: this,\n overrides: overrides ?? ({} as DeepPartial<S[\"UnsignedTransaction\"]>),\n };\n const unsignedTx = await this._typeBuilder.unsignedTransaction(context);\n\n return this.signAndSubmitTransaction(\n unsignedTx,\n {\n signer,\n },\n options,\n );\n }\n\n /**\n * Prepares a runtime call by creating and signing a transaction without submitting it.\n * This is useful for scenarios where you need the signed transaction for later submission\n * or for analysis purposes.\n *\n * @param runtimeCall - The runtime message to prepare.\n * @param params - The parameters for preparing the call.\n * @param params.signer - The signer to use for signing the transaction.\n * @param params.overrides - Optional overrides for the unsigned transaction.\n * @returns A promise that resolves to the signed transaction.\n */\n async prepareCall(\n runtimeCall: S[\"RuntimeCall\"],\n { signer, overrides }: CallParams<S>,\n ): Promise<S[\"Transaction\"]> {\n const context = {\n runtimeCall,\n rollup: this,\n overrides: overrides ?? ({} as DeepPartial<S[\"UnsignedTransaction\"]>),\n };\n const unsignedTx = await this._typeBuilder.unsignedTransaction(context);\n return this.signTransaction(unsignedTx, signer);\n }\n\n /**\n * Signs an unsigned transaction using the provided signer.\n * Creates a signature by combining the serialized unsigned transaction with the chain hash,\n * then constructs a fully signed transaction.\n *\n * @param unsignedTx - The unsigned transaction to sign.\n * @param signer - The signer to use for signing the transaction.\n * @returns A promise that resolves to the signed transaction.\n */\n async signTransaction(\n unsignedTx: S[\"UnsignedTransaction\"],\n signer: Signer,\n ): Promise<S[\"Transaction\"]> {\n const serializer = await this.serializer();\n const serializedUnsignedTx = serializer.serializeUnsignedTx(unsignedTx);\n const chainHash = await this.chainHash();\n const signature = await signer.sign(\n new Uint8Array([...serializedUnsignedTx, ...chainHash]),\n );\n const publicKey = await signer.publicKey();\n const context = {\n unsignedTx,\n sender: publicKey,\n signature,\n rollup: this,\n };\n return this._typeBuilder.transaction(context);\n }\n\n /**\n * Create a subscription to events emitted over websockets by the rollup.\n */\n subscribe<T extends keyof SubscriptionToCallbackMap>(\n type: T,\n callback: SubscriptionToCallbackMap[T],\n ): Subscription {\n return createSubscription(type, callback, this.http);\n }\n\n /**\n * Performs a healthcheck against the rollup to determine if it is currently healthy.\n *\n * @param timeout - Request timeout in milliseconds.\n * @returns `true` if the rollup is considered healthy otherwise `false`.\n */\n async healthcheck(timeout = 5000): Promise<boolean> {\n try {\n await this.http.get(\"/healthcheck\", { timeout, maxRetries: 1 });\n return true;\n } catch (e) {\n return !(e instanceof SovereignClient.APIConnectionError);\n }\n }\n\n /**\n * A ledger client that can be used to query the ledger.\n */\n get ledger(): SovereignClient.Ledger {\n return this.http.ledger;\n }\n\n /**\n * A sequencer client that can be used to submit transactions & batches to the rollup.\n */\n get sequencer(): SovereignClient.Sequencer {\n return this.http.sequencer;\n }\n\n /**\n * A rollup client that can be used to perform operations on the rollup.\n */\n get rollup(): SovereignClient.Rollup {\n return this.http.rollup;\n }\n\n /**\n * A client that can be used to perform HTTP requests to the Sovereign API.\n * This can be used as an escape hatch to execute arbitrary requests to the Sovereign API\n * if the operation is not supported by `ledger`, `sequencer`, or `rollup` clients.\n */\n get http(): SovereignClient {\n return this._config.client;\n }\n\n /**\n * The serializer for the rollup.\n * Can be used to serialize transactions, runtime calls, etc.\n */\n async serializer(): Promise<Serializer> {\n if (this._serializer) return this._serializer;\n const { schema } = await this.rollup.schema();\n this._serializer = this._config.getSerializer(schema);\n return this._serializer;\n }\n\n /**\n * The context for the rollup.\n */\n get context(): C {\n return this._config.context;\n }\n\n async chainHash(): Promise<Uint8Array> {\n if (this._chainHash) return this._chainHash;\n const { chain_hash } = await this.rollup.schema();\n this._chainHash = hexToBytes(chain_hash);\n return this._chainHash;\n }\n}\n\nfunction isVersionMismatchError(e: APIError): boolean {\n if (\n // biome-ignore lint/suspicious/noExplicitAny: yolo\n (e.error as any)?.details?.error?.includes(\"Signature verification failed\")\n ) {\n return true;\n }\n\n return false;\n}\n","/**\n * Base error class for Sovereign SDK Web3.\n */\nexport class SovereignError extends Error {\n constructor(message: string) {\n super(message);\n\n this.name = this.constructor.name;\n this.stack = new Error().stack;\n }\n}\n\nexport class InvalidRollupConfigError extends SovereignError {}\n\nexport class VersionMismatchError extends SovereignError {\n public readonly newVersion: string;\n public readonly currentVersion: string;\n public readonly retryable: boolean;\n\n constructor(message: string, newVersion: string, currentVersion: string) {\n super(message);\n\n this.newVersion = newVersion;\n this.currentVersion = currentVersion;\n this.retryable = newVersion !== currentVersion;\n }\n}\n\nexport class SchemaError extends SovereignError {\n public readonly schema: object;\n public readonly reason: string;\n\n constructor(message: string, reason: string, schema: object) {\n super(`${message}: ${reason}`);\n\n this.reason = reason;\n this.schema = schema;\n }\n}\n","import type SovereignSDK from \"@sovereign-sdk/client\";\nimport IsoWebSocket from \"isomorphic-ws\";\nimport { WebSocket } from \"partysocket\";\nimport { SovereignError } from \"./errors\";\n\ntype Url = string;\n\nexport function httpToWebSocket(url: string) {\n return url.replace(/^http(s?):\\/\\//, (_, s) => `ws${s}://`);\n}\n\nexport type Subscription = {\n /** Url providing the subscription. */\n url: Url;\n /** Unsubscribe this subscription. */\n unsubscribe: () => void;\n};\n\ntype SubscriptionEntry = {\n websocket: WebSocket;\n // biome-ignore lint/suspicious/noExplicitAny: allow\n callbacks: Array<(...args: any[]) => void>;\n};\n\nexport const _subscriptions: Record<Url, SubscriptionEntry> = {};\n\n/** Subscribe to the provided websocket url & call the provided callback on messages received. */\nexport function subscribe(\n url: Url,\n // biome-ignore lint/suspicious/noExplicitAny: allow\n callback: (...args: any[]) => void,\n): Subscription {\n const subscription = _subscriptions[url];\n\n if (!subscription) {\n const websocket = new WebSocket(url, [], { WebSocket: IsoWebSocket });\n // bun compatibility: https://github.com/partykit/partykit/issues/774\n websocket.binaryType = \"arraybuffer\";\n\n _subscriptions[url] = {\n websocket,\n callbacks: [callback],\n };\n\n websocket.addEventListener(\"message\", (message) => {\n const data = JSON.parse(message.data);\n const callbacks = _subscriptions[url]?.callbacks;\n if (callbacks) {\n for (const cb of callbacks) {\n cb(data);\n }\n }\n });\n websocket.addEventListener(\"error\", (e) =>\n console.log(\"Websocket error\", e),\n );\n } else {\n subscription.callbacks.push(callback);\n }\n\n const callbackIndex = _subscriptions[url]?.callbacks.length - 1;\n\n return {\n get url() {\n return url;\n },\n unsubscribe() {\n const subscription = _subscriptions[url];\n\n if (!subscription) {\n return;\n }\n\n subscription.callbacks.splice(callbackIndex, 1);\n\n if (!subscription.callbacks.length) {\n subscription.websocket.close();\n delete _subscriptions[url];\n }\n },\n };\n}\n\nexport type EventPayload = {\n tx_hash: string;\n type: \"event\";\n number: number;\n key: string;\n value: Record<string, unknown>;\n module: {\n type: \"moduleRef\";\n name: string;\n };\n};\n\nexport interface SubscriptionToCallbackMap {\n events: (event: EventPayload) => Promise<void>;\n}\n\nexport function createSubscription<T extends keyof SubscriptionToCallbackMap>(\n subscription: T,\n callback: SubscriptionToCallbackMap[T],\n client: SovereignSDK,\n): Subscription {\n switch (subscription) {\n case \"events\": {\n const url = client.buildURL(\"/sequencer/events/ws\", {});\n return subscribe(\n httpToWebSocket(url),\n callback as SubscriptionToCallbackMap[\"events\"],\n );\n }\n default:\n throw new SovereignError(`Invalid subscription type '${subscription}'`);\n }\n}\n","import SovereignClient from \"@sovereign-sdk/client\";\nimport { JsSerializer } from \"@sovereign-sdk/serializers\";\nimport { type HexString, bytesToHex } from \"@sovereign-sdk/utils\";\nimport type { DeepPartial } from \"../utils\";\nimport {\n Rollup,\n type RollupConfig,\n type SignerParams,\n type TransactionContext,\n type TypeBuilder,\n type UnsignedTransactionContext,\n} from \"./rollup\";\n\nexport type TxDetails = {\n max_priority_fee_bips: number;\n max_fee: string;\n gas_limit: number[] | null;\n chain_id: number;\n};\n\nexport type Generation = { generation: number };\nexport type Nonce = { nonce: number };\nexport type Uniqueness = Nonce | Generation;\n\nexport type UnsignedTransaction<RuntimeCall> = {\n runtime_call: RuntimeCall;\n uniqueness: Uniqueness;\n details: TxDetails;\n};\n\nexport type TransactionV0<RuntimeCall> = {\n pub_key: HexString;\n signature: HexString;\n} & UnsignedTransaction<RuntimeCall>;\n\nexport type Transaction<RuntimeCall> = {\n V0: TransactionV0<RuntimeCall>;\n};\n\nexport type Dedup = {\n nonce: number;\n};\n\nexport type StandardRollupContext = {\n defaultTxDetails: TxDetails;\n};\n\nexport type StandardRollupSpec<RuntimeCall> = {\n UnsignedTransaction: UnsignedTransaction<RuntimeCall>;\n Transaction: Transaction<RuntimeCall>;\n RuntimeCall: RuntimeCall;\n Dedup: Dedup;\n};\n\nconst useOrFetchUniqueness = async <S extends StandardRollupSpec<unknown>>({\n overrides,\n}: Omit<\n UnsignedTransactionContext<S, StandardRollupContext>,\n \"runtimeCall\"\n>) => {\n if (overrides?.uniqueness) {\n return overrides.uniqueness;\n }\n\n return { generation: Date.now() };\n};\n\nexport function standardTypeBuilder<\n S extends StandardRollupSpec<unknown>,\n>(): TypeBuilder<S, StandardRollupContext> {\n return {\n async unsignedTransaction(\n context: UnsignedTransactionContext<S, StandardRollupContext>,\n ) {\n const { rollup, runtimeCall } = context;\n const { uniqueness: _, ...overrides } = context.overrides;\n const uniqueness = await useOrFetchUniqueness(context);\n const details: TxDetails = {\n ...rollup.context.defaultTxDetails,\n ...overrides.details,\n };\n\n return {\n runtime_call: runtimeCall,\n uniqueness,\n details,\n } as S[\"UnsignedTransaction\"];\n },\n async transaction({\n sender,\n signature,\n unsignedTx,\n }: TransactionContext<S, StandardRollupContext>) {\n return {\n V0: {\n pub_key: bytesToHex(sender),\n signature: bytesToHex(signature),\n ...unsignedTx,\n },\n };\n },\n };\n}\n\n/**\n * The parameters for simulating a runtime call transaction.\n */\nexport type SimulateParams = Omit<\n SovereignClient.RollupSimulateParams,\n \"call\" | \"sender\"\n> &\n SignerParams;\n\nexport class StandardRollup<RuntimeCall> extends Rollup<\n StandardRollupSpec<RuntimeCall>,\n StandardRollupContext\n> {\n /**\n * Simulates a runtime call transaction.\n *\n * This method can be useful to estimate the gas cost of a runtime call transaction.\n *\n * @param runtimeMessage - The runtime message to call.\n */\n async simulate(\n runtimeMessage: StandardRollupSpec<RuntimeCall>[\"RuntimeCall\"],\n { signer }: SimulateParams,\n ): Promise<SovereignClient.Rollup.RollupSimulateResponse> {\n const publicKey = await signer.publicKey();\n const sender = bytesToHex(publicKey);\n const call = runtimeMessage as { [key: string]: unknown };\n\n return this.rollup.simulate({ sender, call });\n }\n}\n\nexport const DEFAULT_TX_DETAILS: Omit<TxDetails, \"chain_id\"> = {\n max_priority_fee_bips: 0,\n max_fee: \"100000000\",\n gas_limit: null,\n};\n\nasync function buildContext<C extends StandardRollupContext>(\n client: SovereignClient,\n context?: DeepPartial<C>,\n): Promise<C> {\n const defaultTxDetails = {\n ...DEFAULT_TX_DETAILS,\n ...context?.defaultTxDetails,\n };\n\n if (!defaultTxDetails.chain_id) {\n const { chain_id } = await client.rollup.constants();\n\n defaultTxDetails.chain_id = chain_id;\n }\n\n return {\n defaultTxDetails,\n } as C;\n}\n\nexport async function createStandardRollup<\n RuntimeCall,\n C extends StandardRollupContext = StandardRollupContext,\n>(\n rollupConfig?: Partial<RollupConfig<DeepPartial<C>>>,\n typeBuilderOverrides?: Partial<\n TypeBuilder<StandardRollupSpec<RuntimeCall>, C>\n >,\n) {\n const config = rollupConfig ?? {};\n const client = config.client ?? new SovereignClient({ baseURL: config.url });\n const getSerializer =\n config.getSerializer ?? ((schema) => new JsSerializer(schema));\n const context = await buildContext<C>(client, config.context);\n\n // Default to the standard transaction submission endpoint\n const txSubmissionEndpoint = config.txSubmissionEndpoint ?? \"/sequencer/txs\";\n\n return new StandardRollup<RuntimeCall>(\n {\n ...config,\n client,\n getSerializer,\n context,\n txSubmissionEndpoint,\n },\n {\n ...standardTypeBuilder(),\n ...typeBuilderOverrides,\n },\n );\n}\n","export * from \"./addresses\";\nexport * from \"./rollup\";\nexport * from \"./errors\";\nexport * from \"./type-spec\";\nexport { type EventPayload, Subscription } from \"./subscriptions\";\nexport * as SovereignClient from \"@sovereign-sdk/client\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAyB,mBAAmB;AAC5C,SAAS,eAAe;AAWjB,SAAS,qBACd,WACA,KACA,kBAAkB,IACV;AACR,MAAI,iBAAiB,YAAY,SAAS;AAE1C,MAAI,oBAAoB,UAAU,QAAQ;AACxC,qBAAiB,eAAe,MAAM,GAAG,eAAe;AAAA,EAC1D;AAEA,QAAM,QAAQ,QAAQ,QAAQ,cAAc;AAC5C,SAAO,QAAQ,OAAO,KAAK,KAAK;AAClC;;;ACzBA,OAAO,qBAAqB;AAI5B,SAAS,YAAY,kBAAkB;AACvC,SAAS,cAAc;;;ACFhB,IAAM,iBAAN,cAA6B,MAAM;AAAA,EACxC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AAEb,SAAK,OAAO,KAAK,YAAY;AAC7B,SAAK,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AA,IACF;AAAA,EACF;AAAA;AAEA,SAAsB,qBAIpB,cACA,sBAGA;AAAA;AA1KF;AA2KE,UAAM,SAAS,sCAAgB,CAAC;AAChC,UAAM,UAAS,YAAO,WAAP,YAAiB,IAAIC,iBAAgB,EAAE,SAAS,OAAO,IAAI,CAAC;AAC3E,UAAM,iBACJ,YAAO,kBAAP,YAAyB,CAAC,WAAW,IAAI,aAAa,MAAM;AAC9D,UAAM,UAAU,MAAM,aAAgB,QAAQ,OAAO,OAAO;AAG5D,UAAM,wBAAuB,YAAO,yBAAP,YAA+B;AAE5D,WAAO,IAAI;AAAA,MACT,iCACK,SADL;AAAA,QAEE;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACA,kCACK,oBAAoB,IACpB;AAAA,IAEP;AAAA,EACF;AAAA;;;AC5LA,YAAYC,sBAAqB;","names":["_a","subscription","SovereignClient","bytesToHex","_a","bytesToHex","SovereignClient","SovereignClient"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sovereign-sdk/web3",
3
- "version": "0.9.1",
3
+ "version": "0.11.0",
4
4
  "repository": "github:Sovereign-Labs/sovereign-sdk-web3-js",
5
5
  "files": [
6
6
  "dist",
@@ -24,15 +24,15 @@
24
24
  "typescript": "^5.0.0"
25
25
  },
26
26
  "dependencies": {
27
- "@sovereign-sdk/client": "0.1.0-alpha.36",
27
+ "@sovereign-sdk/client": "0.1.0-alpha.39",
28
28
  "bech32": "^2.0.0",
29
29
  "isomorphic-ws": "^5.0.0",
30
30
  "js-base64": "^3.7.7",
31
31
  "partysocket": "^1.1.3",
32
32
  "ws": "^8.18.1",
33
- "@sovereign-sdk/signers": "^0.2.1",
34
- "@sovereign-sdk/serializers": "^0.1.1",
35
- "@sovereign-sdk/universal-wallet-wasm": "^0.4.0",
33
+ "@sovereign-sdk/signers": "^0.3.0",
34
+ "@sovereign-sdk/serializers": "^0.1.2",
35
+ "@sovereign-sdk/universal-wallet-wasm": "^0.5.0",
36
36
  "@sovereign-sdk/utils": "^0.0.4"
37
37
  },
38
38
  "publishConfig": {