Skip to content

Commit baeece1

Browse files
committed
refactor: address comments and fix issues
1 parent d103b1a commit baeece1

File tree

6 files changed

+184
-164
lines changed

6 files changed

+184
-164
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: 46 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -25,54 +25,53 @@ The `fillPythUpdate` function helps you automatically determine what Pyth price
2525
This function uses the `trace_callMany` method by default but can be used with `debug_traceCall` and a bundler as well. See the example below for more information.
2626

2727
```typescript
28-
import { fillPythUpdate, multicall3Bundler } from "@pythnetwork/pyth-evm-js";
28+
import { fillPythUpdate, multicall3Bundler, CallRequest } 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-
});
37-
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-
);
53-
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-
);
70-
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-
}
32+
const PYTH_CONTRACT_OP_SEPOLIA = "0x0708325268df9f66270f1401206434524814508b"
33+
const HERMES_ENDPOINT = "https://hermes.pyth.network"
34+
35+
const client = createPublicClient({
36+
chain: optimismSepolia,
37+
transport: http("YOUR_RPC_ENDPOINT"),
38+
});
39+
40+
const call: CallRequest = {
41+
to: "0x3252c2F7962689fA17f892C52555613f36056f22",
42+
data: "0xd09de08a", // Your transaction calldata
43+
from: "0x78357316239040e19fC823372cC179ca75e64b81",
44+
};
45+
46+
// Fill Pyth update data using "trace_callMany"
47+
const pythUpdate = await fillPythUpdate(
48+
client,
49+
call,
50+
PYTH_CONTRACT_OP_SEPOLIA,
51+
HERMES_ENDPOINT,
52+
{
53+
method: "trace_callMany",
54+
maxIter: 5,
55+
},
56+
);
57+
58+
// Fill Pyth update data using "debug_traceCall"
59+
const _pythUpdateWithDebugTraceCall = await fillPythUpdate(
60+
client,
61+
call,
62+
PYTH_CONTRACT_OP_SEPOLIA,
63+
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+
);
70+
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");
7776
}
78-
```
77+
```

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)