@helium/helium-admin-cli 0.6.7 → 0.6.9
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/cjs/update-price-oracle.js +120 -0
- package/lib/cjs/update-price-oracle.js.map +1 -0
- package/lib/esm/src/update-price-oracle.js +79 -0
- package/lib/esm/src/update-price-oracle.js.map +1 -0
- package/lib/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/types/src/update-price-oracle.d.ts +2 -0
- package/lib/types/src/update-price-oracle.d.ts.map +1 -0
- package/package.json +13 -13
|
@@ -0,0 +1,120 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.run = void 0;
|
|
39
|
+
const anchor = __importStar(require("@coral-xyz/anchor"));
|
|
40
|
+
const price_oracle_sdk_1 = require("@helium/price-oracle-sdk");
|
|
41
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
42
|
+
const sdk_1 = __importDefault(require("@sqds/sdk"));
|
|
43
|
+
const os_1 = __importDefault(require("os"));
|
|
44
|
+
const yargs_1 = __importDefault(require("yargs/yargs"));
|
|
45
|
+
const utils_1 = require("./utils");
|
|
46
|
+
function run(args = process.argv) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const yarg = (0, yargs_1.default)(args).options({
|
|
49
|
+
wallet: {
|
|
50
|
+
alias: "k",
|
|
51
|
+
describe: "Anchor wallet keypair",
|
|
52
|
+
default: `${os_1.default.homedir()}/.config/solana/id.json`,
|
|
53
|
+
},
|
|
54
|
+
url: {
|
|
55
|
+
alias: "u",
|
|
56
|
+
default: "http://127.0.0.1:8899",
|
|
57
|
+
describe: "The solana url",
|
|
58
|
+
},
|
|
59
|
+
oracle: {
|
|
60
|
+
required: true,
|
|
61
|
+
describe: "Public Key of the oracle",
|
|
62
|
+
type: "string",
|
|
63
|
+
},
|
|
64
|
+
executeTransaction: {
|
|
65
|
+
type: "boolean",
|
|
66
|
+
},
|
|
67
|
+
multisig: {
|
|
68
|
+
type: "string",
|
|
69
|
+
describe: "Address of the squads multisig to be authority. If not provided, your wallet will be the authority",
|
|
70
|
+
},
|
|
71
|
+
authorityIndex: {
|
|
72
|
+
type: "number",
|
|
73
|
+
describe: "Authority index for squads. Defaults to 1",
|
|
74
|
+
default: 1,
|
|
75
|
+
},
|
|
76
|
+
oracles: {
|
|
77
|
+
type: "array",
|
|
78
|
+
describe: 'public keys of the oracles',
|
|
79
|
+
required: true
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
const argv = yield yarg.argv;
|
|
83
|
+
process.env.ANCHOR_WALLET = argv.wallet;
|
|
84
|
+
process.env.ANCHOR_PROVIDER_URL = argv.url;
|
|
85
|
+
anchor.setProvider(anchor.AnchorProvider.local(argv.url));
|
|
86
|
+
const provider = anchor.getProvider();
|
|
87
|
+
const wallet = new anchor.Wallet((0, utils_1.loadKeypair)(argv.wallet));
|
|
88
|
+
const program = yield (0, price_oracle_sdk_1.init)(provider);
|
|
89
|
+
const squads = sdk_1.default.endpoint(process.env.ANCHOR_PROVIDER_URL, wallet, {
|
|
90
|
+
commitmentOrConfig: "finalized",
|
|
91
|
+
});
|
|
92
|
+
const oracleKey = new web3_js_1.PublicKey(argv.oracle);
|
|
93
|
+
const oracle = yield program.account.priceOracleV0.fetch(oracleKey);
|
|
94
|
+
const ix = yield program.methods
|
|
95
|
+
.updatePriceOracleV0({
|
|
96
|
+
oracles: argv.oracles.map(o => ({
|
|
97
|
+
authority: new web3_js_1.PublicKey(o),
|
|
98
|
+
lastSubmittedPrice: null,
|
|
99
|
+
lastSubmittedTimestamp: null,
|
|
100
|
+
})),
|
|
101
|
+
authority: null
|
|
102
|
+
})
|
|
103
|
+
.accounts({
|
|
104
|
+
priceOracle: oracleKey,
|
|
105
|
+
authority: oracle.authority
|
|
106
|
+
})
|
|
107
|
+
.instruction();
|
|
108
|
+
yield (0, utils_1.sendInstructionsOrSquads)({
|
|
109
|
+
provider,
|
|
110
|
+
instructions: [ix],
|
|
111
|
+
executeTransaction: argv.executeTransaction,
|
|
112
|
+
squads,
|
|
113
|
+
multisig: argv.multisig ? new web3_js_1.PublicKey(argv.multisig) : undefined,
|
|
114
|
+
authorityIndex: argv.authorityIndex,
|
|
115
|
+
signers: [],
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
exports.run = run;
|
|
120
|
+
//# sourceMappingURL=update-price-oracle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-price-oracle.js","sourceRoot":"","sources":["../../src/update-price-oracle.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAA4C;AAC5C,+DAEiC;AACjC,6CAA4C;AAC5C,oDAA+B;AAC/B,4CAAoB;AACpB,wDAAgC;AAChC,mCAAgE;AAEhE,SAAsB,GAAG,CAAC,OAAY,OAAO,CAAC,IAAI;;QAChD,MAAM,IAAI,GAAG,IAAA,eAAK,EAAC,IAAI,CAAC,CAAC,OAAO,CAAC;YAC/B,MAAM,EAAE;gBACN,KAAK,EAAE,GAAG;gBACV,QAAQ,EAAE,uBAAuB;gBACjC,OAAO,EAAE,GAAG,YAAE,CAAC,OAAO,EAAE,yBAAyB;aAClD;YACD,GAAG,EAAE;gBACH,KAAK,EAAE,GAAG;gBACV,OAAO,EAAE,uBAAuB;gBAChC,QAAQ,EAAE,gBAAgB;aAC3B;YACD,MAAM,EAAE;gBACN,QAAQ,EAAE,IAAI;gBACd,QAAQ,EAAE,0BAA0B;gBACpC,IAAI,EAAE,QAAQ;aACf;YACD,kBAAkB,EAAE;gBAClB,IAAI,EAAE,SAAS;aAChB;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,QAAQ,EACN,oGAAoG;aACvG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,EAAE,IAAI,mBAAS,CAAC,CAAC,CAAC;gBAC3B,kBAAkB,EAAE,IAAI;gBACxB,sBAAsB,EAAE,IAAI;aAC7B,CAAC,CAAC;YACH,SAAS,EAAE,IAAI;SAChB,CAAC;aACD,QAAQ,CAAC;YACR,WAAW,EAAE,SAAS;YACtB,SAAS,EAAE,MAAM,CAAC,SAAS;SAC5B,CAAC;aACD,WAAW,EAAE,CAAC;QAEjB,MAAM,IAAA,gCAAwB,EAAC;YAC7B,QAAQ;YACR,YAAY,EAAE,CAAC,EAAE,CAAC;YAClB,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;YAC3C,MAAM;YACN,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,mBAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS;YAClE,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,OAAO,EAAE,EAAE;SACZ,CAAC,CAAC;IACL,CAAC;CAAA;AAzED,kBAyEC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import * as anchor from "@coral-xyz/anchor";
|
|
2
|
+
import { init as initPrice, } from "@helium/price-oracle-sdk";
|
|
3
|
+
import { PublicKey } from "@solana/web3.js";
|
|
4
|
+
import Squads from "@sqds/sdk";
|
|
5
|
+
import os from "os";
|
|
6
|
+
import yargs from "yargs/yargs";
|
|
7
|
+
import { loadKeypair, sendInstructionsOrSquads } from "./utils";
|
|
8
|
+
export async function run(args = process.argv) {
|
|
9
|
+
const yarg = yargs(args).options({
|
|
10
|
+
wallet: {
|
|
11
|
+
alias: "k",
|
|
12
|
+
describe: "Anchor wallet keypair",
|
|
13
|
+
default: `${os.homedir()}/.config/solana/id.json`,
|
|
14
|
+
},
|
|
15
|
+
url: {
|
|
16
|
+
alias: "u",
|
|
17
|
+
default: "http://127.0.0.1:8899",
|
|
18
|
+
describe: "The solana url",
|
|
19
|
+
},
|
|
20
|
+
oracle: {
|
|
21
|
+
required: true,
|
|
22
|
+
describe: "Public Key of the oracle",
|
|
23
|
+
type: "string",
|
|
24
|
+
},
|
|
25
|
+
executeTransaction: {
|
|
26
|
+
type: "boolean",
|
|
27
|
+
},
|
|
28
|
+
multisig: {
|
|
29
|
+
type: "string",
|
|
30
|
+
describe: "Address of the squads multisig to be authority. If not provided, your wallet will be the authority",
|
|
31
|
+
},
|
|
32
|
+
authorityIndex: {
|
|
33
|
+
type: "number",
|
|
34
|
+
describe: "Authority index for squads. Defaults to 1",
|
|
35
|
+
default: 1,
|
|
36
|
+
},
|
|
37
|
+
oracles: {
|
|
38
|
+
type: "array",
|
|
39
|
+
describe: 'public keys of the oracles',
|
|
40
|
+
required: true
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
const argv = await yarg.argv;
|
|
44
|
+
process.env.ANCHOR_WALLET = argv.wallet;
|
|
45
|
+
process.env.ANCHOR_PROVIDER_URL = argv.url;
|
|
46
|
+
anchor.setProvider(anchor.AnchorProvider.local(argv.url));
|
|
47
|
+
const provider = anchor.getProvider();
|
|
48
|
+
const wallet = new anchor.Wallet(loadKeypair(argv.wallet));
|
|
49
|
+
const program = await initPrice(provider);
|
|
50
|
+
const squads = Squads.endpoint(process.env.ANCHOR_PROVIDER_URL, wallet, {
|
|
51
|
+
commitmentOrConfig: "finalized",
|
|
52
|
+
});
|
|
53
|
+
const oracleKey = new PublicKey(argv.oracle);
|
|
54
|
+
const oracle = await program.account.priceOracleV0.fetch(oracleKey);
|
|
55
|
+
const ix = await program.methods
|
|
56
|
+
.updatePriceOracleV0({
|
|
57
|
+
oracles: argv.oracles.map(o => ({
|
|
58
|
+
authority: new PublicKey(o),
|
|
59
|
+
lastSubmittedPrice: null,
|
|
60
|
+
lastSubmittedTimestamp: null,
|
|
61
|
+
})),
|
|
62
|
+
authority: null
|
|
63
|
+
})
|
|
64
|
+
.accounts({
|
|
65
|
+
priceOracle: oracleKey,
|
|
66
|
+
authority: oracle.authority
|
|
67
|
+
})
|
|
68
|
+
.instruction();
|
|
69
|
+
await sendInstructionsOrSquads({
|
|
70
|
+
provider,
|
|
71
|
+
instructions: [ix],
|
|
72
|
+
executeTransaction: argv.executeTransaction,
|
|
73
|
+
squads,
|
|
74
|
+
multisig: argv.multisig ? new PublicKey(argv.multisig) : undefined,
|
|
75
|
+
authorityIndex: argv.authorityIndex,
|
|
76
|
+
signers: [],
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=update-price-oracle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-price-oracle.js","sourceRoot":"","sources":["../../../src/update-price-oracle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EACL,IAAI,IAAI,SAAS,GAClB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,KAAK,MAAM,aAAa,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAEhE,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,OAAY,OAAO,CAAC,IAAI;IAChD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC;QAC/B,MAAM,EAAE;YACN,KAAK,EAAE,GAAG;YACV,QAAQ,EAAE,uBAAuB;YACjC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,yBAAyB;SAClD;QACD,GAAG,EAAE;YACH,KAAK,EAAE,GAAG;YACV,OAAO,EAAE,uBAAuB;YAChC,QAAQ,EAAE,gBAAgB;SAC3B;QACD,MAAM,EAAE;YACN,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,0BAA0B;YACpC,IAAI,EAAE,QAAQ;SACf;QACD,kBAAkB,EAAE;YAClB,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