@sovereign-sdk/web3 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.d.mts +204 -29
- package/dist/index.d.ts +204 -29
- package/dist/index.js +374 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +371 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -5
- package/LICENSE +0 -201
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @sovereign-sdk/web3
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@sovereign-sdk/web3)
|
|
4
|
-
[](https://github.com/Sovereign-Labs/sovereign-sdk/actions/workflows/typescript.ci.yml)
|
|
5
5
|
|
|
6
6
|
A TypeScript client library for interacting with Sovereign SDK rollups.
|
|
7
7
|
|
package/dist/index.d.mts
CHANGED
|
@@ -2,8 +2,9 @@ import { HexString } from '@sovereign-sdk/utils';
|
|
|
2
2
|
import SovereignClient__default from '@sovereign-sdk/client';
|
|
3
3
|
import * as SovereignClient from '@sovereign-sdk/client';
|
|
4
4
|
export { SovereignClient };
|
|
5
|
-
import { RollupSchema, Serializer } from '@sovereign-sdk/serializers';
|
|
5
|
+
import { RollupSchema as RollupSchema$1, Serializer as Serializer$1 } from '@sovereign-sdk/serializers';
|
|
6
6
|
import { Signer } from '@sovereign-sdk/signers';
|
|
7
|
+
import { TxDetails, UnsignedTransaction, Transaction } from '@sovereign-sdk/types';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Encodes a public key as a bech32m address with the given human-readable part (hrp).
|
|
@@ -154,7 +155,7 @@ type RollupConfig<C extends RollupContext> = {
|
|
|
154
155
|
* This can be called more than once, for example if the chain hash changes (i.e a new rollup version)
|
|
155
156
|
* is detected then it will be called again with the new rollup schema.
|
|
156
157
|
*/
|
|
157
|
-
getSerializer: (schema: RollupSchema) => Serializer;
|
|
158
|
+
getSerializer: (schema: RollupSchema$1) => Serializer$1;
|
|
158
159
|
/**
|
|
159
160
|
* Arbitrary context that is associated with the rollup.
|
|
160
161
|
*/
|
|
@@ -307,7 +308,7 @@ declare class Rollup<S extends BaseTypeSpec, C extends RollupContext> {
|
|
|
307
308
|
* The serializer for the rollup.
|
|
308
309
|
* Can be used to serialize transactions, runtime calls, etc.
|
|
309
310
|
*/
|
|
310
|
-
serializer(): Promise<Serializer>;
|
|
311
|
+
serializer(): Promise<Serializer$1>;
|
|
311
312
|
/**
|
|
312
313
|
* The context for the rollup.
|
|
313
314
|
*/
|
|
@@ -315,31 +316,6 @@ declare class Rollup<S extends BaseTypeSpec, C extends RollupContext> {
|
|
|
315
316
|
chainHash(): Promise<Uint8Array>;
|
|
316
317
|
}
|
|
317
318
|
|
|
318
|
-
type TxDetails = {
|
|
319
|
-
max_priority_fee_bips: number;
|
|
320
|
-
max_fee: string;
|
|
321
|
-
gas_limit: number[] | null;
|
|
322
|
-
chain_id: number;
|
|
323
|
-
};
|
|
324
|
-
type Generation = {
|
|
325
|
-
generation: number;
|
|
326
|
-
};
|
|
327
|
-
type Nonce = {
|
|
328
|
-
nonce: number;
|
|
329
|
-
};
|
|
330
|
-
type Uniqueness = Nonce | Generation;
|
|
331
|
-
type UnsignedTransaction<RuntimeCall> = {
|
|
332
|
-
runtime_call: RuntimeCall;
|
|
333
|
-
uniqueness: Uniqueness;
|
|
334
|
-
details: TxDetails;
|
|
335
|
-
};
|
|
336
|
-
type TransactionV0<RuntimeCall> = {
|
|
337
|
-
pub_key: HexString;
|
|
338
|
-
signature: HexString;
|
|
339
|
-
} & UnsignedTransaction<RuntimeCall>;
|
|
340
|
-
type Transaction<RuntimeCall> = {
|
|
341
|
-
V0: TransactionV0<RuntimeCall>;
|
|
342
|
-
};
|
|
343
319
|
type Dedup = {
|
|
344
320
|
nonce: number;
|
|
345
321
|
};
|
|
@@ -370,6 +346,205 @@ declare class StandardRollup<RuntimeCall> extends Rollup<StandardRollupSpec<Runt
|
|
|
370
346
|
declare const DEFAULT_TX_DETAILS: Omit<TxDetails, "chain_id">;
|
|
371
347
|
declare function createStandardRollup<RuntimeCall, C extends StandardRollupContext = StandardRollupContext>(rollupConfig?: Partial<RollupConfig<DeepPartial<C>>>, typeBuilderOverrides?: Partial<TypeBuilder<StandardRollupSpec<RuntimeCall>, C>>): Promise<StandardRollup<RuntimeCall>>;
|
|
372
348
|
|
|
349
|
+
/**
|
|
350
|
+
* A rollup schema is a description of the types that are utilized in the rollup.
|
|
351
|
+
* It is used to serialize and deserialize the types.
|
|
352
|
+
* As well as display them in a human-readable way that is verified by the rollup.
|
|
353
|
+
*/
|
|
354
|
+
type RollupSchema = Record<string, any>;
|
|
355
|
+
/**
|
|
356
|
+
* A serializer is used to serialize rollup types to Borsh bytes.
|
|
357
|
+
*
|
|
358
|
+
* @example
|
|
359
|
+
* ```typescript
|
|
360
|
+
* const serializer = createSerializer(yourSchema);
|
|
361
|
+
* const runtimeCall = {
|
|
362
|
+
* value_setter: {
|
|
363
|
+
* set_value: {
|
|
364
|
+
* value: 100,
|
|
365
|
+
* gas: null
|
|
366
|
+
* },
|
|
367
|
+
* },
|
|
368
|
+
* };
|
|
369
|
+
* const borshBytes = serializer.serializeRuntimeCall(runtimeCall);
|
|
370
|
+
* ```
|
|
371
|
+
*/
|
|
372
|
+
declare abstract class Serializer {
|
|
373
|
+
protected _schema: RollupSchema;
|
|
374
|
+
constructor(schema: RollupSchema);
|
|
375
|
+
protected abstract jsonToBorsh(input: unknown, index: number): Uint8Array;
|
|
376
|
+
private lookupKnownTypeIndex;
|
|
377
|
+
/**
|
|
378
|
+
* Serialize an input to Borsh bytes.
|
|
379
|
+
*
|
|
380
|
+
* Treats `Uint8Array` as a plain array of numbers as this is the format used by universal-wallet
|
|
381
|
+
* to represent Borsh bytes.
|
|
382
|
+
*
|
|
383
|
+
* @param input - The input to serialize.
|
|
384
|
+
* @param index - The index of the type in the schema to serialize.
|
|
385
|
+
* @returns The serialized Borsh bytes.
|
|
386
|
+
*/
|
|
387
|
+
serialize(input: unknown, index: number): Uint8Array;
|
|
388
|
+
/**
|
|
389
|
+
* Serialize a runtime call to Borsh bytes.
|
|
390
|
+
*
|
|
391
|
+
* @param input - The runtime call to serialize.
|
|
392
|
+
* @returns The serialized Borsh bytes.
|
|
393
|
+
*/
|
|
394
|
+
serializeRuntimeCall(input: unknown): Uint8Array;
|
|
395
|
+
/**
|
|
396
|
+
* Serialize an unsigned transaction to Borsh bytes.
|
|
397
|
+
*
|
|
398
|
+
* @param input - The unsigned transaction to serialize.
|
|
399
|
+
* @returns The serialized Borsh bytes.
|
|
400
|
+
*/
|
|
401
|
+
serializeUnsignedTx(input: unknown): Uint8Array;
|
|
402
|
+
/**
|
|
403
|
+
* Serialize a transaction to Borsh bytes.
|
|
404
|
+
*
|
|
405
|
+
* @param input - The transaction to serialize.
|
|
406
|
+
* @returns The serialized Borsh bytes.
|
|
407
|
+
*/
|
|
408
|
+
serializeTx(input: unknown): Uint8Array;
|
|
409
|
+
/** Returns the Schema JSON used by the serializer. */
|
|
410
|
+
get schema(): RollupSchema;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
type SolanaOffchainUnsignedTransaction<RuntimeCall> = {
|
|
414
|
+
runtime_call: RuntimeCall;
|
|
415
|
+
uniqueness: {
|
|
416
|
+
nonce: number;
|
|
417
|
+
} | {
|
|
418
|
+
generation: number;
|
|
419
|
+
};
|
|
420
|
+
details: {
|
|
421
|
+
max_priority_fee_bips: number;
|
|
422
|
+
max_fee: string;
|
|
423
|
+
gas_limit: number[] | null;
|
|
424
|
+
chain_id: number;
|
|
425
|
+
};
|
|
426
|
+
chain_name: string;
|
|
427
|
+
};
|
|
428
|
+
type SolanaOffchainSimpleMessage = {
|
|
429
|
+
signed_message: Uint8Array;
|
|
430
|
+
chain_hash: Uint8Array;
|
|
431
|
+
pubkey: Uint8Array;
|
|
432
|
+
signature: Uint8Array;
|
|
433
|
+
};
|
|
434
|
+
type SolanaOffchainSpecCompliantMessage = {
|
|
435
|
+
signed_message_with_preamble: Uint8Array;
|
|
436
|
+
signature: Uint8Array;
|
|
437
|
+
};
|
|
438
|
+
type Authenticator = "standard" | "solanaSimple" | "solana" | "solanaAuto";
|
|
439
|
+
/**
|
|
440
|
+
* Creates a Solana offchain message preamble according to the spec.
|
|
441
|
+
* See https://docs.anza.xyz/proposals/off-chain-message-signing#message-preamble
|
|
442
|
+
*/
|
|
443
|
+
declare function createSolanaPreamble(pubkey: Uint8Array, chainHash: Uint8Array, messageLength: number): Uint8Array;
|
|
444
|
+
declare class SolanaSignableRollup<RuntimeCall> {
|
|
445
|
+
private inner;
|
|
446
|
+
private solanaEndpoint;
|
|
447
|
+
private typeBuilder;
|
|
448
|
+
constructor(inner: StandardRollup<RuntimeCall>, solanaEndpoint?: string);
|
|
449
|
+
/**
|
|
450
|
+
* Determines the appropriate authenticator based on the signer type.
|
|
451
|
+
* Returns "solana" for LedgerSolanaSigner (hardware wallet with spec-compliant signing)
|
|
452
|
+
* and "solanaSimple" for software signers.
|
|
453
|
+
*/
|
|
454
|
+
private getAutoAuthenticator;
|
|
455
|
+
/**
|
|
456
|
+
* Submits serialized data to the Solana endpoint.
|
|
457
|
+
*/
|
|
458
|
+
private submitSerializedMessage;
|
|
459
|
+
/**
|
|
460
|
+
* Submits a Solana offchain message to the rollup.
|
|
461
|
+
*/
|
|
462
|
+
private submitSolanaMessage;
|
|
463
|
+
/**
|
|
464
|
+
* Submits a Solana spec-compliant message to the rollup.
|
|
465
|
+
*/
|
|
466
|
+
private submitSolanaSpecMessage;
|
|
467
|
+
/**
|
|
468
|
+
* Helper to build an unsigned transaction using the standard type builder.
|
|
469
|
+
*/
|
|
470
|
+
private buildUnsignedTransaction;
|
|
471
|
+
/**
|
|
472
|
+
* Helper to build a transaction result object.
|
|
473
|
+
*/
|
|
474
|
+
private buildTransactionResult;
|
|
475
|
+
/**
|
|
476
|
+
* Helper to create and serialize a SolanaOffchainUnsignedTransaction to JSON bytes.
|
|
477
|
+
*/
|
|
478
|
+
private createSolanaJsonBytes;
|
|
479
|
+
/**
|
|
480
|
+
* Signs an unsigned transaction using Solana offchain simple signing and submits it.
|
|
481
|
+
* Returns the transaction result in the same format as standard rollup.
|
|
482
|
+
*/
|
|
483
|
+
private signWithSolanaSimpleAndSubmit;
|
|
484
|
+
/**
|
|
485
|
+
* Signs an unsigned transaction using Solana spec-compliant signing and submits it.
|
|
486
|
+
* Returns the transaction result in the same format as standard rollup.
|
|
487
|
+
*/
|
|
488
|
+
private signWithSolanaSpecAndSubmit;
|
|
489
|
+
/**
|
|
490
|
+
* Performs a runtime call transaction with the specified authenticator.
|
|
491
|
+
*
|
|
492
|
+
* @param runtimeCall - The runtime call to execute
|
|
493
|
+
* @param params - Parameters including signer, authenticator type, and optional overrides
|
|
494
|
+
* @param options - Optional request options
|
|
495
|
+
* @returns The transaction result including hash and transaction object
|
|
496
|
+
*/
|
|
497
|
+
call(runtimeCall: RuntimeCall, params: {
|
|
498
|
+
signer: Signer;
|
|
499
|
+
authenticator: Authenticator;
|
|
500
|
+
overrides?: DeepPartial<UnsignedTransaction<RuntimeCall>>;
|
|
501
|
+
}, options?: SovereignClient__default.RequestOptions): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
502
|
+
/**
|
|
503
|
+
* Signs and submits a transaction with the specified authenticator.
|
|
504
|
+
*
|
|
505
|
+
* @param unsignedTx - The unsigned transaction to sign and submit
|
|
506
|
+
* @param params - Parameters including signer and authenticator type
|
|
507
|
+
* @param options - Optional request options
|
|
508
|
+
* @returns The transaction result
|
|
509
|
+
*/
|
|
510
|
+
signAndSubmitTransaction(unsignedTx: UnsignedTransaction<RuntimeCall>, params: {
|
|
511
|
+
signer: Signer;
|
|
512
|
+
authenticator: Authenticator;
|
|
513
|
+
}, options?: SovereignClient__default.RequestOptions): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
514
|
+
/**
|
|
515
|
+
* Submits a standard transaction.
|
|
516
|
+
*/
|
|
517
|
+
submitTransaction(transaction: StandardRollupSpec<RuntimeCall>["Transaction"], authenticator: "standard", options?: SovereignClient__default.RequestOptions): Promise<SovereignClient__default.Sequencer.TxCreateResponse>;
|
|
518
|
+
/**
|
|
519
|
+
* Submits a Solana offchain message.
|
|
520
|
+
*/
|
|
521
|
+
submitTransaction(transaction: SolanaOffchainSimpleMessage, authenticator: "solanaSimple", options?: SovereignClient__default.RequestOptions): Promise<SovereignClient__default.Sequencer.TxCreateResponse>;
|
|
522
|
+
/**
|
|
523
|
+
* Submits a Solana spec-compliant message.
|
|
524
|
+
*/
|
|
525
|
+
submitTransaction(transaction: SolanaOffchainSpecCompliantMessage, authenticator: "solana", options?: SovereignClient__default.RequestOptions): Promise<SovereignClient__default.Sequencer.TxCreateResponse>;
|
|
526
|
+
simulate(runtimeMessage: RuntimeCall, params: Parameters<StandardRollup<RuntimeCall>["simulate"]>[1]): Promise<SovereignClient__default.Rollup.RollupSimulateResponse>;
|
|
527
|
+
dedup(address: Uint8Array): Promise<Dedup>;
|
|
528
|
+
serializer(): Promise<Serializer>;
|
|
529
|
+
chainHash(): Promise<Uint8Array>;
|
|
530
|
+
healthcheck(timeout?: number): Promise<boolean>;
|
|
531
|
+
subscribe<T extends keyof SubscriptionToCallbackMap>(type: T, callback: SubscriptionToCallbackMap[T]): Subscription;
|
|
532
|
+
get context(): StandardRollupContext;
|
|
533
|
+
get ledger(): SovereignClient__default.Ledger;
|
|
534
|
+
get sequencer(): SovereignClient__default.Sequencer;
|
|
535
|
+
get rollup(): SovereignClient__default.Rollup;
|
|
536
|
+
get http(): SovereignClient__default;
|
|
537
|
+
/**
|
|
538
|
+
* Helper method to serialize a SolanaOffchainSimpleMessage using borsh encoding.
|
|
539
|
+
*/
|
|
540
|
+
private serializeSolanaMessage;
|
|
541
|
+
/**
|
|
542
|
+
* Helper method to serialize a SolanaOffchainSpecCompliantMessage using borsh encoding.
|
|
543
|
+
*/
|
|
544
|
+
private serializeSolanaSpecMessage;
|
|
545
|
+
}
|
|
546
|
+
declare function createSolanaSignableRollup<RuntimeCall>(rollupConfig?: Partial<RollupConfig<DeepPartial<StandardRollupContext>>>, solanaEndpoint?: string): Promise<SolanaSignableRollup<RuntimeCall>>;
|
|
547
|
+
|
|
373
548
|
/**
|
|
374
549
|
* Base error class for Sovereign SDK Web3.
|
|
375
550
|
*/
|
|
@@ -390,4 +565,4 @@ declare class SchemaError extends SovereignError {
|
|
|
390
565
|
constructor(message: string, reason: string, schema: object);
|
|
391
566
|
}
|
|
392
567
|
|
|
393
|
-
export { type BaseTypeSpec, type CallParams, DEFAULT_TX_DETAILS, type Dedup, type EventPayload,
|
|
568
|
+
export { type Authenticator, type BaseTypeSpec, type CallParams, DEFAULT_TX_DETAILS, type Dedup, type EventPayload, InvalidRollupConfigError, Rollup, type RollupConfig, type RollupContext, type RollupTypeSpec, SchemaError, type SignerParams, type SimulateParams, type SolanaOffchainSimpleMessage, type SolanaOffchainSpecCompliantMessage, type SolanaOffchainUnsignedTransaction, SolanaSignableRollup, SovereignError, StandardRollup, type StandardRollupContext, type StandardRollupSpec, type Subscription, type TransactionContext, type TransactionResult, type TypeBuilder, type UnsignedTransactionContext, VersionMismatchError, addressFromPublicKey, createSolanaPreamble, createSolanaSignableRollup, createStandardRollup, standardTypeBuilder };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,9 @@ import { HexString } from '@sovereign-sdk/utils';
|
|
|
2
2
|
import SovereignClient__default from '@sovereign-sdk/client';
|
|
3
3
|
import * as SovereignClient from '@sovereign-sdk/client';
|
|
4
4
|
export { SovereignClient };
|
|
5
|
-
import { RollupSchema, Serializer } from '@sovereign-sdk/serializers';
|
|
5
|
+
import { RollupSchema as RollupSchema$1, Serializer as Serializer$1 } from '@sovereign-sdk/serializers';
|
|
6
6
|
import { Signer } from '@sovereign-sdk/signers';
|
|
7
|
+
import { TxDetails, UnsignedTransaction, Transaction } from '@sovereign-sdk/types';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Encodes a public key as a bech32m address with the given human-readable part (hrp).
|
|
@@ -154,7 +155,7 @@ type RollupConfig<C extends RollupContext> = {
|
|
|
154
155
|
* This can be called more than once, for example if the chain hash changes (i.e a new rollup version)
|
|
155
156
|
* is detected then it will be called again with the new rollup schema.
|
|
156
157
|
*/
|
|
157
|
-
getSerializer: (schema: RollupSchema) => Serializer;
|
|
158
|
+
getSerializer: (schema: RollupSchema$1) => Serializer$1;
|
|
158
159
|
/**
|
|
159
160
|
* Arbitrary context that is associated with the rollup.
|
|
160
161
|
*/
|
|
@@ -307,7 +308,7 @@ declare class Rollup<S extends BaseTypeSpec, C extends RollupContext> {
|
|
|
307
308
|
* The serializer for the rollup.
|
|
308
309
|
* Can be used to serialize transactions, runtime calls, etc.
|
|
309
310
|
*/
|
|
310
|
-
serializer(): Promise<Serializer>;
|
|
311
|
+
serializer(): Promise<Serializer$1>;
|
|
311
312
|
/**
|
|
312
313
|
* The context for the rollup.
|
|
313
314
|
*/
|
|
@@ -315,31 +316,6 @@ declare class Rollup<S extends BaseTypeSpec, C extends RollupContext> {
|
|
|
315
316
|
chainHash(): Promise<Uint8Array>;
|
|
316
317
|
}
|
|
317
318
|
|
|
318
|
-
type TxDetails = {
|
|
319
|
-
max_priority_fee_bips: number;
|
|
320
|
-
max_fee: string;
|
|
321
|
-
gas_limit: number[] | null;
|
|
322
|
-
chain_id: number;
|
|
323
|
-
};
|
|
324
|
-
type Generation = {
|
|
325
|
-
generation: number;
|
|
326
|
-
};
|
|
327
|
-
type Nonce = {
|
|
328
|
-
nonce: number;
|
|
329
|
-
};
|
|
330
|
-
type Uniqueness = Nonce | Generation;
|
|
331
|
-
type UnsignedTransaction<RuntimeCall> = {
|
|
332
|
-
runtime_call: RuntimeCall;
|
|
333
|
-
uniqueness: Uniqueness;
|
|
334
|
-
details: TxDetails;
|
|
335
|
-
};
|
|
336
|
-
type TransactionV0<RuntimeCall> = {
|
|
337
|
-
pub_key: HexString;
|
|
338
|
-
signature: HexString;
|
|
339
|
-
} & UnsignedTransaction<RuntimeCall>;
|
|
340
|
-
type Transaction<RuntimeCall> = {
|
|
341
|
-
V0: TransactionV0<RuntimeCall>;
|
|
342
|
-
};
|
|
343
319
|
type Dedup = {
|
|
344
320
|
nonce: number;
|
|
345
321
|
};
|
|
@@ -370,6 +346,205 @@ declare class StandardRollup<RuntimeCall> extends Rollup<StandardRollupSpec<Runt
|
|
|
370
346
|
declare const DEFAULT_TX_DETAILS: Omit<TxDetails, "chain_id">;
|
|
371
347
|
declare function createStandardRollup<RuntimeCall, C extends StandardRollupContext = StandardRollupContext>(rollupConfig?: Partial<RollupConfig<DeepPartial<C>>>, typeBuilderOverrides?: Partial<TypeBuilder<StandardRollupSpec<RuntimeCall>, C>>): Promise<StandardRollup<RuntimeCall>>;
|
|
372
348
|
|
|
349
|
+
/**
|
|
350
|
+
* A rollup schema is a description of the types that are utilized in the rollup.
|
|
351
|
+
* It is used to serialize and deserialize the types.
|
|
352
|
+
* As well as display them in a human-readable way that is verified by the rollup.
|
|
353
|
+
*/
|
|
354
|
+
type RollupSchema = Record<string, any>;
|
|
355
|
+
/**
|
|
356
|
+
* A serializer is used to serialize rollup types to Borsh bytes.
|
|
357
|
+
*
|
|
358
|
+
* @example
|
|
359
|
+
* ```typescript
|
|
360
|
+
* const serializer = createSerializer(yourSchema);
|
|
361
|
+
* const runtimeCall = {
|
|
362
|
+
* value_setter: {
|
|
363
|
+
* set_value: {
|
|
364
|
+
* value: 100,
|
|
365
|
+
* gas: null
|
|
366
|
+
* },
|
|
367
|
+
* },
|
|
368
|
+
* };
|
|
369
|
+
* const borshBytes = serializer.serializeRuntimeCall(runtimeCall);
|
|
370
|
+
* ```
|
|
371
|
+
*/
|
|
372
|
+
declare abstract class Serializer {
|
|
373
|
+
protected _schema: RollupSchema;
|
|
374
|
+
constructor(schema: RollupSchema);
|
|
375
|
+
protected abstract jsonToBorsh(input: unknown, index: number): Uint8Array;
|
|
376
|
+
private lookupKnownTypeIndex;
|
|
377
|
+
/**
|
|
378
|
+
* Serialize an input to Borsh bytes.
|
|
379
|
+
*
|
|
380
|
+
* Treats `Uint8Array` as a plain array of numbers as this is the format used by universal-wallet
|
|
381
|
+
* to represent Borsh bytes.
|
|
382
|
+
*
|
|
383
|
+
* @param input - The input to serialize.
|
|
384
|
+
* @param index - The index of the type in the schema to serialize.
|
|
385
|
+
* @returns The serialized Borsh bytes.
|
|
386
|
+
*/
|
|
387
|
+
serialize(input: unknown, index: number): Uint8Array;
|
|
388
|
+
/**
|
|
389
|
+
* Serialize a runtime call to Borsh bytes.
|
|
390
|
+
*
|
|
391
|
+
* @param input - The runtime call to serialize.
|
|
392
|
+
* @returns The serialized Borsh bytes.
|
|
393
|
+
*/
|
|
394
|
+
serializeRuntimeCall(input: unknown): Uint8Array;
|
|
395
|
+
/**
|
|
396
|
+
* Serialize an unsigned transaction to Borsh bytes.
|
|
397
|
+
*
|
|
398
|
+
* @param input - The unsigned transaction to serialize.
|
|
399
|
+
* @returns The serialized Borsh bytes.
|
|
400
|
+
*/
|
|
401
|
+
serializeUnsignedTx(input: unknown): Uint8Array;
|
|
402
|
+
/**
|
|
403
|
+
* Serialize a transaction to Borsh bytes.
|
|
404
|
+
*
|
|
405
|
+
* @param input - The transaction to serialize.
|
|
406
|
+
* @returns The serialized Borsh bytes.
|
|
407
|
+
*/
|
|
408
|
+
serializeTx(input: unknown): Uint8Array;
|
|
409
|
+
/** Returns the Schema JSON used by the serializer. */
|
|
410
|
+
get schema(): RollupSchema;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
type SolanaOffchainUnsignedTransaction<RuntimeCall> = {
|
|
414
|
+
runtime_call: RuntimeCall;
|
|
415
|
+
uniqueness: {
|
|
416
|
+
nonce: number;
|
|
417
|
+
} | {
|
|
418
|
+
generation: number;
|
|
419
|
+
};
|
|
420
|
+
details: {
|
|
421
|
+
max_priority_fee_bips: number;
|
|
422
|
+
max_fee: string;
|
|
423
|
+
gas_limit: number[] | null;
|
|
424
|
+
chain_id: number;
|
|
425
|
+
};
|
|
426
|
+
chain_name: string;
|
|
427
|
+
};
|
|
428
|
+
type SolanaOffchainSimpleMessage = {
|
|
429
|
+
signed_message: Uint8Array;
|
|
430
|
+
chain_hash: Uint8Array;
|
|
431
|
+
pubkey: Uint8Array;
|
|
432
|
+
signature: Uint8Array;
|
|
433
|
+
};
|
|
434
|
+
type SolanaOffchainSpecCompliantMessage = {
|
|
435
|
+
signed_message_with_preamble: Uint8Array;
|
|
436
|
+
signature: Uint8Array;
|
|
437
|
+
};
|
|
438
|
+
type Authenticator = "standard" | "solanaSimple" | "solana" | "solanaAuto";
|
|
439
|
+
/**
|
|
440
|
+
* Creates a Solana offchain message preamble according to the spec.
|
|
441
|
+
* See https://docs.anza.xyz/proposals/off-chain-message-signing#message-preamble
|
|
442
|
+
*/
|
|
443
|
+
declare function createSolanaPreamble(pubkey: Uint8Array, chainHash: Uint8Array, messageLength: number): Uint8Array;
|
|
444
|
+
declare class SolanaSignableRollup<RuntimeCall> {
|
|
445
|
+
private inner;
|
|
446
|
+
private solanaEndpoint;
|
|
447
|
+
private typeBuilder;
|
|
448
|
+
constructor(inner: StandardRollup<RuntimeCall>, solanaEndpoint?: string);
|
|
449
|
+
/**
|
|
450
|
+
* Determines the appropriate authenticator based on the signer type.
|
|
451
|
+
* Returns "solana" for LedgerSolanaSigner (hardware wallet with spec-compliant signing)
|
|
452
|
+
* and "solanaSimple" for software signers.
|
|
453
|
+
*/
|
|
454
|
+
private getAutoAuthenticator;
|
|
455
|
+
/**
|
|
456
|
+
* Submits serialized data to the Solana endpoint.
|
|
457
|
+
*/
|
|
458
|
+
private submitSerializedMessage;
|
|
459
|
+
/**
|
|
460
|
+
* Submits a Solana offchain message to the rollup.
|
|
461
|
+
*/
|
|
462
|
+
private submitSolanaMessage;
|
|
463
|
+
/**
|
|
464
|
+
* Submits a Solana spec-compliant message to the rollup.
|
|
465
|
+
*/
|
|
466
|
+
private submitSolanaSpecMessage;
|
|
467
|
+
/**
|
|
468
|
+
* Helper to build an unsigned transaction using the standard type builder.
|
|
469
|
+
*/
|
|
470
|
+
private buildUnsignedTransaction;
|
|
471
|
+
/**
|
|
472
|
+
* Helper to build a transaction result object.
|
|
473
|
+
*/
|
|
474
|
+
private buildTransactionResult;
|
|
475
|
+
/**
|
|
476
|
+
* Helper to create and serialize a SolanaOffchainUnsignedTransaction to JSON bytes.
|
|
477
|
+
*/
|
|
478
|
+
private createSolanaJsonBytes;
|
|
479
|
+
/**
|
|
480
|
+
* Signs an unsigned transaction using Solana offchain simple signing and submits it.
|
|
481
|
+
* Returns the transaction result in the same format as standard rollup.
|
|
482
|
+
*/
|
|
483
|
+
private signWithSolanaSimpleAndSubmit;
|
|
484
|
+
/**
|
|
485
|
+
* Signs an unsigned transaction using Solana spec-compliant signing and submits it.
|
|
486
|
+
* Returns the transaction result in the same format as standard rollup.
|
|
487
|
+
*/
|
|
488
|
+
private signWithSolanaSpecAndSubmit;
|
|
489
|
+
/**
|
|
490
|
+
* Performs a runtime call transaction with the specified authenticator.
|
|
491
|
+
*
|
|
492
|
+
* @param runtimeCall - The runtime call to execute
|
|
493
|
+
* @param params - Parameters including signer, authenticator type, and optional overrides
|
|
494
|
+
* @param options - Optional request options
|
|
495
|
+
* @returns The transaction result including hash and transaction object
|
|
496
|
+
*/
|
|
497
|
+
call(runtimeCall: RuntimeCall, params: {
|
|
498
|
+
signer: Signer;
|
|
499
|
+
authenticator: Authenticator;
|
|
500
|
+
overrides?: DeepPartial<UnsignedTransaction<RuntimeCall>>;
|
|
501
|
+
}, options?: SovereignClient__default.RequestOptions): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
502
|
+
/**
|
|
503
|
+
* Signs and submits a transaction with the specified authenticator.
|
|
504
|
+
*
|
|
505
|
+
* @param unsignedTx - The unsigned transaction to sign and submit
|
|
506
|
+
* @param params - Parameters including signer and authenticator type
|
|
507
|
+
* @param options - Optional request options
|
|
508
|
+
* @returns The transaction result
|
|
509
|
+
*/
|
|
510
|
+
signAndSubmitTransaction(unsignedTx: UnsignedTransaction<RuntimeCall>, params: {
|
|
511
|
+
signer: Signer;
|
|
512
|
+
authenticator: Authenticator;
|
|
513
|
+
}, options?: SovereignClient__default.RequestOptions): Promise<TransactionResult<Transaction<RuntimeCall>>>;
|
|
514
|
+
/**
|
|
515
|
+
* Submits a standard transaction.
|
|
516
|
+
*/
|
|
517
|
+
submitTransaction(transaction: StandardRollupSpec<RuntimeCall>["Transaction"], authenticator: "standard", options?: SovereignClient__default.RequestOptions): Promise<SovereignClient__default.Sequencer.TxCreateResponse>;
|
|
518
|
+
/**
|
|
519
|
+
* Submits a Solana offchain message.
|
|
520
|
+
*/
|
|
521
|
+
submitTransaction(transaction: SolanaOffchainSimpleMessage, authenticator: "solanaSimple", options?: SovereignClient__default.RequestOptions): Promise<SovereignClient__default.Sequencer.TxCreateResponse>;
|
|
522
|
+
/**
|
|
523
|
+
* Submits a Solana spec-compliant message.
|
|
524
|
+
*/
|
|
525
|
+
submitTransaction(transaction: SolanaOffchainSpecCompliantMessage, authenticator: "solana", options?: SovereignClient__default.RequestOptions): Promise<SovereignClient__default.Sequencer.TxCreateResponse>;
|
|
526
|
+
simulate(runtimeMessage: RuntimeCall, params: Parameters<StandardRollup<RuntimeCall>["simulate"]>[1]): Promise<SovereignClient__default.Rollup.RollupSimulateResponse>;
|
|
527
|
+
dedup(address: Uint8Array): Promise<Dedup>;
|
|
528
|
+
serializer(): Promise<Serializer>;
|
|
529
|
+
chainHash(): Promise<Uint8Array>;
|
|
530
|
+
healthcheck(timeout?: number): Promise<boolean>;
|
|
531
|
+
subscribe<T extends keyof SubscriptionToCallbackMap>(type: T, callback: SubscriptionToCallbackMap[T]): Subscription;
|
|
532
|
+
get context(): StandardRollupContext;
|
|
533
|
+
get ledger(): SovereignClient__default.Ledger;
|
|
534
|
+
get sequencer(): SovereignClient__default.Sequencer;
|
|
535
|
+
get rollup(): SovereignClient__default.Rollup;
|
|
536
|
+
get http(): SovereignClient__default;
|
|
537
|
+
/**
|
|
538
|
+
* Helper method to serialize a SolanaOffchainSimpleMessage using borsh encoding.
|
|
539
|
+
*/
|
|
540
|
+
private serializeSolanaMessage;
|
|
541
|
+
/**
|
|
542
|
+
* Helper method to serialize a SolanaOffchainSpecCompliantMessage using borsh encoding.
|
|
543
|
+
*/
|
|
544
|
+
private serializeSolanaSpecMessage;
|
|
545
|
+
}
|
|
546
|
+
declare function createSolanaSignableRollup<RuntimeCall>(rollupConfig?: Partial<RollupConfig<DeepPartial<StandardRollupContext>>>, solanaEndpoint?: string): Promise<SolanaSignableRollup<RuntimeCall>>;
|
|
547
|
+
|
|
373
548
|
/**
|
|
374
549
|
* Base error class for Sovereign SDK Web3.
|
|
375
550
|
*/
|
|
@@ -390,4 +565,4 @@ declare class SchemaError extends SovereignError {
|
|
|
390
565
|
constructor(message: string, reason: string, schema: object);
|
|
391
566
|
}
|
|
392
567
|
|
|
393
|
-
export { type BaseTypeSpec, type CallParams, DEFAULT_TX_DETAILS, type Dedup, type EventPayload,
|
|
568
|
+
export { type Authenticator, type BaseTypeSpec, type CallParams, DEFAULT_TX_DETAILS, type Dedup, type EventPayload, InvalidRollupConfigError, Rollup, type RollupConfig, type RollupContext, type RollupTypeSpec, SchemaError, type SignerParams, type SimulateParams, type SolanaOffchainSimpleMessage, type SolanaOffchainSpecCompliantMessage, type SolanaOffchainUnsignedTransaction, SolanaSignableRollup, SovereignError, StandardRollup, type StandardRollupContext, type StandardRollupSpec, type Subscription, type TransactionContext, type TransactionResult, type TypeBuilder, type UnsignedTransactionContext, VersionMismatchError, addressFromPublicKey, createSolanaPreamble, createSolanaSignableRollup, createStandardRollup, standardTypeBuilder };
|