@haven-fi/solauto-sdk 1.0.4 → 1.0.6
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/dist/utils/local/shared.d.ts +1 -0
- package/dist/utils/local/shared.d.ts.map +1 -1
- package/dist/utils/local/shared.js +15 -3
- package/dist/utils/solanaUtils.d.ts +0 -2
- package/dist/utils/solanaUtils.d.ts.map +1 -1
- package/dist/utils/solanaUtils.js +1 -12
- package/package.json +1 -1
- package/src/utils/local/shared.ts +13 -1
- package/src/utils/solanaUtils.ts +0 -14
- package/tests/shared.ts +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/utils/local/shared.ts"],"names":[],"mappings":"
|
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
|
-
|
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({
|
@@ -1,8 +1,6 @@
|
|
1
1
|
import { AddressLookupTableInput, Signer, TransactionBuilder, WrappedInstruction } from "@metaplex-foundation/umi";
|
2
2
|
import { PublicKey, TransactionInstruction } from "@solana/web3.js";
|
3
3
|
import { SolautoClient } from "../clients/solautoClient";
|
4
|
-
export declare function loadSecretKey(keypairPath: string): Uint8Array;
|
5
|
-
export declare function getSecretKey(keypairFilename?: string): Uint8Array;
|
6
4
|
export declare function currentUnixSecondsSolana(): Promise<number>;
|
7
5
|
export declare function getWrappedInstruction(signer: Signer, ix: TransactionInstruction): WrappedInstruction;
|
8
6
|
export declare function setComputeUnitLimitUmiIx(signer: Signer, maxComputeUnits: number): WrappedInstruction;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solanaUtils.d.ts","sourceRoot":"","sources":["../../src/utils/solanaUtils.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"solanaUtils.d.ts","sourceRoot":"","sources":["../../src/utils/solanaUtils.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EACvB,MAAM,EACN,kBAAkB,EAClB,kBAAkB,EAGnB,MAAM,0BAA0B,CAAC;AAMlC,OAAO,EAGL,SAAS,EAIT,sBAAsB,EAEvB,MAAM,iBAAiB,CAAC;AAOzB,OAAO,EAAE,aAA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BAAsB,8BAA8B,CAClD,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,YAAY,CAAC,EAAE,OAAO,EACtB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAqDjC"}
|
@@ -3,10 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.sendSingleOptimizedTransaction = exports.getComputeUnitPriceEstimate = exports.assembleFinalTransaction = exports.getAdressLookupInputs = exports.splTokenTransferUmiIx = exports.closeTokenAccountUmiIx = exports.systemTransferUmiIx = exports.createAssociatedTokenAccountUmiIx = exports.setComputeUnitPriceUmiIx = exports.setComputeUnitLimitUmiIx = exports.getWrappedInstruction = exports.currentUnixSecondsSolana =
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
6
|
+
exports.sendSingleOptimizedTransaction = exports.getComputeUnitPriceEstimate = exports.assembleFinalTransaction = exports.getAdressLookupInputs = exports.splTokenTransferUmiIx = exports.closeTokenAccountUmiIx = exports.systemTransferUmiIx = exports.createAssociatedTokenAccountUmiIx = exports.setComputeUnitPriceUmiIx = exports.setComputeUnitLimitUmiIx = exports.getWrappedInstruction = exports.currentUnixSecondsSolana = void 0;
|
8
7
|
const bs58_1 = __importDefault(require("bs58"));
|
9
|
-
const path_1 = __importDefault(require("path"));
|
10
8
|
const umi_1 = require("@metaplex-foundation/umi");
|
11
9
|
const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters");
|
12
10
|
const web3_js_1 = require("@solana/web3.js");
|
@@ -15,15 +13,6 @@ const accountUtils_1 = require("./accountUtils");
|
|
15
13
|
const solautoConstants_1 = require("../constants/solautoConstants");
|
16
14
|
const generalUtils_1 = require("./generalUtils");
|
17
15
|
const marginfi_sdk_1 = require("../marginfi-sdk");
|
18
|
-
function loadSecretKey(keypairPath) {
|
19
|
-
const secretKey = JSON.parse(fs_1.default.readFileSync(keypairPath, "utf8"));
|
20
|
-
return new Uint8Array(secretKey);
|
21
|
-
}
|
22
|
-
exports.loadSecretKey = loadSecretKey;
|
23
|
-
function getSecretKey(keypairFilename = "id") {
|
24
|
-
return loadSecretKey(path_1.default.join(process.env.HOME, ".config", "solana", keypairFilename + ".json"));
|
25
|
-
}
|
26
|
-
exports.getSecretKey = getSecretKey;
|
27
16
|
async function currentUnixSecondsSolana() {
|
28
17
|
return await (0, generalUtils_1.retryWithExponentialBackoff)(async () => {
|
29
18
|
const blockTime = await solautoConstants_1.CONNECTION.getBlockTime(await solautoConstants_1.CONNECTION.getSlot());
|
package/package.json
CHANGED
@@ -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/src/utils/solanaUtils.ts
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
import fs from "fs";
|
2
1
|
import bs58 from "bs58";
|
3
|
-
import path from "path";
|
4
2
|
import {
|
5
3
|
AddressLookupTableInput,
|
6
4
|
Signer,
|
@@ -23,7 +21,6 @@ import {
|
|
23
21
|
SystemProgram,
|
24
22
|
TransactionInstruction,
|
25
23
|
VersionedTransaction,
|
26
|
-
TransactionError,
|
27
24
|
} from "@solana/web3.js";
|
28
25
|
import {
|
29
26
|
createAssociatedTokenAccountIdempotentInstruction,
|
@@ -39,17 +36,6 @@ import {
|
|
39
36
|
getLendingAccountStartFlashloanInstructionDataSerializer,
|
40
37
|
} from "../marginfi-sdk";
|
41
38
|
|
42
|
-
export function loadSecretKey(keypairPath: string) {
|
43
|
-
const secretKey = JSON.parse(fs.readFileSync(keypairPath, "utf8"));
|
44
|
-
return new Uint8Array(secretKey);
|
45
|
-
}
|
46
|
-
|
47
|
-
export function getSecretKey(keypairFilename: string = "id"): Uint8Array {
|
48
|
-
return loadSecretKey(
|
49
|
-
path.join(process.env.HOME!, ".config", "solana", keypairFilename + ".json")
|
50
|
-
);
|
51
|
-
}
|
52
|
-
|
53
39
|
export async function currentUnixSecondsSolana(): Promise<number> {
|
54
40
|
return await retryWithExponentialBackoff(async () => {
|
55
41
|
const blockTime = await CONNECTION.getBlockTime(await CONNECTION.getSlot());
|
package/tests/shared.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Signer, createSignerFromKeypair } from "@metaplex-foundation/umi";
|
2
2
|
import { Connection, clusterApiUrl } from "@solana/web3.js";
|
3
3
|
import { createUmi } from "@metaplex-foundation/umi-bundle-defaults";
|
4
|
-
import { getSecretKey } from "../src/utils/
|
4
|
+
import { getSecretKey } from "../src/utils/local/shared";
|
5
5
|
|
6
6
|
export function setupTest(keypairFilename?: string): Signer {
|
7
7
|
const umi = createUmi(
|