@sidhujag/sysweb3-keyring 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +46 -108
- package/cjs/evm-fees.js +223 -0
- package/cjs/evm-fees.js.map +1 -0
- package/cjs/keyring-core.js +1 -227
- package/cjs/keyring-core.js.map +1 -1
- package/cjs/keyring-manager.js +4 -3
- package/cjs/keyring-manager.js.map +1 -1
- package/cjs/software.js +12 -11
- package/cjs/software.js.map +1 -1
- package/cjs/transactions/ethereum.js +194 -190
- package/cjs/transactions/ethereum.js.map +1 -1
- package/cjs/transactions/evm-local-signer.js +28 -7
- package/cjs/transactions/evm-local-signer.js.map +1 -1
- package/cjs/transactions/evm-submission.js +179 -0
- package/cjs/transactions/evm-submission.js.map +1 -0
- package/cjs/transactions/index.js +1 -0
- package/cjs/transactions/index.js.map +1 -1
- package/cjs/transactions/prepared-evm.js +2 -0
- package/cjs/transactions/prepared-evm.js.map +1 -1
- package/cjs/types.js.map +1 -1
- package/cjs/utils/derivation-paths.js +4 -3
- package/cjs/utils/derivation-paths.js.map +1 -1
- package/cjs/utils/watch-descriptor.js +3 -2
- package/cjs/utils/watch-descriptor.js.map +1 -1
- package/esm/types.js.map +1 -1
- package/esm/utils/derivation-paths.js +2 -1
- package/esm/utils/derivation-paths.js.map +1 -1
- package/package.json +24 -11
- package/types/evm-fees.d.ts +42 -0
- package/types/keyring-core.d.ts +3 -8
- package/types/keyring-manager.d.ts +8 -3
- package/types/software.d.ts +6 -11
- package/types/transactions/ethereum.d.ts +10 -8
- package/types/transactions/evm-local-signer.d.ts +4 -1
- package/types/transactions/evm-submission.d.ts +48 -0
- package/types/transactions/index.d.ts +1 -0
- package/types/types.d.ts +4 -0
- package/cjs/bip84-native.js +0 -8
- package/cjs/bip84-native.js.map +0 -1
- package/cjs/public-bip84.js +0 -157
- package/cjs/public-bip84.js.map +0 -1
- package/cjs/software-utxo-account.js +0 -12
- package/cjs/software-utxo-account.js.map +0 -1
- package/cjs/transactions/bip84-native-plan.js +0 -481
- package/cjs/transactions/bip84-native-plan.js.map +0 -1
- package/cjs/transactions/prepared-bip84.js +0 -214
- package/cjs/transactions/prepared-bip84.js.map +0 -1
- package/types/bip84-native.d.ts +0 -3
- package/types/public-bip84.d.ts +0 -39
- package/types/software-utxo-account.d.ts +0 -13
- package/types/transactions/bip84-native-plan.d.ts +0 -83
- package/types/transactions/prepared-bip84.d.ts +0 -27
package/cjs/keyring-core.js
CHANGED
|
@@ -59,15 +59,11 @@ const SLH_DSA_PARAMETER_SET = 'SLH-DSA-SHA2-128-24';
|
|
|
59
59
|
const ethers_v6_1 = require("./ethers-v6");
|
|
60
60
|
const initial_state_1 = require("./initial-state");
|
|
61
61
|
const private_records_1 = require("./private-records");
|
|
62
|
-
const public_bip84_1 = require("./public-bip84");
|
|
63
62
|
const signers_1 = require("./signers");
|
|
64
63
|
const software_hd_account_1 = require("./software-hd-account");
|
|
65
|
-
const software_utxo_account_1 = require("./software-utxo-account");
|
|
66
64
|
const storage_core_1 = require("./storage-core");
|
|
67
|
-
const bip84_native_plan_1 = require("./transactions/bip84-native-plan");
|
|
68
65
|
const ethereum_1 = require("./transactions/ethereum");
|
|
69
66
|
const evm_local_signer_1 = require("./transactions/evm-local-signer");
|
|
70
|
-
const prepared_bip84_1 = require("./transactions/prepared-bip84");
|
|
71
67
|
const prepared_evm_1 = require("./transactions/prepared-evm");
|
|
72
68
|
const syscoin_core_1 = require("./transactions/syscoin-core");
|
|
73
69
|
const types_1 = require("./types");
|
|
@@ -1261,7 +1257,7 @@ class KeyringCore {
|
|
|
1261
1257
|
this.initialTrezorAccountState = initial_state_1.initialActiveTrezorAccountState;
|
|
1262
1258
|
this.initialLedgerAccountState = initial_state_1.initialActiveLedgerAccountState;
|
|
1263
1259
|
this.syscoinTransaction = this.createSyscoinTransactions();
|
|
1264
|
-
this.ethereumTransaction = new ethereum_1.EthereumTransactions(this.getNetwork, this.getDecryptedPrivateKey, this.getAccountsState, this.ledgerSigner, this.trezorSigner, this.capturePsbtSigningContext);
|
|
1260
|
+
this.ethereumTransaction = new ethereum_1.EthereumTransactions(this.getNetwork, this.getDecryptedPrivateKey, this.getAccountsState, this.ledgerSigner, this.trezorSigner, this.capturePsbtSigningContext, dependencies.captureEvmSubmission);
|
|
1265
1261
|
}
|
|
1266
1262
|
// Convenience method for complete setup after construction
|
|
1267
1263
|
async initialize(seed, password, network) {
|
|
@@ -1800,228 +1796,6 @@ class KeyringCore {
|
|
|
1800
1796
|
return { isValid: false, message: error.message };
|
|
1801
1797
|
}
|
|
1802
1798
|
}
|
|
1803
|
-
/** Fixed-profile public UTXO derivation; private material remains operation-local. */
|
|
1804
|
-
async deriveSoftwareBip84HdPublicAccount(input, options) {
|
|
1805
|
-
if (this.bip84Operation)
|
|
1806
|
-
throw new bip84_native_plan_1.Bip84NativeError('BUSY');
|
|
1807
|
-
const operation = {};
|
|
1808
|
-
this.bip84Operation = operation;
|
|
1809
|
-
const nodes = [];
|
|
1810
|
-
try {
|
|
1811
|
-
const session = this.sessionPassword;
|
|
1812
|
-
const mnemonic = this.sessionMnemonic;
|
|
1813
|
-
const revision = this.privateRecordSessionRevision;
|
|
1814
|
-
const vault = this.getVault();
|
|
1815
|
-
const selected = { ...vault.activeAccount };
|
|
1816
|
-
const selectedAccount = vault.accounts[selected.type]?.[selected.id];
|
|
1817
|
-
const identity = {
|
|
1818
|
-
address: selectedAccount?.address,
|
|
1819
|
-
xpub: selectedAccount?.xpub,
|
|
1820
|
-
};
|
|
1821
|
-
const network = { ...vault.activeNetwork };
|
|
1822
|
-
const request = (0, software_utxo_account_1.snapshotBip84HdPublicRequest)(input);
|
|
1823
|
-
const hostGuard = (0, bip84_native_plan_1.snapshotBip84Guard)(options);
|
|
1824
|
-
const profile = (0, bip84_native_plan_1.bip84Profile)(request.network.network);
|
|
1825
|
-
const assertCurrent = () => {
|
|
1826
|
-
const current = this.getVault();
|
|
1827
|
-
const account = current.accounts[selected.type]?.[selected.id];
|
|
1828
|
-
if (!session ||
|
|
1829
|
-
session.isCleared() ||
|
|
1830
|
-
this.sessionPassword !== session ||
|
|
1831
|
-
!mnemonic ||
|
|
1832
|
-
mnemonic.isCleared() ||
|
|
1833
|
-
this.sessionMnemonic !== mnemonic ||
|
|
1834
|
-
this.privateRecordSessionRevision !== revision ||
|
|
1835
|
-
this.bip84Operation !== operation ||
|
|
1836
|
-
selected.type !== types_1.KeyringAccountType.HDAccount ||
|
|
1837
|
-
current.activeAccount.type !== selected.type ||
|
|
1838
|
-
current.activeAccount.id !== selected.id ||
|
|
1839
|
-
account?.address !== identity.address ||
|
|
1840
|
-
account?.xpub !== identity.xpub ||
|
|
1841
|
-
account?.isLedgerWallet ||
|
|
1842
|
-
account?.isTrezorWallet ||
|
|
1843
|
-
account?.isSmartAccount ||
|
|
1844
|
-
network.kind !== sysweb3_network_1.INetworkType.Syscoin ||
|
|
1845
|
-
network.chainId !== profile.chainId ||
|
|
1846
|
-
network.slip44 !== profile.slip44 ||
|
|
1847
|
-
network.url !== request.network.endpoint ||
|
|
1848
|
-
current.activeNetwork.kind !== network.kind ||
|
|
1849
|
-
current.activeNetwork.chainId !== network.chainId ||
|
|
1850
|
-
current.activeNetwork.slip44 !== network.slip44 ||
|
|
1851
|
-
current.activeNetwork.url !== network.url)
|
|
1852
|
-
throw new bip84_native_plan_1.Bip84NativeError('CANCELLED');
|
|
1853
|
-
};
|
|
1854
|
-
const guard = () => {
|
|
1855
|
-
assertCurrent();
|
|
1856
|
-
hostGuard();
|
|
1857
|
-
assertCurrent();
|
|
1858
|
-
};
|
|
1859
|
-
guard();
|
|
1860
|
-
const config = (0, sysweb3_network_1.getNetworkConfig)(profile.slip44, profile.currency);
|
|
1861
|
-
const { hd } = (0, signers_1.getSyscoinSigners)({
|
|
1862
|
-
mnemonic: this.getDecryptedMnemonic(),
|
|
1863
|
-
rpc: {
|
|
1864
|
-
formattedNetwork: { ...network, currency: profile.currency },
|
|
1865
|
-
networkConfig: {
|
|
1866
|
-
networks: config.networks,
|
|
1867
|
-
types: {
|
|
1868
|
-
xPubType: config.types.xPubType,
|
|
1869
|
-
zPubType: config.types.zPubType,
|
|
1870
|
-
},
|
|
1871
|
-
},
|
|
1872
|
-
},
|
|
1873
|
-
});
|
|
1874
|
-
let node = hd.getRootNode();
|
|
1875
|
-
nodes.push(node);
|
|
1876
|
-
for (const child of [84, profile.slip44, request.accountIndex]) {
|
|
1877
|
-
node = node.deriveHardened(child);
|
|
1878
|
-
nodes.push(node);
|
|
1879
|
-
if (node.index !== child + 0x80000000)
|
|
1880
|
-
throw new bip84_native_plan_1.Bip84NativeError('ACCOUNT_MISMATCH');
|
|
1881
|
-
}
|
|
1882
|
-
const account = (0, public_bip84_1.parseBip84PublicAccount)({
|
|
1883
|
-
network: request.network.network,
|
|
1884
|
-
accountKey: node.neutered().toBase58(),
|
|
1885
|
-
});
|
|
1886
|
-
if (account.accountIndex !== request.accountIndex)
|
|
1887
|
-
throw new bip84_native_plan_1.Bip84NativeError('ACCOUNT_MISMATCH');
|
|
1888
|
-
const receive = (0, public_bip84_1.deriveBip84PublicAddress)({
|
|
1889
|
-
network: request.network.network,
|
|
1890
|
-
accountKey: account.canonicalKey,
|
|
1891
|
-
branch: 0,
|
|
1892
|
-
index: 0,
|
|
1893
|
-
});
|
|
1894
|
-
guard();
|
|
1895
|
-
return Object.freeze({
|
|
1896
|
-
type: 'HDAccount',
|
|
1897
|
-
accountIndex: request.accountIndex,
|
|
1898
|
-
account,
|
|
1899
|
-
receive,
|
|
1900
|
-
});
|
|
1901
|
-
}
|
|
1902
|
-
catch (error) {
|
|
1903
|
-
if (error instanceof bip84_native_plan_1.Bip84NativeError)
|
|
1904
|
-
throw error;
|
|
1905
|
-
throw new bip84_native_plan_1.Bip84NativeError('INVALID_REQUEST');
|
|
1906
|
-
}
|
|
1907
|
-
finally {
|
|
1908
|
-
// Only buffers owned by this operation; library/JS copies are not claimed zeroized.
|
|
1909
|
-
for (const node of nodes)
|
|
1910
|
-
node.privateKey?.fill(0);
|
|
1911
|
-
if (this.bip84Operation === operation)
|
|
1912
|
-
this.bip84Operation = undefined;
|
|
1913
|
-
}
|
|
1914
|
-
}
|
|
1915
|
-
/** Fixed selected-account native signing. No storage, discovery or broadcast. */
|
|
1916
|
-
async signPreparedSoftwareBip84Transaction(input, options) {
|
|
1917
|
-
if (this.bip84Operation)
|
|
1918
|
-
throw new bip84_native_plan_1.Bip84NativeError('BUSY');
|
|
1919
|
-
const operation = {};
|
|
1920
|
-
this.bip84Operation = operation;
|
|
1921
|
-
const nodes = [];
|
|
1922
|
-
try {
|
|
1923
|
-
const session = this.sessionPassword;
|
|
1924
|
-
const mnemonic = this.sessionMnemonic;
|
|
1925
|
-
const revision = this.privateRecordSessionRevision;
|
|
1926
|
-
const vault = this.getVault();
|
|
1927
|
-
const selected = { ...vault.activeAccount };
|
|
1928
|
-
const selectedAccount = vault.accounts[selected.type]?.[selected.id];
|
|
1929
|
-
const identity = {
|
|
1930
|
-
id: selectedAccount?.id,
|
|
1931
|
-
address: selectedAccount?.address,
|
|
1932
|
-
xpub: selectedAccount?.xpub,
|
|
1933
|
-
};
|
|
1934
|
-
const network = { ...vault.activeNetwork };
|
|
1935
|
-
const { account, validated } = (0, prepared_bip84_1.snapshotPreparedBip84Request)(input);
|
|
1936
|
-
const hostGuard = (0, bip84_native_plan_1.snapshotBip84Guard)(options);
|
|
1937
|
-
const profile = (0, bip84_native_plan_1.bip84Profile)(validated.prepared.plan.network.network);
|
|
1938
|
-
const assertCurrent = () => {
|
|
1939
|
-
const current = this.getVault();
|
|
1940
|
-
const active = current.accounts[selected.type]?.[selected.id];
|
|
1941
|
-
if (!session ||
|
|
1942
|
-
session.isCleared() ||
|
|
1943
|
-
this.sessionPassword !== session ||
|
|
1944
|
-
!mnemonic ||
|
|
1945
|
-
mnemonic.isCleared() ||
|
|
1946
|
-
this.sessionMnemonic !== mnemonic ||
|
|
1947
|
-
this.privateRecordSessionRevision !== revision ||
|
|
1948
|
-
this.bip84Operation !== operation ||
|
|
1949
|
-
selected.type !== types_1.KeyringAccountType.HDAccount ||
|
|
1950
|
-
selected.id !== account.index ||
|
|
1951
|
-
current.activeAccount.type !== selected.type ||
|
|
1952
|
-
current.activeAccount.id !== selected.id ||
|
|
1953
|
-
!active ||
|
|
1954
|
-
active.id !== account.index ||
|
|
1955
|
-
active.id !== identity.id ||
|
|
1956
|
-
active.address !== identity.address ||
|
|
1957
|
-
active.xpub !== identity.xpub ||
|
|
1958
|
-
active.isImported ||
|
|
1959
|
-
active.isLedgerWallet ||
|
|
1960
|
-
active.isTrezorWallet ||
|
|
1961
|
-
active.isSmartAccount ||
|
|
1962
|
-
network.kind !== sysweb3_network_1.INetworkType.Syscoin ||
|
|
1963
|
-
network.chainId !== profile.chainId ||
|
|
1964
|
-
network.slip44 !== profile.slip44 ||
|
|
1965
|
-
network.url !== validated.prepared.plan.network.endpoint ||
|
|
1966
|
-
current.activeNetwork.kind !== network.kind ||
|
|
1967
|
-
current.activeNetwork.chainId !== network.chainId ||
|
|
1968
|
-
current.activeNetwork.slip44 !== network.slip44 ||
|
|
1969
|
-
current.activeNetwork.url !== network.url)
|
|
1970
|
-
throw new bip84_native_plan_1.Bip84NativeError('CANCELLED');
|
|
1971
|
-
};
|
|
1972
|
-
const guard = () => {
|
|
1973
|
-
assertCurrent();
|
|
1974
|
-
hostGuard();
|
|
1975
|
-
assertCurrent();
|
|
1976
|
-
};
|
|
1977
|
-
guard();
|
|
1978
|
-
if (typeof identity.xpub !== 'string' ||
|
|
1979
|
-
(0, public_bip84_1.parseBip84PublicAccount)({
|
|
1980
|
-
network: validated.prepared.plan.network.network,
|
|
1981
|
-
accountKey: identity.xpub,
|
|
1982
|
-
}).canonicalKey !== account.expectedAccountKey)
|
|
1983
|
-
throw new bip84_native_plan_1.Bip84NativeError('ACCOUNT_MISMATCH');
|
|
1984
|
-
const words = this.getDecryptedMnemonic();
|
|
1985
|
-
if (!BIP84.validateMnemonic(words))
|
|
1986
|
-
throw new bip84_native_plan_1.Bip84NativeError('ACCOUNT_MISMATCH');
|
|
1987
|
-
guard();
|
|
1988
|
-
const config = (0, sysweb3_network_1.getNetworkConfig)(profile.slip44, profile.currency);
|
|
1989
|
-
const { hd } = (0, signers_1.getSyscoinSigners)({
|
|
1990
|
-
mnemonic: words,
|
|
1991
|
-
rpc: {
|
|
1992
|
-
formattedNetwork: { ...network, currency: profile.currency },
|
|
1993
|
-
networkConfig: {
|
|
1994
|
-
networks: config.networks,
|
|
1995
|
-
types: {
|
|
1996
|
-
xPubType: config.types.xPubType,
|
|
1997
|
-
zPubType: config.types.zPubType,
|
|
1998
|
-
},
|
|
1999
|
-
},
|
|
2000
|
-
},
|
|
2001
|
-
});
|
|
2002
|
-
let node = hd.getRootNode();
|
|
2003
|
-
nodes.push(node);
|
|
2004
|
-
for (const child of [84, profile.slip44, account.index]) {
|
|
2005
|
-
guard();
|
|
2006
|
-
node = node.deriveHardened(child);
|
|
2007
|
-
nodes.push(node);
|
|
2008
|
-
if (node.index !== child + 0x80000000)
|
|
2009
|
-
throw new bip84_native_plan_1.Bip84NativeError('ACCOUNT_MISMATCH');
|
|
2010
|
-
}
|
|
2011
|
-
guard();
|
|
2012
|
-
return (0, prepared_bip84_1.signValidatedBip84Plan)(validated, node, guard);
|
|
2013
|
-
}
|
|
2014
|
-
catch (error) {
|
|
2015
|
-
if (error instanceof bip84_native_plan_1.Bip84NativeError)
|
|
2016
|
-
throw error;
|
|
2017
|
-
throw new bip84_native_plan_1.Bip84NativeError('INVALID_REQUEST');
|
|
2018
|
-
}
|
|
2019
|
-
finally {
|
|
2020
|
-
(0, prepared_bip84_1.clearBip84PrivateNodes)(nodes);
|
|
2021
|
-
if (this.bip84Operation === operation)
|
|
2022
|
-
this.bip84Operation = undefined;
|
|
2023
|
-
}
|
|
2024
|
-
}
|
|
2025
1799
|
/** Fixed-path derivation for an authenticated software host; no persistence. */
|
|
2026
1800
|
async deriveSoftwareEvmHdRuntimeAccount(input, options) {
|
|
2027
1801
|
// Capture the session and selection before inspecting caller-owned objects.
|