@sidhujag/sysweb3-keyring 1.0.547 → 1.0.549

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 (212) hide show
  1. package/{dist/cjs → cjs}/providers.js +1 -64
  2. package/cjs/providers.js.map +1 -0
  3. package/{dist/cjs → cjs}/transactions/ethereum.js +1 -16
  4. package/cjs/transactions/ethereum.js.map +1 -0
  5. package/package.json +2 -30
  6. package/{dist/types → types}/providers.d.ts +0 -8
  7. package/{dist/types → types}/transactions/ethereum.d.ts +2 -2
  8. package/{dist/types → types}/types.d.ts +2 -2
  9. package/coverage/clover.xml +0 -2875
  10. package/coverage/coverage-final.json +0 -29468
  11. package/coverage/lcov-report/base.css +0 -354
  12. package/coverage/lcov-report/block-navigation.js +0 -85
  13. package/coverage/lcov-report/favicon.png +0 -0
  14. package/coverage/lcov-report/index.html +0 -320
  15. package/coverage/lcov-report/prettify.css +0 -101
  16. package/coverage/lcov-report/prettify.js +0 -1008
  17. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  18. package/coverage/lcov-report/sorter.js +0 -191
  19. package/coverage/lcov-report/src/index.html +0 -276
  20. package/coverage/lcov-report/src/index.ts.html +0 -114
  21. package/coverage/lcov-report/src/initial-state.ts.html +0 -558
  22. package/coverage/lcov-report/src/keyring-manager.ts.html +0 -6279
  23. package/coverage/lcov-report/src/ledger/bitcoin_client/index.html +0 -178
  24. package/coverage/lcov-report/src/ledger/bitcoin_client/index.ts.html +0 -144
  25. package/coverage/lcov-report/src/ledger/bitcoin_client/lib/appClient.ts.html +0 -1560
  26. package/coverage/lcov-report/src/ledger/bitcoin_client/lib/bip32.ts.html +0 -276
  27. package/coverage/lcov-report/src/ledger/bitcoin_client/lib/buffertools.ts.html +0 -495
  28. package/coverage/lcov-report/src/ledger/bitcoin_client/lib/clientCommands.ts.html +0 -1138
  29. package/coverage/lcov-report/src/ledger/bitcoin_client/lib/index.html +0 -363
  30. package/coverage/lcov-report/src/ledger/bitcoin_client/lib/merkelizedPsbt.ts.html +0 -289
  31. package/coverage/lcov-report/src/ledger/bitcoin_client/lib/merkle.ts.html +0 -486
  32. package/coverage/lcov-report/src/ledger/bitcoin_client/lib/merkleMap.ts.html +0 -240
  33. package/coverage/lcov-report/src/ledger/bitcoin_client/lib/policy.ts.html +0 -342
  34. package/coverage/lcov-report/src/ledger/bitcoin_client/lib/psbtv2.ts.html +0 -2388
  35. package/coverage/lcov-report/src/ledger/bitcoin_client/lib/varint.ts.html +0 -453
  36. package/coverage/lcov-report/src/ledger/consts.ts.html +0 -177
  37. package/coverage/lcov-report/src/ledger/index.html +0 -216
  38. package/coverage/lcov-report/src/ledger/index.ts.html +0 -1371
  39. package/coverage/lcov-report/src/ledger/utils.ts.html +0 -102
  40. package/coverage/lcov-report/src/signers.ts.html +0 -591
  41. package/coverage/lcov-report/src/storage.ts.html +0 -198
  42. package/coverage/lcov-report/src/transactions/ethereum.ts.html +0 -5826
  43. package/coverage/lcov-report/src/transactions/index.html +0 -216
  44. package/coverage/lcov-report/src/transactions/index.ts.html +0 -93
  45. package/coverage/lcov-report/src/transactions/syscoin.ts.html +0 -1521
  46. package/coverage/lcov-report/src/trezor/index.html +0 -176
  47. package/coverage/lcov-report/src/trezor/index.ts.html +0 -2655
  48. package/coverage/lcov-report/src/types.ts.html +0 -1443
  49. package/coverage/lcov-report/src/utils/derivation-paths.ts.html +0 -486
  50. package/coverage/lcov-report/src/utils/index.html +0 -196
  51. package/coverage/lcov-report/src/utils/psbt.ts.html +0 -159
  52. package/coverage/lcov-report/test/helpers/constants.ts.html +0 -627
  53. package/coverage/lcov-report/test/helpers/index.html +0 -176
  54. package/coverage/lcov.info +0 -4832
  55. package/dist/cjs/providers.js.map +0 -1
  56. package/dist/cjs/transactions/ethereum.js.map +0 -1
  57. package/dist/package.json +0 -50
  58. package/examples/basic-usage.js +0 -140
  59. package/jest.config.js +0 -32
  60. package/readme.md +0 -201
  61. package/src/declare.d.ts +0 -7
  62. package/src/errorUtils.ts +0 -83
  63. package/src/hardware-wallet-manager.ts +0 -655
  64. package/src/index.ts +0 -12
  65. package/src/initial-state.ts +0 -108
  66. package/src/keyring-manager.ts +0 -2698
  67. package/src/ledger/bitcoin_client/index.ts +0 -19
  68. package/src/ledger/bitcoin_client/lib/appClient.ts +0 -405
  69. package/src/ledger/bitcoin_client/lib/bip32.ts +0 -61
  70. package/src/ledger/bitcoin_client/lib/buffertools.ts +0 -134
  71. package/src/ledger/bitcoin_client/lib/clientCommands.ts +0 -356
  72. package/src/ledger/bitcoin_client/lib/constants.ts +0 -12
  73. package/src/ledger/bitcoin_client/lib/merkelizedPsbt.ts +0 -65
  74. package/src/ledger/bitcoin_client/lib/merkle.ts +0 -136
  75. package/src/ledger/bitcoin_client/lib/merkleMap.ts +0 -49
  76. package/src/ledger/bitcoin_client/lib/policy.ts +0 -91
  77. package/src/ledger/bitcoin_client/lib/psbtv2.ts +0 -768
  78. package/src/ledger/bitcoin_client/lib/varint.ts +0 -120
  79. package/src/ledger/consts.ts +0 -3
  80. package/src/ledger/index.ts +0 -685
  81. package/src/ledger/types.ts +0 -74
  82. package/src/network-utils.ts +0 -99
  83. package/src/providers.ts +0 -345
  84. package/src/signers.ts +0 -158
  85. package/src/storage.ts +0 -63
  86. package/src/transactions/__tests__/integration.test.ts +0 -303
  87. package/src/transactions/__tests__/syscoin.test.ts +0 -409
  88. package/src/transactions/ethereum.ts +0 -2503
  89. package/src/transactions/index.ts +0 -2
  90. package/src/transactions/syscoin.ts +0 -542
  91. package/src/trezor/index.ts +0 -1050
  92. package/src/types.ts +0 -366
  93. package/src/utils/derivation-paths.ts +0 -133
  94. package/src/utils/psbt.ts +0 -24
  95. package/src/utils.ts +0 -191
  96. package/test/README.md +0 -158
  97. package/test/__mocks__/ledger-mock.js +0 -20
  98. package/test/__mocks__/trezor-mock.js +0 -75
  99. package/test/cleanup-summary.md +0 -167
  100. package/test/helpers/README.md +0 -78
  101. package/test/helpers/constants.ts +0 -79
  102. package/test/helpers/setup.ts +0 -714
  103. package/test/integration/import-validation.spec.ts +0 -588
  104. package/test/unit/hardware/ledger.spec.ts +0 -869
  105. package/test/unit/hardware/trezor.spec.ts +0 -828
  106. package/test/unit/keyring-manager/account-management.spec.ts +0 -970
  107. package/test/unit/keyring-manager/import-watchonly.spec.ts +0 -181
  108. package/test/unit/keyring-manager/import-wif.spec.ts +0 -126
  109. package/test/unit/keyring-manager/initialization.spec.ts +0 -782
  110. package/test/unit/keyring-manager/key-derivation.spec.ts +0 -996
  111. package/test/unit/keyring-manager/security.spec.ts +0 -505
  112. package/test/unit/keyring-manager/state-management.spec.ts +0 -375
  113. package/test/unit/network/network-management.spec.ts +0 -372
  114. package/test/unit/transactions/ethereum-transactions.spec.ts +0 -382
  115. package/test/unit/transactions/syscoin-transactions.spec.ts +0 -615
  116. package/tsconfig.json +0 -14
  117. /package/{dist/README.md → README.md} +0 -0
  118. /package/{dist/cjs → cjs}/errorUtils.js +0 -0
  119. /package/{dist/cjs → cjs}/errorUtils.js.map +0 -0
  120. /package/{dist/cjs → cjs}/hardware-wallet-manager.js +0 -0
  121. /package/{dist/cjs → cjs}/hardware-wallet-manager.js.map +0 -0
  122. /package/{dist/cjs → cjs}/index.js +0 -0
  123. /package/{dist/cjs → cjs}/index.js.map +0 -0
  124. /package/{dist/cjs → cjs}/initial-state.js +0 -0
  125. /package/{dist/cjs → cjs}/initial-state.js.map +0 -0
  126. /package/{dist/cjs → cjs}/keyring-manager.js +0 -0
  127. /package/{dist/cjs → cjs}/keyring-manager.js.map +0 -0
  128. /package/{dist/cjs → cjs}/ledger/bitcoin_client/index.js +0 -0
  129. /package/{dist/cjs → cjs}/ledger/bitcoin_client/index.js.map +0 -0
  130. /package/{dist/cjs → cjs}/ledger/bitcoin_client/lib/appClient.js +0 -0
  131. /package/{dist/cjs → cjs}/ledger/bitcoin_client/lib/appClient.js.map +0 -0
  132. /package/{dist/cjs → cjs}/ledger/bitcoin_client/lib/bip32.js +0 -0
  133. /package/{dist/cjs → cjs}/ledger/bitcoin_client/lib/bip32.js.map +0 -0
  134. /package/{dist/cjs → cjs}/ledger/bitcoin_client/lib/buffertools.js +0 -0
  135. /package/{dist/cjs → cjs}/ledger/bitcoin_client/lib/buffertools.js.map +0 -0
  136. /package/{dist/cjs → cjs}/ledger/bitcoin_client/lib/clientCommands.js +0 -0
  137. /package/{dist/cjs → cjs}/ledger/bitcoin_client/lib/clientCommands.js.map +0 -0
  138. /package/{dist/cjs → cjs}/ledger/bitcoin_client/lib/constants.js +0 -0
  139. /package/{dist/cjs → cjs}/ledger/bitcoin_client/lib/constants.js.map +0 -0
  140. /package/{dist/cjs → cjs}/ledger/bitcoin_client/lib/merkelizedPsbt.js +0 -0
  141. /package/{dist/cjs → cjs}/ledger/bitcoin_client/lib/merkelizedPsbt.js.map +0 -0
  142. /package/{dist/cjs → cjs}/ledger/bitcoin_client/lib/merkle.js +0 -0
  143. /package/{dist/cjs → cjs}/ledger/bitcoin_client/lib/merkle.js.map +0 -0
  144. /package/{dist/cjs → cjs}/ledger/bitcoin_client/lib/merkleMap.js +0 -0
  145. /package/{dist/cjs → cjs}/ledger/bitcoin_client/lib/merkleMap.js.map +0 -0
  146. /package/{dist/cjs → cjs}/ledger/bitcoin_client/lib/policy.js +0 -0
  147. /package/{dist/cjs → cjs}/ledger/bitcoin_client/lib/policy.js.map +0 -0
  148. /package/{dist/cjs → cjs}/ledger/bitcoin_client/lib/psbtv2.js +0 -0
  149. /package/{dist/cjs → cjs}/ledger/bitcoin_client/lib/psbtv2.js.map +0 -0
  150. /package/{dist/cjs → cjs}/ledger/bitcoin_client/lib/varint.js +0 -0
  151. /package/{dist/cjs → cjs}/ledger/bitcoin_client/lib/varint.js.map +0 -0
  152. /package/{dist/cjs → cjs}/ledger/consts.js +0 -0
  153. /package/{dist/cjs → cjs}/ledger/consts.js.map +0 -0
  154. /package/{dist/cjs → cjs}/ledger/index.js +0 -0
  155. /package/{dist/cjs → cjs}/ledger/index.js.map +0 -0
  156. /package/{dist/cjs → cjs}/ledger/types.js +0 -0
  157. /package/{dist/cjs → cjs}/ledger/types.js.map +0 -0
  158. /package/{dist/cjs → cjs}/network-utils.js +0 -0
  159. /package/{dist/cjs → cjs}/network-utils.js.map +0 -0
  160. /package/{dist/cjs → cjs}/signers.js +0 -0
  161. /package/{dist/cjs → cjs}/signers.js.map +0 -0
  162. /package/{dist/cjs → cjs}/storage.js +0 -0
  163. /package/{dist/cjs → cjs}/storage.js.map +0 -0
  164. /package/{dist/cjs → cjs}/transactions/__tests__/integration.test.js +0 -0
  165. /package/{dist/cjs → cjs}/transactions/__tests__/integration.test.js.map +0 -0
  166. /package/{dist/cjs → cjs}/transactions/__tests__/syscoin.test.js +0 -0
  167. /package/{dist/cjs → cjs}/transactions/__tests__/syscoin.test.js.map +0 -0
  168. /package/{dist/cjs → cjs}/transactions/index.js +0 -0
  169. /package/{dist/cjs → cjs}/transactions/index.js.map +0 -0
  170. /package/{dist/cjs → cjs}/transactions/syscoin.js +0 -0
  171. /package/{dist/cjs → cjs}/transactions/syscoin.js.map +0 -0
  172. /package/{dist/cjs → cjs}/trezor/index.js +0 -0
  173. /package/{dist/cjs → cjs}/trezor/index.js.map +0 -0
  174. /package/{dist/cjs → cjs}/types.js +0 -0
  175. /package/{dist/cjs → cjs}/types.js.map +0 -0
  176. /package/{dist/cjs → cjs}/utils/derivation-paths.js +0 -0
  177. /package/{dist/cjs → cjs}/utils/derivation-paths.js.map +0 -0
  178. /package/{dist/cjs → cjs}/utils/psbt.js +0 -0
  179. /package/{dist/cjs → cjs}/utils/psbt.js.map +0 -0
  180. /package/{dist/cjs → cjs}/utils.js +0 -0
  181. /package/{dist/cjs → cjs}/utils.js.map +0 -0
  182. /package/{dist/types → types}/errorUtils.d.ts +0 -0
  183. /package/{dist/types → types}/hardware-wallet-manager.d.ts +0 -0
  184. /package/{dist/types → types}/index.d.ts +0 -0
  185. /package/{dist/types → types}/initial-state.d.ts +0 -0
  186. /package/{dist/types → types}/keyring-manager.d.ts +0 -0
  187. /package/{dist/types → types}/ledger/bitcoin_client/index.d.ts +0 -0
  188. /package/{dist/types → types}/ledger/bitcoin_client/lib/appClient.d.ts +0 -0
  189. /package/{dist/types → types}/ledger/bitcoin_client/lib/bip32.d.ts +0 -0
  190. /package/{dist/types → types}/ledger/bitcoin_client/lib/buffertools.d.ts +0 -0
  191. /package/{dist/types → types}/ledger/bitcoin_client/lib/clientCommands.d.ts +0 -0
  192. /package/{dist/types → types}/ledger/bitcoin_client/lib/constants.d.ts +0 -0
  193. /package/{dist/types → types}/ledger/bitcoin_client/lib/merkelizedPsbt.d.ts +0 -0
  194. /package/{dist/types → types}/ledger/bitcoin_client/lib/merkle.d.ts +0 -0
  195. /package/{dist/types → types}/ledger/bitcoin_client/lib/merkleMap.d.ts +0 -0
  196. /package/{dist/types → types}/ledger/bitcoin_client/lib/policy.d.ts +0 -0
  197. /package/{dist/types → types}/ledger/bitcoin_client/lib/psbtv2.d.ts +0 -0
  198. /package/{dist/types → types}/ledger/bitcoin_client/lib/varint.d.ts +0 -0
  199. /package/{dist/types → types}/ledger/consts.d.ts +0 -0
  200. /package/{dist/types → types}/ledger/index.d.ts +0 -0
  201. /package/{dist/types → types}/ledger/types.d.ts +0 -0
  202. /package/{dist/types → types}/network-utils.d.ts +0 -0
  203. /package/{dist/types → types}/signers.d.ts +0 -0
  204. /package/{dist/types → types}/storage.d.ts +0 -0
  205. /package/{dist/types → types}/transactions/__tests__/integration.test.d.ts +0 -0
  206. /package/{dist/types → types}/transactions/__tests__/syscoin.test.d.ts +0 -0
  207. /package/{dist/types → types}/transactions/index.d.ts +0 -0
  208. /package/{dist/types → types}/transactions/syscoin.d.ts +0 -0
  209. /package/{dist/types → types}/trezor/index.d.ts +0 -0
  210. /package/{dist/types → types}/utils/derivation-paths.d.ts +0 -0
  211. /package/{dist/types → types}/utils/psbt.d.ts +0 -0
  212. /package/{dist/types → types}/utils.d.ts +0 -0
