@haven-fi/solauto-sdk 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,4 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
+ export declare function getSecretKey(keypairFilename?: string): Uint8Array;
2
3
  export declare function updateLookupTable(accounts: string[], lookupTableAddress?: PublicKey): Promise<void>;
3
4
  //# sourceMappingURL=shared.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/utils/local/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,SAAS,EACV,MAAM,iBAAiB,CAAC;AAsDzB,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAAE,EAClB,kBAAkB,CAAC,EAAE,SAAS,iBAqB/B"}
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/utils/local/shared.ts"],"names":[],"mappings":"AAEA,OAAO,EAML,SAAS,EACV,MAAM,iBAAiB,CAAC;AAQzB,wBAAgB,YAAY,CAAC,eAAe,GAAE,MAAa,GAAG,UAAU,CAIvE;AAoDD,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAAE,EAClB,kBAAkB,CAAC,EAAE,SAAS,iBAqB/B"}
@@ -1,10 +1,22 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateLookupTable = void 0;
6
+ exports.updateLookupTable = exports.getSecretKey = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const fs_1 = __importDefault(require("fs"));
4
9
  const web3_js_1 = require("@solana/web3.js");
5
- const solanaUtils_1 = require("../solanaUtils");
6
10
  const solautoConstants_1 = require("../../constants/solautoConstants");
7
- const keypair = web3_js_1.Keypair.fromSecretKey((0, solanaUtils_1.getSecretKey)());
11
+ function loadSecretKey(keypairPath) {
12
+ const secretKey = JSON.parse(fs_1.default.readFileSync(keypairPath, "utf8"));
13
+ return new Uint8Array(secretKey);
14
+ }
15
+ function getSecretKey(keypairFilename = "id") {
16
+ return loadSecretKey(path_1.default.join(process.env.HOME, ".config", "solana", keypairFilename + ".json"));
17
+ }
18
+ exports.getSecretKey = getSecretKey;
19
+ const keypair = web3_js_1.Keypair.fromSecretKey(getSecretKey());
8
20
  async function createAndSendV0Tx(txInstructions) {
9
21
  let latestBlockhash = await solautoConstants_1.CONNECTION.getLatestBlockhash("finalized");
10
22
  const messageV0 = new web3_js_1.TransactionMessage({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "description": "Typescript SDK for the Solauto program on the Solana blockchain",
@@ -1,3 +1,5 @@
1
+ import path from "path";
2
+ import fs from "fs";
1
3
  import {
2
4
  Keypair,
3
5
  AddressLookupTableProgram,
@@ -6,9 +8,19 @@ import {
6
8
  VersionedTransaction,
7
9
  PublicKey,
8
10
  } from "@solana/web3.js";
9
- import { getSecretKey } from "../solanaUtils";
10
11
  import { CONNECTION } from "../../constants/solautoConstants";
11
12
 
13
+ function loadSecretKey(keypairPath: string) {
14
+ const secretKey = JSON.parse(fs.readFileSync(keypairPath, "utf8"));
15
+ return new Uint8Array(secretKey);
16
+ }
17
+
18
+ export function getSecretKey(keypairFilename: string = "id"): Uint8Array {
19
+ return loadSecretKey(
20
+ path.join(process.env.HOME!, ".config", "solana", keypairFilename + ".json")
21
+ );
22
+ }
23
+
12
24
  const keypair = Keypair.fromSecretKey(getSecretKey());
13
25
 
14
26
  async function createAndSendV0Tx(txInstructions: TransactionInstruction[]) {
package/tests/shared.ts CHANGED
@@ -1,19 +1,7 @@
1
- import path from "path";
2
- import fs from "fs";
3
1
  import { Signer, createSignerFromKeypair } from "@metaplex-foundation/umi";
4
2
  import { Connection, clusterApiUrl } from "@solana/web3.js";
5
3
  import { createUmi } from "@metaplex-foundation/umi-bundle-defaults";
6
-
7
- export function loadSecretKey(keypairPath: string) {
8
- const secretKey = JSON.parse(fs.readFileSync(keypairPath, "utf8"));
9
- return new Uint8Array(secretKey);
10
- }
11
-
12
- export function getSecretKey(keypairFilename: string = "id"): Uint8Array {
13
- return loadSecretKey(
14
- path.join(process.env.HOME!, ".config", "solana", keypairFilename + ".json")
15
- );
16
- }
4
+ import { getSecretKey } from "../src/utils/local/shared";
17
5
 
18
6
  export function setupTest(keypairFilename?: string): Signer {
19
7
  const umi = createUmi(