@sovereign-sdk/web3 0.0.13 → 0.0.15

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.mjs CHANGED
@@ -14,6 +14,18 @@ var __spreadValues = (a, b) => {
14
14
  }
15
15
  return a;
16
16
  };
17
+ var __objRest = (source, exclude) => {
18
+ var target = {};
19
+ for (var prop in source)
20
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
21
+ target[prop] = source[prop];
22
+ if (source != null && __getOwnPropSymbols)
23
+ for (var prop of __getOwnPropSymbols(source)) {
24
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
25
+ target[prop] = source[prop];
26
+ }
27
+ return target;
28
+ };
17
29
  var __async = (__this, __arguments, generator) => {
18
30
  return new Promise((resolve, reject) => {
19
31
  var fulfilled = (value) => {
@@ -35,13 +47,11 @@ var __async = (__this, __arguments, generator) => {
35
47
  });
36
48
  };
37
49
 
38
- // src/rollup.ts
50
+ // src/rollup/rollup.ts
39
51
  import SovereignClient from "@sovereign-sdk/client";
52
+ import { bytesToHex } from "@sovereign-sdk/utils";
40
53
  import { Base64 } from "js-base64";
41
54
 
42
- // src/serialization.ts
43
- import { KnownTypeId, Schema } from "@sovereign-sdk/universal-wallet-wasm";
44
-
45
55
  // src/errors.ts
46
56
  var SovereignError = class extends Error {
47
57
  constructor(message) {
@@ -50,8 +60,11 @@ var SovereignError = class extends Error {
50
60
  this.stack = new Error().stack;
51
61
  }
52
62
  };
63
+ var InvalidRollupConfigError = class extends SovereignError {
64
+ };
53
65
 
54
66
  // src/serialization.ts
67
+ import { KnownTypeId, Schema } from "@sovereign-sdk/universal-wallet-wasm";
55
68
  function loadSchema(schemaObject) {
56
69
  try {
57
70
  return Schema.fromJSON(JSON.stringify(schemaObject));
@@ -98,30 +111,42 @@ function createSerializer(schemaObject) {
98
111
  };
99
112
  }
100
113
 
101
- // src/utils.ts
102
- function bytesToHex(arr) {
103
- let hex = "";
104
- for (let i = 0; i < arr.length; i++) {
105
- let hexValue = arr[i].toString(16);
106
- if (hexValue.length === 1) {
107
- hexValue = `0${hexValue}`;
108
- }
109
- hex += hexValue;
110
- }
111
- return hex;
112
- }
113
-
114
- // src/rollup.ts
115
- var StandardRollup = class {
114
+ // src/rollup/rollup.ts
115
+ var Rollup = class {
116
116
  /**
117
117
  * Creates a new rollup client.
118
118
  *
119
+ * @throws {@link InvalidRollupConfigError} - If no schema or serializer is provided.
120
+ *
119
121
  * @param config - The configuration for the rollup client.
122
+ * @param typeBuilder - The type builder for the rollup.
120
123
  */
121
- constructor(config) {
122
- this._client = new SovereignClient({ baseURL: config.url });
123
- this._serializer = createSerializer(config.schema);
124
+ constructor(config, typeBuilder) {
125
+ var _a;
126
+ if (config.serializer) {
127
+ this._serializer = config.serializer;
128
+ } else {
129
+ if (!config.schema) {
130
+ throw new InvalidRollupConfigError(
131
+ "At least 1 of config.schema or config.serializer must be provided"
132
+ );
133
+ }
134
+ this._serializer = createSerializer(config.schema);
135
+ }
136
+ this._client = (_a = config.client) != null ? _a : new SovereignClient({ baseURL: config.url });
124
137
  this._config = config;
138
+ this._typeBuilder = typeBuilder;
139
+ }
140
+ /**
141
+ * Retrieve dedup information about the provided address.
142
+ *
143
+ * @param address - The public key to dedup.
144
+ */
145
+ dedup(address) {
146
+ return __async(this, null, function* () {
147
+ const response = yield this.rollup.addresses.dedup(bytesToHex(address));
148
+ return response.data;
149
+ });
125
150
  }
126
151
  /**
127
152
  * Submits a transaction to the rollup.
@@ -141,20 +166,20 @@ var StandardRollup = class {
141
166
  * Utilizes the provided signer to sign the transaction.
142
167
  *
143
168
  * @param unsignedTx - The unsigned transaction to sign and submit.
169
+ * @param {SignerParams} params - The params for signing and submitting the transaction.
144
170
  */
145
171
  signAndSubmitTransaction(_0, _1) {
146
172
  return __async(this, arguments, function* (unsignedTx, { signer }) {
147
173
  const serializedUnsignedTx = this.serializer.serializeUnsignedTx(unsignedTx);
148
174
  const signature = yield signer.sign(serializedUnsignedTx);
149
175
  const publicKey = yield signer.publicKey();
150
- const tx = __spreadValues({
151
- pub_key: {
152
- pub_key: publicKey
153
- },
154
- signature: {
155
- msg_sig: signature
156
- }
157
- }, unsignedTx);
176
+ const context = {
177
+ unsignedTx,
178
+ sender: publicKey,
179
+ signature,
180
+ rollup: this
181
+ };
182
+ const tx = yield this._typeBuilder.transaction(context);
158
183
  const result = yield this.submitTransaction(tx);
159
184
  return { transaction: tx, response: result };
160
185
  });
@@ -163,68 +188,41 @@ var StandardRollup = class {
163
188
  * Performs a runtime call transaction.
164
189
  * Utilizes the provided signer to sign the transaction.
165
190
  *
166
- * @param runtimeMessage - The runtime message to call.
191
+ * @param runtimeCall - The runtime message to call.
192
+ * @param {CallParams<S>} params - The params for submitting a runtime call transaction.
167
193
  */
168
194
  call(_0, _1) {
169
- return __async(this, arguments, function* (runtimeMessage, { signer, txDetails }) {
170
- const runtimeCall = this.serializer.serializeRuntimeCall(runtimeMessage);
195
+ return __async(this, arguments, function* (runtimeCall, { signer, overrides }) {
171
196
  const publicKey = yield signer.publicKey();
172
- const dedup = yield this.rollup.addresses.dedup(bytesToHex(publicKey));
173
- const nonce = dedup.data.nonce;
174
- const unsignedTx = {
175
- runtime_msg: runtimeCall,
176
- nonce,
177
- details: txDetails != null ? txDetails : this._config.defaultTxDetails
197
+ const context = {
198
+ runtimeCall,
199
+ sender: publicKey,
200
+ rollup: this,
201
+ overrides: overrides != null ? overrides : {}
178
202
  };
179
- return this.signAndSubmitTransaction(
180
- unsignedTx,
181
- {
182
- signer
183
- }
184
- );
185
- });
186
- }
187
- /**
188
- * Simulates a runtime call transaction.
189
- *
190
- * This method can be useful to estimate the gas cost of a runtime call transaction.
191
- *
192
- * @param runtimeMessage - The runtime message to call.
193
- */
194
- simulate(_0, _1) {
195
- return __async(this, arguments, function* (runtimeMessage, { signer, txDetails }) {
196
- const runtimeCall = this.serializer.serializeRuntimeCall(runtimeMessage);
197
- const publicKey = yield signer.publicKey();
198
- const dedup = yield this.rollup.addresses.dedup(bytesToHex(publicKey));
199
- const nonce = dedup.data.nonce;
200
- const response = yield this.rollup.simulate({
201
- body: {
202
- details: txDetails,
203
- encoded_call_message: bytesToHex(runtimeCall),
204
- nonce,
205
- sender_pub_key: bytesToHex(publicKey)
206
- }
203
+ const unsignedTx = yield this._typeBuilder.unsignedTransaction(context);
204
+ return this.signAndSubmitTransaction(unsignedTx, {
205
+ signer
207
206
  });
208
- return response.data;
209
207
  });
210
208
  }
211
209
  /**
212
210
  * A ledger client that can be used to query the ledger.
213
211
  */
214
212
  get ledger() {
215
- return this._client.ledger;
213
+ return this.http.ledger;
216
214
  }
217
215
  /**
218
216
  * A sequencer client that can be used to submit transactions & batches to the rollup.
219
217
  */
220
218
  get sequencer() {
221
- return this._client.sequencer;
219
+ return this.http.sequencer;
222
220
  }
223
221
  /**
224
222
  * A rollup client that can be used to perform operations on the rollup.
225
223
  */
226
224
  get rollup() {
227
- return this._client.rollup;
225
+ return this.http.rollup;
228
226
  }
229
227
  /**
230
228
  * A client that can be used to perform HTTP requests to the Sovereign API.
@@ -242,16 +240,106 @@ var StandardRollup = class {
242
240
  get serializer() {
243
241
  return this._serializer;
244
242
  }
243
+ /**
244
+ * The context for the rollup.
245
+ */
246
+ get context() {
247
+ return this._config.context;
248
+ }
245
249
  };
246
250
 
251
+ // src/rollup/standard-rollup.ts
252
+ import { bytesToHex as bytesToHex2 } from "@sovereign-sdk/utils";
253
+ var useOrFetchNonce = (_0) => __async(void 0, [_0], function* ({
254
+ sender,
255
+ rollup,
256
+ overrides
257
+ }) {
258
+ if ((overrides == null ? void 0 : overrides.nonce) !== void 0 && overrides.nonce >= 0) {
259
+ return overrides.nonce;
260
+ }
261
+ const { data } = yield rollup.rollup.addresses.dedup(bytesToHex2(sender));
262
+ return data.nonce;
263
+ });
264
+ function standardTypeBuilder() {
265
+ return {
266
+ unsignedTransaction(context) {
267
+ return __async(this, null, function* () {
268
+ const { rollup, runtimeCall } = context;
269
+ const runtime_msg = rollup.serializer.serializeRuntimeCall(runtimeCall);
270
+ const _a2 = context.overrides, { nonce: _ } = _a2, overrides = __objRest(_a2, ["nonce"]);
271
+ const nonce = yield useOrFetchNonce(context);
272
+ const details = __spreadValues(__spreadValues({}, rollup.context.defaultTxDetails), overrides.details);
273
+ return {
274
+ runtime_msg,
275
+ nonce,
276
+ details
277
+ };
278
+ });
279
+ },
280
+ transaction(_0) {
281
+ return __async(this, arguments, function* ({
282
+ sender,
283
+ signature,
284
+ unsignedTx
285
+ }) {
286
+ return __spreadValues({
287
+ pub_key: {
288
+ pub_key: sender
289
+ },
290
+ signature: {
291
+ msg_sig: signature
292
+ }
293
+ }, unsignedTx);
294
+ });
295
+ }
296
+ };
297
+ }
298
+ var StandardRollup = class extends Rollup {
299
+ /**
300
+ * Simulates a runtime call transaction.
301
+ *
302
+ * This method can be useful to estimate the gas cost of a runtime call transaction.
303
+ *
304
+ * @param runtimeMessage - The runtime message to call.
305
+ */
306
+ simulate(_0, _1) {
307
+ return __async(this, arguments, function* (runtimeMessage, { signer, txDetails, nonce: overrideNonce }) {
308
+ const runtimeCall = this.serializer.serializeRuntimeCall(runtimeMessage);
309
+ const publicKey = yield signer.publicKey();
310
+ const nonce = yield useOrFetchNonce({
311
+ sender: publicKey,
312
+ rollup: this,
313
+ overrides: { nonce: overrideNonce }
314
+ });
315
+ const response = yield this.rollup.simulate({
316
+ body: {
317
+ details: txDetails,
318
+ encoded_call_message: bytesToHex2(runtimeCall),
319
+ nonce,
320
+ sender_pub_key: bytesToHex2(publicKey)
321
+ }
322
+ });
323
+ return response.data;
324
+ });
325
+ }
326
+ };
327
+ function createStandardRollup(config, typeBuilderOverrides) {
328
+ return new StandardRollup(config, __spreadValues(__spreadValues({}, standardTypeBuilder()), typeBuilderOverrides));
329
+ }
330
+
247
331
  // src/index.ts
248
332
  import * as SovereignClient2 from "@sovereign-sdk/client";
249
333
  import { Schema as Schema2 } from "@sovereign-sdk/universal-wallet-wasm";
250
334
  export {
335
+ InvalidRollupConfigError,
336
+ Rollup,
251
337
  Schema2 as Schema,
252
338
  SovereignClient2 as SovereignClient,
253
339
  SovereignError,
254
340
  StandardRollup,
255
- createSerializer
341
+ createSerializer,
342
+ createStandardRollup,
343
+ standardTypeBuilder
256
344
  };
257
345
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/rollup.ts","../src/serialization.ts","../src/errors.ts","../src/utils.ts","../src/index.ts"],"sourcesContent":["import SovereignClient from \"@sovereign-sdk/client\";\nimport type { Signer } from \"@sovereign-sdk/signers\";\nimport { Base64 } from \"js-base64\";\nimport {\n type RollupSchema,\n type RollupSerializer,\n createSerializer,\n} from \"./serialization\";\nimport type { BaseTypeSpec } from \"./type-spec\";\nimport { bytesToHex } from \"./utils\";\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 configuration for a rollup client.\n */\nexport type RollupConfig = {\n /**\n * The base URL of the rollup full node API.\n */\n url?: string;\n /**\n * The schema of the rollup.\n */\n schema: RollupSchema;\n /**\n * The default transaction details.\n * This will be deprecated soon to remove Sovereign SDK specific types.\n * @deprecated\n * @private\n */\n defaultTxDetails: TxDetails;\n};\n\ntype TxDetails = {\n max_priority_fee_bips: number;\n max_fee: number;\n gas_limit?: number[];\n chain_id: number;\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 = {\n /**\n * The transaction details to use for the call.\n * @deprecated This will be removed soon to remove Sovereign SDK specific types.\n * In favor of a looser type specification.\n */\n txDetails?: TxDetails;\n} & SignerParams;\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 * @deprecated This will be removed soon to remove Sovereign SDK specific types.\n * In favor of a looser type specification.\n */\n txDetails: TxDetails;\n} & SignerParams;\n\n/**\n * The rollup client.\n *\n * @template T - The type specification for the rollup.\n * If not provided, the base type specification will be used which uses `any` for all types.\n */\nexport class StandardRollup<T extends BaseTypeSpec = BaseTypeSpec> {\n private readonly _config: RollupConfig;\n private readonly _client: SovereignClient;\n private readonly _serializer: RollupSerializer;\n\n /**\n * Creates a new rollup client.\n *\n * @param config - The configuration for the rollup client.\n */\n constructor(config: RollupConfig) {\n this._client = new SovereignClient({ baseURL: config.url });\n this._serializer = createSerializer(config.schema);\n this._config = config;\n }\n\n /**\n * Submits a transaction to the rollup.\n *\n * @param transaction - The transaction to submit.\n */\n async submitTransaction(\n transaction: T[\"Transaction\"],\n ): Promise<SovereignClient.Sequencer.TxCreateResponse> {\n const serializedTx = this.serializer.serializeTx(transaction);\n\n return this.sequencer.txs.create({\n body: Base64.fromUint8Array(serializedTx),\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 */\n async signAndSubmitTransaction(\n unsignedTx: T[\"UnsignedTransaction\"],\n { signer }: SignerParams,\n ): Promise<TransactionResult<T[\"Transaction\"]>> {\n const serializedUnsignedTx =\n this.serializer.serializeUnsignedTx(unsignedTx);\n const signature = await signer.sign(serializedUnsignedTx);\n const publicKey = await signer.publicKey();\n const tx = {\n pub_key: {\n pub_key: publicKey,\n },\n signature: {\n msg_sig: signature,\n },\n ...unsignedTx,\n } as T[\"Transaction\"];\n const result = await this.submitTransaction(tx);\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 runtimeMessage - The runtime message to call.\n */\n async call(\n runtimeMessage: T[\"RuntimeCall\"],\n { signer, txDetails }: CallParams,\n ): Promise<TransactionResult<T[\"Transaction\"]>> {\n const runtimeCall = this.serializer.serializeRuntimeCall(runtimeMessage);\n const publicKey = await signer.publicKey();\n const dedup = await this.rollup.addresses.dedup(bytesToHex(publicKey));\n // biome-ignore lint/suspicious/noExplicitAny: fix later\n const nonce = (dedup.data as any).nonce as number;\n const unsignedTx = {\n runtime_msg: runtimeCall,\n nonce,\n details: txDetails ?? this._config.defaultTxDetails,\n };\n\n return this.signAndSubmitTransaction(\n unsignedTx as T[\"UnsignedTransaction\"],\n {\n signer,\n },\n );\n }\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: T[\"RuntimeCall\"],\n { signer, txDetails }: SimulateParams,\n ): Promise<SovereignClient.Rollup.SimulateExecutionResponse> {\n const runtimeCall = this.serializer.serializeRuntimeCall(runtimeMessage);\n const publicKey = await signer.publicKey();\n const dedup = await this.rollup.addresses.dedup(bytesToHex(publicKey));\n // biome-ignore lint/suspicious/noExplicitAny: fix later\n const nonce = (dedup.data as any).nonce as number;\n const response = await this.rollup.simulate({\n body: {\n details: txDetails,\n encoded_call_message: bytesToHex(runtimeCall),\n nonce,\n sender_pub_key: bytesToHex(publicKey),\n },\n });\n\n // biome-ignore lint/style/noNonNullAssertion: fix later\n return response.data!;\n }\n\n /**\n * A ledger client that can be used to query the ledger.\n */\n get ledger(): SovereignClient.Ledger {\n return this._client.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._client.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._client.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._client;\n }\n\n /**\n * The serializer for the rollup.\n * Can be used to serialize transactions, runtime calls, etc.\n * See {@link RollupSerializer} for more information.\n */\n get serializer(): RollupSerializer {\n return this._serializer;\n }\n}\n","import { KnownTypeId, Schema } from \"@sovereign-sdk/universal-wallet-wasm\";\nimport { SovereignError } from \"./errors\";\n\n/**\n * A rollup schema is a description of the types that are utilized in the rollup.\n * It is used to serialize and deserialize the types.\n * As well as display them in a human-readable way that is verified by the rollup.\n */\nexport type RollupSchema = object;\n\n/**\n * A serializer is used to serialize rollup types to Borsh bytes.\n *\n * @example\n * ```typescript\n * const serializer = createSerializer(yourSchema);\n * const runtimeCall = {\n * value_setter: {\n * set_value: 100,\n * },\n * };\n * const borshBytes = serializer.serializeRuntimeCall(runtimeCall);\n * ```\n */\nexport type RollupSerializer = {\n /**\n * Serialize an input to Borsh bytes.\n *\n * Treats `Uint8Array` as a plain array of numbers as this is the format used by universal-wallet-wasm\n * to represent Borsh bytes.\n *\n * @param input - The input to serialize.\n * @param index - The index of the type in the schema to serialize.\n * @returns The serialized Borsh bytes.\n */\n serialize(input: unknown, index: number): Uint8Array;\n\n /**\n * Serialize a runtime call to Borsh bytes.\n *\n * @param input - The runtime call to serialize.\n * @returns The serialized Borsh bytes.\n */\n serializeRuntimeCall(input: unknown): Uint8Array;\n\n /**\n * Serialize an unsigned transaction to Borsh bytes.\n *\n * @param input - The unsigned transaction to serialize.\n * @returns The serialized Borsh bytes.\n */\n serializeUnsignedTx(input: unknown): Uint8Array;\n\n /**\n * Serialize a transaction to Borsh bytes.\n *\n * @param input - The transaction to serialize.\n * @returns The serialized Borsh bytes.\n */\n serializeTx(input: unknown): Uint8Array;\n};\n\nfunction loadSchema(schemaObject: RollupSchema): Schema {\n try {\n return Schema.fromJSON(JSON.stringify(schemaObject));\n } catch (err) {\n throw new SovereignError(`Failed to create runtime schema due to: ${err}`);\n }\n}\n\n/**\n * Create a serializer for a rollup schema.\n *\n * @throws {@link SovereignError} - If the schema is invalid.\n * @param schemaObject - The rollup schema.\n * @returns The serializer.\n */\nexport function createSerializer(schemaObject: RollupSchema): RollupSerializer {\n const schema = loadSchema(schemaObject);\n\n return {\n serialize(input: unknown, index: number): Uint8Array {\n try {\n return schema.jsonToBorsh(\n index,\n JSON.stringify(input, (_, value) => {\n if (value instanceof Uint8Array) {\n return Array.from(value);\n }\n return value;\n }),\n );\n } catch (err) {\n throw new SovereignError(`Failed to serialize input due to: ${err}`);\n }\n },\n serializeRuntimeCall(input: unknown): Uint8Array {\n return this.serialize(\n input,\n schema.knownTypeIndex(KnownTypeId.RuntimeCall),\n );\n },\n serializeUnsignedTx(input: unknown): Uint8Array {\n return this.serialize(\n input,\n schema.knownTypeIndex(KnownTypeId.UnsignedTransaction),\n );\n },\n serializeTx(input: unknown): Uint8Array {\n return this.serialize(\n input,\n schema.knownTypeIndex(KnownTypeId.Transaction),\n );\n },\n };\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","export function hexToBytes(hex: string) {\n if (hex.length && hex.length % 2 !== 0) {\n throw new Error(`Invalid hex string length: ${hex.length}`);\n }\n\n const matches = hex.match(/[\\da-f]{2}/gi);\n\n if (!matches) {\n throw new Error(\"Invalid hex string: No valid hex digits found\");\n }\n\n return new Uint8Array(matches.map((h) => Number.parseInt(h, 16)));\n}\n\nexport function bytesToHex(arr: Uint8Array): string {\n let hex = \"\";\n for (let i = 0; i < arr.length; i++) {\n let hexValue = arr[i].toString(16);\n if (hexValue.length === 1) {\n hexValue = `0${hexValue}`;\n }\n hex += hexValue;\n }\n return hex;\n}\n","export * from \"./rollup\";\nexport * from \"./serialization\";\nexport * from \"./errors\";\nexport * from \"./type-spec\";\nexport * as SovereignClient from \"@sovereign-sdk/client\";\nexport { Schema } from \"@sovereign-sdk/universal-wallet-wasm\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;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O,KAAK;AAAA,EACd;AACF;;;AItPA,YAAYA,sBAAqB;AACjC,SAAS,UAAAC,eAAc;","names":["SovereignClient","Schema"]}
1
+ {"version":3,"sources":["../src/rollup/rollup.ts","../src/errors.ts","../src/serialization.ts","../src/rollup/standard-rollup.ts","../src/index.ts"],"sourcesContent":["import SovereignClient from \"@sovereign-sdk/client\";\nimport type { Signer } from \"@sovereign-sdk/signers\";\nimport { bytesToHex } from \"@sovereign-sdk/utils\";\nimport { Base64 } from \"js-base64\";\nimport { InvalidRollupConfigError } from \"../errors\";\nimport {\n type RollupSchema,\n type RollupSerializer,\n createSerializer,\n} from \"../serialization\";\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 sender: Uint8Array;\n // able to override nonce\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 RollupConfig.url}.\n */\n client?: SovereignClient;\n /**\n * The schema of the rollup.\n */\n schema?: RollupSchema;\n /**\n * The serializer to use for the rollup.\n * If not provided, a serializer will be created using the provided {@link RollupConfig.schema}.\n */\n serializer?: RollupSerializer;\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 _client: SovereignClient;\n private readonly _serializer: RollupSerializer;\n private readonly _typeBuilder: TypeBuilder<S, C>;\n\n /**\n * Creates a new rollup client.\n *\n * @throws {@link InvalidRollupConfigError} - If no schema or serializer is provided.\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 if (config.serializer) {\n this._serializer = config.serializer;\n } else {\n if (!config.schema) {\n throw new InvalidRollupConfigError(\n \"At least 1 of config.schema or config.serializer must be provided\",\n );\n }\n this._serializer = createSerializer(config.schema);\n }\n\n this._client =\n config.client ?? new SovereignClient({ baseURL: config.url });\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.data as S[\"Dedup\"];\n }\n\n /**\n * Submits a transaction to the rollup.\n *\n * @param transaction - The transaction to submit.\n */\n async submitTransaction(\n transaction: S[\"Transaction\"],\n ): Promise<SovereignClient.Sequencer.TxCreateResponse> {\n const serializedTx = this.serializer.serializeTx(transaction);\n\n return this.sequencer.txs.create({\n body: Base64.fromUint8Array(serializedTx),\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 */\n async signAndSubmitTransaction(\n unsignedTx: S[\"UnsignedTransaction\"],\n { signer }: SignerParams,\n ): Promise<TransactionResult<S[\"Transaction\"]>> {\n const serializedUnsignedTx =\n this.serializer.serializeUnsignedTx(unsignedTx);\n const signature = await signer.sign(serializedUnsignedTx);\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);\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 */\n async call(\n runtimeCall: S[\"RuntimeCall\"],\n { signer, overrides }: CallParams<S>,\n ): Promise<TransactionResult<S[\"Transaction\"]>> {\n const publicKey = await signer.publicKey();\n const context = {\n runtimeCall,\n sender: publicKey,\n rollup: this,\n overrides: overrides ?? ({} as DeepPartial<S[\"UnsignedTransaction\"]>),\n };\n const unsignedTx = await this._typeBuilder.unsignedTransaction(context);\n\n return this.signAndSubmitTransaction(unsignedTx, {\n signer,\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._client;\n }\n\n /**\n * The serializer for the rollup.\n * Can be used to serialize transactions, runtime calls, etc.\n * See {@link RollupSerializer} for more information.\n */\n get serializer(): RollupSerializer {\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","/**\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","import { KnownTypeId, Schema } from \"@sovereign-sdk/universal-wallet-wasm\";\nimport { SovereignError } from \"./errors\";\n\n/**\n * A rollup schema is a description of the types that are utilized in the rollup.\n * It is used to serialize and deserialize the types.\n * As well as display them in a human-readable way that is verified by the rollup.\n */\nexport type RollupSchema = object;\n\n/**\n * A serializer is used to serialize rollup types to Borsh bytes.\n *\n * @example\n * ```typescript\n * const serializer = createSerializer(yourSchema);\n * const runtimeCall = {\n * value_setter: {\n * set_value: 100,\n * },\n * };\n * const borshBytes = serializer.serializeRuntimeCall(runtimeCall);\n * ```\n */\nexport type RollupSerializer = {\n /**\n * Serialize an input to Borsh bytes.\n *\n * Treats `Uint8Array` as a plain array of numbers as this is the format used by universal-wallet-wasm\n * to represent Borsh bytes.\n *\n * @param input - The input to serialize.\n * @param index - The index of the type in the schema to serialize.\n * @returns The serialized Borsh bytes.\n */\n serialize(input: unknown, index: number): Uint8Array;\n\n /**\n * Serialize a runtime call to Borsh bytes.\n *\n * @param input - The runtime call to serialize.\n * @returns The serialized Borsh bytes.\n */\n serializeRuntimeCall(input: unknown): Uint8Array;\n\n /**\n * Serialize an unsigned transaction to Borsh bytes.\n *\n * @param input - The unsigned transaction to serialize.\n * @returns The serialized Borsh bytes.\n */\n serializeUnsignedTx(input: unknown): Uint8Array;\n\n /**\n * Serialize a transaction to Borsh bytes.\n *\n * @param input - The transaction to serialize.\n * @returns The serialized Borsh bytes.\n */\n serializeTx(input: unknown): Uint8Array;\n};\n\nfunction loadSchema(schemaObject: RollupSchema): Schema {\n try {\n return Schema.fromJSON(JSON.stringify(schemaObject));\n } catch (err) {\n throw new SovereignError(`Failed to create runtime schema due to: ${err}`);\n }\n}\n\n/**\n * Create a serializer for a rollup schema.\n *\n * @throws {@link SovereignError} - If the schema is invalid.\n * @param schemaObject - The rollup schema.\n * @returns The serializer.\n */\nexport function createSerializer(schemaObject: RollupSchema): RollupSerializer {\n const schema = loadSchema(schemaObject);\n\n return {\n serialize(input: unknown, index: number): Uint8Array {\n try {\n return schema.jsonToBorsh(\n index,\n JSON.stringify(input, (_, value) => {\n if (value instanceof Uint8Array) {\n return Array.from(value);\n }\n return value;\n }),\n );\n } catch (err) {\n throw new SovereignError(`Failed to serialize input due to: ${err}`);\n }\n },\n serializeRuntimeCall(input: unknown): Uint8Array {\n return this.serialize(\n input,\n schema.knownTypeIndex(KnownTypeId.RuntimeCall),\n );\n },\n serializeUnsignedTx(input: unknown): Uint8Array {\n return this.serialize(\n input,\n schema.knownTypeIndex(KnownTypeId.UnsignedTransaction),\n );\n },\n serializeTx(input: unknown): Uint8Array {\n return this.serialize(\n input,\n schema.knownTypeIndex(KnownTypeId.Transaction),\n );\n },\n };\n}\n","import type SovereignClient from \"@sovereign-sdk/client\";\nimport { bytesToHex } from \"@sovereign-sdk/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: number;\n gas_limit?: number[];\n chain_id: number;\n};\n\nexport type UnsignedTransaction = {\n runtime_msg: Uint8Array;\n nonce: number;\n details: TxDetails;\n};\n\nexport type Transaction = {\n pub_key: { pub_key: Uint8Array };\n signature: { msg_sig: Uint8Array };\n} & UnsignedTransaction;\n\nexport type Dedup = {\n nonce: number;\n};\n\nexport type StandardRollupContext = {\n defaultTxDetails: TxDetails;\n};\n\nexport type StandardRollupSpec<RuntimeCall> = {\n UnsignedTransaction: UnsignedTransaction;\n Transaction: Transaction;\n RuntimeCall: RuntimeCall;\n Dedup: Dedup;\n};\n\nconst useOrFetchNonce = async <S extends StandardRollupSpec<unknown>>({\n sender,\n rollup,\n overrides,\n}: Omit<\n UnsignedTransactionContext<S, StandardRollupContext>,\n \"runtimeCall\"\n>) => {\n if (overrides?.nonce !== undefined && overrides.nonce >= 0) {\n return overrides.nonce;\n }\n const { data } = await rollup.rollup.addresses.dedup(bytesToHex(sender));\n\n return (data as S[\"Dedup\"]).nonce;\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 runtime_msg = rollup.serializer.serializeRuntimeCall(runtimeCall);\n const { nonce: _, ...overrides } = context.overrides;\n const nonce = await useOrFetchNonce(context);\n const details: TxDetails = {\n ...rollup.context.defaultTxDetails,\n ...overrides.details,\n };\n\n return {\n runtime_msg,\n nonce,\n details,\n };\n },\n async transaction({\n sender,\n signature,\n unsignedTx,\n }: TransactionContext<S, StandardRollupContext>) {\n return {\n pub_key: {\n pub_key: sender,\n },\n signature: {\n msg_sig: signature,\n },\n ...unsignedTx,\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 nonce?: 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, nonce: overrideNonce }: SimulateParams,\n ): Promise<SovereignClient.Rollup.SimulateExecutionResponse> {\n const runtimeCall = this.serializer.serializeRuntimeCall(runtimeMessage);\n const publicKey = await signer.publicKey();\n const nonce = await useOrFetchNonce({\n sender: publicKey,\n rollup: this,\n overrides: { nonce: overrideNonce },\n });\n const response = await this.rollup.simulate({\n body: {\n details: txDetails,\n encoded_call_message: bytesToHex(runtimeCall),\n nonce,\n sender_pub_key: bytesToHex(publicKey),\n },\n });\n\n // biome-ignore lint/style/noNonNullAssertion: fix later\n return response.data!;\n }\n}\n\nexport function createStandardRollup<\n RuntimeCall,\n C extends StandardRollupContext = StandardRollupContext,\n>(\n config: RollupConfig<C>,\n typeBuilderOverrides?: Partial<\n TypeBuilder<StandardRollupSpec<RuntimeCall>, C>\n >,\n) {\n return new StandardRollup<RuntimeCall>(config, {\n ...standardTypeBuilder(),\n ...typeBuilderOverrides,\n });\n}\n","export * from \"./rollup\";\nexport * from \"./serialization\";\nexport * from \"./errors\";\nexport * from \"./type-spec\";\nexport * as SovereignClient from \"@sovereign-sdk/client\";\nexport { Schema } from \"@sovereign-sdk/universal-wallet-wasm\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,qBAAqB;AAE5B,SAAS,kBAAkB;AAC3B,SAAS,cAAc;;;ACAhB,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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ereign-sdk/web3",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "files": [
5
5
  "dist",
6
6
  "package.json"
@@ -26,8 +26,9 @@
26
26
  "dependencies": {
27
27
  "@sovereign-sdk/client": "0.1.0-alpha.13",
28
28
  "js-base64": "^3.7.7",
29
- "@sovereign-sdk/signers": "^0.0.2",
30
- "@sovereign-sdk/universal-wallet-wasm": "^0.1.4"
29
+ "@sovereign-sdk/signers": "^0.0.3",
30
+ "@sovereign-sdk/utils": "^0.0.2",
31
+ "@sovereign-sdk/universal-wallet-wasm": "^0.1.5"
31
32
  },
32
33
  "publishConfig": {
33
34
  "access": "public"
@@ -37,6 +38,7 @@
37
38
  "ci": "biome ci",
38
39
  "fix": "biome check --write",
39
40
  "lint": "biome lint",
41
+ "typecheck": "tsc --noEmit",
40
42
  "test": "vitest"
41
43
  }
42
44
  }