@sidhujag/sysweb3-keyring 2.1.4 → 2.1.6
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 +6 -0
- package/cjs/evm-fees.js +73 -0
- package/cjs/evm-fees.js.map +1 -1
- package/cjs/software.js.map +1 -1
- package/cjs/transactions/ethereum.js +220 -160
- package/cjs/transactions/ethereum.js.map +1 -1
- package/cjs/transactions/evm-cancellation.js +51 -0
- package/cjs/transactions/evm-cancellation.js.map +1 -1
- package/cjs/transactions/evm-local-signer.js +1 -1
- package/cjs/transactions/evm-local-signer.js.map +1 -1
- package/cjs/transactions/evm-submission.js +78 -8
- package/cjs/transactions/evm-submission.js.map +1 -1
- package/cjs/transactions/syscoin-core.js +155 -10
- package/cjs/transactions/syscoin-core.js.map +1 -1
- package/cjs/types.js.map +1 -1
- package/cjs/utils/excluded-utxos.js +6 -2
- package/cjs/utils/excluded-utxos.js.map +1 -1
- package/esm/evm-fees.js +72 -0
- package/esm/evm-fees.js.map +1 -1
- package/esm/transactions/ethereum.js +222 -162
- package/esm/transactions/ethereum.js.map +1 -1
- package/esm/transactions/evm-cancellation.js +50 -0
- package/esm/transactions/evm-cancellation.js.map +1 -1
- package/esm/transactions/evm-local-signer.js +1 -1
- package/esm/transactions/evm-local-signer.js.map +1 -1
- package/esm/transactions/evm-submission.js +78 -8
- package/esm/transactions/evm-submission.js.map +1 -1
- package/esm/transactions/syscoin-core.js +156 -11
- package/esm/transactions/syscoin-core.js.map +1 -1
- package/esm/types.js.map +1 -1
- package/esm/utils/excluded-utxos.js +6 -2
- package/esm/utils/excluded-utxos.js.map +1 -1
- package/package.json +3 -3
- package/types/evm-fees.d.ts +31 -0
- package/types/software.d.ts +1 -1
- package/types/transactions/ethereum.d.ts +9 -3
- package/types/transactions/evm-cancellation.d.ts +3 -0
- package/types/transactions/evm-local-signer.d.ts +1 -1
- package/types/transactions/evm-submission.d.ts +14 -2
- package/types/transactions/syscoin-core.d.ts +3 -1
- package/types/types.d.ts +49 -1
- package/types/utils/excluded-utxos.d.ts +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { TypedMessage, SignTypedDataVersion, TypedDataV1 } from '@metamask/eth-sig-util';
|
|
2
2
|
import { INetwork } from '@sidhujag/sysweb3-network';
|
|
3
3
|
import { BigNumber, TransactionResponse } from '../ethers-v6';
|
|
4
|
+
import { type EvmFeeReader } from '../evm-fees';
|
|
4
5
|
import { CustomJsonRpcProvider } from '../providers';
|
|
5
6
|
import { IResponseFromSendErcSignedTransaction, ISendSignedErc20TransactionProps, ISendSignedErc721TransactionProps, ISendSignedErc1155TransactionProps, IReviewedEvmTokenApproval, IEthereumTransactions, IEvmCancellationOptions, IEvmReplacementOptions, EvmFormattedSendArguments, SimpleTransactionRequest, KeyringAccountType, accountType, IGasParams } from '../types';
|
|
6
7
|
import { type CaptureEvmSubmission } from './evm-submission';
|
|
@@ -66,13 +67,18 @@ export declare class EthereumTransactions<TLedger extends EthereumLedgerSigner |
|
|
|
66
67
|
receivingAddress: string;
|
|
67
68
|
value: any;
|
|
68
69
|
}) => string;
|
|
69
|
-
getFeeDataWithDynamicMaxPriorityFeePerGas: (provider?:
|
|
70
|
+
getFeeDataWithDynamicMaxPriorityFeePerGas: (provider?: EvmFeeReader) => Promise<{
|
|
70
71
|
maxFeePerGas: BigNumber;
|
|
71
72
|
maxPriorityFeePerGas: BigNumber;
|
|
72
73
|
baseFeePerGas?: BigNumber | undefined;
|
|
73
74
|
gasPrice: BigNumber;
|
|
74
75
|
}>;
|
|
75
|
-
calculateNewGasValues: (oldTxsParams: IGasParams, isForCancel: boolean, isLegacy: boolean
|
|
76
|
+
calculateNewGasValues: (oldTxsParams: IGasParams, isForCancel: boolean, isLegacy: boolean, bounds: Readonly<{
|
|
77
|
+
chainId: bigint;
|
|
78
|
+
retainedCancellationGasLimit?: bigint;
|
|
79
|
+
sampledBlockGasLimit: bigint;
|
|
80
|
+
sampledBaseFeePerGas: bigint | null;
|
|
81
|
+
}>) => IGasParams;
|
|
76
82
|
cancelSentTransaction: (txHash: string, isLegacy: boolean | undefined, fallbackNonce: number | undefined, options: IEvmCancellationOptions) => Promise<{
|
|
77
83
|
error?: boolean;
|
|
78
84
|
isCanceled: boolean;
|
|
@@ -81,7 +87,7 @@ export declare class EthereumTransactions<TLedger extends EthereumLedgerSigner |
|
|
|
81
87
|
maximumFee?: string;
|
|
82
88
|
transaction?: TransactionResponse;
|
|
83
89
|
}>;
|
|
84
|
-
sendFormattedTransaction: (...args: EvmFormattedSendArguments) => Promise<
|
|
90
|
+
sendFormattedTransaction: (...args: EvmFormattedSendArguments) => Promise<unknown>;
|
|
85
91
|
private sendFormattedTransactionInternal;
|
|
86
92
|
sendTransactionWithEditedFee: (txHash: string, isLegacy: boolean | undefined, options: IEvmReplacementOptions) => Promise<{
|
|
87
93
|
maximumFee?: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { planEvmCancellationFees } from '../evm-fees';
|
|
2
|
+
import type { EvmRetainedCancellationOrigin } from '../types';
|
|
2
3
|
/** A host supplies the authenticated original identity and the captured fee plan. */
|
|
3
4
|
export type EvmCancellationEnvelopeIntent = Readonly<{
|
|
4
5
|
payer: string;
|
|
@@ -6,5 +7,7 @@ export type EvmCancellationEnvelopeIntent = Readonly<{
|
|
|
6
7
|
nonce: number | string;
|
|
7
8
|
feePlan: ReturnType<typeof planEvmCancellationFees>;
|
|
8
9
|
}>;
|
|
10
|
+
/** Verify the selected signed bytes and snapshot the host's exact fee floor. */
|
|
11
|
+
export declare function authenticateRetainedCancellation(origin: EvmRetainedCancellationOrigin, hash: string, payer: string, chainId: number): EvmRetainedCancellationOrigin;
|
|
9
12
|
/** Checks the exact unsigned bytes. Original eligibility and approval remain host checks. */
|
|
10
13
|
export declare function assertEvmCancellationEnvelope(unsigned: string, { payer, chainId, nonce, feePlan }: EvmCancellationEnvelopeIntent): void;
|
|
@@ -25,5 +25,5 @@ export declare const normalizeGasLimitedTransaction: (transaction: TransactionRe
|
|
|
25
25
|
export declare const signTransaction: (transaction: TransactionRequest, privateKey: string | Uint8Array) => string;
|
|
26
26
|
export declare const sendLocalEvmTransaction: (provider: CustomJsonRpcProvider, privateKey: string, transaction: Deferrable<Record<string, any>>, beforeBroadcast: (() => void) | undefined, beforeSign: (() => void) | undefined,
|
|
27
27
|
/** Synchronous final-envelope check; throw to reject. Promise results are rejected. */
|
|
28
|
-
validateBeforeSign: ((transaction: TransactionRequest) => void) | undefined, submission: EvmSubmissionBoundary) => Promise<
|
|
28
|
+
validateBeforeSign: ((transaction: TransactionRequest) => void) | undefined, submission: EvmSubmissionBoundary) => Promise<unknown>;
|
|
29
29
|
export declare const sameAddress: (left: string, right: string) => boolean;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Transaction } from 'ethers/transaction';
|
|
2
|
+
import type { EvmRetainedCancellationOrigin, EvmWalletNonce } from '../types';
|
|
2
3
|
export type EvmSubmissionContext = Readonly<{
|
|
3
4
|
account: Readonly<{
|
|
4
5
|
id: number;
|
|
@@ -13,6 +14,8 @@ export type EvmSubmissionContext = Readonly<{
|
|
|
13
14
|
}>;
|
|
14
15
|
operation: 'send' | 'cancel' | 'speed-up' | 'erc20' | 'erc721' | 'erc1155';
|
|
15
16
|
originalHash?: string;
|
|
17
|
+
origin?: EvmRetainedCancellationOrigin;
|
|
18
|
+
walletNonce?: EvmWalletNonce;
|
|
16
19
|
}>;
|
|
17
20
|
/** Signed wire bytes only; never a key, password or mutable transaction request. */
|
|
18
21
|
export type EvmSignedSubmission = Readonly<{
|
|
@@ -24,11 +27,19 @@ export type EvmSignedSubmission = Readonly<{
|
|
|
24
27
|
nonce: number;
|
|
25
28
|
type: number | null;
|
|
26
29
|
}>;
|
|
30
|
+
/** The transport calls this after preflight, immediately around synchronous wire initiation. */
|
|
31
|
+
export type AdmitEvmSignedDispatch<T> = (initiate: () => Promise<T>, preflight?: () => Promise<void>) => Promise<T>;
|
|
32
|
+
export type EvmSignedBroadcast<T> = (request: Readonly<{
|
|
33
|
+
rawTransaction: string;
|
|
34
|
+
admit: AdmitEvmSignedDispatch<T>;
|
|
35
|
+
}>) => Promise<T>;
|
|
27
36
|
export type EvmSubmissionLifecycle = Readonly<{
|
|
28
37
|
/** Synchronous host wallet/session/revision check, including A -> B -> A. */
|
|
29
38
|
assertCurrent: () => void;
|
|
30
39
|
/** Resolve only after durable acknowledgement. A rejection never dispatches. */
|
|
31
40
|
persistSigned: (record: EvmSignedSubmission) => Promise<void>;
|
|
41
|
+
/** Admit the exact retained record, releasing the owner before the remote response. */
|
|
42
|
+
dispatchSigned: <T>(record: EvmSignedSubmission, initiate: () => Promise<T>, preflight: () => Promise<void>) => Promise<T>;
|
|
32
43
|
}>;
|
|
33
44
|
export type CaptureEvmSubmission = (context: EvmSubmissionContext) => EvmSubmissionLifecycle;
|
|
34
45
|
declare const evmSubmissionBrand: unique symbol;
|
|
@@ -37,6 +48,7 @@ export type EvmSubmissionBoundary = Readonly<{
|
|
|
37
48
|
context: EvmSubmissionContext;
|
|
38
49
|
assertCurrent: () => void;
|
|
39
50
|
persistSigned: (record: EvmSignedSubmission) => Promise<void>;
|
|
51
|
+
dispatchSigned: EvmSubmissionLifecycle['dispatchSigned'];
|
|
40
52
|
}>;
|
|
41
53
|
/** Capture once, before RPC or device work. Never reread host capabilities later. */
|
|
42
54
|
export declare function captureEvmSubmission(input: EvmSubmissionContext, assertCurrent: () => void, capture: CaptureEvmSubmission): EvmSubmissionBoundary;
|
|
@@ -52,7 +64,7 @@ export declare function copyEvmSubmissionFailure(source: unknown, target: Error)
|
|
|
52
64
|
/** Compare signed wire bytes with the complete envelope captured before signing. */
|
|
53
65
|
export declare function assertSignedEvmTransactionMatches(rawTransaction: string, expectedUnsignedTransaction: string, expectedFrom?: string): Transaction;
|
|
54
66
|
/** Submit software-signed bytes through the captured durable boundary. */
|
|
55
|
-
export declare function submitSignedEvmTransaction<T>(rawTransaction: string, broadcast:
|
|
67
|
+
export declare function submitSignedEvmTransaction<T>(rawTransaction: string, broadcast: EvmSignedBroadcast<T>, boundary: EvmSubmissionBoundary, beforeBroadcast: (() => void) | undefined, expectedUnsignedTransaction: string): Promise<T>;
|
|
56
68
|
/** @internal Device signatures always require a fresh live chain probe after persistence. */
|
|
57
|
-
export declare function submitSignedHardwareEvmTransaction<T>(rawTransaction: string, broadcast:
|
|
69
|
+
export declare function submitSignedHardwareEvmTransaction<T>(rawTransaction: string, broadcast: EvmSignedBroadcast<T>, boundary: EvmSubmissionBoundary, beforeBroadcast: (() => void) | undefined, expectedUnsignedTransaction: string, verifyCurrentChain: () => Promise<void>): Promise<T>;
|
|
58
70
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ITxid } from '@sidhujag/sysweb3-utils';
|
|
2
2
|
import { Psbt } from 'bitcoinjs-lib';
|
|
3
|
-
import { ISyscoinTransactions, KeyringAccountType, accountType, type SyscoinOwnedReadOptions, type SyscoinOwnedSubmissionOptions } from '../types';
|
|
3
|
+
import { ISyscoinTransactions, KeyringAccountType, accountType, type SyscoinOwnedReadOptions, type SyscoinOwnedSubmissionOptions, type SyscoinRetainedSubmissionOptions } from '../types';
|
|
4
4
|
import { ExcludedOutpoint } from '../utils/excluded-utxos';
|
|
5
5
|
import { type PsbtAccountScope } from '../utils/psbt-account-scope';
|
|
6
6
|
import type { SyscoinHDSigner } from '../signers';
|
|
@@ -115,5 +115,7 @@ export declare class SyscoinTransactionsCore implements ISyscoinTransactions {
|
|
|
115
115
|
psbt: any;
|
|
116
116
|
}, ownedRead: SyscoinOwnedReadOptions) => Promise<any>;
|
|
117
117
|
sendTransaction: (rawTransaction: string, authority: SyscoinOwnedSubmissionOptions) => Promise<ITxid>;
|
|
118
|
+
/** Replay only the bytes and destination authenticated by the selected wallet. */
|
|
119
|
+
replayRetainedTransaction: (txid: string, authority: SyscoinRetainedSubmissionOptions) => Promise<ITxid>;
|
|
118
120
|
}
|
|
119
121
|
export {};
|
package/types/types.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { SyscoinHDSigner } from './signers';
|
|
|
9
9
|
import { TrezorKeyring } from './trezor';
|
|
10
10
|
import type { KeyringCore } from './keyring-core';
|
|
11
11
|
import type { PreparedEvmTransaction } from './transactions/prepared-evm';
|
|
12
|
+
import type { OwnedUtxoRpcVerification } from '@sidhujag/sysweb3-network';
|
|
12
13
|
export type AccessListish = Array<{
|
|
13
14
|
address: string;
|
|
14
15
|
storageKeys: string[];
|
|
@@ -37,10 +38,15 @@ export type EvmLocalAccount = {
|
|
|
37
38
|
privateKey: string;
|
|
38
39
|
publicKey: string;
|
|
39
40
|
};
|
|
41
|
+
export type EvmWalletNonce = Readonly<{
|
|
42
|
+
nonce: number;
|
|
43
|
+
source: 'automatic' | 'manual';
|
|
44
|
+
}>;
|
|
40
45
|
export interface IEvmSendOptions {
|
|
41
46
|
/** Synchronous host admission, rechecked immediately before signing and broadcast. */
|
|
42
47
|
assertCurrent: () => void;
|
|
43
48
|
mode: 'reviewed-native' | 'specialized';
|
|
49
|
+
walletNonce?: EvmWalletNonce;
|
|
44
50
|
}
|
|
45
51
|
export type EvmFormattedSendArguments = [
|
|
46
52
|
approvedTransaction: PreparedEvmTransaction,
|
|
@@ -75,8 +81,30 @@ type EvmOriginalAdmission<Original> = {
|
|
|
75
81
|
};
|
|
76
82
|
export type IEvmReplacementOptions = EvmReplacementFeeApproval & EvmOriginalAdmission<TransactionResponse> & {
|
|
77
83
|
beforeBroadcast?: () => void;
|
|
84
|
+
/** Exact signed original obtained from the host's protected cancellation lineage. */
|
|
85
|
+
retainedCancellation?: string;
|
|
78
86
|
};
|
|
79
|
-
export type
|
|
87
|
+
export type EvmRetainedCancellationOrigin = Readonly<{
|
|
88
|
+
kind: 'retained';
|
|
89
|
+
rawTransaction: string;
|
|
90
|
+
nonce: number;
|
|
91
|
+
tipHash: string;
|
|
92
|
+
feeFloor: Readonly<{
|
|
93
|
+
type: 0;
|
|
94
|
+
gasPrice: bigint;
|
|
95
|
+
} | {
|
|
96
|
+
type: 2;
|
|
97
|
+
maxFeePerGas: bigint;
|
|
98
|
+
maxPriorityFeePerGas: bigint;
|
|
99
|
+
}>;
|
|
100
|
+
}>;
|
|
101
|
+
export type IEvmCancellationOptions = EvmReplacementFeeApproval & ((EvmOriginalAdmission<TransactionResponse | null> & {
|
|
102
|
+
origin?: never;
|
|
103
|
+
}) | (Omit<EvmOriginalAdmission<never>, 'validateOriginal'> & {
|
|
104
|
+
/** The host owns the protected journal lineage and its live admission. */
|
|
105
|
+
origin: EvmRetainedCancellationOrigin;
|
|
106
|
+
validateOriginal?: never;
|
|
107
|
+
}));
|
|
80
108
|
export interface IEthereumTransactions {
|
|
81
109
|
cancelSentTransaction: (txHash: string, isLegacy: boolean | undefined, fallbackNonce: number | undefined, options: IEvmCancellationOptions) => Promise<{
|
|
82
110
|
error?: boolean;
|
|
@@ -146,6 +174,23 @@ export type SyscoinSubmissionDescriptor = Readonly<{
|
|
|
146
174
|
export type SyscoinOwnedSubmissionOptions = SyscoinOwnedReadOptions & Readonly<{
|
|
147
175
|
prepare: (descriptor: SyscoinSubmissionDescriptor) => Promise<void>;
|
|
148
176
|
}>;
|
|
177
|
+
export type SyscoinRetainedSubmissionOwner = Readonly<{
|
|
178
|
+
account: Readonly<{
|
|
179
|
+
id: number;
|
|
180
|
+
type: string;
|
|
181
|
+
xpub: string;
|
|
182
|
+
}>;
|
|
183
|
+
chainId: number;
|
|
184
|
+
genesisHash: string;
|
|
185
|
+
slip44: number;
|
|
186
|
+
}>;
|
|
187
|
+
export type SyscoinRetainedSubmission = SyscoinSubmissionDescriptor & Readonly<{
|
|
188
|
+
owner: SyscoinRetainedSubmissionOwner;
|
|
189
|
+
}>;
|
|
190
|
+
/** The trusted wallet host reads the authenticated journal, not a UI payload. */
|
|
191
|
+
export type SyscoinRetainedSubmissionOptions = SyscoinOwnedSubmissionOptions & Pick<OwnedUtxoRpcVerification, 'readJson'> & Readonly<{
|
|
192
|
+
readRetained: (owner: SyscoinRetainedSubmissionOwner, txid: string) => Promise<SyscoinRetainedSubmission | undefined>;
|
|
193
|
+
}>;
|
|
149
194
|
export interface ISyscoinTransactions {
|
|
150
195
|
getEstimateSysTransactionFee: ({ txOptions, amount, receivingAddress, feeRate, token, isMax, nativeSweep, excludedOutpoints, }: {
|
|
151
196
|
amount: number | string;
|
|
@@ -168,6 +213,7 @@ export interface ISyscoinTransactions {
|
|
|
168
213
|
getRecommendedFee: (explorerUrl: string, ownedRead: SyscoinOwnedReadOptions) => Promise<number>;
|
|
169
214
|
decodeRawTransaction: (psbtOrHex: any, isRawHex?: boolean) => any;
|
|
170
215
|
sendTransaction: (rawTransaction: string, authority: SyscoinOwnedSubmissionOptions) => Promise<ITxid>;
|
|
216
|
+
replayRetainedTransaction: (txid: string, authority: SyscoinRetainedSubmissionOptions) => Promise<ITxid>;
|
|
171
217
|
signPSBT: ({ psbt, isTrezor, isLedger, }: {
|
|
172
218
|
isLedger?: boolean;
|
|
173
219
|
isTrezor?: boolean;
|
|
@@ -340,6 +386,8 @@ export interface ILatestUpdateForSysAccount {
|
|
|
340
386
|
xpub: any;
|
|
341
387
|
}
|
|
342
388
|
export type IReviewedEvmTokenApproval = Readonly<{
|
|
389
|
+
/** Nonce selected by the host's ordinary wallet policy before signing. */
|
|
390
|
+
nonce: number;
|
|
343
391
|
assertCurrent: () => void;
|
|
344
392
|
signal: AbortSignal;
|
|
345
393
|
}>;
|
|
@@ -4,7 +4,7 @@ export interface ExcludedOutpoint {
|
|
|
4
4
|
}
|
|
5
5
|
export declare const excludedOutpointIds: (outpoints?: readonly ExcludedOutpoint[]) => Set<string>;
|
|
6
6
|
/** Preserve the backend's asset metadata while removing only reserved outputs. */
|
|
7
|
-
export declare const filterExcludedUtxos: (raw: any, excluded: ReadonlySet<string
|
|
7
|
+
export declare const filterExcludedUtxos: (raw: any, excluded: ReadonlySet<string>, onExcluded?: (row: any, outpoint: string) => void) => any;
|
|
8
8
|
export declare const assertNoExcludedInputs: (psbt: {
|
|
9
9
|
txInputs: {
|
|
10
10
|
hash: Uint8Array;
|