@sidhujag/sysweb3-keyring 2.1.3 → 2.1.5

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.
Files changed (129) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +47 -47
  3. package/cjs/hardware-transaction-authority.js +36 -0
  4. package/cjs/hardware-transaction-authority.js.map +1 -0
  5. package/cjs/index.js +5 -5
  6. package/cjs/index.js.map +1 -1
  7. package/cjs/keyring-core.js +171 -220
  8. package/cjs/keyring-core.js.map +1 -1
  9. package/cjs/keyring-host.js +113 -0
  10. package/cjs/keyring-host.js.map +1 -0
  11. package/cjs/keyring-manager.js +15 -151
  12. package/cjs/keyring-manager.js.map +1 -1
  13. package/cjs/ledger/host-types.js.map +1 -1
  14. package/cjs/ledger/index.js +44 -19
  15. package/cjs/ledger/index.js.map +1 -1
  16. package/cjs/providers.js +3 -1
  17. package/cjs/providers.js.map +1 -1
  18. package/cjs/software.js +10 -56
  19. package/cjs/software.js.map +1 -1
  20. package/cjs/transactions/ethereum.js +306 -229
  21. package/cjs/transactions/ethereum.js.map +1 -1
  22. package/cjs/transactions/evm-local-signer.js +15 -0
  23. package/cjs/transactions/evm-local-signer.js.map +1 -1
  24. package/cjs/transactions/evm-submission.js +61 -65
  25. package/cjs/transactions/evm-submission.js.map +1 -1
  26. package/cjs/transactions/hardware-psbt.js +11 -8
  27. package/cjs/transactions/hardware-psbt.js.map +1 -1
  28. package/cjs/transactions/index.js +10 -2
  29. package/cjs/transactions/index.js.map +1 -1
  30. package/cjs/transactions/prepared-evm.js +10 -7
  31. package/cjs/transactions/prepared-evm.js.map +1 -1
  32. package/cjs/transactions/syscoin-core.js +308 -205
  33. package/cjs/transactions/syscoin-core.js.map +1 -1
  34. package/cjs/trezor/connect.js +19 -2
  35. package/cjs/trezor/connect.js.map +1 -1
  36. package/cjs/trezor/index.js +38 -16
  37. package/cjs/trezor/index.js.map +1 -1
  38. package/cjs/types.js.map +1 -1
  39. package/cjs/utils/excluded-utxos.js +6 -2
  40. package/cjs/utils/excluded-utxos.js.map +1 -1
  41. package/cjs/utils/owned-blockbook-account.js +45 -0
  42. package/cjs/utils/owned-blockbook-account.js.map +1 -0
  43. package/esm/current-vault-refusal.js +3 -0
  44. package/esm/current-vault-refusal.js.map +1 -0
  45. package/esm/evm-fees.js +242 -0
  46. package/esm/evm-fees.js.map +1 -0
  47. package/esm/hardware-transaction-authority.js +33 -0
  48. package/esm/hardware-transaction-authority.js.map +1 -0
  49. package/esm/initial-state.js +102 -0
  50. package/esm/initial-state.js.map +1 -0
  51. package/esm/keyring-core.js +2781 -0
  52. package/esm/keyring-core.js.map +1 -0
  53. package/esm/keyring-host.js +108 -0
  54. package/esm/keyring-host.js.map +1 -0
  55. package/esm/ledger/dmk-session.js +1 -0
  56. package/esm/ledger/dmk-session.js.map +1 -1
  57. package/esm/ledger/dmk-utxo.js +9 -3
  58. package/esm/ledger/dmk-utxo.js.map +1 -1
  59. package/esm/ledger/host-types.js.map +1 -1
  60. package/esm/ledger/index.js +44 -19
  61. package/esm/ledger/index.js.map +1 -1
  62. package/esm/network-utils.js +70 -0
  63. package/esm/network-utils.js.map +1 -0
  64. package/esm/providers.js +3 -1
  65. package/esm/providers.js.map +1 -1
  66. package/esm/software-hd-account.js +20 -0
  67. package/esm/software-hd-account.js.map +1 -0
  68. package/esm/storage-core.js +258 -0
  69. package/esm/storage-core.js.map +1 -0
  70. package/esm/transactions/ethereum.js +2753 -0
  71. package/esm/transactions/ethereum.js.map +1 -0
  72. package/esm/transactions/evm-cancellation.js +40 -0
  73. package/esm/transactions/evm-cancellation.js.map +1 -0
  74. package/esm/transactions/evm-local-signer.js +202 -0
  75. package/esm/transactions/evm-local-signer.js.map +1 -0
  76. package/esm/transactions/evm-submission.js +187 -0
  77. package/esm/transactions/evm-submission.js.map +1 -0
  78. package/esm/transactions/prepared-evm.js +194 -0
  79. package/esm/transactions/prepared-evm.js.map +1 -0
  80. package/esm/transactions/syscoin-core.js +714 -0
  81. package/esm/transactions/syscoin-core.js.map +1 -0
  82. package/esm/trezor/connect.js +19 -2
  83. package/esm/trezor/connect.js.map +1 -1
  84. package/esm/trezor/index.js +38 -16
  85. package/esm/trezor/index.js.map +1 -1
  86. package/esm/types.js.map +1 -1
  87. package/esm/utils/excluded-utxos.js +57 -0
  88. package/esm/utils/excluded-utxos.js.map +1 -0
  89. package/esm/utils/owned-blockbook-account.js +9 -0
  90. package/esm/utils/owned-blockbook-account.js.map +1 -0
  91. package/esm/utils/psbt.js +32 -0
  92. package/esm/utils/psbt.js.map +1 -0
  93. package/esm/utils/watch-descriptor.js +138 -0
  94. package/esm/utils/watch-descriptor.js.map +1 -0
  95. package/package.json +5 -11
  96. package/types/hardware-transaction-authority.d.ts +5 -0
  97. package/types/index.d.ts +3 -3
  98. package/types/keyring-core.d.ts +22 -51
  99. package/types/keyring-host.d.ts +46 -0
  100. package/types/keyring-manager.d.ts +13 -18
  101. package/types/ledger/host-types.d.ts +4 -1
  102. package/types/ledger/index.d.ts +1 -1
  103. package/types/ledger/types.d.ts +3 -2
  104. package/types/providers.d.ts +1 -1
  105. package/types/software.d.ts +6 -19
  106. package/types/transactions/ethereum.d.ts +14 -11
  107. package/types/transactions/evm-local-signer.d.ts +2 -2
  108. package/types/transactions/evm-submission.d.ts +11 -4
  109. package/types/transactions/hardware-psbt.d.ts +1 -1
  110. package/types/transactions/index.d.ts +3 -2
  111. package/types/transactions/prepared-evm.d.ts +4 -1
  112. package/types/transactions/syscoin-core.d.ts +48 -21
  113. package/types/trezor/connect.d.ts +6 -3
  114. package/types/trezor/index.d.ts +4 -3
  115. package/types/types.d.ts +95 -63
  116. package/types/utils/excluded-utxos.d.ts +1 -1
  117. package/types/utils/owned-blockbook-account.d.ts +3 -0
  118. package/cjs/hardware-wallet-manager-singleton.js +0 -34
  119. package/cjs/hardware-wallet-manager-singleton.js.map +0 -1
  120. package/cjs/storage.js +0 -20
  121. package/cjs/storage.js.map +0 -1
  122. package/cjs/transactions/syscoin.js +0 -16
  123. package/cjs/transactions/syscoin.js.map +0 -1
  124. package/cjs/utils/blockbook-cache.js +0 -76
  125. package/cjs/utils/blockbook-cache.js.map +0 -1
  126. package/types/hardware-wallet-manager-singleton.d.ts +0 -19
  127. package/types/storage.d.ts +0 -5
  128. package/types/transactions/syscoin.d.ts +0 -9
  129. package/types/utils/blockbook-cache.d.ts +0 -6
