@sequence0/sdk 0.1.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/README.md +154 -0
- package/dist/chains/bitcoin.d.ts +44 -0
- package/dist/chains/bitcoin.d.ts.map +1 -0
- package/dist/chains/bitcoin.js +152 -0
- package/dist/chains/bitcoin.js.map +1 -0
- package/dist/chains/ethereum.d.ts +60 -0
- package/dist/chains/ethereum.d.ts.map +1 -0
- package/dist/chains/ethereum.js +179 -0
- package/dist/chains/ethereum.js.map +1 -0
- package/dist/chains/solana.d.ts +48 -0
- package/dist/chains/solana.d.ts.map +1 -0
- package/dist/chains/solana.js +157 -0
- package/dist/chains/solana.js.map +1 -0
- package/dist/core/client.d.ts +123 -0
- package/dist/core/client.d.ts.map +1 -0
- package/dist/core/client.js +311 -0
- package/dist/core/client.js.map +1 -0
- package/dist/core/types.d.ts +150 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +8 -0
- package/dist/core/types.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +54 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/errors.d.ts +26 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +53 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/http.d.ts +23 -0
- package/dist/utils/http.d.ts.map +1 -0
- package/dist/utils/http.js +64 -0
- package/dist/utils/http.js.map +1 -0
- package/dist/utils/websocket.d.ts +45 -0
- package/dist/utils/websocket.d.ts.map +1 -0
- package/dist/utils/websocket.js +130 -0
- package/dist/utils/websocket.js.map +1 -0
- package/dist/wallet/wallet.d.ts +144 -0
- package/dist/wallet/wallet.d.ts.map +1 -0
- package/dist/wallet/wallet.js +254 -0
- package/dist/wallet/wallet.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Solana Chain Adapter
|
|
4
|
+
*
|
|
5
|
+
* Builds Solana transactions, attaches Ed25519 signatures generated
|
|
6
|
+
* by the FROST threshold signing network, and broadcasts via
|
|
7
|
+
* @solana/web3.js Connection.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.SolanaAdapter = void 0;
|
|
11
|
+
exports.createSolanaAdapter = createSolanaAdapter;
|
|
12
|
+
exports.createSolanaDevnetAdapter = createSolanaDevnetAdapter;
|
|
13
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
14
|
+
const errors_1 = require("../utils/errors");
|
|
15
|
+
const DEFAULT_RPC = 'https://api.mainnet-beta.solana.com';
|
|
16
|
+
const DEVNET_RPC = 'https://api.devnet.solana.com';
|
|
17
|
+
class SolanaAdapter {
|
|
18
|
+
constructor(network = 'mainnet', rpcUrl) {
|
|
19
|
+
this.rpcUrl = rpcUrl || (network === 'devnet' ? DEVNET_RPC : DEFAULT_RPC);
|
|
20
|
+
this.connection = new web3_js_1.Connection(this.rpcUrl, 'confirmed');
|
|
21
|
+
}
|
|
22
|
+
getRpcUrl() {
|
|
23
|
+
return this.rpcUrl;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Build an unsigned Solana transaction
|
|
27
|
+
*
|
|
28
|
+
* Creates a SOL transfer instruction, fetches recent blockhash,
|
|
29
|
+
* and serializes the message for Ed25519 signing via FROST.
|
|
30
|
+
*
|
|
31
|
+
* @returns base64-encoded unsigned transaction message
|
|
32
|
+
*/
|
|
33
|
+
async buildTransaction(tx, fromAddress) {
|
|
34
|
+
try {
|
|
35
|
+
const fromPubkey = new web3_js_1.PublicKey(fromAddress);
|
|
36
|
+
const toPubkey = new web3_js_1.PublicKey(tx.to);
|
|
37
|
+
const instructions = [
|
|
38
|
+
web3_js_1.SystemProgram.transfer({
|
|
39
|
+
fromPubkey,
|
|
40
|
+
toPubkey,
|
|
41
|
+
lamports: tx.amount,
|
|
42
|
+
}),
|
|
43
|
+
];
|
|
44
|
+
// Add memo if specified
|
|
45
|
+
if (tx.memo) {
|
|
46
|
+
const MEMO_PROGRAM_ID = new web3_js_1.PublicKey('MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr');
|
|
47
|
+
instructions.push({
|
|
48
|
+
keys: [],
|
|
49
|
+
programId: MEMO_PROGRAM_ID,
|
|
50
|
+
data: Buffer.from(tx.memo),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
const { blockhash } = await this.connection.getLatestBlockhash('finalized');
|
|
54
|
+
const messageV0 = new web3_js_1.TransactionMessage({
|
|
55
|
+
payerKey: fromPubkey,
|
|
56
|
+
recentBlockhash: blockhash,
|
|
57
|
+
instructions,
|
|
58
|
+
}).compileToV0Message();
|
|
59
|
+
const transaction = new web3_js_1.VersionedTransaction(messageV0);
|
|
60
|
+
// Serialize the message that needs to be signed
|
|
61
|
+
const messageBytes = transaction.message.serialize();
|
|
62
|
+
return Buffer.from(messageBytes).toString('hex');
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
throw new errors_1.ChainError(`Failed to build Solana transaction: ${e.message}`, 'solana');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Attach an Ed25519 signature from FROST to the Solana transaction
|
|
70
|
+
*/
|
|
71
|
+
async attachSignature(unsignedTx, signature) {
|
|
72
|
+
try {
|
|
73
|
+
const messageBytes = Buffer.from(unsignedTx, 'hex');
|
|
74
|
+
const sigBytes = Buffer.from(signature.startsWith('0x') ? signature.slice(2) : signature, 'hex');
|
|
75
|
+
// The signed transaction is the message + signature
|
|
76
|
+
const signedData = {
|
|
77
|
+
message: unsignedTx,
|
|
78
|
+
signature: sigBytes.toString('hex'),
|
|
79
|
+
};
|
|
80
|
+
return Buffer.from(JSON.stringify(signedData)).toString('hex');
|
|
81
|
+
}
|
|
82
|
+
catch (e) {
|
|
83
|
+
throw new errors_1.ChainError(`Failed to attach Solana signature: ${e.message}`, 'solana');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Broadcast a signed Solana transaction
|
|
88
|
+
*
|
|
89
|
+
* @returns transaction signature (hash)
|
|
90
|
+
*/
|
|
91
|
+
async broadcast(signedTx) {
|
|
92
|
+
try {
|
|
93
|
+
const signedData = JSON.parse(Buffer.from(signedTx, 'hex').toString());
|
|
94
|
+
const messageBytes = Buffer.from(signedData.message, 'hex');
|
|
95
|
+
const sigBytes = Buffer.from(signedData.signature, 'hex');
|
|
96
|
+
// Reconstruct the versioned transaction with signature
|
|
97
|
+
const transaction = web3_js_1.VersionedTransaction.deserialize(Buffer.concat([
|
|
98
|
+
Buffer.from([1]), // 1 signature
|
|
99
|
+
sigBytes,
|
|
100
|
+
messageBytes,
|
|
101
|
+
]));
|
|
102
|
+
const txHash = await this.connection.sendTransaction(transaction, {
|
|
103
|
+
skipPreflight: false,
|
|
104
|
+
preflightCommitment: 'confirmed',
|
|
105
|
+
});
|
|
106
|
+
return txHash;
|
|
107
|
+
}
|
|
108
|
+
catch (e) {
|
|
109
|
+
throw new errors_1.ChainError(`Failed to broadcast Solana tx: ${e.message}`, 'solana');
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Get SOL balance in lamports
|
|
114
|
+
*/
|
|
115
|
+
async getBalance(address) {
|
|
116
|
+
try {
|
|
117
|
+
const pubkey = new web3_js_1.PublicKey(address);
|
|
118
|
+
const balance = await this.connection.getBalance(pubkey);
|
|
119
|
+
return balance.toString();
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
return '0';
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/** Get SOL balance in SOL (human-readable) */
|
|
126
|
+
async getBalanceSol(address) {
|
|
127
|
+
const lamports = await this.getBalance(address);
|
|
128
|
+
return parseInt(lamports) / web3_js_1.LAMPORTS_PER_SOL;
|
|
129
|
+
}
|
|
130
|
+
/** Get recent block height */
|
|
131
|
+
async getSlot() {
|
|
132
|
+
return this.connection.getSlot();
|
|
133
|
+
}
|
|
134
|
+
/** Get transaction details */
|
|
135
|
+
async getTransaction(signature) {
|
|
136
|
+
return this.connection.getTransaction(signature, {
|
|
137
|
+
maxSupportedTransactionVersion: 0,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/** Confirm transaction */
|
|
141
|
+
async confirmTransaction(signature) {
|
|
142
|
+
const { blockhash, lastValidBlockHeight } = await this.connection.getLatestBlockhash();
|
|
143
|
+
return this.connection.confirmTransaction({
|
|
144
|
+
signature,
|
|
145
|
+
blockhash,
|
|
146
|
+
lastValidBlockHeight,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
exports.SolanaAdapter = SolanaAdapter;
|
|
151
|
+
function createSolanaAdapter(rpcUrl) {
|
|
152
|
+
return new SolanaAdapter('mainnet', rpcUrl);
|
|
153
|
+
}
|
|
154
|
+
function createSolanaDevnetAdapter(rpcUrl) {
|
|
155
|
+
return new SolanaAdapter('devnet', rpcUrl);
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=solana.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solana.js","sourceRoot":"","sources":["../../src/chains/solana.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAyLH,kDAEC;AAED,8DAEC;AA7LD,6CASyB;AAEzB,4CAA6C;AAE7C,MAAM,WAAW,GAAG,qCAAqC,CAAC;AAC1D,MAAM,UAAU,GAAG,+BAA+B,CAAC;AAEnD,MAAa,aAAa;IAItB,YAAY,UAAgC,SAAS,EAAE,MAAe;QAClE,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;QAC1E,IAAI,CAAC,UAAU,GAAG,IAAI,oBAAU,CAAC,IAAI,CAAC,MAAM,EAAE,W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AAC,cAAc,CAAC,SAAiB;QAClC,OAAO,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,SAAS,EAAE;YAC7C,8BAA8B,EAAE,CAAC;SACpC,CAAC,CAAC;IACP,CAAC;IAED,0BAA0B;IAC1B,KAAK,CAAC,kBAAkB,CAAC,SAAiB;QACtC,MAAM,EAAE,SAAS,EAAE,oBAAoB,EAAE,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,kBAAkB,EAAE,CAAC;QACvF,OAAO,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC;YACtC,SAAS;YACT,SAAS;YACT,oBAAoB;SACvB,CAAC,CAAC;IACP,CAAC;CACJ;AArKD,sCAqKC;AAED,SAAgB,mBAAmB,CAAC,MAAe;IAC/C,OAAO,IAAI,aAAa,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;AAChD,CAAC;AAED,SAAgB,yBAAyB,CAAC,MAAe;IACrD,OAAO,IAAI,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sequence0 Client
|
|
3
|
+
*
|
|
4
|
+
* Main entry point for app developers to interact with the Sequence0
|
|
5
|
+
* decentralized signing network. Create wallets, sign transactions,
|
|
6
|
+
* and broadcast to any blockchain.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { Sequence0 } from '@sequence0/sdk';
|
|
11
|
+
*
|
|
12
|
+
* const s0 = new Sequence0({ network: 'mainnet' });
|
|
13
|
+
*
|
|
14
|
+
* // Create a new wallet
|
|
15
|
+
* const wallet = await s0.createWallet({ chain: 'ethereum' });
|
|
16
|
+
* console.log('Address:', wallet.address);
|
|
17
|
+
*
|
|
18
|
+
* // Sign and send a transaction
|
|
19
|
+
* const txHash = await wallet.sendTransaction({
|
|
20
|
+
* to: '0x...',
|
|
21
|
+
* value: '1000000000000000000', // 1 ETH
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
import { NetworkConfig, CreateWalletOptions, HealthResponse, StatusResponse, WalletDetail, SignResultResponse } from './types';
|
|
26
|
+
import { Wallet } from '../wallet/wallet';
|
|
27
|
+
import { WsClient } from '../utils/websocket';
|
|
28
|
+
export declare class Sequence0 {
|
|
29
|
+
private config;
|
|
30
|
+
private http;
|
|
31
|
+
private ws;
|
|
32
|
+
/**
|
|
33
|
+
* Create a new Sequence0 SDK client
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const s0 = new Sequence0({ network: 'mainnet' });
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
constructor(config: NetworkConfig);
|
|
41
|
+
/**
|
|
42
|
+
* Create a new threshold wallet via DKG ceremony
|
|
43
|
+
*
|
|
44
|
+
* Initiates Distributed Key Generation with the agent network.
|
|
45
|
+
* The private key is never assembled — each agent holds a share.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* const wallet = await s0.createWallet({ chain: 'ethereum' });
|
|
50
|
+
* console.log(wallet.address); // 0x...
|
|
51
|
+
* console.log(wallet.threshold); // { t: 17, n: 24 }
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
createWallet(options: CreateWalletOptions): Promise<Wallet>;
|
|
55
|
+
/**
|
|
56
|
+
* Get an existing wallet by its wallet ID
|
|
57
|
+
*
|
|
58
|
+
* Fetches wallet metadata from the agent network.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* const wallet = await s0.getWallet('my-wallet-id');
|
|
63
|
+
* const balance = await wallet.getBalance();
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
getWallet(walletId: string): Promise<Wallet>;
|
|
67
|
+
/**
|
|
68
|
+
* List all wallets managed by the agent network
|
|
69
|
+
*/
|
|
70
|
+
listWallets(): Promise<WalletDetail[]>;
|
|
71
|
+
/**
|
|
72
|
+
* Request a threshold signature from the agent network
|
|
73
|
+
*
|
|
74
|
+
* @param walletId - The wallet to sign with
|
|
75
|
+
* @param message - Hex-encoded message to sign
|
|
76
|
+
* @returns request ID for polling
|
|
77
|
+
*/
|
|
78
|
+
requestSignature(walletId: string, message: string): Promise<string>;
|
|
79
|
+
/**
|
|
80
|
+
* Poll for a signature result
|
|
81
|
+
*
|
|
82
|
+
* @param requestId - From requestSignature()
|
|
83
|
+
* @returns The signature when ready, null if still pending
|
|
84
|
+
*/
|
|
85
|
+
getSignatureResult(requestId: string): Promise<SignResultResponse>;
|
|
86
|
+
/**
|
|
87
|
+
* Request a signature and wait for completion
|
|
88
|
+
*
|
|
89
|
+
* @param walletId - Wallet ID
|
|
90
|
+
* @param message - Hex-encoded message
|
|
91
|
+
* @param timeoutMs - Timeout in ms (default: 30000)
|
|
92
|
+
* @returns hex-encoded signature
|
|
93
|
+
*/
|
|
94
|
+
signAndWait(walletId: string, message: string, timeoutMs?: number): Promise<string>;
|
|
95
|
+
/**
|
|
96
|
+
* Get agent network status
|
|
97
|
+
*/
|
|
98
|
+
getStatus(): Promise<StatusResponse>;
|
|
99
|
+
/**
|
|
100
|
+
* Health check
|
|
101
|
+
*/
|
|
102
|
+
health(): Promise<HealthResponse>;
|
|
103
|
+
/**
|
|
104
|
+
* Request key refresh for a wallet (proactive security)
|
|
105
|
+
*/
|
|
106
|
+
refreshKeys(walletId: string): Promise<void>;
|
|
107
|
+
/**
|
|
108
|
+
* Subscribe to real-time events from the agent network
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* const ws = await s0.subscribe();
|
|
113
|
+
* ws.on('SigningComplete', (e) => console.log('Signed:', e));
|
|
114
|
+
* ws.on('FeeCollected', (e) => console.log('Fee:', e));
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
subscribe(walletId?: string): Promise<WsClient>;
|
|
118
|
+
private getWsClient;
|
|
119
|
+
private getRpcUrl;
|
|
120
|
+
private getCurveForChain;
|
|
121
|
+
private generateWalletId;
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/core/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EACH,aAAa,EACb,mBAAmB,EAEnB,cAAc,EACd,cAAc,EAEd,YAAY,EAGZ,kBAAkB,EACrB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAAgB,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,QAAQ,EAAa,MAAM,oBAAoB,CAAC;AA+BzD,qBAAa,SAAS;IAClB,OAAO,CAAC,MAAM,CAA2D;IACzE,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,EAAE,CAAyB;IAEnC;;;;;;;OAOG;gBACS,MAAM,EAAE,aAAa;IAqBjC;;;;;;;;;;;;OAYG;IACG,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IAiEjE;;;;;;;;;;OAUG;IACG,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAsBlD;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IAS5C;;;;;;OAMG;IACG,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAQ1E;;;;;OAKG;IACG,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAIxE;;;;;;;OAOG;IACG,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;IAiCzF;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,cAAc,CAAC;IAI1C;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,cAAc,CAAC;IAIvC;;OAEG;IACG,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQlD;;;;;;;;;OASG;IACG,SAAS,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;YAWvC,WAAW;IASzB,OAAO,CAAC,SAAS;IAMjB,OAAO,CAAC,gBAAgB;IAOxB,OAAO,CAAC,gBAAgB;CAK3B"}
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Sequence0 Client
|
|
4
|
+
*
|
|
5
|
+
* Main entry point for app developers to interact with the Sequence0
|
|
6
|
+
* decentralized signing network. Create wallets, sign transactions,
|
|
7
|
+
* and broadcast to any blockchain.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { Sequence0 } from '@sequence0/sdk';
|
|
12
|
+
*
|
|
13
|
+
* const s0 = new Sequence0({ network: 'mainnet' });
|
|
14
|
+
*
|
|
15
|
+
* // Create a new wallet
|
|
16
|
+
* const wallet = await s0.createWallet({ chain: 'ethereum' });
|
|
17
|
+
* console.log('Address:', wallet.address);
|
|
18
|
+
*
|
|
19
|
+
* // Sign and send a transaction
|
|
20
|
+
* const txHash = await wallet.sendTransaction({
|
|
21
|
+
* to: '0x...',
|
|
22
|
+
* value: '1000000000000000000', // 1 ETH
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.Sequence0 = void 0;
|
|
28
|
+
const wallet_1 = require("../wallet/wallet");
|
|
29
|
+
const http_1 = require("../utils/http");
|
|
30
|
+
const websocket_1 = require("../utils/websocket");
|
|
31
|
+
const errors_1 = require("../utils/errors");
|
|
32
|
+
/** Default agent node URLs by network */
|
|
33
|
+
const AGENT_URLS = {
|
|
34
|
+
testnet: 'http://18.220.162.112:8080',
|
|
35
|
+
mainnet: 'https://api.sequence0.network',
|
|
36
|
+
};
|
|
37
|
+
/** Default chain RPC URLs */
|
|
38
|
+
const CHAIN_RPCS = {
|
|
39
|
+
testnet: {
|
|
40
|
+
ethereum: 'https://testnet-rpc.sequence0.network',
|
|
41
|
+
polygon: 'https://rpc-mumbai.maticvigil.com',
|
|
42
|
+
arbitrum: 'https://goerli-rollup.arbitrum.io/rpc',
|
|
43
|
+
solana: 'https://api.devnet.solana.com',
|
|
44
|
+
bitcoin: 'https://mempool.space/testnet/api',
|
|
45
|
+
},
|
|
46
|
+
mainnet: {
|
|
47
|
+
ethereum: 'https://eth.llamarpc.com',
|
|
48
|
+
polygon: 'https://polygon-rpc.com',
|
|
49
|
+
arbitrum: 'https://arb1.arbitrum.io/rpc',
|
|
50
|
+
optimism: 'https://mainnet.optimism.io',
|
|
51
|
+
base: 'https://mainnet.base.org',
|
|
52
|
+
bsc: 'https://bsc-dataseed.binance.org',
|
|
53
|
+
avalanche: 'https://api.avax.network/ext/bc/C/rpc',
|
|
54
|
+
solana: 'https://api.mainnet-beta.solana.com',
|
|
55
|
+
bitcoin: 'https://mempool.space/api',
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
class Sequence0 {
|
|
59
|
+
/**
|
|
60
|
+
* Create a new Sequence0 SDK client
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const s0 = new Sequence0({ network: 'mainnet' });
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
constructor(config) {
|
|
68
|
+
this.ws = null;
|
|
69
|
+
const network = config.network || 'mainnet';
|
|
70
|
+
const agentUrl = config.agentUrl || AGENT_URLS[network] || AGENT_URLS.mainnet;
|
|
71
|
+
this.config = {
|
|
72
|
+
...config,
|
|
73
|
+
network,
|
|
74
|
+
agentUrl,
|
|
75
|
+
};
|
|
76
|
+
this.http = new http_1.HttpClient({
|
|
77
|
+
baseUrl: agentUrl,
|
|
78
|
+
timeout: config.timeout || 30000,
|
|
79
|
+
headers: config.apiKey ? { 'X-API-Key': config.apiKey } : undefined,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
// ────────────────────────────────────────────────
|
|
83
|
+
// Wallet Management
|
|
84
|
+
// ────────────────────────────────────────────────
|
|
85
|
+
/**
|
|
86
|
+
* Create a new threshold wallet via DKG ceremony
|
|
87
|
+
*
|
|
88
|
+
* Initiates Distributed Key Generation with the agent network.
|
|
89
|
+
* The private key is never assembled — each agent holds a share.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* const wallet = await s0.createWallet({ chain: 'ethereum' });
|
|
94
|
+
* console.log(wallet.address); // 0x...
|
|
95
|
+
* console.log(wallet.threshold); // { t: 17, n: 24 }
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
async createWallet(options) {
|
|
99
|
+
const chain = options.chain || 'ethereum';
|
|
100
|
+
const threshold = options.threshold || { t: 17, n: 24 };
|
|
101
|
+
const curve = options.curve || this.getCurveForChain(chain);
|
|
102
|
+
const walletId = options.walletId || this.generateWalletId();
|
|
103
|
+
const timeout = options.timeout || 60000;
|
|
104
|
+
// Get agent peers to form committee
|
|
105
|
+
const status = await this.getStatus();
|
|
106
|
+
const participants = status.connected_peer_ids.slice(0, threshold.n);
|
|
107
|
+
if (participants.length < threshold.t) {
|
|
108
|
+
throw new errors_1.DkgError(`Not enough agents: need ${threshold.t}, only ${participants.length} online`);
|
|
109
|
+
}
|
|
110
|
+
// Connect WebSocket for real-time DKG updates
|
|
111
|
+
const ws = await this.getWsClient();
|
|
112
|
+
// Create a promise that resolves when DKG completes
|
|
113
|
+
const dkgComplete = ws.waitFor('WalletCreated', (e) => e.wallet_id === walletId, timeout);
|
|
114
|
+
// Initiate DKG via REST API
|
|
115
|
+
const dkgResponse = await this.http.post('/dkg/initiate', {
|
|
116
|
+
wallet_id: walletId,
|
|
117
|
+
participants,
|
|
118
|
+
threshold: threshold.t,
|
|
119
|
+
curve,
|
|
120
|
+
});
|
|
121
|
+
if (dkgResponse.status !== 'initiated') {
|
|
122
|
+
throw new errors_1.DkgError(`DKG initiation failed: ${dkgResponse.status}`);
|
|
123
|
+
}
|
|
124
|
+
// Wait for DKG to complete (agents coordinate via P2P)
|
|
125
|
+
let publicKey;
|
|
126
|
+
try {
|
|
127
|
+
const result = await dkgComplete;
|
|
128
|
+
publicKey = result.public_key || '';
|
|
129
|
+
}
|
|
130
|
+
catch (e) {
|
|
131
|
+
throw new errors_1.DkgError(`DKG ceremony timed out after ${timeout}ms. The agent network may be busy.`);
|
|
132
|
+
}
|
|
133
|
+
// Derive address from public key based on chain
|
|
134
|
+
const address = publicKey || walletId; // Agent returns the address
|
|
135
|
+
return new wallet_1.Wallet({
|
|
136
|
+
walletId,
|
|
137
|
+
chain,
|
|
138
|
+
address,
|
|
139
|
+
threshold,
|
|
140
|
+
network: this.config.network,
|
|
141
|
+
agentUrl: this.config.agentUrl,
|
|
142
|
+
rpcUrl: this.getRpcUrl(chain),
|
|
143
|
+
curve,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Get an existing wallet by its wallet ID
|
|
148
|
+
*
|
|
149
|
+
* Fetches wallet metadata from the agent network.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```typescript
|
|
153
|
+
* const wallet = await s0.getWallet('my-wallet-id');
|
|
154
|
+
* const balance = await wallet.getBalance();
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
async getWallet(walletId) {
|
|
158
|
+
const wallets = await this.listWallets();
|
|
159
|
+
const detail = wallets.find((w) => w.wallet_id === walletId);
|
|
160
|
+
if (!detail) {
|
|
161
|
+
throw new errors_1.Sequence0Error(`Wallet '${walletId}' not found on ${this.config.network}`);
|
|
162
|
+
}
|
|
163
|
+
const chain = (detail.chain || 'ethereum');
|
|
164
|
+
return new wallet_1.Wallet({
|
|
165
|
+
walletId: detail.wallet_id,
|
|
166
|
+
chain,
|
|
167
|
+
address: detail.address,
|
|
168
|
+
threshold: { t: detail.threshold, n: detail.size },
|
|
169
|
+
network: this.config.network,
|
|
170
|
+
agentUrl: this.config.agentUrl,
|
|
171
|
+
rpcUrl: this.getRpcUrl(chain),
|
|
172
|
+
curve: this.getCurveForChain(chain),
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* List all wallets managed by the agent network
|
|
177
|
+
*/
|
|
178
|
+
async listWallets() {
|
|
179
|
+
const response = await this.http.get('/wallets');
|
|
180
|
+
return response.wallets;
|
|
181
|
+
}
|
|
182
|
+
// ────────────────────────────────────────────────
|
|
183
|
+
// Signing (Low-Level)
|
|
184
|
+
// ────────────────────────────────────────────────
|
|
185
|
+
/**
|
|
186
|
+
* Request a threshold signature from the agent network
|
|
187
|
+
*
|
|
188
|
+
* @param walletId - The wallet to sign with
|
|
189
|
+
* @param message - Hex-encoded message to sign
|
|
190
|
+
* @returns request ID for polling
|
|
191
|
+
*/
|
|
192
|
+
async requestSignature(walletId, message) {
|
|
193
|
+
const response = await this.http.post('/sign', {
|
|
194
|
+
wallet_id: walletId,
|
|
195
|
+
message,
|
|
196
|
+
});
|
|
197
|
+
return response.request_id;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Poll for a signature result
|
|
201
|
+
*
|
|
202
|
+
* @param requestId - From requestSignature()
|
|
203
|
+
* @returns The signature when ready, null if still pending
|
|
204
|
+
*/
|
|
205
|
+
async getSignatureResult(requestId) {
|
|
206
|
+
return this.http.get(`/sign/${requestId}`);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Request a signature and wait for completion
|
|
210
|
+
*
|
|
211
|
+
* @param walletId - Wallet ID
|
|
212
|
+
* @param message - Hex-encoded message
|
|
213
|
+
* @param timeoutMs - Timeout in ms (default: 30000)
|
|
214
|
+
* @returns hex-encoded signature
|
|
215
|
+
*/
|
|
216
|
+
async signAndWait(walletId, message, timeoutMs = 30000) {
|
|
217
|
+
const requestId = await this.requestSignature(walletId, message);
|
|
218
|
+
// Try WebSocket first for real-time notification
|
|
219
|
+
try {
|
|
220
|
+
const ws = await this.getWsClient();
|
|
221
|
+
const result = await ws.waitFor('SigningComplete', (e) => e.request_id === requestId, timeoutMs);
|
|
222
|
+
return result.signature;
|
|
223
|
+
}
|
|
224
|
+
catch {
|
|
225
|
+
// Fall back to polling
|
|
226
|
+
}
|
|
227
|
+
// Polling fallback
|
|
228
|
+
const deadline = Date.now() + timeoutMs;
|
|
229
|
+
while (Date.now() < deadline) {
|
|
230
|
+
const result = await this.getSignatureResult(requestId);
|
|
231
|
+
if (result.status === 'complete' && result.signature) {
|
|
232
|
+
return result.signature;
|
|
233
|
+
}
|
|
234
|
+
await sleep(500);
|
|
235
|
+
}
|
|
236
|
+
throw new errors_1.TimeoutError(`Signing request ${requestId} timed out after ${timeoutMs}ms`);
|
|
237
|
+
}
|
|
238
|
+
// ────────────────────────────────────────────────
|
|
239
|
+
// Network Status
|
|
240
|
+
// ────────────────────────────────────────────────
|
|
241
|
+
/**
|
|
242
|
+
* Get agent network status
|
|
243
|
+
*/
|
|
244
|
+
async getStatus() {
|
|
245
|
+
return this.http.get('/status');
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Health check
|
|
249
|
+
*/
|
|
250
|
+
async health() {
|
|
251
|
+
return this.http.get('/health');
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Request key refresh for a wallet (proactive security)
|
|
255
|
+
*/
|
|
256
|
+
async refreshKeys(walletId) {
|
|
257
|
+
await this.http.post('/refresh', { wallet_id: walletId });
|
|
258
|
+
}
|
|
259
|
+
// ────────────────────────────────────────────────
|
|
260
|
+
// WebSocket Events
|
|
261
|
+
// ────────────────────────────────────────────────
|
|
262
|
+
/**
|
|
263
|
+
* Subscribe to real-time events from the agent network
|
|
264
|
+
*
|
|
265
|
+
* @example
|
|
266
|
+
* ```typescript
|
|
267
|
+
* const ws = await s0.subscribe();
|
|
268
|
+
* ws.on('SigningComplete', (e) => console.log('Signed:', e));
|
|
269
|
+
* ws.on('FeeCollected', (e) => console.log('Fee:', e));
|
|
270
|
+
* ```
|
|
271
|
+
*/
|
|
272
|
+
async subscribe(walletId) {
|
|
273
|
+
const wsUrl = this.config.agentUrl.replace(/^http/, 'ws') + '/ws';
|
|
274
|
+
const ws = new websocket_1.WsClient({ url: wsUrl, walletId });
|
|
275
|
+
await ws.connect();
|
|
276
|
+
return ws;
|
|
277
|
+
}
|
|
278
|
+
// ────────────────────────────────────────────────
|
|
279
|
+
// Internals
|
|
280
|
+
// ────────────────────────────────────────────────
|
|
281
|
+
async getWsClient() {
|
|
282
|
+
if (!this.ws || !this.ws.connected) {
|
|
283
|
+
const wsUrl = this.config.agentUrl.replace(/^http/, 'ws') + '/ws';
|
|
284
|
+
this.ws = new websocket_1.WsClient({ url: wsUrl });
|
|
285
|
+
await this.ws.connect();
|
|
286
|
+
}
|
|
287
|
+
return this.ws;
|
|
288
|
+
}
|
|
289
|
+
getRpcUrl(chain) {
|
|
290
|
+
if (this.config.rpcUrl)
|
|
291
|
+
return this.config.rpcUrl;
|
|
292
|
+
const networkRpcs = CHAIN_RPCS[this.config.network] || CHAIN_RPCS.mainnet;
|
|
293
|
+
return networkRpcs[chain] || networkRpcs.ethereum;
|
|
294
|
+
}
|
|
295
|
+
getCurveForChain(chain) {
|
|
296
|
+
if (chain === 'solana' || chain === 'near' || chain === 'sui' || chain === 'aptos') {
|
|
297
|
+
return 'ed25519';
|
|
298
|
+
}
|
|
299
|
+
return 'secp256k1';
|
|
300
|
+
}
|
|
301
|
+
generateWalletId() {
|
|
302
|
+
const timestamp = Date.now().toString(36);
|
|
303
|
+
const random = Math.random().toString(36).slice(2, 8);
|
|
304
|
+
return `s0-${timestamp}-${random}`;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
exports.Sequence0 = Sequence0;
|
|
308
|
+
function sleep(ms) {
|
|
309
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
310
|
+
}
|
|
311
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/core/client.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAcH,6CAAwD;AACxD,wCAA2C;AAC3C,kDAAyD;AACzD,4CAAuF;AAEvF,yCAAyC;AACzC,MAAM,UAAU,GAA2B;IACvC,OAAO,EAAE,4BAA4B;IACrC,OAAO,EAAE,+BAA+B;CAC3C,CAAC;AAEF,6BAA6B;AAC7B,MAAM,UAAU,GAA2C;IACvD,OAAO,EAAE;QACL,QAAQ,EAAE,uCAAuC;QACjD,OAAO,EAAE,mCAAmC;QAC5C,QAAQ,EAAE,uCAAuC;QACjD,MAAM,EAAE,+BAA+B;QACvC,OAAO,EAAE,mCAAmC;KAC/C;IACD,OAAO,EAAE;QACL,QAAQ,EAAE,0BAA0B;QACpC,OAAO,EAAE,yBAAyB;QAClC,QAAQ,EAAE,8BAA8B;QACxC,QAAQ,EAAE,6BAA6B;QACvC,IAAI,EAAE,0BAA0B;QAChC,GAAG,EAAE,kCAAkC;QACvC,SAAS,EAAE,uCAAuC;QAClD,MAAM,EAAE,qCAAqC;QAC7C,OAAO,EAAE,2BAA2B;KACvC;CACJ,CAAC;AAEF,MAAa,SAAS;IAKlB;;;;;;;OAOG;IACH,YAAY,MAAqB;QAVzB,OAAE,GAAoB,IAAI,CAAC;QAW/B,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,SAAS,CAAC;QAC5C,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC;QAE9E,IAAI,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