shell-sdk 0.3.1 → 0.4.1
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/CHANGELOG.md +25 -0
- package/dist/adapters.js +2 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/keystore.js +1 -1
- package/dist/provider.d.ts +55 -1
- package/dist/provider.js +63 -0
- package/dist/signer.d.ts +6 -3
- package/dist/signer.js +11 -6
- package/dist/transactions.d.ts +129 -1
- package/dist/transactions.js +164 -1
- package/dist/types.d.ts +159 -5
- package/dist/types.js +13 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.4.1] — 2026-04-25
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
- `estimateBatch` JSDoc updated to reflect snake_case field names (`total_gas`, `inner_gas`) aligning with `shell-chain v0.18.1` wire format.
|
|
7
|
+
|
|
8
|
+
## [0.4.0] — 2026-05-16
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **Native AA batch transactions** (`tx_type = 0x7E`): `buildBatchTransaction`, `buildSponsoredTransaction`, `buildInnerTransfer`, `buildInnerCall`, `hashBatchTransaction` in `transactions.ts`.
|
|
12
|
+
- `hashBatchTransaction` computes the `batch_signing_hash` (domain `0x42 || RLP(tx) || RLP(bundle)`), required for signing AA bundle txs.
|
|
13
|
+
- **AA types** (`types.ts`): `AaInnerCall`, `AaBundle`, `ShellBatchInnerCallRequest`, `ShellEstimateBatchRequest`, `ShellEstimateBatchResult`, `ShellBatchInnerGas`, `ShellPaymasterPolicy`, `ShellIsSponsoredResult`.
|
|
14
|
+
- Constants: `AA_BUNDLE_TX_TYPE = 0x7e`, `AA_MAX_INNER_CALLS = 16`.
|
|
15
|
+
- `SignedShellTransaction` now has optional `aa_bundle?: AaBundle` field.
|
|
16
|
+
- **AA provider methods** (`provider.ts`): `estimateBatch`, `getPaymasterPolicy`, `isSponsored`, `verifyWitnessRoot`.
|
|
17
|
+
- **ML-DSA-65 canonical naming** (`signer.ts`): `"ML-DSA-65"` is now the first-class `SignatureTypeName` (FIPS 204). `"Dilithium3"` and `"MlDsa65"` remain as compatibility aliases, all mapping to algorithm ID `0`.
|
|
18
|
+
- `KEY_TYPE_TO_SIGNATURE_TYPE` now maps all ML-DSA-65 variants (including `"dilithium3"`) to `"ML-DSA-65"`.
|
|
19
|
+
- **New exports** (`index.ts`): `SIGNATURE_TYPE_IDS`, `KEY_TYPE_TO_SIGNATURE_TYPE`, all new AA builders and types.
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
- `SIGNATURE_TYPE_IDS`: `"MlDsa65"` now maps to `0` (was `1`) — aligns with chain algorithm ID; no wire-format change.
|
|
23
|
+
|
|
24
|
+
### Compatibility
|
|
25
|
+
- Fully backwards-compatible with `shell-chain v0.17.0` and prior SDK `0.3.x` usage.
|
|
26
|
+
- AA fields (`aa_bundle`, new RPC methods) are only active on `shell-chain v0.18.0+`.
|
|
27
|
+
|
|
3
28
|
## [0.3.1] — 2026-04-23
|
|
4
29
|
|
|
5
30
|
### Changed
|
package/dist/adapters.js
CHANGED
|
@@ -164,6 +164,7 @@ export class SlhDsaAdapter {
|
|
|
164
164
|
*/
|
|
165
165
|
export function generateAdapter(algorithm, seed) {
|
|
166
166
|
switch (algorithm) {
|
|
167
|
+
case "ML-DSA-65":
|
|
167
168
|
case "Dilithium3":
|
|
168
169
|
case "MlDsa65":
|
|
169
170
|
return MlDsa65Adapter.generate(seed);
|
|
@@ -189,6 +190,7 @@ export function generateAdapter(algorithm, seed) {
|
|
|
189
190
|
*/
|
|
190
191
|
export function adapterFromKeyPair(algorithm, publicKey, secretKey) {
|
|
191
192
|
switch (algorithm) {
|
|
193
|
+
case "ML-DSA-65":
|
|
192
194
|
case "Dilithium3":
|
|
193
195
|
case "MlDsa65":
|
|
194
196
|
return MlDsa65Adapter.fromKeyPair(publicKey, secretKey);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { bytesToHexAddress, PQ_ADDRESS_HRP, PQ_ADDRESS_LENGTH, PQ_ADDRESS_VERSION_V1, bytesToPqAddress, derivePqAddressFromPublicKey, isPqAddress, normalizeHexAddress, normalizePqAddress, pqAddressVersion, pqAddressToBytes, } from "./address.js";
|
|
2
2
|
export { createShellProvider, createShellPublicClient, createShellWsClient, ShellProvider, shellDevnet, type CreateShellPublicClientOptions, } from "./provider.js";
|
|
3
3
|
export { accountManagerAddress, accountManagerHexAddress, clearValidationCodeSelector, encodeClearValidationCodeCalldata, encodeRotateKeyCalldata, encodeSetValidationCodeCalldata, isSystemContractAddress, rotateKeySelector, setValidationCodeSelector, validatorRegistryAddress, validatorRegistryHexAddress, } from "./system-contracts.js";
|
|
4
|
-
export { buildClearValidationCodeTransaction, buildRotateKeyTransaction, buildSetValidationCodeTransaction, buildSignature, buildSignedTransaction, buildSystemTransaction, buildTransaction, buildTransferTransaction, DEFAULT_MAX_FEE_PER_GAS, DEFAULT_MAX_PRIORITY_FEE_PER_GAS, DEFAULT_SYSTEM_GAS_LIMIT, DEFAULT_TRANSFER_GAS_LIMIT, DEFAULT_TX_TYPE, hashTransaction, } from "./transactions.js";
|
|
4
|
+
export { AA_BUNDLE_TX_TYPE, AA_MAX_INNER_CALLS, buildBatchTransaction, buildClearValidationCodeTransaction, buildInnerCall, buildInnerTransfer, buildRotateKeyTransaction, buildSetValidationCodeTransaction, buildSignature, buildSignedTransaction, buildSponsoredTransaction, buildSystemTransaction, buildTransaction, buildTransferTransaction, DEFAULT_AA_GAS_LIMIT, DEFAULT_MAX_FEE_PER_GAS, DEFAULT_MAX_PRIORITY_FEE_PER_GAS, DEFAULT_SYSTEM_GAS_LIMIT, DEFAULT_TRANSFER_GAS_LIMIT, DEFAULT_TX_TYPE, hashBatchTransaction, hashTransaction, type BuildBatchTransactionOptions, type BuildSponsoredTransactionOptions, } from "./transactions.js";
|
|
5
5
|
export { assertSignerMatchesKeystore, decryptKeystore, exportEncryptedKeyJson, parseEncryptedKey, validateEncryptedKeyAddress, type ParsedShellKeystore, } from "./keystore.js";
|
|
6
6
|
export { adapterFromKeyPair, generateAdapter, generateMlDsa65KeyPair, generateSlhDsaKeyPair, MlDsa65Adapter, SlhDsaAdapter, type MlDsa65KeyPair, type SlhDsaKeyPair, } from "./adapters.js";
|
|
7
7
|
export { buildShellSignature, publicKeyFromHex, ShellSigner, signatureTypeFromKeyType, type SignerAdapter, } from "./signer.js";
|
|
8
|
-
export type { AddressLike, HexString, ShellAccessListItem, ShellCipherParams, ShellEncryptedKey,
|
|
8
|
+
export type { AaBundle, AaInnerCall, AddressLike, HexString, ShellAccessListItem, ShellBatchInnerCallRequest, ShellBatchInnerGas, ShellCipherParams, ShellEncryptedKey, ShellEstimateBatchRequest, ShellEstimateBatchResult, ShellIsSponsoredResult, ShellKdfParams, ShellNodeInfo, ShellPaymasterPolicy, ShellSendTransactionParams, ShellSignature, ShellStorageProfile, ShellTransactionRequest, ShellTxByAddressPage, ShellTxWitness, ShellWitnessBundle, ShellWitnessRootResult, SignedShellTransaction, SignatureTypeName, } from "./types.js";
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { bytesToHexAddress, PQ_ADDRESS_HRP, PQ_ADDRESS_LENGTH, PQ_ADDRESS_VERSION_V1, bytesToPqAddress, derivePqAddressFromPublicKey, isPqAddress, normalizeHexAddress, normalizePqAddress, pqAddressVersion, pqAddressToBytes, } from "./address.js";
|
|
2
2
|
export { createShellProvider, createShellPublicClient, createShellWsClient, ShellProvider, shellDevnet, } from "./provider.js";
|
|
3
3
|
export { accountManagerAddress, accountManagerHexAddress, clearValidationCodeSelector, encodeClearValidationCodeCalldata, encodeRotateKeyCalldata, encodeSetValidationCodeCalldata, isSystemContractAddress, rotateKeySelector, setValidationCodeSelector, validatorRegistryAddress, validatorRegistryHexAddress, } from "./system-contracts.js";
|
|
4
|
-
export { buildClearValidationCodeTransaction, buildRotateKeyTransaction, buildSetValidationCodeTransaction, buildSignature, buildSignedTransaction, buildSystemTransaction, buildTransaction, buildTransferTransaction, DEFAULT_MAX_FEE_PER_GAS, DEFAULT_MAX_PRIORITY_FEE_PER_GAS, DEFAULT_SYSTEM_GAS_LIMIT, DEFAULT_TRANSFER_GAS_LIMIT, DEFAULT_TX_TYPE, hashTransaction, } from "./transactions.js";
|
|
4
|
+
export { AA_BUNDLE_TX_TYPE, AA_MAX_INNER_CALLS, buildBatchTransaction, buildClearValidationCodeTransaction, buildInnerCall, buildInnerTransfer, buildRotateKeyTransaction, buildSetValidationCodeTransaction, buildSignature, buildSignedTransaction, buildSponsoredTransaction, buildSystemTransaction, buildTransaction, buildTransferTransaction, DEFAULT_AA_GAS_LIMIT, DEFAULT_MAX_FEE_PER_GAS, DEFAULT_MAX_PRIORITY_FEE_PER_GAS, DEFAULT_SYSTEM_GAS_LIMIT, DEFAULT_TRANSFER_GAS_LIMIT, DEFAULT_TX_TYPE, hashBatchTransaction, hashTransaction, } from "./transactions.js";
|
|
5
5
|
export { assertSignerMatchesKeystore, decryptKeystore, exportEncryptedKeyJson, parseEncryptedKey, validateEncryptedKeyAddress, } from "./keystore.js";
|
|
6
6
|
export { adapterFromKeyPair, generateAdapter, generateMlDsa65KeyPair, generateSlhDsaKeyPair, MlDsa65Adapter, SlhDsaAdapter, } from "./adapters.js";
|
|
7
7
|
export { buildShellSignature, publicKeyFromHex, ShellSigner, signatureTypeFromKeyType, } from "./signer.js";
|
package/dist/keystore.js
CHANGED
|
@@ -18,7 +18,7 @@ import { argon2id } from "hash-wasm";
|
|
|
18
18
|
import { derivePqAddressFromPublicKey, normalizeHexAddress, normalizePqAddress } from "./address.js";
|
|
19
19
|
import { adapterFromKeyPair } from "./adapters.js";
|
|
20
20
|
import { ShellSigner, publicKeyFromHex, signatureTypeFromKeyType } from "./signer.js";
|
|
21
|
-
const SIG_IDS = { Dilithium3: 0, MlDsa65:
|
|
21
|
+
const SIG_IDS = { "ML-DSA-65": 0, Dilithium3: 0, MlDsa65: 0, SphincsSha2256f: 2 };
|
|
22
22
|
/**
|
|
23
23
|
* Parse a Shell keystore file (string or object) and extract public metadata.
|
|
24
24
|
*
|
package/dist/provider.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* @module provider
|
|
17
17
|
*/
|
|
18
18
|
import { type Chain, type PublicClient } from "viem";
|
|
19
|
-
import type { ShellNodeInfo, ShellStorageProfile, ShellWitnessBundle, SignedShellTransaction } from "./types.js";
|
|
19
|
+
import type { ShellEstimateBatchRequest, ShellEstimateBatchResult, ShellIsSponsoredResult, ShellNodeInfo, ShellPaymasterPolicy, ShellStorageProfile, ShellWitnessBundle, ShellWitnessRootResult, SignedShellTransaction } from "./types.js";
|
|
20
20
|
/**
|
|
21
21
|
* Pre-configured viem chain definition for Shell Devnet.
|
|
22
22
|
*
|
|
@@ -183,6 +183,60 @@ export declare class ShellProvider {
|
|
|
183
183
|
* `undefined` if the node does not report it.
|
|
184
184
|
*/
|
|
185
185
|
getStorageProfile(): Promise<ShellStorageProfile | undefined>;
|
|
186
|
+
/**
|
|
187
|
+
* Estimate gas for a native AA batch transaction.
|
|
188
|
+
*
|
|
189
|
+
* Calls `shell_estimateBatch`.
|
|
190
|
+
*
|
|
191
|
+
* @param request - Batch estimate request with inner calls and optional paymaster.
|
|
192
|
+
* @returns Gas estimates including `total_gas`, `per_inner`, and breakdown fields.
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```typescript
|
|
196
|
+
* const estimate = await provider.estimateBatch({
|
|
197
|
+
* inner_calls: [{ to: "pq1…", value: "0x0", gas_limit: "0x5208" }],
|
|
198
|
+
* });
|
|
199
|
+
* const totalGas = parseInt(estimate.total_gas, 16);
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
estimateBatch(request: ShellEstimateBatchRequest): Promise<ShellEstimateBatchResult>;
|
|
203
|
+
/**
|
|
204
|
+
* Fetch the paymaster policy for an address.
|
|
205
|
+
*
|
|
206
|
+
* Calls `shell_getPaymasterPolicy`. Any address returns a default `eoa-open`
|
|
207
|
+
* policy even if not explicitly registered as a paymaster.
|
|
208
|
+
*
|
|
209
|
+
* @param address - Paymaster address to query.
|
|
210
|
+
* @returns Paymaster policy object.
|
|
211
|
+
*/
|
|
212
|
+
getPaymasterPolicy(address: string): Promise<ShellPaymasterPolicy>;
|
|
213
|
+
/**
|
|
214
|
+
* Check whether a transaction is sponsored by a paymaster.
|
|
215
|
+
*
|
|
216
|
+
* Calls `shell_isSponsored`. Returns `{ found: false, … }` for unknown hashes
|
|
217
|
+
* without throwing.
|
|
218
|
+
*
|
|
219
|
+
* @param txHash - Transaction hash to query (`0x`-prefixed).
|
|
220
|
+
* @returns Sponsorship details including found status, paymaster address, and inner call count.
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* ```typescript
|
|
224
|
+
* const result = await provider.isSponsored("0xabcd…");
|
|
225
|
+
* if (result.found && result.sponsored) {
|
|
226
|
+
* console.log("gas paid by", result.paymaster);
|
|
227
|
+
* }
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
isSponsored(txHash: string): Promise<ShellIsSponsoredResult>;
|
|
231
|
+
/**
|
|
232
|
+
* Verify the witness root stored in a block header against the bundle.
|
|
233
|
+
*
|
|
234
|
+
* Calls `shell_verifyWitnessRoot`.
|
|
235
|
+
*
|
|
236
|
+
* @param blockNumberOrTag - Hex block number or `"latest"`.
|
|
237
|
+
* @returns Verification result object `{ block, witnessRoot, bundleRoot, match }`.
|
|
238
|
+
*/
|
|
239
|
+
verifyWitnessRoot(blockNumberOrTag: string): Promise<ShellWitnessRootResult>;
|
|
186
240
|
}
|
|
187
241
|
/**
|
|
188
242
|
* Create a viem `PublicClient` connected to Shell Chain over HTTP.
|
package/dist/provider.js
CHANGED
|
@@ -172,6 +172,69 @@ export class ShellProvider {
|
|
|
172
172
|
const info = await this.getNodeInfo();
|
|
173
173
|
return info.storage_profile;
|
|
174
174
|
}
|
|
175
|
+
// ── AA methods (v0.18.0) ──────────────────────────────────────────────────
|
|
176
|
+
/**
|
|
177
|
+
* Estimate gas for a native AA batch transaction.
|
|
178
|
+
*
|
|
179
|
+
* Calls `shell_estimateBatch`.
|
|
180
|
+
*
|
|
181
|
+
* @param request - Batch estimate request with inner calls and optional paymaster.
|
|
182
|
+
* @returns Gas estimates including `total_gas`, `per_inner`, and breakdown fields.
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```typescript
|
|
186
|
+
* const estimate = await provider.estimateBatch({
|
|
187
|
+
* inner_calls: [{ to: "pq1…", value: "0x0", gas_limit: "0x5208" }],
|
|
188
|
+
* });
|
|
189
|
+
* const totalGas = parseInt(estimate.total_gas, 16);
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
async estimateBatch(request) {
|
|
193
|
+
return this.request("shell_estimateBatch", [request]);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Fetch the paymaster policy for an address.
|
|
197
|
+
*
|
|
198
|
+
* Calls `shell_getPaymasterPolicy`. Any address returns a default `eoa-open`
|
|
199
|
+
* policy even if not explicitly registered as a paymaster.
|
|
200
|
+
*
|
|
201
|
+
* @param address - Paymaster address to query.
|
|
202
|
+
* @returns Paymaster policy object.
|
|
203
|
+
*/
|
|
204
|
+
async getPaymasterPolicy(address) {
|
|
205
|
+
return this.request("shell_getPaymasterPolicy", [address]);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Check whether a transaction is sponsored by a paymaster.
|
|
209
|
+
*
|
|
210
|
+
* Calls `shell_isSponsored`. Returns `{ found: false, … }` for unknown hashes
|
|
211
|
+
* without throwing.
|
|
212
|
+
*
|
|
213
|
+
* @param txHash - Transaction hash to query (`0x`-prefixed).
|
|
214
|
+
* @returns Sponsorship details including found status, paymaster address, and inner call count.
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* ```typescript
|
|
218
|
+
* const result = await provider.isSponsored("0xabcd…");
|
|
219
|
+
* if (result.found && result.sponsored) {
|
|
220
|
+
* console.log("gas paid by", result.paymaster);
|
|
221
|
+
* }
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
async isSponsored(txHash) {
|
|
225
|
+
return this.request("shell_isSponsored", [txHash]);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Verify the witness root stored in a block header against the bundle.
|
|
229
|
+
*
|
|
230
|
+
* Calls `shell_verifyWitnessRoot`.
|
|
231
|
+
*
|
|
232
|
+
* @param blockNumberOrTag - Hex block number or `"latest"`.
|
|
233
|
+
* @returns Verification result object `{ block, witnessRoot, bundleRoot, match }`.
|
|
234
|
+
*/
|
|
235
|
+
async verifyWitnessRoot(blockNumberOrTag) {
|
|
236
|
+
return this.request("shell_verifyWitnessRoot", [blockNumberOrTag]);
|
|
237
|
+
}
|
|
175
238
|
}
|
|
176
239
|
/**
|
|
177
240
|
* Create a viem `PublicClient` connected to Shell Chain over HTTP.
|
package/dist/signer.d.ts
CHANGED
|
@@ -4,9 +4,10 @@ import type { SignedShellTransaction, SignatureTypeName } from "./types.js";
|
|
|
4
4
|
* Maps each {@link SignatureTypeName} to its numeric algorithm ID used in
|
|
5
5
|
* address derivation and on-chain records.
|
|
6
6
|
*
|
|
7
|
-
* - `
|
|
8
|
-
* - `
|
|
9
|
-
* - `
|
|
7
|
+
* - `"ML-DSA-65"` → `0` (canonical FIPS 204 name)
|
|
8
|
+
* - `"Dilithium3"` → `0` (legacy alias, same algorithm)
|
|
9
|
+
* - `"MlDsa65"` → `0` (camelCase alias, same algorithm)
|
|
10
|
+
* - `"SphincsSha2256f"` → `2`
|
|
10
11
|
*/
|
|
11
12
|
export declare const SIGNATURE_TYPE_IDS: Record<SignatureTypeName, number>;
|
|
12
13
|
/**
|
|
@@ -14,6 +15,7 @@ export declare const SIGNATURE_TYPE_IDS: Record<SignatureTypeName, number>;
|
|
|
14
15
|
* corresponding {@link SignatureTypeName}.
|
|
15
16
|
*
|
|
16
17
|
* Keys are lowercase; matching is done after calling `.toLowerCase()`.
|
|
18
|
+
* Always returns the FIPS 204 canonical name `"ML-DSA-65"` for ML-DSA-65 variants.
|
|
17
19
|
*/
|
|
18
20
|
export declare const KEY_TYPE_TO_SIGNATURE_TYPE: Record<string, SignatureTypeName>;
|
|
19
21
|
/**
|
|
@@ -116,6 +118,7 @@ export declare class ShellSigner {
|
|
|
116
118
|
buildSignedTransaction(options: Omit<BuildSignedTransactionOptions, "from" | "signature" | "signatureType"> & {
|
|
117
119
|
txHash: Uint8Array;
|
|
118
120
|
includePublicKey?: boolean;
|
|
121
|
+
aaBundle?: import("./types.js").AaBundle;
|
|
119
122
|
}): Promise<SignedShellTransaction>;
|
|
120
123
|
}
|
|
121
124
|
/**
|
package/dist/signer.js
CHANGED
|
@@ -16,13 +16,15 @@ import { buildSignature, buildSignedTransaction, } from "./transactions.js";
|
|
|
16
16
|
* Maps each {@link SignatureTypeName} to its numeric algorithm ID used in
|
|
17
17
|
* address derivation and on-chain records.
|
|
18
18
|
*
|
|
19
|
-
* - `
|
|
20
|
-
* - `
|
|
21
|
-
* - `
|
|
19
|
+
* - `"ML-DSA-65"` → `0` (canonical FIPS 204 name)
|
|
20
|
+
* - `"Dilithium3"` → `0` (legacy alias, same algorithm)
|
|
21
|
+
* - `"MlDsa65"` → `0` (camelCase alias, same algorithm)
|
|
22
|
+
* - `"SphincsSha2256f"` → `2`
|
|
22
23
|
*/
|
|
23
24
|
export const SIGNATURE_TYPE_IDS = {
|
|
25
|
+
"ML-DSA-65": 0,
|
|
24
26
|
Dilithium3: 0,
|
|
25
|
-
MlDsa65:
|
|
27
|
+
MlDsa65: 0,
|
|
26
28
|
SphincsSha2256f: 2,
|
|
27
29
|
};
|
|
28
30
|
/**
|
|
@@ -30,11 +32,13 @@ export const SIGNATURE_TYPE_IDS = {
|
|
|
30
32
|
* corresponding {@link SignatureTypeName}.
|
|
31
33
|
*
|
|
32
34
|
* Keys are lowercase; matching is done after calling `.toLowerCase()`.
|
|
35
|
+
* Always returns the FIPS 204 canonical name `"ML-DSA-65"` for ML-DSA-65 variants.
|
|
33
36
|
*/
|
|
34
37
|
export const KEY_TYPE_TO_SIGNATURE_TYPE = {
|
|
35
|
-
|
|
38
|
+
"ml-dsa-65": "ML-DSA-65",
|
|
39
|
+
mldsa65: "ML-DSA-65",
|
|
40
|
+
dilithium3: "ML-DSA-65",
|
|
36
41
|
"sphincs-sha2-256f": "SphincsSha2256f",
|
|
37
|
-
mldsa65: "MlDsa65",
|
|
38
42
|
};
|
|
39
43
|
/**
|
|
40
44
|
* High-level Shell Chain signer.
|
|
@@ -131,6 +135,7 @@ export class ShellSigner {
|
|
|
131
135
|
signature,
|
|
132
136
|
signatureType: this.signatureType,
|
|
133
137
|
senderPubkey: options.includePublicKey ? this.getPublicKey() : undefined,
|
|
138
|
+
aaBbundle: options.aaBundle,
|
|
134
139
|
});
|
|
135
140
|
}
|
|
136
141
|
}
|
package/dist/transactions.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { AddressLike, HexString, ShellSignature, ShellTransactionRequest, SignedShellTransaction, SignatureTypeName } from "./types.js";
|
|
1
|
+
import type { AaBundle, AaInnerCall, AddressLike, HexString, ShellSignature, ShellTransactionRequest, SignedShellTransaction, SignatureTypeName } from "./types.js";
|
|
2
|
+
import { AA_BUNDLE_TX_TYPE, AA_MAX_INNER_CALLS } from "./types.js";
|
|
3
|
+
export { AA_BUNDLE_TX_TYPE, AA_MAX_INNER_CALLS };
|
|
2
4
|
/** Default transaction type: `2` (EIP-1559). */
|
|
3
5
|
export declare const DEFAULT_TX_TYPE = 2;
|
|
4
6
|
/** Default gas limit for simple SHELL token transfers (`21_000`). */
|
|
@@ -48,6 +50,8 @@ export interface BuildSignedTransactionOptions {
|
|
|
48
50
|
signatureType: SignatureTypeName;
|
|
49
51
|
/** Optional public key bytes to embed as `sender_pubkey`. */
|
|
50
52
|
senderPubkey?: Uint8Array | number[];
|
|
53
|
+
/** AA bundle to attach when `tx.tx_type === AA_BUNDLE_TX_TYPE`. */
|
|
54
|
+
aaBbundle?: AaBundle;
|
|
51
55
|
}
|
|
52
56
|
/**
|
|
53
57
|
* Low-level transaction builder that maps camelCase options to the
|
|
@@ -206,3 +210,127 @@ export declare function hexBytes(bytes: Uint8Array): HexString;
|
|
|
206
210
|
* @returns 32-byte keccak256 hash as a `Uint8Array`.
|
|
207
211
|
*/
|
|
208
212
|
export declare function hashTransaction(tx: ShellTransactionRequest): Uint8Array;
|
|
213
|
+
/**
|
|
214
|
+
* Options for {@link buildBatchTransaction}.
|
|
215
|
+
*/
|
|
216
|
+
export interface BuildBatchTransactionOptions {
|
|
217
|
+
/** EIP-155 chain ID. */
|
|
218
|
+
chainId: number;
|
|
219
|
+
/** Sender account nonce. */
|
|
220
|
+
nonce: number;
|
|
221
|
+
/** Inner calls to include in the batch. Max {@link AA_MAX_INNER_CALLS}. */
|
|
222
|
+
innerCalls: AaInnerCall[];
|
|
223
|
+
/**
|
|
224
|
+
* Total gas budget for the outer transaction.
|
|
225
|
+
* Should be ≥ sum(innerCalls[i].gas_limit) + 21 000 + overhead.
|
|
226
|
+
* Defaults to `200_000`.
|
|
227
|
+
*/
|
|
228
|
+
gasLimit?: number;
|
|
229
|
+
/** EIP-1559 max fee per gas. Defaults to {@link DEFAULT_MAX_FEE_PER_GAS}. */
|
|
230
|
+
maxFeePerGas?: number;
|
|
231
|
+
/** EIP-1559 priority fee. Defaults to {@link DEFAULT_MAX_PRIORITY_FEE_PER_GAS}. */
|
|
232
|
+
maxPriorityFeePerGas?: number;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Options for {@link buildSponsoredTransaction}.
|
|
236
|
+
*
|
|
237
|
+
* Extends {@link BuildBatchTransactionOptions} with paymaster fields.
|
|
238
|
+
*/
|
|
239
|
+
export interface BuildSponsoredTransactionOptions extends BuildBatchTransactionOptions {
|
|
240
|
+
/** Paymaster address that will pay the gas cost. */
|
|
241
|
+
paymaster: AddressLike;
|
|
242
|
+
/**
|
|
243
|
+
* Paymaster's PQ signature over the `paymaster_signing_hash`.
|
|
244
|
+
* Obtain this from the paymaster service before building the transaction.
|
|
245
|
+
*/
|
|
246
|
+
paymasterSignature: Uint8Array | number[];
|
|
247
|
+
}
|
|
248
|
+
/** Default outer gas budget for AA batch transactions. */
|
|
249
|
+
export declare const DEFAULT_AA_GAS_LIMIT = 200000;
|
|
250
|
+
/**
|
|
251
|
+
* Build a native AA batch transaction (`tx_type = 0x7E`).
|
|
252
|
+
*
|
|
253
|
+
* The resulting `SignedShellTransaction` will have `aa_bundle` set.
|
|
254
|
+
* The caller is responsible for signing the `batch_signing_hash` (use
|
|
255
|
+
* {@link hashBatchTransaction}) rather than the plain `tx.hash()`.
|
|
256
|
+
*
|
|
257
|
+
* @param options - Batch transaction options including inner calls.
|
|
258
|
+
* @returns `{ tx: ShellTransactionRequest; aa_bundle: AaBundle }` — an unsigned transaction
|
|
259
|
+
* skeleton plus bundle. Pass `txHash: hashBatchTransaction(tx, aa_bundle)` and `aa_bundle`
|
|
260
|
+
* into `signer.buildSignedTransaction(...)` to produce the final signed transaction.
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
* ```typescript
|
|
264
|
+
* import { buildBatchTransaction, hashBatchTransaction } from "shell-sdk/transactions";
|
|
265
|
+
*
|
|
266
|
+
* const { tx, aa_bundle } = buildBatchTransaction({
|
|
267
|
+
* chainId: 424242,
|
|
268
|
+
* nonce: 0,
|
|
269
|
+
* innerCalls: [{ to: "pq1recipient…", value: "0x3e8", data: "0x", gas_limit: 21_000 }],
|
|
270
|
+
* });
|
|
271
|
+
* const signingHash = hashBatchTransaction(tx, aa_bundle);
|
|
272
|
+
* const signed = await signer.buildSignedTransaction({ tx, txHash: signingHash, aaBundle: aa_bundle });
|
|
273
|
+
* ```
|
|
274
|
+
*/
|
|
275
|
+
export declare function buildBatchTransaction(options: BuildBatchTransactionOptions): {
|
|
276
|
+
tx: ShellTransactionRequest;
|
|
277
|
+
aa_bundle: AaBundle;
|
|
278
|
+
};
|
|
279
|
+
/**
|
|
280
|
+
* Build a sponsored AA batch transaction (`tx_type = 0x7E`) with a paymaster.
|
|
281
|
+
*
|
|
282
|
+
* Identical to {@link buildBatchTransaction} but also sets `paymaster` and
|
|
283
|
+
* `paymaster_signature` in the bundle.
|
|
284
|
+
*
|
|
285
|
+
* @param options - Sponsored transaction options including paymaster address and signature.
|
|
286
|
+
* @returns An unsigned `SignedShellTransaction` skeleton plus the bundle.
|
|
287
|
+
*
|
|
288
|
+
* @example
|
|
289
|
+
* ```typescript
|
|
290
|
+
* const { tx, aa_bundle } = buildSponsoredTransaction({
|
|
291
|
+
* chainId: 424242,
|
|
292
|
+
* nonce: 0,
|
|
293
|
+
* innerCalls: [...],
|
|
294
|
+
* paymaster: "pq1paymaster…",
|
|
295
|
+
* paymasterSignature: pmSigBytes,
|
|
296
|
+
* });
|
|
297
|
+
* const signingHash = hashBatchTransaction(tx, aa_bundle);
|
|
298
|
+
* const signed = await signer.buildSignedTransaction({ tx, txHash: signingHash, aaBundle: aa_bundle });
|
|
299
|
+
* ```
|
|
300
|
+
*/
|
|
301
|
+
export declare function buildSponsoredTransaction(options: BuildSponsoredTransactionOptions): {
|
|
302
|
+
tx: ShellTransactionRequest;
|
|
303
|
+
aa_bundle: AaBundle;
|
|
304
|
+
};
|
|
305
|
+
/**
|
|
306
|
+
* Compute the `batch_signing_hash` for an AA bundle transaction.
|
|
307
|
+
*
|
|
308
|
+
* This is the hash that the **sender** must sign (not the plain `tx.hash()`).
|
|
309
|
+
* The domain separation prevents replay attacks across tx types.
|
|
310
|
+
*
|
|
311
|
+
* Domain: `keccak256( 0x42 || RLP(tx) || RLP(aa_bundle_signing_fields) )`
|
|
312
|
+
*
|
|
313
|
+
* @param tx - The outer unsigned transaction (must have `tx_type = 0x7E`).
|
|
314
|
+
* @param bundle - The AA bundle that will be attached.
|
|
315
|
+
* @returns 32-byte keccak256 hash as a `Uint8Array`.
|
|
316
|
+
*/
|
|
317
|
+
export declare function hashBatchTransaction(tx: ShellTransactionRequest, bundle: AaBundle): Uint8Array;
|
|
318
|
+
/**
|
|
319
|
+
* Convenience helper: build a minimal `AaInnerCall` for a SHELL token transfer.
|
|
320
|
+
*
|
|
321
|
+
* @param to - Recipient address.
|
|
322
|
+
* @param value - Amount in wei to send.
|
|
323
|
+
* @param gasLimit - Gas limit for this inner call. Defaults to `21_000`.
|
|
324
|
+
* @returns An `AaInnerCall` ready for use in {@link buildBatchTransaction}.
|
|
325
|
+
*/
|
|
326
|
+
export declare function buildInnerTransfer(to: AddressLike, value: bigint, gasLimit?: number): AaInnerCall;
|
|
327
|
+
/**
|
|
328
|
+
* Convenience helper: build a contract-call `AaInnerCall`.
|
|
329
|
+
*
|
|
330
|
+
* @param to - Target contract address.
|
|
331
|
+
* @param data - ABI-encoded calldata.
|
|
332
|
+
* @param gasLimit - Gas limit for this inner call.
|
|
333
|
+
* @param value - Optional ETH value. Defaults to `0n`.
|
|
334
|
+
* @returns An `AaInnerCall` ready for use in {@link buildBatchTransaction}.
|
|
335
|
+
*/
|
|
336
|
+
export declare function buildInnerCall(to: AddressLike, data: HexString, gasLimit: number, value?: bigint): AaInnerCall;
|
package/dist/transactions.js
CHANGED
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Provides typed helpers for constructing `ShellTransactionRequest` objects
|
|
5
5
|
* for common operations: token transfers, system contract calls, key rotation,
|
|
6
|
-
*
|
|
6
|
+
* custom validation code management, and AA batch/sponsored transactions.
|
|
7
7
|
*
|
|
8
8
|
* @module transactions
|
|
9
9
|
*/
|
|
10
10
|
import { bytesToHex, keccak256, toRlp, hexToBytes } from "viem";
|
|
11
|
+
import { AA_BUNDLE_TX_TYPE, AA_MAX_INNER_CALLS } from "./types.js";
|
|
12
|
+
export { AA_BUNDLE_TX_TYPE, AA_MAX_INNER_CALLS };
|
|
11
13
|
import { accountManagerAddress, encodeClearValidationCodeCalldata, encodeRotateKeyCalldata, encodeSetValidationCodeCalldata, } from "./system-contracts.js";
|
|
12
14
|
import { normalizeHexAddress } from "./address.js";
|
|
13
15
|
/** Default transaction type: `2` (EIP-1559). */
|
|
@@ -208,6 +210,7 @@ export function buildSignedTransaction(options) {
|
|
|
208
210
|
tx: options.tx,
|
|
209
211
|
signature: buildSignature(options.signatureType, options.signature),
|
|
210
212
|
sender_pubkey: options.senderPubkey ? toByteArray(options.senderPubkey) : null,
|
|
213
|
+
aa_bundle: options.aaBbundle ?? null,
|
|
211
214
|
};
|
|
212
215
|
}
|
|
213
216
|
/**
|
|
@@ -262,3 +265,163 @@ export function hashTransaction(tx) {
|
|
|
262
265
|
const hash = hexToBytes(keccak256(rlpEncoded));
|
|
263
266
|
return hash;
|
|
264
267
|
}
|
|
268
|
+
// ---------------------------------------------------------------------------
|
|
269
|
+
// AA batch & sponsored transaction builders (v0.18.0)
|
|
270
|
+
// ---------------------------------------------------------------------------
|
|
271
|
+
/** `keccak256` domain prefix byte for the batch signing hash (must match chain). */
|
|
272
|
+
const BATCH_SIGNING_HASH_DOMAIN = 0x42;
|
|
273
|
+
/** Default outer gas budget for AA batch transactions. */
|
|
274
|
+
export const DEFAULT_AA_GAS_LIMIT = 200_000;
|
|
275
|
+
/**
|
|
276
|
+
* Build a native AA batch transaction (`tx_type = 0x7E`).
|
|
277
|
+
*
|
|
278
|
+
* The resulting `SignedShellTransaction` will have `aa_bundle` set.
|
|
279
|
+
* The caller is responsible for signing the `batch_signing_hash` (use
|
|
280
|
+
* {@link hashBatchTransaction}) rather than the plain `tx.hash()`.
|
|
281
|
+
*
|
|
282
|
+
* @param options - Batch transaction options including inner calls.
|
|
283
|
+
* @returns `{ tx: ShellTransactionRequest; aa_bundle: AaBundle }` — an unsigned transaction
|
|
284
|
+
* skeleton plus bundle. Pass `txHash: hashBatchTransaction(tx, aa_bundle)` and `aa_bundle`
|
|
285
|
+
* into `signer.buildSignedTransaction(...)` to produce the final signed transaction.
|
|
286
|
+
*
|
|
287
|
+
* @example
|
|
288
|
+
* ```typescript
|
|
289
|
+
* import { buildBatchTransaction, hashBatchTransaction } from "shell-sdk/transactions";
|
|
290
|
+
*
|
|
291
|
+
* const { tx, aa_bundle } = buildBatchTransaction({
|
|
292
|
+
* chainId: 424242,
|
|
293
|
+
* nonce: 0,
|
|
294
|
+
* innerCalls: [{ to: "pq1recipient…", value: "0x3e8", data: "0x", gas_limit: 21_000 }],
|
|
295
|
+
* });
|
|
296
|
+
* const signingHash = hashBatchTransaction(tx, aa_bundle);
|
|
297
|
+
* const signed = await signer.buildSignedTransaction({ tx, txHash: signingHash, aaBundle: aa_bundle });
|
|
298
|
+
* ```
|
|
299
|
+
*/
|
|
300
|
+
export function buildBatchTransaction(options) {
|
|
301
|
+
if (options.innerCalls.length === 0) {
|
|
302
|
+
throw new Error("buildBatchTransaction: innerCalls must not be empty");
|
|
303
|
+
}
|
|
304
|
+
if (options.innerCalls.length > AA_MAX_INNER_CALLS) {
|
|
305
|
+
throw new Error(`buildBatchTransaction: innerCalls length ${options.innerCalls.length} exceeds AA_MAX_INNER_CALLS (${AA_MAX_INNER_CALLS})`);
|
|
306
|
+
}
|
|
307
|
+
const tx = buildTransaction({
|
|
308
|
+
chainId: options.chainId,
|
|
309
|
+
nonce: options.nonce,
|
|
310
|
+
to: null,
|
|
311
|
+
value: 0n,
|
|
312
|
+
data: "0x",
|
|
313
|
+
gasLimit: options.gasLimit ?? DEFAULT_AA_GAS_LIMIT,
|
|
314
|
+
maxFeePerGas: options.maxFeePerGas ?? DEFAULT_MAX_FEE_PER_GAS,
|
|
315
|
+
maxPriorityFeePerGas: options.maxPriorityFeePerGas ?? DEFAULT_MAX_PRIORITY_FEE_PER_GAS,
|
|
316
|
+
txType: AA_BUNDLE_TX_TYPE,
|
|
317
|
+
});
|
|
318
|
+
const aa_bundle = {
|
|
319
|
+
inner_calls: options.innerCalls,
|
|
320
|
+
paymaster: null,
|
|
321
|
+
paymaster_signature: null,
|
|
322
|
+
};
|
|
323
|
+
return { tx, aa_bundle };
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Build a sponsored AA batch transaction (`tx_type = 0x7E`) with a paymaster.
|
|
327
|
+
*
|
|
328
|
+
* Identical to {@link buildBatchTransaction} but also sets `paymaster` and
|
|
329
|
+
* `paymaster_signature` in the bundle.
|
|
330
|
+
*
|
|
331
|
+
* @param options - Sponsored transaction options including paymaster address and signature.
|
|
332
|
+
* @returns An unsigned `SignedShellTransaction` skeleton plus the bundle.
|
|
333
|
+
*
|
|
334
|
+
* @example
|
|
335
|
+
* ```typescript
|
|
336
|
+
* const { tx, aa_bundle } = buildSponsoredTransaction({
|
|
337
|
+
* chainId: 424242,
|
|
338
|
+
* nonce: 0,
|
|
339
|
+
* innerCalls: [...],
|
|
340
|
+
* paymaster: "pq1paymaster…",
|
|
341
|
+
* paymasterSignature: pmSigBytes,
|
|
342
|
+
* });
|
|
343
|
+
* const signingHash = hashBatchTransaction(tx, aa_bundle);
|
|
344
|
+
* const signed = await signer.buildSignedTransaction({ tx, txHash: signingHash, aaBundle: aa_bundle });
|
|
345
|
+
* ```
|
|
346
|
+
*/
|
|
347
|
+
export function buildSponsoredTransaction(options) {
|
|
348
|
+
const { tx, aa_bundle } = buildBatchTransaction(options);
|
|
349
|
+
aa_bundle.paymaster = options.paymaster;
|
|
350
|
+
aa_bundle.paymaster_signature = Array.from(options.paymasterSignature);
|
|
351
|
+
return { tx, aa_bundle };
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Compute the `batch_signing_hash` for an AA bundle transaction.
|
|
355
|
+
*
|
|
356
|
+
* This is the hash that the **sender** must sign (not the plain `tx.hash()`).
|
|
357
|
+
* The domain separation prevents replay attacks across tx types.
|
|
358
|
+
*
|
|
359
|
+
* Domain: `keccak256( 0x42 || RLP(tx) || RLP(aa_bundle_signing_fields) )`
|
|
360
|
+
*
|
|
361
|
+
* @param tx - The outer unsigned transaction (must have `tx_type = 0x7E`).
|
|
362
|
+
* @param bundle - The AA bundle that will be attached.
|
|
363
|
+
* @returns 32-byte keccak256 hash as a `Uint8Array`.
|
|
364
|
+
*/
|
|
365
|
+
export function hashBatchTransaction(tx, bundle) {
|
|
366
|
+
if (tx.tx_type !== AA_BUNDLE_TX_TYPE) {
|
|
367
|
+
throw new Error(`hashBatchTransaction: tx.tx_type must be AA_BUNDLE_TX_TYPE (0x7E), got ${tx.tx_type}`);
|
|
368
|
+
}
|
|
369
|
+
// Encode inner calls for signing (matches chain's encode_for_signing).
|
|
370
|
+
const innerCallsRlp = bundle.inner_calls.map((call) => [
|
|
371
|
+
call.to ? normalizeHexAddress(call.to) : "0x",
|
|
372
|
+
toRlpUint(call.value),
|
|
373
|
+
call.data,
|
|
374
|
+
toRlpUint(call.gas_limit),
|
|
375
|
+
]);
|
|
376
|
+
// Paymaster: 20-byte address or empty bytes.
|
|
377
|
+
const paymasterField = bundle.paymaster
|
|
378
|
+
? normalizeHexAddress(bundle.paymaster)
|
|
379
|
+
: "0x";
|
|
380
|
+
const txFields = [
|
|
381
|
+
toRlpUint(tx.chain_id),
|
|
382
|
+
toRlpUint(tx.nonce),
|
|
383
|
+
tx.to ? normalizeHexAddress(tx.to) : "0x",
|
|
384
|
+
toRlpUint(tx.value),
|
|
385
|
+
tx.data,
|
|
386
|
+
toRlpUint(tx.gas_limit),
|
|
387
|
+
toRlpUint(tx.max_fee_per_gas),
|
|
388
|
+
toRlpUint(tx.max_priority_fee_per_gas),
|
|
389
|
+
toRlpAccessList(tx.access_list),
|
|
390
|
+
toRlpUint(tx.tx_type ?? AA_BUNDLE_TX_TYPE),
|
|
391
|
+
toRlpUint(tx.max_fee_per_blob_gas != null ? 1 : 0),
|
|
392
|
+
toRlpUint(tx.max_fee_per_blob_gas ?? 0),
|
|
393
|
+
(tx.blob_versioned_hashes ?? []).map((hash) => hash),
|
|
394
|
+
];
|
|
395
|
+
const bundleSigningFields = [innerCallsRlp, paymasterField];
|
|
396
|
+
const domainBuf = new Uint8Array([BATCH_SIGNING_HASH_DOMAIN]);
|
|
397
|
+
const txRlp = hexToBytes(toRlp(txFields));
|
|
398
|
+
const bundleRlp = hexToBytes(toRlp(bundleSigningFields));
|
|
399
|
+
const combined = new Uint8Array(domainBuf.length + txRlp.length + bundleRlp.length);
|
|
400
|
+
combined.set(domainBuf, 0);
|
|
401
|
+
combined.set(txRlp, domainBuf.length);
|
|
402
|
+
combined.set(bundleRlp, domainBuf.length + txRlp.length);
|
|
403
|
+
return hexToBytes(keccak256(bytesToHex(combined)));
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Convenience helper: build a minimal `AaInnerCall` for a SHELL token transfer.
|
|
407
|
+
*
|
|
408
|
+
* @param to - Recipient address.
|
|
409
|
+
* @param value - Amount in wei to send.
|
|
410
|
+
* @param gasLimit - Gas limit for this inner call. Defaults to `21_000`.
|
|
411
|
+
* @returns An `AaInnerCall` ready for use in {@link buildBatchTransaction}.
|
|
412
|
+
*/
|
|
413
|
+
export function buildInnerTransfer(to, value, gasLimit = 21_000) {
|
|
414
|
+
return { to, value: ("0x" + value.toString(16)), data: "0x", gas_limit: gasLimit };
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Convenience helper: build a contract-call `AaInnerCall`.
|
|
418
|
+
*
|
|
419
|
+
* @param to - Target contract address.
|
|
420
|
+
* @param data - ABI-encoded calldata.
|
|
421
|
+
* @param gasLimit - Gas limit for this inner call.
|
|
422
|
+
* @param value - Optional ETH value. Defaults to `0n`.
|
|
423
|
+
* @returns An `AaInnerCall` ready for use in {@link buildBatchTransaction}.
|
|
424
|
+
*/
|
|
425
|
+
export function buildInnerCall(to, data, gasLimit, value = 0n) {
|
|
426
|
+
return { to, value: ("0x" + value.toString(16)), data, gas_limit: gasLimit };
|
|
427
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export interface ShellTransactionRequest {
|
|
|
32
32
|
max_priority_fee_per_gas: number;
|
|
33
33
|
/** Optional EIP-2930 access list. */
|
|
34
34
|
access_list?: ShellAccessListItem[] | null;
|
|
35
|
-
/** Transaction type; defaults to `2` (EIP-1559). */
|
|
35
|
+
/** Transaction type; defaults to `2` (EIP-1559). AA bundle uses `0x7E`. */
|
|
36
36
|
tx_type?: number;
|
|
37
37
|
/** EIP-4844 max fee per blob gas unit. */
|
|
38
38
|
max_fee_per_blob_gas?: number | null;
|
|
@@ -42,11 +42,12 @@ export interface ShellTransactionRequest {
|
|
|
42
42
|
/**
|
|
43
43
|
* The name of a supported post-quantum signature algorithm.
|
|
44
44
|
*
|
|
45
|
-
* - `"
|
|
46
|
-
* - `"
|
|
45
|
+
* - `"ML-DSA-65"` — NIST FIPS 204 ML-DSA-65 (canonical name, algorithm ID 0); preferred.
|
|
46
|
+
* - `"Dilithium3"` — Compatibility alias for `"ML-DSA-65"` (same wire format, algorithm ID 0).
|
|
47
|
+
* - `"MlDsa65"` — Legacy camelCase alias for `"ML-DSA-65"` (algorithm ID 0); still accepted.
|
|
47
48
|
* - `"SphincsSha2256f"` — NIST FIPS 205 SLH-DSA-SHA2-256f (algorithm ID 2).
|
|
48
49
|
*/
|
|
49
|
-
export type SignatureTypeName = "Dilithium3" | "MlDsa65" | "SphincsSha2256f";
|
|
50
|
+
export type SignatureTypeName = "ML-DSA-65" | "Dilithium3" | "MlDsa65" | "SphincsSha2256f";
|
|
50
51
|
/**
|
|
51
52
|
* A post-quantum signature attached to a transaction.
|
|
52
53
|
*
|
|
@@ -59,6 +60,51 @@ export interface ShellSignature {
|
|
|
59
60
|
/** Raw signature bytes as a JS number array. */
|
|
60
61
|
data: number[];
|
|
61
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Transaction type byte for AA bundle transactions.
|
|
65
|
+
*
|
|
66
|
+
* `0x7E` — carries a {@link AaBundle} with N inner calls and an optional paymaster.
|
|
67
|
+
*/
|
|
68
|
+
export declare const AA_BUNDLE_TX_TYPE = 126;
|
|
69
|
+
/**
|
|
70
|
+
* Maximum number of inner calls per AA bundle.
|
|
71
|
+
*/
|
|
72
|
+
export declare const AA_MAX_INNER_CALLS = 16;
|
|
73
|
+
/**
|
|
74
|
+
* A single call within an AA batch bundle.
|
|
75
|
+
*
|
|
76
|
+
* Mirrors `InnerCall` on the chain side.
|
|
77
|
+
*/
|
|
78
|
+
export interface AaInnerCall {
|
|
79
|
+
/** Recipient address, or `null` for contract creation. */
|
|
80
|
+
to: AddressLike | null;
|
|
81
|
+
/** Value in wei as a hex string (e.g. `"0x0"`, `"0xde0b6b3a7640000"`). JSON-safe. */
|
|
82
|
+
value: HexString;
|
|
83
|
+
/** ABI-encoded calldata. */
|
|
84
|
+
data: HexString;
|
|
85
|
+
/** Gas limit for this inner call. */
|
|
86
|
+
gas_limit: number;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The AA bundle payload attached to a `tx_type = 0x7E` transaction.
|
|
90
|
+
*
|
|
91
|
+
* All inner calls execute atomically under a single PQ signature covering
|
|
92
|
+
* the outer envelope + bundle (via `batch_signing_hash`).
|
|
93
|
+
*/
|
|
94
|
+
export interface AaBundle {
|
|
95
|
+
/** Ordered list of inner calls to execute. Max {@link AA_MAX_INNER_CALLS}. */
|
|
96
|
+
inner_calls: AaInnerCall[];
|
|
97
|
+
/**
|
|
98
|
+
* Optional paymaster address paying the gas cost.
|
|
99
|
+
* When set, `paymaster_signature` must also be provided.
|
|
100
|
+
*/
|
|
101
|
+
paymaster?: AddressLike | null;
|
|
102
|
+
/**
|
|
103
|
+
* Paymaster's PQ signature over the `paymaster_signing_hash`.
|
|
104
|
+
* Required when `paymaster` is set.
|
|
105
|
+
*/
|
|
106
|
+
paymaster_signature?: number[] | null;
|
|
107
|
+
}
|
|
62
108
|
/**
|
|
63
109
|
* A fully-signed Shell Chain transaction ready to broadcast via `shell_sendTransaction`.
|
|
64
110
|
*
|
|
@@ -81,6 +127,109 @@ export interface SignedShellTransaction {
|
|
|
81
127
|
* verify the address derivation. Pass `null` for subsequent transactions.
|
|
82
128
|
*/
|
|
83
129
|
sender_pubkey?: number[] | null;
|
|
130
|
+
/**
|
|
131
|
+
* AA bundle payload. Present only when `tx.tx_type === AA_BUNDLE_TX_TYPE`.
|
|
132
|
+
*/
|
|
133
|
+
aa_bundle?: AaBundle | null;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* A single inner call entry in a `shell_estimateBatch` request.
|
|
137
|
+
*/
|
|
138
|
+
export interface ShellBatchInnerCallRequest {
|
|
139
|
+
/** Recipient address, or `null`. */
|
|
140
|
+
to?: AddressLike | null;
|
|
141
|
+
/** Value as hex string (e.g. `"0x0"`). */
|
|
142
|
+
value?: string | null;
|
|
143
|
+
/** ABI-encoded calldata. */
|
|
144
|
+
data?: HexString | null;
|
|
145
|
+
/** Gas limit as hex string. If absent, the node simulates to estimate. */
|
|
146
|
+
gas_limit?: string | null;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Request body for `shell_estimateBatch`.
|
|
150
|
+
*/
|
|
151
|
+
export interface ShellEstimateBatchRequest {
|
|
152
|
+
/** Nominal sender address for simulation. Defaults to zero address. */
|
|
153
|
+
from?: AddressLike | null;
|
|
154
|
+
/** Optional paymaster (informational; does not affect gas estimate). */
|
|
155
|
+
paymaster?: AddressLike | null;
|
|
156
|
+
/** Inner calls to estimate. */
|
|
157
|
+
inner_calls: ShellBatchInnerCallRequest[];
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Per-inner-call estimate entry returned by `shell_estimateBatch`.
|
|
161
|
+
*/
|
|
162
|
+
export interface ShellBatchInnerGas {
|
|
163
|
+
/** Gas limit as hex string. */
|
|
164
|
+
gas_limit: string;
|
|
165
|
+
/** `true` if the node simulated this call (no `gas_limit` was provided). */
|
|
166
|
+
simulated: boolean;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Response from `shell_estimateBatch`.
|
|
170
|
+
*/
|
|
171
|
+
export interface ShellEstimateBatchResult {
|
|
172
|
+
/** Total gas (outer intrinsic + inner sum + surcharge) as hex string. */
|
|
173
|
+
total_gas: string;
|
|
174
|
+
/** Outer transaction intrinsic gas (always `"0x5208"` = 21 000). */
|
|
175
|
+
outer_intrinsic: string;
|
|
176
|
+
/** Sum of all inner gas limits as hex string. */
|
|
177
|
+
inner_sum: string;
|
|
178
|
+
/** Per-extra-inner-call intrinsic surcharge as hex string. */
|
|
179
|
+
intrinsic_surcharge: string;
|
|
180
|
+
/** Per-inner gas estimates. */
|
|
181
|
+
per_inner: ShellBatchInnerGas[];
|
|
182
|
+
/** Paymaster echoed back (if supplied in request). */
|
|
183
|
+
paymaster?: AddressLike | null;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Paymaster policy returned by `shell_getPaymasterPolicy`.
|
|
187
|
+
*/
|
|
188
|
+
export interface ShellPaymasterPolicy {
|
|
189
|
+
/** Paymaster address (pq1… form). */
|
|
190
|
+
address: AddressLike;
|
|
191
|
+
/** `true` if a PQ pubkey has been registered on-chain for this address. */
|
|
192
|
+
has_pq_pubkey: boolean;
|
|
193
|
+
/** Pubkey byte length (if present). */
|
|
194
|
+
pubkey_bytes?: number | null;
|
|
195
|
+
/** SHELL balance of the paymaster as hex string. */
|
|
196
|
+
balance: string;
|
|
197
|
+
/** Policy type; currently always `"eoa-open"`. */
|
|
198
|
+
policy: string;
|
|
199
|
+
/** Maximum gas sponsorship cap (null = uncapped). */
|
|
200
|
+
max_gas_sponsorship?: string | null;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Response from `shell_isSponsored`.
|
|
204
|
+
*/
|
|
205
|
+
export interface ShellIsSponsoredResult {
|
|
206
|
+
/** `true` if the transaction was found (mempool or chain). */
|
|
207
|
+
found: boolean;
|
|
208
|
+
/** `true` if the transaction is sponsored by a paymaster. */
|
|
209
|
+
sponsored: boolean;
|
|
210
|
+
/** Where the transaction was found: `"mempool"`, `"chain"`, or `null`. */
|
|
211
|
+
location: "mempool" | "chain" | null;
|
|
212
|
+
/** `true` if the transaction is a native AA bundle. */
|
|
213
|
+
is_aa_bundle: boolean;
|
|
214
|
+
/** Paymaster address, or `null` if not sponsored. */
|
|
215
|
+
paymaster: AddressLike | null;
|
|
216
|
+
/** Sender address. */
|
|
217
|
+
sender: AddressLike | null;
|
|
218
|
+
/** Number of inner calls in the bundle, or `null` for non-AA txs. */
|
|
219
|
+
inner_call_count: number | null;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Result returned by `shell_verifyWitnessRoot`.
|
|
223
|
+
*/
|
|
224
|
+
export interface ShellWitnessRootResult {
|
|
225
|
+
/** The block number that was verified (as hex string). */
|
|
226
|
+
block: string;
|
|
227
|
+
/** The witness root stored in the block header (hex). */
|
|
228
|
+
witness_root: string;
|
|
229
|
+
/** The recomputed root from the bundle signatures (hex). */
|
|
230
|
+
bundle_root: string;
|
|
231
|
+
/** `true` if `witness_root === bundle_root`. */
|
|
232
|
+
match: boolean;
|
|
84
233
|
}
|
|
85
234
|
/**
|
|
86
235
|
* Node storage profile as advertised via the `StorageCapability` P2P message.
|
|
@@ -96,7 +245,7 @@ export type ShellStorageProfile = "archive" | "full" | "light";
|
|
|
96
245
|
* Contains runtime metadata about the connected Shell Chain node.
|
|
97
246
|
*/
|
|
98
247
|
export interface ShellNodeInfo {
|
|
99
|
-
/** Node software version string, e.g. `"shell-node/0.
|
|
248
|
+
/** Node software version string, e.g. `"shell-node/0.18.0"`. */
|
|
100
249
|
version: string;
|
|
101
250
|
/** Chain ID as a decimal string. */
|
|
102
251
|
chain_id: string;
|
|
@@ -136,6 +285,11 @@ export interface ShellWitnessBundle {
|
|
|
136
285
|
witness_count: number;
|
|
137
286
|
/** Individual transaction witnesses. */
|
|
138
287
|
witnesses: ShellTxWitness[];
|
|
288
|
+
/**
|
|
289
|
+
* Merkle root of the witness bundle (stored in the block header).
|
|
290
|
+
* Present on archive/full nodes.
|
|
291
|
+
*/
|
|
292
|
+
witness_root?: string;
|
|
139
293
|
}
|
|
140
294
|
/** Paginated response from `shell_getTransactionsByAddress`. */
|
|
141
295
|
export interface ShellTxByAddressPage {
|
package/dist/types.js
CHANGED
|
@@ -1 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Native AA types (v0.18.0)
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
/**
|
|
5
|
+
* Transaction type byte for AA bundle transactions.
|
|
6
|
+
*
|
|
7
|
+
* `0x7E` — carries a {@link AaBundle} with N inner calls and an optional paymaster.
|
|
8
|
+
*/
|
|
9
|
+
export const AA_BUNDLE_TX_TYPE = 0x7e;
|
|
10
|
+
/**
|
|
11
|
+
* Maximum number of inner calls per AA bundle.
|
|
12
|
+
*/
|
|
13
|
+
export const AA_MAX_INNER_CALLS = 16;
|