@@ -23,7 +23,7 @@ export declare const parsePersonalMessage: (hexMessage: string) => string;
23
23
  /** Pin the checked gas and chain to the same detached envelope that is serialized. */
24
24
  export declare const normalizeGasLimitedTransaction: (transaction: TransactionRequest) => TransactionRequest;
25
25
  export declare const signTransaction: (transaction: TransactionRequest, privateKey: string | Uint8Array) => string;
26
- export declare const sendLocalEvmTransaction: (provider: CustomJsonRpcProvider, privateKey: string, transaction: Deferrable<Record<string, any>>, beforeBroadcast?: () => void, beforeSign?: () => void,
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, submission?: EvmSubmissionBoundary) => Promise<any>;
28
+ validateBeforeSign: ((transaction: TransactionRequest) => void) | undefined, submission: EvmSubmissionBoundary) => Promise<any>;
29
29
  export declare const sameAddress: (left: string, right: string) => boolean;
@@ -31,13 +31,17 @@ export type EvmSubmissionLifecycle = Readonly<{
31
31
  persistSigned: (record: EvmSignedSubmission) => Promise<void>;
32
32
  }>;
33
33
  export type CaptureEvmSubmission = (context: EvmSubmissionContext) => EvmSubmissionLifecycle;
34
+ declare const evmSubmissionBrand: unique symbol;
34
35
  export type EvmSubmissionBoundary = Readonly<{
36
+ [evmSubmissionBrand]: true;
35
37
  context: EvmSubmissionContext;
36
38
  assertCurrent: () => void;
37
- persistSigned?: (record: EvmSignedSubmission) => Promise<void>;
39
+ persistSigned: (record: EvmSignedSubmission) => Promise<void>;
38
40
  }>;
39
41
  /** Capture once, before RPC or device work. Never reread host capabilities later. */
40
- export declare function captureEvmSubmission(input: EvmSubmissionContext, assertCurrent: () => void, capture?: CaptureEvmSubmission): EvmSubmissionBoundary;
42
+ export declare function captureEvmSubmission(input: EvmSubmissionContext, assertCurrent: () => void, capture: CaptureEvmSubmission): EvmSubmissionBoundary;
43
+ /** Refuse any new signature or dispatch without a captured durable port. */
44
+ export declare function assertDurableEvmSubmission(boundary: EvmSubmissionBoundary): void;
41
45
  /** Only local stage evidence can label an error as a possibly dispatched send. */
