@gvnrdao/dh-sdk 0.0.340 → 0.0.341
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/browser/dist/833.browser.js +2 -0
- package/browser/dist/833.browser.js.LICENSE.txt +1 -0
- package/browser/dist/browser.js +1 -1
- package/browser/dist/browser.js.LICENSE.txt +0 -4
- package/dist/constants/chunks/contract-errors.generated.d.ts +15 -0
- package/dist/contract-errors.js +498 -0
- package/dist/contract-errors.mjs +461 -0
- package/dist/index.js +6189 -226
- package/dist/index.mjs +6058 -96
- package/dist/sign-guard.js +6 -0
- package/dist/sign-guard.mjs +4 -0
- package/dist/utils/chunks/eip1559-broadcast.utils.d.ts +2 -2
- package/dist/utils/contract-error-decoder.d.ts +47 -0
- package/dist/utils/quantum-revert.utils.d.ts +14 -2
- package/dist/utils/sign-guard/fee-ceiling.d.ts +16 -0
- package/dist/utils/sign-guard/index.d.ts +1 -1
- package/package.json +21 -6
package/dist/sign-guard.js
CHANGED
|
@@ -32,6 +32,8 @@ __export(sign_guard_exports, {
|
|
|
32
32
|
OP_ENVELOPE_FIELD_ORDER: () => OP_ENVELOPE_FIELD_ORDER,
|
|
33
33
|
OP_ENVELOPE_LAYOUT: () => OP_ENVELOPE_LAYOUT,
|
|
34
34
|
OP_ENVELOPE_TYPES: () => OP_ENVELOPE_TYPES,
|
|
35
|
+
PRIORITY_FEE_CAP_WEI: () => PRIORITY_FEE_CAP_WEI,
|
|
36
|
+
PRIORITY_FEE_FLOOR_WEI: () => PRIORITY_FEE_FLOOR_WEI,
|
|
35
37
|
QUANTUM_SECONDS: () => QUANTUM_SECONDS,
|
|
36
38
|
REQUEST_TIMEOUT_MS: () => REQUEST_TIMEOUT_MS,
|
|
37
39
|
SIGNABLE_FUNCTIONS: () => SIGNABLE_FUNCTIONS,
|
|
@@ -160,6 +162,8 @@ var import_ethers2 = require("ethers");
|
|
|
160
162
|
var MAX_GAS_LIMIT = 5000000n;
|
|
161
163
|
var MAX_FEE_PER_GAS_WEI = 2000000000000n;
|
|
162
164
|
var DEFAULT_MAX_TX_FEE_WEI = 250000000000000000n;
|
|
165
|
+
var PRIORITY_FEE_FLOOR_WEI = 100000000n;
|
|
166
|
+
var PRIORITY_FEE_CAP_WEI = 3000000000n;
|
|
163
167
|
var DEFAULT_FEE_CEILING = {
|
|
164
168
|
maxGasLimit: MAX_GAS_LIMIT,
|
|
165
169
|
maxFeePerGasWei: MAX_FEE_PER_GAS_WEI,
|
|
@@ -1109,6 +1113,8 @@ async function executePsmPlan(plan, signer, vctx) {
|
|
|
1109
1113
|
OP_ENVELOPE_FIELD_ORDER,
|
|
1110
1114
|
OP_ENVELOPE_LAYOUT,
|
|
1111
1115
|
OP_ENVELOPE_TYPES,
|
|
1116
|
+
PRIORITY_FEE_CAP_WEI,
|
|
1117
|
+
PRIORITY_FEE_FLOOR_WEI,
|
|
1112
1118
|
QUANTUM_SECONDS,
|
|
1113
1119
|
REQUEST_TIMEOUT_MS,
|
|
1114
1120
|
SIGNABLE_FUNCTIONS,
|
package/dist/sign-guard.mjs
CHANGED
|
@@ -88,6 +88,8 @@ import { ethers as ethers2 } from "ethers";
|
|
|
88
88
|
var MAX_GAS_LIMIT = 5000000n;
|
|
89
89
|
var MAX_FEE_PER_GAS_WEI = 2000000000000n;
|
|
90
90
|
var DEFAULT_MAX_TX_FEE_WEI = 250000000000000000n;
|
|
91
|
+
var PRIORITY_FEE_FLOOR_WEI = 100000000n;
|
|
92
|
+
var PRIORITY_FEE_CAP_WEI = 3000000000n;
|
|
91
93
|
var DEFAULT_FEE_CEILING = {
|
|
92
94
|
maxGasLimit: MAX_GAS_LIMIT,
|
|
93
95
|
maxFeePerGasWei: MAX_FEE_PER_GAS_WEI,
|
|
@@ -1036,6 +1038,8 @@ export {
|
|
|
1036
1038
|
OP_ENVELOPE_FIELD_ORDER,
|
|
1037
1039
|
OP_ENVELOPE_LAYOUT,
|
|
1038
1040
|
OP_ENVELOPE_TYPES,
|
|
1041
|
+
PRIORITY_FEE_CAP_WEI,
|
|
1042
|
+
PRIORITY_FEE_FLOOR_WEI,
|
|
1039
1043
|
QUANTUM_SECONDS,
|
|
1040
1044
|
REQUEST_TIMEOUT_MS,
|
|
1041
1045
|
SIGNABLE_FUNCTIONS,
|
|
@@ -110,8 +110,8 @@ export declare const LIQUIDATION_REVEAL_GAS_CEILING: bigint;
|
|
|
110
110
|
* fee — far more than the tip), the cap stops a spiking feeHistory from
|
|
111
111
|
* overpaying. At ~751k gas the floor costs ≈ $0.18 (ETH $2,458).
|
|
112
112
|
*/
|
|
113
|
-
|
|
114
|
-
export
|
|
113
|
+
import { PRIORITY_FEE_FLOOR_WEI, PRIORITY_FEE_CAP_WEI } from "../sign-guard/fee-ceiling";
|
|
114
|
+
export { PRIORITY_FEE_FLOOR_WEI, PRIORITY_FEE_CAP_WEI };
|
|
115
115
|
/** Blocks of eth_feeHistory sampled; the median across them absorbs a single spike block. */
|
|
116
116
|
export declare const FEE_HISTORY_BLOCK_COUNT = 20;
|
|
117
117
|
/**
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contract error decoder — a revert's bytes turned into the error the CONTRACT declares.
|
|
3
|
+
*
|
|
4
|
+
* Every name and selector here comes from the committed typechain ABIs, never from a
|
|
5
|
+
* hand-written table. Two hand-written tables used to live in this file and they had
|
|
6
|
+
* drifted: `0x137f3b70 -> InDeadZone` is a selector no contract can ever emit (the real
|
|
7
|
+
* error is `DeadZoneViolation()`, `0xbe4b82c1`; `isInDeadZone` is a view function), so a
|
|
8
|
+
* borrower hitting the dead zone would have been told about an error that does not exist.
|
|
9
|
+
* An ABI-derived table cannot drift: a renamed or deleted error disappears with it.
|
|
10
|
+
*
|
|
11
|
+
* Selector collisions across contracts are possible in principle (4 bytes). The table
|
|
12
|
+
* records EVERY contract a selector belongs to and `contract` names them all, rather than
|
|
13
|
+
* silently picking one.
|
|
14
|
+
*/
|
|
15
|
+
import { type ErrorFragment } from "ethers";
|
|
16
|
+
/** Decoded error information. */
|
|
17
|
+
export interface DecodedError {
|
|
18
|
+
name: string;
|
|
19
|
+
selector: string;
|
|
20
|
+
args?: any[];
|
|
21
|
+
/** The contract(s) declaring this error, or `"Unknown"`. */
|
|
22
|
+
contract: string;
|
|
23
|
+
message: string;
|
|
24
|
+
}
|
|
25
|
+
export interface ContractErrorEntry {
|
|
26
|
+
/** `Name(type,type)` exactly as declared. */
|
|
27
|
+
signature: string;
|
|
28
|
+
fragment: ErrorFragment;
|
|
29
|
+
/** Every contract in the set declaring this selector. */
|
|
30
|
+
contracts: string[];
|
|
31
|
+
}
|
|
32
|
+
/** Selector -> declared error, built once from the generated fragments. */
|
|
33
|
+
export declare function contractErrorTable(): Map<string, ContractErrorEntry>;
|
|
34
|
+
/** The declared error for a selector, or null when no contract in the set declares it. */
|
|
35
|
+
export declare function lookupContractError(selector: string): ContractErrorEntry | null;
|
|
36
|
+
/**
|
|
37
|
+
* Decode a contract revert.
|
|
38
|
+
*
|
|
39
|
+
* Returns the declared error with its ARGUMENTS wherever the payload carries them — the
|
|
40
|
+
* figures are the point (`SlippageExceeded(got, minimum)`, `InsufficientReserves(available,
|
|
41
|
+
* required)`). Selector-only payloads still resolve to the right name with empty args.
|
|
42
|
+
* Standard `Error(string)` and `Panic(uint256)` reverts decode too. Returns null only when
|
|
43
|
+
* there is nothing to decode at all.
|
|
44
|
+
*/
|
|
45
|
+
export declare function decodeContractError(error: any): DecodedError | null;
|
|
46
|
+
/** Format a decoded error for logging and user-facing messages. */
|
|
47
|
+
export declare function formatDecodedError(decoded: DecodedError): string;
|
|
@@ -15,8 +15,20 @@ export declare const ERROR_STRING_SELECTOR = "0x08c379a0";
|
|
|
15
15
|
/** Solidity `Panic(uint256)` (assert failures, overflow, div-by-zero, …). */
|
|
16
16
|
export declare const PANIC_SELECTOR = "0x4e487b71";
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
18
|
+
* The custom-error selectors the mint/payment/quantum paths decode.
|
|
19
|
+
*
|
|
20
|
+
* EVERY row is an error some contract declares, and
|
|
21
|
+
* `tests/shared/unit/contract-error-decoder.test.ts` proves it against the committed ABIs —
|
|
22
|
+
* because six rows here were fiction, and fiction on this path is read by a borrower:
|
|
23
|
+
*
|
|
24
|
+
* - `InDeadZone()`, `QuantumExpired()`, `UnauthorizedSigner()` and a no-argument
|
|
25
|
+
* `InvalidSignature()` are declared by NO contract (the real ones are
|
|
26
|
+
* `DeadZoneViolation()`, and `InvalidSignature(string reason)`);
|
|
27
|
+
* - `0x48f5c3ed` was labelled `Unauthorized()`, which is really `0x82b42900`;
|
|
28
|
+
* - `0x3ee5aeb5` was labelled `OperationNotAuthorized()` — it is
|
|
29
|
+
* `ReentrancyGuardReentrantCall()`, and `0xd92e233d`, labelled `ValidationFailed()`, is
|
|
30
|
+
* really `ZeroAddress()` (`ValidationFailed()` is `0x0a0b0d79`). Both are reachable
|
|
31
|
+
* reverts that were being reported to users under another error's name.
|
|
20
32
|
*/
|
|
21
33
|
export declare const QUANTUM_REVERT_NAMES: Record<string, string>;
|
|
22
34
|
export interface DecodedRevert {
|
|
@@ -16,6 +16,22 @@
|
|
|
16
16
|
export declare const MAX_GAS_LIMIT = 5000000n;
|
|
17
17
|
export declare const MAX_FEE_PER_GAS_WEI = 2000000000000n;
|
|
18
18
|
export declare const DEFAULT_MAX_TX_FEE_WEI = 250000000000000000n;
|
|
19
|
+
/**
|
|
20
|
+
* The priority-fee (tip) band for a quantum-bounded send, in wei.
|
|
21
|
+
*
|
|
22
|
+
* These live HERE, beside the ceilings, because they are the same kind of fact — what a
|
|
23
|
+
* client may pay — and every client needs them: the SDK's EIP-1559 broadcaster clamps the
|
|
24
|
+
* market tip into this band, and the CLI and MCP price their own sends. They were
|
|
25
|
+
* previously reachable only from a deep SDK path (`utils/chunks/eip1559-broadcast.utils`),
|
|
26
|
+
* which a consumer taking only `./sign-guard` cannot import, so each client wrote its own
|
|
27
|
+
* numbers instead.
|
|
28
|
+
*
|
|
29
|
+
* Floor: builders skip a tip that is too low, and a missed quantum wastes the Lit
|
|
30
|
+
* signatures, the Chipotle spend and the reverted transaction's base fee — all far more
|
|
31
|
+
* than the tip. Cap: a spiking `eth_feeHistory` must not turn into an overpaid send.
|
|
32
|
+
*/
|
|
33
|
+
export declare const PRIORITY_FEE_FLOOR_WEI = 100000000n;
|
|
34
|
+
export declare const PRIORITY_FEE_CAP_WEI = 3000000000n;
|
|
19
35
|
export interface FeeCeiling {
|
|
20
36
|
maxGasLimit: bigint;
|
|
21
37
|
maxFeePerGasWei: bigint;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { TxValidationError } from "./errors";
|
|
2
2
|
export { SIGNABLE_FUNCTIONS, encodeSignable, decodeSignable, signableFunctionName, signableSelectors, } from "./signable-functions";
|
|
3
|
-
export { MAX_GAS_LIMIT, MAX_FEE_PER_GAS_WEI, DEFAULT_MAX_TX_FEE_WEI, DEFAULT_FEE_CEILING, worstCaseFeeWei, assertFeeCeiling, type FeeCeiling, } from "./fee-ceiling";
|
|
3
|
+
export { MAX_GAS_LIMIT, MAX_FEE_PER_GAS_WEI, DEFAULT_MAX_TX_FEE_WEI, PRIORITY_FEE_FLOOR_WEI, PRIORITY_FEE_CAP_WEI, DEFAULT_FEE_CEILING, worstCaseFeeWei, assertFeeCeiling, type FeeCeiling, } from "./fee-ceiling";
|
|
4
4
|
export { validateUnsignedTx, buildValidationContext, describeUnsignedTx, readTxFeeFields, type ExpectedAction, type ContractRegistry, type ValidationContext, } from "./tx-validator";
|
|
5
5
|
export { QUANTUM_SECONDS, AUTH_VALIDITY_WINDOWS, authValiditySec, nextQuantumTimestamp, isAuthFresh, isStrictCurrentQuantum, modeForChainId, randomNonceHex, OP_ENVELOPE_LAYOUT, OP_ENVELOPE_TYPES, OP_ENVELOPE_FIELD_ORDER, stampOpEnvelope, buildAuthEnvelope, type OpEnvelopeInput, type StampedOpEnvelope, type AuthEnvelope, } from "./op-envelope";
|
|
6
6
|
export { DELEGATED_OPS, BROADCAST_PATH, type DelegatedOp, type DelegatedOpSpec } from "./op-specs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gvnrdao/dh-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.341",
|
|
4
4
|
"description": "TypeScript SDK for Diamond Hands Protocol",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -39,6 +39,11 @@
|
|
|
39
39
|
"types": "./dist/sign-guard.d.ts",
|
|
40
40
|
"import": "./dist/sign-guard.mjs",
|
|
41
41
|
"require": "./dist/sign-guard.js"
|
|
42
|
+
},
|
|
43
|
+
"./contract-errors": {
|
|
44
|
+
"types": "./dist/contract-errors.d.ts",
|
|
45
|
+
"import": "./dist/contract-errors.mjs",
|
|
46
|
+
"require": "./dist/contract-errors.js"
|
|
42
47
|
}
|
|
43
48
|
},
|
|
44
49
|
"files": [
|
|
@@ -50,8 +55,9 @@
|
|
|
50
55
|
"scripts": {
|
|
51
56
|
"build": "npm run sync:deployments && npm run validate:contracts && npm run build:node",
|
|
52
57
|
"build:all": "npm run sync:deployments && npm run validate:contracts && npm run build:node && npm run build:browser",
|
|
53
|
-
"build:node": "npm run sync:deployments && tsup && npm run build:types",
|
|
58
|
+
"build:node": "npm run sync:deployments && tsup && npm run build:types && npm run check:bundle-externals",
|
|
54
59
|
"build:types": "tsc -p tsconfig.build.json",
|
|
60
|
+
"check:bundle-externals": "node scripts/check-bundle-externals.mjs",
|
|
55
61
|
"build:browser": "cd browser && npm install && npm run build",
|
|
56
62
|
"sync:deployments": "node scripts/sync-deployments.js",
|
|
57
63
|
"sync:typechain": "cd ../contracts && npm run compile",
|
|
@@ -74,7 +80,8 @@
|
|
|
74
80
|
"lint": "eslint src --ext .ts && npm run lint:server-boundary && npm run lint:sign-guard",
|
|
75
81
|
"lint:server-boundary": "node scripts/check-pkp-mint-server-imports.mjs",
|
|
76
82
|
"lint:sign-guard": "node scripts/check-sign-guard-imports.mjs",
|
|
77
|
-
"clean": "rm -rf dist && rm -rf browser/dist"
|
|
83
|
+
"clean": "rm -rf dist && rm -rf browser/dist",
|
|
84
|
+
"gen:contract-errors": "node scripts/gen-contract-errors.mjs"
|
|
78
85
|
},
|
|
79
86
|
"keywords": [
|
|
80
87
|
"bitcoin",
|
|
@@ -93,17 +100,22 @@
|
|
|
93
100
|
},
|
|
94
101
|
"sideEffects": false,
|
|
95
102
|
"dependencies": {
|
|
96
|
-
"@gvnrdao/dh-lit-actions": "^0.0.322",
|
|
97
|
-
"@gvnrdao/dh-lit-ops": "^0.0.316",
|
|
98
103
|
"@noble/hashes": "^1.5.0",
|
|
99
104
|
"axios": "^1.17.0",
|
|
100
105
|
"bech32": "^2.0.0",
|
|
101
106
|
"bip66": "^2.0.0",
|
|
102
107
|
"bitcoinjs-lib": "^6.1.0",
|
|
108
|
+
"bn.js": "^5.2.3",
|
|
103
109
|
"bs58check": "^3.0.1",
|
|
104
110
|
"crypto-js": "^4.2.0",
|
|
105
111
|
"dotenv": "^17.4.2",
|
|
106
|
-
"
|
|
112
|
+
"elliptic": "^6.6.1",
|
|
113
|
+
"ethers": "6.16.0",
|
|
114
|
+
"uuid": "^9.0.1"
|
|
115
|
+
},
|
|
116
|
+
"optionalDependencies": {
|
|
117
|
+
"@gvnrdao/dh-lit-actions": "^0.0.322",
|
|
118
|
+
"@gvnrdao/dh-lit-ops": "^0.0.316"
|
|
107
119
|
},
|
|
108
120
|
"devDependencies": {
|
|
109
121
|
"@babel/preset-env": "7.29.7",
|
|
@@ -150,6 +162,9 @@
|
|
|
150
162
|
],
|
|
151
163
|
"sign-guard": [
|
|
152
164
|
"./dist/sign-guard.d.ts"
|
|
165
|
+
],
|
|
166
|
+
"contract-errors": [
|
|
167
|
+
"./dist/contract-errors.d.ts"
|
|
153
168
|
]
|
|
154
169
|
}
|
|
155
170
|
}
|