@sidhujag/sysweb3-keyring 1.0.491

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 (104) hide show
  1. package/README.md +201 -0
  2. package/cjs/errorUtils.js +75 -0
  3. package/cjs/errorUtils.js.map +1 -0
  4. package/cjs/hardware-wallet-manager.js +462 -0
  5. package/cjs/hardware-wallet-manager.js.map +1 -0
  6. package/cjs/index.js +31 -0
  7. package/cjs/index.js.map +1 -0
  8. package/cjs/initial-state.js +105 -0
  9. package/cjs/initial-state.js.map +1 -0
  10. package/cjs/keyring-manager.js +1687 -0
  11. package/cjs/keyring-manager.js.map +1 -0
  12. package/cjs/ledger/bitcoin_client/index.js +47 -0
  13. package/cjs/ledger/bitcoin_client/index.js.map +1 -0
  14. package/cjs/ledger/bitcoin_client/lib/appClient.js +408 -0
  15. package/cjs/ledger/bitcoin_client/lib/appClient.js.map +1 -0
  16. package/cjs/ledger/bitcoin_client/lib/bip32.js +61 -0
  17. package/cjs/ledger/bitcoin_client/lib/bip32.js.map +1 -0
  18. package/cjs/ledger/bitcoin_client/lib/buffertools.js +126 -0
  19. package/cjs/ledger/bitcoin_client/lib/buffertools.js.map +1 -0
  20. package/cjs/ledger/bitcoin_client/lib/clientCommands.js +270 -0
  21. package/cjs/ledger/bitcoin_client/lib/clientCommands.js.map +1 -0
  22. package/cjs/ledger/bitcoin_client/lib/constants.js +16 -0
  23. package/cjs/ledger/bitcoin_client/lib/constants.js.map +1 -0
  24. package/cjs/ledger/bitcoin_client/lib/merkelizedPsbt.js +54 -0
  25. package/cjs/ledger/bitcoin_client/lib/merkelizedPsbt.js.map +1 -0
  26. package/cjs/ledger/bitcoin_client/lib/merkle.js +109 -0
  27. package/cjs/ledger/bitcoin_client/lib/merkle.js.map +1 -0
  28. package/cjs/ledger/bitcoin_client/lib/merkleMap.js +46 -0
  29. package/cjs/ledger/bitcoin_client/lib/merkleMap.js.map +1 -0
  30. package/cjs/ledger/bitcoin_client/lib/policy.js +66 -0
  31. package/cjs/ledger/bitcoin_client/lib/policy.js.map +1 -0
  32. package/cjs/ledger/bitcoin_client/lib/psbtv2.js +640 -0
  33. package/cjs/ledger/bitcoin_client/lib/psbtv2.js.map +1 -0
  34. package/cjs/ledger/bitcoin_client/lib/varint.js +113 -0
  35. package/cjs/ledger/bitcoin_client/lib/varint.js.map +1 -0
  36. package/cjs/ledger/consts.js +7 -0
  37. package/cjs/ledger/consts.js.map +1 -0
  38. package/cjs/ledger/index.js +319 -0
  39. package/cjs/ledger/index.js.map +1 -0
  40. package/cjs/ledger/types.js +3 -0
  41. package/cjs/ledger/types.js.map +1 -0
  42. package/cjs/network-utils.js +76 -0
  43. package/cjs/network-utils.js.map +1 -0
  44. package/cjs/providers.js +270 -0
  45. package/cjs/providers.js.map +1 -0
  46. package/cjs/signers.js +64 -0
  47. package/cjs/signers.js.map +1 -0
  48. package/cjs/storage.js +30 -0
  49. package/cjs/storage.js.map +1 -0
  50. package/cjs/transactions/__tests__/integration.test.js +237 -0
  51. package/cjs/transactions/__tests__/integration.test.js.map +1 -0
  52. package/cjs/transactions/__tests__/syscoin.test.js +361 -0
  53. package/cjs/transactions/__tests__/syscoin.test.js.map +1 -0
  54. package/cjs/transactions/ethereum.js +1577 -0
  55. package/cjs/transactions/ethereum.js.map +1 -0
  56. package/cjs/transactions/index.js +19 -0
  57. package/cjs/transactions/index.js.map +1 -0
  58. package/cjs/transactions/syscoin.js +328 -0
  59. package/cjs/transactions/syscoin.js.map +1 -0
  60. package/cjs/trezor/index.js +718 -0
  61. package/cjs/trezor/index.js.map +1 -0
  62. package/cjs/types.js +12 -0
  63. package/cjs/types.js.map +1 -0
  64. package/cjs/utils/derivation-paths.js +99 -0
  65. package/cjs/utils/derivation-paths.js.map +1 -0
  66. package/cjs/utils/psbt.js +60 -0
  67. package/cjs/utils/psbt.js.map +1 -0
  68. package/cjs/utils.js +130 -0
  69. package/cjs/utils.js.map +1 -0
  70. package/package.json +46 -0
  71. package/types/errorUtils.d.ts +1 -0
  72. package/types/hardware-wallet-manager.d.ts +110 -0
  73. package/types/index.d.ts +12 -0
  74. package/types/initial-state.d.ts +79 -0
  75. package/types/keyring-manager.d.ts +184 -0
  76. package/types/ledger/bitcoin_client/index.d.ts +5 -0
  77. package/types/ledger/bitcoin_client/lib/appClient.d.ts +106 -0
  78. package/types/ledger/bitcoin_client/lib/bip32.d.ts +11 -0
  79. package/types/ledger/bitcoin_client/lib/buffertools.d.ts +28 -0
  80. package/types/ledger/bitcoin_client/lib/clientCommands.d.ts +77 -0
  81. package/types/ledger/bitcoin_client/lib/constants.d.ts +12 -0
  82. package/types/ledger/bitcoin_client/lib/merkelizedPsbt.d.ts +24 -0
  83. package/types/ledger/bitcoin_client/lib/merkle.d.ts +32 -0
  84. package/types/ledger/bitcoin_client/lib/merkleMap.d.ts +23 -0
  85. package/types/ledger/bitcoin_client/lib/policy.d.ts +36 -0
  86. package/types/ledger/bitcoin_client/lib/psbtv2.d.ts +167 -0
  87. package/types/ledger/bitcoin_client/lib/varint.d.ts +23 -0
  88. package/types/ledger/consts.d.ts +3 -0
  89. package/types/ledger/index.d.ts +51 -0
  90. package/types/ledger/types.d.ts +48 -0
  91. package/types/network-utils.d.ts +14 -0
  92. package/types/providers.d.ts +47 -0
  93. package/types/signers.d.ts +95 -0
  94. package/types/storage.d.ts +2 -0
  95. package/types/transactions/__tests__/integration.test.d.ts +1 -0
  96. package/types/transactions/__tests__/syscoin.test.d.ts +1 -0
  97. package/types/transactions/ethereum.d.ts +80 -0
  98. package/types/transactions/index.d.ts +2 -0
  99. package/types/transactions/syscoin.d.ts +61 -0
  100. package/types/trezor/index.d.ts +170 -0
  101. package/types/types.d.ts +294 -0
  102. package/types/utils/derivation-paths.d.ts +35 -0
  103. package/types/utils/psbt.d.ts +17 -0
  104. package/types/utils.d.ts +4 -0
