@omegax/protocol-sdk 0.4.4 → 0.6.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/NOTICE +5 -0
- package/README.md +88 -20
- package/dist/claims.d.ts +1 -2
- package/dist/claims.js +101 -166
- package/dist/internal/protocol/all.d.ts +283 -0
- package/dist/internal/protocol/all.js +7195 -0
- package/dist/internal/protocol/builders.d.ts +1 -0
- package/dist/internal/protocol/builders.js +1 -0
- package/dist/internal/protocol/client.d.ts +1 -0
- package/dist/internal/protocol/client.js +1 -0
- package/dist/internal/protocol/constants.d.ts +1 -0
- package/dist/internal/protocol/constants.js +1 -0
- package/dist/internal/protocol/decoders.d.ts +1 -0
- package/dist/internal/protocol/decoders.js +1 -0
- package/dist/internal/protocol/fetchers.d.ts +1 -0
- package/dist/internal/protocol/fetchers.js +1 -0
- package/dist/internal/protocol/shared.d.ts +1 -0
- package/dist/internal/protocol/shared.js +1 -0
- package/dist/internal/protocol-seeds/all.d.ts +265 -0
- package/dist/internal/protocol-seeds/all.js +455 -0
- package/dist/internal/protocol-seeds/claims.d.ts +1 -0
- package/dist/internal/protocol-seeds/claims.js +1 -0
- package/dist/internal/protocol-seeds/core.d.ts +1 -0
- package/dist/internal/protocol-seeds/core.js +1 -0
- package/dist/internal/protocol-seeds/liquidity.d.ts +1 -0
- package/dist/internal/protocol-seeds/liquidity.js +1 -0
- package/dist/internal/protocol-seeds/oracle.d.ts +1 -0
- package/dist/internal/protocol-seeds/oracle.js +1 -0
- package/dist/internal/protocol-seeds/policy.d.ts +1 -0
- package/dist/internal/protocol-seeds/policy.js +1 -0
- package/dist/internal/reward-claim.d.ts +17 -0
- package/dist/internal/reward-claim.js +27 -0
- package/dist/internal/rpc.d.ts +15 -0
- package/dist/internal/rpc.js +26 -0
- package/dist/internal/types/all.d.ts +1952 -0
- package/dist/internal/types/all.js +1 -0
- package/dist/internal/types/builders.d.ts +1 -0
- package/dist/internal/types/builders.js +1 -0
- package/dist/internal/types/claims.d.ts +1 -0
- package/dist/internal/types/claims.js +1 -0
- package/dist/internal/types/oracle.d.ts +1 -0
- package/dist/internal/types/oracle.js +1 -0
- package/dist/internal/types/protocol.d.ts +1 -0
- package/dist/internal/types/protocol.js +1 -0
- package/dist/internal/types/rpc.d.ts +1 -0
- package/dist/internal/types/rpc.js +1 -0
- package/dist/oracle.js +3 -2
- package/dist/protocol.d.ts +3 -13
- package/dist/protocol.js +3 -4534
- package/dist/protocol_seeds.d.ts +1 -220
- package/dist/protocol_seeds.js +1 -324
- package/dist/rpc.js +51 -6
- package/dist/transactions.d.ts +1 -0
- package/dist/transactions.js +28 -6
- package/dist/types.d.ts +1 -1424
- package/dist/types.js +1 -1
- package/package.json +22 -5
package/dist/transactions.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import bs58 from 'bs58';
|
|
2
|
-
import { Transaction, VersionedTransaction
|
|
2
|
+
import { Transaction, VersionedTransaction } from '@solana/web3.js';
|
|
3
3
|
function decodeShortVecLength(bytes, offset = 0) {
|
|
4
4
|
let length = 0;
|
|
5
5
|
let size = 0;
|
|
@@ -27,7 +27,9 @@ function signatureIsPresent(signature) {
|
|
|
27
27
|
return signature.some((value) => value !== 0);
|
|
28
28
|
}
|
|
29
29
|
export function decodeSolanaTransaction(input) {
|
|
30
|
-
const bytes = typeof input === 'string'
|
|
30
|
+
const bytes = typeof input === 'string'
|
|
31
|
+
? Buffer.from(input, 'base64')
|
|
32
|
+
: Buffer.from(input);
|
|
31
33
|
const { length: signatureCount, bytesRead } = decodeShortVecLength(bytes);
|
|
32
34
|
const messageOffset = bytesRead + signatureCount * 64;
|
|
33
35
|
if (messageOffset >= bytes.length) {
|
|
@@ -57,8 +59,27 @@ export function solanaTransactionMessageBytes(transaction) {
|
|
|
57
59
|
}
|
|
58
60
|
return transaction.message.serialize();
|
|
59
61
|
}
|
|
62
|
+
function normalizeSolanaMessageBytesIgnoringRecentBlockhash(messageBytes) {
|
|
63
|
+
const normalized = Uint8Array.from(messageBytes);
|
|
64
|
+
const messagePrefix = normalized[0] ?? 0;
|
|
65
|
+
const isVersioned = (messagePrefix & 0x80) !== 0;
|
|
66
|
+
let cursor = isVersioned ? 1 : 0;
|
|
67
|
+
cursor += 3;
|
|
68
|
+
const { length: accountKeyCount, bytesRead } = decodeShortVecLength(normalized, cursor);
|
|
69
|
+
cursor += bytesRead + accountKeyCount * 32;
|
|
70
|
+
if (cursor + 32 > normalized.length) {
|
|
71
|
+
throw new Error('invalid serialized transaction message');
|
|
72
|
+
}
|
|
73
|
+
normalized.fill(0, cursor, cursor + 32);
|
|
74
|
+
return normalized;
|
|
75
|
+
}
|
|
76
|
+
export function solanaTransactionIntentMessageBytes(transaction) {
|
|
77
|
+
return normalizeSolanaMessageBytesIgnoringRecentBlockhash(solanaTransactionMessageBytes(transaction));
|
|
78
|
+
}
|
|
60
79
|
export function solanaTransactionMessageBase64(input) {
|
|
61
|
-
const transaction = typeof input === 'string' ||
|
|
80
|
+
const transaction = typeof input === 'string' ||
|
|
81
|
+
input instanceof Uint8Array ||
|
|
82
|
+
Buffer.isBuffer(input)
|
|
62
83
|
? decodeSolanaTransaction(input)
|
|
63
84
|
: input;
|
|
64
85
|
return Buffer.from(solanaTransactionMessageBytes(transaction)).toString('base64');
|
|
@@ -87,14 +108,15 @@ export function solanaTransactionFirstSignature(transaction) {
|
|
|
87
108
|
export function solanaTransactionSignerSignature(transaction, signer) {
|
|
88
109
|
if (transaction instanceof Transaction) {
|
|
89
110
|
const entry = transaction.signatures.find((candidate) => candidate.publicKey.toBase58() === signer);
|
|
90
|
-
return signatureIsPresent(entry?.signature)
|
|
111
|
+
return signatureIsPresent(entry?.signature)
|
|
112
|
+
? entry?.signature
|
|
113
|
+
: null;
|
|
91
114
|
}
|
|
92
115
|
const accountKeys = versionedStaticAccountKeys(transaction);
|
|
93
116
|
const signerIndex = accountKeys.findIndex((candidate) => candidate.toBase58() === signer);
|
|
94
117
|
if (signerIndex < 0)
|
|
95
118
|
return null;
|
|
96
|
-
const header = transaction.message
|
|
97
|
-
.header;
|
|
119
|
+
const header = transaction.message.header;
|
|
98
120
|
const requiredSignerCount = header?.numRequiredSignatures ?? 0;
|
|
99
121
|
if (signerIndex >= requiredSignerCount) {
|
|
100
122
|
return null;
|