@sidhujag/sysweb3-keyring 2.0.0 → 2.1.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 +19 -0
- package/README.md +46 -0
- package/cjs/evm-fees.js +223 -0
- package/cjs/evm-fees.js.map +1 -0
- package/cjs/keyring-core.js +1 -1
- package/cjs/keyring-core.js.map +1 -1
- package/cjs/keyring-manager.js +4 -3
- package/cjs/keyring-manager.js.map +1 -1
- package/cjs/software.js +12 -3
- package/cjs/software.js.map +1 -1
- package/cjs/transactions/ethereum.js +194 -190
- package/cjs/transactions/ethereum.js.map +1 -1
- package/cjs/transactions/evm-local-signer.js +28 -7
- package/cjs/transactions/evm-local-signer.js.map +1 -1
- package/cjs/transactions/evm-submission.js +179 -0
- package/cjs/transactions/evm-submission.js.map +1 -0
- package/cjs/transactions/index.js +1 -0
- package/cjs/transactions/index.js.map +1 -1
- package/cjs/transactions/prepared-evm.js +3 -0
- package/cjs/transactions/prepared-evm.js.map +1 -1
- package/cjs/types.js.map +1 -1
- package/cjs/utils/derivation-paths.js +4 -3
- package/cjs/utils/derivation-paths.js.map +1 -1
- package/cjs/utils/watch-descriptor.js +3 -2
- package/cjs/utils/watch-descriptor.js.map +1 -1
- package/esm/types.js.map +1 -1
- package/esm/utils/derivation-paths.js +2 -1
- package/esm/utils/derivation-paths.js.map +1 -1
- package/package.json +28 -3
- package/types/evm-fees.d.ts +42 -0
- package/types/keyring-core.d.ts +3 -0
- package/types/keyring-manager.d.ts +8 -3
- package/types/software.d.ts +6 -1
- package/types/transactions/ethereum.d.ts +10 -8
- package/types/transactions/evm-local-signer.d.ts +4 -1
- package/types/transactions/evm-submission.d.ts +48 -0
- package/types/transactions/index.d.ts +1 -0
- package/types/types.d.ts +4 -0
|
@@ -3,6 +3,7 @@ import { INetwork } from '@sidhujag/sysweb3-network';
|
|
|
3
3
|
import { BigNumber, TransactionResponse } from '../ethers-v6';
|
|
4
4
|
import { CustomJsonRpcProvider } from '../providers';
|
|
5
5
|
import { IResponseFromSendErcSignedTransaction, ISendSignedErcTransactionProps, IEthereumTransactions, IEvmCancellationOptions, IEvmReplacementOptions, IEvmSendOptions, SimpleTransactionRequest, KeyringAccountType, accountType, IGasParams } from '../types';
|
|
6
|
+
import { type CaptureEvmSubmission } from './evm-submission';
|
|
6
7
|
import type { LedgerKeyring } from '../ledger';
|
|
7
8
|
import type { TrezorKeyring } from '../trezor';
|
|
8
9
|
/** Minimal trusted device capabilities used by EVM transaction routing. */
|
|
@@ -18,6 +19,7 @@ export declare class EthereumTransactions<TLedger extends EthereumLedgerSigner |
|
|
|
18
19
|
ledgerSigner: TLedger;
|
|
19
20
|
private getNetwork;
|
|
20
21
|
private captureSigningContext?;
|
|
22
|
+
private readonly captureSubmissionLifecycle?;
|
|
21
23
|
private abortController;
|
|
22
24
|
private getDecryptedPrivateKey;
|
|
23
25
|
private gasOverrides;
|
|
@@ -35,11 +37,12 @@ export declare class EthereumTransactions<TLedger extends EthereumLedgerSigner |
|
|
|
35
37
|
activeAccountId: number;
|
|
36
38
|
activeAccountType: KeyringAccountType;
|
|
37
39
|
activeNetwork: INetwork;
|
|
38
|
-
}, ledgerSigner: TLedger, trezorSigner: TTrezor, captureSigningContext?: () => () => void);
|
|
40
|
+
}, ledgerSigner: TLedger, trezorSigner: TTrezor, captureSigningContext?: () => () => void, captureSubmissionLifecycle?: CaptureEvmSubmission);
|
|
39
41
|
private requireLedgerSigner;
|
|
40
42
|
private requireTrezorSigner;
|
|
41
43
|
private assertHardwareSignerAvailable;
|
|
42
44
|
private captureEvmSigningContext;
|
|
45
|
+
private captureSubmission;
|
|
43
46
|
get web3Provider(): CustomJsonRpcProvider;
|
|
44
47
|
private ensureProvidersInitialized;
|
|
45
48
|
private isUtxoNetwork;
|
|
@@ -61,20 +64,17 @@ export declare class EthereumTransactions<TLedger extends EthereumLedgerSigner |
|
|
|
61
64
|
value: any;
|
|
62
65
|
}) => string;
|
|
63
66
|
getFeeDataWithDynamicMaxPriorityFeePerGas: (provider?: CustomJsonRpcProvider) => Promise<{
|
|
64
|
-
gasPrice: BigNumber;
|
|
65
67
|
maxFeePerGas: BigNumber;
|
|
66
68
|
maxPriorityFeePerGas: BigNumber;
|
|
67
|
-
baseFeePerGas?: undefined;
|
|
68
|
-
} | {
|
|
69
|
+
baseFeePerGas?: BigNumber | undefined;
|
|
69
70
|
gasPrice: BigNumber;
|
|
70
|
-
baseFeePerGas: BigNumber;
|
|
71
|
-
maxFeePerGas: BigNumber;
|
|
72
|
-
maxPriorityFeePerGas: BigNumber;
|
|
73
71
|
}>;
|
|
74
72
|
calculateNewGasValues: (oldTxsParams: IGasParams, isForCancel: boolean, isLegacy: boolean) => IGasParams;
|
|
75
73
|
cancelSentTransaction: (txHash: string, isLegacy: boolean | undefined, fallbackNonce: number | undefined, options: IEvmCancellationOptions) => Promise<{
|
|
76
74
|
error?: boolean;
|
|
77
75
|
isCanceled: boolean;
|
|
76
|
+
transactionNotBroadcast?: boolean;
|
|
77
|
+
signedTransactionHash?: string;
|
|
78
78
|
maximumFee?: string;
|
|
79
79
|
transaction?: TransactionResponse;
|
|
80
80
|
}>;
|
|
@@ -84,6 +84,8 @@ export declare class EthereumTransactions<TLedger extends EthereumLedgerSigner |
|
|
|
84
84
|
maximumFee?: string;
|
|
85
85
|
error?: boolean;
|
|
86
86
|
isSpeedUp: boolean;
|
|
87
|
+
transactionNotBroadcast?: boolean;
|
|
88
|
+
signedTransactionHash?: string;
|
|
87
89
|
transaction?: TransactionResponse;
|
|
88
90
|
code?: string;
|
|
89
91
|
message?: string;
|
|
@@ -94,7 +96,7 @@ export declare class EthereumTransactions<TLedger extends EthereumLedgerSigner |
|
|
|
94
96
|
getRecommendedNonce: (address: string) => Promise<number>;
|
|
95
97
|
getFeeByType: (type: string) => Promise<string>;
|
|
96
98
|
getGasLimit: (toAddress: string) => Promise<number>;
|
|
97
|
-
getTxGasLimit: (tx: SimpleTransactionRequest) => Promise<
|
|
99
|
+
getTxGasLimit: (tx: SimpleTransactionRequest) => Promise<BigNumber>;
|
|
98
100
|
getRecommendedGasPrice: (formatted?: boolean) => Promise<string | {
|
|
99
101
|
gwei: string;
|
|
100
102
|
ethers: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import ecc from '@bitcoinerlab/secp256k1';
|
|
2
2
|
import { type Deferrable, type TransactionRequest } from '../ethers-v6';
|
|
3
3
|
import { CustomJsonRpcProvider } from '../providers';
|
|
4
|
+
import { type EvmSubmissionBoundary } from './evm-submission';
|
|
4
5
|
export type EvmLocalAccount = {
|
|
5
6
|
address: string;
|
|
6
7
|
privateKey: string;
|
|
@@ -19,8 +20,10 @@ export declare const signDigestHex: (digest: string | Uint8Array, privateKey: st
|
|
|
19
20
|
export declare const hashPersonalMessage: (message: Uint8Array) => string;
|
|
20
21
|
export declare const signPersonalMessage: (message: string | Uint8Array, privateKey: string | Uint8Array) => string;
|
|
21
22
|
export declare const parsePersonalMessage: (hexMessage: string) => string;
|
|
23
|
+
/** Pin the checked gas and chain to the same detached envelope that is serialized. */
|
|
24
|
+
export declare const normalizeGasLimitedTransaction: (transaction: TransactionRequest) => TransactionRequest;
|
|
22
25
|
export declare const signTransaction: (transaction: TransactionRequest, privateKey: string | Uint8Array) => string;
|
|
23
26
|
export declare const sendLocalEvmTransaction: (provider: CustomJsonRpcProvider, privateKey: string, transaction: Deferrable<Record<string, any>>, beforeBroadcast?: () => void, beforeSign?: () => void,
|
|
24
27
|
/** Synchronous final-envelope check; throw to reject. Promise results are rejected. */
|
|
25
|
-
validateBeforeSign?: (transaction: TransactionRequest) => void) => Promise<any>;
|
|
28
|
+
validateBeforeSign?: (transaction: TransactionRequest) => void, submission?: EvmSubmissionBoundary) => Promise<any>;
|
|
26
29
|
export declare const sameAddress: (left: string, right: string) => boolean;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export type EvmSubmissionContext = Readonly<{
|
|
2
|
+
account: Readonly<{
|
|
3
|
+
id: number;
|
|
4
|
+
type: string;
|
|
5
|
+
address: string;
|
|
6
|
+
}>;
|
|
7
|
+
network: Readonly<{
|
|
8
|
+
kind: string;
|
|
9
|
+
chainId: number;
|
|
10
|
+
slip44: number;
|
|
11
|
+
url: string;
|
|
12
|
+
}>;
|
|
13
|
+
operation: 'send' | 'cancel' | 'speed-up' | 'erc20' | 'erc721' | 'erc1155';
|
|
14
|
+
originalHash?: string;
|
|
15
|
+
}>;
|
|
16
|
+
/** Signed wire bytes only; never a key, password or mutable transaction request. */
|
|
17
|
+
export type EvmSignedSubmission = Readonly<{
|
|
18
|
+
context: EvmSubmissionContext;
|
|
19
|
+
rawTransaction: string;
|
|
20
|
+
hash: string;
|
|
21
|
+
from: string;
|
|
22
|
+
chainId: string;
|
|
23
|
+
nonce: number;
|
|
24
|
+
type: number | null;
|
|
25
|
+
}>;
|
|
26
|
+
export type EvmSubmissionLifecycle = Readonly<{
|
|
27
|
+
/** Synchronous host wallet/session/revision check, including A -> B -> A. */
|
|
28
|
+
assertCurrent: () => void;
|
|
29
|
+
/** Resolve only after durable acknowledgement. A rejection never dispatches. */
|
|
30
|
+
persistSigned: (record: EvmSignedSubmission) => Promise<void>;
|
|
31
|
+
}>;
|
|
32
|
+
export type CaptureEvmSubmission = (context: EvmSubmissionContext) => EvmSubmissionLifecycle;
|
|
33
|
+
export type EvmSubmissionBoundary = Readonly<{
|
|
34
|
+
context: EvmSubmissionContext;
|
|
35
|
+
assertCurrent: () => void;
|
|
36
|
+
persistSigned?: (record: EvmSignedSubmission) => Promise<void>;
|
|
37
|
+
}>;
|
|
38
|
+
/** Capture once, before RPC or device work. Never reread host capabilities later. */
|
|
39
|
+
export declare function captureEvmSubmission(input: EvmSubmissionContext, assertCurrent: () => void, capture?: CaptureEvmSubmission): EvmSubmissionBoundary;
|
|
40
|
+
/** Only local stage evidence can label an error as a possibly dispatched send. */
|
|
41
|
+
export declare function evmSubmissionFailure(error: unknown): Readonly<{
|
|
42
|
+
transactionNotBroadcast: boolean;
|
|
43
|
+
signedTransactionHash?: string;
|
|
44
|
+
}>;
|
|
45
|
+
/** Preserve local evidence when an existing public API wraps its Error object. */
|
|
46
|
+
export declare function copyEvmSubmissionFailure(source: unknown, target: Error): void;
|
|
47
|
+
/** The sole local-signature dispatch boundary. No nonce/fee selection or retry. */
|
|
48
|
+
export declare function submitSignedEvmTransaction<T>(rawTransaction: string, broadcast: (rawTransaction: string) => Promise<T>, boundary?: EvmSubmissionBoundary, beforeBroadcast?: () => void): Promise<T>;
|
package/types/types.d.ts
CHANGED
|
@@ -81,6 +81,8 @@ export interface IEthereumTransactions {
|
|
|
81
81
|
cancelSentTransaction: (txHash: string, isLegacy: boolean | undefined, fallbackNonce: number | undefined, options: IEvmCancellationOptions) => Promise<{
|
|
82
82
|
error?: boolean;
|
|
83
83
|
isCanceled: boolean;
|
|
84
|
+
transactionNotBroadcast?: boolean;
|
|
85
|
+
signedTransactionHash?: string;
|
|
84
86
|
maximumFee?: string;
|
|
85
87
|
transaction?: TransactionResponse;
|
|
86
88
|
}>;
|
|
@@ -106,6 +108,8 @@ export interface IEthereumTransactions {
|
|
|
106
108
|
sendTransactionWithEditedFee: (txHash: string, isLegacy?: boolean, options?: IEvmReplacementOptions) => Promise<{
|
|
107
109
|
maximumFee?: string;
|
|
108
110
|
isSpeedUp: boolean;
|
|
111
|
+
transactionNotBroadcast?: boolean;
|
|
112
|
+
signedTransactionHash?: string;
|
|
109
113
|
transaction?: TransactionResponse;
|
|
110
114
|
error?: boolean;
|
|
111
115
|
}>;
|