Skip to content

Commit

Permalink
fix: bundling config for bridge pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
hstove committed Sep 6, 2023
1 parent 08e8880 commit a670845
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Dockerfile.api
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ COPY packages/bridge/package.json packages/bridge/
COPY packages/punycode/package.json packages/punycode/
COPY web/patches web/patches

COPY . .

RUN CI=true pnpm install --frozen-lockfile --shamefully-hoist

COPY . .

RUN pnpm --filter @bns-x/api prebuild

RUN pnpm build:packages
Expand Down
1 change: 0 additions & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"author": "Hank Stoever",
"license": "ISC",
"dependencies": {
"@bns-x/bridge": "workspace:*",
"@bns-x/client": "workspace:*",
"@bns-x/core": "workspace:*",
"@bns-x/punycode": "workspace:*",
Expand Down
18 changes: 16 additions & 2 deletions api/src/fetchers/inscriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import { verifyMessageSignature, hashMessage } from 'micro-stacks/connect';
import { publicKeyToStxAddress } from 'micro-stacks/crypto';
import { z } from 'zod';
import { getNetworkKey } from '~/constants';
import { bytesToHex } from 'micro-stacks/common';
import { bytesToInscriptionId } from '@bns-x/bridge';
import { bytesToHex, hexToBytes } from 'micro-stacks/common';

export interface InscriptionMeta {
id: string;
Expand Down Expand Up @@ -302,3 +301,18 @@ export async function fetchInscriptionOwner(inscriptionId: string) {
export function inscriptionBuffToId(id: Uint8Array) {
return bytesToInscriptionId(id);
}

export function inscriptionIdToBytes(inscriptionId: string) {
const [txid, outIndexStr] = inscriptionId.split('i');
if (!txid || !outIndexStr) throw new Error('Invalid inscription id');
const outIndex = parseInt(outIndexStr, 10);
if (outIndex > 255) throw new Error('Inscription index must be less than 256');
return new Uint8Array([...hexToBytes(txid), outIndex]);
}

export function bytesToInscriptionId(bytes: Uint8Array) {
const txid = bytes.slice(0, 32);
const outIndex = bytes[32];
if (typeof outIndex === 'undefined') throw new Error('Invalid inscription bytes');
return `${bytesToHex(txid)}i${outIndex}`;
}
5 changes: 2 additions & 3 deletions packages/bridge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
"repository": "https://github.com/mechanismHQ/bns-x/tree/main/packages/png-ztxt",
"types": "./dist/index.d.ts",
"main": "./dist/index.js",
"module": "./dist/index.js",
"import": "./dist/index.js",
"type": "module",
"module": "./dist/index.mjs",
"import": "./dist/index.mjs",
"sideEffects": false,
"files": [
"dist"
Expand Down
2 changes: 1 addition & 1 deletion packages/bridge/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Options } from 'tsup';

export const defaultOptions: Options = {
target: 'es2022',
target: 'node16',
entry: ['src/index.ts'],
minify: false,
clean: true,
Expand Down
3 changes: 0 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a670845

Please sign in to comment.