Skip to content

Commit

Permalink
Merge branch 'develop' into mahmoud/eng-2877-batch-sign-psbt-in-sats-…
Browse files Browse the repository at this point in the history
…connect
  • Loading branch information
dhriaznov authored Nov 10, 2023
2 parents 89fe39b + 52337f2 commit a1a8790
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/capabilities/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Capability } from 'src/provider';
import type { Capability } from '../provider';
import type { RequestOptions, RequestPayload } from '../types';

export interface GetCapabilitiesPayload extends RequestPayload {}
Expand Down
12 changes: 6 additions & 6 deletions src/inscriptions/createInscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ import { createUnsecuredToken } from 'jsontokens';
import { getProviderOrThrow } from '../provider';
import { CreateInscriptionOptions, CreateInscriptionPayload } from './types';

const MAX_CONTENT_LENGTH = 400e3; // 400kb is the max miners will mine
const MAX_CONTENT_LENGTH_MAINNET = 400e3; // 400kb is the max miners will mine
const MAX_CONTENT_LENGTH_TESTNET = 60e3; // 60kb limit on Testnet to prevent spam

export const validateInscriptionPayload = (payload: CreateInscriptionPayload) => {
const { contentType, content, payloadType, network, appFeeAddress, appFee } = payload;
if (network.type !== 'Mainnet') {
throw new Error('Only mainnet is currently supported for inscriptions');
}

if (!/^[a-z]+\/[a-z0-9\-\.\+]+(?=;.*|$)/.test(contentType)) {
throw new Error('Invalid content type detected');
}
Expand All @@ -24,7 +21,10 @@ export const validateInscriptionPayload = (payload: CreateInscriptionPayload) =>
throw new Error('Empty invalid payloadType specified');
}

if (content.length > MAX_CONTENT_LENGTH) {
if (
content.length >
(network.type === 'Mainnet' ? MAX_CONTENT_LENGTH_MAINNET : MAX_CONTENT_LENGTH_TESTNET)
) {
throw new Error('Content too large');
}

Expand Down

0 comments on commit a1a8790

Please sign in to comment.