@wiimdy/openfunderse-sdk 0.1.3 → 1.0.0
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/dist/hash.js +4 -2
- package/dist/scope.d.ts +1 -1
- package/dist/scope.js +2 -1
- package/package.json +1 -1
package/dist/hash.js
CHANGED
|
@@ -60,6 +60,7 @@ export function snapshotHashFromUnordered(epochId, claimHashes) {
|
|
|
60
60
|
return snapshotHash(epochId, orderedClaimHashes);
|
|
61
61
|
}
|
|
62
62
|
const MERKLE_NODE_PAIR = parseAbiParameters("bytes32 a, bytes32 b");
|
|
63
|
+
const EPOCH_STATE_HASH_INPUT = parseAbiParameters("uint64 epochId,bytes32 merkleRoot");
|
|
63
64
|
function merkleHashPair(a, b) {
|
|
64
65
|
const left = a.toLowerCase() < b.toLowerCase() ? a : b;
|
|
65
66
|
const right = left === a ? b : a;
|
|
@@ -97,12 +98,13 @@ export function merkleRootFromUnorderedLeaves(leaves) {
|
|
|
97
98
|
*/
|
|
98
99
|
export function epochStateHash(epochId, orderedClaimHashes) {
|
|
99
100
|
assertUint64(epochId, "epochId");
|
|
100
|
-
|
|
101
|
+
const root = merkleRoot(orderedClaimHashes);
|
|
102
|
+
return keccak256(encodeAbiParameters(EPOCH_STATE_HASH_INPUT, [epochId, root]));
|
|
101
103
|
}
|
|
102
104
|
export function epochStateHashFromUnordered(epochId, claimHashes) {
|
|
103
105
|
assertUint64(epochId, "epochId");
|
|
104
106
|
const ordered = canonicalOrderedClaimHashes(claimHashes);
|
|
105
|
-
return
|
|
107
|
+
return epochStateHash(epochId, ordered);
|
|
106
108
|
}
|
|
107
109
|
export function merkleProof(orderedLeaves, leaf) {
|
|
108
110
|
assertStrictlySortedHex(orderedLeaves, "orderedLeaves");
|
package/dist/scope.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Hex, ProtocolScope } from "./types.js";
|
|
2
2
|
export declare function canonicalScope(input: ProtocolScope): ProtocolScope;
|
|
3
|
-
export declare function scopeKey(input: ProtocolScope):
|
|
3
|
+
export declare function scopeKey(input: ProtocolScope): Hex;
|
|
4
4
|
export declare function assertSameScope(expected: ProtocolScope, received: ProtocolScope): void;
|
|
5
5
|
export declare function scopedSnapshotHash(scope: ProtocolScope, snapshotHash: Hex): Hex;
|
package/dist/scope.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { encodeAbiParameters, keccak256, parseAbiParameters } from "viem";
|
|
2
|
+
const SCOPE_KEY_INPUT = parseAbiParameters("string fundId,string roomId,uint64 epochId");
|
|
2
3
|
function normalizeScopeText(value) {
|
|
3
4
|
return value.normalize("NFC").trim();
|
|
4
5
|
}
|
|
@@ -11,7 +12,7 @@ export function canonicalScope(input) {
|
|
|
11
12
|
}
|
|
12
13
|
export function scopeKey(input) {
|
|
13
14
|
const v = canonicalScope(input);
|
|
14
|
-
return
|
|
15
|
+
return keccak256(encodeAbiParameters(SCOPE_KEY_INPUT, [v.fundId, v.roomId, v.epochId]));
|
|
15
16
|
}
|
|
16
17
|
export function assertSameScope(expected, received) {
|
|
17
18
|
const left = scopeKey(expected);
|