@jsm-mit/tigi-sharded-package 0.3.0 → 0.4.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/README.md +7 -2
- package/declarations/coordinator/coordinator.did +39 -0
- package/declarations/coordinator/coordinator.did.d.ts +68 -0
- package/declarations/coordinator/coordinator.did.js +23 -0
- package/declarations/core/core.did +170 -45
- package/declarations/core/core.did.d.ts +155 -44
- package/declarations/core/core.did.js +122 -43
- package/declarations/tigi-driver/tigi-driver.did +15 -0
- package/declarations/tigi-driver/tigi-driver.did.d.ts +19 -0
- package/declarations/tigi-driver/tigi-driver.did.js +6 -0
- package/declarations/tigi-simulator/tigi-simulator.did +46 -4
- package/declarations/tigi-simulator/tigi-simulator.did.d.ts +70 -4
- package/declarations/tigi-simulator/tigi-simulator.did.js +39 -10
- package/declarations/worker/worker.did +23 -6
- package/declarations/worker/worker.did.d.ts +18 -6
- package/declarations/worker/worker.did.js +14 -7
- package/dist/actors/rides-actor.d.ts +21 -1
- package/dist/actors/rides-actor.d.ts.map +1 -1
- package/dist/actors/rides-actor.js +44 -2
- package/dist/geo.d.ts +5 -0
- package/dist/geo.d.ts.map +1 -1
- package/dist/geo.js +41 -0
- package/dist/group/canister-actor.d.ts +7 -0
- package/dist/group/canister-actor.d.ts.map +1 -1
- package/dist/group/canister-actor.js +18 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/interfaces.d.ts +15 -1
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/mappers.d.ts +7 -2
- package/dist/mappers.d.ts.map +1 -1
- package/dist/mappers.js +17 -2
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
The one package of the Tigi network group: it takes the coordinator's id and hides the
|
|
4
4
|
coordinator, the core and the workers — for a consumer the group is one canister. It also
|
|
5
5
|
carries the rider's few driver-canister endpoints (U-14: `getRide`, `cancelRide`,
|
|
6
|
-
`getLicence`), built from `protocol/tigi-driver.did`, so the consumer never sees a driver
|
|
6
|
+
`getLicence`, `getRideRoute`), built from `protocol/tigi-driver.did`, so the consumer never sees a driver
|
|
7
7
|
canister's id.
|
|
8
8
|
|
|
9
9
|
Status: the rider's side (night 1, U-42); 0.2.0 (stage 2a, U-43) adds the rider's own
|
|
10
10
|
rating and WHERE the chat with a driver is; 0.3.0 (U-45) adds `DriverCanistersActor` — the
|
|
11
|
-
demo lease and the one-time claim code
|
|
11
|
+
demo lease and the one-time claim code; 0.4.0 (route line, 2026-10-24) adds the driver's
|
|
12
|
+
route on the map — the line of a tapped offer, the line of the ride — and the exact pin of
|
|
13
|
+
an offer (`pinExact`). Version 0.1.0 was the first to publish.
|
|
12
14
|
|
|
13
15
|
## The rider
|
|
14
16
|
|
|
@@ -27,6 +29,8 @@ const snapshot = await request.getAsyncUnsafe(); // every REQUEST_POL
|
|
|
27
29
|
// snapshot.offers: a FIXED list (U-42) — by first arrival, new ones at the end, nothing
|
|
28
30
|
// re-sorted; an offer that left keeps its entry with `gone` (rejected | driverNotFree |
|
|
29
31
|
// taken | closed): draw a grey row of the same height there
|
|
32
|
+
// offer.pin: the driver's exact position (offer.pinExact) — the geohash7 centre from an old driver canister
|
|
33
|
+
const line = await request.getOfferRouteAsyncUnsafe(offer.offerId); // ZO-21, after a tap: { toPickup: Geo[]; ride: Geo[] } | undefined
|
|
30
34
|
await request.rejectOfferAsyncUnsafe(offer.offerId); // ✕ → gone "rejected"; the next nearest driver
|
|
31
35
|
await request.refreshOfferAsyncUnsafe(offer.offerId); // a stale (grey) offer asks again
|
|
32
36
|
await request.chooseOfferAsyncUnsafe(offer.offerId); // ordered (= the ride, accepted at once) | busy | offerExpired
|
|
@@ -36,6 +40,7 @@ await request.giveUpAsyncUnsafe();
|
|
|
36
40
|
const again = await request.searchAgainAsyncUnsafe(); // a new request, the same pickup and destination
|
|
37
41
|
|
|
38
42
|
const ride = await request.getRideAsyncUnsafe(); // from the driver canister, every RIDE_POLL_MS (2 s)
|
|
43
|
+
await request.getRideRouteAsyncUnsafe(); // K-13: the ride's line while it is active (once; undefined after the end)
|
|
39
44
|
await request.cancelRideAsyncUnsafe(); // before inProgress, once
|
|
40
45
|
await request.getLicenceAsyncUnsafe(); // from accepted to the end of the ride
|
|
41
46
|
await request.rateDriverAsyncUnsafe(5); // after completed, once
|
|
@@ -48,8 +48,16 @@ type Config = record {
|
|
|
48
48
|
wasm : opt WasmInfo;
|
|
49
49
|
// Somebody who asked for the superadmin role (LIVE; one request a day for the group).
|
|
50
50
|
roleRequest : opt RoleRequest;
|
|
51
|
+
// KO-19 (U-46): the cycles per canister of the group below which the fee multiplier
|
|
52
|
+
// goes up and above which it goes down. None = the defaults.
|
|
53
|
+
feeThresholds : opt FeeThresholds;
|
|
54
|
+
// KO-20: every fee cycle the core forwarded, in total.
|
|
55
|
+
feesReceived : opt nat;
|
|
51
56
|
// The UTC day of the last request: a second request the same day is refused in inspect.
|
|
52
57
|
lastRequestDay : nat64;
|
|
58
|
+
// KO-19: the multiplier of the drivers' daily fee, recomputed at most once a UTC day.
|
|
59
|
+
// None = never computed (the start value counts).
|
|
60
|
+
feeMultiplier : opt FeeMultiplierState;
|
|
53
61
|
// What a new worker starts with, and what a worker or the core gets when it reports a
|
|
54
62
|
// low balance. A worker asks below half of it.
|
|
55
63
|
cyclesPerWorker : nat;
|
|
@@ -135,6 +143,26 @@ type Event = record {
|
|
|
135
143
|
kind : text;
|
|
136
144
|
"text" : text;
|
|
137
145
|
};
|
|
146
|
+
type FeeMultiplier = record { day : nat64; permille : nat32 };
|
|
147
|
+
// KO-19: the core asks for the multiplier of its fee day.
|
|
148
|
+
type FeeMultiplierArgs = record { day : nat64 };
|
|
149
|
+
// KO-19: the multiplier of one UTC day and what it was computed from.
|
|
150
|
+
type FeeMultiplierState = record {
|
|
151
|
+
day : nat64;
|
|
152
|
+
// In thousandths: 1200 = 1.2.
|
|
153
|
+
permille : nat32;
|
|
154
|
+
// The canisters whose balance was not read at that reading ("<id>: <error>"), left out
|
|
155
|
+
// of the sum and of N. Not empty = an alarm on the front.
|
|
156
|
+
unread : opt vec text;
|
|
157
|
+
// The balances of the coordinator, the core and the workers read that day.
|
|
158
|
+
groupSum : opt nat;
|
|
159
|
+
computedAtNs : opt nat64;
|
|
160
|
+
// N: the canisters read (workers + core + coordinator).
|
|
161
|
+
canisters : opt nat32;
|
|
162
|
+
};
|
|
163
|
+
// KO-19: per canister of the group (the coordinator, the core, every worker). Defaults:
|
|
164
|
+
// `DEFAULT_FEE_MIN_PER_CANISTER`, `DEFAULT_FEE_MAX_PER_CANISTER`.
|
|
165
|
+
type FeeThresholds = record { minPerCanister : nat; maxPerCanister : nat };
|
|
138
166
|
// The arguments of the method are the core's, Candid-encoded (`to_candid` in Motoko) —
|
|
139
167
|
// the coordinator does not read them and keeps no copy of the chat group's types.
|
|
140
168
|
type ForwardChatAdminArgs = record {
|
|
@@ -545,6 +573,12 @@ service : (InitArgs) -> {
|
|
|
545
573
|
forwardChatAdmin : (ForwardChatAdminArgs) -> (Result_7);
|
|
546
574
|
// What the core says of itself right now — one composite query for the front.
|
|
547
575
|
getCoreStatus : () -> (Result_8) composite_query;
|
|
576
|
+
// KO-19 (U-46): the multiplier of the drivers' daily fee for the core's fee day —
|
|
577
|
+
// recomputed lazily, at most once a UTC day, when the core asks at the day's first
|
|
578
|
+
// settlement (no timer). The sum of the balances of the coordinator, the core and every
|
|
579
|
+
// worker against N × the thresholds (N = the canisters read). A reading already running
|
|
580
|
+
// answers the multiplier as it is. Only the core of this group (a trap otherwise).
|
|
581
|
+
getFeeMultiplier : (FeeMultiplierArgs) -> (FeeMultiplier);
|
|
548
582
|
// The core of the group.
|
|
549
583
|
getHomeCanister : () -> (opt principal) query;
|
|
550
584
|
// The whole prefix map: which worker serves which area.
|
|
@@ -624,6 +658,8 @@ service : (InitArgs) -> {
|
|
|
624
658
|
// `maxWorkers`, the query thresholds. Only the fields given are changed.
|
|
625
659
|
setConfig : (SetConfigArgs) -> (Result_16);
|
|
626
660
|
setCoreLoggingEnabled : (CoreLoggingArgs) -> (Result_11);
|
|
661
|
+
// KO-19: the superadmin sets the thresholds of the fee multiplier (cycles per canister).
|
|
662
|
+
setFeeThresholds : (FeeThresholds) -> (Result_16);
|
|
627
663
|
// The config of the workers of the group: the load thresholds, logging. Only the fields
|
|
628
664
|
// given are changed. The result is stored, given to every worker that has its code, and
|
|
629
665
|
// to every worker created later.
|
|
@@ -637,6 +673,9 @@ service : (InitArgs) -> {
|
|
|
637
673
|
// A worker of the group sends its cycles here before it is deleted (`giveBackCycles`).
|
|
638
674
|
// The workers only: somebody else's cycles are refused (they go back to the sender).
|
|
639
675
|
takeCycles : () -> (nat);
|
|
676
|
+
// KO-20 (U-46): the drivers' fees the core took, forwarded here — every attached cycle is
|
|
677
|
+
// accepted and counted. No per-driver data: the bills are the core's. Only the core.
|
|
678
|
+
takeFeeCycles : () -> (nat);
|
|
640
679
|
// Cycles for the core, by hand: `cyclesPerWorker`, like a worker's top-up.
|
|
641
680
|
topUpCore : () -> (Result_20);
|
|
642
681
|
// Cycles for a worker, by hand.
|
|
@@ -88,10 +88,24 @@ export interface Config {
|
|
|
88
88
|
* Somebody who asked for the superadmin role (LIVE; one request a day for the group).
|
|
89
89
|
*/
|
|
90
90
|
'roleRequest' : [] | [RoleRequest],
|
|
91
|
+
/**
|
|
92
|
+
* KO-19 (U-46): the cycles per canister of the group below which the fee multiplier
|
|
93
|
+
* goes up and above which it goes down. None = the defaults.
|
|
94
|
+
*/
|
|
95
|
+
'feeThresholds' : [] | [FeeThresholds],
|
|
96
|
+
/**
|
|
97
|
+
* KO-20: every fee cycle the core forwarded, in total.
|
|
98
|
+
*/
|
|
99
|
+
'feesReceived' : [] | [bigint],
|
|
91
100
|
/**
|
|
92
101
|
* The UTC day of the last request: a second request the same day is refused in inspect.
|
|
93
102
|
*/
|
|
94
103
|
'lastRequestDay' : bigint,
|
|
104
|
+
/**
|
|
105
|
+
* KO-19: the multiplier of the drivers' daily fee, recomputed at most once a UTC day.
|
|
106
|
+
* None = never computed (the start value counts).
|
|
107
|
+
*/
|
|
108
|
+
'feeMultiplier' : [] | [FeeMultiplierState],
|
|
95
109
|
/**
|
|
96
110
|
* What a new worker starts with, and what a worker or the core gets when it reports a
|
|
97
111
|
* low balance. A worker asks below half of it.
|
|
@@ -227,6 +241,43 @@ export interface Event {
|
|
|
227
241
|
'kind' : string,
|
|
228
242
|
'text' : string,
|
|
229
243
|
}
|
|
244
|
+
export interface FeeMultiplier { 'day' : bigint, 'permille' : number }
|
|
245
|
+
/**
|
|
246
|
+
* KO-19: the core asks for the multiplier of its fee day.
|
|
247
|
+
*/
|
|
248
|
+
export interface FeeMultiplierArgs { 'day' : bigint }
|
|
249
|
+
/**
|
|
250
|
+
* KO-19: the multiplier of one UTC day and what it was computed from.
|
|
251
|
+
*/
|
|
252
|
+
export interface FeeMultiplierState {
|
|
253
|
+
'day' : bigint,
|
|
254
|
+
/**
|
|
255
|
+
* In thousandths: 1200 = 1.2.
|
|
256
|
+
*/
|
|
257
|
+
'permille' : number,
|
|
258
|
+
/**
|
|
259
|
+
* The canisters whose balance was not read at that reading ("<id>: <error>"), left out
|
|
260
|
+
* of the sum and of N. Not empty = an alarm on the front.
|
|
261
|
+
*/
|
|
262
|
+
'unread' : [] | [Array<string>],
|
|
263
|
+
/**
|
|
264
|
+
* The balances of the coordinator, the core and the workers read that day.
|
|
265
|
+
*/
|
|
266
|
+
'groupSum' : [] | [bigint],
|
|
267
|
+
'computedAtNs' : [] | [bigint],
|
|
268
|
+
/**
|
|
269
|
+
* N: the canisters read (workers + core + coordinator).
|
|
270
|
+
*/
|
|
271
|
+
'canisters' : [] | [number],
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* KO-19: per canister of the group (the coordinator, the core, every worker). Defaults:
|
|
275
|
+
* `DEFAULT_FEE_MIN_PER_CANISTER`, `DEFAULT_FEE_MAX_PER_CANISTER`.
|
|
276
|
+
*/
|
|
277
|
+
export interface FeeThresholds {
|
|
278
|
+
'minPerCanister' : bigint,
|
|
279
|
+
'maxPerCanister' : bigint,
|
|
280
|
+
}
|
|
230
281
|
/**
|
|
231
282
|
* The arguments of the method are the core's, Candid-encoded (`to_candid` in Motoko) —
|
|
232
283
|
* the coordinator does not read them and keeps no copy of the chat group's types.
|
|
@@ -824,6 +875,14 @@ export interface _SERVICE {
|
|
|
824
875
|
* What the core says of itself right now — one composite query for the front.
|
|
825
876
|
*/
|
|
826
877
|
'getCoreStatus' : ActorMethod<[], Result_8>,
|
|
878
|
+
/**
|
|
879
|
+
* KO-19 (U-46): the multiplier of the drivers' daily fee for the core's fee day —
|
|
880
|
+
* recomputed lazily, at most once a UTC day, when the core asks at the day's first
|
|
881
|
+
* settlement (no timer). The sum of the balances of the coordinator, the core and every
|
|
882
|
+
* worker against N × the thresholds (N = the canisters read). A reading already running
|
|
883
|
+
* answers the multiplier as it is. Only the core of this group (a trap otherwise).
|
|
884
|
+
*/
|
|
885
|
+
'getFeeMultiplier' : ActorMethod<[FeeMultiplierArgs], FeeMultiplier>,
|
|
827
886
|
/**
|
|
828
887
|
* The core of the group.
|
|
829
888
|
*/
|
|
@@ -955,6 +1014,10 @@ export interface _SERVICE {
|
|
|
955
1014
|
*/
|
|
956
1015
|
'setConfig' : ActorMethod<[SetConfigArgs], Result_16>,
|
|
957
1016
|
'setCoreLoggingEnabled' : ActorMethod<[CoreLoggingArgs], Result_11>,
|
|
1017
|
+
/**
|
|
1018
|
+
* KO-19: the superadmin sets the thresholds of the fee multiplier (cycles per canister).
|
|
1019
|
+
*/
|
|
1020
|
+
'setFeeThresholds' : ActorMethod<[FeeThresholds], Result_16>,
|
|
958
1021
|
/**
|
|
959
1022
|
* The config of the workers of the group: the load thresholds, logging. Only the fields
|
|
960
1023
|
* given are changed. The result is stored, given to every worker that has its code, and
|
|
@@ -976,6 +1039,11 @@ export interface _SERVICE {
|
|
|
976
1039
|
* The workers only: somebody else's cycles are refused (they go back to the sender).
|
|
977
1040
|
*/
|
|
978
1041
|
'takeCycles' : ActorMethod<[], bigint>,
|
|
1042
|
+
/**
|
|
1043
|
+
* KO-20 (U-46): the drivers' fees the core took, forwarded here — every attached cycle is
|
|
1044
|
+
* accepted and counted. No per-driver data: the bills are the core's. Only the core.
|
|
1045
|
+
*/
|
|
1046
|
+
'takeFeeCycles' : ActorMethod<[], bigint>,
|
|
979
1047
|
/**
|
|
980
1048
|
* Cycles for the core, by hand: `cyclesPerWorker`, like a worker's top-up.
|
|
981
1049
|
*/
|
|
@@ -116,6 +116,11 @@ export const idlFactory = ({ IDL }) => {
|
|
|
116
116
|
'admins' : IDL.Opt(IDL.Vec(IDL.Principal)),
|
|
117
117
|
});
|
|
118
118
|
const Result_8 = IDL.Variant({ 'Ok' : CoreLive, 'Err' : CoordinatorError });
|
|
119
|
+
const FeeMultiplierArgs = IDL.Record({ 'day' : IDL.Nat64 });
|
|
120
|
+
const FeeMultiplier = IDL.Record({
|
|
121
|
+
'day' : IDL.Nat64,
|
|
122
|
+
'permille' : IDL.Nat32,
|
|
123
|
+
});
|
|
119
124
|
const Event = IDL.Record({
|
|
120
125
|
'id' : IDL.Nat64,
|
|
121
126
|
'atNs' : IDL.Nat64,
|
|
@@ -191,6 +196,18 @@ export const idlFactory = ({ IDL }) => {
|
|
|
191
196
|
'load' : IDL.Opt(LoadThresholds),
|
|
192
197
|
'loggingEnabled' : IDL.Opt(IDL.Bool),
|
|
193
198
|
});
|
|
199
|
+
const FeeThresholds = IDL.Record({
|
|
200
|
+
'minPerCanister' : IDL.Nat,
|
|
201
|
+
'maxPerCanister' : IDL.Nat,
|
|
202
|
+
});
|
|
203
|
+
const FeeMultiplierState = IDL.Record({
|
|
204
|
+
'day' : IDL.Nat64,
|
|
205
|
+
'permille' : IDL.Nat32,
|
|
206
|
+
'unread' : IDL.Opt(IDL.Vec(IDL.Text)),
|
|
207
|
+
'groupSum' : IDL.Opt(IDL.Nat),
|
|
208
|
+
'computedAtNs' : IDL.Opt(IDL.Nat64),
|
|
209
|
+
'canisters' : IDL.Opt(IDL.Nat32),
|
|
210
|
+
});
|
|
194
211
|
const Config = IDL.Record({
|
|
195
212
|
'maxWorkers' : IDL.Opt(IDL.Nat64),
|
|
196
213
|
'coreWasm' : IDL.Opt(WasmInfo),
|
|
@@ -203,7 +220,10 @@ export const idlFactory = ({ IDL }) => {
|
|
|
203
220
|
'workerConfig' : IDL.Opt(WorkerConfigArgs),
|
|
204
221
|
'wasm' : IDL.Opt(WasmInfo),
|
|
205
222
|
'roleRequest' : IDL.Opt(RoleRequest),
|
|
223
|
+
'feeThresholds' : IDL.Opt(FeeThresholds),
|
|
224
|
+
'feesReceived' : IDL.Opt(IDL.Nat),
|
|
206
225
|
'lastRequestDay' : IDL.Nat64,
|
|
226
|
+
'feeMultiplier' : IDL.Opt(FeeMultiplierState),
|
|
207
227
|
'cyclesPerWorker' : IDL.Nat,
|
|
208
228
|
'spread' : IDL.Bool,
|
|
209
229
|
'nextEventId' : IDL.Nat64,
|
|
@@ -367,6 +387,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
367
387
|
'drainWorker' : IDL.Func([DrainWorkerArgs], [Result_6], []),
|
|
368
388
|
'forwardChatAdmin' : IDL.Func([ForwardChatAdminArgs], [Result_7], []),
|
|
369
389
|
'getCoreStatus' : IDL.Func([], [Result_8], ['composite_query']),
|
|
390
|
+
'getFeeMultiplier' : IDL.Func([FeeMultiplierArgs], [FeeMultiplier], []),
|
|
370
391
|
'getHomeCanister' : IDL.Func([], [IDL.Opt(IDL.Principal)], ['query']),
|
|
371
392
|
'getPrefixMap' : IDL.Func([], [IDL.Vec(PrefixEntry)], ['query']),
|
|
372
393
|
'getRoles' : IDL.Func([], [Roles], ['query']),
|
|
@@ -400,10 +421,12 @@ export const idlFactory = ({ IDL }) => {
|
|
|
400
421
|
'resetGroup' : IDL.Func([], [Result_15], []),
|
|
401
422
|
'setConfig' : IDL.Func([SetConfigArgs], [Result_16], []),
|
|
402
423
|
'setCoreLoggingEnabled' : IDL.Func([CoreLoggingArgs], [Result_11], []),
|
|
424
|
+
'setFeeThresholds' : IDL.Func([FeeThresholds], [Result_16], []),
|
|
403
425
|
'setWorkerConfig' : IDL.Func([WorkerConfigArgs], [Result_17], []),
|
|
404
426
|
'setWorkerOpen' : IDL.Func([SetWorkerOpenArgs], [Result_18], []),
|
|
405
427
|
'splitWorker' : IDL.Func([CanisterArgs], [Result_19], []),
|
|
406
428
|
'takeCycles' : IDL.Func([], [IDL.Nat], []),
|
|
429
|
+
'takeFeeCycles' : IDL.Func([], [IDL.Nat], []),
|
|
407
430
|
'topUpCore' : IDL.Func([], [Result_20], []),
|
|
408
431
|
'topUpWorker' : IDL.Func([CanisterArgs], [Result_20], []),
|
|
409
432
|
'upgradeCore' : IDL.Func([], [Result_3], []),
|