clanker-wallet 0.1.0 → 0.2.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 +3 -3
- package/dist/client.d.ts +1 -0
- package/dist/client.js +16 -2
- package/dist/types.d.ts +2 -0
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
#
|
|
1
|
+
# clanker-wallet
|
|
2
2
|
|
|
3
3
|
TypeScript SDK for AI agents to request human-approved Ethereum transactions over an E2E encrypted relay.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install
|
|
8
|
+
npm install clanker-wallet
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Quickstart
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import { ClankerWallet } from '
|
|
14
|
+
import { ClankerWallet } from 'clanker-wallet'
|
|
15
15
|
|
|
16
16
|
const wallet = new ClankerWallet({ agentName: 'my-trading-bot' })
|
|
17
17
|
|
package/dist/client.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare class ClankerWallet extends TypedEmitter {
|
|
|
17
17
|
private humanPubkeyHex;
|
|
18
18
|
private relayUrl;
|
|
19
19
|
private humanWallet;
|
|
20
|
+
private mode;
|
|
20
21
|
constructor(options?: ClankerWalletOptions);
|
|
21
22
|
/** whether this agent has been paired with a human */
|
|
22
23
|
get paired(): boolean;
|
package/dist/client.js
CHANGED
|
@@ -12,6 +12,7 @@ export class ClankerWallet extends TypedEmitter {
|
|
|
12
12
|
humanPubkeyHex = null;
|
|
13
13
|
relayUrl = null;
|
|
14
14
|
humanWallet = null;
|
|
15
|
+
mode = 'encrypted';
|
|
15
16
|
constructor(options = {}) {
|
|
16
17
|
super();
|
|
17
18
|
const kp = options.secretKey
|
|
@@ -42,6 +43,7 @@ export class ClankerWallet extends TypedEmitter {
|
|
|
42
43
|
this.humanPubkeyHex = data.pubkey;
|
|
43
44
|
this.relayUrl = data.relay;
|
|
44
45
|
this.humanWallet = data.wallet || null;
|
|
46
|
+
this.mode = data.mode || 'encrypted';
|
|
45
47
|
this.emit('paired', { relay: data.relay, wallet: data.wallet || '' });
|
|
46
48
|
return data;
|
|
47
49
|
}
|
|
@@ -74,6 +76,8 @@ export class ClankerWallet extends TypedEmitter {
|
|
|
74
76
|
const secretKey = this.secretKey;
|
|
75
77
|
const agentPubkeyHex = toHex(this.publicKey);
|
|
76
78
|
const signingPubkeyHex = toHex(this.signingPublicKey);
|
|
79
|
+
const mode = this.mode;
|
|
80
|
+
const humanWallet = this.humanWallet;
|
|
77
81
|
return new Promise((resolve, reject) => {
|
|
78
82
|
let ws;
|
|
79
83
|
let timer;
|
|
@@ -140,11 +144,21 @@ export class ClankerWallet extends TypedEmitter {
|
|
|
140
144
|
ciphertext,
|
|
141
145
|
signing_pubkey: signingPubkeyHex,
|
|
142
146
|
};
|
|
143
|
-
|
|
147
|
+
const wsMsg = {
|
|
144
148
|
type: 'message',
|
|
145
149
|
room: humanPubkeyHex,
|
|
146
150
|
payload: JSON.stringify(envelope),
|
|
147
|
-
}
|
|
151
|
+
};
|
|
152
|
+
if (mode === 'managed') {
|
|
153
|
+
wsMsg.simulate = {
|
|
154
|
+
from: humanWallet || '',
|
|
155
|
+
to: options.transaction.to,
|
|
156
|
+
value: options.transaction.value,
|
|
157
|
+
data: options.transaction.data,
|
|
158
|
+
chainId: options.chain_id,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
ws.send(JSON.stringify(wsMsg));
|
|
148
162
|
this.emit('request_sent', { request_id: requestId });
|
|
149
163
|
return;
|
|
150
164
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -40,6 +40,8 @@ export interface PairingData {
|
|
|
40
40
|
pubkey: string;
|
|
41
41
|
relay: string;
|
|
42
42
|
wallet: string;
|
|
43
|
+
/** 'managed' = relay simulates server-side; 'encrypted' = user provides own keys */
|
|
44
|
+
mode?: 'encrypted' | 'managed';
|
|
43
45
|
}
|
|
44
46
|
/** options for requestTx */
|
|
45
47
|
export interface RequestTxOptions {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clanker-wallet",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,10 +15,9 @@
|
|
|
15
15
|
"author": "Clanker Wallet Contributors",
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
18
|
-
"url": "git+https://github.com/almogdepaz/
|
|
19
|
-
"directory": "sdk"
|
|
18
|
+
"url": "git+https://github.com/almogdepaz/clanker-wallet.git"
|
|
20
19
|
},
|
|
21
|
-
"homepage": "https://github.com/almogdepaz/
|
|
20
|
+
"homepage": "https://github.com/almogdepaz/clanker-wallet#readme",
|
|
22
21
|
"keywords": ["wallet", "ai-agent", "ethereum", "e2e-encrypted", "transaction-approval"],
|
|
23
22
|
"scripts": {
|
|
24
23
|
"build": "tsc -p tsconfig.build.json",
|
|
@@ -32,7 +31,9 @@
|
|
|
32
31
|
},
|
|
33
32
|
"devDependencies": {
|
|
34
33
|
"@types/bun": "^1.3.8",
|
|
34
|
+
"@types/ws": "^8.18.1",
|
|
35
35
|
"typescript": "^5.4.0",
|
|
36
|
-
"vitest": "^2.1.0"
|
|
36
|
+
"vitest": "^2.1.0",
|
|
37
|
+
"ws": "^8.19.0"
|
|
37
38
|
}
|
|
38
39
|
}
|