42
46
  export declare function evmSubmissionFailure(error: unknown): Readonly<{
43
47
  transactionNotBroadcast: boolean;
@@ -47,5 +51,8 @@ export declare function evmSubmissionFailure(error: unknown): Readonly<{
47
51
  export declare function copyEvmSubmissionFailure(source: unknown, target: Error): void;
48
52
  /** Compare signed wire bytes with the complete envelope captured before signing. */
49
53
  export declare function assertSignedEvmTransactionMatches(rawTransaction: string, expectedUnsignedTransaction: string, expectedFrom?: string): Transaction;
50
- /** The sole local-signature dispatch boundary. No nonce/fee selection or retry. */
51
- export declare function submitSignedEvmTransaction<T>(rawTransaction: string, broadcast: (rawTransaction: string) => Promise<T>, boundary?: EvmSubmissionBoundary, beforeBroadcast?: () => void, expectedUnsignedTransaction?: string): Promise<T>;
54
+ /** Submit software-signed bytes through the captured durable boundary. */
55
+ export declare function submitSignedEvmTransaction<T>(rawTransaction: string, broadcast: (rawTransaction: string) => Promise<T>, boundary: EvmSubmissionBoundary, beforeBroadcast: (() => void) | undefined, expectedUnsignedTransaction: string): Promise<T>;
56
+ /** @internal Device signatures always require a fresh live chain probe after persistence. */
57
+ export declare function submitSignedHardwareEvmTransaction<T>(rawTransaction: string, broadcast: (rawTransaction: string) => Promise<T>, boundary: EvmSubmissionBoundary, beforeBroadcast: (() => void) | undefined, expectedUnsignedTransaction: string, verifyCurrentChain: () => Promise<void>): Promise<T>;
58
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { type ISyscoinHardwareSigner } from './syscoin-core';
2
2
  import type { LedgerKeyring } from '../ledger';
3
3
  import type { TrezorKeyring } from '../trezor';
4
- /** Legacy device adapter. The software transaction engine never imports it. */
4
+ /** The software transaction engine never imports this device adapter. */
5
5
  export declare function createLedgerPsbtSigner(ledger: LedgerKeyring): ISyscoinHardwareSigner;
6
6
  /** Keep Trezor conversion and signing outside the software-only import graph. */
7
7
  export declare function createTrezorPsbtSigner(trezor: TrezorKeyring): ISyscoinHardwareSigner;
@@ -1,3 +1,4 @@
1
1
  export * from './ethereum';
2
- export * from './syscoin';
3
- export * from './evm-submission';
2
+ export { assertDurableEvmSubmission, assertSignedEvmTransactionMatches, captureEvmSubmission, copyEvmSubmissionFailure, evmSubmissionFailure, submitSignedEvmTransaction, } from './evm-submission';
3
+ export type { CaptureEvmSubmission, EvmSignedSubmission, EvmSubmissionBoundary, EvmSubmissionContext, EvmSubmissionLifecycle, } from './evm-submission';
4
+ export { readPublicSyscoinFee } from './syscoin-core';
@@ -50,4 +50,7 @@ export type SignedPreparedEvmTransaction = Readonly<{
50
50
  export declare function snapshotPreparedEvmRequest(input: unknown): PreparedSoftwareEvmSigningRequest;
51
51
  export declare function preparedEvmGuard(input: unknown): () => void;
52
52
  /** Internal, network-free signing. The key never becomes part of the result. */
53
- export declare function signPreparedEvmEnvelope(transaction: PreparedEvmTransaction, privateKey: string): SignedPreparedEvmTransaction;
53
+ export declare function signPreparedEvmEnvelope(transaction: PreparedEvmTransaction, privateKey: string): Readonly<{
54
+ signed: SignedPreparedEvmTransaction;
55
+ expectedUnsigned: string;
56
+ }>;
@@ -1,6 +1,6 @@
1
- import { ITxid, txUtils } from '@sidhujag/sysweb3-utils';
1
+ import { ITxid } from '@sidhujag/sysweb3-utils';
2
2
  import { Psbt } from 'bitcoinjs-lib';
3
- import { ISyscoinTransactions, KeyringAccountType, accountType } from '../types';
3
+ import { ISyscoinTransactions, KeyringAccountType, accountType, type SyscoinOwnedReadOptions, type SyscoinOwnedSubmissionOptions } 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';
@@ -12,10 +12,11 @@ export interface ISyscoinHardwareSigningRequest {
12
12
  xpub: string;
13
13
  }>;
14
14
  assertCurrent: () => void;
15
- getRawTransaction?: ReturnType<typeof txUtils>['getRawTransaction'];
15
+ getRawTransaction?: (txid: string) => Promise<unknown>;
16
16
  readonly network: Readonly<INetwork>;
17
17
  psbt: Psbt;
18
18
  scope: PsbtAccountScope;
19
+ signal: AbortSignal;
19
20
  }
20
21
  /**
21
22
  * Trusted wallet-authority adapter, not an untrusted plugin entry point.
@@ -30,19 +31,48 @@ export interface ISyscoinHardwareSigners {
30
31
  export declare const createHardwareSignerUnavailableError: (hardware: string) => Error & {
31
32
  code: string;
32
33
  };
34
+ type BlockbookRead = Pick<SyscoinOwnedReadOptions, 'fetch' | 'signal'>;
35
+ /** Public network fee estimate. It has no wallet, account or signing access. */
36
+ export declare function readPublicSyscoinFee(explorerUrl: string, owner: SyscoinOwnedReadOptions): Promise<number>;
37
+ /** Internal captured context for the keyring's existing read-only builder and address lookup. */
38
+ export type SyscoinUtxoReadContext = Readonly<{
39
+ assertCurrent: () => void;
40
+ network: Readonly<INetwork>;
41
+ transport: BlockbookRead;
42
+ xpub: string;
43
+ }>;
44
+ type OwnedPreparation = Readonly<{
45
+ account: Readonly<{
46
+ address: string;
47
+ xpub: string;
48
+ }>;
49
+ accountId: number;
50
+ accountType: KeyringAccountType;
51
+ read: SyscoinUtxoReadContext;
52
+ }>;
53
+ type GetUtxoReadState = () => {
54
+ accounts: Partial<Record<KeyringAccountType, accountType>>;
55
+ activeAccountId: number;
56
+ activeAccountType: KeyringAccountType;
57
+ activeNetwork: INetwork;
58
+ };
59
+ /** Bind both transaction preparation and address reads to the active wallet. */
60
+ export declare function captureOwnedSyscoinRead(options: SyscoinOwnedReadOptions, getState: GetUtxoReadState, captureSigningContext: (bindSessionRevision: boolean) => () => void): OwnedPreparation;
61
+ type GetUtxoAddress = (xpub: string, isChangeAddress: boolean) => Promise<string>;
62
+ type ReadOnlySigner = {
63
+ main: any;
64
+ getOwnedAddress?: GetUtxoAddress;
65
+ };
33
66
  export declare class SyscoinTransactionsCore implements ISyscoinTransactions {
34
67
  private getSigner;
35
68
  private getReadOnlySigner;
36
69
  private hardwareSigners;
37
70
  private getState;
38
- private getAddress;
39
- private captureSigningContext?;
71
+ private captureSigningContext;
40
72
  constructor(getSyscoinSigner: () => {
41
73
  hd: SyscoinHDSigner;
42
74
  main: any;
43
- }, getReadOnlySigner: () => {
44
- main: any;
45
- }, getState: () => {
75
+ }, getReadOnlySigner: (read?: SyscoinUtxoReadContext) => ReadOnlySigner, getState: () => {
46
76
  accounts: {
47
77
  HDAccount: accountType;
48
78
  Imported: accountType;
@@ -52,14 +82,11 @@ export declare class SyscoinTransactionsCore implements ISyscoinTransactions {
52
82
  activeAccountId: number;
53
83
  activeAccountType: KeyringAccountType;
54
84
  activeNetwork: INetwork;
55
- }, getAddress: (xpub: string, isChangeAddress: boolean) => Promise<string>, hardwareSigners?: ISyscoinHardwareSigners, captureSigningContext?: () => () => void);
85
+ }, hardwareSigners: ISyscoinHardwareSigners, captureSigningContext: (bindSessionRevision: boolean) => () => void);
56
86
  private getTransactionPSBT;
57
87
  decodeRawTransaction: (psbtOrHex: any, isRawHex?: boolean) => any;
58
- private feeCache;
59
- getRecommendedFee: (explorerUrl: string) => Promise<number>;
60
- txUtilsFunctions: () => {
61
- getRawTransaction: (explorerUrl: string, txid: string) => Promise<any>;
62
- };
88
+ private captureOwnedRead;
89
+ getRecommendedFee: (explorerUrl: string, ownedRead: SyscoinOwnedReadOptions) => Promise<number>;
63
90
  private signPSBTWithSigner;
64
91
  private createNativeSweepPSBT;
65
92
  private createUnsignedPSBT;
@@ -76,17 +103,17 @@ export declare class SyscoinTransactionsCore implements ISyscoinTransactions {
76
103
  isMax?: boolean | false;
77
104
  nativeSweep?: boolean;
78
105
  excludedOutpoints?: readonly ExcludedOutpoint[];
79
- }) => Promise<{
106
+ }, ownedRead: SyscoinOwnedReadOptions) => Promise<{
80
107
  grossAmount?: string | undefined;
81
108
  recipientAmount?: string | undefined;
82
109
  fee: number;
83
110
  psbt: any;
84
111
  }>;
85
- private sendSignedTransaction;
86
- signPSBT: ({ psbt, isTrezor, isLedger, }: {
87
- psbt: any;
88
- isTrezor?: boolean;
112
+ signPSBT: ({ psbt }: {
89
113
  isLedger?: boolean;
90
- }) => Promise<any>;
91
- sendTransaction: (psbt: any) => Promise<ITxid>;
114
+ isTrezor?: boolean;
115
+ psbt: any;
116
+ }, ownedRead: SyscoinOwnedReadOptions) => Promise<any>;
117
+ sendTransaction: (rawTransaction: string, authority: SyscoinOwnedSubmissionOptions) => Promise<ITxid>;
92
118
  }
