@faremeter/wallet-crossmint 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/LICENSE +674 -0
- package/dist/src/index.d.ts +7 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +27 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +23 -0
- package/src/index.ts +40 -0
- package/tsconfig.json +8 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { PublicKey, VersionedTransaction } from "@solana/web3.js";
|
|
2
|
+
import {
|
|
3
|
+
createCrossmint,
|
|
4
|
+
CrossmintWallets,
|
|
5
|
+
SolanaWallet,
|
|
6
|
+
} from "@crossmint/wallets-sdk";
|
|
7
|
+
|
|
8
|
+
export async function createCrossmintWallet(
|
|
9
|
+
network: string,
|
|
10
|
+
crossmintApiKey: string,
|
|
11
|
+
crossmintWalletAddress: string,
|
|
12
|
+
) {
|
|
13
|
+
const crossmint = createCrossmint({
|
|
14
|
+
apiKey: crossmintApiKey,
|
|
15
|
+
});
|
|
16
|
+
const crossmintWallets = CrossmintWallets.from(crossmint);
|
|
17
|
+
const wallet = await crossmintWallets.getWallet(crossmintWalletAddress, {
|
|
18
|
+
chain: "solana",
|
|
19
|
+
signer: {
|
|
20
|
+
type: "api-key",
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
console.log(wallet.address);
|
|
25
|
+
|
|
26
|
+
const solanaWallet = SolanaWallet.from(wallet);
|
|
27
|
+
const publicKey = new PublicKey(solanaWallet.address);
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
network,
|
|
31
|
+
publicKey,
|
|
32
|
+
sendTransaction: async (tx: VersionedTransaction) => {
|
|
33
|
+
const solTx = await solanaWallet.sendTransaction({
|
|
34
|
+
transaction: tx as any, // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return solTx.hash;
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|