@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
@@ -0,0 +1,138 @@
1
+ import ecc from '@bitcoinerlab/secp256k1';
2
+ import { findCoin, getNetworkConfig, INetworkType, } from '@sidhujag/sysweb3-network';
3
+ import { BIP32Factory } from 'bip32';
4
+ import bs58check from 'bs58check';
5
+ import { Buffer } from 'buffer';
6
+ import { utils as syscoinUtils } from 'syscoinjs-lib';
7
+ const bip32 = BIP32Factory(ecc);
8
+ const bitcoin = syscoinUtils.bitcoinjs;
9
+ const invalid = () => {
10
+ throw new Error('Unsupported or invalid public watch-only descriptor');
11
+ };
12
+ const childIndex = (value) => {
13
+ if (!Number.isInteger(value) || value < 0 || value >= 0x80000000)
14
+ return invalid();
15
+ return value;
16
+ };
17
+ // Bitcoin Core's descriptor checksum, also used by Pali's public-input guard.
18
+ export const descriptorChecksum = (value) => {
19
+ const input = '0123456789()[],\'/*abcdefgh@:$%{}IJKLMNOPQRSTUVWXYZ&+-.;<=>?!^_|~ijklmnopqrstuvwxyzABCDEFGH`#"\\ ';
20
+ const output = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l';
21
+ const generators = [
22
+ 'f5dee51989',
23
+ 'a9fdca3312',
24
+ '1bab10e32d',
25
+ '3706b1677a',
26
+ '644d626ffd',
27
+ ].map((hex) => BigInt(`0x${hex}`));
28
+ const poly = (current, next) => {
29
+ const top = current >> BigInt(35);
30
+ let result = ((current & BigInt('0x7ffffffff')) << BigInt(5)) ^ BigInt(next);
31
+ generators.forEach((generator, index) => {
32
+ if ((top & (BigInt(1) << BigInt(index))) !== BigInt(0))
33
+ result ^= generator;
34
+ });
35
+ return result;
36
+ };
37
+ let checksum = BigInt(1), group = 0, count = 0;
38
+ for (const character of value) {
39
+ const position = input.indexOf(character);
40
+ if (position < 0)
41
+ return '';
42
+ checksum = poly(checksum, position & 31);
43
+ group = group * 3 + (position >> 5);
44
+ if (++count === 3) {
45
+ checksum = poly(checksum, group);
46
+ group = count = 0;
47
+ }
48
+ }
49
+ if (count)
50
+ checksum = poly(checksum, group);
51
+ for (let index = 0; index < 8; index++)
52
+ checksum = poly(checksum, 0);
53
+ checksum ^= BigInt(1);
54
+ return Array.from({ length: 8 }, (_, index) => output[Number((checksum >> BigInt(5 * (7 - index))) & BigInt(31))]).join('');
55
+ };
56
+ /** Derive only the single-key public descriptor forms supported by Blockbook. */
57
+ export const deriveDescriptorAddress = (descriptor, network, options) => {
58
+ if (typeof descriptor !== 'string' ||
59
+ !descriptor ||
60
+ descriptor.length > 16384 ||
61
+ /\s/.test(descriptor) ||
62
+ (options?.change !== undefined && typeof options.change !== 'boolean'))
63
+ return invalid();
64
+ const parts = descriptor.split('#');
65
+ if (parts.length > 2 ||
66
+ (parts.length === 2 && descriptorChecksum(parts[0]) !== parts[1]))
67
+ return invalid();
68
+ const simple = /^(pkh|wpkh|tr)\(([^()]*)\)$/.exec(parts[0]);
69
+ const wrapped = /^sh\(wpkh\(([^()]*)\)\)$/.exec(parts[0]);
70
+ if (!simple && !wrapped)
71
+ return invalid();
72
+ const type = simple?.[1] || 'sh(wpkh)';
73
+ const key = simple?.[2] || wrapped?.[1] || '';
74
+ const parsed = /^(?:\[([\da-fA-F]{8})\/(\d+)['h]\/(\d+)['h]?\/(\d+)['h]?\])?([1-9A-HJ-NP-Za-km-z]{100,112})(?:\/(\d+|\{\d+(?:,\d+)*\}|<\d+(?:;\d+)*>)\/\*)?$/.exec(key);
75
+ if (!parsed)
76
+ return invalid();
77
+ if (parsed[1])
78
+ parsed.slice(2, 5).forEach((value) => childIndex(Number(value)));
79
+ const branches = parsed[6]
80
+ ? parsed[6]
81
+ .replace(/[{}<>]/g, '')
82
+ .split(/[,;]/)
83
+ .map((value) => childIndex(Number(value)))
84
+ : [0, 1];
85
+ if (branches.length > 10)
86
+ return invalid();
87
+ const branch = branches[options?.change ? 1 : 0];
88
+ if (branch === undefined)
89
+ return invalid();
90
+ const index = childIndex(options?.index === undefined ? 0 : options.index);
91
+ if (!network || network.kind !== INetworkType.Syscoin)
92
+ return invalid();
93
+ const coin = findCoin({
94
+ slip44: network.slip44,
95
+ name: network.currency,
96
+ exactMatch: true,
97
+ });
98
+ if (!coin ||
99
+ (type !== 'pkh' && coin.segwit !== true) ||
100
+ (type === 'tr' && coin.taproot !== true))
101
+ return invalid();
102
+ const config = getNetworkConfig(network.slip44, network.currency);
103
+ const addressNetwork = network.slip44 === 1 ? config.networks.testnet : config.networks.mainnet;
104
+ const payload = Buffer.from(bs58check.decode(parsed[5]));
105
+ if (payload.length !== 78 || ![2, 3].includes(payload[45]))
106
+ return invalid();
107
+ const root = bip32.fromBase58(parsed[5], {
108
+ ...addressNetwork,
109
+ bip32: { public: payload.readUInt32BE(0), private: 0x0488ade4 },
110
+ });
111
+ if (!root.isNeutered())
112
+ return invalid();
113
+ const branchNode = root.derive(branch);
114
+ const addressNode = branchNode.derive(index);
115
+ // Do not let BIP32's invalid-child retry silently select a different path.
116
+ if (branchNode.index !== branch || addressNode.index !== index)
117
+ return invalid();
118
+ const pubkey = addressNode.publicKey;
119
+ const payment = type === 'pkh'
120
+ ? bitcoin.payments.p2pkh({ pubkey, network: addressNetwork })
121
+ : type === 'wpkh'
122
+ ? bitcoin.payments.p2wpkh({ pubkey, network: addressNetwork })
123
+ : type === 'tr'
124
+ ? bitcoin.payments.p2tr({
125
+ internalPubkey: pubkey.slice(1),
126
+ network: addressNetwork,
127
+ })
128
+ : bitcoin.payments.p2sh({
129
+ redeem: bitcoin.payments.p2wpkh({ pubkey, network: addressNetwork }),
130
+ network: addressNetwork,
131
+ });
132
+ if (!payment.address ||
133
+ !payment.output ||
134
+ !Buffer.from(bitcoin.address.toOutputScript(payment.address, addressNetwork)).equals(Buffer.from(payment.output)))
135
+ return invalid();
136
+ return payment.address;
137
+ };
138
+ //# sourceMappingURL=watch-descriptor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watch-descriptor.js","sourceRoot":"","sources":["../../../src/utils/watch-descriptor.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,yBAAyB,CAAC;AAC1C,OAAO,EACL,QAAQ,EACR,gBAAgB,EAEhB,YAAY,GACb,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,eAAe,CAAC;AAEtD,MAAM,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;AAChC,MAAM,OAAO,GAAG,YAAY,CAAC,SAAS,CAAC;AACvC,MAAM,OAAO,GAAG,GAAU,EAAE;IAC1B,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;AACzE,CAAC,CAAC;AACF,MAAM,UAAU,GAAG,CAAC,KAAa,EAAU,EAAE;IAC3C,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,IAAI,UAAU;QAC9D,OAAO,OAAO,EAAE,CAAC;IACnB,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,8EAA8E;AAC9E,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAa,EAAU,EAAE;IAC1D,MAAM,KAAK,GACT,mGAAmG,CAAC;IACtG,MAAM,MAAM,GAAG,kCAAkC,CAAC;IAClD,MAAM,UAAU,GAAG;QACjB,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;KACb,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC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AAC,OAAO,CAAC,OAAO;QAChB,CAAC,OAAO,CAAC,MAAM;QACf,CAAC,MAAM,CAAC,IAAI,CACV,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,OAAO,EAAE,cAAc,CAAC,CAChE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAErC,OAAO,OAAO,EAAE,CAAC;IACnB,OAAO,OAAO,CAAC,OAAO,CAAC;AACzB,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sidhujag/sysweb3-keyring",
3
- "version": "2.1.3",
3
+ "version": "2.1.5",
4
4
  "description": "Keyring Manager for UTXO and Web3 Wallets",
5
5
  "main": "cjs/index.js",
6
6
  "types": "types/index.d.ts",
@@ -42,12 +42,6 @@
42
42
  "cjs/software.js": [
43
43
  "types/software.d.ts"
44
44
  ],
45
- "cjs/keyring-core": [
46
- "types/keyring-core.d.ts"
47
- ],
48
- "cjs/keyring-core.js": [
49
- "types/keyring-core.d.ts"
50
- ],
51
45
  "esm/ledger-host": [
52
46
  "types/ledger-host.d.ts"
53
47
  ],
@@ -100,9 +94,9 @@
100
94
  "@ledgerhq/device-signer-kit-ethereum": "1.18.2",
101
95
  "@ledgerhq/device-transport-kit-web-hid": "1.2.4",
102
96
  "@metamask/eth-sig-util": "^8.2.0",
103
- "@sidhujag/sysweb3-core": "^1.0.29",
104
- "@sidhujag/sysweb3-network": "^1.0.111",
105
- "@sidhujag/sysweb3-utils": "^1.1.280",
97
+ "@sidhujag/sysweb3-core": "1.0.30",
98
+ "@sidhujag/sysweb3-network": "2.0.0",
99
+ "@sidhujag/sysweb3-utils": "1.1.281",
106
100
  "@trezor/connect-webextension": "10.0.1",
107
101
  "bip32": "^5.0.1",
108
102
  "bip32-path": "^0.4.2",
@@ -116,7 +110,7 @@
116
110
  "varuint-bitcoin": "^2.0.0"
117
111
  },
118
112
  "peerDependencies": {
119
- "syscoinjs-lib": "^1.0.277"
113
+ "syscoinjs-lib": "^1.0.280"
120
114
  },
121
115
  "resolutions": {
122
116
  "axios": "^1.18.1",
@@ -0,0 +1,5 @@
1
+ export type HardwareTransactionAuthority = Readonly<{
2
+ assertCurrent: () => void;
3
+ signal: AbortSignal;
4
+ }>;
5
+ export declare function captureHardwareTransactionAuthority(authority: HardwareTransactionAuthority): HardwareTransactionAuthority;
package/types/index.d.ts CHANGED
@@ -1,16 +1,16 @@
1
1
  export * from './transactions';
2
2
  export * from './types';
3
- export * from './storage';
3
+ export { VaultAuthenticationError } from './storage-core';
4
4
  export * from './signers';
5
5
  export * from './initial-state';
6
6
  export * from './keyring-manager';
7
+ export { createKeyringHost } from './keyring-host';
8
+ export type { KeyringHost, KeyringOptions } from './keyring-host';
7
9
  export { MAX_PRIVATE_RECORD_BYTES, MAX_PRIVATE_RECORD_LABEL_BYTES, } from './private-records';
8
10
  export type { IDecryptPrivateRecordParams, IEncryptedPrivateRecord, IEncryptPrivateRecordParams, } from './private-records';
9
11
  export * from './providers';
10
12
  export * from './utils/derivation-paths';
11
13
  export * from './network-utils';
12
14
  export * from './hardware-wallet-manager';
13
- export * from './hardware-wallet-manager-singleton';
14
15
  export { PsbtUtils } from './utils/psbt';
15
- export { invalidateBlockbookAccountCache } from './utils/blockbook-cache';
16
16
  export { deriveDescriptorAddress, descriptorChecksum, } from './utils/watch-descriptor';
@@ -2,19 +2,17 @@ import { INetwork, INetworkType } from '@sidhujag/sysweb3-network';
2
2
  import { IDecryptPrivateRecordParams, IEncryptedPrivateRecord, IEncryptPrivateRecordParams } from './private-records';
3
3
  import { SyscoinHDSigner } from './signers';
4
4
  import { type ISyscoinHardwareSigners } from './transactions/syscoin-core';
5
- import { IKeyringAccountState, ICreateSmartAccountParams, ISyscoinTransactions, KeyringAccountType, IEthereumTransactions } from './types';
5
+ import { IKeyringAccountState, ICreateSmartAccountParams, ISyscoinTransactions, KeyringAccountType, IEthereumTransactions, type SyscoinOwnedReadOptions } from './types';
6
+ import type { KeyringHostBinding } from './keyring-host';
6
7
  import type { LedgerKeyring } from './ledger';
7
8
  import type { EncryptedEvmHdRuntimeAccount, EvmHdRuntimeAccountOptions, EvmHdRuntimeAccountRequest } from './software-hd-account';
8
- import type { VaultPersistence, VaultStoragePort } from './storage-core';
9
- import type { CaptureEvmSubmission } from './transactions/evm-submission';
9
+ import type { VaultStoragePort } from './storage-core';
10
10
  import type { PreparedEvmSigningOptions, PreparedSoftwareEvmSigningRequest, SignedPreparedEvmTransaction } from './transactions/prepared-evm';
11
11
  import type { TrezorKeyring } from './trezor';
12
12
  /** Explicit asynchronous host storage; no browser or global DI fallback. */
13
13
  export interface KeyringStoragePort extends VaultStoragePort {
14
14
  get(key: string): Promise<any>;
15
15
  deleteItem(key: string): Promise<void>;
16
- /** Legacy adapter capability; fixed native hosts can omit it. */
17
- setClient?(client: any): void;
18
16
  /** Atomically read this authority's current encrypted vault and salt. */
19
17
  readDeviceUnlockVaultPair?(): Promise<DeviceUnlockVaultPair | null>;
20
18
  }
@@ -49,28 +47,10 @@ export interface KeyringLedgerSigner {
49
47
  verifyUtxoAddress: LedgerKeyring['verifyUtxoAddress'];
50
48
  }
51
49
  export type KeyringTrezorSigner = Pick<TrezorKeyring, 'destroy' | 'getAccountInfo' | 'getPublicKey' | 'signTypedData' | 'signMessage' | 'signEthTransaction' | 'verifyUtxoAddress'>;
52
- type SessionOwner = {
53
- current?: symbol;
54
- epoch: number;
55
- };
56
- export interface KeyringCoreDependencies<TLedger extends KeyringLedgerSigner | undefined, TTrezor extends KeyringTrezorSigner | undefined> {
57
- /** Immutable identity shared only by keyrings in the same wallet authority. */
58
- authority: object;
59
- storage: KeyringStoragePort;
60
- /** Must be bound to this authority's storage and shared across its keyrings. */
61
- vaultPersistence: VaultPersistence;
50
+ interface KeyringHardware<TLedger extends KeyringLedgerSigner | undefined, TTrezor extends KeyringTrezorSigner | undefined> {
62
51
  ledgerSigner: TLedger;
63
52
  trezorSigner: TTrezor;
64
- /** Trusted host adapters; absent device capabilities fail closed. */
65
53
  syscoinHardwareSigners?: ISyscoinHardwareSigners;
66
- /** Trusted host lifecycle, captured before each locally signed EVM submission. */
67
- captureEvmSubmission?: CaptureEvmSubmission;
68
- /** Shared only by software keyrings of the same opted-in host. */
69
- sessionOwner?: SessionOwner;
70
- deviceUnlock?: {
71
- port: DeviceUnlockPort;
72
- receive(controls: DeviceUnlockControls): void;
73
- };
74
54
  }
75
55
  export interface ISysAccount {
76
56
  address: string;
@@ -78,19 +58,6 @@ export interface ISysAccount {
78
58
  xprv?: string;
79
59
  xpub: string;
80
60
  }
81
- /**
82
- * Secure Buffer implementation for sensitive data
83
- * Provides explicit memory clearing capability
84
- */
85
- declare class SecureBuffer {
86
- private buffer;
87
- private _isCleared;
88
- constructor(data: string | Buffer);
89
- get(): Buffer;
90
- toString(): string;
91
- clear(): void;
92
- isCleared(): boolean;
93
- }
94
61
  export declare class KeyringCore<TLedger extends KeyringLedgerSigner | undefined = KeyringLedgerSigner | undefined, TTrezor extends KeyringTrezorSigner | undefined = KeyringTrezorSigner | undefined> {
95
62
  #private;
96
63
  trezorSigner: TTrezor;
@@ -112,17 +79,15 @@ export declare class KeyringCore<TLedger extends KeyringLedgerSigner | undefined
112
79
  private sessionPassword;
113
80
  private sessionMnemonic;
114
81
  private privateRecordSessionRevision;
115
- constructor(dependencies: KeyringCoreDependencies<TLedger, TTrezor>);
82
+ constructor(binding: KeyringHostBinding, hardware: KeyringHardware<TLedger, TTrezor>);
116
83
  private createSyscoinTransactions;
117
84
  private requireLedgerSigner;
118
85
  private requireTrezorSigner;
119
86
  initialize(seed: string, password: string, network?: INetwork): Promise<IKeyringAccountState>;
120
- setStorage: (client: any) => void;
121
87
  validateAccountType: (account: IKeyringAccountState) => KeyringAccountType.HDAccount | KeyringAccountType.Imported;
122
88
  isUnlocked: () => boolean;
123
89
  lockWallet: () => Promise<void>;
124
- transferSessionTo: (targetKeyring: Pick<KeyringCore, "receiveSessionOwnership">) => void;
125
- receiveSessionOwnership: (sessionPassword: SecureBuffer, sessionMnemonic: SecureBuffer) => void;
90
+ transferSessionTo: (targetKeyring: KeyringCore) => void;
126
91
  addNewAccount: (label?: string) => Promise<IKeyringAccountState>;
127
92
  createSmartAccount: ({ address, deriveAccount, label, metadata, }: ICreateSmartAccountParams) => Promise<IKeyringAccountState>;
128
93
  /**
@@ -134,11 +99,14 @@ export declare class KeyringCore<TLedger extends KeyringLedgerSigner | undefined
134
99
  canLogin: boolean;
135
100
  needsAccountCreation?: boolean;
136
101
  }>;
137
- getNewChangeAddress: () => Promise<string>;
138
- getChangeAddress: (id: number) => Promise<string>;
139
- getPubkey: (id: number, isChangeAddress: boolean) => Promise<string>;
140
- getBip32Path: (id: number, isChangeAddress: boolean) => Promise<string>;
141
- updateReceivingAddress: () => Promise<string>;
102
+ private getActiveUtxoAddressAccount;
103
+ getNewChangeAddress: (ownedRead: SyscoinOwnedReadOptions) => Promise<string>;
104
+ getChangeAddress: (id: number, ownedRead: SyscoinOwnedReadOptions) => Promise<string>;
105
+ getPubkey: (id: number, isChangeAddress: boolean, ownedRead: SyscoinOwnedReadOptions) => Promise<string>;
106
+ getBip32Path: (id: number, isChangeAddress: boolean, ownedRead: SyscoinOwnedReadOptions) => Promise<string>;
107
+ updateReceivingAddress: (ownedRead: SyscoinOwnedReadOptions) => Promise<string>;
108
+ private getAddressForUtxoAccount;
109
+ private assertUtxoDerivationAvailable;
142
110
  getAccountById: (id: number, accountType: KeyringAccountType) => Omit<IKeyringAccountState, "xprv">;
143
111
  getPrivateKeyByAccountId: (id: number, accountType: KeyringAccountType, pwd: string) => Promise<string>;
144
112
  getActiveAccount: () => {
@@ -179,12 +147,15 @@ export declare class KeyringCore<TLedger extends KeyringLedgerSigner | undefined
179
147
  getActiveUTXOAccountState: () => any;
180
148
  getNetwork: () => any;
181
149
  createEthAccount: (privateKey: string) => import("./transactions/evm-local-signer").EvmLocalAccount;
150
+ private loadBip84AddressAccount;
151
+ private deriveFirstUtxoAddress;
182
152
  private fetchCurrentAccountData;
183
- getAddress: (xpub: string, isChangeAddress: boolean, options?: {
184
- forceIndex0?: boolean;
185
- }) => Promise<string>;
186
- getCurrentAddressPubkey: (xpub: string, isChangeAddress: boolean) => Promise<string>;
187
- getCurrentAddressBip32Path: (xpub: string, isChangeAddress: boolean) => Promise<string>;
153
+ private discoverUtxoAddress;
154
+ getAddress: (xpub: string, isChangeAddress: boolean, ownedRead: SyscoinOwnedReadOptions) => Promise<string>;
155
+ private getAddressPubkey;
156
+ getCurrentAddressPubkey: (xpub: string, isChangeAddress: boolean, ownedRead: SyscoinOwnedReadOptions) => Promise<string>;
157
+ private getAddressBip32Path;
158
+ getCurrentAddressBip32Path: (xpub: string, isChangeAddress: boolean, ownedRead: SyscoinOwnedReadOptions) => Promise<string>;
188
159
  logout: () => void;
189
160
  importAccount(privKey: string, label?: string, options?: {
190
161
  utxoAddressType?: 'p2wpkh' | 'p2pkh' | 'p2tr';
@@ -0,0 +1,46 @@
1
+ import type { DeviceUnlockControls, DeviceUnlockPort, KeyringStoragePort } from './keyring-core';
2
+ import type { VaultPersistence } from './storage-core';
3
+ import type { CaptureEvmSubmission } from './transactions/evm-submission';
4
+ declare const keyringHostBrand: unique symbol;
5
+ /** Opaque identity for one fixed wallet store and its unlock session. */
6
+ export interface KeyringHost {
7
+ readonly [keyringHostBrand]: true;
8
+ }
9
+ export type SessionOwner = {
10
+ current?: symbol;
11
+ epoch: number;
12
+ };
13
+ type BoundHost = {
14
+ storage: KeyringStoragePort;
15
+ vaultPersistence: VaultPersistence;
16
+ sessionOwner: SessionOwner;
17
+ deviceUnlockPort?: DeviceUnlockPort;
18
+ };
19
+ export declare function createKeyringHost(storage: KeyringStoragePort, options?: {
20
+ deviceUnlock?: DeviceUnlockPort;
21
+ }): KeyringHost;
22
+ export type KeyringOptions = {
23
+ captureEvmSubmission: CaptureEvmSubmission | null;
24
+ receiveDeviceUnlock?(controls: DeviceUnlockControls): void;
25
+ };
26
+ declare const bindingBrand: unique symbol;
27
+ export interface KeyringHostBinding {
28
+ readonly [bindingBrand]: true;
29
+ }
30
+ type PreparedHost = Omit<BoundHost, 'deviceUnlockPort'> & {
31
+ authority: KeyringHost;
32
+ captureEvmSubmission: CaptureEvmSubmission | null;
33
+ deviceUnlock?: {
34
+ port: DeviceUnlockPort;
35
+ receive(controls: DeviceUnlockControls): void;
36
+ };
37
+ };
38
+ export declare function takeKeyringHostBinding(binding: KeyringHostBinding): PreparedHost;
39
+ export declare function prepareKeyringHost(host: KeyringHost, options: KeyringOptions): {
40
+ binding: KeyringHostBinding;
41
+ publishControls?: undefined;
42
+ } | {
43
+ binding: KeyringHostBinding;
44
+ publishControls(): void;
45
+ };
46
+ export {};
@@ -2,28 +2,23 @@ import { HardwareWalletManager } from './hardware-wallet-manager';
2
2
  import { KeyringCore } from './keyring-core';
3
3
  import { LedgerKeyring } from './ledger';
4
4
  import { TrezorKeyring } from './trezor';
5
- import type { DeviceUnlockControls, DeviceUnlockPort, KeyringStoragePort } from './keyring-core';
5
+ import type { KeyringHost, KeyringOptions } from './keyring-host';
6
6
  import type { LedgerHost } from './ledger/host-types';
7
7
  import type { CaptureEvmSubmission } from './transactions/evm-submission';
8
8
  import type { IKeyringManager } from './types';
9
9
  export type { ISysAccount } from './keyring-core';
10
10
  export type { DeviceUnlockControls, DeviceUnlockPort, DeviceUnlockVaultPair, KeyringStoragePort, } from './keyring-core';
11
- declare const keyringManagerHostBrand: unique symbol;
12
- /** Opaque identity for one explicitly configured browser wallet authority. */
13
- export interface KeyringManagerHost {
14
- readonly [keyringManagerHostBrand]: true;
15
- }
16
- /** Create once for a fixed wallet store and share across replacement managers. */
17
- export declare function createKeyringManagerHost(storage: KeyringStoragePort, deviceUnlock: DeviceUnlockPort): KeyringManagerHost;
18
- export type KeyringManagerOptions = {
19
- captureEvmSubmission?: CaptureEvmSubmission;
20
- host?: KeyringManagerHost;
21
- receiveDeviceUnlock?(controls: DeviceUnlockControls): void;
22
- };
23
- /** Existing browser entry. Native/software hosts must use the software entry. */
11
+ export type KeyringManagerOptions = Omit<KeyringOptions, 'captureEvmSubmission'> & {
12
+ captureEvmSubmission: CaptureEvmSubmission;
13
+ } & ({
14
+ ledgerHost: LedgerHost;
15
+ hardwareManager?: never;
16
+ } | {
17
+ ledgerHost?: never;
18
+ hardwareManager: HardwareWalletManager;
19
+ });
20
+ /** Browser keyring with an explicit wallet authority and hardware adapter. */
24
21
  export declare class KeyringManager extends KeyringCore<LedgerKeyring, TrezorKeyring> implements IKeyringManager {
25
- constructor(sharedHardwareWalletManager?: HardwareWalletManager, ledgerHost?: LedgerHost, options?: KeyringManagerOptions);
26
- static createInitialized(seed: string, password: string, vaultStateGetter: () => any, options?: {
27
- captureEvmSubmission?: CaptureEvmSubmission;
28
- }): Promise<KeyringManager>;
22
+ constructor(host: KeyringHost, options: KeyringManagerOptions);
23
+ static createInitialized(host: KeyringHost, seed: string, password: string, vaultStateGetter: () => any, options: KeyringManagerOptions): Promise<KeyringManager>;
29
24
  }
@@ -1,3 +1,4 @@
1
+ import type { HardwareTransactionAuthority } from '../hardware-transaction-authority';
1
2
  /** Serializable Ledger requests. This module must remain free of device SDK imports. */
2
3
  export interface LedgerProgress {
3
4
  status: 'not-started' | 'pending' | 'stopped' | 'completed' | 'error';
@@ -5,9 +6,11 @@ export interface LedgerProgress {
5
6
  step?: string;
6
7
  }
7
8
  export interface LedgerOperationOptions {
9
+ assertCurrent?: () => void;
8
10
  signal?: AbortSignal;
9
11
  onProgress?: (progress: LedgerProgress) => void;
10
12
  }
13
+ export type LedgerPsbtAuthority = HardwareTransactionAuthority & Pick<LedgerOperationOptions, 'onProgress'>;
11
14
  export interface LedgerUtxoAccount {
12
15
  currency: string;
13
16
  slip44: number;
@@ -106,7 +109,7 @@ export interface LedgerUtxoHost {
106
109
  signPsbt(request: LedgerUtxoAccount & {
107
110
  psbtBase64: string;
108
111
  accountXpub: string;
109
- }, options?: LedgerOperationOptions): Promise<{
112
+ }, authority: LedgerPsbtAuthority): Promise<{
110
113
  fingerprint: string;
111
114
  signatures: LedgerPartialSignature[];
112
115
  }>;
@@ -15,7 +15,7 @@ export declare class LedgerKeyring {
15
15
  ensureConnection: () => Promise<void>;
16
16
  verifyUtxoAddress: (accountIndex: number, currency: string, slip44: number) => Promise<string>;
17
17
  signUtxoMessage: (request: Parameters<LedgerUtxoHost["signMessage"]>[0]) => Promise<string>;
18
- signPsbt: (request: Parameters<LedgerUtxoHost["signPsbt"]>[0]) => ReturnType<LedgerUtxoHost["signPsbt"]>;
18
+ signPsbt: (request: Parameters<LedgerUtxoHost["signPsbt"]>[0], authority: Parameters<LedgerUtxoHost["signPsbt"]>[1]) => ReturnType<LedgerUtxoHost["signPsbt"]>;
19
19
  getStatus(): {
20
20
  type: HardwareWalletType;
21
21
  connected: boolean;
@@ -1,4 +1,5 @@
1
1
  import { SignTypedDataVersion } from '@metamask/eth-sig-util';
2
+ import type { HardwareTransactionAuthority } from '../hardware-transaction-authority';
2
3
  export interface IUTXOMethods {
3
4
  getUtxoAddress: ({ coin, index, slip44, }: {
4
5
  coin: string;
@@ -27,11 +28,11 @@ export interface IEvmMethods {
27
28
  address: string;
28
29
  publicKey: string;
29
30
  }>;
30
- signEVMTransaction: ({ rawTx, accountIndex, }: {
31
+ signEVMTransaction: (request: {
31
32
  accountIndex: number;
32
33
  rawTx: string;
33
34
  expectedAddress: string;
34
- }) => Promise<{
35
+ }, authority: HardwareTransactionAuthority) => Promise<{
35
36
  r: string;
36
37
  s: string;
37
38
  v: string;
@@ -39,7 +39,7 @@ declare class BaseProvider extends JsonRpcProvider {
39
39
  private bindMethods;
40
40
  private throttledRequest;
41
41
  private canMakeRequest;
42
- verifyConfiguredChainId(): Promise<void>;
42
+ verifyConfiguredChainId(fresh?: boolean): Promise<void>;
43
43
  private fetchAndVerifyConfiguredChainId;
44
44
  private cooldown;
45
45
  private validateRpcResponses;
@@ -1,21 +1,10 @@
1
1
  /** Software-only entry: explicit host storage, no browser/device initialization. */
2
2
  import { KeyringCore } from './keyring-core';
3
- import type { DeviceUnlockControls, DeviceUnlockPort, KeyringStoragePort } from './keyring-core';
3
+ import type { KeyringHost, KeyringOptions } from './keyring-host';
4
4
  import type { EncryptedEvmHdRuntimeAccount, EvmHdRuntimeAccountOptions, EvmHdRuntimeAccountRequest } from './software-hd-account';
5
- import type { CaptureEvmSubmission } from './transactions/evm-submission';
6
5
  import type { PreparedEvmSigningOptions, PreparedSoftwareEvmSigningRequest, SignedPreparedEvmTransaction } from './transactions/prepared-evm';
7
- declare const softwareHostBrand: unique symbol;
8
- /** Opaque handle minted by createSoftwareKeyringHost; no injectable persistence. */
9
- export interface SoftwareKeyringHost {
10
- readonly [softwareHostBrand]: true;
11
- }
12
- /** Create once per wallet authority, then share with its per-network keyrings. */
13
- export declare const createSoftwareKeyringHost: (storage: KeyringStoragePort, options?: {
14
- captureEvmSubmission?: CaptureEvmSubmission;
15
- deviceUnlock?: DeviceUnlockPort;
16
- }) => SoftwareKeyringHost;
17
6
  export declare class SoftwareKeyring extends KeyringCore<undefined, undefined> {
18
- constructor(host: SoftwareKeyringHost, receiveDeviceUnlock?: (controls: DeviceUnlockControls) => void);
7
+ constructor(host: KeyringHost, options: KeyringOptions);
19
8
  /**
20
9
  * Derive a fixed-path Ethereum HD runtime account without network or storage
21
10
  * writes. The returned password-encrypted xprv is internal runtime state,
@@ -28,17 +17,15 @@ export declare class SoftwareKeyring extends KeyringCore<undefined, undefined> {
28
17
  * A later lock cannot revoke already returned signed bytes.
29
18
  */
30
19
  signPreparedEvmTransaction(request: PreparedSoftwareEvmSigningRequest, options: PreparedEvmSigningOptions): SignedPreparedEvmTransaction;
31
- /** Software authorities cannot rebind their backing store after creation. */
32
- setStorage: (client: any) => never;
33
- /** Sessions may move only through the core's same-authority transfer path. */
34
- receiveSessionOwnership: (...session: Parameters<KeyringCore["receiveSessionOwnership"]>) => never;
35
- static createInitialized(host: SoftwareKeyringHost, seed: string, password: string, vaultStateGetter: () => any): Promise<SoftwareKeyring>;
20
+ static createInitialized(host: KeyringHost, seed: string, password: string, vaultStateGetter: () => any, options: KeyringOptions): Promise<SoftwareKeyring>;
36
21
  }
22
+ export { createKeyringHost } from './keyring-host';
23
+ export type { KeyringHost, KeyringOptions } from './keyring-host';
37
24
  export { KeyringAccountType } from './types';
38
25
  export { INetworkType } from '@sidhujag/sysweb3-network';
39
26
  export type { INetwork } from '@sidhujag/sysweb3-network';
40
27
  export type { DeviceUnlockControls, DeviceUnlockCredential, DeviceUnlockPort, DeviceUnlockVaultPair, KeyringStoragePort, } from './keyring-core';
41
- export type { IKeyringAccountState } from './types';
28
+ export type { IKeyringAccountState, SyscoinOwnedReadOptions, SyscoinOwnedSubmissionOptions, SyscoinSubmissionDescriptor, } from './types';
42
29
  export type { PreparedEvmTransaction, PreparedEvmSigningOptions, PreparedSoftwareEvmSigningRequest, SignedPreparedEvmTransaction, } from './transactions/prepared-evm';
43
30
  export type { EncryptedEvmHdRuntimeAccount, EvmHdRuntimeAccountOptions, EvmHdRuntimeAccountRequest, } from './software-hd-account';
44
31
  export { captureEvmSubmission, submitSignedEvmTransaction, evmSubmissionFailure, } from './transactions/evm-submission';
@@ -2,7 +2,7 @@ import { TypedMessage, SignTypedDataVersion, TypedDataV1 } from '@metamask/eth-s
2
2
  import { INetwork } from '@sidhujag/sysweb3-network';
3
3
  import { BigNumber, TransactionResponse } from '../ethers-v6';
4
4
  import { CustomJsonRpcProvider } from '../providers';
5
- import { IResponseFromSendErcSignedTransaction, ISendSignedErcTransactionProps, IEthereumTransactions, IEvmCancellationOptions, IEvmReplacementOptions, IEvmSendOptions, SimpleTransactionRequest, KeyringAccountType, accountType, IGasParams } from '../types';
5
+ import { IResponseFromSendErcSignedTransaction, ISendSignedErc20TransactionProps, ISendSignedErc721TransactionProps, ISendSignedErc1155TransactionProps, IReviewedEvmTokenApproval, IEthereumTransactions, IEvmCancellationOptions, IEvmReplacementOptions, EvmFormattedSendArguments, SimpleTransactionRequest, KeyringAccountType, accountType, IGasParams } from '../types';
6
6
  import { type CaptureEvmSubmission } from './evm-submission';
7
7
  import type { LedgerKeyring } from '../ledger';
8
8
  import type { TrezorKeyring } from '../trezor';
@@ -18,8 +18,8 @@ export declare class EthereumTransactions<TLedger extends EthereumLedgerSigner |
18
18
  trezorSigner: TTrezor;
19
19
  ledgerSigner: TLedger;
20
20
  private getNetwork;
21
- private captureSigningContext?;
22
- private readonly captureSubmissionLifecycle?;
21
+ private readonly captureSigningContext;
22
+ private readonly captureSubmissionLifecycle;
23
23
  private abortController;
24
24
  private getDecryptedPrivateKey;
25
25
  private gasOverrides;
@@ -37,15 +37,17 @@ export declare class EthereumTransactions<TLedger extends EthereumLedgerSigner |
37
37
  activeAccountId: number;
38
38
  activeAccountType: KeyringAccountType;
39
39
  activeNetwork: INetwork;
40
- }, ledgerSigner: TLedger, trezorSigner: TTrezor, captureSigningContext?: () => () => void, captureSubmissionLifecycle?: CaptureEvmSubmission);
40
+ }, ledgerSigner: TLedger, trezorSigner: TTrezor, captureSigningContext: () => () => void, captureSubmissionLifecycle: CaptureEvmSubmission | null);
41
41
  private requireLedgerSigner;
42
42
  private requireTrezorSigner;
43
43
  private assertHardwareSignerAvailable;
44
+ private captureSessionGuard;
44
45
  private captureEvmSigningContext;
45
46
  private captureSubmission;
47
+ private authorizeHardwareTransaction;
48
+ private submitSignedHardwareTransaction;
46
49
  get web3Provider(): CustomJsonRpcProvider;
47
50
  private ensureProvidersInitialized;
48
- private isUtxoNetwork;
49
51
  signTypedData: (addr: string, typedData: TypedDataV1 | TypedMessage<any>, version: SignTypedDataVersion) => Promise<string>;
50
52
  verifyUtxoAddress: (accountIndex: number, currency: string, slip44: number) => Promise<string | undefined>;
51
53
  verifyTypedSignature: (data: TypedDataV1 | TypedMessage<any>, signature: string, version: SignTypedDataVersion) => string;
@@ -57,7 +59,8 @@ export declare class EthereumTransactions<TLedger extends EthereumLedgerSigner |
57
59
  decryptMessage: (msgParams: string[]) => string;
58
60
  toBigNumber: (aBigNumberish: string | number) => BigNumber;
59
61
  private toHex0x;
60
- private resolveEvmFeeParams;
62
+ private captureReviewedTokenApproval;
63
+ private reviewedTokenFees;
61
64
  getData: ({ contractAddress, receivingAddress, value, }: {
62
65
  contractAddress: string;
63
66
  receivingAddress: string;
@@ -78,9 +81,9 @@ export declare class EthereumTransactions<TLedger extends EthereumLedgerSigner |
78
81
  maximumFee?: string;
79
82
  transaction?: TransactionResponse;
80
83
  }>;
81
- sendFormattedTransaction: (params: SimpleTransactionRequest, isLegacy?: boolean, options?: IEvmSendOptions) => Promise<any>;
84
+ sendFormattedTransaction: (...args: EvmFormattedSendArguments) => Promise<any>;
82
85
  private sendFormattedTransactionInternal;
83
- sendTransactionWithEditedFee: (txHash: string, isLegacy?: boolean, options?: IEvmReplacementOptions) => Promise<{
86
+ sendTransactionWithEditedFee: (txHash: string, isLegacy: boolean | undefined, options: IEvmReplacementOptions) => Promise<{
84
87
  maximumFee?: string;
85
88
  error?: boolean;
86
89
  isSpeedUp: boolean;
@@ -90,9 +93,9 @@ export declare class EthereumTransactions<TLedger extends EthereumLedgerSigner |
90
93
  code?: string;
91
94
  message?: string;
92
95
  }>;
93
- sendSignedErc20Transaction: ({ receiver, tokenAddress, tokenAmount, isLegacy, maxPriorityFeePerGas, maxFeePerGas, gasPrice, decimals, gasLimit, saveTrezorTx, }: ISendSignedErcTransactionProps) => Promise<IResponseFromSendErcSignedTransaction>;
94
- sendSignedErc721Transaction: ({ receiver, tokenAddress, tokenId, isLegacy, maxPriorityFeePerGas, maxFeePerGas, gasPrice, gasLimit, }: ISendSignedErcTransactionProps) => Promise<IResponseFromSendErcSignedTransaction>;
95
- sendSignedErc1155Transaction: ({ receiver, tokenAddress, tokenId, tokenAmount, isLegacy, maxPriorityFeePerGas, maxFeePerGas, gasPrice, gasLimit, }: ISendSignedErcTransactionProps) => Promise<IResponseFromSendErcSignedTransaction>;
96
+ sendSignedErc20Transaction: (request: ISendSignedErc20TransactionProps, approval: IReviewedEvmTokenApproval) => Promise<IResponseFromSendErcSignedTransaction>;
97
+ sendSignedErc721Transaction: (request: ISendSignedErc721TransactionProps, approval: IReviewedEvmTokenApproval) => Promise<IResponseFromSendErcSignedTransaction>;
98
+ sendSignedErc1155Transaction: (request: ISendSignedErc1155TransactionProps, approval: IReviewedEvmTokenApproval) => Promise<IResponseFromSendErcSignedTransaction>;
96
99
  getRecommendedNonce: (address: string) => Promise<number>;
97
100
  getFeeByType: (type: string) => Promise<string>;
98
101
  getGasLimit: (toAddress: string) => Promise<number>;