sats-connect 2.0.0 → 2.1.0-5dcdcdf
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -2
- package/dist/index.d.ts +14 -8
- package/dist/index.js +67 -8
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -13
- package/dist/addresses/index.d.ts +0 -3
- package/dist/addresses/index.js +0 -38
- package/dist/addresses/index.js.map +0 -1
- package/dist/addresses/types.d.ts +0 -28
- package/dist/addresses/types.js +0 -19
- package/dist/addresses/types.js.map +0 -1
- package/dist/capabilities/index.d.ts +0 -3
- package/dist/capabilities/index.js +0 -70
- package/dist/capabilities/index.js.map +0 -1
- package/dist/capabilities/types.d.ts +0 -6
- package/dist/capabilities/types.js +0 -3
- package/dist/capabilities/types.js.map +0 -1
- package/dist/inscriptions/createInscription.d.ts +0 -2
- package/dist/inscriptions/createInscription.js +0 -22
- package/dist/inscriptions/createInscription.js.map +0 -1
- package/dist/inscriptions/createRepeatInscriptions.d.ts +0 -2
- package/dist/inscriptions/createRepeatInscriptions.js +0 -22
- package/dist/inscriptions/createRepeatInscriptions.js.map +0 -1
- package/dist/inscriptions/index.d.ts +0 -3
- package/dist/inscriptions/index.js +0 -20
- package/dist/inscriptions/index.js.map +0 -1
- package/dist/inscriptions/types.d.ts +0 -21
- package/dist/inscriptions/types.js +0 -3
- package/dist/inscriptions/types.js.map +0 -1
- package/dist/inscriptions/utils.d.ts +0 -2
- package/dist/inscriptions/utils.js +0 -26
- package/dist/inscriptions/utils.js.map +0 -1
- package/dist/messages/index.d.ts +0 -3
- package/dist/messages/index.js +0 -41
- package/dist/messages/index.js.map +0 -1
- package/dist/messages/types.d.ts +0 -7
- package/dist/messages/types.js +0 -3
- package/dist/messages/types.js.map +0 -1
- package/dist/provider/index.d.ts +0 -5
- package/dist/provider/index.js +0 -44
- package/dist/provider/index.js.map +0 -1
- package/dist/provider/types.d.ts +0 -43
- package/dist/provider/types.js +0 -3
- package/dist/provider/types.js.map +0 -1
- package/dist/request/index.d.ts +0 -4
- package/dist/request/index.js +0 -47
- package/dist/request/index.js.map +0 -1
- package/dist/request/types/btcMethods.d.ts +0 -111
- package/dist/request/types/btcMethods.js +0 -6
- package/dist/request/types/btcMethods.js.map +0 -1
- package/dist/request/types/index.d.ts +0 -26
- package/dist/request/types/index.js +0 -19
- package/dist/request/types/index.js.map +0 -1
- package/dist/request/types/stxMethods.d.ts +0 -193
- package/dist/request/types/stxMethods.js +0 -3
- package/dist/request/types/stxMethods.js.map +0 -1
- package/dist/transactions/index.d.ts +0 -4
- package/dist/transactions/index.js +0 -21
- package/dist/transactions/index.js.map +0 -1
- package/dist/transactions/sendBtcTransaction.d.ts +0 -2
- package/dist/transactions/sendBtcTransaction.js +0 -45
- package/dist/transactions/sendBtcTransaction.js.map +0 -1
- package/dist/transactions/signMultipleTransactions.d.ts +0 -2
- package/dist/transactions/signMultipleTransactions.js +0 -26
- package/dist/transactions/signMultipleTransactions.js.map +0 -1
- package/dist/transactions/signTransaction.d.ts +0 -2
- package/dist/transactions/signTransaction.js +0 -26
- package/dist/transactions/signTransaction.js.map +0 -1
- package/dist/transactions/types.d.ts +0 -46
- package/dist/transactions/types.js +0 -3
- package/dist/transactions/types.js.map +0 -1
- package/dist/types.d.ts +0 -87
- package/dist/types.js +0 -46
- package/dist/types.js.map +0 -1
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import { MethodParamsAndResult } from '../../types';
|
|
2
|
-
interface Pubkey {
|
|
3
|
-
/**
|
|
4
|
-
* When sending a transfer STX request to a wallet, users can generally
|
|
5
|
-
* choose from which accout they want to send the STX tokens from. In
|
|
6
|
-
* cases where applications want the transfer to be made from a specific
|
|
7
|
-
* account, they can provide the `pubkey` of the address they'd like the
|
|
8
|
-
* transfer to be made from. It is up to wallet providers to handle this
|
|
9
|
-
* field as they see fit.
|
|
10
|
-
*/
|
|
11
|
-
pubkey: string;
|
|
12
|
-
}
|
|
13
|
-
interface Address {
|
|
14
|
-
/**
|
|
15
|
-
* A Crockford base-32 encoded Stacks address.
|
|
16
|
-
*/
|
|
17
|
-
address: string;
|
|
18
|
-
}
|
|
19
|
-
interface ContractName {
|
|
20
|
-
/**
|
|
21
|
-
* The name of the contract.
|
|
22
|
-
*/
|
|
23
|
-
contract: string;
|
|
24
|
-
}
|
|
25
|
-
interface PostConditions {
|
|
26
|
-
/**
|
|
27
|
-
* A hex-encoded string representing the post conditions.
|
|
28
|
-
*
|
|
29
|
-
* A post condition may be converted to it's hex representation using the `serializePostCondition` helper from the `@stacks/transactions` package,
|
|
30
|
-
*
|
|
31
|
-
* ```js
|
|
32
|
-
* import { serializePostCondition } from '@stacks/transactions';
|
|
33
|
-
*
|
|
34
|
-
* const postCondition = somePostCondition;
|
|
35
|
-
* const hexPostCondition = serializePostCondition(postCondition).toString('hex');
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
postConditions: Array<string>;
|
|
39
|
-
}
|
|
40
|
-
interface PostConditionMode {
|
|
41
|
-
/**
|
|
42
|
-
* The mode of the post conditions.
|
|
43
|
-
*/
|
|
44
|
-
postConditionMode: number;
|
|
45
|
-
}
|
|
46
|
-
interface ParameterFormatVersion {
|
|
47
|
-
/**
|
|
48
|
-
* Version of parameter format.
|
|
49
|
-
*/
|
|
50
|
-
version: string;
|
|
51
|
-
}
|
|
52
|
-
interface Sponsored {
|
|
53
|
-
/**
|
|
54
|
-
* Whether the transaction is sponsored.
|
|
55
|
-
*/
|
|
56
|
-
sponsored: boolean;
|
|
57
|
-
}
|
|
58
|
-
interface Recipient {
|
|
59
|
-
/**
|
|
60
|
-
* The recipeint's Crockford base-32 encoded Stacks address.
|
|
61
|
-
*/
|
|
62
|
-
recipient: string;
|
|
63
|
-
}
|
|
64
|
-
interface Amount {
|
|
65
|
-
/**
|
|
66
|
-
* Amount of STX tokens to transfer in microstacks as a string. Anything
|
|
67
|
-
* parseable by `BigInt` is acceptable.
|
|
68
|
-
*
|
|
69
|
-
* Example,
|
|
70
|
-
*
|
|
71
|
-
* ```js
|
|
72
|
-
* const amount1 = 1234;
|
|
73
|
-
* const amount2 = 1234n;
|
|
74
|
-
* const amount3 = '1234';
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
amount: number | string;
|
|
78
|
-
}
|
|
79
|
-
interface Memo {
|
|
80
|
-
/**
|
|
81
|
-
* A string representing the memo.
|
|
82
|
-
*/
|
|
83
|
-
memo: string;
|
|
84
|
-
}
|
|
85
|
-
interface TxId {
|
|
86
|
-
/**
|
|
87
|
-
* The transaction ID of the transfer STX transaction as a hex-encoded string.
|
|
88
|
-
*/
|
|
89
|
-
txid: string;
|
|
90
|
-
}
|
|
91
|
-
interface Transaction {
|
|
92
|
-
/**
|
|
93
|
-
* An STX transaction as a hex-encoded string.
|
|
94
|
-
*/
|
|
95
|
-
transaction: string;
|
|
96
|
-
}
|
|
97
|
-
interface Message {
|
|
98
|
-
/**
|
|
99
|
-
* Message payload to be signed.
|
|
100
|
-
*/
|
|
101
|
-
message: string;
|
|
102
|
-
}
|
|
103
|
-
interface Signature {
|
|
104
|
-
/**
|
|
105
|
-
* Signature of the message.
|
|
106
|
-
*/
|
|
107
|
-
signature: string;
|
|
108
|
-
}
|
|
109
|
-
interface PublicKey {
|
|
110
|
-
/**
|
|
111
|
-
* Public key as hex-encoded string.
|
|
112
|
-
*/
|
|
113
|
-
publicKey: string;
|
|
114
|
-
}
|
|
115
|
-
interface Domain {
|
|
116
|
-
/**
|
|
117
|
-
* The domain to be signed.
|
|
118
|
-
*/
|
|
119
|
-
domain: string;
|
|
120
|
-
}
|
|
121
|
-
interface CodeBody {
|
|
122
|
-
/**
|
|
123
|
-
* The code body of the Clarity contract.
|
|
124
|
-
*/
|
|
125
|
-
codeBody: string;
|
|
126
|
-
}
|
|
127
|
-
interface ClarityVersion {
|
|
128
|
-
/**
|
|
129
|
-
* The Clarity version of the contract.
|
|
130
|
-
*/
|
|
131
|
-
clarityVersion?: string;
|
|
132
|
-
}
|
|
133
|
-
export interface CallContractParams {
|
|
134
|
-
/**
|
|
135
|
-
* The contract's Crockford base-32 encoded Stacks address and name.
|
|
136
|
-
*
|
|
137
|
-
* E.g. `"SPKE...GD5C.my-contract"`
|
|
138
|
-
*/
|
|
139
|
-
contract: string;
|
|
140
|
-
/**
|
|
141
|
-
* The name of the function to call.
|
|
142
|
-
*
|
|
143
|
-
* Note: spec changes ongoing,
|
|
144
|
-
* https://github.com/stacksgov/sips/pull/166#pullrequestreview-1914236999
|
|
145
|
-
*/
|
|
146
|
-
functionName: string;
|
|
147
|
-
/**
|
|
148
|
-
* The function's arguments. The arguments are expected to be hex-encoded
|
|
149
|
-
* strings of Clarity values.
|
|
150
|
-
*
|
|
151
|
-
* To convert Clarity values to their hex representation, the `cvToString`
|
|
152
|
-
* helper from the `@stacks/transactions` package may be helpful.
|
|
153
|
-
*
|
|
154
|
-
* ```js
|
|
155
|
-
* import { cvToString } from '@stacks/transactions';
|
|
156
|
-
*
|
|
157
|
-
* const functionArgs = [someClarityValue1, someClarityValue2];
|
|
158
|
-
* const hexArgs = functionArgs.map(cvToString);
|
|
159
|
-
* ```
|
|
160
|
-
*/
|
|
161
|
-
arguments?: Array<string>;
|
|
162
|
-
}
|
|
163
|
-
type CallContractResult = TxId & Transaction;
|
|
164
|
-
export type StxCallContract = MethodParamsAndResult<CallContractParams, CallContractResult>;
|
|
165
|
-
type TransferStxParams = Amount & Recipient & Partial<Memo> & Partial<ParameterFormatVersion> & Partial<PostConditionMode> & Partial<PostConditions> & Partial<Pubkey>;
|
|
166
|
-
type TransferStxResult = TxId & Transaction;
|
|
167
|
-
export type StxTransferStx = MethodParamsAndResult<TransferStxParams, TransferStxResult>;
|
|
168
|
-
type SignStxMessageParams = Message & Partial<Pubkey> & Partial<ParameterFormatVersion>;
|
|
169
|
-
type SignStxMessageResult = Signature & PublicKey;
|
|
170
|
-
export type StxSignStxMessage = MethodParamsAndResult<SignStxMessageParams, SignStxMessageResult>;
|
|
171
|
-
type SignStructuredMessageParams = Domain & Message & Partial<ParameterFormatVersion> & Partial<Pubkey>;
|
|
172
|
-
type SignStructuredMessageResult = Signature & PublicKey;
|
|
173
|
-
export type StxSignStructuredMessage = MethodParamsAndResult<SignStructuredMessageParams, SignStructuredMessageResult>;
|
|
174
|
-
type DeployContractParams = CodeBody & ContractName & Sponsored & Partial<ClarityVersion> & Partial<ParameterFormatVersion> & Partial<PostConditionMode> & Partial<PostConditions> & Partial<Pubkey>;
|
|
175
|
-
type DeployContractResult = TxId & Transaction;
|
|
176
|
-
export type StxDeployContract = MethodParamsAndResult<DeployContractParams, DeployContractResult>;
|
|
177
|
-
type GetAccountsParams = {};
|
|
178
|
-
type GetAccountsResult = {
|
|
179
|
-
addresses: Array<Address & PublicKey & {
|
|
180
|
-
gaiaHubUrl: string;
|
|
181
|
-
gaiaAppKey: string;
|
|
182
|
-
}>;
|
|
183
|
-
};
|
|
184
|
-
export type StxGetAccounts = MethodParamsAndResult<GetAccountsParams, GetAccountsResult>;
|
|
185
|
-
type GetAddressesParams = {};
|
|
186
|
-
type GetAddressesResult = {
|
|
187
|
-
addresses: Array<Address & PublicKey>;
|
|
188
|
-
};
|
|
189
|
-
export type StxGetAddresses = MethodParamsAndResult<GetAddressesParams, GetAddressesResult>;
|
|
190
|
-
export type SignTransactionParams = Transaction & Partial<Pubkey>;
|
|
191
|
-
export type SignTransactionResult = Transaction;
|
|
192
|
-
export type StxSignTransaction = MethodParamsAndResult<SignTransactionParams, SignTransactionResult>;
|
|
193
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stxMethods.js","sourceRoot":"","sources":["../../../src/request/types/stxMethods.ts"],"names":[],"mappings":""}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./sendBtcTransaction"), exports);
|
|
18
|
-
__exportStar(require("./signTransaction"), exports);
|
|
19
|
-
__exportStar(require("./signMultipleTransactions"), exports);
|
|
20
|
-
__exportStar(require("./types"), exports);
|
|
21
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transactions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,oDAAkC;AAClC,6DAA2C;AAC3C,0CAAwB"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sendBtcTransaction = void 0;
|
|
4
|
-
const jsontokens_1 = require("jsontokens");
|
|
5
|
-
const provider_1 = require("../provider");
|
|
6
|
-
const serializer = (recipient) => {
|
|
7
|
-
return recipient.map((value) => {
|
|
8
|
-
const { address, amountSats } = value;
|
|
9
|
-
return {
|
|
10
|
-
address,
|
|
11
|
-
amountSats: amountSats.toString(),
|
|
12
|
-
};
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
const sendBtcTransaction = async (options) => {
|
|
16
|
-
const provider = await (0, provider_1.getProviderOrThrow)(options.getProvider);
|
|
17
|
-
const { recipients, senderAddress, network, message } = options.payload;
|
|
18
|
-
if (!recipients || recipients.length === 0) {
|
|
19
|
-
throw new Error('At least one recipient is required');
|
|
20
|
-
}
|
|
21
|
-
if (recipients.some((item) => typeof item.address !== 'string' || typeof item.amountSats !== 'bigint')) {
|
|
22
|
-
throw new Error('Incorrect recipient format');
|
|
23
|
-
}
|
|
24
|
-
if (!senderAddress) {
|
|
25
|
-
throw new Error('The sender address is required');
|
|
26
|
-
}
|
|
27
|
-
try {
|
|
28
|
-
const serializedRecipients = serializer(recipients);
|
|
29
|
-
const serializedPayload = {
|
|
30
|
-
network,
|
|
31
|
-
senderAddress,
|
|
32
|
-
message,
|
|
33
|
-
recipients: serializedRecipients,
|
|
34
|
-
};
|
|
35
|
-
const request = (0, jsontokens_1.createUnsecuredToken)(serializedPayload);
|
|
36
|
-
const response = await provider.sendBtcTransaction(request);
|
|
37
|
-
options.onFinish?.(response);
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
console.error('[Connect] Error during send BTC transaction request', error);
|
|
41
|
-
options.onCancel?.();
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
exports.sendBtcTransaction = sendBtcTransaction;
|
|
45
|
-
//# sourceMappingURL=sendBtcTransaction.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sendBtcTransaction.js","sourceRoot":"","sources":["../../src/transactions/sendBtcTransaction.ts"],"names":[],"mappings":";;;AACA,2CAAkD;AAElD,0CAAiD;AAQjD,MAAM,UAAU,GAAG,CAAC,SAAsB,EAAyB,EAAE;IACnE,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAC7B,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;QACtC,OAAO;YACL,OAAO;YACP,UAAU,EAAE,UAAU,CAAC,QAAQ,EAAE;SAClC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEK,MAAM,kBAAkB,GAAG,KAAK,EAAE,OAAkC,EAAE,EAAE;IAC7E,MAAM,QAAQ,GAAG,MAAM,IAAA,6BAAkB,EAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAE/D,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IACxE,IAAI,CAAC,UAAU,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;QAC1C,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;KACvD;IACD,IACE,UAAU,CAAC,IAAI,CACb,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,IAAI,OAAO,IAAI,CAAC,UAAU,KAAK,QAAQ,CAClF,EACD;QACA,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;KAC/C;IACD,IAAI,CAAC,aAAa,EAAE;QAClB,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;KACnD;IAED,IAAI;QACF,MAAM,oBAAoB,GAA0B,UAAU,CAAC,UAAU,CAAC,CAAC;QAC3E,MAAM,iBAAiB,GAAwC;YAC7D,OAAO;YACP,aAAa;YACb,OAAO;YACP,UAAU,EAAE,oBAAoB;SACjC,CAAC;QACF,MAAM,OAAO,GAAG,IAAA,iCAAoB,EAAC,iBAAoC,CAAC,CAAC;QAC3E,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAC5D,OAAO,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC;KAC9B;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,qDAAqD,EAAE,KAAK,CAAC,CAAC;QAC5E,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;KACtB;AACH,CAAC,CAAC;AAjCW,QAAA,kBAAkB,sBAiC7B"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.signMultipleTransactions = void 0;
|
|
4
|
-
const jsontokens_1 = require("jsontokens");
|
|
5
|
-
const provider_1 = require("../provider");
|
|
6
|
-
const signMultipleTransactions = async (options) => {
|
|
7
|
-
const provider = await (0, provider_1.getProviderOrThrow)(options.getProvider);
|
|
8
|
-
const { psbts } = options.payload;
|
|
9
|
-
if (!psbts || !psbts.length) {
|
|
10
|
-
throw new Error('psbts array is required');
|
|
11
|
-
}
|
|
12
|
-
if (psbts.length > 100) {
|
|
13
|
-
throw new Error('psbts array must contain less than 100 psbts');
|
|
14
|
-
}
|
|
15
|
-
try {
|
|
16
|
-
const request = (0, jsontokens_1.createUnsecuredToken)(options.payload);
|
|
17
|
-
const response = await provider.signMultipleTransactions(request);
|
|
18
|
-
options.onFinish?.(response);
|
|
19
|
-
}
|
|
20
|
-
catch (error) {
|
|
21
|
-
console.error('[Connect] Error during sign Multiple transactions request', error);
|
|
22
|
-
options.onCancel?.();
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
exports.signMultipleTransactions = signMultipleTransactions;
|
|
26
|
-
//# sourceMappingURL=signMultipleTransactions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signMultipleTransactions.js","sourceRoot":"","sources":["../../src/transactions/signMultipleTransactions.ts"],"names":[],"mappings":";;;AACA,2CAAkD;AAClD,0CAAiD;AAG1C,MAAM,wBAAwB,GAAG,KAAK,EAAE,OAAuC,EAAE,EAAE;IACxF,MAAM,QAAQ,GAAG,MAAM,IAAA,6BAAkB,EAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAE/D,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAClC,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;QAC3B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;KAC5C;IAED,IAAI,KAAK,CAAC,MAAM,GAAG,GAAG,EAAE;QACtB,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;KACjE;IAED,IAAI;QACF,MAAM,OAAO,GAAG,IAAA,iCAAoB,EAAC,OAAO,CAAC,OAA0B,CAAC,CAAC;QACzE,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC;QAClE,OAAO,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC;KAC9B;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,2DAA2D,EAAE,KAAK,CAAC,CAAC;QAClF,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;KACtB;AACH,CAAC,CAAC;AApBW,QAAA,wBAAwB,4BAoBnC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.signTransaction = void 0;
|
|
4
|
-
const jsontokens_1 = require("jsontokens");
|
|
5
|
-
const provider_1 = require("../provider");
|
|
6
|
-
const signTransaction = async (options) => {
|
|
7
|
-
const provider = await (0, provider_1.getProviderOrThrow)(options.getProvider);
|
|
8
|
-
const { psbtBase64, inputsToSign } = options.payload;
|
|
9
|
-
if (!psbtBase64) {
|
|
10
|
-
throw new Error('A value for psbtBase64 representing the tx hash is required');
|
|
11
|
-
}
|
|
12
|
-
if (!inputsToSign) {
|
|
13
|
-
throw new Error('An array specifying the inputs to be signed by the wallet is required');
|
|
14
|
-
}
|
|
15
|
-
try {
|
|
16
|
-
const request = (0, jsontokens_1.createUnsecuredToken)(options.payload);
|
|
17
|
-
const response = await provider.signTransaction(request);
|
|
18
|
-
options.onFinish?.(response);
|
|
19
|
-
}
|
|
20
|
-
catch (error) {
|
|
21
|
-
console.error('[Connect] Error during sign transaction request', error);
|
|
22
|
-
options.onCancel?.();
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
exports.signTransaction = signTransaction;
|
|
26
|
-
//# sourceMappingURL=signTransaction.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signTransaction.js","sourceRoot":"","sources":["../../src/transactions/signTransaction.ts"],"names":[],"mappings":";;;AACA,2CAAkD;AAClD,0CAAiD;AAG1C,MAAM,eAAe,GAAG,KAAK,EAAE,OAA+B,EAAE,EAAE;IACvE,MAAM,QAAQ,GAAG,MAAM,IAAA,6BAAkB,EAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAE/D,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IACrD,IAAI,CAAC,UAAU,EAAE;QACf,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;KAChF;IACD,IAAI,CAAC,YAAY,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,uEAAuE,CAAC,CAAC;KAC1F;IAED,IAAI;QACF,MAAM,OAAO,GAAG,IAAA,iCAAoB,EAAC,OAAO,CAAC,OAA0B,CAAC,CAAC;QACzE,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QACzD,OAAO,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC;KAC9B;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,iDAAiD,EAAE,KAAK,CAAC,CAAC;QACxE,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;KACtB;AACH,CAAC,CAAC;AAnBW,QAAA,eAAe,mBAmB1B"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { RequestOptions, RequestPayload } from '../types';
|
|
2
|
-
export interface Recipient {
|
|
3
|
-
address: string;
|
|
4
|
-
amountSats: bigint;
|
|
5
|
-
}
|
|
6
|
-
export type SerializedRecipient = Omit<Recipient, 'amountSats'> & {
|
|
7
|
-
amountSats: string;
|
|
8
|
-
};
|
|
9
|
-
export interface SendBtcTransactionPayload extends RequestPayload {
|
|
10
|
-
recipients: Recipient[];
|
|
11
|
-
senderAddress: string;
|
|
12
|
-
message?: string;
|
|
13
|
-
}
|
|
14
|
-
export type SerializedSendBtcTransactionPayload = Omit<SendBtcTransactionPayload, 'recipients'> & {
|
|
15
|
-
recipients: SerializedRecipient[];
|
|
16
|
-
};
|
|
17
|
-
export type SendBtcTransactionResponse = string;
|
|
18
|
-
export type SendBtcTransactionOptions = RequestOptions<SendBtcTransactionPayload, SendBtcTransactionResponse>;
|
|
19
|
-
export interface InputToSign {
|
|
20
|
-
address: string;
|
|
21
|
-
signingIndexes: number[];
|
|
22
|
-
sigHash?: number;
|
|
23
|
-
}
|
|
24
|
-
export type PsbtPayload = {
|
|
25
|
-
psbtBase64: string;
|
|
26
|
-
inputsToSign: InputToSign[];
|
|
27
|
-
broadcast?: boolean;
|
|
28
|
-
};
|
|
29
|
-
export type SignMultiplePsbtPayload = {
|
|
30
|
-
psbtBase64: string;
|
|
31
|
-
inputsToSign: InputToSign[];
|
|
32
|
-
};
|
|
33
|
-
export interface SignTransactionPayload extends RequestPayload, PsbtPayload {
|
|
34
|
-
message: string;
|
|
35
|
-
}
|
|
36
|
-
export interface SignTransactionResponse {
|
|
37
|
-
psbtBase64: string;
|
|
38
|
-
txId?: string;
|
|
39
|
-
}
|
|
40
|
-
export type SignTransactionOptions = RequestOptions<SignTransactionPayload, SignTransactionResponse>;
|
|
41
|
-
export interface SignMultipleTransactionsPayload extends RequestPayload {
|
|
42
|
-
message: string;
|
|
43
|
-
psbts: SignMultiplePsbtPayload[];
|
|
44
|
-
}
|
|
45
|
-
export type SignMultipleTransactionsResponse = SignTransactionResponse[];
|
|
46
|
-
export type SignMultipleTransactionOptions = RequestOptions<SignMultipleTransactionsPayload, SignMultipleTransactionsResponse>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/transactions/types.ts"],"names":[],"mappings":""}
|
package/dist/types.d.ts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import type { BitcoinProvider } from './provider';
|
|
2
|
-
import { Requests, Return } from './request';
|
|
3
|
-
export declare enum BitcoinNetworkType {
|
|
4
|
-
Mainnet = "Mainnet",
|
|
5
|
-
Testnet = "Testnet"
|
|
6
|
-
}
|
|
7
|
-
export interface BitcoinNetwork {
|
|
8
|
-
type: BitcoinNetworkType;
|
|
9
|
-
address?: string;
|
|
10
|
-
}
|
|
11
|
-
export interface RequestPayload {
|
|
12
|
-
network: BitcoinNetwork;
|
|
13
|
-
}
|
|
14
|
-
export interface RequestOptions<Payload extends RequestPayload, Response> {
|
|
15
|
-
onFinish: (response: Response) => void;
|
|
16
|
-
onCancel: () => void;
|
|
17
|
-
payload: Payload;
|
|
18
|
-
getProvider?: () => Promise<BitcoinProvider | undefined>;
|
|
19
|
-
}
|
|
20
|
-
export type RpcId = string | null;
|
|
21
|
-
export interface RpcBase {
|
|
22
|
-
jsonrpc: '2.0';
|
|
23
|
-
id: RpcId;
|
|
24
|
-
}
|
|
25
|
-
export interface RpcRequest<T extends string, U> extends RpcBase {
|
|
26
|
-
method: T;
|
|
27
|
-
params: U;
|
|
28
|
-
}
|
|
29
|
-
export interface MethodParamsAndResult<TParams, TResult> {
|
|
30
|
-
params: TParams;
|
|
31
|
-
result: TResult;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* @enum {number} RpcErrorCode
|
|
35
|
-
* @description JSON-RPC error codes
|
|
36
|
-
* @see https://www.jsonrpc.org/specification#error_object
|
|
37
|
-
*/
|
|
38
|
-
export declare enum RpcErrorCode {
|
|
39
|
-
/**
|
|
40
|
-
* Parse error Invalid JSON
|
|
41
|
-
**/
|
|
42
|
-
PARSE_ERROR = -32700,
|
|
43
|
-
/**
|
|
44
|
-
* The JSON sent is not a valid Request object.
|
|
45
|
-
**/
|
|
46
|
-
INVALID_REQUEST = -32600,
|
|
47
|
-
/**
|
|
48
|
-
* The method does not exist/is not available.
|
|
49
|
-
**/
|
|
50
|
-
METHOD_NOT_FOUND = -32601,
|
|
51
|
-
/**
|
|
52
|
-
* Invalid method parameter(s).
|
|
53
|
-
*/
|
|
54
|
-
INVALID_PARAMS = -32602,
|
|
55
|
-
/**
|
|
56
|
-
* Internal JSON-RPC error.
|
|
57
|
-
* This is a generic error, used when the server encounters an error in performing the request.
|
|
58
|
-
**/
|
|
59
|
-
INTERNAL_ERROR = -32603,
|
|
60
|
-
/**
|
|
61
|
-
* user rejected/canceled the request
|
|
62
|
-
*/
|
|
63
|
-
USER_REJECTION = -32000,
|
|
64
|
-
/**
|
|
65
|
-
* method is not supported for the address provided
|
|
66
|
-
*/
|
|
67
|
-
METHOD_NOT_SUPPORTED = -32001
|
|
68
|
-
}
|
|
69
|
-
export interface RpcError {
|
|
70
|
-
code: number | RpcErrorCode;
|
|
71
|
-
message: string;
|
|
72
|
-
data?: any;
|
|
73
|
-
}
|
|
74
|
-
export interface RpcErrorResponse<TError extends RpcError = RpcError> extends RpcBase {
|
|
75
|
-
error: TError;
|
|
76
|
-
}
|
|
77
|
-
export interface RpcSuccessResponse<Method extends keyof Requests> extends RpcBase {
|
|
78
|
-
result: Return<Method>;
|
|
79
|
-
}
|
|
80
|
-
export type RpcResponse<Method extends keyof Requests> = RpcSuccessResponse<Method> | RpcErrorResponse;
|
|
81
|
-
export type RpcResult<Method extends keyof Requests> = {
|
|
82
|
-
result: RpcSuccessResponse<Method>['result'];
|
|
83
|
-
status: 'success';
|
|
84
|
-
} | {
|
|
85
|
-
error: RpcErrorResponse['error'];
|
|
86
|
-
status: 'error';
|
|
87
|
-
};
|
package/dist/types.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RpcErrorCode = exports.BitcoinNetworkType = void 0;
|
|
4
|
-
var BitcoinNetworkType;
|
|
5
|
-
(function (BitcoinNetworkType) {
|
|
6
|
-
BitcoinNetworkType["Mainnet"] = "Mainnet";
|
|
7
|
-
BitcoinNetworkType["Testnet"] = "Testnet";
|
|
8
|
-
})(BitcoinNetworkType = exports.BitcoinNetworkType || (exports.BitcoinNetworkType = {}));
|
|
9
|
-
/**
|
|
10
|
-
* @enum {number} RpcErrorCode
|
|
11
|
-
* @description JSON-RPC error codes
|
|
12
|
-
* @see https://www.jsonrpc.org/specification#error_object
|
|
13
|
-
*/
|
|
14
|
-
var RpcErrorCode;
|
|
15
|
-
(function (RpcErrorCode) {
|
|
16
|
-
/**
|
|
17
|
-
* Parse error Invalid JSON
|
|
18
|
-
**/
|
|
19
|
-
RpcErrorCode[RpcErrorCode["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
|
|
20
|
-
/**
|
|
21
|
-
* The JSON sent is not a valid Request object.
|
|
22
|
-
**/
|
|
23
|
-
RpcErrorCode[RpcErrorCode["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
|
|
24
|
-
/**
|
|
25
|
-
* The method does not exist/is not available.
|
|
26
|
-
**/
|
|
27
|
-
RpcErrorCode[RpcErrorCode["METHOD_NOT_FOUND"] = -32601] = "METHOD_NOT_FOUND";
|
|
28
|
-
/**
|
|
29
|
-
* Invalid method parameter(s).
|
|
30
|
-
*/
|
|
31
|
-
RpcErrorCode[RpcErrorCode["INVALID_PARAMS"] = -32602] = "INVALID_PARAMS";
|
|
32
|
-
/**
|
|
33
|
-
* Internal JSON-RPC error.
|
|
34
|
-
* This is a generic error, used when the server encounters an error in performing the request.
|
|
35
|
-
**/
|
|
36
|
-
RpcErrorCode[RpcErrorCode["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
|
|
37
|
-
/**
|
|
38
|
-
* user rejected/canceled the request
|
|
39
|
-
*/
|
|
40
|
-
RpcErrorCode[RpcErrorCode["USER_REJECTION"] = -32000] = "USER_REJECTION";
|
|
41
|
-
/**
|
|
42
|
-
* method is not supported for the address provided
|
|
43
|
-
*/
|
|
44
|
-
RpcErrorCode[RpcErrorCode["METHOD_NOT_SUPPORTED"] = -32001] = "METHOD_NOT_SUPPORTED";
|
|
45
|
-
})(RpcErrorCode = exports.RpcErrorCode || (exports.RpcErrorCode = {}));
|
|
46
|
-
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAGA,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,yCAAmB,CAAA;IACnB,yCAAmB,CAAA;AACrB,CAAC,EAHW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAG7B;AAoCD;;;;GAIG;AACH,IAAY,YA8BX;AA9BD,WAAY,YAAY;IACtB;;QAEI;IACJ,kEAAoB,CAAA;IACpB;;QAEI;IACJ,0EAAwB,CAAA;IACxB;;QAEI;IACJ,4EAAyB,CAAA;IACzB;;OAEG;IACH,wEAAuB,CAAA;IACvB;;;QAGI;IACJ,wEAAuB,CAAA;IACvB;;OAEG;IACH,wEAAuB,CAAA;IACvB;;OAEG;IACH,oFAA6B,CAAA;AAC/B,CAAC,EA9BW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QA8BvB"}
|