@coinbase/agentkit 0.2.0 → 0.2.1
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/action-providers/spl/schemas.d.ts +13 -0
- package/dist/action-providers/spl/schemas.js +13 -1
- package/dist/action-providers/spl/splActionProvider.d.ts +9 -1
- package/dist/action-providers/spl/splActionProvider.js +48 -0
- package/dist/action-providers/spl/splActionProvider.test.js +57 -0
- package/dist/network/svm.d.ts +1 -0
- package/dist/network/svm.js +6 -1
- package/dist/wallet-providers/index.d.ts +2 -0
- package/dist/wallet-providers/index.js +2 -0
- package/dist/wallet-providers/privyEvmWalletProvider.d.ts +55 -0
- package/dist/wallet-providers/privyEvmWalletProvider.js +140 -0
- package/dist/wallet-providers/privyShared.d.ts +40 -0
- package/dist/wallet-providers/privyShared.js +49 -0
- package/dist/wallet-providers/privySvmWalletProvider.d.ts +128 -0
- package/dist/wallet-providers/privySvmWalletProvider.js +212 -0
- package/dist/wallet-providers/privyWalletProvider.d.ts +21 -56
- package/dist/wallet-providers/privyWalletProvider.js +18 -118
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -34,6 +34,9 @@ AgentKit is a framework for easily enabling AI agents to take actions onchain. I
|
|
|
34
34
|
- [SolanaKeypairWalletProvider](#solanakeypairwalletprovider)
|
|
35
35
|
- [Network Configuration](#solana-network-configuration)
|
|
36
36
|
- [RPC URL Configuration](#rpc-url-configuration)
|
|
37
|
+
- [PrivyWalletProvider](#privywalletprovider-solana)
|
|
38
|
+
- [Authorization Keys](#authorization-keys)
|
|
39
|
+
- [Exporting Privy Wallet information](#exporting-privy-wallet-information)
|
|
37
40
|
- [Contributing](#contributing)
|
|
38
41
|
|
|
39
42
|
## Getting Started
|
|
@@ -634,6 +637,72 @@ const rpcUrl = process.env.SOLANA_RPC_URL;
|
|
|
634
637
|
const walletProvider = await SolanaKeypairWalletProvider.fromRpcUrl(network, privateKey);
|
|
635
638
|
```
|
|
636
639
|
|
|
640
|
+
### PrivyWalletProvider (Solana)
|
|
641
|
+
|
|
642
|
+
The `PrivyWalletProvider` is a wallet provider that uses [Privy Server Wallets](https://docs.privy.io/guide/server-wallets/).
|
|
643
|
+
|
|
644
|
+
```typescript
|
|
645
|
+
import { PrivyWalletProvider } from "@coinbase/agentkit";
|
|
646
|
+
|
|
647
|
+
// Configure Wallet Provider
|
|
648
|
+
const config = {
|
|
649
|
+
appId: "PRIVY_APP_ID",
|
|
650
|
+
appSecret: "PRIVY_APP_SECRET",
|
|
651
|
+
chainType: "solana", // optional, defaults to "evm". Make sure to set this to "solana" if you want to use Solana!
|
|
652
|
+
networkId: "solana-devnet", // optional, defaults to "solana-devnet"
|
|
653
|
+
walletId: "PRIVY_WALLET_ID", // optional, otherwise a new wallet will be created
|
|
654
|
+
authorizationPrivateKey: PRIVY_WALLET_AUTHORIZATION_PRIVATE_KEY, // optional, required if your account is using authorization keys
|
|
655
|
+
authorizationKeyId: PRIVY_WALLET_AUTHORIZATION_KEY_ID, // optional, only required to create a new wallet if walletId is not provided
|
|
656
|
+
};
|
|
657
|
+
|
|
658
|
+
const walletProvider = await PrivyWalletProvider.configureWithWallet(config);
|
|
659
|
+
```
|
|
660
|
+
|
|
661
|
+
Optionally, you can configure your own `@solana/web3.js` connection by passing the `connection` parameter to the `configureWithWallet` method.
|
|
662
|
+
|
|
663
|
+
```typescript
|
|
664
|
+
import { PrivyWalletProvider } from "@coinbase/agentkit";
|
|
665
|
+
|
|
666
|
+
const connection = new Connection("YOUR_RPC_URL");
|
|
667
|
+
|
|
668
|
+
// Configure Wallet Provider
|
|
669
|
+
const config = {
|
|
670
|
+
appId: "PRIVY_APP_ID",
|
|
671
|
+
appSecret: "PRIVY_APP_SECRET",
|
|
672
|
+
connection,
|
|
673
|
+
chainType: "solana", // optional, defaults to "evm". Make sure to set this to "solana" if you want to use Solana!
|
|
674
|
+
networkId: "solana-devnet", // optional, defaults to "solana-devnet"
|
|
675
|
+
walletId: "PRIVY_WALLET_ID", // optional, otherwise a new wallet will be created
|
|
676
|
+
authorizationPrivateKey: PRIVY_WALLET_AUTHORIZATION_PRIVATE_KEY, // optional, required if your account is using authorization keys
|
|
677
|
+
authorizationKeyId: PRIVY_WALLET_AUTHORIZATION_KEY_ID, // optional, only required to create a new wallet if walletId is not provided
|
|
678
|
+
};
|
|
679
|
+
|
|
680
|
+
const walletProvider = await PrivyWalletProvider.configureWithWallet(config);
|
|
681
|
+
```
|
|
682
|
+
|
|
683
|
+
#### Authorization Keys
|
|
684
|
+
|
|
685
|
+
Privy offers the option to use authorization keys to secure your server wallets.
|
|
686
|
+
|
|
687
|
+
You can manage authorization keys from your [Privy dashboard](https://dashboard.privy.io/account) or programmatically [using the API](https://docs.privy.io/guide/server-wallets/authorization/signatures).
|
|
688
|
+
|
|
689
|
+
When using authorization keys, you must provide the `authorizationPrivateKey` and `authorizationKeyId` parameters to the `configureWithWallet` method if you are creating a new wallet. Please note that when creating a key, if you enable "Create and modify wallets", you will be required to use that key when creating new wallets via the PrivyWalletProvider.
|
|
690
|
+
|
|
691
|
+
#### Exporting Privy Wallet information
|
|
692
|
+
|
|
693
|
+
The `PrivyWalletProvider` can export wallet information by calling the `exportWallet` method.
|
|
694
|
+
|
|
695
|
+
```typescript
|
|
696
|
+
const walletData = await walletProvider.exportWallet();
|
|
697
|
+
|
|
698
|
+
// walletData will be in the following format:
|
|
699
|
+
{
|
|
700
|
+
walletId: string;
|
|
701
|
+
authorizationKey: string | undefined;
|
|
702
|
+
networkId: string | undefined;
|
|
703
|
+
}
|
|
704
|
+
```
|
|
705
|
+
|
|
637
706
|
## Contributing
|
|
638
707
|
|
|
639
708
|
See [CONTRIBUTING.md](../../CONTRIBUTING.md) for more information.
|
|
@@ -15,3 +15,16 @@ export declare const TransferTokenSchema: z.ZodObject<{
|
|
|
15
15
|
recipient: string;
|
|
16
16
|
mintAddress: string;
|
|
17
17
|
}>;
|
|
18
|
+
/**
|
|
19
|
+
* Schema for getting SPL token balance.
|
|
20
|
+
*/
|
|
21
|
+
export declare const GetBalanceSchema: z.ZodObject<{
|
|
22
|
+
mintAddress: z.ZodString;
|
|
23
|
+
address: z.ZodOptional<z.ZodString>;
|
|
24
|
+
}, "strip", z.ZodTypeAny, {
|
|
25
|
+
mintAddress: string;
|
|
26
|
+
address?: string | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
mintAddress: string;
|
|
29
|
+
address?: string | undefined;
|
|
30
|
+
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TransferTokenSchema = void 0;
|
|
3
|
+
exports.GetBalanceSchema = exports.TransferTokenSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
/**
|
|
6
6
|
* Schema for transferring SPL tokens to another address.
|
|
@@ -12,3 +12,15 @@ exports.TransferTokenSchema = zod_1.z
|
|
|
12
12
|
amount: zod_1.z.number().positive().describe("Amount of tokens to transfer"),
|
|
13
13
|
})
|
|
14
14
|
.describe("Transfer SPL tokens to another Solana address");
|
|
15
|
+
/**
|
|
16
|
+
* Schema for getting SPL token balance.
|
|
17
|
+
*/
|
|
18
|
+
exports.GetBalanceSchema = zod_1.z
|
|
19
|
+
.object({
|
|
20
|
+
mintAddress: zod_1.z.string().describe("The SPL token's mint address"),
|
|
21
|
+
address: zod_1.z
|
|
22
|
+
.string()
|
|
23
|
+
.optional()
|
|
24
|
+
.describe("Optional address to check balance for. If not provided, uses the wallet's address"),
|
|
25
|
+
})
|
|
26
|
+
.describe("Get SPL token balance for an address");
|
|
@@ -2,7 +2,7 @@ import { ActionProvider } from "../actionProvider";
|
|
|
2
2
|
import { Network } from "../../network";
|
|
3
3
|
import { SvmWalletProvider } from "../../wallet-providers/svmWalletProvider";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
-
import { TransferTokenSchema } from "./schemas";
|
|
5
|
+
import { TransferTokenSchema, GetBalanceSchema } from "./schemas";
|
|
6
6
|
/**
|
|
7
7
|
* SplActionProvider serves as a provider for SPL token actions.
|
|
8
8
|
* It provides SPL token transfer functionality.
|
|
@@ -12,6 +12,14 @@ export declare class SplActionProvider extends ActionProvider<SvmWalletProvider>
|
|
|
12
12
|
* Creates a new SplActionProvider instance.
|
|
13
13
|
*/
|
|
14
14
|
constructor();
|
|
15
|
+
/**
|
|
16
|
+
* Get the balance of SPL tokens for an address.
|
|
17
|
+
*
|
|
18
|
+
* @param walletProvider - The wallet provider to use
|
|
19
|
+
* @param args - Parameters including mint address and optional target address
|
|
20
|
+
* @returns A message indicating the token balance
|
|
21
|
+
*/
|
|
22
|
+
getBalance(walletProvider: SvmWalletProvider, args: z.infer<typeof GetBalanceSchema>): Promise<string>;
|
|
15
23
|
/**
|
|
16
24
|
* Transfer SPL tokens to another address.
|
|
17
25
|
*
|
|
@@ -27,6 +27,39 @@ class SplActionProvider extends actionProvider_1.ActionProvider {
|
|
|
27
27
|
constructor() {
|
|
28
28
|
super("spl", []);
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Get the balance of SPL tokens for an address.
|
|
32
|
+
*
|
|
33
|
+
* @param walletProvider - The wallet provider to use
|
|
34
|
+
* @param args - Parameters including mint address and optional target address
|
|
35
|
+
* @returns A message indicating the token balance
|
|
36
|
+
*/
|
|
37
|
+
async getBalance(walletProvider, args) {
|
|
38
|
+
try {
|
|
39
|
+
const connection = walletProvider.getConnection();
|
|
40
|
+
const mintPubkey = new web3_js_1.PublicKey(args.mintAddress);
|
|
41
|
+
const ownerPubkey = args.address
|
|
42
|
+
? new web3_js_1.PublicKey(args.address)
|
|
43
|
+
: walletProvider.getPublicKey();
|
|
44
|
+
const { getMint, getAssociatedTokenAddress, getAccount } = await import("@solana/spl-token");
|
|
45
|
+
const mintInfo = await getMint(connection, mintPubkey);
|
|
46
|
+
const ata = await getAssociatedTokenAddress(mintPubkey, ownerPubkey);
|
|
47
|
+
try {
|
|
48
|
+
const account = await getAccount(connection, ata);
|
|
49
|
+
const balance = Number(account.amount) / Math.pow(10, mintInfo.decimals);
|
|
50
|
+
return `Balance for ${args.address || "connected wallet"} is ${balance} tokens`;
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
if (error.message.includes("could not find account")) {
|
|
54
|
+
return `Balance for ${args.address || "connected wallet"} is 0 tokens`;
|
|
55
|
+
}
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
return `Error getting SPL token balance: ${error}`;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
30
63
|
/**
|
|
31
64
|
* Transfer SPL tokens to another address.
|
|
32
65
|
*
|
|
@@ -86,6 +119,21 @@ class SplActionProvider extends actionProvider_1.ActionProvider {
|
|
|
86
119
|
}
|
|
87
120
|
}
|
|
88
121
|
exports.SplActionProvider = SplActionProvider;
|
|
122
|
+
__decorate([
|
|
123
|
+
(0, actionDecorator_1.CreateAction)({
|
|
124
|
+
name: "get_balance",
|
|
125
|
+
description: `
|
|
126
|
+
This tool will get the balance of SPL tokens for an address.
|
|
127
|
+
- Mint address must be a valid SPL token mint
|
|
128
|
+
- If no address is provided, uses the connected wallet's address
|
|
129
|
+
- Returns the token balance in token units (not raw)
|
|
130
|
+
`,
|
|
131
|
+
schema: schemas_1.GetBalanceSchema,
|
|
132
|
+
}),
|
|
133
|
+
__metadata("design:type", Function),
|
|
134
|
+
__metadata("design:paramtypes", [svmWalletProvider_1.SvmWalletProvider, void 0]),
|
|
135
|
+
__metadata("design:returntype", Promise)
|
|
136
|
+
], SplActionProvider.prototype, "getBalance", null);
|
|
89
137
|
__decorate([
|
|
90
138
|
(0, actionDecorator_1.CreateAction)({
|
|
91
139
|
name: "transfer",
|
|
@@ -203,4 +203,61 @@ describe("SplActionProvider", () => {
|
|
|
203
203
|
expect(result).toContain(`Successfully transferred ${transferArgs.amount} tokens`);
|
|
204
204
|
});
|
|
205
205
|
});
|
|
206
|
+
describe("getBalance", () => {
|
|
207
|
+
const MINT_ADDRESS = "So11111111111111111111111111111111111111112";
|
|
208
|
+
const TARGET_ADDRESS = "DjXsn34uz8yCBQ8bevLrEPYYC1RvhHvjzuVF8opNc4K2";
|
|
209
|
+
const SENDER_ADDRESS = "11111111111111111111111111111111";
|
|
210
|
+
const balanceArgs = {
|
|
211
|
+
mintAddress: MINT_ADDRESS,
|
|
212
|
+
};
|
|
213
|
+
const balanceWithAddressArgs = {
|
|
214
|
+
mintAddress: MINT_ADDRESS,
|
|
215
|
+
address: TARGET_ADDRESS,
|
|
216
|
+
};
|
|
217
|
+
const mockTokenAccount = {
|
|
218
|
+
amount: BigInt(1000000000),
|
|
219
|
+
address: new web3_js_1.PublicKey(MINT_ADDRESS),
|
|
220
|
+
mint: new web3_js_1.PublicKey(MINT_ADDRESS),
|
|
221
|
+
owner: new web3_js_1.PublicKey(TARGET_ADDRESS),
|
|
222
|
+
delegate: null,
|
|
223
|
+
delegatedAmount: BigInt(0),
|
|
224
|
+
closeAuthority: null,
|
|
225
|
+
isFrozen: false,
|
|
226
|
+
isNative: false,
|
|
227
|
+
rentExemptReserve: null,
|
|
228
|
+
isInitialized: true,
|
|
229
|
+
tlvData: new Map(),
|
|
230
|
+
};
|
|
231
|
+
beforeEach(() => {
|
|
232
|
+
mockWallet.getPublicKey.mockReturnValue(new web3_js_1.PublicKey(SENDER_ADDRESS));
|
|
233
|
+
mockWallet.getAddress.mockReturnValue(SENDER_ADDRESS);
|
|
234
|
+
});
|
|
235
|
+
it("should get balance for connected wallet", async () => {
|
|
236
|
+
mockGetAccount.mockResolvedValue(mockTokenAccount);
|
|
237
|
+
const result = await actionProvider.getBalance(mockWallet, balanceArgs);
|
|
238
|
+
expect(mockGetAssociatedTokenAddress).toHaveBeenCalledWith(new web3_js_1.PublicKey(balanceArgs.mintAddress), new web3_js_1.PublicKey(SENDER_ADDRESS));
|
|
239
|
+
expect(mockGetMint).toHaveBeenCalledWith(mockConnection, new web3_js_1.PublicKey(balanceArgs.mintAddress));
|
|
240
|
+
expect(mockGetAccount).toHaveBeenCalled();
|
|
241
|
+
expect(result).toBe("Balance for connected wallet is 1000 tokens");
|
|
242
|
+
});
|
|
243
|
+
it("should get balance for specified address", async () => {
|
|
244
|
+
mockGetAccount.mockResolvedValue(mockTokenAccount);
|
|
245
|
+
const result = await actionProvider.getBalance(mockWallet, balanceWithAddressArgs);
|
|
246
|
+
expect(mockGetAssociatedTokenAddress).toHaveBeenCalledWith(new web3_js_1.PublicKey(balanceWithAddressArgs.mintAddress), new web3_js_1.PublicKey(balanceWithAddressArgs.address));
|
|
247
|
+
expect(mockGetMint).toHaveBeenCalledWith(mockConnection, new web3_js_1.PublicKey(balanceWithAddressArgs.mintAddress));
|
|
248
|
+
expect(mockGetAccount).toHaveBeenCalled();
|
|
249
|
+
expect(result).toBe(`Balance for ${TARGET_ADDRESS} is 1000 tokens`);
|
|
250
|
+
});
|
|
251
|
+
it("should handle non-existent token account", async () => {
|
|
252
|
+
mockGetAccount.mockRejectedValue(new Error("could not find account"));
|
|
253
|
+
const result = await actionProvider.getBalance(mockWallet, balanceArgs);
|
|
254
|
+
expect(result).toBe("Balance for connected wallet is 0 tokens");
|
|
255
|
+
});
|
|
256
|
+
it("should handle errors", async () => {
|
|
257
|
+
const error = new Error("Test error");
|
|
258
|
+
mockGetAccount.mockRejectedValue(error);
|
|
259
|
+
const result = await actionProvider.getBalance(mockWallet, balanceArgs);
|
|
260
|
+
expect(result).toBe("Error getting SPL token balance: Error: Test error");
|
|
261
|
+
});
|
|
262
|
+
});
|
|
206
263
|
});
|
package/dist/network/svm.d.ts
CHANGED
|
@@ -12,3 +12,4 @@ export declare const SOLANA_MAINNET_NETWORK: Network;
|
|
|
12
12
|
export declare const SOLANA_TESTNET_NETWORK: Network;
|
|
13
13
|
export declare const SOLANA_DEVNET_NETWORK: Network;
|
|
14
14
|
export declare const SOLANA_NETWORKS: Record<SOLANA_CLUSTER, Network>;
|
|
15
|
+
export declare const SOLANA_CLUSTER_ID_BY_NETWORK_ID: Record<SOLANA_NETWORK_ID, string>;
|
package/dist/network/svm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SOLANA_NETWORKS = exports.SOLANA_DEVNET_NETWORK = exports.SOLANA_TESTNET_NETWORK = exports.SOLANA_MAINNET_NETWORK = exports.SOLANA_DEVNET_GENESIS_BLOCK_HASH = exports.SOLANA_TESTNET_GENESIS_BLOCK_HASH = exports.SOLANA_MAINNET_GENESIS_BLOCK_HASH = exports.SOLANA_PROTOCOL_FAMILY = exports.SOLANA_DEVNET_NETWORK_ID = exports.SOLANA_TESTNET_NETWORK_ID = exports.SOLANA_MAINNET_NETWORK_ID = void 0;
|
|
3
|
+
exports.SOLANA_CLUSTER_ID_BY_NETWORK_ID = exports.SOLANA_NETWORKS = exports.SOLANA_DEVNET_NETWORK = exports.SOLANA_TESTNET_NETWORK = exports.SOLANA_MAINNET_NETWORK = exports.SOLANA_DEVNET_GENESIS_BLOCK_HASH = exports.SOLANA_TESTNET_GENESIS_BLOCK_HASH = exports.SOLANA_MAINNET_GENESIS_BLOCK_HASH = exports.SOLANA_PROTOCOL_FAMILY = exports.SOLANA_DEVNET_NETWORK_ID = exports.SOLANA_TESTNET_NETWORK_ID = exports.SOLANA_MAINNET_NETWORK_ID = void 0;
|
|
4
4
|
// CDP Network IDs
|
|
5
5
|
exports.SOLANA_MAINNET_NETWORK_ID = "solana-mainnet";
|
|
6
6
|
exports.SOLANA_TESTNET_NETWORK_ID = "solana-testnet";
|
|
@@ -31,3 +31,8 @@ exports.SOLANA_NETWORKS = {
|
|
|
31
31
|
[exports.SOLANA_TESTNET_GENESIS_BLOCK_HASH]: exports.SOLANA_TESTNET_NETWORK,
|
|
32
32
|
[exports.SOLANA_DEVNET_GENESIS_BLOCK_HASH]: exports.SOLANA_DEVNET_NETWORK,
|
|
33
33
|
};
|
|
34
|
+
exports.SOLANA_CLUSTER_ID_BY_NETWORK_ID = {
|
|
35
|
+
[exports.SOLANA_MAINNET_NETWORK_ID]: "mainnet-beta",
|
|
36
|
+
[exports.SOLANA_TESTNET_NETWORK_ID]: "testnet",
|
|
37
|
+
[exports.SOLANA_DEVNET_NETWORK_ID]: "devnet",
|
|
38
|
+
};
|
|
@@ -21,3 +21,5 @@ __exportStar(require("./cdpWalletProvider"), exports);
|
|
|
21
21
|
__exportStar(require("./svmWalletProvider"), exports);
|
|
22
22
|
__exportStar(require("./solanaKeypairWalletProvider"), exports);
|
|
23
23
|
__exportStar(require("./privyWalletProvider"), exports);
|
|
24
|
+
__exportStar(require("./privyEvmWalletProvider"), exports);
|
|
25
|
+
__exportStar(require("./privySvmWalletProvider"), exports);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ViemWalletProvider } from "./viemWalletProvider";
|
|
2
|
+
import { PrivyWalletConfig, PrivyWalletExport } from "./privyShared";
|
|
3
|
+
/**
|
|
4
|
+
* Configuration options for the Privy wallet provider.
|
|
5
|
+
*
|
|
6
|
+
* @interface
|
|
7
|
+
*/
|
|
8
|
+
export interface PrivyEvmWalletConfig extends PrivyWalletConfig {
|
|
9
|
+
/** Optional chain ID to connect to */
|
|
10
|
+
chainId?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A wallet provider that uses Privy's server wallet API.
|
|
14
|
+
* This provider extends the ViemWalletProvider to provide Privy-specific wallet functionality
|
|
15
|
+
* while maintaining compatibility with the base wallet provider interface.
|
|
16
|
+
*/
|
|
17
|
+
export declare class PrivyEvmWalletProvider extends ViemWalletProvider {
|
|
18
|
+
#private;
|
|
19
|
+
/**
|
|
20
|
+
* Private constructor to enforce use of factory method.
|
|
21
|
+
*
|
|
22
|
+
* @param walletClient - The Viem wallet client instance
|
|
23
|
+
* @param config - The configuration options for the Privy wallet
|
|
24
|
+
*/
|
|
25
|
+
private constructor();
|
|
26
|
+
/**
|
|
27
|
+
* Creates and configures a new PrivyWalletProvider instance.
|
|
28
|
+
*
|
|
29
|
+
* @param config - The configuration options for the Privy wallet
|
|
30
|
+
* @returns A configured PrivyWalletProvider instance
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const provider = await PrivyWalletProvider.configureWithWallet({
|
|
35
|
+
* appId: "your-app-id",
|
|
36
|
+
* appSecret: "your-app-secret",
|
|
37
|
+
* walletId: "wallet-id",
|
|
38
|
+
* chainId: "84532"
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
static configureWithWallet(config: PrivyEvmWalletConfig): Promise<PrivyEvmWalletProvider>;
|
|
43
|
+
/**
|
|
44
|
+
* Gets the name of the wallet provider.
|
|
45
|
+
*
|
|
46
|
+
* @returns The string identifier for this wallet provider
|
|
47
|
+
*/
|
|
48
|
+
getName(): string;
|
|
49
|
+
/**
|
|
50
|
+
* Exports the wallet data.
|
|
51
|
+
*
|
|
52
|
+
* @returns The wallet data
|
|
53
|
+
*/
|
|
54
|
+
exportWallet(): PrivyWalletExport;
|
|
55
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _PrivyEvmWalletProvider_walletId, _PrivyEvmWalletProvider_authorizationPrivateKey;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.PrivyEvmWalletProvider = void 0;
|
|
16
|
+
const server_auth_1 = require("@privy-io/server-auth");
|
|
17
|
+
const viem_1 = require("@privy-io/server-auth/viem");
|
|
18
|
+
const viemWalletProvider_1 = require("./viemWalletProvider");
|
|
19
|
+
const viem_2 = require("viem");
|
|
20
|
+
const network_1 = require("../network/network");
|
|
21
|
+
/**
|
|
22
|
+
* A wallet provider that uses Privy's server wallet API.
|
|
23
|
+
* This provider extends the ViemWalletProvider to provide Privy-specific wallet functionality
|
|
24
|
+
* while maintaining compatibility with the base wallet provider interface.
|
|
25
|
+
*/
|
|
26
|
+
class PrivyEvmWalletProvider extends viemWalletProvider_1.ViemWalletProvider {
|
|
27
|
+
/**
|
|
28
|
+
* Private constructor to enforce use of factory method.
|
|
29
|
+
*
|
|
30
|
+
* @param walletClient - The Viem wallet client instance
|
|
31
|
+
* @param config - The configuration options for the Privy wallet
|
|
32
|
+
*/
|
|
33
|
+
constructor(walletClient, config) {
|
|
34
|
+
super(walletClient);
|
|
35
|
+
_PrivyEvmWalletProvider_walletId.set(this, void 0);
|
|
36
|
+
_PrivyEvmWalletProvider_authorizationPrivateKey.set(this, void 0);
|
|
37
|
+
__classPrivateFieldSet(this, _PrivyEvmWalletProvider_walletId, config.walletId, "f"); // Now guaranteed to exist
|
|
38
|
+
__classPrivateFieldSet(this, _PrivyEvmWalletProvider_authorizationPrivateKey, config.authorizationPrivateKey, "f");
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Creates and configures a new PrivyWalletProvider instance.
|
|
42
|
+
*
|
|
43
|
+
* @param config - The configuration options for the Privy wallet
|
|
44
|
+
* @returns A configured PrivyWalletProvider instance
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const provider = await PrivyWalletProvider.configureWithWallet({
|
|
49
|
+
* appId: "your-app-id",
|
|
50
|
+
* appSecret: "your-app-secret",
|
|
51
|
+
* walletId: "wallet-id",
|
|
52
|
+
* chainId: "84532"
|
|
53
|
+
* });
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
static async configureWithWallet(config) {
|
|
57
|
+
const privy = new server_auth_1.PrivyClient(config.appId, config.appSecret, {
|
|
58
|
+
walletApi: config.authorizationPrivateKey
|
|
59
|
+
? {
|
|
60
|
+
authorizationPrivateKey: config.authorizationPrivateKey,
|
|
61
|
+
}
|
|
62
|
+
: undefined,
|
|
63
|
+
});
|
|
64
|
+
let walletId;
|
|
65
|
+
let address;
|
|
66
|
+
if (!config.walletId) {
|
|
67
|
+
if (config.authorizationPrivateKey && !config.authorizationKeyId) {
|
|
68
|
+
throw new Error("authorizationKeyId is required when creating a new wallet with an authorization key, this can be found in your Privy Dashboard");
|
|
69
|
+
}
|
|
70
|
+
if (config.authorizationKeyId && !config.authorizationPrivateKey) {
|
|
71
|
+
throw new Error("authorizationPrivateKey is required when creating a new wallet with an authorizationKeyId. " +
|
|
72
|
+
"If you don't have it, you can create a new one in your Privy Dashboard, or delete the authorization key.");
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
const wallet = await privy.walletApi.create({
|
|
76
|
+
chainType: "ethereum",
|
|
77
|
+
authorizationKeyIds: config.authorizationKeyId ? [config.authorizationKeyId] : undefined,
|
|
78
|
+
});
|
|
79
|
+
walletId = wallet.id;
|
|
80
|
+
address = wallet.address;
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
console.error(error);
|
|
84
|
+
if (error instanceof Error &&
|
|
85
|
+
error.message.includes("Missing `privy-authorization-signature` header")) {
|
|
86
|
+
// Providing a more informative error message, see context: https://github.com/coinbase/agentkit/pull/242#discussion_r1956428617
|
|
87
|
+
throw new Error("Privy error: you have an authorization key on your account which can create and modify wallets, please delete this key or pass it to the PrivyWalletProvider to create a new wallet");
|
|
88
|
+
}
|
|
89
|
+
throw new Error("Failed to create wallet");
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
walletId = config.walletId;
|
|
94
|
+
const wallet = await privy.walletApi.getWallet({ id: walletId });
|
|
95
|
+
if (!wallet) {
|
|
96
|
+
throw new Error(`Wallet with ID ${walletId} not found`);
|
|
97
|
+
}
|
|
98
|
+
address = wallet.address;
|
|
99
|
+
}
|
|
100
|
+
const account = await (0, viem_1.createViemAccount)({
|
|
101
|
+
walletId,
|
|
102
|
+
address,
|
|
103
|
+
privy,
|
|
104
|
+
});
|
|
105
|
+
const chainId = config.chainId || "84532";
|
|
106
|
+
const chain = (0, network_1.getChain)(chainId);
|
|
107
|
+
if (!chain) {
|
|
108
|
+
throw new Error(`Chain with ID ${chainId} not found`);
|
|
109
|
+
}
|
|
110
|
+
const walletClient = (0, viem_2.createWalletClient)({
|
|
111
|
+
account,
|
|
112
|
+
chain,
|
|
113
|
+
transport: (0, viem_2.http)(),
|
|
114
|
+
});
|
|
115
|
+
return new PrivyEvmWalletProvider(walletClient, { ...config, walletId });
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Gets the name of the wallet provider.
|
|
119
|
+
*
|
|
120
|
+
* @returns The string identifier for this wallet provider
|
|
121
|
+
*/
|
|
122
|
+
getName() {
|
|
123
|
+
return "privy_evm_wallet_provider";
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Exports the wallet data.
|
|
127
|
+
*
|
|
128
|
+
* @returns The wallet data
|
|
129
|
+
*/
|
|
130
|
+
exportWallet() {
|
|
131
|
+
return {
|
|
132
|
+
walletId: __classPrivateFieldGet(this, _PrivyEvmWalletProvider_walletId, "f"),
|
|
133
|
+
authorizationPrivateKey: __classPrivateFieldGet(this, _PrivyEvmWalletProvider_authorizationPrivateKey, "f"),
|
|
134
|
+
chainId: this.getNetwork().chainId,
|
|
135
|
+
networkId: this.getNetwork().networkId,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.PrivyEvmWalletProvider = PrivyEvmWalletProvider;
|
|
140
|
+
_PrivyEvmWalletProvider_walletId = new WeakMap(), _PrivyEvmWalletProvider_authorizationPrivateKey = new WeakMap();
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { PrivyClient, Wallet } from "@privy-io/server-auth";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration options for the Privy wallet provider.
|
|
4
|
+
*
|
|
5
|
+
* @interface
|
|
6
|
+
*/
|
|
7
|
+
export interface PrivyWalletConfig {
|
|
8
|
+
/** The Privy application ID */
|
|
9
|
+
appId: string;
|
|
10
|
+
/** The Privy application secret */
|
|
11
|
+
appSecret: string;
|
|
12
|
+
/** The ID of the wallet to use, if not provided a new wallet will be created */
|
|
13
|
+
walletId?: string;
|
|
14
|
+
/** Optional authorization key for the wallet API */
|
|
15
|
+
authorizationPrivateKey?: string;
|
|
16
|
+
/** Optional authorization key ID for creating new wallets */
|
|
17
|
+
authorizationKeyId?: string;
|
|
18
|
+
/** The chain type to create the wallet on */
|
|
19
|
+
chainType?: "ethereum" | "solana";
|
|
20
|
+
}
|
|
21
|
+
export type PrivyWalletExport = {
|
|
22
|
+
walletId: string;
|
|
23
|
+
authorizationPrivateKey: string | undefined;
|
|
24
|
+
chainId: string | undefined;
|
|
25
|
+
networkId: string | undefined;
|
|
26
|
+
};
|
|
27
|
+
type CreatePrivyWalletReturnType = {
|
|
28
|
+
wallet: Wallet & {
|
|
29
|
+
id: string;
|
|
30
|
+
};
|
|
31
|
+
privy: PrivyClient;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Create a Privy wallet
|
|
35
|
+
*
|
|
36
|
+
* @param config - The configuration options for the Privy wallet
|
|
37
|
+
* @returns The created Privy wallet
|
|
38
|
+
*/
|
|
39
|
+
export declare function createPrivyWallet(config: PrivyWalletConfig): Promise<CreatePrivyWalletReturnType>;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createPrivyWallet = createPrivyWallet;
|
|
4
|
+
const server_auth_1 = require("@privy-io/server-auth");
|
|
5
|
+
/**
|
|
6
|
+
* Create a Privy wallet
|
|
7
|
+
*
|
|
8
|
+
* @param config - The configuration options for the Privy wallet
|
|
9
|
+
* @returns The created Privy wallet
|
|
10
|
+
*/
|
|
11
|
+
async function createPrivyWallet(config) {
|
|
12
|
+
const privy = new server_auth_1.PrivyClient(config.appId, config.appSecret, {
|
|
13
|
+
walletApi: config.authorizationPrivateKey
|
|
14
|
+
? {
|
|
15
|
+
authorizationPrivateKey: config.authorizationPrivateKey,
|
|
16
|
+
}
|
|
17
|
+
: undefined,
|
|
18
|
+
});
|
|
19
|
+
if (config.walletId) {
|
|
20
|
+
const wallet = await privy.walletApi.getWallet({ id: config.walletId });
|
|
21
|
+
if (!wallet) {
|
|
22
|
+
throw new Error(`Wallet with ID ${config.walletId} not found`);
|
|
23
|
+
}
|
|
24
|
+
return { wallet, privy };
|
|
25
|
+
}
|
|
26
|
+
if (config.authorizationPrivateKey && !config.authorizationKeyId) {
|
|
27
|
+
throw new Error("authorizationKeyId is required when creating a new wallet with an authorization key, this can be found in your Privy Dashboard");
|
|
28
|
+
}
|
|
29
|
+
if (config.authorizationKeyId && !config.authorizationPrivateKey) {
|
|
30
|
+
throw new Error("authorizationPrivateKey is required when creating a new wallet with an authorizationKeyId. " +
|
|
31
|
+
"If you don't have it, you can create a new one in your Privy Dashboard, or delete the authorization key.");
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
const wallet = await privy.walletApi.create({
|
|
35
|
+
chainType: config.chainType,
|
|
36
|
+
authorizationKeyIds: config.authorizationKeyId ? [config.authorizationKeyId] : undefined,
|
|
37
|
+
});
|
|
38
|
+
return { wallet, privy };
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
console.error(error);
|
|
42
|
+
if (error instanceof Error &&
|
|
43
|
+
error.message.includes("Missing `privy-authorization-signature` header")) {
|
|
44
|
+
// Providing a more informative error message, see context: https://github.com/coinbase/agentkit/pull/242#discussion_r1956428617
|
|
45
|
+
throw new Error("Privy error: you have an authorization key on your account which can create and modify wallets, please delete this key or pass it to the PrivyWalletProvider to create a new wallet");
|
|
46
|
+
}
|
|
47
|
+
throw new Error("Failed to create wallet");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { SvmWalletProvider } from "./svmWalletProvider";
|
|
2
|
+
import { RpcResponseAndContext, SignatureStatus, VersionedTransaction, Connection, PublicKey, SignatureResult } from "@solana/web3.js";
|
|
3
|
+
import { Network } from "../network/types";
|
|
4
|
+
import { PrivyWalletConfig, PrivyWalletExport } from "./privyShared";
|
|
5
|
+
/**
|
|
6
|
+
* Configuration options for the Privy Svm wallet provider.
|
|
7
|
+
*/
|
|
8
|
+
export interface PrivySvmWalletConfig extends PrivyWalletConfig {
|
|
9
|
+
/** The network ID to use for the wallet */
|
|
10
|
+
networkId?: string;
|
|
11
|
+
/** The connection to use for the wallet */
|
|
12
|
+
connection?: Connection;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A wallet provider that uses Privy's server wallet API.
|
|
16
|
+
* This provider extends the SvmWalletProvider to provide Privy-specific wallet functionality
|
|
17
|
+
* while maintaining compatibility with the base wallet provider interface.
|
|
18
|
+
*/
|
|
19
|
+
export declare class PrivySvmWalletProvider extends SvmWalletProvider {
|
|
20
|
+
#private;
|
|
21
|
+
/**
|
|
22
|
+
* Private constructor to enforce use of factory method.
|
|
23
|
+
*
|
|
24
|
+
* @param config - The configuration options for the Privy wallet
|
|
25
|
+
*/
|
|
26
|
+
private constructor();
|
|
27
|
+
/**
|
|
28
|
+
* Creates and configures a new PrivySolanaWalletProvider instance.
|
|
29
|
+
*
|
|
30
|
+
* @param config - The configuration options for the Privy wallet
|
|
31
|
+
* @returns A configured PrivySolanaWalletProvider instance
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const provider = await PrivySolanaWalletProvider.configureWithWallet({
|
|
36
|
+
* appId: "your-app-id",
|
|
37
|
+
* appSecret: "your-app-secret",
|
|
38
|
+
* walletId: "wallet-id",
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
static configureWithWallet<T extends PrivySvmWalletProvider>(config: PrivySvmWalletConfig): Promise<T>;
|
|
43
|
+
/**
|
|
44
|
+
* Sign a transaction.
|
|
45
|
+
*
|
|
46
|
+
* @param transaction - The transaction to sign.
|
|
47
|
+
* @returns The signed transaction.
|
|
48
|
+
*/
|
|
49
|
+
signTransaction(transaction: VersionedTransaction): Promise<VersionedTransaction>;
|
|
50
|
+
/**
|
|
51
|
+
* Sign and send a transaction.
|
|
52
|
+
*
|
|
53
|
+
* @param transaction - The transaction to send.
|
|
54
|
+
* @returns The transaction hash.
|
|
55
|
+
*/
|
|
56
|
+
signAndSendTransaction(transaction: VersionedTransaction): Promise<string>;
|
|
57
|
+
/**
|
|
58
|
+
* Send a transaction.
|
|
59
|
+
*
|
|
60
|
+
* @param _ - The transaction to send.
|
|
61
|
+
* @returns The transaction hash.
|
|
62
|
+
*/
|
|
63
|
+
sendTransaction(_: VersionedTransaction): Promise<string>;
|
|
64
|
+
/**
|
|
65
|
+
* Exports the wallet data.
|
|
66
|
+
*
|
|
67
|
+
* @returns The wallet data
|
|
68
|
+
*/
|
|
69
|
+
exportWallet(): PrivyWalletExport;
|
|
70
|
+
/**
|
|
71
|
+
* Gets the name of the wallet provider.
|
|
72
|
+
*
|
|
73
|
+
* @returns The string identifier for this wallet provider
|
|
74
|
+
*/
|
|
75
|
+
getName(): string;
|
|
76
|
+
/**
|
|
77
|
+
* Get the address of the wallet.
|
|
78
|
+
*
|
|
79
|
+
* @returns The address of the wallet.
|
|
80
|
+
*/
|
|
81
|
+
getAddress(): string;
|
|
82
|
+
/**
|
|
83
|
+
* Get the network of the wallet.
|
|
84
|
+
*
|
|
85
|
+
* @returns The network of the wallet.
|
|
86
|
+
*/
|
|
87
|
+
getNetwork(): Network;
|
|
88
|
+
/**
|
|
89
|
+
* Get the balance of the wallet.
|
|
90
|
+
*
|
|
91
|
+
* @returns The balance of the wallet.
|
|
92
|
+
*/
|
|
93
|
+
getBalance(): Promise<bigint>;
|
|
94
|
+
/**
|
|
95
|
+
* Transfer a native token.
|
|
96
|
+
*
|
|
97
|
+
* @param _ - The address to transfer the token to.
|
|
98
|
+
* @param arg2 - The value to transfer.
|
|
99
|
+
* @returns The transaction hash.
|
|
100
|
+
*/
|
|
101
|
+
nativeTransfer(_: string, arg2: string): Promise<string>;
|
|
102
|
+
/**
|
|
103
|
+
* Get the status of a transaction.
|
|
104
|
+
*
|
|
105
|
+
* @param signature - The transaction signature.
|
|
106
|
+
* @returns The transaction status.
|
|
107
|
+
*/
|
|
108
|
+
getSignatureStatus(signature: string): Promise<RpcResponseAndContext<SignatureStatus | null>>;
|
|
109
|
+
/**
|
|
110
|
+
* Wait for a signature result.
|
|
111
|
+
*
|
|
112
|
+
* @param signature - The signature to wait for.
|
|
113
|
+
* @returns The signature result.
|
|
114
|
+
*/
|
|
115
|
+
waitForSignatureResult(signature: string): Promise<RpcResponseAndContext<SignatureResult>>;
|
|
116
|
+
/**
|
|
117
|
+
* Get the connection.
|
|
118
|
+
*
|
|
119
|
+
* @returns The connection.
|
|
120
|
+
*/
|
|
121
|
+
getConnection(): Connection;
|
|
122
|
+
/**
|
|
123
|
+
* Get the public key.
|
|
124
|
+
*
|
|
125
|
+
* @returns The public key.
|
|
126
|
+
*/
|
|
127
|
+
getPublicKey(): PublicKey;
|
|
128
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _PrivySvmWalletProvider_walletId, _PrivySvmWalletProvider_address, _PrivySvmWalletProvider_authorizationPrivateKey, _PrivySvmWalletProvider_privyClient, _PrivySvmWalletProvider_connection, _PrivySvmWalletProvider_genesisHash;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.PrivySvmWalletProvider = void 0;
|
|
16
|
+
const svmWalletProvider_1 = require("./svmWalletProvider");
|
|
17
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
18
|
+
const svm_1 = require("../network/svm");
|
|
19
|
+
const privyShared_1 = require("./privyShared");
|
|
20
|
+
/**
|
|
21
|
+
* A wallet provider that uses Privy's server wallet API.
|
|
22
|
+
* This provider extends the SvmWalletProvider to provide Privy-specific wallet functionality
|
|
23
|
+
* while maintaining compatibility with the base wallet provider interface.
|
|
24
|
+
*/
|
|
25
|
+
class PrivySvmWalletProvider extends svmWalletProvider_1.SvmWalletProvider {
|
|
26
|
+
/**
|
|
27
|
+
* Private constructor to enforce use of factory method.
|
|
28
|
+
*
|
|
29
|
+
* @param config - The configuration options for the Privy wallet
|
|
30
|
+
*/
|
|
31
|
+
constructor(config) {
|
|
32
|
+
super();
|
|
33
|
+
_PrivySvmWalletProvider_walletId.set(this, void 0);
|
|
34
|
+
_PrivySvmWalletProvider_address.set(this, void 0);
|
|
35
|
+
_PrivySvmWalletProvider_authorizationPrivateKey.set(this, void 0);
|
|
36
|
+
_PrivySvmWalletProvider_privyClient.set(this, void 0);
|
|
37
|
+
_PrivySvmWalletProvider_connection.set(this, void 0);
|
|
38
|
+
_PrivySvmWalletProvider_genesisHash.set(this, void 0);
|
|
39
|
+
__classPrivateFieldSet(this, _PrivySvmWalletProvider_walletId, config.walletId, "f");
|
|
40
|
+
__classPrivateFieldSet(this, _PrivySvmWalletProvider_address, config.address, "f");
|
|
41
|
+
__classPrivateFieldSet(this, _PrivySvmWalletProvider_authorizationPrivateKey, config.authorizationPrivateKey, "f");
|
|
42
|
+
__classPrivateFieldSet(this, _PrivySvmWalletProvider_privyClient, config.privyClient, "f");
|
|
43
|
+
__classPrivateFieldSet(this, _PrivySvmWalletProvider_connection, config.connection, "f");
|
|
44
|
+
__classPrivateFieldSet(this, _PrivySvmWalletProvider_genesisHash, config.genesisHash, "f");
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Creates and configures a new PrivySolanaWalletProvider instance.
|
|
48
|
+
*
|
|
49
|
+
* @param config - The configuration options for the Privy wallet
|
|
50
|
+
* @returns A configured PrivySolanaWalletProvider instance
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const provider = await PrivySolanaWalletProvider.configureWithWallet({
|
|
55
|
+
* appId: "your-app-id",
|
|
56
|
+
* appSecret: "your-app-secret",
|
|
57
|
+
* walletId: "wallet-id",
|
|
58
|
+
* });
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
static async configureWithWallet(config) {
|
|
62
|
+
const { wallet, privy } = await (0, privyShared_1.createPrivyWallet)(config);
|
|
63
|
+
const connection = config.connection ??
|
|
64
|
+
new web3_js_1.Connection((0, web3_js_1.clusterApiUrl)(svm_1.SOLANA_CLUSTER_ID_BY_NETWORK_ID[config.networkId ?? ""]));
|
|
65
|
+
return new PrivySvmWalletProvider({
|
|
66
|
+
...config,
|
|
67
|
+
walletId: wallet.id,
|
|
68
|
+
address: wallet.address,
|
|
69
|
+
privyClient: privy,
|
|
70
|
+
connection,
|
|
71
|
+
genesisHash: await connection.getGenesisHash(),
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Sign a transaction.
|
|
76
|
+
*
|
|
77
|
+
* @param transaction - The transaction to sign.
|
|
78
|
+
* @returns The signed transaction.
|
|
79
|
+
*/
|
|
80
|
+
async signTransaction(transaction) {
|
|
81
|
+
const { signedTransaction } = await __classPrivateFieldGet(this, _PrivySvmWalletProvider_privyClient, "f").walletApi.solana.signTransaction({
|
|
82
|
+
walletId: __classPrivateFieldGet(this, _PrivySvmWalletProvider_walletId, "f"),
|
|
83
|
+
transaction,
|
|
84
|
+
});
|
|
85
|
+
return signedTransaction;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Sign and send a transaction.
|
|
89
|
+
*
|
|
90
|
+
* @param transaction - The transaction to send.
|
|
91
|
+
* @returns The transaction hash.
|
|
92
|
+
*/
|
|
93
|
+
async signAndSendTransaction(transaction) {
|
|
94
|
+
try {
|
|
95
|
+
const { hash } = await __classPrivateFieldGet(this, _PrivySvmWalletProvider_privyClient, "f").walletApi.solana.signAndSendTransaction({
|
|
96
|
+
walletId: __classPrivateFieldGet(this, _PrivySvmWalletProvider_walletId, "f"),
|
|
97
|
+
caip2: `solana:${__classPrivateFieldGet(this, _PrivySvmWalletProvider_genesisHash, "f").substring(0, 32)}`,
|
|
98
|
+
transaction,
|
|
99
|
+
});
|
|
100
|
+
return hash;
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
console.error("Failed to send transaction", error);
|
|
104
|
+
throw new Error("Failed to send transaction");
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Send a transaction.
|
|
109
|
+
*
|
|
110
|
+
* @param _ - The transaction to send.
|
|
111
|
+
* @returns The transaction hash.
|
|
112
|
+
*/
|
|
113
|
+
async sendTransaction(_) {
|
|
114
|
+
throw new Error("Method not implemented.");
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Exports the wallet data.
|
|
118
|
+
*
|
|
119
|
+
* @returns The wallet data
|
|
120
|
+
*/
|
|
121
|
+
exportWallet() {
|
|
122
|
+
return {
|
|
123
|
+
walletId: __classPrivateFieldGet(this, _PrivySvmWalletProvider_walletId, "f"),
|
|
124
|
+
authorizationPrivateKey: __classPrivateFieldGet(this, _PrivySvmWalletProvider_authorizationPrivateKey, "f"),
|
|
125
|
+
chainId: this.getNetwork().chainId,
|
|
126
|
+
networkId: this.getNetwork().networkId,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Gets the name of the wallet provider.
|
|
131
|
+
*
|
|
132
|
+
* @returns The string identifier for this wallet provider
|
|
133
|
+
*/
|
|
134
|
+
getName() {
|
|
135
|
+
return "privy_svm_wallet_provider";
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Get the address of the wallet.
|
|
139
|
+
*
|
|
140
|
+
* @returns The address of the wallet.
|
|
141
|
+
*/
|
|
142
|
+
getAddress() {
|
|
143
|
+
return __classPrivateFieldGet(this, _PrivySvmWalletProvider_address, "f");
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Get the network of the wallet.
|
|
147
|
+
*
|
|
148
|
+
* @returns The network of the wallet.
|
|
149
|
+
*/
|
|
150
|
+
getNetwork() {
|
|
151
|
+
return svm_1.SOLANA_NETWORKS[__classPrivateFieldGet(this, _PrivySvmWalletProvider_genesisHash, "f")];
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Get the balance of the wallet.
|
|
155
|
+
*
|
|
156
|
+
* @returns The balance of the wallet.
|
|
157
|
+
*/
|
|
158
|
+
async getBalance() {
|
|
159
|
+
const balance = await __classPrivateFieldGet(this, _PrivySvmWalletProvider_connection, "f").getBalance(new web3_js_1.PublicKey(__classPrivateFieldGet(this, _PrivySvmWalletProvider_address, "f")));
|
|
160
|
+
return BigInt(balance);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Transfer a native token.
|
|
164
|
+
*
|
|
165
|
+
* @param _ - The address to transfer the token to.
|
|
166
|
+
* @param arg2 - The value to transfer.
|
|
167
|
+
* @returns The transaction hash.
|
|
168
|
+
*/
|
|
169
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
170
|
+
async nativeTransfer(_, arg2) {
|
|
171
|
+
throw new Error("Method not implemented.");
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Get the status of a transaction.
|
|
175
|
+
*
|
|
176
|
+
* @param signature - The transaction signature.
|
|
177
|
+
* @returns The transaction status.
|
|
178
|
+
*/
|
|
179
|
+
async getSignatureStatus(signature) {
|
|
180
|
+
return __classPrivateFieldGet(this, _PrivySvmWalletProvider_connection, "f").getSignatureStatus(signature);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Wait for a signature result.
|
|
184
|
+
*
|
|
185
|
+
* @param signature - The signature to wait for.
|
|
186
|
+
* @returns The signature result.
|
|
187
|
+
*/
|
|
188
|
+
waitForSignatureResult(signature) {
|
|
189
|
+
return __classPrivateFieldGet(this, _PrivySvmWalletProvider_connection, "f").confirmTransaction({
|
|
190
|
+
signature,
|
|
191
|
+
...svm_1.SOLANA_NETWORKS[__classPrivateFieldGet(this, _PrivySvmWalletProvider_genesisHash, "f")],
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Get the connection.
|
|
196
|
+
*
|
|
197
|
+
* @returns The connection.
|
|
198
|
+
*/
|
|
199
|
+
getConnection() {
|
|
200
|
+
return __classPrivateFieldGet(this, _PrivySvmWalletProvider_connection, "f");
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Get the public key.
|
|
204
|
+
*
|
|
205
|
+
* @returns The public key.
|
|
206
|
+
*/
|
|
207
|
+
getPublicKey() {
|
|
208
|
+
return new web3_js_1.PublicKey(__classPrivateFieldGet(this, _PrivySvmWalletProvider_address, "f"));
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
exports.PrivySvmWalletProvider = PrivySvmWalletProvider;
|
|
212
|
+
_PrivySvmWalletProvider_walletId = new WeakMap(), _PrivySvmWalletProvider_address = new WeakMap(), _PrivySvmWalletProvider_authorizationPrivateKey = new WeakMap(), _PrivySvmWalletProvider_privyClient = new WeakMap(), _PrivySvmWalletProvider_connection = new WeakMap(), _PrivySvmWalletProvider_genesisHash = new WeakMap();
|
|
@@ -1,70 +1,35 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PrivyEvmWalletProvider, PrivyEvmWalletConfig } from "./privyEvmWalletProvider";
|
|
2
|
+
import { PrivySvmWalletProvider, PrivySvmWalletConfig } from "./privySvmWalletProvider";
|
|
3
|
+
export type PrivyWalletConfig = PrivyEvmWalletConfig | PrivySvmWalletConfig;
|
|
2
4
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* @interface
|
|
5
|
+
* Factory class for creating chain-specific Privy wallet providers
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
/** The Privy application ID */
|
|
9
|
-
appId: string;
|
|
10
|
-
/** The Privy application secret */
|
|
11
|
-
appSecret: string;
|
|
12
|
-
/** The ID of the wallet to use, if not provided a new wallet will be created */
|
|
13
|
-
walletId?: string;
|
|
14
|
-
/** Optional chain ID to connect to */
|
|
15
|
-
chainId?: string;
|
|
16
|
-
/** Optional authorization key for the wallet API */
|
|
17
|
-
authorizationPrivateKey?: string;
|
|
18
|
-
/** Optional authorization key ID for creating new wallets */
|
|
19
|
-
authorizationKeyId?: string;
|
|
20
|
-
}
|
|
21
|
-
type PrivyWalletExport = {
|
|
22
|
-
walletId: string;
|
|
23
|
-
authorizationPrivateKey: string | undefined;
|
|
24
|
-
chainId: string | undefined;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* A wallet provider that uses Privy's server wallet API.
|
|
28
|
-
* This provider extends the ViemWalletProvider to provide Privy-specific wallet functionality
|
|
29
|
-
* while maintaining compatibility with the base wallet provider interface.
|
|
30
|
-
*/
|
|
31
|
-
export declare class PrivyWalletProvider extends ViemWalletProvider {
|
|
32
|
-
#private;
|
|
33
|
-
/**
|
|
34
|
-
* Private constructor to enforce use of factory method.
|
|
35
|
-
*
|
|
36
|
-
* @param walletClient - The Viem wallet client instance
|
|
37
|
-
* @param config - The configuration options for the Privy wallet
|
|
38
|
-
*/
|
|
39
|
-
private constructor();
|
|
7
|
+
export declare class PrivyWalletProvider {
|
|
40
8
|
/**
|
|
41
|
-
* Creates and configures a new
|
|
9
|
+
* Creates and configures a new wallet provider instance based on the chain type.
|
|
42
10
|
*
|
|
43
11
|
* @param config - The configuration options for the Privy wallet
|
|
44
|
-
* @returns A configured
|
|
12
|
+
* @returns A configured WalletProvider instance for the specified chain
|
|
45
13
|
*
|
|
46
14
|
* @example
|
|
47
15
|
* ```typescript
|
|
48
|
-
*
|
|
16
|
+
* // For EVM (default)
|
|
17
|
+
* const evmWallet = await PrivyWalletProvider.configureWithWallet({
|
|
18
|
+
* appId: "your-app-id",
|
|
19
|
+
* appSecret: "your-app-secret"
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* // For Solana
|
|
23
|
+
* const solanaWallet = await PrivyWalletProvider.configureWithWallet({
|
|
49
24
|
* appId: "your-app-id",
|
|
50
25
|
* appSecret: "your-app-secret",
|
|
51
|
-
*
|
|
52
|
-
* chainId: "84532"
|
|
26
|
+
* chainType: "solana"
|
|
53
27
|
* });
|
|
54
28
|
* ```
|
|
55
29
|
*/
|
|
56
|
-
static configureWithWallet(config:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
*/
|
|
62
|
-
getName(): string;
|
|
63
|
-
/**
|
|
64
|
-
* Exports the wallet data.
|
|
65
|
-
*
|
|
66
|
-
* @returns The wallet data
|
|
67
|
-
*/
|
|
68
|
-
exportWallet(): PrivyWalletExport;
|
|
30
|
+
static configureWithWallet<T extends PrivyWalletConfig>(config: T & {
|
|
31
|
+
chainType?: "ethereum" | "solana";
|
|
32
|
+
}): Promise<T extends {
|
|
33
|
+
chainType: "solana";
|
|
34
|
+
} ? PrivySvmWalletProvider : PrivyEvmWalletProvider>;
|
|
69
35
|
}
|
|
70
|
-
export {};
|
|
@@ -1,139 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
-
};
|
|
8
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
-
};
|
|
13
|
-
var _PrivyWalletProvider_walletId, _PrivyWalletProvider_authorizationPrivateKey;
|
|
14
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
3
|
exports.PrivyWalletProvider = void 0;
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const viemWalletProvider_1 = require("./viemWalletProvider");
|
|
19
|
-
const viem_2 = require("viem");
|
|
20
|
-
const network_1 = require("../network/network");
|
|
4
|
+
const privyEvmWalletProvider_1 = require("./privyEvmWalletProvider");
|
|
5
|
+
const privySvmWalletProvider_1 = require("./privySvmWalletProvider");
|
|
21
6
|
/**
|
|
22
|
-
*
|
|
23
|
-
* This provider extends the ViemWalletProvider to provide Privy-specific wallet functionality
|
|
24
|
-
* while maintaining compatibility with the base wallet provider interface.
|
|
7
|
+
* Factory class for creating chain-specific Privy wallet providers
|
|
25
8
|
*/
|
|
26
|
-
class PrivyWalletProvider
|
|
9
|
+
class PrivyWalletProvider {
|
|
27
10
|
/**
|
|
28
|
-
*
|
|
11
|
+
* Creates and configures a new wallet provider instance based on the chain type.
|
|
29
12
|
*
|
|
30
|
-
* @param walletClient - The Viem wallet client instance
|
|
31
13
|
* @param config - The configuration options for the Privy wallet
|
|
32
|
-
|
|
33
|
-
constructor(walletClient, config) {
|
|
34
|
-
super(walletClient);
|
|
35
|
-
_PrivyWalletProvider_walletId.set(this, void 0);
|
|
36
|
-
_PrivyWalletProvider_authorizationPrivateKey.set(this, void 0);
|
|
37
|
-
__classPrivateFieldSet(this, _PrivyWalletProvider_walletId, config.walletId, "f"); // Now guaranteed to exist
|
|
38
|
-
__classPrivateFieldSet(this, _PrivyWalletProvider_authorizationPrivateKey, config.authorizationPrivateKey, "f");
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Creates and configures a new PrivyWalletProvider instance.
|
|
42
|
-
*
|
|
43
|
-
* @param config - The configuration options for the Privy wallet
|
|
44
|
-
* @returns A configured PrivyWalletProvider instance
|
|
14
|
+
* @returns A configured WalletProvider instance for the specified chain
|
|
45
15
|
*
|
|
46
16
|
* @example
|
|
47
17
|
* ```typescript
|
|
48
|
-
*
|
|
18
|
+
* // For EVM (default)
|
|
19
|
+
* const evmWallet = await PrivyWalletProvider.configureWithWallet({
|
|
20
|
+
* appId: "your-app-id",
|
|
21
|
+
* appSecret: "your-app-secret"
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* // For Solana
|
|
25
|
+
* const solanaWallet = await PrivyWalletProvider.configureWithWallet({
|
|
49
26
|
* appId: "your-app-id",
|
|
50
27
|
* appSecret: "your-app-secret",
|
|
51
|
-
*
|
|
52
|
-
* chainId: "84532"
|
|
28
|
+
* chainType: "solana"
|
|
53
29
|
* });
|
|
54
30
|
* ```
|
|
55
31
|
*/
|
|
56
32
|
static async configureWithWallet(config) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
? {
|
|
60
|
-
authorizationPrivateKey: config.authorizationPrivateKey,
|
|
61
|
-
}
|
|
62
|
-
: undefined,
|
|
63
|
-
});
|
|
64
|
-
let walletId;
|
|
65
|
-
let address;
|
|
66
|
-
if (!config.walletId) {
|
|
67
|
-
if (config.authorizationPrivateKey && !config.authorizationKeyId) {
|
|
68
|
-
throw new Error("authorizationKeyId is required when creating a new wallet with an authorization key, this can be found in your Privy Dashboard");
|
|
69
|
-
}
|
|
70
|
-
if (config.authorizationKeyId && !config.authorizationPrivateKey) {
|
|
71
|
-
throw new Error("authorizationPrivateKey is required when creating a new wallet with an authorizationKeyId. " +
|
|
72
|
-
"If you don't have it, you can create a new one in your Privy Dashboard, or delete the authorization key.");
|
|
73
|
-
}
|
|
74
|
-
try {
|
|
75
|
-
const wallet = await privy.walletApi.create({
|
|
76
|
-
chainType: "ethereum",
|
|
77
|
-
authorizationKeyIds: config.authorizationKeyId ? [config.authorizationKeyId] : undefined,
|
|
78
|
-
});
|
|
79
|
-
walletId = wallet.id;
|
|
80
|
-
address = wallet.address;
|
|
81
|
-
}
|
|
82
|
-
catch (error) {
|
|
83
|
-
console.error(error);
|
|
84
|
-
if (error instanceof Error &&
|
|
85
|
-
error.message.includes("Missing `privy-authorization-signature` header")) {
|
|
86
|
-
// Providing a more informative error message, see context: https://github.com/coinbase/agentkit/pull/242#discussion_r1956428617
|
|
87
|
-
throw new Error("Privy error: you have an authorization key on your account which can create and modify wallets, please delete this key or pass it to the PrivyWalletProvider to create a new wallet");
|
|
88
|
-
}
|
|
89
|
-
throw new Error("Failed to create wallet");
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
walletId = config.walletId;
|
|
94
|
-
const wallet = await privy.walletApi.getWallet({ id: walletId });
|
|
95
|
-
if (!wallet) {
|
|
96
|
-
throw new Error(`Wallet with ID ${walletId} not found`);
|
|
97
|
-
}
|
|
98
|
-
address = wallet.address;
|
|
33
|
+
if (config.chainType === "solana") {
|
|
34
|
+
return (await privySvmWalletProvider_1.PrivySvmWalletProvider.configureWithWallet(config));
|
|
99
35
|
}
|
|
100
|
-
|
|
101
|
-
walletId,
|
|
102
|
-
address,
|
|
103
|
-
privy,
|
|
104
|
-
});
|
|
105
|
-
const chainId = config.chainId || "84532";
|
|
106
|
-
const chain = (0, network_1.getChain)(chainId);
|
|
107
|
-
if (!chain) {
|
|
108
|
-
throw new Error(`Chain with ID ${chainId} not found`);
|
|
109
|
-
}
|
|
110
|
-
const walletClient = (0, viem_2.createWalletClient)({
|
|
111
|
-
account,
|
|
112
|
-
chain,
|
|
113
|
-
transport: (0, viem_2.http)(),
|
|
114
|
-
});
|
|
115
|
-
return new PrivyWalletProvider(walletClient, { ...config, walletId });
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Gets the name of the wallet provider.
|
|
119
|
-
*
|
|
120
|
-
* @returns The string identifier for this wallet provider
|
|
121
|
-
*/
|
|
122
|
-
getName() {
|
|
123
|
-
return "privy_wallet_provider";
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Exports the wallet data.
|
|
127
|
-
*
|
|
128
|
-
* @returns The wallet data
|
|
129
|
-
*/
|
|
130
|
-
exportWallet() {
|
|
131
|
-
return {
|
|
132
|
-
walletId: __classPrivateFieldGet(this, _PrivyWalletProvider_walletId, "f"),
|
|
133
|
-
authorizationPrivateKey: __classPrivateFieldGet(this, _PrivyWalletProvider_authorizationPrivateKey, "f"),
|
|
134
|
-
chainId: this.getNetwork().chainId,
|
|
135
|
-
};
|
|
36
|
+
return (await privyEvmWalletProvider_1.PrivyEvmWalletProvider.configureWithWallet(config));
|
|
136
37
|
}
|
|
137
38
|
}
|
|
138
39
|
exports.PrivyWalletProvider = PrivyWalletProvider;
|
|
139
|
-
_PrivyWalletProvider_walletId = new WeakMap(), _PrivyWalletProvider_authorizationPrivateKey = new WeakMap();
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@coinbase/agentkit",
|
|
3
3
|
"description": "Coinbase AgentKit core primitives",
|
|
4
4
|
"repository": "https://github.com/coinbase/agentkit",
|
|
5
|
-
"version": "0.2.
|
|
5
|
+
"version": "0.2.1",
|
|
6
6
|
"author": "Coinbase Inc.",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"main": "dist/index.js",
|