@wiimdy/openfunderse-sdk 0.1.1 → 0.1.2
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/README.md +3 -3
- package/dist/attestation-verifier.d.ts +1 -2
- package/dist/attestation-verifier.js +1 -13
- package/dist/canonical.d.ts +2 -2
- package/dist/canonical.js +16 -11
- package/dist/eip712.d.ts +0 -56
- package/dist/eip712.js +0 -33
- package/dist/hash.d.ts +4 -2
- package/dist/hash.js +29 -17
- package/dist/relayer-utils.d.ts +6 -7
- package/dist/relayer-utils.js +29 -12
- package/dist/types.d.ts +12 -21
- package/package.json +4 -2
- package/dist/dist_bak_vercel_repro/attestation-verifier.d.ts +0 -11
- package/dist/dist_bak_vercel_repro/attestation-verifier.js +0 -60
- package/dist/dist_bak_vercel_repro/attestation.d.ts +0 -4
- package/dist/dist_bak_vercel_repro/attestation.js +0 -16
- package/dist/dist_bak_vercel_repro/canonical.d.ts +0 -3
- package/dist/dist_bak_vercel_repro/canonical.js +0 -37
- package/dist/dist_bak_vercel_repro/eip712.d.ts +0 -112
- package/dist/dist_bak_vercel_repro/eip712.js +0 -74
- package/dist/dist_bak_vercel_repro/erc1271.d.ts +0 -4
- package/dist/dist_bak_vercel_repro/erc1271.js +0 -24
- package/dist/dist_bak_vercel_repro/execution-data.d.ts +0 -3
- package/dist/dist_bak_vercel_repro/execution-data.js +0 -66
- package/dist/dist_bak_vercel_repro/hash.d.ts +0 -16
- package/dist/dist_bak_vercel_repro/hash.js +0 -67
- package/dist/dist_bak_vercel_repro/index.d.ts +0 -14
- package/dist/dist_bak_vercel_repro/index.js +0 -14
- package/dist/dist_bak_vercel_repro/nadfun-types.d.ts +0 -29
- package/dist/dist_bak_vercel_repro/nadfun-types.js +0 -1
- package/dist/dist_bak_vercel_repro/ordering.d.ts +0 -5
- package/dist/dist_bak_vercel_repro/ordering.js +0 -22
- package/dist/dist_bak_vercel_repro/relayer-utils.d.ts +0 -29
- package/dist/dist_bak_vercel_repro/relayer-utils.js +0 -108
- package/dist/dist_bak_vercel_repro/scope.d.ts +0 -5
- package/dist/dist_bak_vercel_repro/scope.js +0 -26
- package/dist/dist_bak_vercel_repro/types.d.ts +0 -106
- package/dist/dist_bak_vercel_repro/types.js +0 -1
- package/dist/dist_bak_vercel_repro/validate.d.ts +0 -2
- package/dist/dist_bak_vercel_repro/validate.js +0 -12
- package/dist/dist_bak_vercel_repro/weighted-attestation.d.ts +0 -19
- package/dist/dist_bak_vercel_repro/weighted-attestation.js +0 -62
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
export type Hex = `0x${string}`;
|
|
2
|
-
export type Address = `0x${string}`;
|
|
3
|
-
export interface ClaimPayload {
|
|
4
|
-
schemaId: string;
|
|
5
|
-
sourceType: string;
|
|
6
|
-
sourceRef: string;
|
|
7
|
-
selector: string;
|
|
8
|
-
extracted: string;
|
|
9
|
-
extractedType: string;
|
|
10
|
-
timestamp: bigint;
|
|
11
|
-
responseHash: Hex;
|
|
12
|
-
evidenceType: string;
|
|
13
|
-
evidenceURI: string;
|
|
14
|
-
crawler: Address;
|
|
15
|
-
notes?: string;
|
|
16
|
-
}
|
|
17
|
-
export interface TradeIntent {
|
|
18
|
-
intentVersion: string;
|
|
19
|
-
vault: Address;
|
|
20
|
-
action: "BUY" | "SELL";
|
|
21
|
-
tokenIn: Address;
|
|
22
|
-
tokenOut: Address;
|
|
23
|
-
amountIn: bigint;
|
|
24
|
-
minAmountOut: bigint;
|
|
25
|
-
deadline: bigint;
|
|
26
|
-
maxSlippageBps: bigint;
|
|
27
|
-
snapshotHash: Hex;
|
|
28
|
-
reason?: string;
|
|
29
|
-
}
|
|
30
|
-
export interface Eip712DomainInput {
|
|
31
|
-
name: string;
|
|
32
|
-
version: string;
|
|
33
|
-
chainId: bigint;
|
|
34
|
-
verifyingContract: Address;
|
|
35
|
-
}
|
|
36
|
-
export interface ProtocolScope {
|
|
37
|
-
fundId: string;
|
|
38
|
-
roomId: string;
|
|
39
|
-
epochId: bigint;
|
|
40
|
-
}
|
|
41
|
-
export type SubjectType = "CLAIM" | "INTENT";
|
|
42
|
-
export interface AttestationMeta {
|
|
43
|
-
verifier: Address;
|
|
44
|
-
expiresAt: bigint;
|
|
45
|
-
nonce: bigint;
|
|
46
|
-
}
|
|
47
|
-
export interface ClaimAttestationDraft extends AttestationMeta {
|
|
48
|
-
claimHash: Hex;
|
|
49
|
-
epochId: bigint;
|
|
50
|
-
}
|
|
51
|
-
export interface IntentAttestationDraft extends AttestationMeta {
|
|
52
|
-
intentHash: Hex;
|
|
53
|
-
}
|
|
54
|
-
export interface SignedAttestation<TSubject extends SubjectType, TMessage> {
|
|
55
|
-
subjectType: TSubject;
|
|
56
|
-
subjectHash: Hex;
|
|
57
|
-
message: TMessage;
|
|
58
|
-
signature: Hex;
|
|
59
|
-
}
|
|
60
|
-
export type ExecutionAction = "BUY" | "SELL";
|
|
61
|
-
export type ExecutionVenue = "NADFUN_BONDING_CURVE" | "NADFUN_DEX";
|
|
62
|
-
export interface NadfunExecutionDataV1 {
|
|
63
|
-
version: 1;
|
|
64
|
-
action: ExecutionAction;
|
|
65
|
-
venue: ExecutionVenue;
|
|
66
|
-
router: Address;
|
|
67
|
-
recipient: Address;
|
|
68
|
-
token: Address;
|
|
69
|
-
deadline: bigint;
|
|
70
|
-
amountOutMin: bigint;
|
|
71
|
-
extra: Hex;
|
|
72
|
-
}
|
|
73
|
-
export interface IntentConstraints {
|
|
74
|
-
allowlistHash: Hex;
|
|
75
|
-
maxSlippageBps: bigint;
|
|
76
|
-
maxNotional: bigint;
|
|
77
|
-
deadline: bigint;
|
|
78
|
-
}
|
|
79
|
-
export interface IntentExecutionRouteInput {
|
|
80
|
-
tokenIn: Address;
|
|
81
|
-
tokenOut: Address;
|
|
82
|
-
quoteAmountOut: bigint;
|
|
83
|
-
minAmountOut: bigint;
|
|
84
|
-
adapter: Address;
|
|
85
|
-
adapterData?: Hex;
|
|
86
|
-
adapterDataHash?: Hex;
|
|
87
|
-
}
|
|
88
|
-
export interface CoreExecutionRequestInput {
|
|
89
|
-
tokenIn: Address;
|
|
90
|
-
tokenOut: Address;
|
|
91
|
-
amountIn: bigint;
|
|
92
|
-
quoteAmountOut: bigint;
|
|
93
|
-
minAmountOut: bigint;
|
|
94
|
-
adapter: Address;
|
|
95
|
-
adapterData: Hex;
|
|
96
|
-
}
|
|
97
|
-
export interface CanonicalClaimRecord {
|
|
98
|
-
payload: ClaimPayload;
|
|
99
|
-
epochId: bigint;
|
|
100
|
-
claimHash: Hex;
|
|
101
|
-
}
|
|
102
|
-
export interface CanonicalIntentRecord {
|
|
103
|
-
intent: TradeIntent;
|
|
104
|
-
intentHash: Hex;
|
|
105
|
-
constraints: IntentConstraints;
|
|
106
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const UINT16_MAX = (1n << 16n) - 1n;
|
|
2
|
-
const UINT64_MAX = (1n << 64n) - 1n;
|
|
3
|
-
export function assertUint16(value, label) {
|
|
4
|
-
if (value < 0n || value > UINT16_MAX) {
|
|
5
|
-
throw new Error(`${label} must be uint16`);
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
export function assertUint64(value, label) {
|
|
9
|
-
if (value < 0n || value > UINT64_MAX) {
|
|
10
|
-
throw new Error(`${label} must be uint64`);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { Address } from "./types.js";
|
|
2
|
-
export interface ValidatorWeight {
|
|
3
|
-
validator: Address;
|
|
4
|
-
weight: bigint;
|
|
5
|
-
}
|
|
6
|
-
export interface WeightMapOptions {
|
|
7
|
-
allowZeroWeight?: boolean;
|
|
8
|
-
}
|
|
9
|
-
export interface WeightedThresholdState {
|
|
10
|
-
totalWeight: bigint;
|
|
11
|
-
attestedWeight: bigint;
|
|
12
|
-
thresholdWeight: bigint;
|
|
13
|
-
met: boolean;
|
|
14
|
-
}
|
|
15
|
-
export declare function buildValidatorWeightMap(entries: ValidatorWeight[], options?: WeightMapOptions): Map<string, bigint>;
|
|
16
|
-
export declare function totalValidatorWeight(weightMap: Map<string, bigint>): bigint;
|
|
17
|
-
export declare function attestedWeight(attesters: Address[], weightMap: Map<string, bigint>): bigint;
|
|
18
|
-
export declare function reachedWeightedThreshold(attesters: Address[], weightMap: Map<string, bigint>, thresholdWeight: bigint): boolean;
|
|
19
|
-
export declare function weightedThresholdState(attesters: Address[], weightMap: Map<string, bigint>, thresholdWeight: bigint): WeightedThresholdState;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
function toKey(address) {
|
|
2
|
-
return address.toLowerCase();
|
|
3
|
-
}
|
|
4
|
-
export function buildValidatorWeightMap(entries, options = {}) {
|
|
5
|
-
const allowZeroWeight = options.allowZeroWeight ?? false;
|
|
6
|
-
const map = new Map();
|
|
7
|
-
for (const entry of entries) {
|
|
8
|
-
if (entry.weight < 0n) {
|
|
9
|
-
throw new Error("weight must be non-negative");
|
|
10
|
-
}
|
|
11
|
-
if (!allowZeroWeight && entry.weight === 0n) {
|
|
12
|
-
throw new Error("weight must be positive");
|
|
13
|
-
}
|
|
14
|
-
const key = toKey(entry.validator);
|
|
15
|
-
if (map.has(key)) {
|
|
16
|
-
throw new Error(`duplicate validator weight entry: ${entry.validator}`);
|
|
17
|
-
}
|
|
18
|
-
map.set(key, entry.weight);
|
|
19
|
-
}
|
|
20
|
-
return map;
|
|
21
|
-
}
|
|
22
|
-
export function totalValidatorWeight(weightMap) {
|
|
23
|
-
let total = 0n;
|
|
24
|
-
for (const weight of weightMap.values()) {
|
|
25
|
-
total += weight;
|
|
26
|
-
}
|
|
27
|
-
return total;
|
|
28
|
-
}
|
|
29
|
-
export function attestedWeight(attesters, weightMap) {
|
|
30
|
-
let total = 0n;
|
|
31
|
-
const seen = new Set();
|
|
32
|
-
for (const attester of attesters) {
|
|
33
|
-
const key = toKey(attester);
|
|
34
|
-
if (seen.has(key))
|
|
35
|
-
continue;
|
|
36
|
-
seen.add(key);
|
|
37
|
-
const weight = weightMap.get(key);
|
|
38
|
-
if (weight !== undefined) {
|
|
39
|
-
total += weight;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return total;
|
|
43
|
-
}
|
|
44
|
-
export function reachedWeightedThreshold(attesters, weightMap, thresholdWeight) {
|
|
45
|
-
if (thresholdWeight <= 0n) {
|
|
46
|
-
throw new Error("thresholdWeight must be positive");
|
|
47
|
-
}
|
|
48
|
-
return attestedWeight(attesters, weightMap) >= thresholdWeight;
|
|
49
|
-
}
|
|
50
|
-
export function weightedThresholdState(attesters, weightMap, thresholdWeight) {
|
|
51
|
-
if (thresholdWeight <= 0n) {
|
|
52
|
-
throw new Error("thresholdWeight must be positive");
|
|
53
|
-
}
|
|
54
|
-
const totalWeight = totalValidatorWeight(weightMap);
|
|
55
|
-
const reachedWeight = attestedWeight(attesters, weightMap);
|
|
56
|
-
return {
|
|
57
|
-
totalWeight,
|
|
58
|
-
attestedWeight: reachedWeight,
|
|
59
|
-
thresholdWeight,
|
|
60
|
-
met: reachedWeight >= thresholdWeight
|
|
61
|
-
};
|
|
62
|
-
}
|