@sig-net/signet.js 0.5.0-rc1
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 +19 -0
- package/README.md +95 -0
- package/dist/index.cjs +3223 -0
- package/dist/index.d.cts +2098 -0
- package/dist/index.d.ts +2096 -0
- package/dist/index.js +3167 -0
- package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
- package/package.json +109 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Signet.js
|
|
2
|
+
|
|
3
|
+
A TypeScript library for handling multi-chain transactions and signatures using MPC (Multi-Party Computation).
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This library provides a unified interface for interacting with different blockchain networks through a common set of methods. It uses MPC for secure key management and transaction signing.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- **Multi-Chain Support**: Built-in support for EVM chains, Bitcoin, and Cosmos networks
|
|
12
|
+
- **Unified Interface**: Common API across all supported chains
|
|
13
|
+
- **MPC Integration**: Secure key management and transaction signing
|
|
14
|
+
- **Type Safety**: Full TypeScript support with comprehensive type definitions
|
|
15
|
+
- **Modular Design**: Easy to extend with new chain implementations
|
|
16
|
+
- **Secure**: No private keys stored or transmitted
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @sig-net/signet.js
|
|
22
|
+
# or
|
|
23
|
+
yarn add @sig-net/signet.js
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Quick Example (EVM)
|
|
27
|
+
|
|
28
|
+
```ts twoslash
|
|
29
|
+
import { chainAdapters, contracts } from '@sig-net/signet.js'
|
|
30
|
+
import { createPublicClient, http } from 'viem'
|
|
31
|
+
import { mainnet } from 'viem/chains'
|
|
32
|
+
|
|
33
|
+
const publicClient = createPublicClient({
|
|
34
|
+
chain: mainnet,
|
|
35
|
+
transport: http(),
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
// Assume you already instantiated your ChainSignatures EVM contract wrapper
|
|
39
|
+
const contract = new contracts.evm.ChainSignatureContract({
|
|
40
|
+
publicClient,
|
|
41
|
+
contractAddress: '0xYourContractAddress' as `0x${string}`,
|
|
42
|
+
walletClient: /* your WalletClient */ undefined as any,
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
const evmChain = new chainAdapters.evm.EVM({
|
|
46
|
+
publicClient,
|
|
47
|
+
contract,
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
// Derive address and public key for a predecessor identifier
|
|
51
|
+
const predecessorId = '0xYourEOAOrContract'
|
|
52
|
+
const { address, publicKey } = await evmChain.deriveAddressAndPublicKey(
|
|
53
|
+
predecessorId,
|
|
54
|
+
'any_string',
|
|
55
|
+
1
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
// Check balance
|
|
59
|
+
const { balance, decimals } = await evmChain.getBalance(address)
|
|
60
|
+
|
|
61
|
+
// Create and sign transaction
|
|
62
|
+
const { transaction, hashesToSign } =
|
|
63
|
+
await evmChain.prepareTransactionForSigning({
|
|
64
|
+
from: address,
|
|
65
|
+
to: '0x...',
|
|
66
|
+
value: 1n,
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
// Request MPC signature
|
|
70
|
+
const rsvSignature = await contract.sign({
|
|
71
|
+
payload: hashesToSign[0],
|
|
72
|
+
path: 'any_string',
|
|
73
|
+
key_version: 1,
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
// Finalize and broadcast
|
|
77
|
+
const signedTx = evmChain.finalizeTransactionSigning({
|
|
78
|
+
transaction,
|
|
79
|
+
rsvSignatures: [rsvSignature],
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
const txHash = await evmChain.broadcastTx(signedTx)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Documentation
|
|
86
|
+
|
|
87
|
+
For detailed documentation, including:
|
|
88
|
+
|
|
89
|
+
- Getting started guide
|
|
90
|
+
- Chain-specific implementations
|
|
91
|
+
- MPC system overview
|
|
92
|
+
- Implementation guides
|
|
93
|
+
- API reference
|
|
94
|
+
|
|
95
|
+
Visit our [documentation site](https://docs.sig.network/).
|