sats-connect
Advanced tools
Comparing version 1.1.2-5f6a296 to 1.1.2-b30f133
@@ -38,3 +38,3 @@ "use strict"; | ||
createInscription: validateCapability('createInscription'), | ||
signMultipleTransactions: validateCapability('signMultipleTransactions'), | ||
createRepeatInscriptions: validateCapability('createRepeatInscriptions'), | ||
}; | ||
@@ -41,0 +41,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); |
@@ -11,2 +11,5 @@ import type { RequestOptions, RequestPayload } from '../types'; | ||
} | ||
export interface CreateRepeatInscriptionsPayload extends CreateInscriptionPayload { | ||
repeat: number; | ||
} | ||
export type CreateInscriptionResponse = { | ||
@@ -16,1 +19,2 @@ txId: string; | ||
export type CreateInscriptionOptions = RequestOptions<CreateInscriptionPayload, CreateInscriptionResponse>; | ||
export type CreateRepeatInscriptionsOptions = RequestOptions<CreateRepeatInscriptionsPayload, CreateInscriptionResponse>; |
@@ -6,3 +6,3 @@ import type { GetAddressResponse } from '../addresses'; | ||
import type { SignMessageResponse } from '../messages'; | ||
import type { SendBtcTransactionResponse, SignMultipleTransactionsResponse, SignTransactionResponse } from '../transactions'; | ||
import type { SendBtcTransactionResponse, SignTransactionResponse } from '../transactions'; | ||
interface BaseBitcoinProvider { | ||
@@ -15,3 +15,3 @@ call: (request: string) => Promise<CallWalletResponse>; | ||
createInscription: (request: string) => Promise<CreateInscriptionResponse>; | ||
signMultipleTransactions: (request: string) => Promise<SignMultipleTransactionsResponse>; | ||
createRepeatInscriptions: (request: string) => Promise<CreateInscriptionResponse>; | ||
} | ||
@@ -18,0 +18,0 @@ export type Capability = keyof BaseBitcoinProvider; |
export * from './sendBtcTransaction'; | ||
export * from './signTransaction'; | ||
export * from './signMultipleTransactions'; | ||
export * from './types'; |
@@ -19,4 +19,3 @@ "use strict"; | ||
__exportStar(require("./signTransaction"), exports); | ||
__exportStar(require("./signMultipleTransactions"), exports); | ||
__exportStar(require("./types"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -24,13 +24,7 @@ import type { RequestOptions, RequestPayload } from '../types'; | ||
} | ||
export type PsbtPayload = { | ||
export interface SignTransactionPayload extends RequestPayload { | ||
message: string; | ||
psbtBase64: string; | ||
inputsToSign: InputToSign[]; | ||
broadcast?: boolean; | ||
}; | ||
export type SignMultiplePsbtPayload = { | ||
psbtBase64: string; | ||
inputsToSign: InputToSign[]; | ||
}; | ||
export interface SignTransactionPayload extends RequestPayload, PsbtPayload { | ||
message: string; | ||
} | ||
@@ -42,7 +36,1 @@ 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-5f6a296", | ||
"version": "1.1.2-b30f133", | ||
"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
66
64814
604