sats-connect
Advanced tools
Comparing version 1.1.2 to 1.2.0-b68d8d9
@@ -38,2 +38,4 @@ "use strict"; | ||
createInscription: validateCapability('createInscription'), | ||
createRepeatInscriptions: validateCapability('createRepeatInscriptions'), | ||
signMultipleTransactions: validateCapability('signMultipleTransactions'), | ||
}; | ||
@@ -40,0 +42,0 @@ return Object.entries(capabilityMap).reduce((acc, [capability, value]) => { |
@@ -1,3 +0,2 @@ | ||
import { CreateInscriptionOptions, CreateInscriptionPayload } from './types'; | ||
export declare const validateInscriptionPayload: (payload: CreateInscriptionPayload) => void; | ||
import { CreateInscriptionOptions } from './types'; | ||
export declare const createInscription: (options: CreateInscriptionOptions) => Promise<void>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createInscription = exports.validateInscriptionPayload = void 0; | ||
exports.createInscription = void 0; | ||
const jsontokens_1 = require("jsontokens"); | ||
const provider_1 = require("../provider"); | ||
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 | ||
const validateInscriptionPayload = (payload) => { | ||
const { contentType, content, payloadType, network, appFeeAddress, appFee } = payload; | ||
if (!/^[a-z]+\/[a-z0-9\-\.\+]+(?=;.*|$)/.test(contentType)) { | ||
throw new Error('Invalid content type detected'); | ||
} | ||
if (!content || content.length === 0) { | ||
throw new Error('Empty content not allowed'); | ||
} | ||
if (!payloadType || (payloadType !== 'BASE_64' && payloadType !== 'PLAIN_TEXT')) { | ||
throw new Error('Empty invalid payloadType specified'); | ||
} | ||
if (content.length > | ||
(network.type === 'Mainnet' ? MAX_CONTENT_LENGTH_MAINNET : MAX_CONTENT_LENGTH_TESTNET)) { | ||
throw new Error('Content too large'); | ||
} | ||
if ((appFeeAddress?.length ?? 0) > 0 && (appFee ?? 0) <= 0) { | ||
throw new Error('Invalid combination of app fee address and fee provided'); | ||
} | ||
}; | ||
exports.validateInscriptionPayload = validateInscriptionPayload; | ||
const utils_1 = require("./utils"); | ||
const createInscription = async (options) => { | ||
const { getProvider } = options; | ||
const provider = await (0, provider_1.getProviderOrThrow)(getProvider); | ||
(0, exports.validateInscriptionPayload)(options.payload); | ||
(0, utils_1.validateInscriptionPayload)(options.payload); | ||
try { | ||
@@ -33,0 +12,0 @@ const request = (0, jsontokens_1.createUnsecuredToken)(options.payload); |
export * from './createInscription'; | ||
export * from './createRepeatInscriptions'; | ||
export * from './types'; |
@@ -18,3 +18,4 @@ "use strict"; | ||
__exportStar(require("./createInscription"), exports); | ||
__exportStar(require("./createRepeatInscriptions"), exports); | ||
__exportStar(require("./types"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -11,5 +11,12 @@ import type { RequestOptions, RequestPayload } from '../types'; | ||
} | ||
export interface CreateRepeatInscriptionsPayload extends CreateInscriptionPayload { | ||
repeat: number; | ||
} | ||
export type CreateInscriptionResponse = { | ||
txId: string; | ||
}; | ||
export type CreateRepeatInscriptionsResponse = { | ||
txId: string; | ||
}; | ||
export type CreateInscriptionOptions = RequestOptions<CreateInscriptionPayload, CreateInscriptionResponse>; | ||
export type CreateRepeatInscriptionsOptions = RequestOptions<CreateRepeatInscriptionsPayload, CreateRepeatInscriptionsResponse>; |
import type { GetAddressResponse } from '../addresses'; | ||
import type { CallWalletResponse } from '../call'; | ||
import type { GetCapabilitiesResponse } from '../capabilities'; | ||
import type { CreateInscriptionResponse } from '../inscriptions'; | ||
import type { CreateInscriptionResponse, CreateRepeatInscriptionsResponse } from '../inscriptions'; | ||
import type { SignMessageResponse } from '../messages'; | ||
import type { SendBtcTransactionResponse, SignTransactionResponse } from '../transactions'; | ||
import type { SendBtcTransactionResponse, SignMultipleTransactionsResponse, SignTransactionResponse } from '../transactions'; | ||
interface BaseBitcoinProvider { | ||
@@ -14,2 +14,4 @@ call: (request: string) => Promise<CallWalletResponse>; | ||
createInscription: (request: string) => Promise<CreateInscriptionResponse>; | ||
createRepeatInscriptions: (request: string) => Promise<CreateRepeatInscriptionsResponse>; | ||
signMultipleTransactions: (request: string) => Promise<SignMultipleTransactionsResponse>; | ||
} | ||
@@ -16,0 +18,0 @@ export type Capability = keyof BaseBitcoinProvider; |
export * from './sendBtcTransaction'; | ||
export * from './signTransaction'; | ||
export * from './signMultipleTransactions'; | ||
export * from './types'; |
@@ -19,3 +19,4 @@ "use strict"; | ||
__exportStar(require("./signTransaction"), exports); | ||
__exportStar(require("./signMultipleTransactions"), exports); | ||
__exportStar(require("./types"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -24,7 +24,13 @@ import type { RequestOptions, RequestPayload } from '../types'; | ||
} | ||
export interface SignTransactionPayload extends RequestPayload { | ||
message: string; | ||
export type PsbtPayload = { | ||
psbtBase64: string; | ||
inputsToSign: InputToSign[]; | ||
broadcast?: boolean; | ||
}; | ||
export type SignMultiplePsbtPayload = { | ||
psbtBase64: string; | ||
inputsToSign: InputToSign[]; | ||
}; | ||
export interface SignTransactionPayload extends RequestPayload, PsbtPayload { | ||
message: string; | ||
} | ||
@@ -36,1 +42,7 @@ export interface SignTransactionResponse { | ||
export type SignTransactionOptions = RequestOptions<SignTransactionPayload, SignTransactionResponse>; | ||
export interface SignMultipleTransactionsPayload extends RequestPayload { | ||
message: string; | ||
psbts: SignMultiplePsbtPayload[]; | ||
} | ||
export type SignMultipleTransactionsResponse = SignTransactionResponse[]; | ||
export type SignMultipleTransactionOptions = RequestOptions<SignMultipleTransactionsPayload, SignMultipleTransactionsResponse>; |
{ | ||
"name": "sats-connect", | ||
"version": "1.1.2", | ||
"version": "1.2.0-b68d8d9", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
68259
69
652
1