@pythnetwork/price-pusher 7.1.0 → 8.0.0-alpha
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/lib/evm/command.d.ts +1 -1
- package/lib/evm/command.d.ts.map +1 -1
- package/lib/evm/command.js +13 -7
- package/lib/evm/custom-gas-station.d.ts +1 -1
- package/lib/evm/custom-gas-station.d.ts.map +1 -1
- package/lib/evm/custom-gas-station.js +3 -7
- package/lib/evm/evm.d.ts +9 -33
- package/lib/evm/evm.d.ts.map +1 -1
- package/lib/evm/evm.js +147 -178
- package/lib/evm/pyth-abi.d.ts +1001 -0
- package/lib/evm/pyth-abi.d.ts.map +1 -0
- package/lib/evm/pyth-abi.js +660 -0
- package/lib/evm/pyth-contract.d.ts +6 -0
- package/lib/evm/pyth-contract.d.ts.map +1 -0
- package/lib/evm/pyth-contract.js +11 -0
- package/lib/evm/super-wallet.d.ts +4 -0
- package/lib/evm/super-wallet.d.ts.map +1 -0
- package/lib/evm/super-wallet.js +63 -0
- package/lib/utils.d.ts +2 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +12 -7
- package/package.json +5 -8
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.createClient = void 0;
|
|
27
|
+
const viem_1 = require("viem");
|
|
28
|
+
const accounts_1 = require("viem/accounts");
|
|
29
|
+
const chains = __importStar(require("viem/chains"));
|
|
30
|
+
const utils_1 = require("../utils");
|
|
31
|
+
const UNKNOWN_CHAIN_CONFIG = {
|
|
32
|
+
name: "Unknown",
|
|
33
|
+
nativeCurrency: {
|
|
34
|
+
name: "Unknown",
|
|
35
|
+
symbol: "Unknown",
|
|
36
|
+
decimals: 18,
|
|
37
|
+
},
|
|
38
|
+
rpcUrls: {
|
|
39
|
+
default: {
|
|
40
|
+
http: [],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
// Get the transport based on the endpoint
|
|
45
|
+
const getTransport = (endpoint) => (0, utils_1.isWsEndpoint)(endpoint) ? (0, viem_1.webSocket)(endpoint) : (0, viem_1.http)(endpoint);
|
|
46
|
+
// Get the chain corresponding to the chainId. If the chain is not found, it will return
|
|
47
|
+
// an unknown chain which should work fine in most of the cases. We might need to update
|
|
48
|
+
// the viem package to support new chains if they don't work as expected with the unknown
|
|
49
|
+
// chain.
|
|
50
|
+
const getChainById = (chainId) => Object.values(chains).find((chain) => chain.id === chainId) ||
|
|
51
|
+
(0, viem_1.defineChain)({ id: chainId, ...UNKNOWN_CHAIN_CONFIG });
|
|
52
|
+
const createClient = async (endpoint, mnemonic) => {
|
|
53
|
+
const transport = getTransport(endpoint);
|
|
54
|
+
const chainId = await (0, viem_1.createPublicClient)({
|
|
55
|
+
transport,
|
|
56
|
+
}).getChainId();
|
|
57
|
+
return (0, viem_1.createWalletClient)({
|
|
58
|
+
transport,
|
|
59
|
+
account: (0, accounts_1.mnemonicToAccount)(mnemonic),
|
|
60
|
+
chain: getChainById(chainId),
|
|
61
|
+
}).extend(viem_1.publicActions);
|
|
62
|
+
};
|
|
63
|
+
exports.createClient = createClient;
|
package/lib/utils.d.ts
CHANGED
|
@@ -7,7 +7,8 @@ export declare const customGasChainIds: readonly [137];
|
|
|
7
7
|
export type CustomGasChainId = typeof customGasChainIds[number];
|
|
8
8
|
export declare function sleep(ms: number): Promise<void>;
|
|
9
9
|
export declare function removeLeading0x(id: HexString): HexString;
|
|
10
|
-
export declare
|
|
10
|
+
export declare const addLeading0x: (id: HexString) => `0x${string}`;
|
|
11
11
|
export declare function isWsEndpoint(endpoint: string): boolean;
|
|
12
12
|
export declare function verifyValidOption<options extends Readonly<Array<any>>, validOption extends options[number]>(option: any, validOptions: options): validOption;
|
|
13
|
+
export declare const assertDefined: <T>(value: T | undefined) => T;
|
|
13
14
|
//# sourceMappingURL=utils.d.ts.map
|
package/lib/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAE9D,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAC/B,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACvC,eAAO,MAAM,QAAQ,uCAAwC,CAAC;AAC9D,MAAM,MAAM,OAAO,GAAG,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC;AAC9C,eAAO,MAAM,iBAAiB,gBAAiB,CAAC;AAChD,MAAM,MAAM,gBAAgB,GAAG,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC;AAEhE,wBAAsB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAErD;AAED,wBAAgB,eAAe,CAAC,EAAE,EAAE,SAAS,GAAG,SAAS,CAKxD;AAED,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAE9D,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAC/B,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACvC,eAAO,MAAM,QAAQ,uCAAwC,CAAC;AAC9D,MAAM,MAAM,OAAO,GAAG,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC;AAC9C,eAAO,MAAM,iBAAiB,gBAAiB,CAAC;AAChD,MAAM,MAAM,gBAAgB,GAAG,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC;AAEhE,wBAAsB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAErD;AAED,wBAAgB,eAAe,CAAC,EAAE,EAAE,SAAS,GAAG,SAAS,CAKxD;AAED,eAAO,MAAM,YAAY,OAAQ,SAAS,KAAG,KAAK,MAAM,EACrB,CAAC;AAKpC,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAStD;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,SAAS,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EACpC,WAAW,SAAS,OAAO,CAAC,MAAM,CAAC,EACnC,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,eAOnC;AAED,eAAO,MAAM,aAAa,aAAc,CAAC,GAAG,SAAS,KAAG,CAMvD,CAAC"}
|
package/lib/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.verifyValidOption = exports.isWsEndpoint = exports.addLeading0x = exports.removeLeading0x = exports.sleep = exports.customGasChainIds = exports.txSpeeds = void 0;
|
|
3
|
+
exports.assertDefined = exports.verifyValidOption = exports.isWsEndpoint = exports.addLeading0x = exports.removeLeading0x = exports.sleep = exports.customGasChainIds = exports.txSpeeds = void 0;
|
|
4
4
|
exports.txSpeeds = ["slow", "standard", "fast"];
|
|
5
5
|
exports.customGasChainIds = [137];
|
|
6
6
|
async function sleep(ms) {
|
|
@@ -14,13 +14,9 @@ function removeLeading0x(id) {
|
|
|
14
14
|
return id;
|
|
15
15
|
}
|
|
16
16
|
exports.removeLeading0x = removeLeading0x;
|
|
17
|
-
|
|
18
|
-
if (id.startsWith("0x")) {
|
|
19
|
-
return id;
|
|
20
|
-
}
|
|
21
|
-
return "0x" + id;
|
|
22
|
-
}
|
|
17
|
+
const addLeading0x = (id) => hasLeading0x(id) ? id : `0x${id}`;
|
|
23
18
|
exports.addLeading0x = addLeading0x;
|
|
19
|
+
const hasLeading0x = (input) => input.startsWith("0x");
|
|
24
20
|
function isWsEndpoint(endpoint) {
|
|
25
21
|
const url = new URL(endpoint);
|
|
26
22
|
const protocol = url.protocol;
|
|
@@ -38,3 +34,12 @@ function verifyValidOption(option, validOptions) {
|
|
|
38
34
|
throw new Error(errorString);
|
|
39
35
|
}
|
|
40
36
|
exports.verifyValidOption = verifyValidOption;
|
|
37
|
+
const assertDefined = (value) => {
|
|
38
|
+
if (value === undefined) {
|
|
39
|
+
throw new Error("Assertion failed: value was undefined");
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
exports.assertDefined = assertDefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pythnetwork/price-pusher",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0-alpha",
|
|
4
4
|
"description": "Pyth Price Pusher",
|
|
5
5
|
"homepage": "https://pyth.network",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -59,23 +59,20 @@
|
|
|
59
59
|
"@mysten/sui": "^1.3.0",
|
|
60
60
|
"@pythnetwork/price-service-client": "1.9.0",
|
|
61
61
|
"@pythnetwork/price-service-sdk": "^1.7.1",
|
|
62
|
-
"@pythnetwork/pyth-sdk-solidity": "
|
|
63
|
-
"@pythnetwork/pyth-solana-receiver": "0.8.
|
|
62
|
+
"@pythnetwork/pyth-sdk-solidity": "4.0.0",
|
|
63
|
+
"@pythnetwork/pyth-solana-receiver": "0.8.1",
|
|
64
64
|
"@pythnetwork/pyth-sui-js": "2.1.0",
|
|
65
65
|
"@pythnetwork/solana-utils": "0.4.2",
|
|
66
66
|
"@solana/web3.js": "^1.93.0",
|
|
67
|
-
"@truffle/hdwallet-provider": "^2.1.3",
|
|
68
67
|
"@types/pino": "^7.0.5",
|
|
69
68
|
"aptos": "^1.8.5",
|
|
70
69
|
"jito-ts": "^3.0.1",
|
|
71
70
|
"joi": "^17.6.0",
|
|
72
71
|
"near-api-js": "^3.0.2",
|
|
73
72
|
"pino": "^9.2.0",
|
|
74
|
-
"
|
|
75
|
-
"web3-core": "^1.8.1",
|
|
76
|
-
"web3-eth-contract": "^1.8.1",
|
|
73
|
+
"viem": "^2.19.4",
|
|
77
74
|
"yaml": "^2.1.1",
|
|
78
75
|
"yargs": "^17.5.1"
|
|
79
76
|
},
|
|
80
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "4eb89564385717bdfa9c84ac7b484312ee001d22"
|
|
81
78
|
}
|