@thru/programs 0.3.17 → 0.4.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/README.md +9 -0
- package/dist/abi-manager/index.cjs +154 -33
- package/dist/abi-manager/index.cjs.map +1 -1
- package/dist/abi-manager/index.d.cts +1 -1
- package/dist/abi-manager/index.d.ts +1 -1
- package/dist/abi-manager/index.js +3 -2
- package/dist/amm/index.cjs +81 -47
- package/dist/amm/index.cjs.map +1 -1
- package/dist/amm/index.js +2 -3
- package/dist/amm/index.js.map +1 -1
- package/dist/bootstrap-addresses/index.cjs +58 -20
- package/dist/bootstrap-addresses/index.cjs.map +1 -1
- package/dist/bootstrap-addresses/index.d.cts +38 -19
- package/dist/bootstrap-addresses/index.d.ts +38 -19
- package/dist/bootstrap-addresses/index.js +2 -3
- package/dist/{chunk-6IC6CO5S.js → chunk-2NNQJFKS.js} +5 -4
- package/dist/chunk-2NNQJFKS.js.map +1 -0
- package/dist/chunk-4F54VFIH.js +58 -0
- package/dist/chunk-4F54VFIH.js.map +1 -0
- package/dist/{chunk-BNYDH4ZP.js → chunk-A2BWZE2D.js} +12 -10
- package/dist/chunk-A2BWZE2D.js.map +1 -0
- package/dist/{chunk-7DRJVAYI.js → chunk-A44ZPXY6.js} +5 -58
- package/dist/chunk-A44ZPXY6.js.map +1 -0
- package/dist/{chunk-YX7BLFQZ.js → chunk-JHINXDSG.js} +44 -5
- package/dist/chunk-JHINXDSG.js.map +1 -0
- package/dist/chunk-QGOAPK5X.js +174 -0
- package/dist/chunk-QGOAPK5X.js.map +1 -0
- package/dist/chunk-S3UTJHRO.js +77 -0
- package/dist/chunk-S3UTJHRO.js.map +1 -0
- package/dist/{chunk-CYG4PB65.js → chunk-ZOFTRAAH.js} +4 -4
- package/dist/{chunk-CYG4PB65.js.map → chunk-ZOFTRAAH.js.map} +1 -1
- package/dist/{chunk-ZHF2PH5H.js → chunk-ZP7A3GHV.js} +3 -4
- package/dist/chunk-ZP7A3GHV.js.map +1 -0
- package/dist/clob/index.cjs +380 -322
- package/dist/clob/index.cjs.map +1 -1
- package/dist/clob/index.d.cts +4 -3
- package/dist/clob/index.d.ts +4 -3
- package/dist/clob/index.js +36 -198
- package/dist/clob/index.js.map +1 -1
- package/dist/deploy/index.cjs +241 -169
- package/dist/deploy/index.cjs.map +1 -1
- package/dist/deploy/index.d.cts +5 -0
- package/dist/deploy/index.d.ts +5 -0
- package/dist/deploy/index.js +66 -37
- package/dist/deploy/index.js.map +1 -1
- package/dist/manager/index.cjs +15 -2
- package/dist/manager/index.cjs.map +1 -1
- package/dist/manager/index.d.cts +6 -79
- package/dist/manager/index.d.ts +6 -79
- package/dist/manager/index.js +2 -3
- package/dist/multicall/index.cjs +57 -23
- package/dist/multicall/index.cjs.map +1 -1
- package/dist/multicall/index.js +3 -4
- package/dist/oracle/index.cjs +64 -30
- package/dist/oracle/index.cjs.map +1 -1
- package/dist/oracle/index.d.cts +3 -39
- package/dist/oracle/index.d.ts +3 -39
- package/dist/oracle/index.js +2 -3
- package/dist/oracle/index.js.map +1 -1
- package/dist/orderbook-CEYM4N_S.d.cts +5 -0
- package/dist/orderbook-CEYM4N_S.d.ts +5 -0
- package/dist/passkey-manager/index.cjs +52 -18
- package/dist/passkey-manager/index.cjs.map +1 -1
- package/dist/passkey-manager/index.js +2 -3
- package/dist/passkey-manager/index.js.map +1 -1
- package/dist/perp/index.cjs +16750 -0
- package/dist/perp/index.cjs.map +1 -0
- package/dist/perp/index.d.cts +4577 -0
- package/dist/perp/index.d.ts +4577 -0
- package/dist/perp/index.js +16244 -0
- package/dist/perp/index.js.map +1 -0
- package/dist/token/index.js +2 -1
- package/dist/types-5XmDprcB.d.ts +81 -0
- package/dist/types-Cpi7Ibs2.d.cts +81 -0
- package/dist/types-T4cL02K7.d.cts +39 -0
- package/dist/types-T4cL02K7.d.ts +39 -0
- package/dist/uploader/index.cjs +46 -8
- package/dist/uploader/index.cjs.map +1 -1
- package/dist/uploader/index.d.cts +2 -1
- package/dist/uploader/index.d.ts +2 -1
- package/dist/uploader/index.js +2 -2
- package/package.json +7 -2
- package/src/abi-manager/constants.ts +2 -1
- package/src/abi-manager/index.test.ts +2 -2
- package/src/bootstrap-addresses/index.test.ts +70 -18
- package/src/bootstrap-addresses/index.ts +56 -19
- package/src/clob/index.ts +67 -201
- package/src/deploy/accounts.ts +7 -3
- package/src/deploy/chain.ts +1 -1
- package/src/deploy/constants.ts +3 -4
- package/src/deploy/deploy.test.ts +11 -10
- package/src/deploy/inspection.ts +3 -2
- package/src/deploy/types.ts +5 -0
- package/src/deploy/uploader.ts +5 -4
- package/src/deploy/workflows.test.ts +74 -5
- package/src/deploy/workflows.ts +55 -17
- package/src/manager/constants.ts +14 -2
- package/src/manager/derivation.ts +3 -3
- package/src/manager/index.test.ts +3 -3
- package/src/manager/index.ts +3 -0
- package/src/manager/types.ts +1 -1
- package/src/multicall/index.test.ts +1 -1
- package/src/passkey-manager/validate.test.ts +1 -1
- package/src/perp/abi/thru/common/primitives/types.ts +2428 -0
- package/src/perp/abi/thru/program/perp/types.ts +16813 -0
- package/src/perp/index.test.ts +822 -0
- package/src/perp/index.ts +1793 -0
- package/src/uploader/constants.ts +5 -4
- package/src/uploader/index.test.ts +2 -2
- package/src/uploader/index.ts +1 -0
- package/src/utils/helpers.ts +1 -1
- package/src/utils/orderbook.test.ts +86 -0
- package/src/utils/orderbook.ts +214 -0
- package/tsup.config.ts +1 -0
- package/dist/chunk-6IC6CO5S.js.map +0 -1
- package/dist/chunk-7DHFYBRW.js +0 -51
- package/dist/chunk-7DHFYBRW.js.map +0 -1
- package/dist/chunk-7DRJVAYI.js.map +0 -1
- package/dist/chunk-BNYDH4ZP.js.map +0 -1
- package/dist/chunk-VNTPD4AR.js +0 -37
- package/dist/chunk-VNTPD4AR.js.map +0 -1
- package/dist/chunk-YX7BLFQZ.js.map +0 -1
- package/dist/chunk-ZHF2PH5H.js.map +0 -1
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ZERO_PUBKEY, TICKER_MAX_LENGTH } from './chunk-4F54VFIH.js';
|
|
2
2
|
import { encodeAddress } from '@thru/sdk/helpers';
|
|
3
3
|
|
|
4
|
-
// src/token/constants.ts
|
|
5
|
-
var PUBKEY_LENGTH = 32;
|
|
6
|
-
var TICKER_MAX_LENGTH = 8;
|
|
7
|
-
var ZERO_PUBKEY = new Uint8Array(PUBKEY_LENGTH);
|
|
8
|
-
|
|
9
4
|
// src/token/abi/thru/common/primitives/types.ts
|
|
10
5
|
var __tnWarnings = /* @__PURE__ */ new Set();
|
|
11
6
|
var __tnHasNativeBigInt = typeof BigInt === "function";
|
|
@@ -8459,54 +8454,6 @@ function createTransferInstruction(args) {
|
|
|
8459
8454
|
return buildTokenInstructionBytes("transfer", payload);
|
|
8460
8455
|
};
|
|
8461
8456
|
}
|
|
8462
|
-
var TOKEN_ACCOUNT_DEFAULT_SEED = new Uint8Array(PUBKEY_LENGTH);
|
|
8463
|
-
function deriveMintAddress(thru, mintAuthorityAddress, seed, tokenProgramAddress) {
|
|
8464
|
-
const mintAuthorityBytes = Pubkey$1.from(mintAuthorityAddress).toBytes();
|
|
8465
|
-
const seedBytes = hexToBytes2(seed);
|
|
8466
|
-
if (seedBytes.length !== 32) throw new Error("Seed must be 32 bytes (64 hex characters)");
|
|
8467
|
-
const { bytes: derivedSeed } = thru.helpers.deriveAddress([mintAuthorityBytes, seedBytes]);
|
|
8468
|
-
const result = thru.helpers.deriveProgramAddress({
|
|
8469
|
-
programAddress: tokenProgramAddress,
|
|
8470
|
-
seed: derivedSeed,
|
|
8471
|
-
ephemeral: false
|
|
8472
|
-
});
|
|
8473
|
-
return {
|
|
8474
|
-
address: result.address,
|
|
8475
|
-
bytes: result.bytes,
|
|
8476
|
-
derivedSeed
|
|
8477
|
-
};
|
|
8478
|
-
}
|
|
8479
|
-
function deriveTokenAccountAddress(thru, ownerAddress, mintAddress, tokenProgramAddress, seed = TOKEN_ACCOUNT_DEFAULT_SEED) {
|
|
8480
|
-
if (seed.length !== PUBKEY_LENGTH) throw new Error("Token account seed must be 32 bytes");
|
|
8481
|
-
const ownerBytes = Pubkey$1.from(ownerAddress).toBytes();
|
|
8482
|
-
const mintBytes = Pubkey$1.from(mintAddress).toBytes();
|
|
8483
|
-
const { bytes: derivedSeed } = thru.helpers.deriveAddress([ownerBytes, mintBytes, seed]);
|
|
8484
|
-
const result = thru.helpers.deriveProgramAddress({
|
|
8485
|
-
programAddress: tokenProgramAddress,
|
|
8486
|
-
seed: derivedSeed,
|
|
8487
|
-
ephemeral: false
|
|
8488
|
-
});
|
|
8489
|
-
return {
|
|
8490
|
-
address: result.address,
|
|
8491
|
-
bytes: result.bytes,
|
|
8492
|
-
derivedSeed
|
|
8493
|
-
};
|
|
8494
|
-
}
|
|
8495
|
-
function deriveWalletSeed(thru, walletAddress, extraSeeds = []) {
|
|
8496
|
-
const walletBytes = Pubkey$1.from(walletAddress).toBytes();
|
|
8497
|
-
return thru.helpers.deriveAddress([walletBytes, ...extraSeeds]).bytes;
|
|
8498
|
-
}
|
|
8499
|
-
function hexToBytes2(hex) {
|
|
8500
|
-
const normalized = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
8501
|
-
if (normalized.length % 2 !== 0) {
|
|
8502
|
-
throw new Error("Hex string must have even number of characters");
|
|
8503
|
-
}
|
|
8504
|
-
const bytes = new Uint8Array(normalized.length / 2);
|
|
8505
|
-
for (let i = 0; i < normalized.length; i += 2) {
|
|
8506
|
-
bytes[i / 2] = parseInt(normalized.substring(i, i + 2), 16);
|
|
8507
|
-
}
|
|
8508
|
-
return bytes;
|
|
8509
|
-
}
|
|
8510
8457
|
var TEXT_DECODER = new TextDecoder();
|
|
8511
8458
|
function parseMintAccountData(account) {
|
|
8512
8459
|
const data = account.data?.data;
|
|
@@ -8570,7 +8517,7 @@ function formatRawAmount(amount, decimals) {
|
|
|
8570
8517
|
function bytesToHex(bytes) {
|
|
8571
8518
|
return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
8572
8519
|
}
|
|
8573
|
-
function
|
|
8520
|
+
function hexToBytes2(hex) {
|
|
8574
8521
|
const normalized = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
8575
8522
|
if (normalized.length % 2 !== 0) {
|
|
8576
8523
|
throw new Error("Hex string must have even number of characters");
|
|
@@ -8582,6 +8529,6 @@ function hexToBytes3(hex) {
|
|
|
8582
8529
|
return bytes;
|
|
8583
8530
|
}
|
|
8584
8531
|
|
|
8585
|
-
export { InitializeAccountInstructionBuilder, InitializeMintInstructionBuilder, MintToInstructionBuilder,
|
|
8586
|
-
//# sourceMappingURL=chunk-
|
|
8587
|
-
//# sourceMappingURL=chunk-
|
|
8532
|
+
export { InitializeAccountInstructionBuilder, InitializeMintInstructionBuilder, MintToInstructionBuilder, Pubkey, TickerField, TickerFieldBuilder, TokenAccount, TokenMintAccount, TransferInstruction, TransferInstructionBuilder, buildTokenInstructionBytes, bytesToHex, createInitializeAccountInstruction, createInitializeMintInstruction, createMintToInstruction, createTransferInstruction, formatRawAmount, hexToBytes2 as hexToBytes, isAccountNotFoundError, parseMintAccountData, parseTokenAccountData };
|
|
8533
|
+
//# sourceMappingURL=chunk-A44ZPXY6.js.map
|
|
8534
|
+
//# sourceMappingURL=chunk-A44ZPXY6.js.map
|