@monolythium/core-sdk 0.5.2 → 0.6.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/index.cjs +44 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +46 -5
- package/dist/index.d.ts +46 -5
- package/dist/index.js +42 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -127,7 +127,7 @@ function parseAddress(address) {
|
|
|
127
127
|
}
|
|
128
128
|
return bech32ToAddressBytes(address);
|
|
129
129
|
}
|
|
130
|
-
function validateAddress(address) {
|
|
130
|
+
function validateAddress(address, opts = {}) {
|
|
131
131
|
if (typeof address !== "string" || address.length === 0) {
|
|
132
132
|
return { valid: false, reason: "address cannot be empty" };
|
|
133
133
|
}
|
|
@@ -136,11 +136,17 @@ function validateAddress(address) {
|
|
|
136
136
|
return { valid: false, reason: "address cannot be empty" };
|
|
137
137
|
}
|
|
138
138
|
if (trimmed.startsWith("0x") || trimmed.startsWith("0X")) {
|
|
139
|
+
if (!opts.allowLegacyHex) {
|
|
140
|
+
return {
|
|
141
|
+
valid: false,
|
|
142
|
+
reason: "raw 0x addresses are retired; use a typed mono\u2026 bech32m address"
|
|
143
|
+
};
|
|
144
|
+
}
|
|
139
145
|
try {
|
|
140
146
|
const bytes = hexToAddressBytes(trimmed);
|
|
141
147
|
return {
|
|
142
148
|
valid: true,
|
|
143
|
-
normalized:
|
|
149
|
+
normalized: addressBytesToHex(bytes),
|
|
144
150
|
kind: null,
|
|
145
151
|
format: "hex",
|
|
146
152
|
bytes
|
|
@@ -10431,6 +10437,8 @@ var DELEGATION_REVERT_TAGS = {
|
|
|
10431
10437
|
* must be sent with `value = 0`. */
|
|
10432
10438
|
unexpectedValue: "0x020e"
|
|
10433
10439
|
};
|
|
10440
|
+
var CLAIMED_EVENT_SIG = "Claimed(address,uint256,bool)";
|
|
10441
|
+
var CLAIMED_EVENT_TOPIC0 = "0xfa8256f7c08bb01a03ea96f8b3a904a4450311c9725d1c52cdbe21ed3dc42dcc";
|
|
10434
10442
|
var DelegationPrecompileError = class extends Error {
|
|
10435
10443
|
constructor(message) {
|
|
10436
10444
|
super(message);
|
|
@@ -10480,6 +10488,30 @@ function encodeSetAutoCompoundCalldata(enabled) {
|
|
|
10480
10488
|
function isUnexpectedValueRevert(data) {
|
|
10481
10489
|
return bytesToHex9(toBytes8(data)).toLowerCase() === DELEGATION_REVERT_TAGS.unexpectedValue;
|
|
10482
10490
|
}
|
|
10491
|
+
function decodeClaimedEvent(topics, data) {
|
|
10492
|
+
if (topics.length !== 2) {
|
|
10493
|
+
throw new DelegationPrecompileError(`Claimed expects 2 topics, got ${topics.length}`);
|
|
10494
|
+
}
|
|
10495
|
+
const topic0 = toBytes8(topics[0]);
|
|
10496
|
+
if (topic0.length !== 32) {
|
|
10497
|
+
throw new DelegationPrecompileError("Claimed topic0 must be 32 bytes");
|
|
10498
|
+
}
|
|
10499
|
+
if (bytesToHex9(topic0).toLowerCase() !== CLAIMED_EVENT_TOPIC0) {
|
|
10500
|
+
throw new DelegationPrecompileError("unexpected topic0 for Claimed");
|
|
10501
|
+
}
|
|
10502
|
+
const walletWord = toBytes8(topics[1]);
|
|
10503
|
+
if (walletWord.length !== 32) {
|
|
10504
|
+
throw new DelegationPrecompileError("Claimed wallet topic must be 32 bytes");
|
|
10505
|
+
}
|
|
10506
|
+
const body = toBytes8(data);
|
|
10507
|
+
if (body.length < 64) {
|
|
10508
|
+
throw new DelegationPrecompileError("Claimed data shorter than amount + autoCompound words");
|
|
10509
|
+
}
|
|
10510
|
+
const delegator = bytesToHex9(walletWord.slice(12, 32));
|
|
10511
|
+
const amount = u256FromWord(body.slice(0, 32));
|
|
10512
|
+
const autoCompound = body.slice(32, 64).some((b) => b !== 0);
|
|
10513
|
+
return { delegator, amount, autoCompound };
|
|
10514
|
+
}
|
|
10483
10515
|
function uint32Word2(value, name) {
|
|
10484
10516
|
const n = toBigint3(value, name);
|
|
10485
10517
|
if (n < 0n || n > 0xffffffffn) {
|
|
@@ -10519,6 +10551,13 @@ function toBigint3(value, name) {
|
|
|
10519
10551
|
}
|
|
10520
10552
|
return BigInt(value);
|
|
10521
10553
|
}
|
|
10554
|
+
function u256FromWord(word) {
|
|
10555
|
+
let out = 0n;
|
|
10556
|
+
for (const b of word) {
|
|
10557
|
+
out = out << 8n | BigInt(b);
|
|
10558
|
+
}
|
|
10559
|
+
return out;
|
|
10560
|
+
}
|
|
10522
10561
|
function toBytes8(value) {
|
|
10523
10562
|
if (typeof value === "string") {
|
|
10524
10563
|
return hexToBytes8(value);
|
|
@@ -12327,6 +12366,8 @@ exports.BridgePrecompileError = BridgePrecompileError;
|
|
|
12327
12366
|
exports.BridgeRouteCatalogueError = BridgeRouteCatalogueError;
|
|
12328
12367
|
exports.CHAIN_REGISTRY = CHAIN_REGISTRY;
|
|
12329
12368
|
exports.CHAIN_REGISTRY_RAW_BASE = CHAIN_REGISTRY_RAW_BASE;
|
|
12369
|
+
exports.CLAIMED_EVENT_SIG = CLAIMED_EVENT_SIG;
|
|
12370
|
+
exports.CLAIMED_EVENT_TOPIC0 = CLAIMED_EVENT_TOPIC0;
|
|
12330
12371
|
exports.CLOB_MARKET_ID_DOMAIN_TAG = CLOB_MARKET_ID_DOMAIN_TAG;
|
|
12331
12372
|
exports.CLOB_SELECTORS = CLOB_SELECTORS;
|
|
12332
12373
|
exports.CLUSTER_FORMED_EVENT_SIG = CLUSTER_FORMED_EVENT_SIG;
|
|
@@ -12607,6 +12648,7 @@ exports.computeNoEvmTargetReceiptHash = computeNoEvmTargetReceiptHash;
|
|
|
12607
12648
|
exports.computeQuoteLiquidity = computeQuoteLiquidity;
|
|
12608
12649
|
exports.consumeNativeEvents = consumeNativeEvents;
|
|
12609
12650
|
exports.decodeActiveCharter = decodeActiveCharter;
|
|
12651
|
+
exports.decodeClaimedEvent = decodeClaimedEvent;
|
|
12610
12652
|
exports.decodeClusterCharter = decodeClusterCharter;
|
|
12611
12653
|
exports.decodeClusterDiversity = decodeClusterDiversity;
|
|
12612
12654
|
exports.decodeClusterFormedEvent = decodeClusterFormedEvent;
|