Skip to content
Merged

Develop #1061

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/develop-release-program.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Deploy Programs to devnet

env:
SOLANA_CLI_VERSION: 2.1.6
NODE_VERSION: 18.12.1
NODE_VERSION: 22.19.0

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Deploy to ECR

env:
SOLANA_CLI_VERSION: 2.1.6
NODE_VERSION: 18.12.1
NODE_VERSION: 22.19.0

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/manual-devnet-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Manual Devnet Program Deploy

env:
SOLANA_CLI_VERSION: 2.1.6
NODE_VERSION: 18.12.1
NODE_VERSION: 22.19.0

on:
workflow_dispatch:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/npm-canary-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:

env:
SOLANA_CLI_VERSION: 2.1.6
NODE_VERSION: 18.12.1
NODE_VERSION: 22.19.0

permissions:
contents: read # for checkout
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/npm-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: NPM Publish

env:
SOLANA_CLI_VERSION: 2.1.6
NODE_VERSION: 18.12.1
NODE_VERSION: 22.19.0

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-program.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Release Program to Mainnet

env:
SOLANA_CLI_VERSION: 2.1.6
NODE_VERSION: 18.12.1
NODE_VERSION: 22.19.0

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
- develop
env:
SOLANA_CLI_VERSION: 2.1.6
NODE_VERSION: 18.12.1
NODE_VERSION: 22.19.0

jobs:
test-rust-lint:
Expand Down
16 changes: 13 additions & 3 deletions Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ address = "BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY" # bubblegum
[[test.validator.clone]]
address = "noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV" # noop

[[test.validator.clone]]
address = "4DdmDswskDxXGpwHrXUfn2CNUm9rt21ac79GHNTN3J33" # hnt feed needed for dc auto top

[[test.validator.clone]]
address = "cmtDvXumGCrqC1Age74AVPhSRVXJMd8PJS91L8KbNCK" # account compression

Expand Down Expand Up @@ -114,12 +117,19 @@ address = "stcfiqW3fwD9QCd8Bqr1NBLrs7dftZHBQe7RiMMA4aM" # State controller progr
[[test.validator.clone]]
address = "GPQNABq6s63uqzHRwZN9e2GcxtzG4yLP5AnJer7DkB9E" # State controller IDL

# Pyth price oracle program
[[test.validator.clone]]
address = "rec5EKMGg6MxZYaMdyBfgwp4d5rB9T1VQH5pJv5LtFJ"

# Wormhole
[[test.validator.clone]]
address = "HDwcJBJXjL9FpJ7UBsYBtaDjsBUhuLCUYoz3zr8SWWaQ"

[[test.validator.clone]]
address = "DQ4C1tzvu28cwo1roN1Wm6TW35sfJEjLh517k3ZeWevx" # Mobile price oracle
address = "5gxPdahvSzcKySxXxPuRXZZ9s6h8hZ88XDVKavWpaQGn"

# Pyth price oracle
[[test.validator.clone]]
address = "4DdmDswskDxXGpwHrXUfn2CNUm9rt21ac79GHNTN3J33"
address = "DaWUKXCyXsnzcvLUyeJRWou8KTn7XtadgTsdhJ6RHS7b"

# Squads multisig program
[[test.validator.clone]]
Expand Down
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions migration-docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Specify the base image
FROM node:18-alpine AS BUILD_IMAGE
FROM node:22-alpine AS BUILD_IMAGE

WORKDIR /app

Expand All @@ -17,7 +17,7 @@ RUN lerna bootstrap

RUN yarn run build

FROM node:18-alpine
FROM node:22-alpine

WORKDIR /app

Expand Down
4 changes: 2 additions & 2 deletions packages/account-postgres-sink-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18-alpine AS BUILD_IMAGE
FROM node:22-alpine AS BUILD_IMAGE

WORKDIR /usr/src/app

Expand All @@ -16,7 +16,7 @@ COPY tsconfig.build.json tsconfig.json

RUN yarn run build

FROM node:18-alpine
FROM node:22-alpine

WORKDIR /usr/src/app

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,22 @@ export const ExplodeRecipientDestinationOwnershipPlugin = ((): IPlugin => {
})
}

// Case 2: New destination is a mini fanout
if (newDestination !== PublicKey.default.toBase58()) {
await RewardsRecipient.destroy({
where: {
asset: account.asset,
},
transaction
})

// Case 2: New destination is a mini fanout
const newMiniFanout = await MiniFanout.findByPk(newDestination, { transaction })
if (newMiniFanout) {
await handleMiniFanout(account.asset, newMiniFanout, transaction)
return account
}
}

