Skip to content
Draft
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: 2 additions & 0 deletions Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ mobile_entity_manager = "memMa1HG4odAFmUbGWfPwS1WWfK95k99F2YTkGvyxZr"
hexboosting = "hexbnKYoA2GercNNhHUCCfrTRWrHjT6ujKPXTa5NPqJ"
no_emit = "noEmmgLmQdk6DLiPV8CSwQv3qQDyGEhz9m5A4zhtByv"
hpl_crons = "hcrLPFgFUY6sCUKzqLWxXx5bntDiDCrAZVcrXfx9AHu"
sessions = "sesD2P1SxjDDo6Z9wGrymwmkx3Z1EZdyL9H5tk7iaNg"

[workspace]
members = [
Expand All @@ -36,6 +37,7 @@ members = [
"programs/hexboosting",
"programs/no-emit",
"programs/hpl-crons",
"programs/sessions",
]

[registry]
Expand Down
14 changes: 14 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ bubblegum-cpi = { rev = "1584d8e", git = "https://github.com/helium/account-comp
solana-security-txt = "1.1.1"
default-env = { path = "./utils/default-env" }
shared-utils = { path = "./utils/shared-utils" }
sessions = { path = "./programs/sessions", features = ["cpi", "no-entrypoint"] }
circuit-breaker = { path = "./programs/circuit-breaker", features = ["cpi", "no-entrypoint"] }
helium-sub-daos = { path = "./programs/helium-sub-daos", features = ["cpi", "no-entrypoint"] }
helium-entity-manager = { path = "./programs/helium-entity-manager", features = ["cpi", "no-entrypoint"] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export async function updateIotMetadata({
gain,
dcFeePayer,
payer,
session,
dao = HELIUM_DAO,
...rest
}: {
Expand All @@ -28,6 +29,7 @@ export async function updateIotMetadata({
gain: number | null;
assetId: PublicKey;
rewardableEntityConfig: PublicKey;
session?: PublicKey;
dao?: PublicKey
} & Omit<ProofArgsAndAccountsArgs, "connection">) {
const {
Expand Down Expand Up @@ -60,6 +62,7 @@ export async function updateIotMetadata({
.accountsPartial({
// hotspot: assetId,
...accounts,
session,
dcFeePayer,
payer,
rewardableEntityConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export async function updateMobileMetadata({
payer,
dao = HELIUM_DAO,
deploymentInfo,
session,
...rest
}: {
program: Program<HeliumEntityManager>;
Expand All @@ -28,6 +29,7 @@ export async function updateMobileMetadata({
rewardableEntityConfig: PublicKey;
deploymentInfo?: MobileDeploymentInfoV0 | null;
dao?: PublicKey;
session?: PublicKey;
} & Omit<ProofArgsAndAccountsArgs, "connection">) {
const { asset, args, accounts, remainingAccounts } =
await proofArgsAndAccounts({
Expand Down Expand Up @@ -57,6 +59,7 @@ export async function updateMobileMetadata({
// hotspot: assetId,
...accounts,
dcFeePayer,
session,
payer,
rewardableEntityConfig,
hotspotOwner: owner,
Expand Down
50 changes: 50 additions & 0 deletions packages/sessions-sdk/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "@helium/sessions-sdk",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"license": "Apache-2.0",
"version": "0.0.1",
"description": "Interface to the sessions smart contract",
"repository": {
"type": "git",
"url": "https://github.com/helium/helium-program-libary"
},
"main": "./lib/cjs/index.js",
"module": "./lib/esm/src/index.js",
"types": "./lib/types/src/index.d.ts",
"sideEffects": false,
"files": [
"lib"
],
"exports": {
"import": "./lib/esm/src/index.js",
"require": "./lib/cjs/index.js",
"types": "./lib/types/src/index.d.ts"
},
"scripts": {
"format": "prettier --write \"src/**/*.{ts,tsx}\"",
"precommit": "npx git-format-staged -f 'prettier --ignore-unknown --stdin --stdin-filepath \"{}\"' .",
"clean": "npx shx mkdir -p lib && npx shx rm -rf lib",
"package": "npx shx mkdir -p lib/cjs lib/esm",
"prebuild": "npm run clean && npm run package"
},
"dependencies": {
"@coral-xyz/anchor": "^0.31.0",
"@helium/anchor-resolvers": "^0.10.12",
"@helium/idls": "^0.10.12",
"@helium/spl-utils": "^0.10.12",
"@helium/tuktuk-sdk": "^0.0.8",
"@solana/web3.js": "^1.91.1",
"bs58": "^4.0.1"
},
"devDependencies": {
"git-format-staged": "^2.1.3",
"ts-loader": "^9.2.3",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
},
"keywords": [],
"author": ""
}
5 changes: 5 additions & 0 deletions packages/sessions-sdk/src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { PublicKey } from "@solana/web3.js";

export const PROGRAM_ID = new PublicKey(
"sesD2P1SxjDDo6Z9wGrymwmkx3Z1EZdyL9H5tk7iaNg"
);
30 changes: 30 additions & 0 deletions packages/sessions-sdk/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { AnchorProvider, Idl, Program } from "@coral-xyz/anchor";
import { heliumCommonResolver } from "@helium/anchor-resolvers";
import { Sessions } from "@helium/idls/lib/types/sessions";
import { fetchBackwardsCompatibleIdl } from "@helium/spl-utils";
import { PublicKey } from "@solana/web3.js";
import { PROGRAM_ID } from "./constants";

export * from "./constants";
export * from "./pdas";

export async function init(
provider: AnchorProvider,
programId: PublicKey = PROGRAM_ID,
idl?: Idl | null
): Promise<Program<Sessions>> {
if (!idl) {
idl = await fetchBackwardsCompatibleIdl(programId, provider);
}

const program = new Program<Sessions>(
idl as Sessions,
provider,
undefined,
() => {
return heliumCommonResolver;
}
) as Program<Sessions>;

return program;
}
31 changes: 31 additions & 0 deletions packages/sessions-sdk/src/pdas.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { PublicKey } from "@solana/web3.js";
import { PROGRAM_ID } from "./constants";

export function sessionManagerKey(
programId = PROGRAM_ID
): [PublicKey, number] {
return PublicKey.findProgramAddressSync(
[Buffer.from("session_manager")],
programId
);
}

export function sessionKey(
application: string,
wallet: PublicKey,
programId = PROGRAM_ID
): [PublicKey, number] {
return PublicKey.findProgramAddressSync(
[Buffer.from("session"), Buffer.from(application, "utf-8"), wallet.toBuffer()],
programId
);
}

export function queueAuthorityKey(
programId = PROGRAM_ID
): [PublicKey, number] {
return PublicKey.findProgramAddressSync(
[Buffer.from("queue_authority")],
programId
);
}
7 changes: 7 additions & 0 deletions packages/sessions-sdk/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.cjs.json",
"include": ["src"],
"compilerOptions": {
"outDir": "lib/cjs"
}
}
8 changes: 8 additions & 0 deletions packages/sessions-sdk/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../../tsconfig.esm.json",
"include": ["src"],
"compilerOptions": {
"outDir": "lib/esm",
"declarationDir": "lib/types"
}
}
20 changes: 20 additions & 0 deletions packages/sessions-sdk/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"extends": "../../tsconfig.root.json",
"references": [
{
"path": "../idls"
},
{
"path": "../spl-utils"
},
{
"path": "../anchor-resolvers"
},
{
"path": "./tsconfig.cjs.json"
},
{
"path": "./tsconfig.esm.json"
}
]
}
Loading