Skip to content
Merged
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
346 changes: 173 additions & 173 deletions doc/code-guidelines.md

Large diffs are not rendered by default.

570 changes: 284 additions & 286 deletions doc/rust-code-guidelines.md

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions governance/xc_admin/packages/xc_admin_cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import {
} from "@pythnetwork/pyth-solana-receiver";
import {
SOLANA_LAZER_PROGRAM_ID,
SOLANA_STORAGE_ID,
SOLANA_LAZER_STORAGE_ID,
} from "@pythnetwork/pyth-lazer-sdk";

import { LedgerNodeWallet } from "./ledger";
Expand Down Expand Up @@ -978,7 +978,7 @@ multisigCommand(
.update(trustedSigner, expiryTime)
.accounts({
topAuthority: await vault.getVaultAuthorityPDA(targetCluster),
storage: SOLANA_STORAGE_ID,
storage: new PublicKey(SOLANA_LAZER_STORAGE_ID),
})
.instruction();

Expand Down Expand Up @@ -1010,7 +1010,7 @@ multisigCommand(
const trustedSigner = Buffer.from(options.signer, "hex");
const expiryTime = new BN(options.expiryTime);

const programId = SOLANA_LAZER_PROGRAM_ID;
const programId = new PublicKey(SOLANA_LAZER_PROGRAM_ID);
const programDataAccount = PublicKey.findProgramAddressSync(
[programId.toBuffer()],
BPF_UPGRADABLE_LOADER,
Expand Down Expand Up @@ -1039,7 +1039,7 @@ multisigCommand(
// Create Anchor program instance
const lazerProgram = new Program(
lazerIdl as Idl,
SOLANA_LAZER_PROGRAM_ID,
programId,
vault.getAnchorProvider(),
);

Expand All @@ -1048,7 +1048,7 @@ multisigCommand(
.updateEcdsaSigner(trustedSigner, expiryTime)
.accounts({
topAuthority: await vault.getVaultAuthorityPDA(targetCluster),
storage: SOLANA_STORAGE_ID,
storage: new PublicKey(SOLANA_LAZER_STORAGE_ID),
})
.instruction();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ export class MultisigParser {
return SolanaStakingMultisigInstruction.fromTransactionInstruction(
instruction,
);
} else if (instruction.programId.equals(SOLANA_LAZER_PROGRAM_ID)) {
} else if (
instruction.programId.equals(new PublicKey(SOLANA_LAZER_PROGRAM_ID))
) {
return LazerMultisigInstruction.fromInstruction(instruction);
} else {
return UnrecognizedProgram.fromTransactionInstruction(instruction);
Expand Down
5 changes: 4 additions & 1 deletion lazer/contracts/solana/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
"check-trusted-signer": "pnpm ts-node scripts/check_trusted_signer.ts"
},
"dependencies": {
"@coral-xyz/anchor": "^0.30.1"
"@coral-xyz/anchor": "^0.30.1",
"@pythnetwork/pyth-lazer-sdk": "workspace:*",
"@solana/web3.js": "^1.98.0",
"@solana/buffer-layout": "^4.0.1"
},
"devDependencies": {
"@types/bn.js": "^5.1.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(unexpected_cfgs)] // anchor macro triggers it

mod signature;

use {
Expand Down
50 changes: 50 additions & 0 deletions lazer/contracts/solana/scripts/add_ed25519_signer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import * as anchor from "@coral-xyz/anchor";
import { Program } from "@coral-xyz/anchor";
import { PythLazerSolanaContract } from "../target/types/pyth_lazer_solana_contract";
import * as pythLazerSolanaContractIdl from "../target/idl/pyth_lazer_solana_contract.json";
import yargs from "yargs/yargs";
import { readFileSync } from "fs";
import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet";

// Add a trusted signer or change its expiry time.
//
// Example:
// pnpm ts-node scripts/add_ed25519_signer.ts --url 'https://api.testnet.solana.com' \
// --keypair-path .../key.json --trusted-signer HaXscpSUcbCLSnPQB8Z7H6idyANxp1mZAXTbHeYpfrJJ \
// --expiry-time-seconds 2057930841
async function main() {
let argv = await yargs(process.argv.slice(2))
.options({
url: { type: "string", demandOption: true },
"keypair-path": { type: "string", demandOption: true },
"trusted-signer": { type: "string", demandOption: true },
"expiry-time-seconds": { type: "number", demandOption: true },
})
.parse();

const keypair = anchor.web3.Keypair.fromSecretKey(
new Uint8Array(JSON.parse(readFileSync(argv.keypairPath, "ascii"))),
);

const wallet = new NodeWallet(keypair);
const connection = new anchor.web3.Connection(argv.url, {
commitment: "confirmed",
});
const provider = new anchor.AnchorProvider(connection, wallet);

const program: Program<PythLazerSolanaContract> = new Program(
pythLazerSolanaContractIdl as PythLazerSolanaContract,
provider,
);

await program.methods
.update(
new anchor.web3.PublicKey(argv.trustedSigner),
new anchor.BN(argv.expiryTimeSeconds),
)
.accounts({})
.rpc();
console.log("signer updated");
}

main();
8 changes: 4 additions & 4 deletions lazer/contracts/solana/scripts/check_trusted_signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ async function main() {

// Print storage info
console.log("Storage Account Info:");
console.log("--------------------");
console.log("---------------------");
console.log("Top Authority:", storage.topAuthority.toBase58());
console.log("Treasury:", storage.treasury.toBase58());
console.log("\nTrusted Signers:");
console.log("----------------");
console.log("\nTrusted Ed25519 Signers:");
console.log("------------------------");

const trustedSigners = storage.trustedSigners.slice(
0,
Expand All @@ -67,7 +67,7 @@ async function main() {
}

console.log("\nTrusted ECDSA Signers:");
console.log("----------------");
console.log("----------------------");

const trustedEcdsaSigners = storage.trustedEcdsaSigners.slice(
0,
Expand Down
76 changes: 76 additions & 0 deletions lazer/contracts/solana/scripts/verify_ed25519_message.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import * as anchor from "@coral-xyz/anchor";
import { Program } from "@coral-xyz/anchor";
import { PythLazerSolanaContract } from "../target/types/pyth_lazer_solana_contract";
import * as pythLazerSolanaContractIdl from "../target/idl/pyth_lazer_solana_contract.json";
import yargs from "yargs/yargs";
import { readFileSync } from "fs";
import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet";
import { createEd25519Instruction } from "../src/ed25519";
import {
sendAndConfirmTransaction,
SendTransactionError,
SYSVAR_INSTRUCTIONS_PUBKEY,
Transaction,
} from "@solana/web3.js";

async function main() {
let argv = await yargs(process.argv.slice(2))
.options({
url: { type: "string", demandOption: true },
"keypair-path": { type: "string", demandOption: true },
message: { type: "string", demandOption: true },
})
.parse();

const keypair = anchor.web3.Keypair.fromSecretKey(
new Uint8Array(JSON.parse(readFileSync(argv.keypairPath, "ascii"))),
);

const wallet = new NodeWallet(keypair);
const connection = new anchor.web3.Connection(argv.url, {
commitment: "confirmed",
});
const provider = new anchor.AnchorProvider(connection, wallet);

const program: Program<PythLazerSolanaContract> = new Program(
pythLazerSolanaContractIdl as PythLazerSolanaContract,
provider,
);

const instructionMessage = Buffer.from(argv.message, "hex");
const ed25519Instruction = createEd25519Instruction(
instructionMessage,
1,
12,
);
const lazerInstruction = await program.methods
.verifyMessage(instructionMessage, 0, 0)
.accounts({
payer: wallet.publicKey,
instructionsSysvar: SYSVAR_INSTRUCTIONS_PUBKEY,
})
.instruction();

const transaction = new Transaction().add(
ed25519Instruction,
lazerInstruction,
);
console.log("transaction:", transaction);

try {
const signature = await sendAndConfirmTransaction(
connection,
transaction,
[wallet.payer],
{
skipPreflight: true,
},
);
console.log("Transaction confirmed with signature:", signature);
} catch (e) {
console.log("error", e);
console.log(e.getLogs());
}
}

main();
File renamed without changes.
4 changes: 1 addition & 3 deletions lazer/sdk/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pythnetwork/pyth-lazer-sdk",
"version": "1.0.0",
"version": "2.0.0",
"description": "Pyth Lazer SDK",
"publishConfig": {
"access": "public"
Expand Down Expand Up @@ -59,8 +59,6 @@
"license": "Apache-2.0",
"dependencies": {
"@isaacs/ttlcache": "^1.4.1",
"@solana/buffer-layout": "^4.0.1",
"@solana/web3.js": "^1.98.0",
"isomorphic-ws": "^5.0.0",
"ts-log": "^2.2.7",
"ws": "^8.18.0"
Expand Down
12 changes: 4 additions & 8 deletions lazer/sdk/js/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import { PublicKey } from "@solana/web3.js";

export const SOLANA_LAZER_PROGRAM_ID = new PublicKey(
"pytd2yyk641x7ak7mkaasSJVXh6YYZnC7wTmtgAyxPt",
);
export const SOLANA_STORAGE_ID = new PublicKey(
"3rdJbqfnagQ4yx9HXJViD4zc4xpiSqmFsKpPuSCQVyQL",
);
export const SOLANA_LAZER_PROGRAM_ID =
"pytd2yyk641x7ak7mkaasSJVXh6YYZnC7wTmtgAyxPt";
export const SOLANA_LAZER_STORAGE_ID =
"3rdJbqfnagQ4yx9HXJViD4zc4xpiSqmFsKpPuSCQVyQL";
1 change: 0 additions & 1 deletion lazer/sdk/js/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from "./client.js";
export * from "./protocol.js";
export * from "./ed25519.js";
export * from "./constants.js";
53 changes: 16 additions & 37 deletions pnpm-lock.yaml

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

Loading