@sidhujag/sysweb3-keyring 2.1.2 → 2.1.4
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 +6 -0
- package/README.md +55 -47
- package/cjs/current-vault-refusal.js +6 -0
- package/cjs/current-vault-refusal.js.map +1 -0
- package/cjs/evm-fees.js +29 -1
- package/cjs/evm-fees.js.map +1 -1
- package/cjs/hardware-transaction-authority.js +36 -0
- package/cjs/hardware-transaction-authority.js.map +1 -0
- package/cjs/index.js +5 -5
- package/cjs/index.js.map +1 -1
- package/cjs/keyring-core.js +466 -250
- package/cjs/keyring-core.js.map +1 -1
- package/cjs/keyring-host.js +113 -0
- package/cjs/keyring-host.js.map +1 -0
- package/cjs/keyring-manager.js +15 -55
- package/cjs/keyring-manager.js.map +1 -1
- package/cjs/ledger/host-types.js.map +1 -1
- package/cjs/ledger/index.js +44 -19
- package/cjs/ledger/index.js.map +1 -1
- package/cjs/providers.js +3 -1
- package/cjs/providers.js.map +1 -1
- package/cjs/software.js +10 -43
- package/cjs/software.js.map +1 -1
- package/cjs/storage-core.js +44 -4
- package/cjs/storage-core.js.map +1 -1
- package/cjs/transactions/ethereum.js +358 -294
- package/cjs/transactions/ethereum.js.map +1 -1
- package/cjs/transactions/evm-cancellation.js +43 -0
- package/cjs/transactions/evm-cancellation.js.map +1 -0
- package/cjs/transactions/evm-local-signer.js +15 -0
- package/cjs/transactions/evm-local-signer.js.map +1 -1
- package/cjs/transactions/evm-submission.js +61 -65
- package/cjs/transactions/evm-submission.js.map +1 -1
- package/cjs/transactions/hardware-psbt.js +11 -8
- package/cjs/transactions/hardware-psbt.js.map +1 -1
- package/cjs/transactions/index.js +10 -2
- package/cjs/transactions/index.js.map +1 -1
- package/cjs/transactions/prepared-evm.js +10 -7
- package/cjs/transactions/prepared-evm.js.map +1 -1
- package/cjs/transactions/syscoin-core.js +282 -202
- package/cjs/transactions/syscoin-core.js.map +1 -1
- package/cjs/trezor/connect.js +19 -2
- package/cjs/trezor/connect.js.map +1 -1
- package/cjs/trezor/index.js +38 -16
- package/cjs/trezor/index.js.map +1 -1
- package/cjs/types.js.map +1 -1
- package/cjs/utils/owned-blockbook-account.js +45 -0
- package/cjs/utils/owned-blockbook-account.js.map +1 -0
- package/esm/current-vault-refusal.js +3 -0
- package/esm/current-vault-refusal.js.map +1 -0
- package/esm/evm-fees.js +242 -0
- package/esm/evm-fees.js.map +1 -0
- package/esm/hardware-transaction-authority.js +33 -0
- package/esm/hardware-transaction-authority.js.map +1 -0
- package/esm/initial-state.js +102 -0
- package/esm/initial-state.js.map +1 -0
- package/esm/keyring-core.js +2781 -0
- package/esm/keyring-core.js.map +1 -0
- package/esm/keyring-host.js +108 -0
- package/esm/keyring-host.js.map +1 -0
- package/esm/ledger/dmk-host.js +31 -0
- package/esm/ledger/dmk-host.js.map +1 -0
- package/esm/ledger/dmk-selected-host.js +6 -0
- package/esm/ledger/dmk-selected-host.js.map +1 -0
- package/esm/ledger/dmk-session.js +154 -34
- package/esm/ledger/dmk-session.js.map +1 -1
- package/esm/ledger/dmk-utxo.js +9 -3
- package/esm/ledger/dmk-utxo.js.map +1 -1
- package/esm/ledger/host-types.js.map +1 -1
- package/esm/ledger/index.js +44 -19
- package/esm/ledger/index.js.map +1 -1
- package/esm/ledger-host.js +3 -27
- package/esm/ledger-host.js.map +1 -1
- package/esm/network-utils.js +70 -0
- package/esm/network-utils.js.map +1 -0
- package/esm/providers.js +3 -1
- package/esm/providers.js.map +1 -1
- package/esm/software-hd-account.js +20 -0
- package/esm/software-hd-account.js.map +1 -0
- package/esm/storage-core.js +258 -0
- package/esm/storage-core.js.map +1 -0
- package/esm/transactions/ethereum.js +2753 -0
- package/esm/transactions/ethereum.js.map +1 -0
- package/esm/transactions/evm-cancellation.js +40 -0
- package/esm/transactions/evm-cancellation.js.map +1 -0
- package/esm/transactions/evm-local-signer.js +202 -0
- package/esm/transactions/evm-local-signer.js.map +1 -0
- package/esm/transactions/evm-submission.js +187 -0
- package/esm/transactions/evm-submission.js.map +1 -0
- package/esm/transactions/prepared-evm.js +194 -0
- package/esm/transactions/prepared-evm.js.map +1 -0
- package/esm/transactions/syscoin-core.js +691 -0
- package/esm/transactions/syscoin-core.js.map +1 -0
- package/esm/trezor/connect.js +19 -2
- package/esm/trezor/connect.js.map +1 -1
- package/esm/trezor/index.js +38 -16
- package/esm/trezor/index.js.map +1 -1
- package/esm/types.js.map +1 -1
- package/esm/utils/excluded-utxos.js +53 -0
- package/esm/utils/excluded-utxos.js.map +1 -0
- package/esm/utils/owned-blockbook-account.js +9 -0
- package/esm/utils/owned-blockbook-account.js.map +1 -0
- package/esm/utils/psbt.js +32 -0
- package/esm/utils/psbt.js.map +1 -0
- package/esm/utils/watch-descriptor.js +138 -0
- package/esm/utils/watch-descriptor.js.map +1 -0
- package/package.json +17 -11
- package/types/current-vault-refusal.d.ts +2 -0
- package/types/evm-fees.d.ts +25 -0
- package/types/hardware-transaction-authority.d.ts +5 -0
- package/types/index.d.ts +3 -3
- package/types/keyring-core.d.ts +48 -44
- package/types/keyring-host.d.ts +46 -0
- package/types/keyring-manager.d.ts +14 -7
- package/types/ledger/dmk-host.d.ts +7 -0
- package/types/ledger/dmk-selected-host.d.ts +7 -0
- package/types/ledger/dmk-session.d.ts +10 -2
- package/types/ledger/host-types.d.ts +4 -1
- package/types/ledger/index.d.ts +1 -1
- package/types/ledger/types.d.ts +3 -2
- package/types/ledger-host.d.ts +6 -2
- package/types/providers.d.ts +1 -1
- package/types/software.d.ts +7 -19
- package/types/storage-core.d.ts +3 -1
- package/types/transactions/ethereum.d.ts +14 -11
- package/types/transactions/evm-cancellation.d.ts +10 -0
- package/types/transactions/evm-local-signer.d.ts +2 -2
- package/types/transactions/evm-submission.d.ts +11 -4
- package/types/transactions/hardware-psbt.d.ts +1 -1
- package/types/transactions/index.d.ts +3 -2
- package/types/transactions/prepared-evm.d.ts +4 -1
- package/types/transactions/syscoin-core.d.ts +48 -21
- package/types/trezor/connect.d.ts +6 -3
- package/types/trezor/index.d.ts +4 -3
- package/types/types.d.ts +95 -63
- package/types/utils/owned-blockbook-account.d.ts +3 -0
- package/cjs/hardware-wallet-manager-singleton.js +0 -34
- package/cjs/hardware-wallet-manager-singleton.js.map +0 -1
- package/cjs/storage.js +0 -20
- package/cjs/storage.js.map +0 -1
- package/cjs/transactions/syscoin.js +0 -16
- package/cjs/transactions/syscoin.js.map +0 -1
- package/cjs/utils/blockbook-cache.js +0 -76
- package/cjs/utils/blockbook-cache.js.map +0 -1
- package/types/hardware-wallet-manager-singleton.d.ts +0 -19
- package/types/storage.d.ts +0 -5
- package/types/transactions/syscoin.d.ts +0 -9
- package/types/utils/blockbook-cache.d.ts +0 -6
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { Transaction } from 'ethers/transaction';
|
|
2
|
+
const capturedBoundaries = new WeakSet();
|
|
3
|
+
function assertSynchronous(check) {
|
|
4
|
+
const result = check();
|
|
5
|
+
if (result !== undefined) {
|
|
6
|
+
if (result &&
|
|
7
|
+
(typeof result === 'object' || typeof result === 'function')) {
|
|
8
|
+
void Promise.resolve(result).catch(() => undefined);
|
|
9
|
+
}
|
|
10
|
+
throw new Error('EVM submission guard must return undefined synchronously');
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/** Capture once, before RPC or device work. Never reread host capabilities later. */
|
|
14
|
+
export function captureEvmSubmission(input, assertCurrent, capture) {
|
|
15
|
+
const context = Object.freeze({
|
|
16
|
+
account: Object.freeze({ ...input.account }),
|
|
17
|
+
network: Object.freeze({ ...input.network }),
|
|
18
|
+
operation: input.operation,
|
|
19
|
+
...(input.originalHash !== undefined
|
|
20
|
+
? { originalHash: input.originalHash }
|
|
21
|
+
: {}),
|
|
22
|
+
});
|
|
23
|
+
assertSynchronous(assertCurrent);
|
|
24
|
+
if (typeof capture !== 'function')
|
|
25
|
+
throw new TypeError('A durable EVM submission lifecycle is required');
|
|
26
|
+
const lifecycle = capture(context);
|
|
27
|
+
const hostGuard = lifecycle?.assertCurrent;
|
|
28
|
+
const persistSigned = lifecycle?.persistSigned;
|
|
29
|
+
if (!lifecycle ||
|
|
30
|
+
typeof lifecycle !== 'object' ||
|
|
31
|
+
typeof hostGuard !== 'function' ||
|
|
32
|
+
typeof persistSigned !== 'function') {
|
|
33
|
+
if (lifecycle && typeof lifecycle.then === 'function') {
|
|
34
|
+
void Promise.resolve(lifecycle).catch(() => undefined);
|
|
35
|
+
}
|
|
36
|
+
throw new TypeError('EVM submission lifecycle must be captured synchronously');
|
|
37
|
+
}
|
|
38
|
+
const guard = () => {
|
|
39
|
+
assertSynchronous(assertCurrent);
|
|
40
|
+
assertSynchronous(hostGuard);
|
|
41
|
+
};
|
|
42
|
+
guard();
|
|
43
|
+
const boundary = Object.freeze({
|
|
44
|
+
context,
|
|
45
|
+
assertCurrent: guard,
|
|
46
|
+
persistSigned,
|
|
47
|
+
});
|
|
48
|
+
capturedBoundaries.add(boundary);
|
|
49
|
+
return boundary;
|
|
50
|
+
}
|
|
51
|
+
/** Refuse any new signature or dispatch without a captured durable port. */
|
|
52
|
+
export function assertDurableEvmSubmission(boundary) {
|
|
53
|
+
if (!capturedBoundaries.has(boundary))
|
|
54
|
+
throw new TypeError('A captured durable EVM submission is required');
|
|
55
|
+
boundary.assertCurrent();
|
|
56
|
+
}
|
|
57
|
+
const failures = new WeakMap();
|
|
58
|
+
/** Only local stage evidence can label an error as a possibly dispatched send. */
|
|
59
|
+
export function evmSubmissionFailure(error) {
|
|
60
|
+
return ((error && (typeof error === 'object' || typeof error === 'function')
|
|
61
|
+
? failures.get(error)
|
|
62
|
+
: undefined) ?? { transactionNotBroadcast: true });
|
|
63
|
+
}
|
|
64
|
+
/** Preserve local evidence when an existing public API wraps its Error object. */
|
|
65
|
+
export function copyEvmSubmissionFailure(source, target) {
|
|
66
|
+
if (source && (typeof source === 'object' || typeof source === 'function')) {
|
|
67
|
+
const failure = failures.get(source);
|
|
68
|
+
if (failure)
|
|
69
|
+
failures.set(target, failure);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/** Compare signed wire bytes with the complete envelope captured before signing. */
|
|
73
|
+
export function assertSignedEvmTransactionMatches(rawTransaction, expectedUnsignedTransaction, expectedFrom) {
|
|
74
|
+
if (typeof rawTransaction !== 'string' ||
|
|
75
|
+
typeof expectedUnsignedTransaction !== 'string')
|
|
76
|
+
throw new TypeError('EVM transaction bytes must be strings');
|
|
77
|
+
const expected = Transaction.from(expectedUnsignedTransaction);
|
|
78
|
+
const signed = Transaction.from(rawTransaction);
|
|
79
|
+
if (expected.isSigned() ||
|
|
80
|
+
expected.unsignedSerialized !== expectedUnsignedTransaction ||
|
|
81
|
+
!signed.isSigned() ||
|
|
82
|
+
signed.serialized !== rawTransaction ||
|
|
83
|
+
signed.unsignedSerialized !== expectedUnsignedTransaction ||
|
|
84
|
+
(expectedFrom !== undefined &&
|
|
85
|
+
signed.from?.toLowerCase() !== expectedFrom.toLowerCase()))
|
|
86
|
+
throw new Error('Signed EVM transaction does not match expected unsigned envelope');
|
|
87
|
+
return signed;
|
|
88
|
+
}
|
|
89
|
+
/** Submit software-signed bytes through the captured durable boundary. */
|
|
90
|
+
export function submitSignedEvmTransaction(rawTransaction, broadcast, boundary, beforeBroadcast, expectedUnsignedTransaction) {
|
|
91
|
+
return submit(rawTransaction, broadcast, boundary, beforeBroadcast, expectedUnsignedTransaction, { mode: 'software' });
|
|
92
|
+
}
|
|
93
|
+
/** @internal Device signatures always require a fresh live chain probe after persistence. */
|
|
94
|
+
export function submitSignedHardwareEvmTransaction(rawTransaction, broadcast, boundary, beforeBroadcast, expectedUnsignedTransaction, verifyCurrentChain) {
|
|
95
|
+
return submit(rawTransaction, broadcast, boundary, beforeBroadcast, expectedUnsignedTransaction, { mode: 'hardware', verifyCurrentChain });
|
|
96
|
+
}
|
|
97
|
+
const hardwareAccountTypes = ['Ledger', 'Trezor'];
|
|
98
|
+
/** The common signed-byte dispatch boundary. No nonce/fee selection or retry. */
|
|
99
|
+
async function submit(rawTransaction, broadcast, boundary, beforeBroadcast, expectedUnsignedTransaction, admission) {
|
|
100
|
+
let dispatched = false;
|
|
101
|
+
let hash;
|
|
102
|
+
try {
|
|
103
|
+
const check = () => assertDurableEvmSubmission(boundary);
|
|
104
|
+
check();
|
|
105
|
+
const hardwareAccount = hardwareAccountTypes.some((type) => type === boundary.context.account.type);
|
|
106
|
+
if (hardwareAccount !== (admission.mode === 'hardware') ||
|
|
107
|
+
(admission.mode === 'hardware' &&
|
|
108
|
+
typeof admission.verifyCurrentChain !== 'function'))
|
|
109
|
+
throw new TypeError('EVM submission does not match the signing mode');
|
|
110
|
+
const tx = assertSignedEvmTransactionMatches(rawTransaction, expectedUnsignedTransaction, boundary.context.account.address);
|
|
111
|
+
if (tx.chainId !== BigInt(boundary.context.network.chainId))
|
|
112
|
+
throw new Error('Signed EVM submission does not match captured context');
|
|
113
|
+
hash = tx.hash;
|
|
114
|
+
const record = Object.freeze({
|
|
115
|
+
context: boundary.context,
|
|
116
|
+
rawTransaction,
|
|
117
|
+
hash,
|
|
118
|
+
from: tx.from,
|
|
119
|
+
chainId: tx.chainId.toString(),
|
|
120
|
+
nonce: tx.nonce,
|
|
121
|
+
type: tx.type,
|
|
122
|
+
});
|
|
123
|
+
const acknowledgement = boundary.persistSigned(record);
|
|
124
|
+
if (!acknowledgement || typeof acknowledgement.then !== 'function')
|
|
125
|
+
throw new TypeError('EVM signed persistence must return an acknowledgement Promise');
|
|
126
|
+
await acknowledgement;
|
|
127
|
+
check();
|
|
128
|
+
if (admission.mode === 'hardware') {
|
|
129
|
+
await admission.verifyCurrentChain();
|
|
130
|
+
check();
|
|
131
|
+
}
|
|
132
|
+
if (beforeBroadcast)
|
|
133
|
+
assertSynchronous(beforeBroadcast);
|
|
134
|
+
check();
|
|
135
|
+
dispatched = true;
|
|
136
|
+
return await broadcast(rawTransaction);
|
|
137
|
+
}
|
|
138
|
+
catch (cause) {
|
|
139
|
+
const failure = Object.freeze({
|
|
140
|
+
transactionNotBroadcast: !dispatched,
|
|
141
|
+
...(hash ? { signedTransactionHash: hash } : {}),
|
|
142
|
+
});
|
|
143
|
+
// Preserve provider Error identity/class and its data/shortMessage/reason/
|
|
144
|
+
// cause contract. Only the locally owned submission fields are overwritten.
|
|
145
|
+
let error = cause instanceof Error
|
|
146
|
+
? cause
|
|
147
|
+
: new Error(typeof cause === 'string' ? cause : 'EVM submission failed');
|
|
148
|
+
if (!(cause instanceof Error) && cause && typeof cause === 'object') {
|
|
149
|
+
// JSON-RPC adapters can reject with a plain error object. Copy data
|
|
150
|
+
// descriptors without invoking accessors or accepting its stage claim.
|
|
151
|
+
for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(cause))) {
|
|
152
|
+
if (key !== 'transactionNotBroadcast' &&
|
|
153
|
+
key !== 'signedTransactionHash' &&
|
|
154
|
+
'value' in descriptor) {
|
|
155
|
+
Object.defineProperty(error, key, descriptor);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
const stageDescriptors = Object.fromEntries(Object.entries({ ...failure, signedTransactionHash: hash }).map(([key, value]) => [
|
|
160
|
+
key,
|
|
161
|
+
{ value, enumerable: true, configurable: true, writable: true },
|
|
162
|
+
]));
|
|
163
|
+
try {
|
|
164
|
+
Object.defineProperties(error, stageDescriptors);
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
// A frozen provider Error may have non-configurable forged stage fields.
|
|
168
|
+
// Retain its original details/cause without allowing those fields to win.
|
|
169
|
+
const wrapped = new Error(error.message);
|
|
170
|
+
wrapped.name = error.name;
|
|
171
|
+
const descriptors = Object.getOwnPropertyDescriptors(error);
|
|
172
|
+
delete descriptors.transactionNotBroadcast;
|
|
173
|
+
delete descriptors.signedTransactionHash;
|
|
174
|
+
Object.defineProperties(wrapped, descriptors);
|
|
175
|
+
if (!Object.prototype.hasOwnProperty.call(wrapped, 'cause'))
|
|
176
|
+
Object.defineProperty(wrapped, 'cause', {
|
|
177
|
+
value: error,
|
|
178
|
+
configurable: true,
|
|
179
|
+
});
|
|
180
|
+
Object.defineProperties(wrapped, stageDescriptors);
|
|
181
|
+
error = wrapped;
|
|
182
|
+
}
|
|
183
|
+
failures.set(error, failure);
|
|
184
|
+
throw error;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
//# sourceMappingURL=evm-submission.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evm-submission.js","sourceRoot":"","sources":["../../../src/transactions/evm-submission.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AA6CjD,MAAM,kBAAkB,GAAG,IAAI,OAAO,EAAyB,CAAC;AAEhE,SAAS,iBAAiB,CAAC,KAAiB;IAC1C,MAAM,MAAM,GAAY,KAAK,EAAE,CAAC;IAChC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,IACE,MAAM;YACN,CAAC,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,KAAK,UAAU,CAAC,EAC5D,CAAC;YACD,KAAK,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QACtD,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAC9E,CAAC;AACH,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,oBAAoB,CAClC,KAA2B,EAC3B,aAAyB,EACzB,OAA6B;IAE7B,MAAM,OAAO,GAAyB,MAAM,CAAC,MAAM,CAAC;QAClD,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC;QAC5C,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC;QAC5C,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,GAAG,CAAC,KAAK,CAAC,Y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
|
+
import { keccak256 } from 'ethers/crypto';
|
|
3
|
+
import { Transaction } from 'ethers/transaction';
|
|
4
|
+
import { assertEvmGasLimit } from '../evm-fees';
|
|
5
|
+
import { signTransaction } from './evm-local-signer';
|
|
6
|
+
import { assertSignedEvmTransactionMatches } from './evm-submission';
|
|
7
|
+
const UINT256 = (1n << 256n) - 1n;
|
|
8
|
+
const UINT64 = (1n << 64n) - 1n;
|
|
9
|
+
const MAX_DATA_BYTES = 16 * 1024;
|
|
10
|
+
const invalid = () => new TypeError('Invalid prepared EVM signing request');
|
|
11
|
+
/** Snapshot values without invoking accessors or accepting hidden fields. */
|
|
12
|
+
function record(value, keys) {
|
|
13
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
14
|
+
throw invalid();
|
|
15
|
+
const prototype = Object.getPrototypeOf(value);
|
|
16
|
+
if (prototype !== Object.prototype && prototype !== null)
|
|
17
|
+
throw invalid();
|
|
18
|
+
const names = Reflect.ownKeys(value);
|
|
19
|
+
if (names.length !== keys.length ||
|
|
20
|
+
names.some((key) => typeof key !== 'string' || !keys.includes(key)))
|
|
21
|
+
throw invalid();
|
|
22
|
+
const result = Object.create(null);
|
|
23
|
+
for (const key of keys) {
|
|
24
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
25
|
+
if (!descriptor ||
|
|
26
|
+
!descriptor.enumerable ||
|
|
27
|
+
!Object.prototype.hasOwnProperty.call(descriptor, 'value'))
|
|
28
|
+
throw invalid();
|
|
29
|
+
result[key] = descriptor.value;
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
function quantity(value, maximum = UINT256, positive = false) {
|
|
34
|
+
if (typeof value !== 'string' || !/^(0|[1-9][0-9]{0,77})$/.test(value))
|
|
35
|
+
throw invalid();
|
|
36
|
+
const parsed = BigInt(value);
|
|
37
|
+
if (parsed > maximum || (positive && parsed === 0n))
|
|
38
|
+
throw invalid();
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
function address(value) {
|
|
42
|
+
if (typeof value !== 'string' || !/^0x[0-9a-fA-F]{40}$/.test(value))
|
|
43
|
+
throw invalid();
|
|
44
|
+
let canonical;
|
|
45
|
+
try {
|
|
46
|
+
canonical = getAddress(value);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
throw invalid();
|
|
50
|
+
}
|
|
51
|
+
if (/^0x0{40}$/i.test(canonical))
|
|
52
|
+
throw invalid();
|
|
53
|
+
return canonical;
|
|
54
|
+
}
|
|
55
|
+
export function snapshotPreparedEvmRequest(input) {
|
|
56
|
+
const root = record(input, ['account', 'network', 'transaction']);
|
|
57
|
+
const account = record(root.account, ['id', 'type', 'expectedAddress']);
|
|
58
|
+
if (!Number.isSafeInteger(account.id) ||
|
|
59
|
+
account.id < 0 ||
|
|
60
|
+
account.id > 0x7fffffff ||
|
|
61
|
+
(account.type !== 'HDAccount' && account.type !== 'Imported'))
|
|
62
|
+
throw invalid();
|
|
63
|
+
const network = record(root.network, ['kind', 'chainId', 'slip44', 'url']);
|
|
64
|
+
if (network.kind !== 'ethereum' ||
|
|
65
|
+
network.slip44 !== 60 ||
|
|
66
|
+
typeof network.url !== 'string' ||
|
|
67
|
+
!network.url ||
|
|
68
|
+
network.url.length > 4096 ||
|
|
69
|
+
network.url.trim() !== network.url ||
|
|
70
|
+
// eslint-disable-next-line no-control-regex -- Reject endpoint control characters and lone surrogates.
|
|
71
|
+
/[\uD800-\uDFFF\u0000-\u001f\u007f]/u.test(network.url))
|
|
72
|
+
throw invalid();
|
|
73
|
+
const chainId = quantity(network.chainId, UINT256, true);
|
|
74
|
+
// Read the discriminator from a data property before choosing the exact schema.
|
|
75
|
+
if (!root.transaction || typeof root.transaction !== 'object')
|
|
76
|
+
throw invalid();
|
|
77
|
+
const typeDescriptor = Object.getOwnPropertyDescriptor(root.transaction, 'type');
|
|
78
|
+
if (!typeDescriptor ||
|
|
79
|
+
!Object.prototype.hasOwnProperty.call(typeDescriptor, 'value'))
|
|
80
|
+
throw invalid();
|
|
81
|
+
const type = typeDescriptor.value;
|
|
82
|
+
if (type !== 0 && type !== 2)
|
|
83
|
+
throw invalid();
|
|
84
|
+
const fields = [
|
|
85
|
+
'type',
|
|
86
|
+
'from',
|
|
87
|
+
'to',
|
|
88
|
+
'chainId',
|
|
89
|
+
'nonce',
|
|
90
|
+
'value',
|
|
91
|
+
'gasLimit',
|
|
92
|
+
'data',
|
|
93
|
+
];
|
|
94
|
+
const transaction = record(root.transaction, type === 0
|
|
95
|
+
? [...fields, 'gasPrice']
|
|
96
|
+
: [...fields, 'maxFeePerGas', 'maxPriorityFeePerGas']);
|
|
97
|
+
const from = address(transaction.from);
|
|
98
|
+
const expectedAddress = address(account.expectedAddress);
|
|
99
|
+
if (from !== expectedAddress ||
|
|
100
|
+
quantity(transaction.chainId, UINT256, true) !== chainId)
|
|
101
|
+
throw invalid();
|
|
102
|
+
if (typeof transaction.data !== 'string' ||
|
|
103
|
+
transaction.data.length > 2 + 2 * MAX_DATA_BYTES ||
|
|
104
|
+
!/^0x(?:[0-9a-fA-F]{2})*$/.test(transaction.data))
|
|
105
|
+
throw invalid();
|
|
106
|
+
const common = {
|
|
107
|
+
from,
|
|
108
|
+
to: address(transaction.to),
|
|
109
|
+
chainId,
|
|
110
|
+
nonce: quantity(transaction.nonce, BigInt(Number.MAX_SAFE_INTEGER)),
|
|
111
|
+
value: quantity(transaction.value),
|
|
112
|
+
gasLimit: quantity(transaction.gasLimit, UINT64, true),
|
|
113
|
+
data: transaction.data.toLowerCase(),
|
|
114
|
+
};
|
|
115
|
+
assertEvmGasLimit(BigInt(common.gasLimit), BigInt(chainId));
|
|
116
|
+
const fees = type === 0
|
|
117
|
+
? { type: 0, gasPrice: quantity(transaction.gasPrice) }
|
|
118
|
+
: {
|
|
119
|
+
type: 2,
|
|
120
|
+
maxFeePerGas: quantity(transaction.maxFeePerGas),
|
|
121
|
+
maxPriorityFeePerGas: quantity(transaction.maxPriorityFeePerGas),
|
|
122
|
+
};
|
|
123
|
+
if (fees.type === 2 &&
|
|
124
|
+
BigInt(fees.maxPriorityFeePerGas) > BigInt(fees.maxFeePerGas))
|
|
125
|
+
throw invalid();
|
|
126
|
+
const maximumFee = BigInt(common.gasLimit) *
|
|
127
|
+
BigInt(fees.type === 0 ? fees.gasPrice : fees.maxFeePerGas);
|
|
128
|
+
if (maximumFee + BigInt(common.value) > UINT256)
|
|
129
|
+
throw invalid();
|
|
130
|
+
return Object.freeze({
|
|
131
|
+
account: Object.freeze({
|
|
132
|
+
id: account.id,
|
|
133
|
+
type: account.type,
|
|
134
|
+
expectedAddress,
|
|
135
|
+
}),
|
|
136
|
+
network: Object.freeze({
|
|
137
|
+
kind: 'ethereum',
|
|
138
|
+
chainId,
|
|
139
|
+
slip44: 60,
|
|
140
|
+
url: network.url,
|
|
141
|
+
}),
|
|
142
|
+
transaction: Object.freeze({ ...common, ...fees }),
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
export function preparedEvmGuard(input) {
|
|
146
|
+
const options = record(input, ['assertCurrent']);
|
|
147
|
+
if (typeof options.assertCurrent !== 'function')
|
|
148
|
+
throw invalid();
|
|
149
|
+
const guard = options.assertCurrent;
|
|
150
|
+
return () => {
|
|
151
|
+
const result = guard();
|
|
152
|
+
if (result !== undefined) {
|
|
153
|
+
// Consume a rejected async guard without allowing it to authorize signing.
|
|
154
|
+
if (result !== null &&
|
|
155
|
+
(typeof result === 'object' || typeof result === 'function'))
|
|
156
|
+
void Promise.resolve(result).catch(() => undefined);
|
|
157
|
+
throw new TypeError('Prepared EVM signing guard must return undefined synchronously');
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
/** Internal, network-free signing. The key never becomes part of the result. */
|
|
162
|
+
export function signPreparedEvmEnvelope(transaction, privateKey) {
|
|
163
|
+
const unsigned = {
|
|
164
|
+
type: transaction.type,
|
|
165
|
+
to: transaction.to,
|
|
166
|
+
chainId: BigInt(transaction.chainId),
|
|
167
|
+
nonce: Number(transaction.nonce),
|
|
168
|
+
value: BigInt(transaction.value),
|
|
169
|
+
gasLimit: BigInt(transaction.gasLimit),
|
|
170
|
+
data: transaction.data,
|
|
171
|
+
...(transaction.type === 0
|
|
172
|
+
? { gasPrice: BigInt(transaction.gasPrice) }
|
|
173
|
+
: {
|
|
174
|
+
maxFeePerGas: BigInt(transaction.maxFeePerGas),
|
|
175
|
+
maxPriorityFeePerGas: BigInt(transaction.maxPriorityFeePerGas),
|
|
176
|
+
}),
|
|
177
|
+
};
|
|
178
|
+
const expectedUnsigned = Transaction.from(unsigned).unsignedSerialized;
|
|
179
|
+
const rawTransaction = signTransaction(unsigned, privateKey);
|
|
180
|
+
const signed = assertSignedEvmTransactionMatches(rawTransaction, expectedUnsigned, transaction.from);
|
|
181
|
+
if (signed.hash !== keccak256(rawTransaction))
|
|
182
|
+
throw new Error('Prepared EVM signature does not match requested transaction');
|
|
183
|
+
return Object.freeze({
|
|
184
|
+
expectedUnsigned,
|
|
185
|
+
signed: Object.freeze({
|
|
186
|
+
rawTransaction,
|
|
187
|
+
hash: signed.hash,
|
|
188
|
+
unsignedHash: signed.unsignedHash,
|
|
189
|
+
from: signed.from,
|
|
190
|
+
transaction,
|
|
191
|
+
}),
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=prepared-evm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepared-evm.js","sourceRoot":"","sources":["../../../src/transactions/prepared-evm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,iCAAiC,EA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