@helium/helium-admin-cli 0.1.2 → 0.1.4
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/close-buffers.js +131 -0
- package/lib/cjs/close-buffers.js.map +1 -0
- package/lib/cjs/create-dao.js +5 -5
- package/lib/cjs/create-dao.js.map +1 -1
- package/lib/cjs/create-price-oracle.js +4 -0
- package/lib/cjs/create-price-oracle.js.map +1 -1
- package/lib/cjs/create-subdao.js +20 -17
- package/lib/cjs/create-subdao.js.map +1 -1
- package/lib/cjs/log-hotspot.js +2 -1
- package/lib/cjs/log-hotspot.js.map +1 -1
- package/lib/cjs/setup-hst.js +8 -1
- package/lib/cjs/setup-hst.js.map +1 -1
- package/lib/cjs/update-lazy-transactions.js +116 -0
- package/lib/cjs/update-lazy-transactions.js.map +1 -0
- package/lib/cjs/update-registrar-authorities.js +92 -0
- package/lib/cjs/update-registrar-authorities.js.map +1 -0
- package/lib/cjs/update-subdao-vehnt.js +109 -84
- package/lib/cjs/update-subdao-vehnt.js.map +1 -1
- package/lib/cjs/upgrade-idl.js +108 -0
- package/lib/cjs/upgrade-idl.js.map +1 -0
- package/lib/cjs/utils.js +88 -4
- package/lib/cjs/utils.js.map +1 -1
- package/lib/esm/src/close-buffers.js +90 -0
- package/lib/esm/src/close-buffers.js.map +1 -0
- package/lib/esm/src/create-dao.js +5 -5
- package/lib/esm/src/create-dao.js.map +1 -1
- package/lib/esm/src/create-price-oracle.js +5 -1
- package/lib/esm/src/create-price-oracle.js.map +1 -1
- package/lib/esm/src/create-subdao.js +20 -17
- package/lib/esm/src/create-subdao.js.map +1 -1
- package/lib/esm/src/log-hotspot.js +3 -2
- package/lib/esm/src/log-hotspot.js.map +1 -1
- package/lib/esm/src/setup-hst.js +8 -2
- package/lib/esm/src/setup-hst.js.map +1 -1
- package/lib/esm/src/update-lazy-transactions.js +75 -0
- package/lib/esm/src/update-lazy-transactions.js.map +1 -0
- package/lib/esm/src/update-registrar-authorities.js +51 -0
- package/lib/esm/src/update-registrar-authorities.js.map +1 -0
- package/lib/esm/src/update-subdao-vehnt.js +112 -84
- package/lib/esm/src/update-subdao-vehnt.js.map +1 -1
- package/lib/esm/src/upgrade-idl.js +67 -0
- package/lib/esm/src/upgrade-idl.js.map +1 -0
- package/lib/esm/src/utils.js +81 -5
- package/lib/esm/src/utils.js.map +1 -1
- package/lib/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/types/src/close-buffers.d.ts +2 -0
- package/lib/types/src/close-buffers.d.ts.map +1 -0
- package/lib/types/src/create-price-oracle.d.ts.map +1 -1
- package/lib/types/src/create-subdao.d.ts.map +1 -1
- package/lib/types/src/log-hotspot.d.ts.map +1 -1
- package/lib/types/src/setup-hst.d.ts.map +1 -1
- package/lib/types/src/update-lazy-transactions.d.ts +2 -0
- package/lib/types/src/update-lazy-transactions.d.ts.map +1 -0
- package/lib/types/src/update-registrar-authorities.d.ts +2 -0
- package/lib/types/src/update-registrar-authorities.d.ts.map +1 -0
- package/lib/types/src/update-subdao-vehnt.d.ts.map +1 -1
- package/lib/types/src/upgrade-idl.d.ts +2 -0
- package/lib/types/src/upgrade-idl.d.ts.map +1 -0
- package/lib/types/src/utils.d.ts +3 -1
- package/lib/types/src/utils.d.ts.map +1 -1
- package/package.json +11 -11
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-lazy-transactions.js","sourceRoot":"","sources":["../../src/update-lazy-transactions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAA4C;AAC5C,yEAGuC;AACvC,6CAA4C;AAC5C,oDAA+B;AAC/B,4CAAoB;AACpB,wDAAgC;AAChC,mCAAmD;AAEnD,SAAsB,GAAG,CAAC,OAAY,OAAO,CAAC,IAAI;;QAChD,MAAM,IAAI,GAAG,IAAA,eAAK,EAAC,IAAI,CAAC,CAAC,OAAO,CAAC;YAC/B,MAAM,EAAE;gBACN,KA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AC5B,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAC/B,QAAQ,CAAC,MAAM,EACf;YACE,kBAAkB,EAAE,WAAW;SAChC,CACF,CAAC;QAEF,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC,CAAC;QACzC,MAAM,EAAE,GAAG,MAAM,aAAa,CAAC,OAAO;aACnC,wBAAwB,CAAC;YACxB,SAAS,EAAE,IAAI,CAAC,YAAY;gBAC1B,CAAC,CAAC,IAAI,mBAAS,CAAC,IAAI,CAAC,YAAY,CAAC;gBAClC,CAAC,CAAC,SAAS,CAAC,SAAS;YACvB,IAAI,EAAE,IAAI;SACX,CAAC;aACD,QAAQ,CAAC;YACR,gBAAgB;YAChB,SAAS,EAAE,SAAS,CAAC,SAAS;YAC9B,MAAM,EAAE,SAAS,CAAC,MAAM;SACzB,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;AA5ED,kBA4EC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
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 voter_stake_registry_sdk_1 = require("@helium/voter-stake-registry-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
|
+
registrar: {
|
|
60
|
+
type: "string",
|
|
61
|
+
required: true,
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
const argv = yield yarg.argv;
|
|
65
|
+
process.env.ANCHOR_WALLET = argv.wallet;
|
|
66
|
+
process.env.ANCHOR_PROVIDER_URL = argv.url;
|
|
67
|
+
anchor.setProvider(anchor.AnchorProvider.local(argv.url));
|
|
68
|
+
const provider = anchor.getProvider();
|
|
69
|
+
const vsrProgram = yield (0, voter_stake_registry_sdk_1.init)(provider);
|
|
70
|
+
const registrar = new web3_js_1.PublicKey(argv.registrar);
|
|
71
|
+
const registrarAcc = yield vsrProgram.account.registrar.fetch(registrar);
|
|
72
|
+
const instructions = [
|
|
73
|
+
yield vsrProgram.methods.updateRegistrarAuthorityV0().accounts({
|
|
74
|
+
registrar,
|
|
75
|
+
realm: registrarAcc.realm,
|
|
76
|
+
realmAuthority: registrarAcc.realmAuthority,
|
|
77
|
+
}).instruction(),
|
|
78
|
+
];
|
|
79
|
+
const squads = sdk_1.default.endpoint(process.env.ANCHOR_PROVIDER_URL, provider.wallet, {
|
|
80
|
+
commitmentOrConfig: "finalized"
|
|
81
|
+
});
|
|
82
|
+
yield (0, utils_1.sendInstructionsOrSquads)({
|
|
83
|
+
provider,
|
|
84
|
+
instructions,
|
|
85
|
+
executeTransaction: true,
|
|
86
|
+
squads,
|
|
87
|
+
signers: [],
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
exports.run = run;
|
|
92
|
+
//# sourceMappingURL=update-registrar-authorities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-registrar-authorities.js","sourceRoot":"","sources":["../../src/update-registrar-authorities.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAA4C;AAC5C,+EAAwD;AACxD,6CAA4C;AAC5C,oDAA+B;AAC/B,4CAAoB;AACpB,wDAAgC;AAChC,mCAAmD;AAEnD,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,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,IAAI;aACf;SACF,CAAC,CAAC;QAEH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC;QAC7B,OAAO,CAAC,GAAG,CAAC,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC;QACxC,OAAO,CAAC,GAAG,CAAC,mBAAmB,GAAG,IAAI,CAAC,GAAG,CAAC;QAC3C,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QAC1D,MAAM,QAAQ,GAAG,MAAM,CAAC,WAAW,EAA2B,CAAC;QAE/D,MAAM,UAAU,GAAG,MAAM,IAAA,+BAAI,EAAC,QAAQ,CAAC,CAAC;QACxC,MAAM,SAAS,GAAG,IAAI,mBAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAChD,MAAM,YAAY,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACzE,MAAM,YAAY,GAAG;YACnB,MAAM,UAAU,CAAC,OAAO,CAAC,0BAA0B,EAAE,CAAC,QAAQ,CAAC;gBAC7D,SAAS;gBACT,KAAK,EAAE,YAAY,CAAC,KAAK;gBACzB,cAAc,EAAE,YAAY,CAAC,cAAc;aAC5C,CAAC,CAAC,WAAW,EAAE;SACjB,CAAC;QAEF,MAAM,MAAM,GAAG,aAAM,CAAC,QAAQ,CAC5B,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAC/B,QAAQ,CAAC,MAAM,EAAE;YACf,kBAAkB,EAAE,WAAW;SAChC,CACF,CAAC;QACF,MAAM,IAAA,gCAAwB,EAAC;YAC7B,QAAQ;YACR,YAAY;YACZ,kBAAkB,EAAE,IAAI;YACxB,MAAM;YACN,OAAO,EAAE,EAAE;SACZ,CAAC,CAAC;IACL,CAAC;CAAA;AAhDD,kBAgDC"}
|
|
@@ -40,12 +40,12 @@ const anchor = __importStar(require("@coral-xyz/anchor"));
|
|
|
40
40
|
const helium_sub_daos_sdk_1 = require("@helium/helium-sub-daos-sdk");
|
|
41
41
|
const web3_js_1 = require("@solana/web3.js");
|
|
42
42
|
const sdk_1 = __importDefault(require("@sqds/sdk"));
|
|
43
|
+
const aws_sdk_1 = __importDefault(require("aws-sdk"));
|
|
43
44
|
const bn_js_1 = require("bn.js");
|
|
44
45
|
const os_1 = __importDefault(require("os"));
|
|
46
|
+
const pg_1 = require("pg");
|
|
45
47
|
const yargs_1 = __importDefault(require("yargs/yargs"));
|
|
46
48
|
const utils_1 = require("./utils");
|
|
47
|
-
const pg_1 = require("pg");
|
|
48
|
-
const aws_sdk_1 = __importDefault(require("aws-sdk"));
|
|
49
49
|
function run(args = process.argv) {
|
|
50
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
51
|
const yarg = (0, yargs_1.default)(args).options({
|
|
@@ -86,10 +86,10 @@ function run(args = process.argv) {
|
|
|
86
86
|
default: "postgres",
|
|
87
87
|
},
|
|
88
88
|
pgPassword: {
|
|
89
|
-
type: "string"
|
|
89
|
+
type: "string",
|
|
90
90
|
},
|
|
91
91
|
pgDatabase: {
|
|
92
|
-
type: "string"
|
|
92
|
+
type: "string",
|
|
93
93
|
},
|
|
94
94
|
pgHost: {
|
|
95
95
|
default: "localhost",
|
|
@@ -102,8 +102,8 @@ function run(args = process.argv) {
|
|
|
102
102
|
},
|
|
103
103
|
noSsl: {
|
|
104
104
|
type: "boolean",
|
|
105
|
-
default: false
|
|
106
|
-
}
|
|
105
|
+
default: false,
|
|
106
|
+
},
|
|
107
107
|
});
|
|
108
108
|
const argv = yield yarg.argv;
|
|
109
109
|
process.env.ANCHOR_WALLET = argv.wallet;
|
|
@@ -142,84 +142,110 @@ function run(args = process.argv) {
|
|
|
142
142
|
});
|
|
143
143
|
yield client.connect();
|
|
144
144
|
const response = (yield client.query(`WITH
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
145
|
+
readable_positions AS (
|
|
146
|
+
SELECT p.*,
|
|
147
|
+
r.realm_governing_token_mint,
|
|
148
|
+
cast(r.voting_mints[p.voting_mint_config_idx + 1]->>'lockupSaturationSecs' as numeric) as lockup_saturation_seconds,
|
|
149
|
+
cast(r.voting_mints[p.voting_mint_config_idx + 1]->>'maxExtraLockupVoteWeightScaledFactor' as numeric) / 1000000000 as max_extra_lockup_vote_weight_scaled_factor,
|
|
150
|
+
CASE WHEN p.genesis_end > current_ts THEN cast(r.voting_mints[p.voting_mint_config_idx + 1]->>'genesisVotePowerMultiplier' as numeric) ELSE 1 END as genesis_multiplier,
|
|
151
|
+
GREATEST(
|
|
151
152
|
cast(
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
)
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
153
|
+
p.end_ts -
|
|
154
|
+
CASE WHEN lockup_kind = 'constant' THEN start_ts ELSE current_ts END
|
|
155
|
+
as numeric
|
|
156
|
+
),
|
|
157
|
+
0
|
|
158
|
+
)
|
|
159
|
+
as seconds_remaining
|
|
160
|
+
FROM (
|
|
161
|
+
SELECT *,
|
|
162
|
+
lockup->>'kind' as lockup_kind,
|
|
163
|
+
cast(lockup->>'endTs' as numeric) as end_ts,
|
|
164
|
+
cast(lockup->>'startTs' as numeric) as start_ts,
|
|
165
|
+
-- 1682373334 as current_ts
|
|
166
|
+
FLOOR(EXTRACT(EPOCH FROM CURRENT_TIMESTAMP)) as current_ts
|
|
167
|
+
FROM positions
|
|
168
|
+
) p
|
|
169
|
+
JOIN registrars r on p.registrar = r.address
|
|
170
|
+
),
|
|
171
|
+
positions_with_vehnt AS (
|
|
172
|
+
SELECT realm_governing_token_mint as mint,
|
|
173
|
+
address,
|
|
174
|
+
num_active_votes,
|
|
175
|
+
registrar,
|
|
176
|
+
refreshed_at,
|
|
177
|
+
created_at,
|
|
178
|
+
amount_deposited_native,
|
|
179
|
+
ve_tokens,
|
|
180
|
+
initial_ve_tokens,
|
|
181
|
+
CASE WHEN lockup_kind = 'constant' THEN
|
|
182
|
+
0
|
|
183
|
+
ELSE
|
|
184
|
+
CASE WHEN current_ts < genesis_end THEN
|
|
185
|
+
-- genesis
|
|
186
|
+
(ve_tokens - (
|
|
187
|
+
amount_deposited_native * (
|
|
188
|
+
LEAST(
|
|
189
|
+
(end_ts - genesis_end) / lockup_saturation_seconds,
|
|
190
|
+
1
|
|
191
|
+
) * (
|
|
192
|
+
max_extra_lockup_vote_weight_scaled_factor
|
|
193
|
+
) * genesis_multiplier
|
|
194
|
+
)
|
|
195
|
+
)
|
|
196
|
+
) / (genesis_end - current_ts)
|
|
197
|
+
ELSE
|
|
198
|
+
-- normal
|
|
199
|
+
ve_tokens / (end_ts - current_ts)
|
|
200
|
+
END
|
|
201
|
+
END as fall_rate,
|
|
202
|
+
start_ts,
|
|
203
|
+
end_ts,
|
|
204
|
+
current_ts,
|
|
205
|
+
seconds_remaining
|
|
206
|
+
FROM (
|
|
207
|
+
SELECT *,
|
|
208
|
+
amount_deposited_native * (
|
|
209
|
+
(
|
|
210
|
+
max_extra_lockup_vote_weight_scaled_factor
|
|
211
|
+
) * genesis_multiplier * LEAST(
|
|
212
|
+
seconds_remaining / lockup_saturation_seconds,
|
|
213
|
+
1
|
|
214
|
+
)
|
|
215
|
+
) as ve_tokens,
|
|
216
|
+
amount_deposited_native * (
|
|
217
|
+
(
|
|
218
|
+
max_extra_lockup_vote_weight_scaled_factor
|
|
219
|
+
) * genesis_multiplier * LEAST(
|
|
220
|
+
(end_ts - start_ts) / lockup_saturation_seconds,
|
|
221
|
+
1
|
|
214
222
|
)
|
|
215
|
-
)
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
+
) as initial_ve_tokens
|
|
224
|
+
FROM readable_positions
|
|
225
|
+
) a
|
|
226
|
+
),
|
|
227
|
+
subdao_delegations AS (
|
|
228
|
+
SELECT
|
|
229
|
+
count(*) as delegations,
|
|
230
|
+
min(current_ts) as current_ts,
|
|
231
|
+
sum(p.fall_rate) as real_fall_rate,
|
|
232
|
+
s.vehnt_fall_rate / 1000000000000 as approx_fall_rate,
|
|
233
|
+
s.dnt_mint as mint,
|
|
234
|
+
SUM(ve_tokens) as real_ve_tokens,
|
|
235
|
+
(
|
|
236
|
+
s.vehnt_delegated - (
|
|
237
|
+
(min(current_ts) - s.vehnt_last_calculated_ts)
|
|
238
|
+
* s.vehnt_fall_rate
|
|
239
|
+
)
|
|
240
|
+
) / 1000000000000 as approx_ve_tokens,
|
|
241
|
+
s.vehnt_delegated as vehnt_delegated_snapshot,
|
|
242
|
+
s.vehnt_last_calculated_ts as vehnt_last_calculated_ts
|
|
243
|
+
FROM positions_with_vehnt p
|
|
244
|
+
JOIN delegated_positions d on d.position = p.address
|
|
245
|
+
JOIN sub_daos s on s.address = d.sub_dao
|
|
246
|
+
WHERE end_ts > (floor(current_ts / (60 * 60 * 24)) * (60 * 60 * 24)) + 60 * 60 * 24
|
|
247
|
+
GROUP BY s.dnt_mint, s.vehnt_fall_rate, s.vehnt_delegated, s.vehnt_last_calculated_ts, s.vehnt_last_calculated_ts
|
|
248
|
+
)
|
|
223
249
|
SELECT
|
|
224
250
|
mint,
|
|
225
251
|
current_ts,
|
|
@@ -232,7 +258,6 @@ function run(args = process.argv) {
|
|
|
232
258
|
approx_ve_tokens - real_ve_tokens as ve_tokens_diff
|
|
233
259
|
FROM subdao_delegations`)).rows;
|
|
234
260
|
const row = response.find((x) => x.mint == argv.dntMint);
|
|
235
|
-
console.log("Setting", row);
|
|
236
261
|
const instructions = [];
|
|
237
262
|
const subDao = (0, helium_sub_daos_sdk_1.subDaoKey)(new web3_js_1.PublicKey(argv.dntMint))[0];
|
|
238
263
|
const subDaoAcc = yield program.account.subDaoV0.fetch(subDao);
|
|
@@ -249,7 +274,7 @@ function run(args = process.argv) {
|
|
|
249
274
|
})
|
|
250
275
|
.instruction());
|
|
251
276
|
const squads = sdk_1.default.endpoint(process.env.ANCHOR_PROVIDER_URL, provider.wallet, {
|
|
252
|
-
commitmentOrConfig: "finalized"
|
|
277
|
+
commitmentOrConfig: "finalized",
|
|
253
278
|
});
|
|
254
279
|
yield (0, utils_1.sendInstructionsOrSquads)({
|
|
255
280
|
provider,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-subdao-vehnt.js","sourceRoot":"","sources":["../../src/update-subdao-vehnt.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAA4C;AAC5C,qEAGqC;AACrC,6CAA4C;AAC5C,oDAA+B;AAC/B,iCAA2B;AAC3B,4CAAoB;AACpB,wDAAgC;AAChC,
|
|
1
|
+
{"version":3,"file":"update-subdao-vehnt.js","sourceRoot":"","sources":["../../src/update-subdao-vehnt.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAA4C;AAC5C,qEAGqC;AACrC,6CAA4C;AAC5C,oDAA+B;AAC/B,sDAA0B;AAC1B,iCAA2B;AAC3B,4CAAoB;AACpB,2BAA4B;AAC5B,wDAAgC;AAChC,mCAAmD;AAGnD,SAAsB,GAAG,CAAC,OAAY,OAAO,CAAC,IAAI;;QAChD,MAAM,IAAI,GAAG,IAAA,eAAK,EAAC,IAAI,CAAC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D,CAAC;aACD,QAAQ,CAAC;YACR,MAAM;YACN,SAAS,EAAE,SAAS,CAAC,SAAS;SAC/B,CAAC;aACD,WAAW,EAAE,CACjB,CAAC;QAEF,MAAM,MAAM,GAAG,aAAM,CAAC,QAAQ,CAC5B,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAC/B,QAAQ,CAAC,MAAM,EACf;YACE,kBAAkB,EAAE,WAAW;SAChC,CACF,CAAC;QACF,MAAM,IAAA,gCAAwB,EAAC;YAC7B,QAAQ;YACR,YAAY;YACZ,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;AA9PD,kBA8PC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
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 web3_js_1 = require("@solana/web3.js");
|
|
41
|
+
const sdk_1 = __importDefault(require("@sqds/sdk"));
|
|
42
|
+
const os_1 = __importDefault(require("os"));
|
|
43
|
+
const yargs_1 = __importDefault(require("yargs/yargs"));
|
|
44
|
+
const utils_1 = require("./utils");
|
|
45
|
+
function run(args = process.argv) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
const yarg = (0, yargs_1.default)(args).options({
|
|
48
|
+
wallet: {
|
|
49
|
+
alias: "k",
|
|
50
|
+
describe: "Anchor wallet keypair",
|
|
51
|
+
default: `${os_1.default.homedir()}/.config/solana/id.json`,
|
|
52
|
+
},
|
|
53
|
+
url: {
|
|
54
|
+
alias: "u",
|
|
55
|
+
default: "http://127.0.0.1:8899",
|
|
56
|
+
describe: "The solana url",
|
|
57
|
+
},
|
|
58
|
+
executeTransaction: {
|
|
59
|
+
type: "boolean",
|
|
60
|
+
},
|
|
61
|
+
multisig: {
|
|
62
|
+
type: "string",
|
|
63
|
+
describe: "Address of the squads multisig to be authority. If not provided, your wallet will be the authority",
|
|
64
|
+
},
|
|
65
|
+
authorityIndex: {
|
|
66
|
+
type: "number",
|
|
67
|
+
describe: "Authority index for squads. Defaults to 1",
|
|
68
|
+
default: 1,
|
|
69
|
+
},
|
|
70
|
+
programId: {
|
|
71
|
+
type: "string",
|
|
72
|
+
required: true,
|
|
73
|
+
},
|
|
74
|
+
bufferId: {
|
|
75
|
+
type: "string",
|
|
76
|
+
required: true
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
const argv = yield yarg.argv;
|
|
80
|
+
process.env.ANCHOR_WALLET = argv.wallet;
|
|
81
|
+
process.env.ANCHOR_PROVIDER_URL = argv.url;
|
|
82
|
+
anchor.setProvider(anchor.AnchorProvider.local(argv.url));
|
|
83
|
+
const provider = anchor.getProvider();
|
|
84
|
+
const connection = provider.connection;
|
|
85
|
+
const squads = sdk_1.default.endpoint(process.env.ANCHOR_PROVIDER_URL, provider.wallet, {
|
|
86
|
+
commitmentOrConfig: "finalized",
|
|
87
|
+
});
|
|
88
|
+
let authority = provider.wallet.publicKey;
|
|
89
|
+
let multisig = argv.multisig ? new web3_js_1.PublicKey(argv.multisig) : null;
|
|
90
|
+
if (multisig) {
|
|
91
|
+
authority = squads.getAuthorityPDA(multisig, argv.authorityIndex);
|
|
92
|
+
}
|
|
93
|
+
console.log(authority.toBase58());
|
|
94
|
+
yield (0, utils_1.sendInstructionsOrSquads)({
|
|
95
|
+
provider,
|
|
96
|
+
instructions: [
|
|
97
|
+
yield (0, utils_1.createIdlUpgradeInstruction)(new web3_js_1.PublicKey(argv.programId), new web3_js_1.PublicKey(argv.bufferId), authority)
|
|
98
|
+
],
|
|
99
|
+
executeTransaction: argv.executeTransaction,
|
|
100
|
+
squads,
|
|
101
|
+
multisig: argv.multisig ? new web3_js_1.PublicKey(argv.multisig) : undefined,
|
|
102
|
+
authorityIndex: argv.authorityIndex,
|
|
103
|
+
signers: [],
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
exports.run = run;
|
|
108
|
+
//# sourceMappingURL=upgrade-idl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upgrade-idl.js","sourceRoot":"","sources":["../../src/upgrade-idl.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAA4C;AAC5C,6CAA4C;AAC5C,oDAA+B;AAC/B,4CAAoB;AACpB,wDAAgC;AAChC,mCAIiB;AAIjB,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,kBAAkB,EAAE;gBAClB,IAAI,EAAE,SAAS;aAChB;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,QAAQ,EACN,oGAAoG;aACvG;YACD,cAAc,EAAE;gBACd,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,2CAA2C;gBACrD,OAAO,EAAE,CAAC;aACX;YACD,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,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,EAC5B,SAAS,CACV;aACF;YACD,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;AApED,kBAoEC"}
|
package/lib/cjs/utils.js
CHANGED
|
@@ -35,8 +35,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.parseEmissionsSchedule = exports.sendInstructionsOrSquads = exports.createSwitchboardAggregator = exports.sendInstructionsOrCreateProposal = exports.isLocalhost = exports.loadKeypair = exports.createAndMint = exports.exists = exports.getUnixTimestamp = exports.getTimestampFromDays = void 0;
|
|
38
|
+
exports.parseEmissionsSchedule = exports.sendInstructionsOrSquads = exports.createCloseBufferInstruction = exports.createSwitchboardAggregator = exports.sendInstructionsOrCreateProposal = exports.isLocalhost = exports.loadKeypair = exports.createAndMint = exports.exists = exports.getUnixTimestamp = exports.getTimestampFromDays = exports.createIdlUpgradeInstruction = void 0;
|
|
39
39
|
const anchor = __importStar(require("@coral-xyz/anchor"));
|
|
40
|
+
const idl_1 = require("@coral-xyz/anchor/dist/cjs/idl");
|
|
40
41
|
const spl_utils_1 = require("@helium/spl-utils");
|
|
41
42
|
const mpl_token_metadata_1 = require("@metaplex-foundation/mpl-token-metadata");
|
|
42
43
|
const spl_governance_1 = require("@solana/spl-governance");
|
|
@@ -48,6 +49,37 @@ const bn_js_1 = require("bn.js");
|
|
|
48
49
|
const fs_1 = __importDefault(require("fs"));
|
|
49
50
|
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
50
51
|
const SECONDS_PER_DAY = 86400;
|
|
52
|
+
function createIdlUpgradeInstruction(programId, bufferAddress, upgradeAuthority) {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
const prefix = Buffer.from("0a69e9a778bcf440", "hex");
|
|
55
|
+
const ixn = Buffer.from("03", "hex");
|
|
56
|
+
const data = Buffer.concat([prefix.reverse(), ixn]);
|
|
57
|
+
const idlAddr = yield (0, idl_1.idlAddress)(programId);
|
|
58
|
+
const keys = [
|
|
59
|
+
{
|
|
60
|
+
pubkey: bufferAddress,
|
|
61
|
+
isWritable: true,
|
|
62
|
+
isSigner: false,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
pubkey: idlAddr,
|
|
66
|
+
isWritable: true,
|
|
67
|
+
isSigner: false,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
pubkey: upgradeAuthority,
|
|
71
|
+
isWritable: true,
|
|
72
|
+
isSigner: true,
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
return new web3_js_1.TransactionInstruction({
|
|
76
|
+
keys,
|
|
77
|
+
programId,
|
|
78
|
+
data,
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
exports.createIdlUpgradeInstruction = createIdlUpgradeInstruction;
|
|
51
83
|
const getTimestampFromDays = (days) => days * SECONDS_PER_DAY;
|
|
52
84
|
exports.getTimestampFromDays = getTimestampFromDays;
|
|
53
85
|
const getUnixTimestamp = (provider) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -62,6 +94,19 @@ function exists(connection, account) {
|
|
|
62
94
|
});
|
|
63
95
|
}
|
|
64
96
|
exports.exists = exists;
|
|
97
|
+
function withRetries(tries, input) {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
for (let i = 0; i < tries; i++) {
|
|
100
|
+
try {
|
|
101
|
+
return yield input();
|
|
102
|
+
}
|
|
103
|
+
catch (e) {
|
|
104
|
+
console.log(`Retrying ${i}...`, e);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
throw new Error("Failed after retries");
|
|
108
|
+
});
|
|
109
|
+
}
|
|
65
110
|
function createAndMint({ provider, mintKeypair = web3_js_1.Keypair.generate(), amount, metadataUrl, decimals = 8, to, mintAuthority = provider.wallet.publicKey, freezeAuthority = provider.wallet.publicKey, updateAuthority = provider.wallet.publicKey, }) {
|
|
66
111
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
112
|
const mintTo = to || provider.wallet.publicKey;
|
|
@@ -306,6 +351,45 @@ function createSwitchboardAggregator({ provider, aggKeypair, url, switchboardNet
|
|
|
306
351
|
});
|
|
307
352
|
}
|
|
308
353
|
exports.createSwitchboardAggregator = createSwitchboardAggregator;
|
|
354
|
+
function createCloseBufferInstruction(programId, bufferAddress, upgradeAuthority, recipientAddress) {
|
|
355
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
356
|
+
const bpfUpgradableLoaderId = spl_governance_1.BPF_UPGRADE_LOADER_ID;
|
|
357
|
+
const [programDataAddress] = yield web3_js_1.PublicKey.findProgramAddress([programId.toBuffer()], bpfUpgradableLoaderId);
|
|
358
|
+
const keys = [
|
|
359
|
+
{
|
|
360
|
+
pubkey: bufferAddress,
|
|
361
|
+
isWritable: true,
|
|
362
|
+
isSigner: false,
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
pubkey: recipientAddress,
|
|
366
|
+
isWritable: true,
|
|
367
|
+
isSigner: false,
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
pubkey: upgradeAuthority,
|
|
371
|
+
isWritable: false,
|
|
372
|
+
isSigner: true,
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
pubkey: programDataAddress,
|
|
376
|
+
isWritable: false,
|
|
377
|
+
isSigner: false,
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
pubkey: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
381
|
+
isWritable: false,
|
|
382
|
+
isSigner: false,
|
|
383
|
+
},
|
|
384
|
+
];
|
|
385
|
+
return new web3_js_1.TransactionInstruction({
|
|
386
|
+
keys,
|
|
387
|
+
programId: bpfUpgradableLoaderId,
|
|
388
|
+
data: Buffer.from([5, 0, 0, 0]), // Upgrade instruction bincode
|
|
389
|
+
});
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
exports.createCloseBufferInstruction = createCloseBufferInstruction;
|
|
309
393
|
function sendInstructionsOrSquads({ provider, instructions, signers = [], payer = provider.wallet.publicKey, commitment = "confirmed", idlErrors = new Map(), executeTransaction = false, squads, multisig, authorityIndex, }) {
|
|
310
394
|
return __awaiter(this, void 0, void 0, function* () {
|
|
311
395
|
if (!multisig) {
|
|
@@ -326,11 +410,11 @@ function sendInstructionsOrSquads({ provider, instructions, signers = [], payer
|
|
|
326
410
|
}
|
|
327
411
|
const tx = yield squads.createTransaction(multisig, authorityIndex);
|
|
328
412
|
for (const ix of instructions.filter(ix => !ix.programId.equals(web3_js_1.ComputeBudgetProgram.programId))) {
|
|
329
|
-
yield squads.addInstruction(tx.publicKey, ix);
|
|
413
|
+
yield withRetries(3, () => __awaiter(this, void 0, void 0, function* () { return yield squads.addInstruction(tx.publicKey, ix); }));
|
|
330
414
|
}
|
|
331
|
-
yield squads.activateTransaction(tx.publicKey);
|
|
415
|
+
yield withRetries(3, () => __awaiter(this, void 0, void 0, function* () { return yield squads.activateTransaction(tx.publicKey); }));
|
|
416
|
+
yield withRetries(3, () => __awaiter(this, void 0, void 0, function* () { return yield squads.approveTransaction(tx.publicKey); }));
|
|
332
417
|
if (executeTransaction) {
|
|
333
|
-
yield squads.approveTransaction(tx.publicKey);
|
|
334
418
|
const ix = yield squads.buildExecuteTransaction(tx.publicKey, provider.wallet.publicKey);
|
|
335
419
|
yield (0, spl_utils_1.sendInstructions)(provider, [web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: 800000 }), ix], signers);
|
|
336
420
|
}
|