@pythnetwork/pyth-ton-js 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +5 -1
- package/lib/index.d.ts +1 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +7 -7
- package/package.json +13 -13
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -57,9 +57,13 @@ async function main() {
|
|
|
57
57
|
);
|
|
58
58
|
console.log("Hermes BTC price:", latestPriceUpdates.parsed?.[0].price);
|
|
59
59
|
|
|
60
|
+
const numUpdates = 1; // Only BTC price
|
|
60
61
|
const updateData = Buffer.from(latestPriceUpdates.binary.data[0], "hex");
|
|
61
62
|
console.log("Update data:", updateData);
|
|
62
63
|
|
|
64
|
+
// NOTE: As of 2025/10/19 There's a bug with TON Access (https://ton.access.orbs.network) RPC service where if you provide an
|
|
65
|
+
// update data buffer with length of more than ~320 then the rpc returns error 404 and the function fails. In this case you can use the
|
|
66
|
+
// contract.getSingleUpdateFee() method to get the single update fee and multiply it by the number of updates you want to perform.
|
|
63
67
|
const updateFee = await contract.getUpdateFee(updateData);
|
|
64
68
|
console.log("Update fee:", updateFee);
|
|
65
69
|
|
|
@@ -74,7 +78,7 @@ async function main() {
|
|
|
74
78
|
await contract.sendUpdatePriceFeeds(
|
|
75
79
|
provider.sender(key.secretKey),
|
|
76
80
|
updateData,
|
|
77
|
-
calculateUpdatePriceFeedsFee(
|
|
81
|
+
calculateUpdatePriceFeedsFee(numUpdates) + BigInt(updateFee)
|
|
78
82
|
);
|
|
79
83
|
console.log("Price feeds updated successfully.");
|
|
80
84
|
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Address, Cell, Contract, Sender } from "@ton/core";
|
|
3
2
|
import { ContractProvider } from "@ton/ton";
|
|
4
|
-
export declare const PYTH_CONTRACT_ADDRESS_MAINNET = "
|
|
3
|
+
export declare const PYTH_CONTRACT_ADDRESS_MAINNET = "EQBgtfuGIzWLiOzpZO48_psYvco4xRtkAbdbmTwy0_o95LtZ";
|
|
5
4
|
export declare const PYTH_CONTRACT_ADDRESS_TESTNET = "EQB4ZnrI5qsP_IUJgVJNwEGKLzZWsQOFhiaqDbD7pTt_f9oU";
|
|
6
5
|
export declare const UPDATE_PRICE_FEEDS_BASE_GAS = 300000n;
|
|
7
6
|
export declare const UPDATE_PRICE_FEEDS_PER_UPDATE_GAS = 90000n;
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAEP,IAAI,EACJ,QAAQ,EAER,MAAM,EAGP,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,eAAO,MAAM,6BAA6B,qDACU,CAAC;AACrD,eAAO,MAAM,6BAA6B,qDACU,CAAC;AAErD,eAAO,MAAM,2BAA2B,UAAU,CAAC;AACnD,eAAO,MAAM,iCAAiC,SAAS,CAAC;AAExD,eAAO,MAAM,gBAAgB,OAAO,CAAC;AAErC,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,qBAAa,YAAa,YAAW,QAAQ;IAEzC,QAAQ,CAAC,OAAO,EAAE,OAAO;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE;QAAE,IAAI,EAAE,IAAI,CAAC;QAAC,IAAI,EAAE,IAAI,CAAA;KAAE;gBADjC,OAAO,EAAE,OAAO,EAChB,IAAI,CAAC,EAAE;QAAE,IAAI,EAAE,IAAI,CAAC;QAAC,IAAI,EAAE,IAAI,CAAA;KA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AM,GAAG,IAAI,CAsBpD;AAmBD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,UAAU,EAAE,CAczD;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,UAAU,GAAG,IAAI,CAQ7D;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,EAAE,CAoBzD;AAED,wBAAgB,4BAA4B,CAAC,UAAU,EAAE,MAAM,UAM9D"}
|
package/lib/index.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.PythContract = exports.GAS_PRICE_FACTOR = exports.UPDATE_PRICE_FEEDS_PER_UPDATE_GAS = exports.UPDATE_PRICE_FEEDS_BASE_GAS = exports.PYTH_CONTRACT_ADDRESS_TESTNET = exports.PYTH_CONTRACT_ADDRESS_MAINNET = void 0;
|
|
4
|
+
exports.createCellChain = createCellChain;
|
|
5
|
+
exports.parseDataSources = parseDataSources;
|
|
6
|
+
exports.parseDataSource = parseDataSource;
|
|
7
|
+
exports.parseGuardianSetKeys = parseGuardianSetKeys;
|
|
8
|
+
exports.calculateUpdatePriceFeedsFee = calculateUpdatePriceFeedsFee;
|
|
4
9
|
const core_1 = require("@ton/core");
|
|
5
|
-
exports.PYTH_CONTRACT_ADDRESS_MAINNET = "
|
|
10
|
+
exports.PYTH_CONTRACT_ADDRESS_MAINNET = "EQBgtfuGIzWLiOzpZO48_psYvco4xRtkAbdbmTwy0_o95LtZ";
|
|
6
11
|
exports.PYTH_CONTRACT_ADDRESS_TESTNET = "EQB4ZnrI5qsP_IUJgVJNwEGKLzZWsQOFhiaqDbD7pTt_f9oU";
|
|
7
12
|
// This is defined in target_chains/ton/contracts/common/gas.fc
|
|
8
13
|
exports.UPDATE_PRICE_FEEDS_BASE_GAS = 300000n;
|
|
@@ -190,7 +195,6 @@ function createCellChain(buffer) {
|
|
|
190
195
|
}
|
|
191
196
|
return lastCell;
|
|
192
197
|
}
|
|
193
|
-
exports.createCellChain = createCellChain;
|
|
194
198
|
function bufferToChunks(buff, chunkSizeBytes = 127) {
|
|
195
199
|
const chunks = [];
|
|
196
200
|
const uint8Array = new Uint8Array(buff.buffer, buff.byteOffset, buff.byteLength);
|
|
@@ -213,7 +217,6 @@ function parseDataSources(cell) {
|
|
|
213
217
|
}
|
|
214
218
|
return dataSources;
|
|
215
219
|
}
|
|
216
|
-
exports.parseDataSources = parseDataSources;
|
|
217
220
|
function parseDataSource(cell) {
|
|
218
221
|
const slice = cell.beginParse();
|
|
219
222
|
if (slice.remainingBits === 0) {
|
|
@@ -223,7 +226,6 @@ function parseDataSource(cell) {
|
|
|
223
226
|
const emitterAddress = slice.loadUintBig(256).toString(16).padStart(64, "0");
|
|
224
227
|
return { emitterChain, emitterAddress };
|
|
225
228
|
}
|
|
226
|
-
exports.parseDataSource = parseDataSource;
|
|
227
229
|
function parseGuardianSetKeys(cell) {
|
|
228
230
|
const keys = [];
|
|
229
231
|
function parseCell(c) {
|
|
@@ -243,10 +245,8 @@ function parseGuardianSetKeys(cell) {
|
|
|
243
245
|
parseCell(cell);
|
|
244
246
|
return keys;
|
|
245
247
|
}
|
|
246
|
-
exports.parseGuardianSetKeys = parseGuardianSetKeys;
|
|
247
248
|
function calculateUpdatePriceFeedsFee(numUpdates) {
|
|
248
249
|
return ((exports.UPDATE_PRICE_FEEDS_BASE_GAS +
|
|
249
250
|
exports.UPDATE_PRICE_FEEDS_PER_UPDATE_GAS * numUpdates) *
|
|
250
251
|
exports.GAS_PRICE_FACTOR);
|
|
251
252
|
}
|
|
252
|
-
exports.calculateUpdatePriceFeedsFee = calculateUpdatePriceFeedsFee;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pythnetwork/pyth-ton-js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Pyth Network TON Utilities",
|
|
5
5
|
"homepage": "https://pyth.network",
|
|
6
6
|
"author": {
|
|
@@ -19,14 +19,6 @@
|
|
|
19
19
|
"publishConfig": {
|
|
20
20
|
"access": "public"
|
|
21
21
|
},
|
|
22
|
-
"scripts": {
|
|
23
|
-
"build": "tsc",
|
|
24
|
-
"format": "prettier --write \"src/**/*.ts\"",
|
|
25
|
-
"test:lint": "eslint src/",
|
|
26
|
-
"prepublishOnly": "pnpm run build && pnpm run test:lint",
|
|
27
|
-
"preversion": "pnpm run test:lint",
|
|
28
|
-
"version": "pnpm run format && git add -A src"
|
|
29
|
-
},
|
|
30
22
|
"keywords": [
|
|
31
23
|
"pyth",
|
|
32
24
|
"oracle"
|
|
@@ -41,10 +33,18 @@
|
|
|
41
33
|
"@typescript-eslint/parser": "^5.21.0",
|
|
42
34
|
"eslint": "^8.14.0",
|
|
43
35
|
"jest": "^29.4.1",
|
|
44
|
-
"prettier": "^
|
|
36
|
+
"prettier": "^3.5.3",
|
|
45
37
|
"ts-jest": "^29.0.5",
|
|
46
38
|
"ts-node": "^10.9.2",
|
|
47
|
-
"typescript": "^
|
|
39
|
+
"typescript": "^5.8.2"
|
|
48
40
|
},
|
|
49
|
-
"
|
|
50
|
-
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsc",
|
|
43
|
+
"test:lint": "eslint src/ --max-warnings 0",
|
|
44
|
+
"test:format": "prettier --check \"src/**/*.ts\"",
|
|
45
|
+
"fix:lint": "eslint src/ --fix --max-warnings 0",
|
|
46
|
+
"fix:format": "prettier --write \"src/**/*.ts\"",
|
|
47
|
+
"preversion": "pnpm run test:lint",
|
|
48
|
+
"version": "pnpm run test:format && git add -A src"
|
|
49
|
+
}
|
|
50
|
+
}
|