@helium/automation-hooks 0.10.7
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 +203 -0
- package/lib/cjs/hooks/index.js +10 -0
- package/lib/cjs/hooks/index.js.map +1 -0
- package/lib/cjs/hooks/useAutomateHotspotClaims.js +267 -0
- package/lib/cjs/hooks/useAutomateHotspotClaims.js.map +1 -0
- package/lib/cjs/hooks/useCronJob.js +7 -0
- package/lib/cjs/hooks/useCronJob.js.map +1 -0
- package/lib/cjs/hooks/useTaskQueue.js +7 -0
- package/lib/cjs/hooks/useTaskQueue.js.map +1 -0
- package/lib/cjs/index.js +18 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/esm/src/hooks/index.js +4 -0
- package/lib/esm/src/hooks/index.js.map +1 -0
- package/lib/esm/src/hooks/useAutomateHotspotClaims.js +252 -0
- package/lib/esm/src/hooks/useAutomateHotspotClaims.js.map +1 -0
- package/lib/esm/src/hooks/useCronJob.js +3 -0
- package/lib/esm/src/hooks/useCronJob.js.map +1 -0
- package/lib/esm/src/hooks/useTaskQueue.js +3 -0
- package/lib/esm/src/hooks/useTaskQueue.js.map +1 -0
- package/lib/esm/src/index.js +2 -0
- package/lib/esm/src/index.js.map +1 -0
- package/lib/esm/tsconfig.esm.tsbuildinfo +1 -0
- package/lib/types/src/hooks/index.d.ts +4 -0
- package/lib/types/src/hooks/index.d.ts.map +1 -0
- package/lib/types/src/hooks/useAutomateHotspotClaims.d.ts +53 -0
- package/lib/types/src/hooks/useAutomateHotspotClaims.d.ts.map +1 -0
- package/lib/types/src/hooks/useCronJob.d.ts +21 -0
- package/lib/types/src/hooks/useCronJob.d.ts.map +1 -0
- package/lib/types/src/hooks/useTaskQueue.d.ts +23 -0
- package/lib/types/src/hooks/useTaskQueue.d.ts.map +1 -0
- package/lib/types/src/index.d.ts +2 -0
- package/lib/types/src/index.d.ts.map +1 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2020 Helium Systems, Inc.
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
203
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useTaskQueue = exports.useCronJob = exports.useAutomateHotspotClaims = void 0;
|
|
4
|
+
var useAutomateHotspotClaims_1 = require("./useAutomateHotspotClaims");
|
|
5
|
+
Object.defineProperty(exports, "useAutomateHotspotClaims", { enumerable: true, get: function () { return useAutomateHotspotClaims_1.useAutomateHotspotClaims; } });
|
|
6
|
+
var useCronJob_1 = require("./useCronJob");
|
|
7
|
+
Object.defineProperty(exports, "useCronJob", { enumerable: true, get: function () { return useCronJob_1.useCronJob; } });
|
|
8
|
+
var useTaskQueue_1 = require("./useTaskQueue");
|
|
9
|
+
Object.defineProperty(exports, "useTaskQueue", { enumerable: true, get: function () { return useTaskQueue_1.useTaskQueue; } });
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":";;;AACA,uEAAsE;AAA7D,oIAAA,wBAAwB,OAAA;AACjC,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,+CAA8C;AAArC,4GAAA,YAAY,OAAA"}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.useAutomateHotspotClaims = exports.interpretCronString = void 0;
|
|
13
|
+
const cron_sdk_1 = require("@helium/cron-sdk");
|
|
14
|
+
const helium_react_hooks_1 = require("@helium/helium-react-hooks");
|
|
15
|
+
const hpl_crons_sdk_1 = require("@helium/hpl-crons-sdk");
|
|
16
|
+
const spl_utils_1 = require("@helium/spl-utils");
|
|
17
|
+
const tuktuk_sdk_1 = require("@helium/tuktuk-sdk");
|
|
18
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
19
|
+
const react_1 = require("react");
|
|
20
|
+
const react_async_hook_1 = require("react-async-hook");
|
|
21
|
+
const useCronJob_1 = require("./useCronJob");
|
|
22
|
+
const useTaskQueue_1 = require("./useTaskQueue");
|
|
23
|
+
const TASK_QUEUE = new web3_js_1.PublicKey('H39gEszvsi6AT4rYBiJTuZHJSF5hMHy6CKGTd7wzhsg7');
|
|
24
|
+
const getScheduleCronString = (schedule) => {
|
|
25
|
+
// Get current time and add 1 minute
|
|
26
|
+
const now = new Date();
|
|
27
|
+
now.setMinutes(now.getMinutes() + 1);
|
|
28
|
+
// Convert to UTC
|
|
29
|
+
const utcSeconds = now.getUTCSeconds();
|
|
30
|
+
const utcMinutes = now.getUTCMinutes();
|
|
31
|
+
const utcHours = now.getUTCHours();
|
|
32
|
+
const utcDayOfMonth = now.getUTCDate();
|
|
33
|
+
const utcDayOfWeek = now.getUTCDay();
|
|
34
|
+
switch (schedule) {
|
|
35
|
+
case 'daily':
|
|
36
|
+
// Run at the same hour and minute every day in UTC
|
|
37
|
+
return `${utcSeconds} ${utcMinutes} ${utcHours} * * *`;
|
|
38
|
+
case 'weekly':
|
|
39
|
+
// Run at the same hour and minute on the same day of week in UTC
|
|
40
|
+
return `${utcSeconds} ${utcMinutes} ${utcHours} * * ${utcDayOfWeek}`;
|
|
41
|
+
case 'monthly':
|
|
42
|
+
// Run at the same hour and minute on the same day of month in UTC
|
|
43
|
+
return `${utcSeconds} ${utcMinutes} ${utcHours} ${utcDayOfMonth} * *`;
|
|
44
|
+
default:
|
|
45
|
+
return `${utcSeconds} ${utcMinutes} ${utcHours} * * *`;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const interpretCronString = (cronString) => {
|
|
49
|
+
const [seconds, minutes, hours, dayOfMonth, month, dayOfWeek] = cronString.split(' ');
|
|
50
|
+
// Create a UTC date object for the next run time
|
|
51
|
+
const now = new Date();
|
|
52
|
+
const nextRunUTC = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), parseInt(hours, 10), parseInt(minutes, 10), parseInt(seconds, 10)));
|
|
53
|
+
// Convert UTC to local time for display
|
|
54
|
+
const nextRun = new Date(nextRunUTC);
|
|
55
|
+
// Format time as HH:MM AM/PM in local time
|
|
56
|
+
const timeStr = nextRun.toLocaleTimeString('en-US', {
|
|
57
|
+
hour: 'numeric',
|
|
58
|
+
minute: '2-digit',
|
|
59
|
+
hour12: true,
|
|
60
|
+
});
|
|
61
|
+
// Determine schedule type
|
|
62
|
+
let schedule;
|
|
63
|
+
if (dayOfMonth !== '*' && month === '*') {
|
|
64
|
+
schedule = 'monthly';
|
|
65
|
+
// If the day has already passed this month, move to next month
|
|
66
|
+
if (now.getUTCDate() > parseInt(dayOfMonth, 10)) {
|
|
67
|
+
nextRunUTC.setUTCMonth(nextRunUTC.getUTCMonth() + 1);
|
|
68
|
+
}
|
|
69
|
+
nextRunUTC.setUTCDate(parseInt(dayOfMonth, 10));
|
|
70
|
+
nextRun.setTime(nextRunUTC.getTime());
|
|
71
|
+
}
|
|
72
|
+
else if (dayOfWeek !== '*') {
|
|
73
|
+
schedule = 'weekly';
|
|
74
|
+
// Calculate days until next occurrence
|
|
75
|
+
const currentDay = now.getUTCDay();
|
|
76
|
+
const targetDay = parseInt(dayOfWeek, 10);
|
|
77
|
+
const daysUntil = targetDay - currentDay;
|
|
78
|
+
nextRunUTC.setUTCDate(now.getUTCDate() + (daysUntil >= 0 ? daysUntil : 7 + daysUntil));
|
|
79
|
+
nextRun.setTime(nextRunUTC.getTime());
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
schedule = 'daily';
|
|
83
|
+
// If time has already passed today in UTC, move to tomorrow
|
|
84
|
+
if (now > nextRun) {
|
|
85
|
+
nextRunUTC.setUTCDate(nextRunUTC.getUTCDate() + 1);
|
|
86
|
+
nextRun.setTime(nextRunUTC.getTime());
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
schedule,
|
|
91
|
+
time: timeStr,
|
|
92
|
+
nextRun,
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
exports.interpretCronString = interpretCronString;
|
|
96
|
+
const BASE_AUTOMATION_RENT = 0.012588199;
|
|
97
|
+
const useAutomateHotspotClaims = ({ schedule, duration, totalHotspots, wallet, provider: providerRaw }) => {
|
|
98
|
+
const providerFromHook = (0, helium_react_hooks_1.useAnchorProvider)();
|
|
99
|
+
const provider = providerRaw || providerFromHook;
|
|
100
|
+
const authority = (0, react_1.useMemo)(() => {
|
|
101
|
+
if (!wallet)
|
|
102
|
+
return undefined;
|
|
103
|
+
return (0, hpl_crons_sdk_1.entityCronAuthorityKey)(wallet)[0];
|
|
104
|
+
}, [wallet]);
|
|
105
|
+
const cronJob = (0, react_1.useMemo)(() => {
|
|
106
|
+
if (!authority)
|
|
107
|
+
return undefined;
|
|
108
|
+
return (0, cron_sdk_1.cronJobKey)(authority, 0)[0];
|
|
109
|
+
}, [authority]);
|
|
110
|
+
const { amount: userSol, loading: loadingSol } = (0, helium_react_hooks_1.useSolOwnedAmount)(wallet);
|
|
111
|
+
const { info: cronJobAccount, account: cronJobSolanaAccount } = (0, useCronJob_1.useCronJob)(cronJob);
|
|
112
|
+
const { info: taskQueue } = (0, useTaskQueue_1.useTaskQueue)(TASK_QUEUE);
|
|
113
|
+
const totalFundingNeeded = (0, react_1.useMemo)(() => {
|
|
114
|
+
var _a;
|
|
115
|
+
const minCrankReward = ((_a = taskQueue === null || taskQueue === void 0 ? void 0 : taskQueue.minCrankReward) === null || _a === void 0 ? void 0 : _a.toNumber()) || 10000;
|
|
116
|
+
return (duration * (minCrankReward + 5000) * (totalHotspots || 1) +
|
|
117
|
+
duration * minCrankReward);
|
|
118
|
+
}, [duration, totalHotspots, taskQueue]);
|
|
119
|
+
const solFee = (0, react_1.useMemo)(() => {
|
|
120
|
+
return totalFundingNeeded - ((cronJobSolanaAccount === null || cronJobSolanaAccount === void 0 ? void 0 : cronJobSolanaAccount.lamports) || 0);
|
|
121
|
+
}, [totalFundingNeeded, cronJobSolanaAccount]);
|
|
122
|
+
const { loading, error, execute } = (0, react_async_hook_1.useAsyncCallback)((params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
123
|
+
if (!provider || !authority || !cronJob || !wallet) {
|
|
124
|
+
throw new Error('Missing required parameters');
|
|
125
|
+
}
|
|
126
|
+
const hplCronsProgram = yield (0, hpl_crons_sdk_1.init)(provider);
|
|
127
|
+
const tuktukProgram = yield (0, tuktuk_sdk_1.init)(provider);
|
|
128
|
+
const taskQueueAcc = yield tuktukProgram.account.taskQueueV0.fetch(TASK_QUEUE);
|
|
129
|
+
const nextAvailable = (0, tuktuk_sdk_1.nextAvailableTaskIds)(taskQueueAcc.taskBitmap, 1, false)[0];
|
|
130
|
+
const [task] = (0, tuktuk_sdk_1.taskKey)(TASK_QUEUE, nextAvailable);
|
|
131
|
+
const instructions = [];
|
|
132
|
+
// If cronJob doesn't exist or schedule changed, create/recreate it
|
|
133
|
+
if (!cronJobAccount ||
|
|
134
|
+
(cronJobAccount.schedule &&
|
|
135
|
+
(0, exports.interpretCronString)(cronJobAccount.schedule).schedule !== schedule)) {
|
|
136
|
+
// If it exists but schedule changed, remove it first
|
|
137
|
+
if (cronJobAccount) {
|
|
138
|
+
const maxTxId = cronJobAccount.nextTransactionId || 0;
|
|
139
|
+
const txIds = Array.from({ length: maxTxId }, (_, i) => i);
|
|
140
|
+
instructions.push(...(yield Promise.all(txIds.map((txId) => hplCronsProgram.methods
|
|
141
|
+
.removeEntityFromCronV0({
|
|
142
|
+
index: txId,
|
|
143
|
+
})
|
|
144
|
+
.accounts({
|
|
145
|
+
cronJob,
|
|
146
|
+
rentRefund: wallet,
|
|
147
|
+
cronJobTransaction: (0, cron_sdk_1.cronJobTransactionKey)(cronJob, txId)[0],
|
|
148
|
+
})
|
|
149
|
+
.instruction()))), yield hplCronsProgram.methods
|
|
150
|
+
.closeEntityClaimCronV0()
|
|
151
|
+
.accounts({
|
|
152
|
+
cronJob,
|
|
153
|
+
rentRefund: wallet,
|
|
154
|
+
cronJobNameMapping: (0, cron_sdk_1.cronJobNameMappingKey)(authority, 'entity_claim')[0],
|
|
155
|
+
})
|
|
156
|
+
.instruction());
|
|
157
|
+
}
|
|
158
|
+
// Create new cron job
|
|
159
|
+
instructions.push(yield hplCronsProgram.methods
|
|
160
|
+
.initEntityClaimCronV0({
|
|
161
|
+
schedule: getScheduleCronString(schedule),
|
|
162
|
+
})
|
|
163
|
+
.accounts({
|
|
164
|
+
taskQueue: TASK_QUEUE,
|
|
165
|
+
cronJob,
|
|
166
|
+
task,
|
|
167
|
+
cronJobNameMapping: (0, cron_sdk_1.cronJobNameMappingKey)(authority, 'entity_claim')[0],
|
|
168
|
+
})
|
|
169
|
+
.instruction());
|
|
170
|
+
}
|
|
171
|
+
else if (cronJobAccount === null || cronJobAccount === void 0 ? void 0 : cronJobAccount.removedFromQueue) {
|
|
172
|
+
// If cron exists but was removed from queue due to insufficient SOL, requeue it
|
|
173
|
+
instructions.push(yield hplCronsProgram.methods
|
|
174
|
+
.requeueEntityClaimCronV0()
|
|
175
|
+
.accounts({
|
|
176
|
+
taskQueue: TASK_QUEUE,
|
|
177
|
+
cronJob,
|
|
178
|
+
task,
|
|
179
|
+
cronJobNameMapping: (0, cron_sdk_1.cronJobNameMappingKey)(authority, 'entity_claim')[0],
|
|
180
|
+
})
|
|
181
|
+
.instruction());
|
|
182
|
+
}
|
|
183
|
+
// Add SOL if needed
|
|
184
|
+
if (solFee > 0) {
|
|
185
|
+
instructions.push(web3_js_1.SystemProgram.transfer({
|
|
186
|
+
fromPubkey: wallet,
|
|
187
|
+
toPubkey: cronJob,
|
|
188
|
+
lamports: solFee,
|
|
189
|
+
}));
|
|
190
|
+
}
|
|
191
|
+
// Add the entity to the cron job if it's new
|
|
192
|
+
if (!cronJobAccount) {
|
|
193
|
+
const { instruction } = yield hplCronsProgram.methods
|
|
194
|
+
.addWalletToEntityCronV0({
|
|
195
|
+
index: 0,
|
|
196
|
+
})
|
|
197
|
+
.accounts({
|
|
198
|
+
wallet,
|
|
199
|
+
cronJob,
|
|
200
|
+
cronJobTransaction: (0, cron_sdk_1.cronJobTransactionKey)(cronJob, 0)[0],
|
|
201
|
+
})
|
|
202
|
+
.prepare();
|
|
203
|
+
instructions.push(instruction);
|
|
204
|
+
}
|
|
205
|
+
if (params.onInstructions) {
|
|
206
|
+
yield params.onInstructions(instructions);
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
yield (0, spl_utils_1.sendInstructionsWithPriorityFee)(provider, instructions, {
|
|
210
|
+
computeUnitLimit: 500000,
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}));
|
|
214
|
+
const { execute: remove, loading: removing, error: removeError, } = (0, react_async_hook_1.useAsyncCallback)((params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
215
|
+
if (!provider || !cronJob || !authority || !wallet) {
|
|
216
|
+
throw new Error('Missing required parameters');
|
|
217
|
+
}
|
|
218
|
+
const hplCronsProgram = yield (0, hpl_crons_sdk_1.init)(provider);
|
|
219
|
+
const maxTxId = (cronJobAccount === null || cronJobAccount === void 0 ? void 0 : cronJobAccount.nextTransactionId) || 0;
|
|
220
|
+
const txIds = Array.from({ length: maxTxId }, (_, i) => i);
|
|
221
|
+
const instructions = [
|
|
222
|
+
...(yield Promise.all(txIds.map((txId) => hplCronsProgram.methods
|
|
223
|
+
.removeEntityFromCronV0({
|
|
224
|
+
index: txId,
|
|
225
|
+
})
|
|
226
|
+
.accounts({
|
|
227
|
+
cronJob,
|
|
228
|
+
rentRefund: wallet,
|
|
229
|
+
cronJobTransaction: (0, cron_sdk_1.cronJobTransactionKey)(cronJob, txId)[0],
|
|
230
|
+
})
|
|
231
|
+
.instruction()))),
|
|
232
|
+
yield hplCronsProgram.methods
|
|
233
|
+
.closeEntityClaimCronV0()
|
|
234
|
+
.accounts({
|
|
235
|
+
cronJob,
|
|
236
|
+
rentRefund: wallet,
|
|
237
|
+
cronJobNameMapping: (0, cron_sdk_1.cronJobNameMappingKey)(authority, 'entity_claim')[0],
|
|
238
|
+
})
|
|
239
|
+
.instruction(),
|
|
240
|
+
];
|
|
241
|
+
if (params.onInstructions) {
|
|
242
|
+
yield params.onInstructions(instructions);
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
yield (0, spl_utils_1.sendInstructionsWithPriorityFee)(provider, instructions, {
|
|
246
|
+
computeUnitLimit: 500000,
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
}));
|
|
250
|
+
return {
|
|
251
|
+
loading: loading || removing,
|
|
252
|
+
error: error || removeError,
|
|
253
|
+
execute,
|
|
254
|
+
remove,
|
|
255
|
+
hasExistingAutomation: !!cronJobAccount && !cronJobAccount.removedFromQueue,
|
|
256
|
+
cron: cronJobAccount,
|
|
257
|
+
currentSchedule: (cronJobAccount === null || cronJobAccount === void 0 ? void 0 : cronJobAccount.schedule)
|
|
258
|
+
? (0, exports.interpretCronString)(cronJobAccount.schedule)
|
|
259
|
+
: undefined,
|
|
260
|
+
rentFee: cronJobAccount ? 0 : BASE_AUTOMATION_RENT,
|
|
261
|
+
solFee: solFee / web3_js_1.LAMPORTS_PER_SOL,
|
|
262
|
+
insufficientSol: !loadingSol && solFee > (userSol || 0),
|
|
263
|
+
isOutOfSol: (cronJobAccount === null || cronJobAccount === void 0 ? void 0 : cronJobAccount.removedFromQueue) || false,
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
exports.useAutomateHotspotClaims = useAutomateHotspotClaims;
|
|
267
|
+
//# sourceMappingURL=useAutomateHotspotClaims.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAutomateHotspotClaims.js","sourceRoot":"","sources":["../../../src/hooks/useAutomateHotspotClaims.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAIyB;AACzB,mEAAiF;AACjF,yDAG8B;AAC9B,iDAAmE;AACnE,mDAI2B;AAC3B,6CAKwB;AACxB,iCAA+B;AAC/B,uDAAmD;AACnD,6CAAyC;AACzC,iDAA6C;AAK7C,MAAM,UAAU,GAAG,IAAI,mBAAS,CAAC,8CAA8C,CAAC,CAAA;AAEhF,MAAM,qBAAqB,GAAG,CAAC,QAAkB,EAAE,EAAE;IACnD,oCAAoC;IACpC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;IACtB,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAA;IAEpC,iBAAiB;IACjB,MAAM,UAAU,GAAG,GAAG,CAAC,aAAa,EAAE,CAAA;IACtC,MAAM,UAAU,GAAG,GAAG,CAAC,aAAa,EAAE,CAAA;IACtC,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAE,CAAA;IAClC,MAAM,aAAa,GAAG,GAAG,CAAC,UAAU,EAAE,CAAA;IACtC,MAAM,YAA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B,EACvC,SAAS,EACT,cAAc,CACf,CAAC,CAAC,CAAC;aACL,CAAC;iBACD,WAAW,EAAE;SACjB,CAAA;QAED,IAAI,MAAM,CAAC,cAAc,EAAE;YACzB,MAAM,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,CAAA;SAC1C;aAAM;YACL,MAAM,IAAA,2CAA+B,EAAC,QAAQ,EAAE,YAAY,EAAE;gBAC5D,gBAAgB,EAAE,MAAM;aACzB,CAAC,CAAA;SACH;IACH,CAAC,CAAA,CACF,CAAA;IAED,OAAO;QACL,OAAO,EAAE,OAAO,IAAI,QAAQ;QAC5B,KAAK,EAAE,KAAK,IAAI,WAAW;QAC3B,OAAO;QACP,MAAM;QACN,qBAAqB,EAAE,CAAC,CAAC,cAAc,IAAI,CAAC,cAAc,CAAC,gBAAgB;QAC3E,IAAI,EAAE,cAAc;QACpB,eAAe,EAAE,CAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,QAAQ;YACvC,CAAC,CAAC,IAAA,2BAAmB,EAAC,cAAc,CAAC,QAAQ,CAAC;YAC9C,CAAC,CAAC,SAAS;QACb,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,oBAAoB;QAClD,MAAM,EAAE,MAAM,GAAG,0BAAgB;QACjC,eAAe,EAAE,CAAC,UAAU,IAAI,MAAM,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC;QACvD,UAAU,EAAE,CAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,gBAAgB,KAAI,KAAK;KACtD,CAAA;AACH,CAAC,CAAA;AAxPY,QAAA,wBAAwB,4BAwPpC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useCronJob = void 0;
|
|
4
|
+
const helium_react_hooks_1 = require("@helium/helium-react-hooks");
|
|
5
|
+
const useCronJob = (cronJobKey) => (0, helium_react_hooks_1.useAnchorAccount)(cronJobKey, 'cronJobV0');
|
|
6
|
+
exports.useCronJob = useCronJob;
|
|
7
|
+
//# sourceMappingURL=useCronJob.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCronJob.js","sourceRoot":"","sources":["../../../src/hooks/useCronJob.ts"],"names":[],"mappings":";;;AAAA,mEAA6D;AAItD,MAAM,UAAU,GAAG,CAAC,UAAiC,EAAE,EAAE,CAC9D,IAAA,qCAAgB,EAAoB,UAAU,EAAE,WAAW,CAAC,CAAA;AADjD,QAAA,UAAU,cACuC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useTaskQueue = void 0;
|
|
4
|
+
const helium_react_hooks_1 = require("@helium/helium-react-hooks");
|
|
5
|
+
const useTaskQueue = (taskQueueKey) => (0, helium_react_hooks_1.useAnchorAccount)(taskQueueKey, 'taskQueueV0');
|
|
6
|
+
exports.useTaskQueue = useTaskQueue;
|
|
7
|
+
//# sourceMappingURL=useTaskQueue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTaskQueue.js","sourceRoot":"","sources":["../../../src/hooks/useTaskQueue.ts"],"names":[],"mappings":";;;AAAA,mEAA6D;AAItD,MAAM,YAAY,GAAG,CAAC,YAAmC,EAAE,EAAE,CAClE,IAAA,qCAAgB,EAAwB,YAAY,EAAE,aAAa,CAAC,CAAA;AADzD,QAAA,YAAY,gBAC6C"}
|
package/lib/cjs/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./hooks/index"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/hooks/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|