@whetstone-research/doppler-sdk 1.0.23 → 1.0.25
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/solana/index.cjs +136 -2
- package/dist/solana/index.cjs.map +1 -1
- package/dist/solana/index.d.cts +50 -2
- package/dist/solana/index.d.ts +50 -2
- package/dist/solana/index.js +136 -2
- package/dist/solana/index.js.map +1 -1
- package/package.json +1 -1
package/dist/solana/index.cjs
CHANGED
|
@@ -748,6 +748,12 @@ chunkQ7SFCCGT_cjs.__export(cosignerHook_exports, {
|
|
|
748
748
|
COSIGNER_HOOK_PROGRAM_ID: () => COSIGNER_HOOK_PROGRAM_ID,
|
|
749
749
|
CosignerHookAccount: () => CosignerHookAccount,
|
|
750
750
|
CosignerHookInstruction: () => CosignerHookInstruction,
|
|
751
|
+
GATE_EXPIRY_DISABLED: () => GATE_EXPIRY_DISABLED,
|
|
752
|
+
GATE_EXPIRY_HEADER_LEN: () => GATE_EXPIRY_HEADER_LEN,
|
|
753
|
+
GATE_EXPIRY_PAYLOAD_LEN: () => GATE_EXPIRY_PAYLOAD_LEN,
|
|
754
|
+
GATE_EXPIRY_PAYLOAD_VERSION: () => GATE_EXPIRY_PAYLOAD_VERSION,
|
|
755
|
+
GATE_EXPIRY_SLOT: () => GATE_EXPIRY_SLOT,
|
|
756
|
+
GATE_EXPIRY_UNIX_TIMESTAMP: () => GATE_EXPIRY_UNIX_TIMESTAMP,
|
|
751
757
|
INITIALIZE_CONFIG_DISCRIMINATOR: () => INITIALIZE_CONFIG_DISCRIMINATOR2,
|
|
752
758
|
MAX_COSIGNERS: () => MAX_COSIGNERS,
|
|
753
759
|
REMOVE_COSIGNER_DISCRIMINATOR: () => REMOVE_COSIGNER_DISCRIMINATOR,
|
|
@@ -755,6 +761,8 @@ chunkQ7SFCCGT_cjs.__export(cosignerHook_exports, {
|
|
|
755
761
|
SET_AUTHORITY_DISCRIMINATOR: () => SET_AUTHORITY_DISCRIMINATOR,
|
|
756
762
|
cosignerHookProgram: () => cosignerHookProgram,
|
|
757
763
|
decodeCosignerConfig: () => decodeCosignerConfig,
|
|
764
|
+
decodeCosignerGateExpiryPayload: () => decodeCosignerGateExpiryPayload,
|
|
765
|
+
encodeCosignerGateExpiryPayload: () => encodeCosignerGateExpiryPayload,
|
|
758
766
|
fetchAllCosignerConfig: () => fetchAllCosignerConfig,
|
|
759
767
|
fetchAllMaybeCosignerConfig: () => fetchAllMaybeCosignerConfig,
|
|
760
768
|
fetchCosignerConfig: () => fetchCosignerConfig,
|
|
@@ -773,6 +781,7 @@ chunkQ7SFCCGT_cjs.__export(cosignerHook_exports, {
|
|
|
773
781
|
getCosignerConfigDiscriminatorBytes: () => getCosignerConfigDiscriminatorBytes,
|
|
774
782
|
getCosignerConfigEncoder: () => getCosignerConfigEncoder,
|
|
775
783
|
getCosignerConfigSize: () => getCosignerConfigSize,
|
|
784
|
+
getCosignerGateStatus: () => getCosignerGateStatus,
|
|
776
785
|
getCosignerHookConfigAddress: () => getCosignerHookConfigAddress,
|
|
777
786
|
getCosignerHookErrorMessage: () => getCosignerHookErrorMessage,
|
|
778
787
|
getInitializeConfigArgsCodec: () => getInitializeConfigArgsCodec,
|
|
@@ -801,6 +810,7 @@ chunkQ7SFCCGT_cjs.__export(cosignerHook_exports, {
|
|
|
801
810
|
getSetAuthorityInstructionDataEncoder: () => getSetAuthorityInstructionDataEncoder,
|
|
802
811
|
identifyCosignerHookAccount: () => identifyCosignerHookAccount,
|
|
803
812
|
identifyCosignerHookInstruction: () => identifyCosignerHookInstruction,
|
|
813
|
+
isCosignerGateEnforced: () => isCosignerGateEnforced,
|
|
804
814
|
isCosignerHookError: () => isCosignerHookError,
|
|
805
815
|
parseAddCosignerInstruction: () => parseAddCosignerInstruction,
|
|
806
816
|
parseCosignerHookInstruction: () => parseCosignerHookInstruction,
|
|
@@ -1649,6 +1659,132 @@ function getSetAuthorityArgsCodec() {
|
|
|
1649
1659
|
var COSIGNER_HOOK_PROGRAM_ID = COSIGNER_HOOK_PROGRAM_ADDRESS;
|
|
1650
1660
|
var SEED_COSIGNER_HOOK_CONFIG = "cosigner_hook_config";
|
|
1651
1661
|
var MAX_COSIGNERS = 32;
|
|
1662
|
+
var GATE_EXPIRY_DISABLED = 0;
|
|
1663
|
+
var GATE_EXPIRY_UNIX_TIMESTAMP = 1;
|
|
1664
|
+
var GATE_EXPIRY_SLOT = 2;
|
|
1665
|
+
var GATE_EXPIRY_PAYLOAD_VERSION = 1;
|
|
1666
|
+
var GATE_EXPIRY_HEADER_LEN = 10;
|
|
1667
|
+
var GATE_EXPIRY_PAYLOAD_LEN = 42;
|
|
1668
|
+
var MAX_U64 = (1n << 64n) - 1n;
|
|
1669
|
+
function toBigInt(value) {
|
|
1670
|
+
return typeof value === "bigint" ? value : BigInt(value);
|
|
1671
|
+
}
|
|
1672
|
+
function isValidExpiryMode(mode) {
|
|
1673
|
+
return mode === GATE_EXPIRY_UNIX_TIMESTAMP || mode === GATE_EXPIRY_SLOT;
|
|
1674
|
+
}
|
|
1675
|
+
function readU64Le(bytes, offset) {
|
|
1676
|
+
let value = 0n;
|
|
1677
|
+
for (let i = 0; i < 8; i++) {
|
|
1678
|
+
value |= BigInt(bytes[offset + i] ?? 0) << BigInt(i * 8);
|
|
1679
|
+
}
|
|
1680
|
+
return value;
|
|
1681
|
+
}
|
|
1682
|
+
function writeU64Le(bytes, offset, value) {
|
|
1683
|
+
for (let i = 0; i < 8; i++) {
|
|
1684
|
+
bytes[offset + i] = Number(value >> BigInt(i * 8) & 0xffn);
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
function encodeCosignerGateExpiryPayload(expiry) {
|
|
1688
|
+
if (expiry.mode === GATE_EXPIRY_DISABLED) {
|
|
1689
|
+
if (expiry.cosigner !== void 0) {
|
|
1690
|
+
throw new Error("Cosigner hint cannot be encoded for disabled gates");
|
|
1691
|
+
}
|
|
1692
|
+
return new Uint8Array();
|
|
1693
|
+
}
|
|
1694
|
+
if (!isValidExpiryMode(expiry.mode)) {
|
|
1695
|
+
throw new Error(`Invalid cosigner gate expiry mode: ${expiry.mode}`);
|
|
1696
|
+
}
|
|
1697
|
+
const value = toBigInt(expiry.value);
|
|
1698
|
+
if (value < 0n || value > MAX_U64) {
|
|
1699
|
+
throw new Error(`Invalid cosigner gate expiry value: ${expiry.value}`);
|
|
1700
|
+
}
|
|
1701
|
+
if (expiry.cosigner === void 0) {
|
|
1702
|
+
throw new Error("Cosigner hint is required for expiring gates");
|
|
1703
|
+
}
|
|
1704
|
+
const payload = new Uint8Array(GATE_EXPIRY_PAYLOAD_LEN);
|
|
1705
|
+
payload[0] = GATE_EXPIRY_PAYLOAD_VERSION;
|
|
1706
|
+
payload[1] = expiry.mode;
|
|
1707
|
+
writeU64Le(payload, 2, value);
|
|
1708
|
+
payload.set(
|
|
1709
|
+
kit.getAddressEncoder().encode(expiry.cosigner),
|
|
1710
|
+
GATE_EXPIRY_HEADER_LEN
|
|
1711
|
+
);
|
|
1712
|
+
return payload;
|
|
1713
|
+
}
|
|
1714
|
+
function decodeCosignerGateExpiryPayload(payload) {
|
|
1715
|
+
if (!payload || payload.length === 0) {
|
|
1716
|
+
return { mode: GATE_EXPIRY_DISABLED, value: 0n };
|
|
1717
|
+
}
|
|
1718
|
+
if (payload.length !== GATE_EXPIRY_PAYLOAD_LEN || payload[0] !== GATE_EXPIRY_PAYLOAD_VERSION) {
|
|
1719
|
+
return null;
|
|
1720
|
+
}
|
|
1721
|
+
const mode = payload[1] ?? GATE_EXPIRY_DISABLED;
|
|
1722
|
+
if (!isValidExpiryMode(mode)) {
|
|
1723
|
+
return null;
|
|
1724
|
+
}
|
|
1725
|
+
return {
|
|
1726
|
+
mode,
|
|
1727
|
+
value: readU64Le(payload, 2),
|
|
1728
|
+
cosigner: kit.getAddressDecoder().decode(
|
|
1729
|
+
payload.slice(GATE_EXPIRY_HEADER_LEN, GATE_EXPIRY_PAYLOAD_LEN)
|
|
1730
|
+
)
|
|
1731
|
+
};
|
|
1732
|
+
}
|
|
1733
|
+
function getCosignerGateStatus(hookPayload, clock = {}) {
|
|
1734
|
+
const expiry = decodeCosignerGateExpiryPayload(hookPayload);
|
|
1735
|
+
if (!expiry) {
|
|
1736
|
+
return {
|
|
1737
|
+
gateEnforced: true,
|
|
1738
|
+
expiryMode: GATE_EXPIRY_DISABLED,
|
|
1739
|
+
expiryValue: 0n,
|
|
1740
|
+
reason: "invalid_expiry_payload"
|
|
1741
|
+
};
|
|
1742
|
+
}
|
|
1743
|
+
if (expiry.mode === GATE_EXPIRY_DISABLED) {
|
|
1744
|
+
return {
|
|
1745
|
+
gateEnforced: true,
|
|
1746
|
+
expiryMode: expiry.mode,
|
|
1747
|
+
expiryValue: expiry.value,
|
|
1748
|
+
reason: "expiry_disabled"
|
|
1749
|
+
};
|
|
1750
|
+
}
|
|
1751
|
+
if (expiry.mode === GATE_EXPIRY_UNIX_TIMESTAMP) {
|
|
1752
|
+
const unixTimestamp = clock.unixTimestamp === void 0 ? BigInt(Math.floor(Date.now() / 1e3)) : toBigInt(clock.unixTimestamp);
|
|
1753
|
+
const expired = unixTimestamp >= expiry.value;
|
|
1754
|
+
return {
|
|
1755
|
+
gateEnforced: !expired,
|
|
1756
|
+
expiryMode: expiry.mode,
|
|
1757
|
+
expiryValue: expiry.value,
|
|
1758
|
+
reason: expired ? "timestamp_expired" : "timestamp_pending"
|
|
1759
|
+
};
|
|
1760
|
+
}
|
|
1761
|
+
if (expiry.mode === GATE_EXPIRY_SLOT) {
|
|
1762
|
+
if (clock.slot === void 0) {
|
|
1763
|
+
return {
|
|
1764
|
+
gateEnforced: true,
|
|
1765
|
+
expiryMode: expiry.mode,
|
|
1766
|
+
expiryValue: expiry.value,
|
|
1767
|
+
reason: "slot_unavailable"
|
|
1768
|
+
};
|
|
1769
|
+
}
|
|
1770
|
+
const expired = toBigInt(clock.slot) >= expiry.value;
|
|
1771
|
+
return {
|
|
1772
|
+
gateEnforced: !expired,
|
|
1773
|
+
expiryMode: expiry.mode,
|
|
1774
|
+
expiryValue: expiry.value,
|
|
1775
|
+
reason: expired ? "slot_expired" : "slot_pending"
|
|
1776
|
+
};
|
|
1777
|
+
}
|
|
1778
|
+
return {
|
|
1779
|
+
gateEnforced: true,
|
|
1780
|
+
expiryMode: expiry.mode,
|
|
1781
|
+
expiryValue: expiry.value,
|
|
1782
|
+
reason: "invalid_expiry_mode"
|
|
1783
|
+
};
|
|
1784
|
+
}
|
|
1785
|
+
function isCosignerGateEnforced(hookPayload, clock = {}) {
|
|
1786
|
+
return getCosignerGateStatus(hookPayload, clock).gateEnforced;
|
|
1787
|
+
}
|
|
1652
1788
|
var textEncoder2 = new TextEncoder();
|
|
1653
1789
|
async function getCosignerHookConfigAddress(programId = COSIGNER_HOOK_PROGRAM_ID) {
|
|
1654
1790
|
return kit.getProgramDerivedAddress({
|
|
@@ -5284,7 +5420,6 @@ function createRemainingAccountMeta(value) {
|
|
|
5284
5420
|
}
|
|
5285
5421
|
function createCurveSwapExactInInstruction(accounts, args, programId = INITIALIZER_PROGRAM_ID) {
|
|
5286
5422
|
const {
|
|
5287
|
-
config,
|
|
5288
5423
|
launch,
|
|
5289
5424
|
launchAuthority,
|
|
5290
5425
|
baseVault,
|
|
@@ -5301,7 +5436,6 @@ function createCurveSwapExactInInstruction(accounts, args, programId = INITIALIZ
|
|
|
5301
5436
|
remainingAccounts = []
|
|
5302
5437
|
} = accounts;
|
|
5303
5438
|
const keys = [
|
|
5304
|
-
{ address: config, role: kit.AccountRole.READONLY },
|
|
5305
5439
|
{ address: launch, role: kit.AccountRole.WRITABLE },
|
|
5306
5440
|
{ address: launchAuthority, role: kit.AccountRole.READONLY },
|
|
5307
5441
|
{ address: baseVault, role: kit.AccountRole.WRITABLE },
|