Skip to content

Commit fbf49a2

Browse files
committed
refactor: address comments
1 parent b443c30 commit fbf49a2

File tree

5 files changed

+178
-160
lines changed

5 files changed

+178
-160
lines changed

pnpm-lock.yaml

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

target_chains/ethereum/sdk/js/README.md

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -29,50 +29,51 @@ import { fillPythUpdate, multicall3Bundler } from "@pythnetwork/pyth-evm-js";
2929
import { createPublicClient, http } from "viem";
3030
import { optimismSepolia } from "viem/chains";
3131

32-
async function example() {
33-
const client = createPublicClient({
34-
chain: optimismSepolia,
35-
transport: http("YOUR_RPC_ENDPOINT"),
36-
});
32+
const PYTH_CONTRACT_OP_SEPOLIA = "0x0708325268df9f66270f1401206434524814508b"
33+
const HERMES_ENDPOINT = "https://hermes.pyth.network"
3734

38-
// Fill Pyth update data using "trace_callMany"
39-
const pythUpdate = await fillPythUpdate(
40-
client,
41-
{
42-
to: "0x3252c2F7962689fA17f892C52555613f36056f22",
43-
data: "0xd09de08a", // Your transaction calldata
44-
from: "0x78357316239040e19fC823372cC179ca75e64b81",
45-
},
46-
"0x0708325268df9f66270f1401206434524814508b", // Pyth contract address
47-
"https://hermes.pyth.network", // Hermes endpoint
48-
{
49-
method: "trace_callMany"
50-
maxIter: 5,
51-
},
52-
);
35+
const client = createPublicClient({
36+
chain: optimismSepolia,
37+
transport: http("YOUR_RPC_ENDPOINT"),
38+
});
5339

54-
// Fill Pyth update data using "debug_traceCall"
55-
const pythUpdateWithDebugTrace = await fillPythUpdate(
56-
client,
57-
{
58-
to: "0x3252c2F7962689fA17f892C52555613f36056f22",
59-
data: "0xd09de08a", // Your transaction calldata
60-
from: "0x78357316239040e19fC823372cC179ca75e64b81",
61-
},
62-
"0x0708325268df9f66270f1401206434524814508b", // Pyth contract address
63-
"https://hermes.pyth.network", // Hermes endpoint
64-
{
65-
method: "debug_traceCall",
66-
bundler: multicall3Bundler // or any function that takes a PythUpdate and a CallRequest and produces a CallRequest
67-
maxIter: 5,
68-
},
69-
);
40+
// Fill Pyth update data using "trace_callMany"
41+
const pythUpdate = await fillPythUpdate(
42+
client,
43+
{
44+
to: "0x3252c2F7962689fA17f892C52555613f36056f22",
45+
data: "0xd09de08a", // Your transaction calldata
46+
from: "0x78357316239040e19fC823372cC179ca75e64b81",
47+
},
48+
PYTH_CONTRACT_OP_SEPOLIA
49+
HERMES_ENDPOINT,
50+
{
51+
method: "trace_callMany"
52+
maxIter: 5,
53+
},
54+
);
7055

71-
if (pythUpdate) {
72-
console.log("Pyth update needed:", pythUpdate);
73-
// Bundle the calls together, or pass the pythUpdate.updateData to your contract.
74-
} else {
75-
console.log("No Pyth data needed for this transaction");
76-
}
56+
// Fill Pyth update data using "debug_traceCall"
57+
const pythUpdateWithDebugTrace = await fillPythUpdate(
58+
client,
59+
{
60+
to: "0x3252c2F7962689fA17f892C52555613f36056f22",
61+
data: "0xd09de08a", // Your transaction calldata
62+
from: "0x78357316239040e19fC823372cC179ca75e64b81",
63+
},
64+
"0x0708325268df9f66270f1401206434524814508b", // Pyth contract address
65+
"https://hermes.pyth.network", // Hermes endpoint
66+
{
67+
method: "debug_traceCall",
68+
bundler: multicall3Bundler // or any function that takes a PythUpdate and a CallRequest and produces a CallRequest
69+
maxIter: 5,
70+
},
71+
);
72+
73+
if (pythUpdate) {
74+
console.log("Pyth update needed:", pythUpdate);
75+
// Bundle the calls together, or pass the pythUpdate.updateData to your contract.
76+
} else {
77+
console.log("No Pyth data needed for this transaction");
7778
}
78-
```
79+
```

target_chains/ethereum/sdk/js/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
"jest": "^29.4.1",
4848
"prettier": "catalog:",
4949
"ts-jest": "^29.0.5",
50-
"ts-node": "catalog:",
5150
"typescript": "catalog:"
5251
},
5352
"dependencies": {

0 commit comments

Comments
 (0)