Skip to content

Commit f481c15

Browse files
committed
up tohex
1 parent de407ec commit f481c15

File tree

5 files changed

+38
-27
lines changed

5 files changed

+38
-27
lines changed

examples/otp-auth/with-backend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"@tailwindcss/postcss": "4.1.13",
1616
"@turnkey/react-wallet-kit": "workspace:*",
1717
"@turnkey/sdk-server": "workspace:*",
18+
"@turnkey/encoding": "workspace:*",
1819
"@types/node": "20.3.1",
1920
"@types/react": "18.2.14",
2021
"@types/react-dom": "18.2.6",

examples/otp-auth/with-backend/src/app/dashboard/page.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
VersionedTransaction,
2626
clusterApiUrl,
2727
} from "@solana/web3.js";
28+
import { uint8ArrayToHexString } from "@turnkey/encoding";
2829

2930
/** ---------- Utils ---------- */
3031
function safeStringify(x: unknown) {
@@ -35,13 +36,6 @@ function safeStringify(x: unknown) {
3536
);
3637
}
3738

38-
// Uint8Array -> hex
39-
function toHex(u8: Uint8Array) {
40-
return Array.from(u8)
41-
.map((b) => b.toString(16).padStart(2, "0"))
42-
.join("");
43-
}
44-
4539
// Build a Solana v0 **unsigned** tx and return HEX (Turnkey expects hex for SOL)
4640
async function buildUnsignedSolanaTxHex(fromAddress: string, rpcUrl?: string) {
4741
const connection = new Connection(
@@ -65,7 +59,7 @@ async function buildUnsignedSolanaTxHex(fromAddress: string, rpcUrl?: string) {
6559

6660
const unsignedTx = new VersionedTransaction(msgV0);
6761
const bytes = unsignedTx.serialize();
68-
return toHex(bytes);
62+
return uint8ArrayToHexString(bytes);
6963
}
7064

7165
// Build an EVM demo tx (send-to-self, 0 value) with a fresh nonce

examples/otp-auth/without-backend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"@tailwindcss/postcss": "4.1.13",
1616
"@turnkey/react-wallet-kit": "workspace:*",
1717
"@turnkey/sdk-server": "workspace:*",
18+
"@turnkey/encoding": "workspace:*",
1819
"@types/node": "20.3.1",
1920
"@types/react": "18.2.14",
2021
"@types/react-dom": "18.2.6",

examples/otp-auth/without-backend/src/app/dashboard/page.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
VersionedTransaction,
2626
clusterApiUrl,
2727
} from "@solana/web3.js";
28+
import { uint8ArrayToHexString } from "@turnkey/encoding";
2829

2930
/** ---------- Utils ---------- */
3031
function safeStringify(x: unknown) {
@@ -35,13 +36,6 @@ function safeStringify(x: unknown) {
3536
);
3637
}
3738

38-
// Uint8Array -> hex
39-
function toHex(u8: Uint8Array) {
40-
return Array.from(u8)
41-
.map((b) => b.toString(16).padStart(2, "0"))
42-
.join("");
43-
}
44-
4539
// Build a Solana v0 **unsigned** tx and return HEX (Turnkey expects hex for SOL)
4640
async function buildUnsignedSolanaTxHex(fromAddress: string, rpcUrl?: string) {
4741
const connection = new Connection(
@@ -65,7 +59,7 @@ async function buildUnsignedSolanaTxHex(fromAddress: string, rpcUrl?: string) {
6559

6660
const unsignedTx = new VersionedTransaction(msgV0);
6761
const bytes = unsignedTx.serialize();
68-
return toHex(bytes);
62+
return uint8ArrayToHexString(bytes);
6963
}
7064

7165
// Build an EVM demo tx (send-to-self, 0 value) with a fresh nonce

pnpm-lock.yaml

Lines changed: 32 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)