package/src/types.ts DELETED
@@ -1,366 +0,0 @@
1
- import { TransactionResponse } from '@ethersproject/abstract-provider';
2
- import { BigNumber, BigNumberish } from '@ethersproject/bignumber';
3
- import { BytesLike } from '@ethersproject/bytes';
4
- import { AccessListish } from '@ethersproject/transactions';
5
- import { Wallet } from '@ethersproject/wallet';
6
- import {
7
- TypedDataV1,
8
- TypedMessage,
9
- SignTypedDataVersion,
10
- } from '@metamask/eth-sig-util';
11
- import { INetwork, INetworkType } from '@sidhujag/sysweb3-network';
12
- import { ITxid } from '@sidhujag/sysweb3-utils';
13
- import { CustomJsonRpcProvider, CustomL2JsonRpcProvider } from 'providers';
14
-
15
- import { LedgerKeyring } from './ledger';
16
- import { SyscoinHDSigner } from './signers';
17
- import { TrezorKeyring } from './trezor';
18
-
19
- export type SimpleTransactionRequest = {
20
- accessList?: AccessListish;
21
- ccipReadEnabled?: boolean;
22
- chainId: number;
23
- customData?: Record<string, any>;
24
- data?: BytesLike;
25
-
26
- from: string;
27
- gasLimit?: BigNumberish;
28
- gasPrice?: BigNumberish;
29
-
30
- maxFeePerGas: BigNumberish;
31
- maxPriorityFeePerGas: BigNumberish;
32
-
33
- nonce?: BigNumberish;
34
- r?: string;
35
-
36
- s?: string;
37
- to: string;
38
- type?: number;
39
- v?: string;
40
- value?: BigNumberish;
41
- };
42
-
43
- // Version type is now replaced by SignTypedDataVersion from @metamask/eth-sig-util
44
-
45
- export interface IEthereumTransactions {
46
- cancelSentTransaction: (
47
- txHash: string,
48
- isLegacy?: boolean,
49
- fallbackNonce?: number
50
- ) => Promise<{
51
- error?: boolean;
52
- isCanceled: boolean;
53
- transaction?: TransactionResponse;
54
- }>;
55
- decryptMessage: (msgParams: string[]) => string;
56
- ethSign: (params: string[]) => Promise<string>;
57
- getBalance: (address: string) => Promise<number>;
58
- getEncryptedPubKey: () => string;
59
- getErc20TokensByAddress?: (
60
- address: string,
61
- isSupported: boolean,
62
- apiUrl: string
63
- ) => Promise<any[]>;
64
- getFeeByType: (type: string) => Promise<string>;
65
- getFeeDataWithDynamicMaxPriorityFeePerGas: () => Promise<any>;
66
- getGasLimit: (toAddress: string) => Promise<number>;
67
- getGasOracle?: () => Promise<any>;
68
- getRecommendedNonce: (address: string) => Promise<number>;
69
- signTypedData: (
70
- addr: string,
71
- typedData: TypedDataV1 | TypedMessage<any>,
72
- version: SignTypedDataVersion
73
- ) => Promise<string>;
74
-
75
- importAccount: (mnemonicOrPrivKey: string) => Wallet;
76
- parsePersonalMessage: (hexMsg: string) => string;
77
- sendFormattedTransaction: (
78
- params: SimpleTransactionRequest,
79
- isLegacy?: boolean
80
- ) => Promise<TransactionResponse>;
81
- sendSignedErc1155Transaction: ({
82
- receiver,
83
- tokenAddress,
84
- tokenId,
85
- isLegacy,
86
- gasPrice,
87
- gasLimit,
88
- maxFeePerGas,
89
- maxPriorityFeePerGas,
90
- }: ISendSignedErcTransactionProps) => Promise<IResponseFromSendErcSignedTransaction>;
91
- verifyPersonalMessage: (msg: string, sign: string) => string;
92
- toBigNumber: (aBigNumberish: string | number) => BigNumber;
93
- sendSignedErc20Transaction: ({
94
- networkUrl,
95
- receiver,
96
- tokenAddress,
97
- tokenAmount,
98
- }: ISendSignedErcTransactionProps) => Promise<IResponseFromSendErcSignedTransaction>;
99
-
100
- sendSignedErc721Transaction: ({
101
- networkUrl,
102
- receiver,
103
- tokenAddress,
104
- tokenId,
105
- }: ISendSignedErcTransactionProps) => Promise<IResponseFromSendErcSignedTransaction>;
106
-
107
- sendTransactionWithEditedFee: (
108
- txHash: string,
109
- isLegacy?: boolean
110
- ) => Promise<{
111
- isSpeedUp: boolean;
112
- transaction?: TransactionResponse;
113
- error?: boolean;
114
- }>;
115
-
116
- signPersonalMessage: (params: string[]) => Promise<string>;
117
- verifyTypedSignature: (
118
- data: TypedDataV1 | TypedMessage<any>,
119
- signature: string,
120
- version: SignTypedDataVersion
121
- ) => string;
122
- setWeb3Provider: (network: INetwork) => void;
123
- getRecommendedGasPrice: (formatted?: boolean) => Promise<
124
- | string
125
- | {
126
- ethers: string;
127
- gwei: string;
128
- }
129
- >;
130
- web3Provider: CustomJsonRpcProvider | CustomL2JsonRpcProvider;
131
- getTxGasLimit: (tx: SimpleTransactionRequest) => Promise<BigNumber>;
132
- }
133
-
134
- export interface ISyscoinTransactions {
135
- getEstimateSysTransactionFee: ({
136
- txOptions,
137
- amount,
138
- receivingAddress,
139
- feeRate,
140
- token,
141
- isMax,
142
- }: {
143
- amount: number;
144
- feeRate?: number;
145
- receivingAddress: string;
146
- token?: { guid: string; symbol?: string } | null;
147
- txOptions?: any;
148
- isMax?: boolean | false;
149
- }) => Promise<{ fee: number; psbt: any }>; // Returns UNSIGNED psbt - may throw ISyscoinTransactionError
150
- getRecommendedFee: (explorerUrl: string) => Promise<number>;
151
- decodeRawTransaction: (psbtOrHex: any, isRawHex?: boolean) => any;
152
- // Sign PSBT separately
153
- sendTransaction: (psbt: any) => Promise<ITxid>;
154
- signPSBT: ({
155
- psbt,
156
- isTrezor,
157
- isLedger,
158
- }: {
159
- isLedger?: boolean;
160
- isTrezor?: boolean;
161
- psbt: any;
162
- }) => Promise<any>;
163
- }
164
-
165
- export interface IKeyringManager {
166
- // Core keyring functionality
167
- addNewAccount: (label?: string) => Promise<IKeyringAccountState>;
168
- ethereumTransaction: IEthereumTransactions;
169
- forgetMainWallet: (pwd: string) => void;
170
- getAccountById: (
171
- id: number,
172
- accountType: KeyringAccountType
173
- ) => Omit<IKeyringAccountState, 'xprv'>;
174
- getAccountXpub: () => string;
175
- getEncryptedXprv: (hd: SyscoinHDSigner) => string;
176
- unlock: (
177
- password: string,
178
- isForPvtKey?: boolean
179
- ) => Promise<{
180
- canLogin: boolean;
181
- needsAccountCreation?: boolean;
182
- }>;
183
- isUnlocked: () => boolean;
184
- logout: () => void;
185
- ledgerSigner: LedgerKeyring;
186
- trezorSigner: TrezorKeyring;
187
- setSignerNetwork: (network: INetwork) => Promise<{
188
- success: boolean;
189
- }>;
190
- getPrivateKeyByAccountId: (
191
- id: number,
192
- accountType: KeyringAccountType,
193
- pwd: string
194
- ) => Promise<string>;
195
- setStorage: (client: any) => void;
196
- syscoinTransaction: ISyscoinTransactions;
197
- isSeedValid: (seedPhrase: string) => boolean;
198
- getSeed: (pwd: string) => Promise<string>;
199
- importTrezorAccount: (label?: string) => Promise<IKeyringAccountState>;
200
- utf8Error: boolean;
201
- validateZprv: (
202
- zprv: string,
203
- targetNetwork?: INetwork
204
- ) => IValidateZprvResponse;
205
- validateWif: (
206
- wif: string,
207
- targetNetwork?: INetwork
208
- ) => { isValid: boolean; message?: string };
209
- // Account management
210
- importAccount: (
211
- privKey: string,
212
- label?: string,
213
- options?: { utxoAddressType?: 'p2wpkh' | 'p2pkh' }
214
- ) => Promise<IKeyringAccountState>;
215
- getNewChangeAddress: () => Promise<string>;
216
- getChangeAddress: (id: number) => Promise<string>;
217
- getPubkey: (id: number, isChangeAddress: boolean) => Promise<string>;
218
- getBip32Path: (id: number, isChangeAddress: boolean) => Promise<string>;
219
- updateReceivingAddress: () => Promise<string>;
220
- getActiveAccount: () => {
221
- activeAccount: Omit<IKeyringAccountState, 'xprv'>;
222
- activeAccountType: KeyringAccountType;
223
- };
224
- importWeb3Account: (mnemonicOrPrivKey: string) => any;
225
- createNewSeed: (wordCount?: number) => string;
226
- getUTXOState: () => any;
227
- importLedgerAccount: (
228
- label?: string
229
- ) => Promise<IKeyringAccountState | undefined>;
230
- getActiveUTXOAccountState: () => any;
231
- createEthAccount: (privateKey: string) => any;
232
- getAddress: (xpub: string, isChangeAddress: boolean) => Promise<string>;
233
- // Secure initialization and password management
234
- initializeWalletSecurely: (
235
- seedPhrase: string,
236
- password: string,
237
- prvPassword?: string
238
- ) => Promise<IKeyringAccountState>;
239
- // NEW: Separated initialization methods
240
- initializeSession: (seedPhrase: string, password: string) => Promise<void>;
241
- createFirstAccount: (label?: string) => Promise<IKeyringAccountState>;
242
- transferSessionTo: (targetKeyring: IKeyringManager) => void;
243
- receiveSessionOwnership: (sessionPassword: any, sessionMnemonic: any) => void;
244
- lockWallet: () => void;
245
- // NEW: Store access for stateless keyring
246
- setVaultStateGetter: (getter: () => any) => void;
247
- }
248
-
249
- export enum KeyringAccountType {
250
- HDAccount = 'HDAccount',
251
- Imported = 'Imported',
252
- Ledger = 'Ledger',
253
- Trezor = 'Trezor',
254
- }
255
-
256
- export type IKeyringDApp = {
257
- active: boolean;
258
- id: number;
259
- url: string;
260
- };
261
-
262
- export type accountType = {
263
- [id: number]: IKeyringAccountState;
264
- };
265
-
266
- export type IKeyringBalances = {
267
- [INetworkType.Syscoin]: number;
268
- [INetworkType.Ethereum]: number;
269
- };
270
-
271
- interface INetworkParams {
272
- bech32: string;
273
- bip32: {
274
- private: number;
275
- public: number;
276
- };
277
- messagePrefix: string;
278
- pubKeyHash: number;
279
- scriptHash: number;
280
- slip44: number;
281
- wif: number;
282
- }
283
-
284
- interface IValidateZprvResponse {
285
- isValid: boolean;
286
- message: string;
287
- network?: INetworkParams | null;
288
- node?: any;
289
- }
290
-
291
- export interface IKeyringAccountState {
292
- address: string;
293
- balances: IKeyringBalances;
294
- id: number;
295
- isImported: boolean;
296
- isLedgerWallet: boolean;
297
- isTrezorWallet: boolean;
298
- label: string;
299
- xprv: string;
300
- xpub: string;
301
- }
302
-
303
- export interface ISyscoinBackendAccount {
304
- address: string;
305
- balance: string;
306
- itemsOnPage: number;
307
- page: number;
308
- totalPages: number;
309
- totalReceived: string;
310
- totalSent: string;
311
- txs: number;
312
- unconfirmedBalance: string;
313
- unconfirmedTxs: number;
314
- }
315
-
316
- export interface ILatestUpdateForSysAccount {
317
- balances: {
318
- ethereum: number;
319
- syscoin: number;
320
- };
321
- receivingAddress: any;
322
- xpub: any;
323
- }
324
-
325
- export interface ISendSignedErcTransactionProps {
326
- decimals?: number;
327
- gasLimit?: BigNumberish;
328
- gasPrice?: BigNumberish;
329
- isLegacy?: boolean;
330
- maxFeePerGas?: BigNumberish;
331
- maxPriorityFeePerGas?: BigNumberish;
332
- networkUrl: string;
333
- receiver: string;
334
- saveTrezorTx?: (tx: any) => void;
335
- tokenAddress: string;
336
- tokenAmount?: string;
337
- tokenId?: number;
338
- }
339
-
340
- export interface IResponseFromSendErcSignedTransaction {
341
- accessList: any[];
342
- chainId: number;
343
- confirmations: number | null;
344
- data: string;
345
- from: string;
346
- gasLimit: BigNumber;
347
- gasPrice: BigNumber | null;
348
- hash: string;
349
- maxFeePerGas: BigNumber;
350
- maxPriorityFeePerGas: BigNumber;
351
- nonce: number;
352
- r: string;
353
- s: string;
354
- to: string;
355
- type: number;
356
- v: number | null;
357
- value: BigNumber;
358
- wait: any;
359
- }
360
-
361
- export interface IGasParams {
362
- gasLimit?: BigNumber;
363
- gasPrice?: BigNumber;
364
- maxFeePerGas?: BigNumber;
365
- maxPriorityFeePerGas?: BigNumber;
366
- }
@@ -1,133 +0,0 @@
1
- // Import coins data from the relative package in the monorepo
2
- import { findCoin } from '@sidhujag/sysweb3-network';
3
-
4
- /**
5
- * Get coin information by coin shortcut or slip44
6
- * Priority: 1) Check if slip44=60 (EVM), 2) Check coins.ts (UTXO), 3) Default to unknown
7
- */
8
- export function getCoinInfo(coinShortcut: string, slip44: number) {
9
- // slip44=60: Ethereum and most EVM-compatible networks (BSC, Polygon, Arbitrum, etc.)
10
- // This must be checked FIRST to prevent any UTXO coin conflicts
11
- if (slip44 === 60) {
12
- return {
13
- slip44,
14
- segwit: false,
15
- isEvm: true,
16
- };
17
- }
18
-
19
- // Use the shared findCoin utility to search for UTXO coins
20
- const coin = findCoin({ slip44, name: coinShortcut });
21
-
22
- if (coin) {
23
- return {
24
- slip44: coin.slip44,
25
- segwit: coin.segwit || false,
26
- isEvm: false, // UTXO coins from coins.ts are not EVM
27
- };
28
- }
29
-
30
- // For unknown slip44 values, we cannot safely assume EVM
31
- // Return as unknown/unsupported rather than defaulting to EVM
32
- return {
33
- slip44,
34
- segwit: false,
35
- isEvm: false, // Changed from true to false - unknown slip44 should not default to EVM
36
- };
37
- }
38
-
39
- /**
40
- * Determine if a coin is EVM-based (Ethereum-like)
41
- */
42
- export function isEvmCoin(coinShortcut: string, slip44: number): boolean {
43
- const coinInfo = getCoinInfo(coinShortcut, slip44);
44
- return coinInfo.isEvm;
45
- }
46
-
47
- /**
48
- * Determine if a coin uses SegWit (BIP84 - m/84')
49
- */
50
- export function isSegwitCoin(coinShortcut: string, slip44: number): boolean {
51
- const coinInfo = getCoinInfo(coinShortcut, slip44);
52
- return coinInfo.segwit === true;
53
- }
54
-
55
- /**
56
- * Determine if a coin uses legacy derivation (BIP44 - m/44')
57
- */
58
- export function isLegacyCoin(coinShortcut: string, slip44: number): boolean {
59
- return !isSegwitCoin(coinShortcut, slip44);
60
- }
61
-
62
- /**
63
- * Get the appropriate BIP standard for a coin
64
- */
65
- export function getBipStandard(coinShortcut: string, slip44: number): number {
66
- if (isEvmCoin(coinShortcut, slip44)) {
67
- return 44; // EVM coins use BIP44
68
- }
69
-
70
- if (isSegwitCoin(coinShortcut, slip44)) {
71
- return 84; // SegWit coins use BIP84
72
- }
73
-
74
- return 44; // Default to BIP44 for legacy coins
75
- }
76
-
77
- /**
78
- * Generate derivation path for account level (ending with account index)
79
- * Example: m/84'/57'/0' for Syscoin account derivation
80
- */
81
- export function getAccountDerivationPath(
82
- coinShortcut: string,
83
- slip44: number,
84
- accountIndex = 0
85
- ): string {
86
- const bip = getBipStandard(coinShortcut, slip44);
87
- return `m/${bip}'/${slip44}'/${accountIndex}'`;
88
- }
89
-
90
- /**
91
- * Generate derivation path for address level (full path to specific address)
92
- * Example: m/84'/57'/0'/0/0 for first address of first Syscoin account
93
- */
94
- export function getAddressDerivationPath(
95
- coinShortcut: string,
96
- slip44: number,
97
- accountIndex = 0,
98
- isChangeAddress = false,
99
- addressIndex = 0
100
- ): string {
101
- const bip = getBipStandard(coinShortcut, slip44);
102
-
103
- if (isEvmCoin(coinShortcut, slip44)) {
104
- // EVM coins typically use: m/44'/60'/0'/0/addressIndex
105
- return `m/${bip}'/${slip44}'/0'/0/${addressIndex}`;
106
- } else {
107
- // UTXO coins use: m/84'/slip44'/account'/change/addressIndex
108
- const changeValue = isChangeAddress ? 1 : 0;
109
- return `m/${bip}'/${slip44}'/${accountIndex}'/${changeValue}/${addressIndex}`;
110
- }
111
- }
112
-
113
- /**
114
- * Convert an extended key's version bytes to a target version (e.g., xpub->zpub or tpub->vpub)
115
- * - Pass targetVersionHex as a 4-byte hex string (e.g., '04b24746' for zpub, '045f1cf6' for vpub)
116
- */
117
- export function convertExtendedKeyVersion(
118
- extendedKey: string,
119
- targetVersionHex: string
120
- ): string {
121
- try {
122
- // Lazy import to avoid bundling when unused
123
- /* eslint-disable @typescript-eslint/no-var-requires */
124
- const bs58check = require('bs58check');
125
- const decoded: Buffer = Buffer.from(bs58check.decode(extendedKey));
126
- const target = Buffer.from(targetVersionHex, 'hex');
127
- target.copy(decoded, 0, 0, 4);
128
- return bs58check.encode(decoded);
129
- } catch (e) {
130
- // If conversion fails, return original key
131
- return extendedKey;
132
- }
133
- }
package/src/utils/psbt.ts DELETED
@@ -1,24 +0,0 @@
1
- import * as syscoinjs from 'syscoinjs-lib';
2
-
3
- /**
4
- * Utility functions for PSBT conversion between Pali and syscoinjs formats
5
- */
6
- export class PsbtUtils {
7
- /**
8
- * Import PSBT from Pali's exported format to syscoinjs PSBT object
9
- * @param psbtFromPali - PSBT data exported from Pali
10
- * @returns syscoinjs PSBT object
11
- */
12
- static fromPali(psbtFromPali: any): any {
13
- return syscoinjs.utils.importPsbtFromJson(psbtFromPali).psbt;
14
- }
15
-
16
- /**
17
- * Export syscoinjs PSBT object to Pali's expected format
18
- * @param psbt - syscoinjs PSBT object
19
- * @returns PSBT data in Pali's expected format
20
- */
21
- static toPali(psbt: any): any {
22
- return syscoinjs.utils.exportPsbtToJson(psbt, undefined);
23
- }
24
- }
package/src/utils.ts DELETED
@@ -1,191 +0,0 @@
1
- import { isHexString } from '@ethersproject/bytes';
2
- import { Logger } from '@ethersproject/logger';
3
-
4
- const logger = new Logger('utils');
5
-
6
- const errorGas = ['call', 'estimateGas'];
7
-
8
- function spelunk(
9
- value: any,
10
- requireData: boolean
11
- ): null | { data: null | string; message: string } {
12
- if (value == null) {
13
- return null;
14
- }
15
-
16
- // These *are* the droids we're looking for.
17
- if (typeof value.message === 'string' && value.message.match('reverted')) {
18
- const data = isHexString(value.data) ? value.data : null;
19
- if (!requireData || data) {
20
- return { message: value.message, data };
21
- }
22
- }
23
-
24
- // Spelunk further...
25
- if (typeof value === 'object') {
26
- for (const key in value) {
27
- const result = spelunk(value[key], requireData);
28
- if (result) {
29
- return result;
30
- }
31
- }
32
- return null;
33
- }
34
-
35
- // Might be a JSON string we can further descend...
36
- if (typeof value === 'string') {
37
- try {
38
- return spelunk(JSON.parse(value), requireData);
39
- // eslint-disable-next-line
40
- } catch (error) {}
41
- }
42
-
43
- return null;
44
- }
45
-
46
- export function checkError(method: string, error: any, params: any): any {
47
- const transaction = params.transaction || params.signedTransaction;
48
-
49
- // Undo the "convenience" some nodes are attempting to prevent backwards
50
- // incompatibility; maybe for v6 consider forwarding reverts as errors
51
- if (method === 'call') {
52
- const result = spelunk(error, true);
53
- if (result) {
54
- return result.data;
55
- }
56
-
57
- // Nothing descriptive..
58
- logger.throwError(
59
- 'missing revert data in call exception; Transaction reverted without a reason string',
60
- Logger.errors.CALL_EXCEPTION,
61
- {
62
- data: '0x',
63
- transaction,
64
- error,
65
- }
66
- );
67
- }
68
-
69
- if (method === 'estimateGas') {
70
- // Try to find something, with a preference on SERVER_ERROR body
71
- let result = spelunk(error.body, false);
72
- if (result == null) {
73
- result = spelunk(error, false);
74
- }
75
-
76
- // Found "reverted", this is a CALL_EXCEPTION
77
- if (result) {
78
- logger.throwError(
79
- 'cannot estimate gas; transaction may fail or may require manual gas limit',
80
- Logger.errors.UNPREDICTABLE_GAS_LIMIT,
81
- {
82
- reason: result.message,
83
- method,
84
- transaction,
85
- error,
86
- }
87
- );
88
- }
89
- }
90
-
91
- // @TODO: Should we spelunk for message too?
92
-
93
- let message = error.message;
94
- if (
95
- error.code === Logger.errors.SERVER_ERROR &&
96
- error.error &&
97
- typeof error.error.message === 'string'
98
- ) {
99
- message = error.error.message;
100
- } else if (typeof error.body === 'string') {
101
- message = error.body;
102
- } else if (typeof error.responseText === 'string') {
103
- message = error.responseText;
104
- }
105
- message = (message || '').toLowerCase();
106
-
107
- // "insufficient funds for gas * price + value + cost(data)"
108
- if (
109
- message.match(
110
- /insufficient funds|base fee exceeds gas limit|InsufficientFunds/i
111
- )
112
- ) {
113
- logger.throwError(
114
- 'insufficient funds for intrinsic transaction cost',
115
- Logger.errors.INSUFFICIENT_FUNDS,
116
- {
117
- error,
118
- method,
119
- transaction,
120
- }
121
- );
122
- }
123
-
124
- // "nonce too low"
125
- if (message.match(/nonce (is )?too low/i)) {
126
- logger.throwError(
127
- 'nonce has already been used',
128
- Logger.errors.NONCE_EXPIRED,
129
- {
130
- error,
131
- method,
132
- transaction,
133
- }
134
- );
135
- }
136
-
137
- // "replacement transaction underpriced"
138
- if (
139
- message.match(
140
- /replacement transaction underpriced|transaction gas price.*too low/i
141
- )
142
- ) {
143
- logger.throwError(
144
- 'replacement fee too low',
145
- Logger.errors.REPLACEMENT_UNDERPRICED,
146
- {
147
- error,
148
- method,
149
- transaction,
150
- }
151
- );
152
- }
153
-
154
- // "replacement transaction underpriced"
155
- if (message.match(/only replay-protected/i)) {
156
- logger.throwError(
157
- 'legacy pre-eip-155 transactions not supported',
158
- Logger.errors.UNSUPPORTED_OPERATION,
159
- {
160
- error,
161
- method,
162
- transaction,
163
- }
164
- );
165
- }
166
-
167
- if (
168
- errorGas.indexOf(method) >= 0 &&
169
- message.match(
170
- /gas required exceeds allowance|always failing transaction|execution reverted|revert/
171
- )
172
- ) {
173
- logger.throwError(
174
- 'cannot estimate gas; transaction may fail or may require manual gas limit',
175
- Logger.errors.UNPREDICTABLE_GAS_LIMIT,
176
- {
177
- error,
178
- method,
179
- transaction,
180
- }
181
- );
182
- }
183
-
184
- throw error;
185
- }
186
-
187
- export const SYSCOIN_BASIC_FEE = 0.00001;
188
-
189
- export const ONE_HUNDRED_MILLION = 1e8;
190
-
191
- export const BIP_84 = 84;