viem 0.0.0-main.20240306T090432 → 0.0.0-main.20240306T211153
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/_cjs/chains/opStack/actions/buildProveWithdrawal.js +22 -2
- package/_cjs/chains/opStack/actions/buildProveWithdrawal.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_esm/chains/opStack/actions/buildProveWithdrawal.js +29 -1
- package/_esm/chains/opStack/actions/buildProveWithdrawal.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_types/chains/opStack/actions/buildProveWithdrawal.d.ts +2 -0
- package/_types/chains/opStack/actions/buildProveWithdrawal.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/chains/opStack/actions/buildProveWithdrawal.ts +31 -1
- package/errors/version.ts +1 -1
- package/package.json +1 -1
@@ -1,8 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.buildProveWithdrawal = void 0;
|
3
|
+
exports.maybeAddProofNode = exports.buildProveWithdrawal = void 0;
|
4
4
|
const getBlock_js_1 = require("../../../actions/public/getBlock.js");
|
5
5
|
const getProof_js_1 = require("../../../actions/public/getProof.js");
|
6
|
+
const fromRlp_js_1 = require("../../../utils/encoding/fromRlp.js");
|
7
|
+
const toRlp_js_1 = require("../../../utils/encoding/toRlp.js");
|
8
|
+
const keccak256_js_1 = require("../../../utils/hash/keccak256.js");
|
6
9
|
const contracts_js_1 = require("../contracts.js");
|
7
10
|
const getWithdrawalHashStorageSlot_js_1 = require("../utils/getWithdrawalHashStorageSlot.js");
|
8
11
|
const outputRootProofVersion = '0x0000000000000000000000000000000000000000000000000000000000000000';
|
@@ -31,9 +34,26 @@ async function buildProveWithdrawal(client, args) {
|
|
31
34
|
version: outputRootProofVersion,
|
32
35
|
},
|
33
36
|
targetChain: chain,
|
34
|
-
withdrawalProof: proof.storageProof[0].proof,
|
37
|
+
withdrawalProof: maybeAddProofNode((0, keccak256_js_1.keccak256)(slot), proof.storageProof[0].proof),
|
35
38
|
withdrawal,
|
36
39
|
};
|
37
40
|
}
|
38
41
|
exports.buildProveWithdrawal = buildProveWithdrawal;
|
42
|
+
function maybeAddProofNode(key, proof) {
|
43
|
+
const lastProofRlp = proof[proof.length - 1];
|
44
|
+
const lastProof = (0, fromRlp_js_1.fromRlp)(lastProofRlp);
|
45
|
+
if (lastProof.length !== 17)
|
46
|
+
return proof;
|
47
|
+
const modifiedProof = [...proof];
|
48
|
+
for (const item of lastProof) {
|
49
|
+
if (!Array.isArray(item))
|
50
|
+
continue;
|
51
|
+
const suffix = item[0].slice(3);
|
52
|
+
if (typeof suffix !== 'string' || !key.endsWith(suffix))
|
53
|
+
continue;
|
54
|
+
modifiedProof.push((0, toRlp_js_1.toRlp)(item));
|
55
|
+
}
|
56
|
+
return modifiedProof;
|
57
|
+
}
|
58
|
+
exports.maybeAddProofNode = maybeAddProofNode;
|
39
59
|
//# sourceMappingURL=buildProveWithdrawal.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"buildProveWithdrawal.js","sourceRoot":"","sources":["../../../../chains/opStack/actions/buildProveWithdrawal.ts"],"names":[],"mappings":";;;AACA,qEAG4C;AAC5C,qEAG4C;
|
1
|
+
{"version":3,"file":"buildProveWithdrawal.js","sourceRoot":"","sources":["../../../../chains/opStack/actions/buildProveWithdrawal.ts"],"names":[],"mappings":";;;AACA,qEAG4C;AAC5C,qEAG4C;AAgB5C,mEAA4D;AAC5D,+DAAwD;AACxD,mEAA4D;AAC5D,kDAA2C;AAE3C,8FAGiD;AAIjD,MAAM,sBAAsB,GAC1B,oEAA6E,CAAA;AAiExE,KAAK,UAAU,oBAAoB,CAMxC,MAAyC,EACzC,IAKC;IAID,MAAM,EAAE,OAAO,EAAE,KAAK,GAAG,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAA;IAClE,MAAM,EAAE,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AI,IAAI,SAAS,EAAE,CAAC;QAE7B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;YAAE,SAAQ;QAQlC,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAC/B,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC;YAAE,SAAQ;QACjE,aAAa,CAAC,IAAI,CAAC,IAAA,gBAAK,EAAC,IAAI,CAAC,CAAC,CAAA;IACjC,CAAC;IACD,OAAO,aAAa,CAAA;AACtB,CAAC;AArBD,8CAqBC"}
|
package/_cjs/errors/version.js
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
import { getBlock, } from '../../../actions/public/getBlock.js';
|
2
2
|
import { getProof, } from '../../../actions/public/getProof.js';
|
3
|
+
import {} from '../../../types/misc.js';
|
4
|
+
import { fromRlp } from '../../../utils/encoding/fromRlp.js';
|
5
|
+
import { toRlp } from '../../../utils/encoding/toRlp.js';
|
6
|
+
import { keccak256 } from '../../../utils/hash/keccak256.js';
|
3
7
|
import { contracts } from '../contracts.js';
|
4
8
|
import { getWithdrawalHashStorageSlot, } from '../utils/getWithdrawalHashStorageSlot.js';
|
5
9
|
const outputRootProofVersion = '0x0000000000000000000000000000000000000000000000000000000000000000';
|
@@ -52,8 +56,32 @@ export async function buildProveWithdrawal(client, args) {
|
|
52
56
|
version: outputRootProofVersion,
|
53
57
|
},
|
54
58
|
targetChain: chain,
|
55
|
-
withdrawalProof: proof.storageProof[0].proof,
|
59
|
+
withdrawalProof: maybeAddProofNode(keccak256(slot), proof.storageProof[0].proof),
|
56
60
|
withdrawal,
|
57
61
|
};
|
58
62
|
}
|
63
|
+
export function maybeAddProofNode(key, proof) {
|
64
|
+
const lastProofRlp = proof[proof.length - 1];
|
65
|
+
const lastProof = fromRlp(lastProofRlp);
|
66
|
+
if (lastProof.length !== 17)
|
67
|
+
return proof;
|
68
|
+
const modifiedProof = [...proof];
|
69
|
+
for (const item of lastProof) {
|
70
|
+
// Find any nodes located inside of the branch node.
|
71
|
+
if (!Array.isArray(item))
|
72
|
+
continue;
|
73
|
+
// Check if the key inside the node matches the key we're looking for. We remove the first
|
74
|
+
// two characters (0x) and then we remove one more character (the first nibble) since this
|
75
|
+
// is the identifier for the type of node we're looking at. In this case we don't actually
|
76
|
+
// care what type of node it is because a branch node would only ever be the final proof
|
77
|
+
// element if (1) it includes the leaf node we're looking for or (2) it stores the value
|
78
|
+
// within itself. If (1) then this logic will work, if (2) then this won't find anything
|
79
|
+
// and we won't append any proof elements, which is exactly what we would want.
|
80
|
+
const suffix = item[0].slice(3);
|
81
|
+
if (typeof suffix !== 'string' || !key.endsWith(suffix))
|
82
|
+
continue;
|
83
|
+
modifiedProof.push(toRlp(item));
|
84
|
+
}
|
85
|
+
return modifiedProof;
|
86
|
+
}
|
59
87
|
//# sourceMappingURL=buildProveWithdrawal.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"buildProveWithdrawal.js","sourceRoot":"","sources":["../../../../chains/opStack/actions/buildProveWithdrawal.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,QAAQ,GACT,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAEL,QAAQ,GACT,MAAM,qCAAqC,CAAA;
|
1
|
+
{"version":3,"file":"buildProveWithdrawal.js","sourceRoot":"","sources":["../../../../chains/opStack/actions/buildProveWithdrawal.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,QAAQ,GACT,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAEL,QAAQ,GACT,MAAM,qCAAqC,CAAA;AAc5C,OAAO,EAAY,MAAM,wBAAwB,CAAA;AAEjD,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAA;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,kCAAkC,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;A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H,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,GAAW,EAAE,KAAqB;IAClE,MAAM,YAAY,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IAC5C,MAAM,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;IACvC,IAAI,SAAS,CAAC,MAAM,KAAK,EAAE;QAAE,OAAO,KAAK,CAAA;IAEzC,MAAM,aAAa,GAAG,CAAC,GAAG,KAAK,CAAC,CAAA;IAChC,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;QAC7B,oDAAoD;QACpD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;YAAE,SAAQ;QAClC,0FAA0F;QAC1F,0FAA0F;QAC1F,0FAA0F;QAC1F,wFAAwF;QACxF,wFAAwF;QACxF,wFAAwF;QACxF,+EAA+E;QAC/E,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAC/B,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC;YAAE,SAAQ;QACjE,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;IACjC,CAAC;IACD,OAAO,aAAa,CAAA;AACtB,CAAC"}
|
package/_esm/errors/version.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export const version = '0.0.0-main.
|
1
|
+
export const version = '0.0.0-main.20240306T211153';
|
2
2
|
//# sourceMappingURL=version.js.map
|
@@ -6,6 +6,7 @@ import type { Transport } from '../../../clients/transports/createTransport.js';
|
|
6
6
|
import type { ErrorType } from '../../../errors/utils.js';
|
7
7
|
import type { Account, DeriveAccount, GetAccountParameter } from '../../../types/account.js';
|
8
8
|
import type { Chain, DeriveChain, GetChainParameter } from '../../../types/chain.js';
|
9
|
+
import { type Hex } from '../../../types/misc.js';
|
9
10
|
import type { Prettify } from '../../../types/utils.js';
|
10
11
|
import type { Withdrawal } from '../types/withdrawal.js';
|
11
12
|
import { type GetWithdrawalHashStorageSlotErrorType } from '../utils/getWithdrawalHashStorageSlot.js';
|
@@ -45,4 +46,5 @@ export type BuildProveWithdrawalErrorType = GetBlockErrorType | GetProofErrorTyp
|
|
45
46
|
* })
|
46
47
|
*/
|
47
48
|
export declare function buildProveWithdrawal<chain extends Chain | undefined, account extends Account | undefined, chainOverride extends Chain | undefined = undefined, accountOverride extends Account | Address | undefined = undefined>(client: Client<Transport, chain, account>, args: BuildProveWithdrawalParameters<chain, account, chainOverride, accountOverride>): Promise<BuildProveWithdrawalReturnType<chain, account, chainOverride, accountOverride>>;
|
49
|
+
export declare function maybeAddProofNode(key: string, proof: readonly Hex[]): readonly `0x${string}`[];
|
48
50
|
//# sourceMappingURL=buildProveWithdrawal.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"buildProveWithdrawal.d.ts","sourceRoot":"","sources":["../../../../chains/opStack/actions/buildProveWithdrawal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAA;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gDAAgD,CAAA;AAC/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,KAAK,EACV,OAAO,EACP,aAAa,EACb,mBAAmB,EACpB,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,EACV,KAAK,EACL,WAAW,EACX,iBAAiB,EAClB,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;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CAClC,KAAK,EACL,OAAO,EACP,aAAa,EACb,eAAe,CAChB,GACA,OAAO,CACR,8BAA8B,CAAC,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,eAAe,CAAC,CAC/E,CAsCA;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,EAAE,4BAqBnE"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export declare const version = "0.0.0-main.
|
1
|
+
export declare const version = "0.0.0-main.20240306T211153";
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
@@ -20,7 +20,11 @@ import type {
|
|
20
20
|
DeriveChain,
|
21
21
|
GetChainParameter,
|
22
22
|
} from '../../../types/chain.js'
|
23
|
+
import { type Hex } from '../../../types/misc.js'
|
23
24
|
import type { Prettify } from '../../../types/utils.js'
|
25
|
+
import { fromRlp } from '../../../utils/encoding/fromRlp.js'
|
26
|
+
import { toRlp } from '../../../utils/encoding/toRlp.js'
|
27
|
+
import { keccak256 } from '../../../utils/hash/keccak256.js'
|
24
28
|
import { contracts } from '../contracts.js'
|
25
29
|
import type { Withdrawal } from '../types/withdrawal.js'
|
26
30
|
import {
|
@@ -138,7 +142,10 @@ export async function buildProveWithdrawal<
|
|
138
142
|
version: outputRootProofVersion,
|
139
143
|
},
|
140
144
|
targetChain: chain,
|
141
|
-
withdrawalProof:
|
145
|
+
withdrawalProof: maybeAddProofNode(
|
146
|
+
keccak256(slot),
|
147
|
+
proof.storageProof[0].proof,
|
148
|
+
),
|
142
149
|
withdrawal,
|
143
150
|
} as unknown as BuildProveWithdrawalReturnType<
|
144
151
|
chain,
|
@@ -147,3 +154,26 @@ export async function buildProveWithdrawal<
|
|
147
154
|
accountOverride
|
148
155
|
>
|
149
156
|
}
|
157
|
+
|
158
|
+
export function maybeAddProofNode(key: string, proof: readonly Hex[]) {
|
159
|
+
const lastProofRlp = proof[proof.length - 1]
|
160
|
+
const lastProof = fromRlp(lastProofRlp)
|
161
|
+
if (lastProof.length !== 17) return proof
|
162
|
+
|
163
|
+
const modifiedProof = [...proof]
|
164
|
+
for (const item of lastProof) {
|
165
|
+
// Find any nodes located inside of the branch node.
|
166
|
+
if (!Array.isArray(item)) continue
|
167
|
+
// Check if the key inside the node matches the key we're looking for. We remove the first
|
168
|
+
// two characters (0x) and then we remove one more character (the first nibble) since this
|
169
|
+
// is the identifier for the type of node we're looking at. In this case we don't actually
|
170
|
+
// care what type of node it is because a branch node would only ever be the final proof
|
171
|
+
// element if (1) it includes the leaf node we're looking for or (2) it stores the value
|
172
|
+
// within itself. If (1) then this logic will work, if (2) then this won't find anything
|
173
|
+
// and we won't append any proof elements, which is exactly what we would want.
|
174
|
+
const suffix = item[0].slice(3)
|
175
|
+
if (typeof suffix !== 'string' || !key.endsWith(suffix)) continue
|
176
|
+
modifiedProof.push(toRlp(item))
|
177
|
+
}
|
178
|
+
return modifiedProof
|
179
|
+
}
|
package/errors/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = '0.0.0-main.
|
1
|
+
export const version = '0.0.0-main.20240306T211153'
|
package/package.json
CHANGED