@@ -0,0 +1,167 @@
1
+ import * as bjs from 'bitcoinjs-lib';
2
+ export declare enum psbtGlobal {
3
+ UNSIGNED_TX = 0,
4
+ XPUB = 1,
5
+ TX_VERSION = 2,
6
+ FALLBACK_LOCKTIME = 3,
7
+ INPUT_COUNT = 4,
8
+ OUTPUT_COUNT = 5,
9
+ TX_MODIFIABLE = 6,
10
+ VERSION = 251
11
+ }
12
+ export declare enum psbtIn {
13
+ NON_WITNESS_UTXO = 0,
14
+ WITNESS_UTXO = 1,
15
+ PARTIAL_SIG = 2,
16
+ SIGHASH_TYPE = 3,
17
+ REDEEM_SCRIPT = 4,
18
+ WITNESS_SCRIPT = 5,
19
+ BIP32_DERIVATION = 6,
20
+ FINAL_SCRIPTSIG = 7,
21
+ FINAL_SCRIPTWITNESS = 8,
22
+ PREVIOUS_TXID = 14,
23
+ OUTPUT_INDEX = 15,
24
+ SEQUENCE = 16,
25
+ TAP_KEY_SIG = 19,
26
+ TAP_BIP32_DERIVATION = 22
27
+ }
28
+ export declare enum psbtOut {
29
+ REDEEM_SCRIPT = 0,
30
+ WITNESS_SCRIPT = 1,
31
+ BIP_32_DERIVATION = 2,
32
+ AMOUNT = 3,
33
+ SCRIPT = 4,
34
+ TAP_BIP32_DERIVATION = 7
35
+ }
36
+ export declare class NoSuchEntry extends Error {
37
+ }
38
+ /**
39
+ * Implements Partially Signed Bitcoin Transaction version 2, BIP370, as
40
+ * documented at https://github.com/bitcoin/bips/blob/master/bip-0370.mediawiki
41
+ * and https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki
42
+ *
43
+ * A psbt is a data structure that can carry all relevant information about a
44
+ * transaction through all stages of the signing process. From constructing an
45
+ * unsigned transaction to extracting the final serialized transaction ready for
46
+ * broadcast.
47
+ *
48
+ * This implementation is limited to what's needed in ledgerjs to carry out its
49
+ * duties, which means that support for features like multisig or taproot script
50
+ * path spending are not implemented. Specifically, it supports p2pkh,
51
+ * p2wpkhWrappedInP2sh, p2wpkh and p2tr key path spending.
52
+ *
53
+ * This class is made purposefully dumb, so it's easy to add support for
54
+ * complemantary fields as needed in the future.
55
+ */
56
+ export declare class PsbtV2 {
57
+ protected globalMap: Map<string, Buffer>;
58
+ protected inputMaps: Map<string, Buffer>[];
59
+ protected outputMaps: Map<string, Buffer>[];
60
+ setGlobalTxVersion(version: number): void;
61
+ getGlobalTxVersion(): number;
62
+ setGlobalFallbackLocktime(locktime: number): void;
63
+ getGlobalFallbackLocktime(): number | undefined;
64
+ setGlobalInputCount(inputCount: number): void;
65
+ getGlobalInputCount(): number;
66
+ setGlobalOutputCount(outputCount: number): void;
67
+ getGlobalOutputCount(): number;
68
+ setGlobalTxModifiable(byte: Buffer): void;
69
+ getGlobalTxModifiable(): Buffer | undefined;
70
+ setGlobalPsbtVersion(psbtVersion: number): void;
71
+ getGlobalPsbtVersion(): number;
72
+ setInputNonWitnessUtxo(inputIndex: number, transaction: Buffer): void;
73
+ getInputNonWitnessUtxo(inputIndex: number): Buffer | undefined;
74
+ setInputWitnessUtxo(inputIndex: number, amount: number, scriptPubKey: Buffer): void;
75
+ getInputWitnessUtxo(inputIndex: number): {
76
+ readonly amount: number;
77
+ readonly scriptPubKey: Buffer;
78
+ } | undefined;
79
+ setInputPartialSig(inputIndex: number, pubkey: Buffer, signature: Buffer): void;
80
+ getInputPartialSig(inputIndex: number, pubkey: Buffer): Buffer | undefined;
81
+ setInputSighashType(inputIndex: number, sigHashtype: number): void;
82
+ getInputSighashType(inputIndex: number): number | undefined;
83
+ setInputRedeemScript(inputIndex: number, redeemScript: Buffer): void;
84
+ getInputRedeemScript(inputIndex: number): Buffer | undefined;
85
+ setInputWitnessScript(inputIndex: number, witnessScript: Buffer): void;
86
+ getInputWitnessScript(inputIndex: number): Buffer | undefined;
87
+ setInputBip32Derivation(inputIndex: number, pubkey: Buffer, masterFingerprint: Buffer, path: readonly number[]): void;
88
+ getInputBip32Derivation(inputIndex: number, pubkey: Buffer): {
89
+ readonly masterFingerprint: Buffer;
90
+ readonly path: readonly number[];
91
+ } | undefined;
92
+ setInputFinalScriptsig(inputIndex: number, scriptSig: Buffer): void;
93
+ getInputFinalScriptsig(inputIndex: number): Buffer | undefined;
94
+ setInputFinalScriptwitness(inputIndex: number, scriptWitness: Buffer): void;
95
+ getInputFinalScriptwitness(inputIndex: number): Buffer;
96
+ setInputPreviousTxId(inputIndex: number, txid: Buffer): void;
97
+ getInputPreviousTxid(inputIndex: number): Buffer;
98
+ setInputOutputIndex(inputIndex: number, outputIndex: number): void;
99
+ getInputOutputIndex(inputIndex: number): number;
100
+ setInputSequence(inputIndex: number, sequence: number): void;
101
+ getInputSequence(inputIndex: number): number;
102
+ setInputTapKeySig(inputIndex: number, sig: Buffer): void;
103
+ getInputTapKeySig(inputIndex: number): Buffer | undefined;
104
+ setInputTapBip32Derivation(inputIndex: number, pubkey: Buffer, hashes: readonly Buffer[], masterFingerprint: Buffer, path: readonly number[]): void;
105
+ getInputTapBip32Derivation(inputIndex: number, pubkey: Buffer): {
106
+ readonly hashes: readonly Buffer[];
107
+ readonly masterFingerprint: Buffer;
108
+ readonly path: readonly number[];
109
+ };
110
+ getInputKeyDatas(inputIndex: number, keyType: KeyType): readonly Buffer[];
111
+ setOutputRedeemScript(outputIndex: number, redeemScript: Buffer): void;
112
+ getOutputRedeemScript(outputIndex: number): Buffer;
113
+ setOutputBip32Derivation(outputIndex: number, pubkey: Buffer, masterFingerprint: Buffer, path: readonly number[]): void;
114
+ getOutputBip32Derivation(outputIndex: number, pubkey: Buffer): {
115
+ readonly masterFingerprint: Buffer;
116
+ readonly path: readonly number[];
117
+ };
118
+ setOutputAmount(outputIndex: number, amount: number): void;
119
+ getOutputAmount(outputIndex: number): number;
120
+ setOutputScript(outputIndex: number, scriptPubKey: Buffer): void;
121
+ getOutputScript(outputIndex: number): Buffer;
122
+ setOutputTapBip32Derivation(outputIndex: number, pubkey: Buffer, hashes: readonly Buffer[], fingerprint: Buffer, path: readonly number[]): void;
123
+ getOutputTapBip32Derivation(outputIndex: number, pubkey: Buffer): {
124
+ readonly hashes: readonly Buffer[];
125
+ readonly masterFingerprint: Buffer;
126
+ readonly path: readonly number[];
127
+ };
128
+ deleteInputEntries(inputIndex: number, keyTypes: readonly psbtIn[]): void;
129
+ copy(to: PsbtV2): void;
130
+ copyMaps(from: readonly ReadonlyMap<string, Buffer>[], to: Map<string, Buffer>[]): void;
131
+ copyMap(from: ReadonlyMap<string, Buffer>, to: Map<string, Buffer>): void;
132
+ serialize(): Buffer;
133
+ deserialize(psbt: Buffer): void;
134
+ normalizeToV2(): void;
135
+ /**
136
+ * Imports a BitcoinJS (bitcoinjs-lib) Psbt object.
137
+ * https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/ts_src/psbt.ts
138
+ *
139
+ * Prepares the fields required for signing a Psbt on a Ledger
140
+ * device. It should be used exclusively before calling
141
+ * `appClient.signPsbt()` and not as a general Psbt conversion method.
142
+ *
143
+ * Note: This method supports all the policies that the Ledger is able to
144
+ * sign, with the exception of taproot: tr(@0).
145
+ */
146
+ fromBitcoinJS(psbtBJS: bjs.Psbt): PsbtV2;
147
+ private readKeyPair;
148
+ private getKeyDatas;
149
+ private isKeyType;
150
+ private setGlobal;
151
+ private getGlobal;
152
+ private getGlobalOptional;
153
+ private setInput;
154
+ private getInput;
155
+ private getInputOptional;
156
+ private setOutput;
157
+ private getOutput;
158
+ private getMap;
159
+ private encodeBip32Derivation;
160
+ private decodeBip32Derivation;
161
+ private writeBip32Derivation;
162
+ private readBip32Derivation;
163
+ private encodeTapBip32Derivation;
164
+ private decodeTapBip32Derivation;
165
+ }
166
+ type KeyType = number;
167
+ export {};
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Converts a `bigint` to a `number` if it non-negative and at most MAX_SAFE_INTEGER; throws `RangeError` otherwise.
3
+ * Used when converting a Bitcoin-style varint to a `number`, since varints could be larger than what the `Number`
4
+ * class can represent without loss of precision.
5
+ *
6
+ * @param n the number to convert
7
+ * @returns `n` as a `number`
8
+ */
9
+ export declare function sanitizeBigintToNumber(n: number | bigint): number;
10
+ /**
11
+ * Parses a Bitcoin-style variable length integer from a buffer, starting at the given `offset`. Returns a pair
12
+ * containing the parsed `BigInt`, and its length in bytes from the buffer.
13
+ *
14
+ * @param data the `Buffer` from which the variable-length integer is read
15
+ * @param offset a non-negative offset to read from
16
+ * @returns a pair where the first element is the parsed BigInt, and the second element is the length in bytes parsed
17
+ * from the buffer.
18
+ *
19
+ * @throws `RangeError` if offset is negative.
20
+ * @throws `Error` if the buffer's end is reached withut parsing being completed.
21
+ */
22
+ export declare function parseVarint(data: Buffer, offset: number): readonly [bigint, number];
23
+ export declare function createVarint(value: number | bigint): Buffer;
@@ -0,0 +1,3 @@
1
+ export declare const DESCRIPTOR = "wpkh(@0/**)";
2
+ export declare const RECEIVING_ADDRESS_INDEX = 0;
3
+ export declare const WILL_NOT_DISPLAY = false;
@@ -0,0 +1,51 @@
1
+ import Transport from '@ledgerhq/hw-transport';
2
+ import SysUtxoClient from './bitcoin_client';
3
+ import { IEvmMethods, IUTXOMethods } from './types';
4
+ import LedgerEthClient from '@ledgerhq/hw-app-eth';
5
+ export declare class LedgerKeyring {
6
+ ledgerEVMClient: LedgerEthClient;
7
+ ledgerUtxoClient: SysUtxoClient;
8
+ private hdPath;
9
+ evm: IEvmMethods;
10
+ utxo: IUTXOMethods;
11
+ transport: Transport | null;
12
+ private hardwareWalletManager;
13
+ constructor();
14
+ /**
15
+ * Ensure Ledger is connected with automatic retry
16
+ * Note: This is automatically called by all operations through executeWithRetry
17
+ * External callers don't need to call this directly
18
+ */
19
+ ensureConnection(): Promise<void>;
20
+ private getUtxoAddress;
21
+ verifyUtxoAddress: (accountIndex: number, currency: string, slip44: number) => Promise<string>;
22
+ private getXpub;
23
+ /**
24
+ * Sign a UTXO message - public method used by transaction classes
25
+ */
26
+ signUtxoMessage: (path: string, message: string) => Promise<string>;
27
+ private signEVMTransaction;
28
+ private signPersonalMessage;
29
+ private sanitizeData;
30
+ private transformTypedData;
31
+ private getEvmAddressAndPubKey;
32
+ private signTypedData;
33
+ private getMasterFingerprint;
34
+ private setHdPath;
35
+ /**
36
+ * Convert PSBT to Ledger format with retry logic
37
+ */
38
+ convertToLedgerFormat(psbt: any, accountXpub: string, accountId: number, currency: string, slip44: number): Promise<any>;
39
+ /**
40
+ * Execute operation with automatic retry
41
+ */
42
+ private executeWithRetry;
43
+ /**
44
+ * Get hardware wallet status
45
+ */
46
+ getStatus(): import("../hardware-wallet-manager").HardwareWalletStatus | undefined;
47
+ /**
48
+ * Clean up resources
49
+ */
50
+ destroy(): Promise<void>;
51
+ }
@@ -0,0 +1,48 @@
1
+ import { Version } from 'eth-sig-util';
2
+ export interface IUTXOMethods {
3
+ getUtxoAddress: ({ coin, index, slip44, }: {
4
+ coin: string;
5
+ index: number;
6
+ slip44: number;
7
+ }) => Promise<string>;
8
+ getXpub: ({ index, coin, slip44, }: {
9
+ coin: string;
10
+ index: number;
11
+ slip44: number;
12
+ }) => Promise<string>;
13
+ verifyUtxoAddress: (accountIndex: number, currency: string, slip44: number) => Promise<string>;
14
+ }
15
+ interface MessageTypeProperty {
16
+ name: string;
17
+ type: string;
18
+ }
19
+ export interface MessageTypes {
20
+ [additionalProperties: string]: MessageTypeProperty[];
21
+ EIP712Domain: MessageTypeProperty[];
22
+ }
23
+ export interface IEvmMethods {
24
+ getEvmAddressAndPubKey: ({ accountIndex, }: {
25
+ accountIndex: number;
26
+ }) => Promise<{
27
+ address: string;
28
+ publicKey: string;
29
+ }>;
30
+ signEVMTransaction: ({ rawTx, accountIndex, }: {
31
+ accountIndex: number;
32
+ rawTx: string;
33
+ }) => Promise<{
34
+ r: string;
35
+ s: string;
36
+ v: string;
37
+ }>;
38
+ signPersonalMessage: ({ message, accountIndex, }: {
39
+ accountIndex: number;
40
+ message: string;
41
+ }) => Promise<string>;
42
+ signTypedData: ({ version, data, accountIndex, }: {
43
+ accountIndex: number;
44
+ data: any;
45
+ version: Version;
46
+ }) => Promise<string>;
47
+ }
48
+ export {};
@@ -0,0 +1,14 @@
1
+ import { INetwork } from '@sidhujag/sysweb3-network';
2
+ /**
3
+ * Generate default UTXO networks from coins.ts data
4
+ * This ensures consistency and avoids hardcoded duplicates
5
+ */
6
+ export declare function getDefaultUTXONetworks(): {
7
+ [chainId: number]: INetwork;
8
+ };
9
+ /**
10
+ * Get specific default UTXO networks for backwards compatibility
11
+ */
12
+ export declare function getSyscoinUTXOMainnetNetwork(): INetwork;
13
+ export declare function getSyscoinUTXOTestnetNetwork(): INetwork;
14
+ export declare function getBitcoinMainnetNetwork(): INetwork;
@@ -0,0 +1,47 @@
1
+ import { Networkish } from '@ethersproject/networks';
2
+ import { ethers } from 'ethers';
3
+ import { ConnectionInfo } from 'ethers/lib/utils';
4
+ import { Provider } from 'zksync-ethers';
5
+ declare class BaseProvider extends ethers.providers.JsonRpcProvider {
6
+ private isPossibleGetChainId;
7
+ private cooldownTime;
8
+ private rateLimit;
9
+ private requestCount;
10
+ private lastRequestTime;
11
+ private currentChainId;
12
+ private currentId;
13
+ isInCooldown: boolean;
14
+ errorMessage: any;
15
+ serverHasAnError: boolean;
16
+ signal: AbortSignal;
17
+ _pendingBatchAggregator: NodeJS.Timer | null;
18
+ _pendingBatch: Array<{
19
+ reject: (error: Error) => void;
20
+ request: {
21
+ id: number;
22
+ jsonrpc: '2.0';
23
+ method: string;
24
+ params: Array<any>;
25
+ };
26
+ resolve: (result: any) => void;
27
+ }> | null;
28
+ constructor(signal: AbortSignal, url?: ConnectionInfo | string, network?: Networkish);
29
+ private bindMethods;
30
+ private throttledRequest;
31
+ private canMakeRequest;
32
+ private cooldown;
33
+ perform(method: string, params: any): Promise<any>;
34
+ send: (method: string, params: any[]) => Promise<any>;
35
+ sendBatch(method: string, params: Array<any[]>): Promise<any[]>;
36
+ }
37
+ export declare class CustomJsonRpcProvider extends BaseProvider {
38
+ constructor(signal: AbortSignal, url?: ConnectionInfo | string, network?: Networkish);
39
+ }
40
+ export declare class CustomL2JsonRpcProvider extends Provider {
41
+ private baseProvider;
42
+ constructor(signal: AbortSignal, url?: ConnectionInfo | string, network?: ethers.providers.Networkish);
43
+ perform(method: string, params: any): Promise<any>;
44
+ send(method: string, params: any[]): Promise<any>;
45
+ sendBatch(method: string, params: Array<any[]>): Promise<any[]>;
46
+ }
47
+ export {};
@@ -0,0 +1,95 @@
1
+ import { BitcoinNetwork, IPubTypes, INetwork } from '@sidhujag/sysweb3-network';
2
+ import { BIP32Interface } from 'bip32';
3
+ import { Psbt } from 'bitcoinjs-lib';
4
+ export declare const getSyscoinSigners: ({ mnemonic, rpc, }: ISyscoinSignerParams) => {
5
+ hd: SyscoinHDSigner;
6
+ main: any;
7
+ };
8
+ export type SyscoinHdAccount = {
9
+ network: BitcoinNetwork;
10
+ networks: {
11
+ mainnet: BitcoinNetwork;
12
+ testnet: BitcoinNetwork;
13
+ };
14
+ pubTypes: IPubTypes;
15
+ zprv: string;
16
+ };
17
+ export type ISyscoinSignerParams = {
18
+ mnemonic: string;
19
+ rpc: {
20
+ formattedNetwork: INetwork;
21
+ networkConfig?: {
22
+ networks: {
23
+ mainnet: BitcoinNetwork;
24
+ testnet: BitcoinNetwork;
25
+ };
26
+ types: {
27
+ xPubType: IPubTypes;
28
+ zPubType: IPubTypes;
29
+ };
30
+ };
31
+ };
32
+ };
33
+ export type IMainSignerParams = {
34
+ hd: SyscoinHDSigner;
35
+ network?: BitcoinNetwork;
36
+ url: string;
37
+ };
38
+ export interface SyscoinHDSigner {
39
+ Signer: {
40
+ SLIP44: number;
41
+ accountIndex: number;
42
+ accounts: any;
43
+ blockbookURL: string;
44
+ changeIndex: number;
45
+ network: BitcoinNetwork;
46
+ networks: {
47
+ mainnet: BitcoinNetwork;
48
+ testnet: BitcoinNetwork;
49
+ };
50
+ password: string | null;
51
+ pubTypes: IPubTypes;
52
+ receivingIndex: number;
53
+ setIndexFlag: number;
54
+ };
55
+ backup: () => void;
56
+ blockbookURL: string;
57
+ createAccount: (bipNum?: number, zprv?: string) => number;
58
+ createAccountAtIndex: (index: number, bipNum?: number, zprv?: string) => number;
59
+ createAddress: (addressIndex: number, isChange: boolean, bipNum?: number) => string;
60
+ createKeypair: (addressIndex: number, isChange: boolean) => BIP32Interface;
61
+ deriveAccount: (index: number, bipNum?: number) => string;
62
+ deriveKeypair: (keypath: string) => BIP32Interface;
63
+ derivePubKey: (keypath: string) => string;
64
+ getAccountXpub: () => string;
65
+ getAddressFromKeypair: (keypair: BIP32Interface) => string;
66
+ getAddressFromPubKey: (pubkey: string) => string;
67
+ getHDPath: (addressIndex: number, isChange: boolean, bipNum?: number) => string;
68
+ getNewReceivingAddress: (skipIncrement?: boolean, bipNum?: number) => Promise<string>;
69
+ node: {
70
+ seed: Buffer;
71
+ coinType: number;
72
+ pubTypes: IPubTypes;
73
+ network: BitcoinNetwork;
74
+ };
75
+ setAccountIndex: (accountIndex: number) => void;
76
+ getRootNode: () => BIP32Interface;
77
+ importMethod: string;
78
+ signPSBT: ({ psbt, isTrezor, isLedger, pathIn, }: {
79
+ psbt: any;
80
+ isTrezor?: boolean;
81
+ isLedger?: boolean;
82
+ pathIn?: string;
83
+ }) => Promise<any>;
84
+ getNewChangeAddress: (skipIncrement?: boolean, bipNum?: number) => Promise<string>;
85
+ restore: (password: string, bipNum?: number) => boolean;
86
+ mnemonicOrZprv: string;
87
+ setLatestIndexesFromXPubTokens: (tokens: any) => void;
88
+ sign: (psbt: Psbt, pathIn?: string) => Promise<Psbt>;
89
+ getMasterFingerprint: () => Buffer;
90
+ }
91
+ export type SyscoinMainSigner = {
92
+ Signer: SyscoinHDSigner;
93
+ blockbookURL: string;
94
+ network: BitcoinNetwork;
95
+ };
@@ -0,0 +1,2 @@
1
+ export declare const setEncryptedVault: (decryptedVault: any, pwd: string) => Promise<void>;
2
+ export declare const getDecryptedVault: (pwd: string) => Promise<any>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,80 @@
1
+ import { TransactionResponse } from '@ethersproject/abstract-provider';
2
+ import { INetwork } from '@sidhujag/sysweb3-network';
3
+ import { TypedMessage, Version, TypedData } from 'eth-sig-util';
4
+ import { BigNumber, ethers } from 'ethers';
5
+ import { LedgerKeyring } from '../ledger';
6
+ import { CustomJsonRpcProvider, CustomL2JsonRpcProvider } from '../providers';
7
+ import { TrezorKeyring } from '../trezor';
8
+ import { IResponseFromSendErcSignedTransaction, ISendSignedErcTransactionProps, ISendTransaction, IEthereumTransactions, SimpleTransactionRequest, KeyringAccountType, accountType, IGasParams } from '../types';
9
+ export declare class EthereumTransactions implements IEthereumTransactions {
10
+ private _web3Provider;
11
+ trezorSigner: TrezorKeyring;
12
+ ledgerSigner: LedgerKeyring;
13
+ private getNetwork;
14
+ private abortController;
15
+ private getDecryptedPrivateKey;
16
+ private getState;
17
+ constructor(getNetwork: () => INetwork, getDecryptedPrivateKey: () => {
18
+ address: string;
19
+ decryptedPrivateKey: string;
20
+ }, getState: () => {
21
+ accounts: {
22
+ HDAccount: accountType;
23
+ Imported: accountType;
24
+ Ledger: accountType;
25
+ Trezor: accountType;
26
+ };
27
+ activeAccountId: number;
28
+ activeAccountType: KeyringAccountType;
29
+ activeNetwork: INetwork;
30
+ }, ledgerSigner: LedgerKeyring, trezorSigner: TrezorKeyring);
31
+ get web3Provider(): CustomJsonRpcProvider | CustomL2JsonRpcProvider;
32
+ private ensureProvidersInitialized;
33
+ private isUtxoNetwork;
34
+ signTypedData: (addr: string, typedData: TypedData | TypedMessage<any>, version: Version) => Promise<any>;
35
+ verifyTypedSignature: (data: TypedData | TypedMessage<any>, signature: string, version: Version) => string;
36
+ ethSign: (params: string[]) => Promise<string>;
37
+ signPersonalMessage: (params: string[]) => Promise<string>;
38
+ parsePersonalMessage: (hexMsg: string) => string;
39
+ verifyPersonalMessage: (message: string, sign: string) => string;
40
+ getEncryptedPubKey: () => string;
41
+ decryptMessage: (msgParams: string[]) => string;
42
+ toBigNumber: (aBigNumberish: string | number) => BigNumber;
43
+ getData: ({ contractAddress, receivingAddress, value, }: {
44
+ contractAddress: string;
45
+ receivingAddress: string;
46
+ value: any;
47
+ }) => any;
48
+ getFeeDataWithDynamicMaxPriorityFeePerGas: () => Promise<{
49
+ maxFeePerGas: BigNumber;
50
+ maxPriorityFeePerGas: BigNumber;
51
+ }>;
52
+ calculateNewGasValues: (oldTxsParams: IGasParams, isForCancel: boolean, isLegacy: boolean) => IGasParams;
53
+ cancelSentTransaction: (txHash: string, isLegacy?: boolean) => Promise<{
54
+ error?: boolean;
55
+ isCanceled: boolean;
56
+ transaction?: TransactionResponse;
57
+ }>;
58
+ sendFormattedTransaction: (params: SimpleTransactionRequest, isLegacy?: boolean) => Promise<TransactionResponse>;
59
+ sendTransactionWithEditedFee: (txHash: string, isLegacy?: boolean) => Promise<{
60
+ error?: boolean;
61
+ isSpeedUp: boolean;
62
+ transaction?: TransactionResponse;
63
+ }>;
64
+ sendTransaction: ({ sender, receivingAddress, amount, gasLimit, token, }: ISendTransaction) => Promise<TransactionResponse>;
65
+ sendSignedErc20Transaction: ({ receiver, tokenAddress, tokenAmount, isLegacy, maxPriorityFeePerGas, maxFeePerGas, gasPrice, decimals, gasLimit, saveTrezorTx, }: ISendSignedErcTransactionProps) => Promise<IResponseFromSendErcSignedTransaction>;
66
+ sendSignedErc721Transaction: ({ receiver, tokenAddress, tokenId, isLegacy, maxPriorityFeePerGas, maxFeePerGas, gasPrice, gasLimit, }: ISendSignedErcTransactionProps) => Promise<IResponseFromSendErcSignedTransaction>;
67
+ sendSignedErc1155Transaction: ({ receiver, tokenAddress, tokenId, tokenAmount, isLegacy, maxPriorityFeePerGas, maxFeePerGas, gasPrice, gasLimit, }: ISendSignedErcTransactionProps) => Promise<IResponseFromSendErcSignedTransaction>;
68
+ getRecommendedNonce: (address: string) => Promise<number>;
69
+ getFeeByType: (type: string) => Promise<string>;
70
+ getGasLimit: (toAddress: string) => Promise<number>;
71
+ getTxGasLimit: (tx: SimpleTransactionRequest) => Promise<BigNumber>;
72
+ getRecommendedGasPrice: (formatted?: boolean) => Promise<string | {
73
+ gwei: string;
74
+ ethers: string;
75
+ }>;
76
+ getBalance: (address: string) => Promise<number>;
77
+ private getTransactionTimestamp;
78
+ setWeb3Provider(network: INetwork): void;
79
+ importAccount: (mnemonicOrPrivKey: string) => ethers.Wallet;
80
+ }
@@ -0,0 +1,2 @@
1
+ export * from './ethereum';
2
+ export * from './syscoin';
@@ -0,0 +1,61 @@
1
+ import { INetwork } from '@sidhujag/sysweb3-network';
2
+ import { ITxid } from '@sidhujag/sysweb3-utils';
3
+ import { LedgerKeyring } from '../ledger';
4
+ import { SyscoinHDSigner } from '../signers';
5
+ import { TrezorKeyring } from '../trezor';
6
+ import { ISyscoinTransactions, KeyringAccountType, accountType } from '../types';
7
+ export declare class SyscoinTransactions implements ISyscoinTransactions {
8
+ private getSigner;
9
+ private getReadOnlySigner;
10
+ private trezor;
11
+ private ledger;
12
+ private getState;
13
+ private getAddress;
14
+ constructor(getSyscoinSigner: () => {
15
+ hd: SyscoinHDSigner;
16
+ main: any;
17
+ }, getReadOnlySigner: () => {
18
+ main: any;
19
+ }, getState: () => {
20
+ accounts: {
21
+ HDAccount: accountType;
22
+ Imported: accountType;
23
+ Ledger: accountType;
24
+ Trezor: accountType;
25
+ };
26
+ activeAccountId: number;
27
+ activeAccountType: KeyringAccountType;
28
+ activeNetwork: INetwork;
29
+ }, getAddress: (xpub: string, isChangeAddress: boolean) => Promise<string>, ledgerSigner: LedgerKeyring, trezorSigner: TrezorKeyring);
30
+ private getTransactionPSBT;
31
+ decodeRawTransaction: (psbtOrHex: any, isRawHex?: boolean) => any;
32
+ getRecommendedFee: (explorerUrl: string) => Promise<number>;
33
+ txUtilsFunctions: () => {
34
+ getRawTransaction: (explorerUrl: string, txid: string) => any;
35
+ };
36
+ private signPSBTWithSigner;
37
+ private createUnsignedPSBT;
38
+ private signPSBTWithMethod;
39
+ getEstimateSysTransactionFee: ({ txOptions, isMax, amount, receivingAddress, feeRate, token, }: {
40
+ amount: number;
41
+ feeRate?: number;
42
+ receivingAddress: string;
43
+ token?: {
44
+ guid: string;
45
+ symbol?: string;
46
+ } | null;
47
+ txOptions?: any;
48
+ isMax?: boolean | false;
49
+ }) => Promise<{
50
+ fee: number;
51
+ psbt: any;
52
+ }>;
53
+ private sendSignedTransaction;
54
+ signPSBT: ({ psbt, isTrezor, isLedger, pathIn, }: {
55
+ psbt: any;
56
+ isTrezor?: boolean;
57
+ isLedger?: boolean;
58
+ pathIn?: string;
59
+ }) => Promise<any>;
60
+ sendTransaction: (psbt: any) => Promise<ITxid>;
61
+ }