@relayprotocol/relay-bitcoin-wallet-adapter 10.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Reservoir
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ <h3 align="center">Relay Solana Wallet Adapter</h3>
2
+
3
+ ### Installation
4
+
5
+ ```
6
+ yarn add @relayprotocol/relay-bitcoin-wallet-adapter @relayprotocol/relay-sdk
7
+ ```
8
+
9
+ Also make sure to install the peer dependencies required by the adapter if your application doesn't already include them:
10
+
11
+ ```
12
+ yarn add viem @relayprotocol/relay-sdk
13
+ ```
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.adaptBitcoinWallet = void 0;
4
+ const relay_sdk_1 = require("@relayprotocol/relay-sdk");
5
+ const bitcoin = require("bitcoinjs-lib");
6
+ const adaptBitcoinWallet = (walletAddress, signPsbt) => {
7
+ return {
8
+ vmType: 'bvm',
9
+ getChainId: async () => {
10
+ return 8253038;
11
+ },
12
+ address: async () => {
13
+ return walletAddress;
14
+ },
15
+ handleSignMessageStep: async () => {
16
+ throw new Error('Message signing not implemented for Bitcoin');
17
+ },
18
+ handleSendTransactionStep: async (_chainId, stepItem) => {
19
+ const client = (0, relay_sdk_1.getClient)();
20
+ const psbtHex = stepItem.data.psbt;
21
+ const psbt = bitcoin.Psbt.fromHex(psbtHex, {
22
+ network: bitcoin.networks.bitcoin
23
+ });
24
+ const signature = psbt.txInputs.map((_input, index) => {
25
+ return {
26
+ address: walletAddress,
27
+ signingIndexes: [index]
28
+ };
29
+ });
30
+ const dynamicParams = {
31
+ allowedSighash: [1],
32
+ unsignedPsbtBase64: psbt.toBase64(),
33
+ signature
34
+ };
35
+ const signedPsbt = bitcoin.Psbt.fromBase64(await signPsbt(walletAddress, psbt, dynamicParams));
36
+ signedPsbt.finalizeAllInputs();
37
+ const rawTransaction = signedPsbt.extractTransaction().toHex();
38
+ client.log(['BTC Transaction', rawTransaction], relay_sdk_1.LogLevel.Verbose);
39
+ const mempoolResponse = await relay_sdk_1.axios
40
+ .post('https://mempool.space/api/tx', rawTransaction)
41
+ .then((r) => r.data);
42
+ client.log(['Transaction Broadcasted', mempoolResponse], relay_sdk_1.LogLevel.Verbose);
43
+ return mempoolResponse;
44
+ },
45
+ handleConfirmTransactionStep: async () => {
46
+ throw 'Not implemented';
47
+ },
48
+ switchChain: (chainId) => {
49
+ throw 'Not yet implemented';
50
+ }
51
+ };
52
+ };
53
+ exports.adaptBitcoinWallet = adaptBitcoinWallet;
54
+ //# sourceMappingURL=adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/adapter.ts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GAAG,UAAU,CAAC,kBAAkB,EAAE,CAAC,KAAK,EAAE,CAAA;YAC9D,MAAM,CAAC,GAAG,CAAC,CAAC,iBAAiB,EAAE,cAAc,CAAC,EAAE,oBAAQ,CAAC,OAAO,CAAC,CAAA;YACjE,MAAM,eAAe,GAAG,MAAM,iBAAK;iBAChC,IAAI,CAAC,8BAA8B,EAAE,cAAc,CAAC;iBACpD,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;YACtB,MAAM,CAAC,GAAG,CAAC,CAAC,yBAAyB,EAAE,eAAe,CAAC,EAAE,oBAAQ,CAAC,OAAO,CAAC,CAAA;YAC1E,OAAO,eAAe,CAAA;QACxB,CAAC;QAED,4BAA4B,EAAE,KAAK,IAAI,EAAE;YACvC,MAAM,iBAAiB,CAAA;QACzB,CAAC;QAED,WAAW,EAAE,CAAC,OAAe,EAAE,EAAE;YAC/B,MAAM,qBAAqB,CAAA;QAC7B,CAAC;KACF,CAAA;AACH,CAAC,CAAA;AA/DY,QAAA,kBAAkB,sBA+D9B"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./adapter.js"), exports);
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,uDAA4B"}