sats-connect
Advanced tools
Comparing version 0.4.0-beta.1 to 0.5.0-5eeba6f
export * from './src/address/index'; | ||
export * from './src/call'; | ||
export * from './src/provider'; | ||
export * from './src/call'; | ||
export * from './src/signatures'; | ||
export * from './src/transactions/sendBtcTransaction'; | ||
export * from './src/transactions/signTransaction'; | ||
export * from './src/transactions/sendBtcTransaction'; | ||
export * from './src/signatures'; |
@@ -18,7 +18,7 @@ "use strict"; | ||
__exportStar(require("./src/address/index"), exports); | ||
__exportStar(require("./src/call"), exports); | ||
__exportStar(require("./src/provider"), exports); | ||
__exportStar(require("./src/call"), exports); | ||
__exportStar(require("./src/signatures"), exports); | ||
__exportStar(require("./src/transactions/sendBtcTransaction"), exports); | ||
__exportStar(require("./src/transactions/signTransaction"), exports); | ||
__exportStar(require("./src/transactions/sendBtcTransaction"), exports); | ||
__exportStar(require("./src/signatures"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -19,8 +19,10 @@ "use strict"; | ||
const jsontokens_1 = require("jsontokens"); | ||
const provider_1 = require("../provider"); | ||
const getAddress = async (options) => { | ||
const { message, network, purposes } = options.payload; | ||
const provider = window.BitcoinProvider; | ||
const { getProvider = provider_1.getDefaultProvider } = options; | ||
const provider = await getProvider(); | ||
if (!provider) { | ||
throw new Error('No Bitcoin Wallet installed'); | ||
throw new Error('No Bitcoin wallet installed'); | ||
} | ||
const { purposes } = options.payload; | ||
if (!purposes) { | ||
@@ -27,0 +29,0 @@ throw new Error('Address purposes are required'); |
@@ -1,2 +0,2 @@ | ||
import { BitcoinNetwork } from '../provider'; | ||
import { BitcoinNetwork, GetBitcoinProviderFunc } from '../provider'; | ||
export declare enum AddressPurposes { | ||
@@ -24,2 +24,3 @@ PAYMENT = "payment", | ||
export interface GetAddressOptions { | ||
getProvider?: GetBitcoinProviderFunc; | ||
onFinish: (response: GetAddressResponse) => void; | ||
@@ -26,0 +27,0 @@ onCancel: () => void; |
@@ -1,2 +0,2 @@ | ||
import { BitcoinNetwork } from '../provider'; | ||
import { BitcoinNetwork, GetBitcoinProviderFunc } from '../provider'; | ||
export interface CallWalletPayload { | ||
@@ -8,2 +8,3 @@ method: string; | ||
export interface CallWalletOptions { | ||
getProvider?: GetBitcoinProviderFunc; | ||
onFinish: (response: Record<string, any>) => void; | ||
@@ -10,0 +11,0 @@ onCancel: () => void; |
@@ -5,2 +5,3 @@ "use strict"; | ||
const jsontokens_1 = require("jsontokens"); | ||
const provider_1 = require("../provider"); | ||
var CallMethod; | ||
@@ -12,7 +13,8 @@ (function (CallMethod) { | ||
const callWalletPopup = async (options) => { | ||
const provider = window.BitcoinProvider; | ||
const { method } = options.payload; | ||
const { getProvider = provider_1.getDefaultProvider } = options; | ||
const provider = await getProvider(); | ||
if (!provider) { | ||
throw new Error('No Bitcoin Wallet installed'); | ||
throw new Error('No Bitcoin wallet installed'); | ||
} | ||
const { method } = options.payload; | ||
if (!method) { | ||
@@ -19,0 +21,0 @@ throw new Error('A wallet method is required'); |
@@ -0,3 +1,3 @@ | ||
import { GetAddressResponse } from '../address'; | ||
import { SignTransactionResponse } from '../transactions/signTransaction'; | ||
import { GetAddressResponse } from '../address'; | ||
export interface BitcoinNetwork { | ||
@@ -19,1 +19,3 @@ type: 'Mainnet' | 'Testnet'; | ||
} | ||
export type GetBitcoinProviderFunc = () => Promise<BitcoinProvider | undefined>; | ||
export declare function getDefaultProvider(): Promise<BitcoinProvider | undefined>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getDefaultProvider = void 0; | ||
async function getDefaultProvider() { | ||
return window.BitcoinProvider; | ||
} | ||
exports.getDefaultProvider = getDefaultProvider; | ||
//# sourceMappingURL=index.js.map |
@@ -19,13 +19,15 @@ "use strict"; | ||
const jsontokens_1 = require("jsontokens"); | ||
const provider_1 = require("../provider"); | ||
const signMessage = async (options) => { | ||
const { address, message } = options.payload; | ||
const provider = window.BitcoinProvider; | ||
const { getProvider = provider_1.getDefaultProvider } = options; | ||
const provider = await getProvider(); | ||
if (!provider) { | ||
throw new Error('No Bitcoin Wallet installed'); | ||
throw new Error('No Bitcoin wallet installed'); | ||
} | ||
const { address, message } = options.payload; | ||
if (!address) { | ||
throw new Error("An Address is required to sign a message"); | ||
throw new Error('An address is required to sign a message'); | ||
} | ||
if (!message) { | ||
throw new Error('you need to provide a message to be signed'); | ||
throw new Error('A message to be signed is required'); | ||
} | ||
@@ -38,3 +40,3 @@ try { | ||
catch (error) { | ||
console.error('[Connect] Error during Signing request', error); | ||
console.error('[Connect] Error during sign message request', error); | ||
options.onCancel?.(); | ||
@@ -41,0 +43,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { BitcoinNetwork } from '../provider'; | ||
import { BitcoinNetwork, GetBitcoinProviderFunc } from '../provider'; | ||
export interface SignMessagePayload { | ||
@@ -8,2 +8,3 @@ address: string; | ||
export interface SignMessageOptions { | ||
getProvider?: GetBitcoinProviderFunc; | ||
onFinish: (response: string) => void; | ||
@@ -10,0 +11,0 @@ onCancel: () => void; |
@@ -1,2 +0,2 @@ | ||
import { BitcoinNetwork } from '../provider'; | ||
import { BitcoinNetwork, GetBitcoinProviderFunc } from '../provider'; | ||
export interface Recipient { | ||
@@ -13,6 +13,7 @@ address: string; | ||
export interface SendBtcTransactionOptions { | ||
payload: SendBtcTransactionPayload; | ||
getProvider?: GetBitcoinProviderFunc; | ||
onFinish: (response: string) => void; | ||
onCancel: () => void; | ||
payload: SendBtcTransactionPayload; | ||
} | ||
export declare const sendBtcTransaction: (options: SendBtcTransactionOptions) => Promise<void>; |
@@ -5,13 +5,15 @@ "use strict"; | ||
const jsontokens_1 = require("jsontokens"); | ||
const provider_1 = require("../provider"); | ||
const sendBtcTransaction = async (options) => { | ||
const { recipients, senderAddress } = options.payload; | ||
const provider = window.BitcoinProvider; | ||
const { getProvider = provider_1.getDefaultProvider } = options; | ||
const provider = await getProvider(); | ||
if (!provider) { | ||
throw new Error('No Bitcoin Wallet installed'); | ||
throw new Error('No Bitcoin wallet installed'); | ||
} | ||
if (!recipients) { | ||
throw new Error('Recipient is required'); | ||
const { recipients, senderAddress } = options.payload; | ||
if (!recipients || recipients.length === 0) { | ||
throw new Error('At least one recipient is required'); | ||
} | ||
if (!senderAddress) { | ||
throw new Error('Sender address is required'); | ||
throw new Error('The sender address is required'); | ||
} | ||
@@ -24,3 +26,3 @@ try { | ||
catch (error) { | ||
console.error('[Connect] Error during send btc request', error); | ||
console.error('[Connect] Error during send BTC transaction request', error); | ||
options.onCancel?.(); | ||
@@ -27,0 +29,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { BitcoinNetwork } from '../provider'; | ||
import { BitcoinNetwork, GetBitcoinProviderFunc } from '../provider'; | ||
export interface InputToSign { | ||
@@ -15,5 +15,6 @@ address: string; | ||
export interface SignTransactionOptions { | ||
payload: SignTransactionPayload; | ||
getProvider?: GetBitcoinProviderFunc; | ||
onFinish: (response: any) => void; | ||
onCancel: () => void; | ||
payload: SignTransactionPayload; | ||
} | ||
@@ -20,0 +21,0 @@ export interface SignTransactionResponse { |
@@ -5,13 +5,15 @@ "use strict"; | ||
const jsontokens_1 = require("jsontokens"); | ||
const provider_1 = require("../provider"); | ||
const signTransaction = async (options) => { | ||
const { psbtBase64, inputsToSign } = options.payload; | ||
const provider = window.BitcoinProvider; | ||
const { getProvider = provider_1.getDefaultProvider } = options; | ||
const provider = await getProvider(); | ||
if (!provider) { | ||
throw new Error('No Bitcoin Wallet installed'); | ||
throw new Error('No Bitcoin wallet installed'); | ||
} | ||
const { psbtBase64, inputsToSign } = options.payload; | ||
if (!psbtBase64) { | ||
throw new Error('a value for psbtBase64 representing the tx hash is required'); | ||
throw new Error('A value for psbtBase64 representing the tx hash is required'); | ||
} | ||
if (!inputsToSign) { | ||
throw new Error('an array specifying the inputs to be signed by the wallet is required'); | ||
throw new Error('An array specifying the inputs to be signed by the wallet is required'); | ||
} | ||
@@ -24,3 +26,3 @@ try { | ||
catch (error) { | ||
console.error('[Connect] Error during signPsbt request', error); | ||
console.error('[Connect] Error during sign transaction request', error); | ||
options.onCancel?.(); | ||
@@ -27,0 +29,0 @@ } |
{ | ||
"name": "sats-connect", | ||
"version": "0.4.0-beta.1", | ||
"version": "0.5.0-5eeba6f", | ||
"main": "dist/index.js", | ||
"files": ["dist"], | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
@@ -7,0 +9,0 @@ "test": "jest", |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
43589
344