@utxopia/sdk 0.1.0-alpha.6 → 0.1.0-alpha.7
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/client.js +12 -19
- package/package.json +1 -1
- package/src/client.ts +13 -17
package/dist/client.js
CHANGED
|
@@ -25,6 +25,7 @@ import { setupKeysFromWallet, setupKeysFromSeed, setupKeysFromAuthSignature, rec
|
|
|
25
25
|
import { scanUnifiedNotesMulti, scanAnnouncementsViewOnlyMulti, computeNullifierHashForNote, computeNullifierBytes, isDepositForViewerHex, createDepositFromConfig, createTweakDeposit, depositViewingNode, createStealthOutputWithKeys, } from "./stealth";
|
|
26
26
|
import { selectUtxos } from "./psbt";
|
|
27
27
|
import { hexToBytes } from "./crypto";
|
|
28
|
+
import { getAddressEncoder } from "@solana/kit";
|
|
28
29
|
import { EventClient } from "./event-client";
|
|
29
30
|
// ─── Client ─────────────────────────────────────────────────────────
|
|
30
31
|
let _instance = null;
|
|
@@ -183,25 +184,17 @@ export class UTXOpiaClient {
|
|
|
183
184
|
const cached = this._tokenIdCache.get(mintAddress);
|
|
184
185
|
if (cached !== undefined)
|
|
185
186
|
return cached;
|
|
186
|
-
//
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
bytes = new PublicKey(mintAddress).toBytes();
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
catch {
|
|
201
|
-
// Lazy on purpose: a base58 mint padded to 64 is not hex, so computing
|
|
202
|
-
// this eagerly threw before the branch above ever ran.
|
|
203
|
-
bytes = hexToBytes(mintAddress.padStart(64, "0"));
|
|
204
|
-
}
|
|
187
|
+
// 64 hex chars is a raw token id; anything else is a base58 mint.
|
|
188
|
+
//
|
|
189
|
+
// Decoded with getAddressEncoder, the same path pda.ts uses, because
|
|
190
|
+
// require("@solana/web3.js") is not callable from an ESM browser bundle —
|
|
191
|
+
// it threw for every base58 mint, and the hex fallback behind it threw
|
|
192
|
+
// again on the same input. There is no fallback now: both branches are
|
|
193
|
+
// total for their input, and a malformed mint should raise, not be padded
|
|
194
|
+
// into a different token's id.
|
|
195
|
+
const bytes = mintAddress.length === 64 && /^[0-9a-fA-F]+$/.test(mintAddress)
|
|
196
|
+
? hexToBytes(mintAddress)
|
|
197
|
+
: new Uint8Array(getAddressEncoder().encode(mintAddress));
|
|
205
198
|
const tokenId = computeTokenId(bytes);
|
|
206
199
|
this._tokenIdCache.set(mintAddress, tokenId);
|
|
207
200
|
return tokenId;
|
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -55,6 +55,7 @@ import {
|
|
|
55
55
|
} from "./stealth";
|
|
56
56
|
import { selectUtxos, type UtxoDescriptor } from "./psbt";
|
|
57
57
|
import { hexToBytes, bytesToHex, bigintToBytes } from "./crypto";
|
|
58
|
+
import { getAddressEncoder, type Address } from "@solana/kit";
|
|
58
59
|
import { EventClient } from "./event-client";
|
|
59
60
|
import { type DepositOpReturnContext, type BitcoinNetwork } from "./taproot";
|
|
60
61
|
|
|
@@ -269,23 +270,18 @@ export class UTXOpiaClient {
|
|
|
269
270
|
const cached = this._tokenIdCache.get(mintAddress);
|
|
270
271
|
if (cached !== undefined) return cached;
|
|
271
272
|
|
|
272
|
-
//
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
} catch {
|
|
285
|
-
// Lazy on purpose: a base58 mint padded to 64 is not hex, so computing
|
|
286
|
-
// this eagerly threw before the branch above ever ran.
|
|
287
|
-
bytes = hexToBytes(mintAddress.padStart(64, "0"));
|
|
288
|
-
}
|
|
273
|
+
// 64 hex chars is a raw token id; anything else is a base58 mint.
|
|
274
|
+
//
|
|
275
|
+
// Decoded with getAddressEncoder, the same path pda.ts uses, because
|
|
276
|
+
// require("@solana/web3.js") is not callable from an ESM browser bundle —
|
|
277
|
+
// it threw for every base58 mint, and the hex fallback behind it threw
|
|
278
|
+
// again on the same input. There is no fallback now: both branches are
|
|
279
|
+
// total for their input, and a malformed mint should raise, not be padded
|
|
280
|
+
// into a different token's id.
|
|
281
|
+
const bytes =
|
|
282
|
+
mintAddress.length === 64 && /^[0-9a-fA-F]+$/.test(mintAddress)
|
|
283
|
+
? hexToBytes(mintAddress)
|
|
284
|
+
: new Uint8Array(getAddressEncoder().encode(mintAddress as Address));
|
|
289
285
|
|
|
290
286
|
const tokenId = computeTokenId(bytes);
|
|
291
287
|
this._tokenIdCache.set(mintAddress, tokenId);
|