@drift-labs/sdk 2.91.0-beta.3 → 2.91.0-beta.5
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/VERSION +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/keypair.d.ts +2 -0
- package/lib/keypair.js +28 -0
- package/lib/wallet.d.ts +0 -1
- package/lib/wallet.js +1 -26
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/keypair.ts +24 -0
- package/src/wallet.ts +0 -23
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.91.0-beta.
|
|
1
|
+
2.91.0-beta.5
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -85,6 +85,7 @@ __exportStar(require("./marinade"), exports);
|
|
|
85
85
|
__exportStar(require("./orderParams"), exports);
|
|
86
86
|
__exportStar(require("./slot/SlotSubscriber"), exports);
|
|
87
87
|
__exportStar(require("./wallet"), exports);
|
|
88
|
+
__exportStar(require("./keypair"), exports);
|
|
88
89
|
__exportStar(require("./types"), exports);
|
|
89
90
|
__exportStar(require("./math/utils"), exports);
|
|
90
91
|
__exportStar(require("./math/fuel"), exports);
|
package/lib/keypair.d.ts
ADDED
package/lib/keypair.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.loadKeypair = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const bs58_1 = __importDefault(require("bs58"));
|
|
9
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
10
|
+
function loadKeypair(privateKey) {
|
|
11
|
+
// try to load privateKey as a filepath
|
|
12
|
+
let loadedKey;
|
|
13
|
+
if (fs_1.default.existsSync(privateKey)) {
|
|
14
|
+
privateKey = fs_1.default.readFileSync(privateKey).toString();
|
|
15
|
+
}
|
|
16
|
+
if (privateKey.includes('[') && privateKey.includes(']')) {
|
|
17
|
+
loadedKey = Uint8Array.from(JSON.parse(privateKey));
|
|
18
|
+
}
|
|
19
|
+
else if (privateKey.includes(',')) {
|
|
20
|
+
loadedKey = Uint8Array.from(privateKey.split(',').map((val) => Number(val)));
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
privateKey = privateKey.replace(/\s/g, '');
|
|
24
|
+
loadedKey = new Uint8Array(bs58_1.default.decode(privateKey));
|
|
25
|
+
}
|
|
26
|
+
return web3_js_1.Keypair.fromSecretKey(Uint8Array.from(loadedKey));
|
|
27
|
+
}
|
|
28
|
+
exports.loadKeypair = loadKeypair;
|
package/lib/wallet.d.ts
CHANGED
package/lib/wallet.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const bs58_1 = __importDefault(require("bs58"));
|
|
3
|
+
exports.Wallet = void 0;
|
|
10
4
|
class Wallet {
|
|
11
5
|
constructor(payer) {
|
|
12
6
|
this.payer = payer;
|
|
@@ -36,22 +30,3 @@ class Wallet {
|
|
|
36
30
|
}
|
|
37
31
|
}
|
|
38
32
|
exports.Wallet = Wallet;
|
|
39
|
-
function loadKeypair(privateKey) {
|
|
40
|
-
// try to load privateKey as a filepath
|
|
41
|
-
let loadedKey;
|
|
42
|
-
if (fs_1.default.existsSync(privateKey)) {
|
|
43
|
-
privateKey = fs_1.default.readFileSync(privateKey).toString();
|
|
44
|
-
}
|
|
45
|
-
if (privateKey.includes('[') && privateKey.includes(']')) {
|
|
46
|
-
loadedKey = Uint8Array.from(JSON.parse(privateKey));
|
|
47
|
-
}
|
|
48
|
-
else if (privateKey.includes(',')) {
|
|
49
|
-
loadedKey = Uint8Array.from(privateKey.split(',').map((val) => Number(val)));
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
privateKey = privateKey.replace(/\s/g, '');
|
|
53
|
-
loadedKey = new Uint8Array(bs58_1.default.decode(privateKey));
|
|
54
|
-
}
|
|
55
|
-
return web3_js_1.Keypair.fromSecretKey(Uint8Array.from(loadedKey));
|
|
56
|
-
}
|
|
57
|
-
exports.loadKeypair = loadKeypair;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
package/src/keypair.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import bs58 from 'bs58';
|
|
3
|
+
import { Keypair } from '@solana/web3.js';
|
|
4
|
+
|
|
5
|
+
export function loadKeypair(privateKey: string): Keypair {
|
|
6
|
+
// try to load privateKey as a filepath
|
|
7
|
+
let loadedKey: Uint8Array;
|
|
8
|
+
if (fs.existsSync(privateKey)) {
|
|
9
|
+
privateKey = fs.readFileSync(privateKey).toString();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (privateKey.includes('[') && privateKey.includes(']')) {
|
|
13
|
+
loadedKey = Uint8Array.from(JSON.parse(privateKey));
|
|
14
|
+
} else if (privateKey.includes(',')) {
|
|
15
|
+
loadedKey = Uint8Array.from(
|
|
16
|
+
privateKey.split(',').map((val) => Number(val))
|
|
17
|
+
);
|
|
18
|
+
} else {
|
|
19
|
+
privateKey = privateKey.replace(/\s/g, '');
|
|
20
|
+
loadedKey = new Uint8Array(bs58.decode(privateKey));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return Keypair.fromSecretKey(Uint8Array.from(loadedKey));
|
|
24
|
+
}
|
package/src/wallet.ts
CHANGED
|
@@ -5,8 +5,6 @@ import {
|
|
|
5
5
|
VersionedTransaction,
|
|
6
6
|
} from '@solana/web3.js';
|
|
7
7
|
import { IWallet, IVersionedWallet } from './types';
|
|
8
|
-
import fs from 'fs';
|
|
9
|
-
import bs58 from 'bs58';
|
|
10
8
|
|
|
11
9
|
export class Wallet implements IWallet, IVersionedWallet {
|
|
12
10
|
constructor(readonly payer: Keypair) {}
|
|
@@ -43,24 +41,3 @@ export class Wallet implements IWallet, IVersionedWallet {
|
|
|
43
41
|
return this.payer.publicKey;
|
|
44
42
|
}
|
|
45
43
|
}
|
|
46
|
-
|
|
47
|
-
export function loadKeypair(privateKey: string): Keypair {
|
|
48
|
-
// try to load privateKey as a filepath
|
|
49
|
-
let loadedKey: Uint8Array;
|
|
50
|
-
if (fs.existsSync(privateKey)) {
|
|
51
|
-
privateKey = fs.readFileSync(privateKey).toString();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (privateKey.includes('[') && privateKey.includes(']')) {
|
|
55
|
-
loadedKey = Uint8Array.from(JSON.parse(privateKey));
|
|
56
|
-
} else if (privateKey.includes(',')) {
|
|
57
|
-
loadedKey = Uint8Array.from(
|
|
58
|
-
privateKey.split(',').map((val) => Number(val))
|
|
59
|
-
);
|
|
60
|
-
} else {
|
|
61
|
-
privateKey = privateKey.replace(/\s/g, '');
|
|
62
|
-
loadedKey = new Uint8Array(bs58.decode(privateKey));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return Keypair.fromSecretKey(Uint8Array.from(loadedKey));
|
|
66
|
-
}
|