|
|
3 週間 前 | |
|---|---|---|
| .. | ||
| examples | de0d661ce5 fix(lazer/js/sdk): fix casing (#3099) | 1 ヶ月 前 |
| src | 2bc47856e0 feat(pyth-lazer-sui-js): Init Lazer Sui SDK (#3017) | 2 ヶ月 前 |
| .gitignore | 2bc47856e0 feat(pyth-lazer-sui-js): Init Lazer Sui SDK (#3017) | 2 ヶ月 前 |
| .prettierignore | 2bc47856e0 feat(pyth-lazer-sui-js): Init Lazer Sui SDK (#3017) | 2 ヶ月 前 |
| README.md | 2bc47856e0 feat(pyth-lazer-sui-js): Init Lazer Sui SDK (#3017) | 2 ヶ月 前 |
| eslint.config.js | 2bc47856e0 feat(pyth-lazer-sui-js): Init Lazer Sui SDK (#3017) | 2 ヶ月 前 |
| package.json | ab0cf6f7d8 chore: updated gitignore to excluse the built dist/ folder | 3 週間 前 |
| tsconfig.build.json | ab0cf6f7d8 chore: updated gitignore to excluse the built dist/ folder | 3 週間 前 |
| tsconfig.json | fe92275443 chore: migrated all package.json and tsconfig files to a single, modern standard | 3 週間 前 |
| turbo.json | 2bc47856e0 feat(pyth-lazer-sui-js): Init Lazer Sui SDK (#3017) | 2 ヶ月 前 |
This package provides utilities to create a Sui Programmable Transaction to parse & verify a Pyth Lazer price update on-chain.
From the repository root:
pnpm turbo build -F @pythnetwork/pyth-lazer-sui-js
A runnable example is provided at examples/FetchAndVerifyUpdate.ts. It:
@pythnetwork/pyth-lazer-sdk,leEcdsa payload,parse_and_verify_le_ecdsa_update.Install tsx to run TypeScript scripts:
npm install -g tsx
Execute the example script:
SUI_KEY=<YOUR_SUI_PRIVATE_KEY> pnpm -F @pythnetwork/pyth-lazer-sui-js example:fetch-and-verify --fullnodeUrl <SUI_FULLNODE_URL> --packageId <PYTH_LAZER_PACKAGE_ID> --stateObjectId <PYTH_LAZER_STATE_OBJECT_ID> --token <LAZER_TOKEN>
The script's core logic is summarized below:
import { SuiClient } from "@mysten/sui/client";
import { Transaction } from "@mysten/sui/transactions";
import { SuiLazerClient } from "@pythnetwork/pyth-lazer-sui-js";
// Prepare Mysten Sui client
const provider = new SuiClient({ url: "<sui-fullnode-url>" });
// Create SDK client
const client = new SuiLazerClient(provider);
// Obtain a Lazer leEcdsa payload using @pythnetwork/pyth-lazer-sdk.
// See examples/FetchAndVerifyUpdate.ts for a runnable end-to-end example.
const leEcdsa: Buffer = /* fetch via @pythnetwork/pyth-lazer-sdk */ Buffer.from(
[],
);
// Build transaction calling parse_and_verify_le_ecdsa_update
const tx = new Transaction();
const packageId = "<pyth_lazer_package_id>";
const stateObjectId = "<pyth_lazer_state_object_id>";
const updateVal = client.addParseAndVerifyLeEcdsaUpdateCall({
tx,
packageId,
stateObjectId,
updateBytes: leEcdsa,
});
// Sign and execute the transaction using your signer.
packageId management is coming soon. The Lazer contract doesn't support upgradeability yet.lazer/contracts/sui/lazer/sdk/js/