119
+ export {};
@@ -1,7 +1,8 @@
1
+ import type { HardwareTransactionAuthority } from '../hardware-transaction-authority';
1
2
  import type { ConnectDynamicSettings, TrezorConnectPublicAPI } from '@trezor/connect-webextension';
2
3
  type Client = TrezorConnectPublicAPI<ConnectDynamicSettings>;
3
- declare const methods: readonly ["getFeatures", "getAccountInfo", "ethereumGetAddress", "ethereumGetPublicKey", "getPublicKey", "getAddress", "signTransaction", "ethereumSignTransaction", "signMessage", "ethereumSignMessage", "ethereumSignTypedData", "verifyMessage", "ethereumVerifyMessage"];
4
- type Method = (typeof methods)[number];
4
+ declare const methods: readonly ["getFeatures", "getAccountInfo", "ethereumGetAddress", "ethereumGetPublicKey", "getPublicKey", "getAddress", "signMessage", "ethereumSignMessage", "ethereumSignTypedData", "verifyMessage", "ethereumVerifyMessage"];
5
+ type ForwardedMethod = (typeof methods)[number];
5
6
  type Compatible<T> = T extends {
6
7
  success: false;
7
8
  } ? T & {
@@ -20,7 +21,7 @@ type CompatibleCall<FunctionType> = FunctionType extends {
20
21
  (...args: C): Promise<Compatible<Awaited<T>>>;
21
22
  } : never;
22
23
  type Calls = {
23
- [Name in Method]: CompatibleCall<Client[Name]>;
24
+ [Name in ForwardedMethod]: CompatibleCall<Client[Name]>;
24
25
  };
25
26
  type ConnectionEvent = {
26
27
  type: 'disconnected';
@@ -30,6 +31,8 @@ type ConnectionEvent = {
30
31
  };
31
32
  export declare const subscribeTrezorEvents: (listener: (event: ConnectionEvent) => void) => (() => void);
32
33
  declare const TrezorConnect: Calls & {
34
+ ethereumSignTransactionOwned: (request: Parameters<Client['ethereumSignTransaction']>[0], authority: HardwareTransactionAuthority) => ReturnType<CompatibleCall<Client['ethereumSignTransaction']>>;
35
+ signTransactionOwned: (request: Parameters<Client['signTransaction']>[0], authority: HardwareTransactionAuthority) => ReturnType<CompatibleCall<Client['signTransaction']>>;
33
36
  init: Client['init'];
34
37
  dispose: () => Promise<void>;
35
38
  };
@@ -1,6 +1,7 @@
1
1
  import { TypedMessage, SignTypedDataVersion, TypedDataV1 } from '@metamask/eth-sig-util';
2
2
  import { Psbt } from 'bitcoinjs-lib';
3
3
  import { Buffer } from 'buffer';
4
+ import type { HardwareTransactionAuthority } from '../hardware-transaction-authority';
4
5
  import type { AccountInfo, EthereumTransaction, EthereumTransactionEIP1559 } from '@trezor/connect-webextension';
5
6
  export interface TrezorControllerState {
6
7
  hdPath: string;
@@ -28,7 +29,7 @@ export declare class TrezorKeyring {
28
29
  /**
29
30
  * Initialize Trezor script.
30
31
  */
31
- init(): Promise<boolean>;
32
+ init(assertCurrent?: () => void): Promise<boolean>;
32
33
  /**
33
34
  * Execute operation with automatic retry
34
35
  */
@@ -102,7 +103,7 @@ export declare class TrezorKeyring {
102
103
  * @param outputs - utxo transaction outputs
103
104
  * @returns signature object
104
105
  */
105
- signUtxoTransaction(utxoTransaction: any, psbt: Psbt): Promise<Psbt>;
106
+ signUtxoTransaction(utxoTransaction: any, psbt: Psbt, authority: HardwareTransactionAuthority): Promise<Psbt>;
106
107
  private setHdPath;
107
108
  convertToAddressNFormat(path: string): any[];
108
109
  isScriptHash(address: string, networkInfo: any): boolean;
@@ -122,7 +123,7 @@ export declare class TrezorKeyring {
122
123
  tx: EthereumTransaction | EthereumTransactionEIP1559;
123
124
  coin: string;
124
125
  slip44: number;
125
- }): Promise<import("@trezor/connect-webextension").OkWithDevice<{
126
+ }, authority: HardwareTransactionAuthority): Promise<import("@trezor/connect-webextension").OkWithDevice<{
126
127
  authorizationList?: {
127
128
  address: string;
128
129
  chainId: number;
package/types/types.d.ts CHANGED
@@ -7,6 +7,8 @@ import { LedgerKeyring } from './ledger';
7
7
  import { IDecryptPrivateRecordParams, IEncryptedPrivateRecord, IEncryptPrivateRecordParams } from './private-records';
8
8
  import { SyscoinHDSigner } from './signers';
9
9
  import { TrezorKeyring } from './trezor';
10
+ import type { KeyringCore } from './keyring-core';
11
+ import type { PreparedEvmTransaction } from './transactions/prepared-evm';
10
12
  export type AccessListish = Array<{
11
13
  address: string;
12
14
  storageKeys: string[];
@@ -37,46 +39,44 @@ export type EvmLocalAccount = {
37
39
  };
38
40
  export interface IEvmSendOptions {
39
41
  /** Synchronous host admission, rechecked immediately before signing and broadcast. */
40
- assertCurrent?: () => void;
42
+ assertCurrent: () => void;
43
+ mode: 'reviewed-native' | 'specialized';
41
44
  }
42
- export interface IEvmReplacementOptions {
43
- /** Read-only preview; never requests credentials, a device signature or broadcast. */
44
- previewOnly?: boolean;
45
- /** Required for sending: maximum execution gas fee in decimal wei approved by the user. */
46
- approvedMaximumFee?: string;
47
- /** Select the locally controlled outer gas payer for a smart-account transaction. */
48
- targetAccount?: {
49
- id: number;
50
- type: KeyringAccountType;
51
- };
52
- /** Host guard for the current account, network, session and pending original. */
53
- assertCurrentContext?: () => void;
54
- /** Synchronous original admission; Promise/thenable returns are rejected, never awaited. */
55
- validateOriginal?: (transaction: TransactionResponse) => void;
56
- beforeBroadcast?: () => void;
57
- }
58
- export interface IEvmCancellationOptions {
59
- /** Select the locally controlled outer gas payer for a smart-account transaction. */
45
+ export type EvmFormattedSendArguments = [
46
+ approvedTransaction: PreparedEvmTransaction,
47
+ isLegacy: boolean | undefined,
48
+ options: IEvmSendOptions & {
49
+ mode: 'reviewed-native';
50
+ }
51
+ ] | [
52
+ transaction: SimpleTransactionRequest,
53
+ isLegacy: boolean | undefined,
54
+ options: IEvmSendOptions & {
55
+ mode: 'specialized';
56
+ }
57
+ ];
58
+ export type EvmReplacementFeeApproval = {
59
+ previewOnly: true;
60
+ approvedMaximumFee?: never;
61
+ } | {
62
+ previewOnly?: false;
63
+ approvedMaximumFee: string;
64
+ };
65
+ type EvmOriginalAdmission<Original> = {
66
+ /** Select a distinct locally controlled gas payer for a smart account. */
60
67
  targetAccount?: {
61
68
  id: number;
62
69
  type: KeyringAccountType;
63
70
  };
64
- /** Read-only preview; never requests credentials, a device signature or broadcast. */
65
- previewOnly?: boolean;
66
- /** Required for sending: maximum execution gas fee in decimal wei approved by the user. */
67
- approvedMaximumFee?: string;
68
- /** Synchronous host guard for selection or session state outside the keyring. */
71
+ /** Synchronous host guard for the current account, network, session and pending original. */
69
72
  assertCurrentContext: () => void;
70
- /**
71
- * Required synchronous host admission for the reviewed pending original.
72
- * Non-null values contain detached, authenticated signed fields. Null means
73
- * the RPC did not find the original: admit it only when the supplied fallbackNonce
74
- * belongs to trusted, still-current local submission data; otherwise throw.
75
- * Invalid non-null RPC replies never become a null/fallback admission.
76
- * Promise/thenable returns are rejected, never awaited.
77
- */
78
- validateOriginal: (transaction: TransactionResponse | null) => void;
79
- }
73
+ /** Receives authenticated signed fields. Null requires explicit cancellation fallback admission. */
74
+ validateOriginal: (transaction: Original) => void;
75
+ };
76
+ export type IEvmReplacementOptions = EvmReplacementFeeApproval & EvmOriginalAdmission<TransactionResponse> & {
77
+ beforeBroadcast?: () => void;
78
+ };
79
+ export type IEvmCancellationOptions = EvmReplacementFeeApproval & EvmOriginalAdmission<TransactionResponse | null>;
80
80
  export interface IEthereumTransactions {
81
81
  cancelSentTransaction: (txHash: string, isLegacy: boolean | undefined, fallbackNonce: number | undefined, options: IEvmCancellationOptions) => Promise<{
82
82
  error?: boolean;
@@ -99,13 +99,13 @@ export interface IEthereumTransactions {
99
99
  signTypedData: (addr: string, typedData: TypedDataV1 | TypedMessage<any>, version: SignTypedDataVersion) => Promise<string>;
100
100
  importAccount: (mnemonicOrPrivKey: string) => EvmLocalAccount;
101
101
  parsePersonalMessage: (hexMsg: string) => string;
102
- sendFormattedTransaction: (params: SimpleTransactionRequest, isLegacy?: boolean, options?: IEvmSendOptions) => Promise<TransactionResponse>;
103
- sendSignedErc1155Transaction: ({ receiver, tokenAddress, tokenId, isLegacy, gasPrice, gasLimit, maxFeePerGas, maxPriorityFeePerGas, }: ISendSignedErcTransactionProps) => Promise<IResponseFromSendErcSignedTransaction>;
102
+ sendFormattedTransaction: (...args: EvmFormattedSendArguments) => Promise<TransactionResponse>;
103
+ sendSignedErc1155Transaction: (params: ISendSignedErc1155TransactionProps, approval: IReviewedEvmTokenApproval) => Promise<IResponseFromSendErcSignedTransaction>;
104
104
  verifyPersonalMessage: (msg: string, sign: string) => string;
105
105
  toBigNumber: (aBigNumberish: string | number) => BigNumber;
106
- sendSignedErc20Transaction: ({ networkUrl, receiver, tokenAddress, tokenAmount, }: ISendSignedErcTransactionProps) => Promise<IResponseFromSendErcSignedTransaction>;
107
- sendSignedErc721Transaction: ({ networkUrl, receiver, tokenAddress, tokenId, }: ISendSignedErcTransactionProps) => Promise<IResponseFromSendErcSignedTransaction>;
108
- sendTransactionWithEditedFee: (txHash: string, isLegacy?: boolean, options?: IEvmReplacementOptions) => Promise<{
106
+ sendSignedErc20Transaction: (params: ISendSignedErc20TransactionProps, approval: IReviewedEvmTokenApproval) => Promise<IResponseFromSendErcSignedTransaction>;
107
+ sendSignedErc721Transaction: (params: ISendSignedErc721TransactionProps, approval: IReviewedEvmTokenApproval) => Promise<IResponseFromSendErcSignedTransaction>;
108
+ sendTransactionWithEditedFee: (txHash: string, isLegacy: boolean | undefined, options: IEvmReplacementOptions) => Promise<{
109
109
  maximumFee?: string;
110
110
  isSpeedUp: boolean;
111
111
  transactionNotBroadcast?: boolean;
@@ -131,6 +131,21 @@ export interface ISyscoinTransactionFeeQuote {
131
131
  grossAmount?: string;
132
132
  recipientAmount?: string;
133
133
  }
134
+ /** A trusted wallet host owns the lifetime and HTTP policy of these reads. */
135
+ export type SyscoinOwnedReadOptions = Readonly<{
136
+ assertCurrent: () => void;
137
+ fetch: typeof globalThis.fetch;
138
+ signal: AbortSignal;
139
+ }>;
140
+ /** Exact signed bytes presented to a wallet host before the only POST. */
141
+ export type SyscoinSubmissionDescriptor = Readonly<{
142
+ rawTransaction: string;
143
+ txid: string;
144
+ url: string;
145
+ }>;
146
+ export type SyscoinOwnedSubmissionOptions = SyscoinOwnedReadOptions & Readonly<{
147
+ prepare: (descriptor: SyscoinSubmissionDescriptor) => Promise<void>;
148
+ }>;
134
149
  export interface ISyscoinTransactions {
135
150
  getEstimateSysTransactionFee: ({ txOptions, amount, receivingAddress, feeRate, token, isMax, nativeSweep, excludedOutpoints, }: {
136
151
  amount: number | string;
@@ -149,15 +164,15 @@ export interface ISyscoinTransactions {
149
164
  txid: string;
150
165
  vout: number;
151
166
  }[];
152
- }) => Promise<ISyscoinTransactionFeeQuote>;
153
- getRecommendedFee: (explorerUrl: string) => Promise<number>;
167
+ }, ownedRead: SyscoinOwnedReadOptions) => Promise<ISyscoinTransactionFeeQuote>;
168
+ getRecommendedFee: (explorerUrl: string, ownedRead: SyscoinOwnedReadOptions) => Promise<number>;
154
169
  decodeRawTransaction: (psbtOrHex: any, isRawHex?: boolean) => any;
155
- sendTransaction: (psbt: any) => Promise<ITxid>;
170
+ sendTransaction: (rawTransaction: string, authority: SyscoinOwnedSubmissionOptions) => Promise<ITxid>;
156
171
  signPSBT: ({ psbt, isTrezor, isLedger, }: {
157
172
  isLedger?: boolean;
158
173
  isTrezor?: boolean;
159
174
  psbt: any;
160
- }) => Promise<any>;
175
+ }, ownedRead: SyscoinOwnedReadOptions) => Promise<any>;
161
176
  }
162
177
  export interface IKeyringManager {
163
178
  addNewAccount: (label?: string) => Promise<IKeyringAccountState>;
@@ -179,7 +194,6 @@ export interface IKeyringManager {
179
194
  success: boolean;
180
195
  }>;
181
196
  getPrivateKeyByAccountId: (id: number, accountType: KeyringAccountType, pwd: string) => Promise<string>;
182
- setStorage: (client: any) => void;
183
197
  syscoinTransaction: ISyscoinTransactions;
184
198
  isSeedValid: (seedPhrase: string) => boolean;
185
199
  getSeed: (pwd: string) => Promise<string>;
@@ -204,11 +218,11 @@ export interface IKeyringManager {
204
218
  importAccount: (privKey: string, label?: string, options?: {
205
219
  utxoAddressType?: 'p2wpkh' | 'p2pkh';
206
220
  }) => Promise<IKeyringAccountState>;
207
- getNewChangeAddress: () => Promise<string>;
208
- getChangeAddress: (id: number) => Promise<string>;
209
- getPubkey: (id: number, isChangeAddress: boolean) => Promise<string>;
210
- getBip32Path: (id: number, isChangeAddress: boolean) => Promise<string>;
211
- updateReceivingAddress: () => Promise<string>;
221
+ getNewChangeAddress: (ownedRead: SyscoinOwnedReadOptions) => Promise<string>;
222
+ getChangeAddress: (id: number, ownedRead: SyscoinOwnedReadOptions) => Promise<string>;
223
+ getPubkey: (id: number, isChangeAddress: boolean, ownedRead: SyscoinOwnedReadOptions) => Promise<string>;
224
+ getBip32Path: (id: number, isChangeAddress: boolean, ownedRead: SyscoinOwnedReadOptions) => Promise<string>;
225
+ updateReceivingAddress: (ownedRead: SyscoinOwnedReadOptions) => Promise<string>;
212
226
  getActiveAccount: () => {
213
227
  activeAccount: Omit<IKeyringAccountState, 'xprv'>;
214
228
  activeAccountType: KeyringAccountType;
@@ -219,12 +233,11 @@ export interface IKeyringManager {
219
233
  importLedgerAccount: (label?: string) => Promise<IKeyringAccountState | undefined>;
220
234
  getActiveUTXOAccountState: () => any;
221
235
  createEthAccount: (privateKey: string) => any;
222
- getAddress: (xpub: string, isChangeAddress: boolean) => Promise<string>;
236
+ getAddress: (xpub: string, isChangeAddress: boolean, ownedRead: SyscoinOwnedReadOptions) => Promise<string>;
223
237
  initializeWalletSecurely: (seedPhrase: string, password: string, prvPassword?: string) => Promise<IKeyringAccountState>;
224
238
  initializeSession: (seedPhrase: string, password: string) => Promise<void>;
225
239
  createFirstAccount: (label?: string) => Promise<IKeyringAccountState>;
226
- transferSessionTo: (targetKeyring: IKeyringManager) => void;
227
- receiveSessionOwnership: (sessionPassword: any, sessionMnemonic: any) => void;
240
+ transferSessionTo: (targetKeyring: KeyringCore) => void;
228
241
  lockWallet: () => Promise<void>;
229
242
  setVaultStateGetter: (getter: () => any) => void;
230
243
  }
@@ -326,20 +339,39 @@ export interface ILatestUpdateForSysAccount {
326
339
  receivingAddress: any;
327
340
  xpub: any;
328
341
  }
329
- export interface ISendSignedErcTransactionProps {
330
- decimals?: number;
331
- gasLimit?: BigNumberish;
332
- gasPrice?: BigNumberish;
333
- isLegacy?: boolean;
334
- maxFeePerGas?: BigNumberish;
335
- maxPriorityFeePerGas?: BigNumberish;
342
+ export type IReviewedEvmTokenApproval = Readonly<{
343
+ assertCurrent: () => void;
344
+ signal: AbortSignal;
345
+ }>;
346
+ export type IReviewedEvmTokenFees = {
347
+ gasLimit: BigNumberish;
348
+ } & ({
349
+ isLegacy: true;
350
+ gasPrice: BigNumberish;
351
+ maxFeePerGas?: never;
352
+ maxPriorityFeePerGas?: never;
353
+ } | {
354
+ isLegacy: false;
355
+ maxFeePerGas: BigNumberish;
356
+ maxPriorityFeePerGas: BigNumberish;
357
+ gasPrice?: never;
358
+ });
359
+ type ISendReviewedTokenBase = IReviewedEvmTokenFees & {
336
360
  networkUrl: string;
337
361
  receiver: string;
338
- saveTrezorTx?: (tx: any) => void;
339
362
  tokenAddress: string;
340
- tokenAmount?: string;
341
- tokenId?: bigint | number | string;
342
- }
363
+ };
364
+ /** Integer amounts and token identifiers are canonical uint256 strings. */
365
+ export type ISendSignedErc20TransactionProps = ISendReviewedTokenBase & {
366
+ tokenAmountUnits: string;
367
+ saveTrezorTx?: (tx: any) => void;
368
+ };
369
+ export type ISendSignedErc721TransactionProps = ISendReviewedTokenBase & {
370
+ tokenId: string;
371
+ };
372
+ export type ISendSignedErc1155TransactionProps = ISendSignedErc721TransactionProps & {
373
+ tokenAmount: string;
374
+ };
343
375
  export interface IResponseFromSendErcSignedTransaction {
344
376
  accessList: any[];
345
377
  chainId: number;
@@ -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>) => any;
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;
@@ -0,0 +1,3 @@
1
+ import type { SyscoinOwnedReadOptions } from '../types';
2
+ /** Read address paths with the host's endpoint policy and independent lifetime. */
3
+ export declare function fetchOwnedBlockbookAccount(backendUrl: string, xpub: string, transport: Pick<SyscoinOwnedReadOptions, 'fetch' | 'signal'>): Promise<any>;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HardwareWalletManagerSingleton = void 0;
4
- const hardware_wallet_manager_1 = require("./hardware-wallet-manager");
5
- /**
6
- * Singleton wrapper for HardwareWalletManager to ensure a single instance
7
- * is shared across all KeyringManager instances. This prevents "device already open"
8
- * errors when multiple networks try to connect to the same Ledger device.
9
- */
10
- class HardwareWalletManagerSingleton {
11
- /**
12
- * Get the shared HardwareWalletManager instance
13
- * Creates one if it doesn't exist
14
- */
15
- static getInstance() {
16
- if (!HardwareWalletManagerSingleton.instance) {
17
- HardwareWalletManagerSingleton.instance = new hardware_wallet_manager_1.HardwareWalletManager();
18
- }
19
- return HardwareWalletManagerSingleton.instance;
20
- }
21
- /**
22
- * Reset the singleton instance (useful for testing)
23
- */
24
- static resetInstance() {
25
- if (HardwareWalletManagerSingleton.instance) {
26
- // Clean up any existing connections
27
- HardwareWalletManagerSingleton.instance.destroy();
28
- HardwareWalletManagerSingleton.instance = null;
29
- }
30
- }
31
- }
32
- exports.HardwareWalletManagerSingleton = HardwareWalletManagerSingleton;
33
- HardwareWalletManagerSingleton.instance = null;
34
- //# sourceMappingURL=hardware-wallet-manager-singleton.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hardware-wallet-manager-singleton.js","sourceRoot":"","sources":["../../src/hardware-wallet-manager-singleton.ts"],"names":[],"mappings":";;;AAAA,uEAAkE;AAElE;;;;GAIG;AACH,MAAM,8BAA8B;IAGlC;;;OAGG;IACH,MAAM,CAAC,WAAW;QAChB,IAAI,CAAC,8BAA8B,CAAC,QAAQ,EAAE,CAAC;YAC7C,8BAA8B,CAAC,QAAQ,GAAG,IAAI,+CAAqB,EAAE,CAAC;QACxE,CAAC;QACD,OAAO,8BAA8B,CAAC,QAAQ,CAAC;IACjD,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,aAAa;QAClB,IAAI,8BAA8B,CAAC,QAAQ,EAAE,CAAC;YAC5C,oCAAoC;YACpC,8BAA8B,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YAClD,8BAA8B,CAAC,QAAQ,GAAG,IAAI,CAAC;QACjD,CAAC;IACH,CAAC;;AAGM,wEAA8B;AAzBtB,uCAAQ,GAAiC,IAAI,CAAC"}
package/cjs/storage.js DELETED
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VaultAuthenticationError = exports.getDecryptedVault = exports.setEncryptedVault = void 0;
4
- const sysweb3_core_1 = require("@sidhujag/sysweb3-core");
5
- const storage_core_1 = require("./storage-core");
6
- // Preserve the legacy process-wide storage authority. Host-isolated consumers
7
- // import storage-core directly and supply their own asynchronous storage port.
8
- const storage = sysweb3_core_1.sysweb3Di.getStateStorageDb();
9
- const persistence = (0, storage_core_1.createVaultPersistence)({
10
- get: async (key) => storage.get(key),
11
- set: async (key, value) => {
12
- await storage.set(key, value);
13
- },
14
- createManyIfAbsent: async (items) => storage.createManyIfAbsent(items),
15
- });
16
- exports.setEncryptedVault = persistence.setEncryptedVault;
17
- exports.getDecryptedVault = persistence.getDecryptedVault;
18
- var storage_core_2 = require("./storage-core");
19
- Object.defineProperty(exports, "VaultAuthenticationError", { enumerable: true, get: function () { return storage_core_2.VaultAuthenticationError; } });
20
- //# sourceMappingURL=storage.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/storage.ts"],"names":[],"mappings":";;;AAAA,yDAAmD;AAEnD,iDAAwD;AAExD,8EAA8E;AAC9E,+EAA+E;AAC/E,MAAM,OAAO,GAAG,wBAAS,CAAC,iBAAiB,EAAE,CAAC;AAC9C,MAAM,WAAW,GAAG,IAAA,qCAAsB,EAAC;IACzC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IACpC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE;QACxB,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAChC,CAAC;IACD,kBAAkB,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,kBAAkB,CAAC,KAAK,CAAC;CACvE,CAAC,CAAC;AAEU,QAAA,iBAAiB,GAAG,WAAW,CAAC,iBAAiB,CAAC;AAClD,QAAA,iBAAiB,GAAG,WAAW,CAAC,iBAAiB,CAAC;AAC/D,+CAA0D;AAAjD,wHAAA,wBAAwB,OAAA"}
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SyscoinTransactions = void 0;
4
- const hardware_psbt_1 = require("./hardware-psbt");
5
- const syscoin_core_1 = require("./syscoin-core");
6
- /** Legacy constructor: preserve device arguments while composing shared logic. */
7
- class SyscoinTransactions extends syscoin_core_1.SyscoinTransactionsCore {
8
- constructor(getSyscoinSigner, getReadOnlySigner, getState, getAddress, ledgerSigner, trezorSigner, captureSigningContext) {
9
- super(getSyscoinSigner, getReadOnlySigner, getState, getAddress, {
10
- ledger: ledgerSigner ? (0, hardware_psbt_1.createLedgerPsbtSigner)(ledgerSigner) : undefined,
11
- trezor: trezorSigner ? (0, hardware_psbt_1.createTrezorPsbtSigner)(trezorSigner) : undefined,
12
- }, captureSigningContext);
13
- }
14
- }
15
- exports.SyscoinTransactions = SyscoinTransactions;
16
- //# sourceMappingURL=syscoin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"syscoin.js","sourceRoot":"","sources":["../../../src/transactions/syscoin.ts"],"names":[],"mappings":";;;AAAA,mDAGyB;AACzB,iDAAyD;AAOzD,kFAAkF;AAClF,MAAa,mBAAoB,SAAQ,sCAAuB;IAC9D,YACE,gBAAkC,EAClC,iBAAmC,EACnC,QAA0B,EAC1B,UAA4B,EAC5B,YAA2B,EAC3B,YAA2B,EAC3B,qBAAwC;QAExC,KAAK,CACH,gBAAgB,EAChB,iBAAiB,EACjB,QAAQ,EACR,UAAU,EACV;YACE,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,IAAA,sCAAsB,EAAC,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS;YACvE,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,IAAA,sCAAsB,EAAC,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS;SACxE,EACD,qBAAqB,CACtB,CAAC;IACJ,CAAC;CACF;AAtBD,kDAsBC"}