@exodus/solana-lib 1.2.14 → 1.2.16
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/package.json +6 -5
- package/src/constants.js +12 -0
- package/src/encode.js +57 -0
- package/src/fee-data/index.js +1 -0
- package/src/fee-data/solana.js +9 -0
- package/src/helpers/spl-token.js +108 -0
- package/src/helpers/tokenTransfer.js +72 -0
- package/src/index.js +9 -0
- package/src/keypair.js +32 -0
- package/src/tokens.js +12 -0
- package/src/transaction.js +292 -0
- package/src/tx/create-and-sign-tx.js +8 -0
- package/{lib → src}/tx/create-unsigned-tx.js +11 -18
- package/src/tx/index.js +4 -0
- package/src/tx/parse-unsigned-tx.js +41 -0
- package/src/tx/sign-unsigned-tx.js +78 -0
- package/src/vendor/account.js +38 -0
- package/src/vendor/index.js +9 -0
- package/src/vendor/instruction.js +46 -0
- package/src/vendor/message.js +216 -0
- package/src/vendor/nonce-account.js +46 -0
- package/src/vendor/publickey.js +212 -0
- package/src/vendor/stake-program.js +527 -0
- package/src/vendor/system-program.js +782 -0
- package/src/vendor/sysvar.js +16 -0
- package/src/vendor/transaction.js +594 -0
- package/src/vendor/utils/blockhash.js +6 -0
- package/src/vendor/utils/fee-calculator.js +17 -0
- package/src/vendor/utils/layout.js +80 -0
- package/src/vendor/utils/shortvec-encoding.js +30 -0
- package/src/vendor/utils/to-buffer.js +9 -0
- package/lib/constants.js +0 -19
- package/lib/encode.js +0 -67
- package/lib/fee-data/index.js +0 -15
- package/lib/fee-data/solana.js +0 -14
- package/lib/helpers/spl-token.js +0 -122
- package/lib/helpers/tokenTransfer.js +0 -78
- package/lib/index.js +0 -88
- package/lib/keypair.js +0 -38
- package/lib/tokens.js +0 -21
- package/lib/transaction.js +0 -338
- package/lib/tx/create-and-sign-tx.js +0 -15
- package/lib/tx/index.js +0 -53
- package/lib/tx/parse-unsigned-tx.js +0 -55
- package/lib/tx/sign-unsigned-tx.js +0 -90
- package/lib/vendor/account.js +0 -48
- package/lib/vendor/index.js +0 -113
- package/lib/vendor/instruction.js +0 -48
- package/lib/vendor/message.js +0 -167
- package/lib/vendor/nonce-account.js +0 -56
- package/lib/vendor/publickey.js +0 -211
- package/lib/vendor/stake-program.js +0 -476
- package/lib/vendor/system-program.js +0 -640
- package/lib/vendor/sysvar.js +0 -19
- package/lib/vendor/transaction.js +0 -594
- package/lib/vendor/utils/blockhash.js +0 -1
- package/lib/vendor/utils/fee-calculator.js +0 -25
- package/lib/vendor/utils/layout.js +0 -97
- package/lib/vendor/utils/shortvec-encoding.js +0 -41
- package/lib/vendor/utils/to-buffer.js +0 -18
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getAlloc = getAlloc;
|
|
7
|
-
exports.lockup = exports.authorized = exports.rustString = exports.uint64 = exports.publicKey = void 0;
|
|
8
|
-
|
|
9
|
-
var BufferLayout = _interopRequireWildcard(require("@exodus/buffer-layout"));
|
|
10
|
-
|
|
11
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
12
|
-
|
|
13
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Layout for a public key
|
|
17
|
-
*/
|
|
18
|
-
const publicKey = (property = 'publicKey') => {
|
|
19
|
-
return BufferLayout.blob(32, property);
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Layout for a 64bit unsigned value
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
exports.publicKey = publicKey;
|
|
27
|
-
|
|
28
|
-
const uint64 = (property = 'uint64') => {
|
|
29
|
-
return BufferLayout.blob(8, property);
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Layout for a Rust String type
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
exports.uint64 = uint64;
|
|
37
|
-
|
|
38
|
-
const rustString = (property = 'string') => {
|
|
39
|
-
const rsl = BufferLayout.struct([BufferLayout.u32('length'), BufferLayout.u32('lengthPadding'), BufferLayout.blob(BufferLayout.offset(BufferLayout.u32(), -8), 'chars')], property);
|
|
40
|
-
|
|
41
|
-
const _decode = rsl.decode.bind(rsl);
|
|
42
|
-
|
|
43
|
-
const _encode = rsl.encode.bind(rsl);
|
|
44
|
-
|
|
45
|
-
rsl.decode = (buffer, offset) => {
|
|
46
|
-
const data = _decode(buffer, offset);
|
|
47
|
-
|
|
48
|
-
return data.chars.toString('utf8');
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
rsl.encode = (str, buffer, offset) => {
|
|
52
|
-
const data = {
|
|
53
|
-
chars: Buffer.from(str, 'utf8')
|
|
54
|
-
};
|
|
55
|
-
return _encode(data, buffer, offset);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
rsl.alloc = str => {
|
|
59
|
-
return BufferLayout.u32().span + BufferLayout.u32().span + Buffer.from(str, 'utf8').length;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
return rsl;
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* Layout for an Authorized object
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
exports.rustString = rustString;
|
|
70
|
-
|
|
71
|
-
const authorized = (property = 'authorized') => {
|
|
72
|
-
return BufferLayout.struct([publicKey('staker'), publicKey('withdrawer')], property);
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* Layout for a Lockup object
|
|
76
|
-
*/
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
exports.authorized = authorized;
|
|
80
|
-
|
|
81
|
-
const lockup = (property = 'lockup') => {
|
|
82
|
-
return BufferLayout.struct([BufferLayout.ns64('unixTimestamp'), BufferLayout.ns64('epoch'), publicKey('custodian')], property);
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
exports.lockup = lockup;
|
|
86
|
-
|
|
87
|
-
function getAlloc(type, fields) {
|
|
88
|
-
let alloc = 0;
|
|
89
|
-
type.layout.fields.forEach(item => {
|
|
90
|
-
if (item.span >= 0) {
|
|
91
|
-
alloc += item.span;
|
|
92
|
-
} else if (typeof item.alloc === 'function') {
|
|
93
|
-
alloc += item.alloc(fields[item.property]);
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
return alloc;
|
|
97
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.decodeLength = decodeLength;
|
|
7
|
-
exports.encodeLength = encodeLength;
|
|
8
|
-
|
|
9
|
-
function decodeLength(bytes) {
|
|
10
|
-
let len = 0;
|
|
11
|
-
let size = 0;
|
|
12
|
-
|
|
13
|
-
for (;;) {
|
|
14
|
-
let elem = bytes.shift();
|
|
15
|
-
len |= (elem & 0x7f) << size * 7;
|
|
16
|
-
size += 1;
|
|
17
|
-
|
|
18
|
-
if ((elem & 0x80) === 0) {
|
|
19
|
-
break;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return len;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function encodeLength(bytes, len) {
|
|
27
|
-
let remLen = len;
|
|
28
|
-
|
|
29
|
-
for (;;) {
|
|
30
|
-
let elem = remLen & 0x7f;
|
|
31
|
-
remLen >>= 7;
|
|
32
|
-
|
|
33
|
-
if (remLen === 0) {
|
|
34
|
-
bytes.push(elem);
|
|
35
|
-
break;
|
|
36
|
-
} else {
|
|
37
|
-
elem |= 0x80;
|
|
38
|
-
bytes.push(elem);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.toBuffer = void 0;
|
|
7
|
-
|
|
8
|
-
const toBuffer = arr => {
|
|
9
|
-
if (arr instanceof Buffer) {
|
|
10
|
-
return arr;
|
|
11
|
-
} else if (arr instanceof Uint8Array) {
|
|
12
|
-
return Buffer.from(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
13
|
-
} else {
|
|
14
|
-
return Buffer.from(arr);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
exports.toBuffer = toBuffer;
|