// Case 3: New destination is a direct recipient (not a mini fanout)
if (newDestination !== PublicKey.default.toBase58()) {

// Case 3: New destination is a direct recipient (not a mini fanout)
const kta = await KeyToAsset.findOne({
where: {
dao: 'BQ3MCuTT5zVBhNfQ4SjMh3NPVhFy73MPV8rjfq5d1zie',
Expand All @@ -55,7 +60,7 @@ export const ExplodeRecipientDestinationOwnershipPlugin = ((): IPlugin => {
transaction
})

await RewardsRecipient.upsert({
await RewardsRecipient.create({
asset: account.asset,
owner: newDestination,
destination: newDestination,
Expand Down
2 changes: 1 addition & 1 deletion packages/active-device-oracle/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18-alpine
FROM node:22-alpine

WORKDIR /usr/src/app

Expand Down
4 changes: 2 additions & 2 deletions packages/asset-ownership-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18-alpine AS BUILD_IMAGE
FROM node:22-alpine AS BUILD_IMAGE

WORKDIR /usr/src/app

Expand All @@ -16,7 +16,7 @@ COPY tsconfig.build.json tsconfig.json

RUN yarn run build

FROM node:18-alpine
FROM node:22-alpine

WORKDIR /usr/src/app

Expand Down
4 changes: 2 additions & 2 deletions packages/crons/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18-alpine AS BUILD_IMAGE
FROM node:22-alpine AS BUILD_IMAGE

WORKDIR /usr/src/app

Expand All @@ -16,7 +16,7 @@ COPY tsconfig.build.json tsconfig.json

RUN yarn run build

FROM node:18-alpine
FROM node:22-alpine

WORKDIR /usr/src/app

Expand Down
31 changes: 17 additions & 14 deletions packages/crons/src/close-governance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
populateMissingDraftInfo,
sendAndConfirmWithRetry,
toVersionedTx,
truthy,
} from "@helium/spl-utils";
import { init as initState } from "@helium/state-controller-sdk";
import { init as initVsr, positionKey } from "@helium/voter-stake-registry-sdk";
Expand Down Expand Up @@ -158,9 +159,9 @@ async function getSolanaUnixTimestamp(
a.account.index < b.account.index ? 1 : -1
);

return await Promise.all(
return (await Promise.all(
sortedProxies.map(async (proxy, index) => {
if (index === sortedProxies.length - 1) {
if (proxy.account.index === 0) {
return proxyProgram.methods
.closeExpiredProxyV0()
.accountsPartial({
Expand All @@ -169,25 +170,27 @@ async function getSolanaUnixTimestamp(
.instruction();
}

const prevProxyAssignment = new PublicKey(
sortedProxies[index + 1].publicKey
);
if (proxy.account.index !== 0 && sortedProxies[index + 1]) {
const prevProxyAssignment = new PublicKey(
sortedProxies[index + 1].publicKey
);

return proxyProgram.methods
.unassignExpiredProxyV0()
.accountsPartial({
prevProxyAssignment,
proxyAssignment: new PublicKey(proxy.publicKey),
})
.instruction();
return proxyProgram.methods
.unassignExpiredProxyV0()
.accountsPartial({
prevProxyAssignment,
proxyAssignment: new PublicKey(proxy.publicKey),
})
.instruction();
}
})
);
)).filter(truthy);
})
);

const txs = await batchInstructionsToTxsWithPriorityFee(
provider,
multiDimArray.flat()
multiDimArray
);

for (const tx of txs) {
Expand Down
2 changes: 2 additions & 0 deletions packages/currency-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"prebuild": "npm run clean && npm run package"
},
"dependencies": {
"@helium/spl-utils": "^0.10.35",
"@pythnetwork/hermes-client": "^2.0.0",
"@solana/spl-token": "^0.3.8",
"@solana/web3.js": "^1.91.1"
},
Expand Down
79 changes: 52 additions & 27 deletions packages/currency-utils/src/currencyUtils.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import { Connection, PublicKey, Cluster } from "@solana/web3.js";
import { getAssociatedTokenAddressSync, getAccount } from "@solana/spl-token";
import {
PythSolanaReceiver,
IDL as pythSolanaReceiverIdl,
} from "./pyth";
import { AnchorProvider, Program, Wallet } from "@coral-xyz/anchor";

export type { PythSolanaReceiver } from "./pyth";
export { pythSolanaReceiverIdl };
import { getAccount, getAssociatedTokenAddressSync } from "@solana/spl-token";
import { Cluster, Connection, PublicKey } from "@solana/web3.js";
import { HermesClient } from "@pythnetwork/hermes-client";
import { HNT_PRICE_FEED_ID } from "@helium/spl-utils";
import BN from "bn.js";

export const getBalance = async ({
pubKey,
Expand All @@ -28,25 +23,55 @@ export const getBalance = async ({
}
};

export const getOraclePrice = async ({
tokenType,
cluster,
connection,
}: {
tokenType: "HNT";
cluster: Cluster;
connection: Connection;
export const PYTH_HERMES_URL = "https://hermes.pyth.network/"

type PythReturn = {
priceMessage: {
emaPrice: {
feedId: number[]
price: BN
conf: BN
exponent: number
publishTime: BN
prevPublishTime: BN
emaPrice: BN
emaConf: BN
}
}
}

export const getOraclePrice = async ({tokenType}: {
tokenType?: "HNT";
cluster?: Cluster;
connection?: Connection;
}) => {
const pythProgram: Program<PythSolanaReceiver> = new Program(
pythSolanaReceiverIdl as any,
new AnchorProvider(connection, {} as Wallet, {
skipPreflight: true,
})
if (tokenType !== "HNT") {
throw new Error("Only HNT is supported");
}
const priceServiceConnection = new HermesClient(
PYTH_HERMES_URL,
{}
);

const data = await pythProgram.account.priceUpdateV2.fetch(
new PublicKey("4DdmDswskDxXGpwHrXUfn2CNUm9rt21ac79GHNTN3J33")
const priceUpdates = (
await priceServiceConnection.getLatestPriceUpdates(
[HNT_PRICE_FEED_ID],
{ encoding: "base64" }
)
);

return data;
const price = priceUpdates.parsed![0];
return {
priceMessage: {
emaPrice: {
feedId: HNT_PRICE_FEED_ID,
price: price.ema_price.price,
conf: price.ema_price.conf,
exponent: price.ema_price.expo,
publishTime: price.ema_price.publish_time,
prevPublishTime: price.ema_price.prev_publish_time,
emaPrice: price.ema_price.ema_price,
emaConf: price.ema_price.ema_conf,
}
}
}
};
Loading
Loading