mpp-vault-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 +69 -0
- package/dist/index.d.ts +84 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +194 -0
- package/dist/index.js.map +1 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# mpp-vault-sdk
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for [MPP Vault](https://github.com/mppvault/mppvault) — agent-to-agent USDC payments on Solana.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install mpp-vault-sdk @solana/web3.js
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { Connection, Keypair } from "@solana/web3.js";
|
|
15
|
+
import { MppVaultSDK } from "mpp-vault-sdk";
|
|
16
|
+
|
|
17
|
+
const sdk = new MppVaultSDK({
|
|
18
|
+
connection: new Connection("https://api.mainnet-beta.solana.com"),
|
|
19
|
+
agentKeypair: Keypair.fromSecretKey(/* ... */),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// Execute a payment
|
|
23
|
+
const result = await sdk.pay(
|
|
24
|
+
"YOUR_SUB_ACCOUNT_ADDRESS",
|
|
25
|
+
"RECIPIENT_ADDRESS",
|
|
26
|
+
5.00, // USDC
|
|
27
|
+
);
|
|
28
|
+
console.log("Tx:", result.signature);
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## API
|
|
32
|
+
|
|
33
|
+
### `new MppVaultSDK(config)`
|
|
34
|
+
|
|
35
|
+
| Parameter | Type | Description |
|
|
36
|
+
|-----------|------|-------------|
|
|
37
|
+
| `connection` | `Connection` | Solana RPC connection |
|
|
38
|
+
| `programId` | `PublicKey \| string` | Optional. Defaults to mainnet program |
|
|
39
|
+
| `agentKeypair` | `Keypair` | Agent keypair for signing transactions |
|
|
40
|
+
|
|
41
|
+
### `sdk.pay(subAccount, recipient, amount)`
|
|
42
|
+
|
|
43
|
+
Execute a USDC payment from a sub-account to a whitelisted recipient.
|
|
44
|
+
|
|
45
|
+
Returns `{ signature, amount, recipient }`.
|
|
46
|
+
|
|
47
|
+
### `sdk.canPay(subAccount, amount)`
|
|
48
|
+
|
|
49
|
+
Pre-check if a payment will succeed. Checks balance, per-tx limit, daily limit, and account status.
|
|
50
|
+
|
|
51
|
+
Returns `{ allowed: boolean, reason?: string }`.
|
|
52
|
+
|
|
53
|
+
### `sdk.getSubAccount(address)`
|
|
54
|
+
|
|
55
|
+
Read sub-account state from on-chain data.
|
|
56
|
+
|
|
57
|
+
Returns `SubAccountInfo` with balance, spent, rules, status, and transaction count.
|
|
58
|
+
|
|
59
|
+
## Requirements
|
|
60
|
+
|
|
61
|
+
- The recipient must be whitelisted on the sub-account
|
|
62
|
+
- The agent keypair needs ~0.01 SOL for transaction fees
|
|
63
|
+
- Funds come from the sub-account, not the agent wallet
|
|
64
|
+
|
|
65
|
+
## Links
|
|
66
|
+
|
|
67
|
+
- [MPP Vault](https://github.com/mppvault/mppvault)
|
|
68
|
+
- [Documentation](https://mppvault.com/docs)
|
|
69
|
+
- [Agent Registry](https://mppvault.com/registry)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Connection, PublicKey, Keypair } from "@solana/web3.js";
|
|
2
|
+
export interface MppVaultConfig {
|
|
3
|
+
/** Solana RPC connection */
|
|
4
|
+
connection: Connection;
|
|
5
|
+
/** MPP Vault program ID (defaults to mainnet deployment) */
|
|
6
|
+
programId?: PublicKey | string;
|
|
7
|
+
/** Agent keypair used to sign payment transactions */
|
|
8
|
+
agentKeypair: Keypair;
|
|
9
|
+
}
|
|
10
|
+
export interface SubAccountInfo {
|
|
11
|
+
/** Vault PDA this sub-account belongs to */
|
|
12
|
+
vault: string;
|
|
13
|
+
/** Human-readable name */
|
|
14
|
+
name: string;
|
|
15
|
+
/** Agent identifier */
|
|
16
|
+
agentId: string;
|
|
17
|
+
/** Current USDC balance */
|
|
18
|
+
balance: number;
|
|
19
|
+
/** Total budget allocation in USDC */
|
|
20
|
+
totalBudget: number;
|
|
21
|
+
/** Total USDC spent all-time */
|
|
22
|
+
spent: number;
|
|
23
|
+
/** Account status */
|
|
24
|
+
status: "active" | "paused" | "closed";
|
|
25
|
+
/** Max USDC per transaction (-1 = unlimited) */
|
|
26
|
+
maxPerTx: number;
|
|
27
|
+
/** Max USDC per day (-1 = unlimited) */
|
|
28
|
+
maxPerDay: number;
|
|
29
|
+
/** USDC spent today (resets daily) */
|
|
30
|
+
spentToday: number;
|
|
31
|
+
/** Total transaction count */
|
|
32
|
+
txCount: number;
|
|
33
|
+
}
|
|
34
|
+
export interface PaymentResult {
|
|
35
|
+
/** Transaction signature */
|
|
36
|
+
signature: string;
|
|
37
|
+
/** Amount paid in USDC */
|
|
38
|
+
amount: number;
|
|
39
|
+
/** Recipient wallet address */
|
|
40
|
+
recipient: string;
|
|
41
|
+
}
|
|
42
|
+
export interface PaymentCheck {
|
|
43
|
+
/** Whether the payment would succeed */
|
|
44
|
+
allowed: boolean;
|
|
45
|
+
/** Reason if not allowed */
|
|
46
|
+
reason?: string;
|
|
47
|
+
}
|
|
48
|
+
export declare class MppVaultSDK {
|
|
49
|
+
readonly connection: Connection;
|
|
50
|
+
readonly programId: PublicKey;
|
|
51
|
+
readonly agent: Keypair;
|
|
52
|
+
constructor(config: MppVaultConfig);
|
|
53
|
+
/**
|
|
54
|
+
* Execute a USDC payment from a sub-account to a whitelisted recipient.
|
|
55
|
+
*
|
|
56
|
+
* The agent keypair is used as the signer. The recipient must be
|
|
57
|
+
* whitelisted on the sub-account or the transaction will be rejected.
|
|
58
|
+
*
|
|
59
|
+
* @param subAccountAddress - The sub-account PDA address
|
|
60
|
+
* @param recipientAddress - The whitelisted recipient wallet
|
|
61
|
+
* @param amountUsdc - Amount in USDC (e.g. 5.00 = five dollars)
|
|
62
|
+
* @returns Transaction signature and payment details
|
|
63
|
+
*/
|
|
64
|
+
pay(subAccountAddress: string | PublicKey, recipientAddress: string | PublicKey, amountUsdc: number): Promise<PaymentResult>;
|
|
65
|
+
/**
|
|
66
|
+
* Read sub-account data from on-chain state.
|
|
67
|
+
*
|
|
68
|
+
* @param subAccountAddress - The sub-account PDA address
|
|
69
|
+
* @returns Parsed sub-account info including balance, rules, and stats
|
|
70
|
+
*/
|
|
71
|
+
getSubAccount(subAccountAddress: string | PublicKey): Promise<SubAccountInfo>;
|
|
72
|
+
/**
|
|
73
|
+
* Pre-check whether a payment of the given amount would succeed.
|
|
74
|
+
*
|
|
75
|
+
* Checks sub-account status, balance, per-tx limit, and daily limit.
|
|
76
|
+
* Does NOT check whitelist (that requires an on-chain lookup).
|
|
77
|
+
*
|
|
78
|
+
* @param subAccountAddress - The sub-account PDA address
|
|
79
|
+
* @param amountUsdc - Amount in USDC to check
|
|
80
|
+
* @returns Whether the payment is allowed, with reason if not
|
|
81
|
+
*/
|
|
82
|
+
canPay(subAccountAddress: string | PublicKey, amountUsdc: number): Promise<PaymentCheck>;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,OAAO,EAIR,MAAM,iBAAiB,CAAC;AAmEzB,MAAM,WAAW,cAAc;IAC7B,4BAA4B;IAC5B,UAAU,EAAE,UAAU,CAAC;IACvB,4DAA4D;IAC5D,SAAS,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAC/B,sDAAsD;IACtD,YAAY,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,cAAc;IAC7B,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,0BAA0B;IAC1B,IAAI,E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AAE,MAAM,GAAG,SAAS,EACrC,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,YAAY,CAAC;CA0BzB"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MppVaultSDK = void 0;
|
|
4
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
5
|
+
const TOKEN_PROGRAM_ID = new web3_js_1.PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
|
|
6
|
+
const ASSOCIATED_TOKEN_PROGRAM_ID = new web3_js_1.PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");
|
|
7
|
+
const USDC_MINT = new web3_js_1.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
|
|
8
|
+
const DEFAULT_PROGRAM_ID = "2WBK34gnJjYRN4J8fB97CTwRqPJYpx8XsdhDSb1fpPBx";
|
|
9
|
+
// ── encoding helpers ──────────────────────────────
|
|
10
|
+
function encodeU64(value) {
|
|
11
|
+
const buf = Buffer.alloc(8);
|
|
12
|
+
let v = value;
|
|
13
|
+
for (let i = 0; i < 8; i++) {
|
|
14
|
+
buf[i] = Number(v & 0xffn);
|
|
15
|
+
v >>= 8n;
|
|
16
|
+
}
|
|
17
|
+
return buf;
|
|
18
|
+
}
|
|
19
|
+
function decodeU64(buf, offset) {
|
|
20
|
+
let result = 0n;
|
|
21
|
+
for (let i = 7; i >= 0; i--) {
|
|
22
|
+
result = (result << 8n) | BigInt(buf[offset + i]);
|
|
23
|
+
}
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
function readString(buf, offset) {
|
|
27
|
+
const len = buf[offset] |
|
|
28
|
+
(buf[offset + 1] << 8) |
|
|
29
|
+
(buf[offset + 2] << 16) |
|
|
30
|
+
(buf[offset + 3] << 24);
|
|
31
|
+
const str = Buffer.from(buf.slice(offset + 4, offset + 4 + len)).toString("utf-8");
|
|
32
|
+
return [str, offset + 4 + len];
|
|
33
|
+
}
|
|
34
|
+
async function anchorDiscriminator(name) {
|
|
35
|
+
const data = new TextEncoder().encode(`global:${name}`);
|
|
36
|
+
const hashBuffer = await globalThis.crypto.subtle.digest("SHA-256", new Uint8Array(data));
|
|
37
|
+
return Buffer.from(new Uint8Array(hashBuffer).slice(0, 8));
|
|
38
|
+
}
|
|
39
|
+
function findATA(owner, mint) {
|
|
40
|
+
return web3_js_1.PublicKey.findProgramAddressSync([owner.toBuffer(), TOKEN_PROGRAM_ID.toBuffer(), mint.toBuffer()], ASSOCIATED_TOKEN_PROGRAM_ID)[0];
|
|
41
|
+
}
|
|
42
|
+
// ── SDK ───────────────────────────────────────────
|
|
43
|
+
class MppVaultSDK {
|
|
44
|
+
constructor(config) {
|
|
45
|
+
this.connection = config.connection;
|
|
46
|
+
this.programId =
|
|
47
|
+
config.programId == null
|
|
48
|
+
? new web3_js_1.PublicKey(DEFAULT_PROGRAM_ID)
|
|
49
|
+
: typeof config.programId === "string"
|
|
50
|
+
? new web3_js_1.PublicKey(config.programId)
|
|
51
|
+
: config.programId;
|
|
52
|
+
this.agent = config.agentKeypair;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Execute a USDC payment from a sub-account to a whitelisted recipient.
|
|
56
|
+
*
|
|
57
|
+
* The agent keypair is used as the signer. The recipient must be
|
|
58
|
+
* whitelisted on the sub-account or the transaction will be rejected.
|
|
59
|
+
*
|
|
60
|
+
* @param subAccountAddress - The sub-account PDA address
|
|
61
|
+
* @param recipientAddress - The whitelisted recipient wallet
|
|
62
|
+
* @param amountUsdc - Amount in USDC (e.g. 5.00 = five dollars)
|
|
63
|
+
* @returns Transaction signature and payment details
|
|
64
|
+
*/
|
|
65
|
+
async pay(subAccountAddress, recipientAddress, amountUsdc) {
|
|
66
|
+
const subAccount = new web3_js_1.PublicKey(subAccountAddress);
|
|
67
|
+
const recipient = new web3_js_1.PublicKey(recipientAddress);
|
|
68
|
+
const amountLamports = BigInt(Math.round(amountUsdc * 1e6));
|
|
69
|
+
const subInfo = await this.connection.getAccountInfo(subAccount);
|
|
70
|
+
if (!subInfo)
|
|
71
|
+
throw new Error("Sub-account not found on-chain");
|
|
72
|
+
const vaultPubkey = new web3_js_1.PublicKey(subInfo.data.slice(8, 40));
|
|
73
|
+
const whitelistPDA = web3_js_1.PublicKey.findProgramAddressSync([
|
|
74
|
+
Buffer.from("whitelist"),
|
|
75
|
+
subAccount.toBuffer(),
|
|
76
|
+
recipient.toBuffer(),
|
|
77
|
+
], this.programId)[0];
|
|
78
|
+
const vaultTokenAccount = findATA(vaultPubkey, USDC_MINT);
|
|
79
|
+
const recipientTokenAccount = findATA(recipient, USDC_MINT);
|
|
80
|
+
const data = Buffer.concat([
|
|
81
|
+
await anchorDiscriminator("execute_payment"),
|
|
82
|
+
encodeU64(amountLamports),
|
|
83
|
+
]);
|
|
84
|
+
const ix = new web3_js_1.TransactionInstruction({
|
|
85
|
+
programId: this.programId,
|
|
86
|
+
keys: [
|
|
87
|
+
{ pubkey: this.agent.publicKey, isSigner: true, isWritable: false },
|
|
88
|
+
{ pubkey: vaultPubkey, isSigner: false, isWritable: false },
|
|
89
|
+
{ pubkey: subAccount, isSigner: false, isWritable: true },
|
|
90
|
+
{ pubkey: whitelistPDA, isSigner: false, isWritable: false },
|
|
91
|
+
{ pubkey: vaultTokenAccount, isSigner: false, isWritable: true },
|
|
92
|
+
{ pubkey: recipient, isSigner: false, isWritable: true },
|
|
93
|
+
{ pubkey: recipientTokenAccount, isSigner: false, isWritable: true },
|
|
94
|
+
{ pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
95
|
+
],
|
|
96
|
+
data,
|
|
97
|
+
});
|
|
98
|
+
const tx = new web3_js_1.Transaction().add(ix);
|
|
99
|
+
const signature = await (0, web3_js_1.sendAndConfirmTransaction)(this.connection, tx, [this.agent], { commitment: "confirmed" });
|
|
100
|
+
return {
|
|
101
|
+
signature,
|
|
102
|
+
amount: amountUsdc,
|
|
103
|
+
recipient: recipient.toBase58(),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Read sub-account data from on-chain state.
|
|
108
|
+
*
|
|
109
|
+
* @param subAccountAddress - The sub-account PDA address
|
|
110
|
+
* @returns Parsed sub-account info including balance, rules, and stats
|
|
111
|
+
*/
|
|
112
|
+
async getSubAccount(subAccountAddress) {
|
|
113
|
+
const pubkey = new web3_js_1.PublicKey(subAccountAddress);
|
|
114
|
+
const info = await this.connection.getAccountInfo(pubkey);
|
|
115
|
+
if (!info)
|
|
116
|
+
throw new Error("Sub-account not found");
|
|
117
|
+
const d = info.data;
|
|
118
|
+
let offset = 8;
|
|
119
|
+
const vault = new web3_js_1.PublicKey(d.slice(offset, offset + 32)).toBase58();
|
|
120
|
+
offset += 32;
|
|
121
|
+
const [name, off2] = readString(d, offset);
|
|
122
|
+
offset = off2;
|
|
123
|
+
const [agentId, off3] = readString(d, offset);
|
|
124
|
+
offset = off3;
|
|
125
|
+
const balance = decodeU64(d, offset);
|
|
126
|
+
offset += 8;
|
|
127
|
+
const totalBudget = decodeU64(d, offset);
|
|
128
|
+
offset += 8;
|
|
129
|
+
const spent = decodeU64(d, offset);
|
|
130
|
+
offset += 8;
|
|
131
|
+
const statusByte = d[offset];
|
|
132
|
+
offset += 1;
|
|
133
|
+
const maxPerTx = decodeU64(d, offset);
|
|
134
|
+
offset += 8;
|
|
135
|
+
const maxPerDay = decodeU64(d, offset);
|
|
136
|
+
offset += 8;
|
|
137
|
+
const spentToday = decodeU64(d, offset);
|
|
138
|
+
offset += 8;
|
|
139
|
+
offset += 8; // lastDayReset
|
|
140
|
+
offset += 4 + 4 + 1 + 1; // timeWindow fields
|
|
141
|
+
offset += 8 + 8; // autoTopup fields
|
|
142
|
+
const txCount = decodeU64(d, offset);
|
|
143
|
+
const U64_MAX = 18446744073709551615n;
|
|
144
|
+
const toUsdc = (v) => v >= U64_MAX - 1000n ? -1 : Number(v) / 1e6;
|
|
145
|
+
const statusMap = ["active", "paused", "closed"];
|
|
146
|
+
return {
|
|
147
|
+
vault,
|
|
148
|
+
name,
|
|
149
|
+
agentId,
|
|
150
|
+
balance: toUsdc(balance),
|
|
151
|
+
totalBudget: toUsdc(totalBudget),
|
|
152
|
+
spent: toUsdc(spent),
|
|
153
|
+
status: statusMap[statusByte] ?? "closed",
|
|
154
|
+
maxPerTx: toUsdc(maxPerTx),
|
|
155
|
+
maxPerDay: toUsdc(maxPerDay),
|
|
156
|
+
spentToday: toUsdc(spentToday),
|
|
157
|
+
txCount: Number(txCount),
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Pre-check whether a payment of the given amount would succeed.
|
|
162
|
+
*
|
|
163
|
+
* Checks sub-account status, balance, per-tx limit, and daily limit.
|
|
164
|
+
* Does NOT check whitelist (that requires an on-chain lookup).
|
|
165
|
+
*
|
|
166
|
+
* @param subAccountAddress - The sub-account PDA address
|
|
167
|
+
* @param amountUsdc - Amount in USDC to check
|
|
168
|
+
* @returns Whether the payment is allowed, with reason if not
|
|
169
|
+
*/
|
|
170
|
+
async canPay(subAccountAddress, amountUsdc) {
|
|
171
|
+
const sub = await this.getSubAccount(subAccountAddress);
|
|
172
|
+
if (sub.status !== "active")
|
|
173
|
+
return { allowed: false, reason: "Sub-account is not active" };
|
|
174
|
+
if (sub.balance < amountUsdc)
|
|
175
|
+
return {
|
|
176
|
+
allowed: false,
|
|
177
|
+
reason: `Insufficient balance: ${sub.balance} USDC`,
|
|
178
|
+
};
|
|
179
|
+
if (sub.maxPerTx >= 0 && amountUsdc > sub.maxPerTx)
|
|
180
|
+
return {
|
|
181
|
+
allowed: false,
|
|
182
|
+
reason: `Exceeds per-tx limit: ${sub.maxPerTx} USDC`,
|
|
183
|
+
};
|
|
184
|
+
if (sub.maxPerDay >= 0 &&
|
|
185
|
+
sub.spentToday + amountUsdc > sub.maxPerDay)
|
|
186
|
+
return {
|
|
187
|
+
allowed: false,
|
|
188
|
+
reason: `Exceeds daily limit: ${sub.maxPerDay} USDC`,
|
|
189
|
+
};
|
|
190
|
+
return { allowed: true };
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
exports.MppVaultSDK = MppVaultSDK;
|
|
194
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6CAOyB;AAEzB,MAAM,gBAAgB,GAAG,IAAI,mBAAS,CACpC,6CAA6C,CAC9C,CAAC;AACF,MAAM,2BAA2B,GAAG,IAAI,mBAAS,CAC/C,8CAA8C,CAC/C,CAAC;AACF,MAAM,SAAS,GAAG,IAAI,mBAAS,CAC7B,8CAA8C,CAC/C,CAAC;AAEF,MAAM,kBAAkB,GAAG,8CAA8C,CAAC;AAE1E,qDAAqD;AAErD,SAAS,SAAS,CAAC,KAAa;IAC9B,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC5B,IAAI,CAAC,GAAG,KAAK,CAAC;IACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;QAC3B,CAAC,KAAK,EAAE,CAAC;IACX,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,SAAS,CAAC,GAAwB,EAAE,MAAc;IACzD,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5B,MAAM,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,GAAG,MAAM,CAAC,GAAG,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
|
|
4
|
+
"description": "TypeScript SDK for MPP Vault — agent-to-agent payments on Solana",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"prepublishOnly": "npm run build"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"solana",
|
|
16
|
+
"mpp",
|
|
17
|
+
"vault",
|
|
18
|
+
"agent",
|
|
19
|
+
"payments",
|
|
20
|
+
"sdk",
|
|
21
|
+
"web3"
|
|
22
|
+
],
|
|
23
|
+
"author": "MPP Vault",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/mppvault/mppvault"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://github.com/mppvault/mppvault",
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"@solana/web3.js": "^1.90.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@solana/web3.js": "^1.98.4",
|
|
35
|
+
"typescript": "^5.7.0"
|
|
36
|
+
}
|
|
37
|
+
}
|