@jsm-mit/tigi-sharded-package 0.8.0 → 0.10.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 +3 -0
- package/declarations/core/core.did +103 -53
- package/declarations/core/core.did.d.ts +101 -53
- package/declarations/core/core.did.js +86 -49
- package/declarations/tigi-driver/tigi-driver.did +28 -0
- package/declarations/tigi-driver/tigi-driver.did.d.ts +35 -0
- package/declarations/tigi-driver/tigi-driver.did.js +31 -1
- package/declarations/tigi-simulator/tigi-simulator.did +35 -1
- package/declarations/tigi-simulator/tigi-simulator.did.d.ts +64 -3
- package/declarations/tigi-simulator/tigi-simulator.did.js +27 -1
- package/dist/actors/driver-canisters-actor.d.ts +20 -1
- package/dist/actors/driver-canisters-actor.d.ts.map +1 -1
- package/dist/actors/driver-canisters-actor.js +25 -0
- package/dist/actors/rides-actor.d.ts +18 -1
- package/dist/actors/rides-actor.d.ts.map +1 -1
- package/dist/actors/rides-actor.js +49 -0
- package/dist/interfaces.d.ts +30 -0
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/mappers.d.ts.map +1 -1
- package/dist/mappers.js +5 -0
- package/package.json +3 -3
|
@@ -167,6 +167,30 @@ type RideView = record {
|
|
|
167
167
|
positionAtNs : opt nat64;
|
|
168
168
|
etaToPickupSec : opt nat32;
|
|
169
169
|
price : Money;
|
|
170
|
+
cardAccepted : opt bool; // P-20: the driver takes cards; absent = no
|
|
171
|
+
cardPayment : opt CardPaymentView; // P-20: once the rider started one
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
// P-20: the rider's card payment of a ride — Stripe Checkout on the driver's own account.
|
|
175
|
+
type CardPaymentState = variant {
|
|
176
|
+
creating; // the session is being made
|
|
177
|
+
open; // waits for the rider at `url`
|
|
178
|
+
paid;
|
|
179
|
+
expired; // ran out unpaid; a new one may be started
|
|
180
|
+
failed : text; // could not be made; a new try may be started
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
type CardPaymentView = record {
|
|
184
|
+
state : CardPaymentState;
|
|
185
|
+
amount : Money;
|
|
186
|
+
url : opt text; // the Stripe Checkout page, while `open`
|
|
187
|
+
updatedAtNs : nat64;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
type CardPaymentArgs = record {
|
|
191
|
+
requestId : RequestId;
|
|
192
|
+
driverKey : DriverKey;
|
|
193
|
+
returnUrl : text; // https; Stripe sends the rider back with `card=paid|cancelled`
|
|
170
194
|
};
|
|
171
195
|
|
|
172
196
|
type Licence = record {
|
|
@@ -196,6 +220,10 @@ service : {
|
|
|
196
220
|
// line or after the end); an old canister has no such method — the rider draws none.
|
|
197
221
|
getRideRoute : (RideRef) -> (variant { ok : RouteLine; err : ProtocolError }) query;
|
|
198
222
|
cancelRide : (RideRef) -> (variant { ok; err : ProtocolError });
|
|
223
|
+
// P-20: pay by card during the ride (`inProgress`); the same page while it stands. A
|
|
224
|
+
// driver without cards answers `invalidData`; an old canister has no such methods.
|
|
225
|
+
startCardPayment : (CardPaymentArgs) -> (variant { ok : CardPaymentView; err : ProtocolError });
|
|
226
|
+
checkCardPayment : (RideRef) -> (variant { ok : CardPaymentView; err : ProtocolError });
|
|
199
227
|
}
|
|
200
228
|
|
|
201
229
|
// What a driver canister may call on a worker (part of the worker's interface).
|
|
@@ -2,6 +2,25 @@ import type { Principal } from '@icp-sdk/core/principal';
|
|
|
2
2
|
import type { ActorMethod } from '@icp-sdk/core/agent';
|
|
3
3
|
import type { IDL } from '@icp-sdk/core/candid';
|
|
4
4
|
|
|
5
|
+
export interface CardPaymentArgs {
|
|
6
|
+
'returnUrl' : string,
|
|
7
|
+
'requestId' : RequestId,
|
|
8
|
+
'driverKey' : DriverKey,
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* P-20: the rider's card payment of a ride — Stripe Checkout on the driver's own account.
|
|
12
|
+
*/
|
|
13
|
+
export type CardPaymentState = { 'expired' : null } |
|
|
14
|
+
{ 'creating' : null } |
|
|
15
|
+
{ 'open' : null } |
|
|
16
|
+
{ 'paid' : null } |
|
|
17
|
+
{ 'failed' : string };
|
|
18
|
+
export interface CardPaymentView {
|
|
19
|
+
'url' : [] | [string],
|
|
20
|
+
'updatedAtNs' : bigint,
|
|
21
|
+
'state' : CardPaymentState,
|
|
22
|
+
'amount' : Money,
|
|
23
|
+
}
|
|
5
24
|
export type CarrierKind = { 'other' : string } |
|
|
6
25
|
{ 'taxi' : null } |
|
|
7
26
|
{ 'rideHailing' : null } |
|
|
@@ -114,9 +133,11 @@ export interface RideView {
|
|
|
114
133
|
'status' : RideStatus,
|
|
115
134
|
'requestId' : RequestId,
|
|
116
135
|
'positionAtNs' : [] | [bigint],
|
|
136
|
+
'cardPayment' : [] | [CardPaymentView],
|
|
117
137
|
'price' : Money,
|
|
118
138
|
'etaToPickupSec' : [] | [number],
|
|
119
139
|
'driver' : DriverCard,
|
|
140
|
+
'cardAccepted' : [] | [boolean],
|
|
120
141
|
'driverPosition' : [] | [Geo],
|
|
121
142
|
}
|
|
122
143
|
export interface RiderRating {
|
|
@@ -141,6 +162,11 @@ export interface _SERVICE {
|
|
|
141
162
|
{ 'ok' : null } |
|
|
142
163
|
{ 'err' : ProtocolError }
|
|
143
164
|
>,
|
|
165
|
+
'checkCardPayment' : ActorMethod<
|
|
166
|
+
[RideRef],
|
|
167
|
+
{ 'ok' : CardPaymentView } |
|
|
168
|
+
{ 'err' : ProtocolError }
|
|
169
|
+
>,
|
|
144
170
|
'getLicence' : ActorMethod<
|
|
145
171
|
[RideRef],
|
|
146
172
|
{ 'ok' : Licence } |
|
|
@@ -179,6 +205,15 @@ export interface _SERVICE {
|
|
|
179
205
|
{ 'ok' : null } |
|
|
180
206
|
{ 'err' : ProtocolError }
|
|
181
207
|
>,
|
|
208
|
+
/**
|
|
209
|
+
* P-20: pay by card during the ride (`inProgress`); the same page while it stands. A
|
|
210
|
+
* driver without cards answers `invalidData`; an old canister has no such methods.
|
|
211
|
+
*/
|
|
212
|
+
'startCardPayment' : ActorMethod<
|
|
213
|
+
[CardPaymentArgs],
|
|
214
|
+
{ 'ok' : CardPaymentView } |
|
|
215
|
+
{ 'err' : ProtocolError }
|
|
216
|
+
>,
|
|
182
217
|
}
|
|
183
218
|
export declare const idlFactory: IDL.InterfaceFactory;
|
|
184
219
|
export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[];
|
|
@@ -15,12 +15,25 @@ export const idlFactory = ({ IDL }) => {
|
|
|
15
15
|
'unsupportedVersion' : IDL.Nat32,
|
|
16
16
|
'notMyArea' : IDL.Null,
|
|
17
17
|
});
|
|
18
|
+
const CardPaymentState = IDL.Variant({
|
|
19
|
+
'expired' : IDL.Null,
|
|
20
|
+
'creating' : IDL.Null,
|
|
21
|
+
'open' : IDL.Null,
|
|
22
|
+
'paid' : IDL.Null,
|
|
23
|
+
'failed' : IDL.Text,
|
|
24
|
+
});
|
|
25
|
+
const Money = IDL.Record({ 'currency' : IDL.Text, 'amount' : IDL.Nat64 });
|
|
26
|
+
const CardPaymentView = IDL.Record({
|
|
27
|
+
'url' : IDL.Opt(IDL.Text),
|
|
28
|
+
'updatedAtNs' : IDL.Nat64,
|
|
29
|
+
'state' : CardPaymentState,
|
|
30
|
+
'amount' : Money,
|
|
31
|
+
});
|
|
18
32
|
const Licence = IDL.Record({
|
|
19
33
|
'mimeType' : IDL.Text,
|
|
20
34
|
'image' : IDL.Vec(IDL.Nat8),
|
|
21
35
|
'documentNumber' : IDL.Text,
|
|
22
36
|
});
|
|
23
|
-
const Money = IDL.Record({ 'currency' : IDL.Text, 'amount' : IDL.Nat64 });
|
|
24
37
|
const RideStatus = IDL.Variant({
|
|
25
38
|
'completed' : IDL.Record({ 'price' : Money }),
|
|
26
39
|
'cancelledByRider' : IDL.Null,
|
|
@@ -48,9 +61,11 @@ export const idlFactory = ({ IDL }) => {
|
|
|
48
61
|
'status' : RideStatus,
|
|
49
62
|
'requestId' : RequestId,
|
|
50
63
|
'positionAtNs' : IDL.Opt(IDL.Nat64),
|
|
64
|
+
'cardPayment' : IDL.Opt(CardPaymentView),
|
|
51
65
|
'price' : Money,
|
|
52
66
|
'etaToPickupSec' : IDL.Opt(IDL.Nat32),
|
|
53
67
|
'driver' : DriverCard,
|
|
68
|
+
'cardAccepted' : IDL.Opt(IDL.Bool),
|
|
54
69
|
'driverPosition' : IDL.Opt(Geo),
|
|
55
70
|
});
|
|
56
71
|
const RouteLine = IDL.Record({ 'ride' : IDL.Text, 'toPickup' : IDL.Text });
|
|
@@ -85,12 +100,22 @@ export const idlFactory = ({ IDL }) => {
|
|
|
85
100
|
'riderName' : IDL.Text,
|
|
86
101
|
'rider' : IDL.Principal,
|
|
87
102
|
});
|
|
103
|
+
const CardPaymentArgs = IDL.Record({
|
|
104
|
+
'returnUrl' : IDL.Text,
|
|
105
|
+
'requestId' : RequestId,
|
|
106
|
+
'driverKey' : DriverKey,
|
|
107
|
+
});
|
|
88
108
|
return IDL.Service({
|
|
89
109
|
'cancelRide' : IDL.Func(
|
|
90
110
|
[RideRef],
|
|
91
111
|
[IDL.Variant({ 'ok' : IDL.Null, 'err' : ProtocolError })],
|
|
92
112
|
[],
|
|
93
113
|
),
|
|
114
|
+
'checkCardPayment' : IDL.Func(
|
|
115
|
+
[RideRef],
|
|
116
|
+
[IDL.Variant({ 'ok' : CardPaymentView, 'err' : ProtocolError })],
|
|
117
|
+
[],
|
|
118
|
+
),
|
|
94
119
|
'getLicence' : IDL.Func(
|
|
95
120
|
[RideRef],
|
|
96
121
|
[IDL.Variant({ 'ok' : Licence, 'err' : ProtocolError })],
|
|
@@ -118,6 +143,11 @@ export const idlFactory = ({ IDL }) => {
|
|
|
118
143
|
[IDL.Variant({ 'ok' : IDL.Null, 'err' : ProtocolError })],
|
|
119
144
|
[],
|
|
120
145
|
),
|
|
146
|
+
'startCardPayment' : IDL.Func(
|
|
147
|
+
[CardPaymentArgs],
|
|
148
|
+
[IDL.Variant({ 'ok' : CardPaymentView, 'err' : ProtocolError })],
|
|
149
|
+
[],
|
|
150
|
+
),
|
|
121
151
|
});
|
|
122
152
|
};
|
|
123
153
|
export const init = ({ IDL }) => { return []; };
|
|
@@ -1,4 +1,31 @@
|
|
|
1
1
|
type CancelledByDriverStatus = record { reason : text };
|
|
2
|
+
// `variant { ok : CardPaymentView; err : ProtocolError }`.
|
|
3
|
+
type CardPaymentAnswer = variant { ok : CardPaymentView; err : ProtocolError };
|
|
4
|
+
// P-20: `startCardPayment` — the rider's front gives the page Stripe sends the rider back to.
|
|
5
|
+
type CardPaymentArgs = record {
|
|
6
|
+
returnUrl : text;
|
|
7
|
+
requestId : text;
|
|
8
|
+
driverKey : text;
|
|
9
|
+
};
|
|
10
|
+
// P-20: where the rider's card payment of a ride stands.
|
|
11
|
+
type CardPaymentState = variant {
|
|
12
|
+
// The session ran out unpaid; a new one may be started.
|
|
13
|
+
expired;
|
|
14
|
+
// The driver canister is making the Stripe Checkout session.
|
|
15
|
+
creating;
|
|
16
|
+
// The session waits for the rider at `url`.
|
|
17
|
+
open;
|
|
18
|
+
paid;
|
|
19
|
+
// The session could not be made (the reason, for the fronts); a new try may be started.
|
|
20
|
+
failed : text;
|
|
21
|
+
};
|
|
22
|
+
type CardPaymentView = record {
|
|
23
|
+
// The Stripe Checkout page, while `open`.
|
|
24
|
+
url : opt text;
|
|
25
|
+
updatedAtNs : nat64;
|
|
26
|
+
state : CardPaymentState;
|
|
27
|
+
amount : Money;
|
|
28
|
+
};
|
|
2
29
|
type CarrierKind = variant {
|
|
3
30
|
other : text;
|
|
4
31
|
taxi;
|
|
@@ -239,9 +266,13 @@ type RideView = record {
|
|
|
239
266
|
status : RideStatus;
|
|
240
267
|
requestId : text;
|
|
241
268
|
positionAtNs : opt nat64;
|
|
269
|
+
// P-20: the rider's card payment of this ride, once started.
|
|
270
|
+
cardPayment : opt CardPaymentView;
|
|
242
271
|
price : Money;
|
|
243
272
|
etaToPickupSec : opt nat32;
|
|
244
273
|
driver : DriverCard;
|
|
274
|
+
// P-20: the driver takes cards (Stripe on the driver's own account); absent = no.
|
|
275
|
+
cardAccepted : opt bool;
|
|
245
276
|
// Exact, for the rider of this ride only.
|
|
246
277
|
driverPosition : opt Geo;
|
|
247
278
|
};
|
|
@@ -313,8 +344,8 @@ type SpeedUpArgs = record {
|
|
|
313
344
|
factor : nat8;
|
|
314
345
|
};
|
|
315
346
|
service : (InitArgs) -> {
|
|
316
|
-
// S-14 (KK-33): the rider cancels before `inProgress`, once.
|
|
317
347
|
cancelRide : (RideRef) -> (ProtocolAnswer);
|
|
348
|
+
checkCardPayment : (RideRef) -> (CardPaymentAnswer);
|
|
318
349
|
// S-N15: where testers last asked for drivers — the router moves the automat driver
|
|
319
350
|
// canister near it (TIGI-DRIVER-MODES). None until the first search after an install or
|
|
320
351
|
// an upgrade.
|
|
@@ -343,6 +374,9 @@ service : (InitArgs) -> {
|
|
|
343
374
|
// S-2, S-3: virtual drivers around a point, each registered in the worker of its cell
|
|
344
375
|
// with `validUntilNs` (30 min) instead of a pulse.
|
|
345
376
|
spawnDrivers : (SpawnArgs) -> (Result_3);
|
|
377
|
+
// S-14 (KK-33): the rider cancels before `inProgress`, once.
|
|
378
|
+
// P-20: simulated drivers take no cards (`cardAccepted` is absent in their `getRide`).
|
|
379
|
+
startCardPayment : (CardPaymentArgs) -> (CardPaymentAnswer);
|
|
346
380
|
// S-N13: the router's route for one virtual driver — metres, seconds, the line. The quote
|
|
347
381
|
// goes with it at its moment (S-8), or at once when that moment has passed.
|
|
348
382
|
submitRoute : (SimRouteResult) -> (Result_2);
|
|
@@ -3,6 +3,56 @@ import type { ActorMethod } from '@icp-sdk/core/agent';
|
|
|
3
3
|
import type { IDL } from '@icp-sdk/core/candid';
|
|
4
4
|
|
|
5
5
|
export interface CancelledByDriverStatus { 'reason' : string }
|
|
6
|
+
/**
|
|
7
|
+
* `variant { ok : CardPaymentView; err : ProtocolError }`.
|
|
8
|
+
*/
|
|
9
|
+
export type CardPaymentAnswer = { 'ok' : CardPaymentView } |
|
|
10
|
+
{ 'err' : ProtocolError };
|
|
11
|
+
/**
|
|
12
|
+
* P-20: `startCardPayment` — the rider's front gives the page Stripe sends the rider back to.
|
|
13
|
+
*/
|
|
14
|
+
export interface CardPaymentArgs {
|
|
15
|
+
'returnUrl' : string,
|
|
16
|
+
'requestId' : string,
|
|
17
|
+
'driverKey' : string,
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* P-20: where the rider's card payment of a ride stands.
|
|
21
|
+
*/
|
|
22
|
+
export type CardPaymentState = {
|
|
23
|
+
/**
|
|
24
|
+
* The session ran out unpaid; a new one may be started.
|
|
25
|
+
*/
|
|
26
|
+
'expired' : null
|
|
27
|
+
} |
|
|
28
|
+
{
|
|
29
|
+
/**
|
|
30
|
+
* The driver canister is making the Stripe Checkout session.
|
|
31
|
+
*/
|
|
32
|
+
'creating' : null
|
|
33
|
+
} |
|
|
34
|
+
{
|
|
35
|
+
/**
|
|
36
|
+
* The session waits for the rider at `url`.
|
|
37
|
+
*/
|
|
38
|
+
'open' : null
|
|
39
|
+
} |
|
|
40
|
+
{ 'paid' : null } |
|
|
41
|
+
{
|
|
42
|
+
/**
|
|
43
|
+
* The session could not be made (the reason, for the fronts); a new try may be started.
|
|
44
|
+
*/
|
|
45
|
+
'failed' : string
|
|
46
|
+
};
|
|
47
|
+
export interface CardPaymentView {
|
|
48
|
+
/**
|
|
49
|
+
* The Stripe Checkout page, while `open`.
|
|
50
|
+
*/
|
|
51
|
+
'url' : [] | [string],
|
|
52
|
+
'updatedAtNs' : bigint,
|
|
53
|
+
'state' : CardPaymentState,
|
|
54
|
+
'amount' : Money,
|
|
55
|
+
}
|
|
6
56
|
export type CarrierKind = { 'other' : string } |
|
|
7
57
|
{ 'taxi' : null } |
|
|
8
58
|
{
|
|
@@ -332,9 +382,17 @@ export interface RideView {
|
|
|
332
382
|
'status' : RideStatus,
|
|
333
383
|
'requestId' : string,
|
|
334
384
|
'positionAtNs' : [] | [bigint],
|
|
385
|
+
/**
|
|
386
|
+
* P-20: the rider's card payment of this ride, once started.
|
|
387
|
+
*/
|
|
388
|
+
'cardPayment' : [] | [CardPaymentView],
|
|
335
389
|
'price' : Money,
|
|
336
390
|
'etaToPickupSec' : [] | [number],
|
|
337
391
|
'driver' : DriverCard,
|
|
392
|
+
/**
|
|
393
|
+
* P-20: the driver takes cards (Stripe on the driver's own account); absent = no.
|
|
394
|
+
*/
|
|
395
|
+
'cardAccepted' : [] | [boolean],
|
|
338
396
|
/**
|
|
339
397
|
* Exact, for the rider of this ride only.
|
|
340
398
|
*/
|
|
@@ -435,10 +493,8 @@ export interface SpeedUpArgs {
|
|
|
435
493
|
'factor' : number,
|
|
436
494
|
}
|
|
437
495
|
export interface _SERVICE {
|
|
438
|
-
/**
|
|
439
|
-
* S-14 (KK-33): the rider cancels before `inProgress`, once.
|
|
440
|
-
*/
|
|
441
496
|
'cancelRide' : ActorMethod<[RideRef], ProtocolAnswer>,
|
|
497
|
+
'checkCardPayment' : ActorMethod<[RideRef], CardPaymentAnswer>,
|
|
442
498
|
/**
|
|
443
499
|
* S-N15: where testers last asked for drivers — the router moves the automat driver
|
|
444
500
|
* canister near it (TIGI-DRIVER-MODES). None until the first search after an install or
|
|
@@ -485,6 +541,11 @@ export interface _SERVICE {
|
|
|
485
541
|
* with `validUntilNs` (30 min) instead of a pulse.
|
|
486
542
|
*/
|
|
487
543
|
'spawnDrivers' : ActorMethod<[SpawnArgs], Result_3>,
|
|
544
|
+
/**
|
|
545
|
+
* S-14 (KK-33): the rider cancels before `inProgress`, once.
|
|
546
|
+
* P-20: simulated drivers take no cards (`cardAccepted` is absent in their `getRide`).
|
|
547
|
+
*/
|
|
548
|
+
'startCardPayment' : ActorMethod<[CardPaymentArgs], CardPaymentAnswer>,
|
|
488
549
|
/**
|
|
489
550
|
* S-N13: the router's route for one virtual driver — metres, seconds, the line. The quote
|
|
490
551
|
* goes with it at its moment (S-8), or at once when that moment has passed.
|
|
@@ -28,6 +28,24 @@ export const idlFactory = ({ IDL }) => {
|
|
|
28
28
|
'ok' : IDL.Null,
|
|
29
29
|
'err' : ProtocolError,
|
|
30
30
|
});
|
|
31
|
+
const CardPaymentState = IDL.Variant({
|
|
32
|
+
'expired' : IDL.Null,
|
|
33
|
+
'creating' : IDL.Null,
|
|
34
|
+
'open' : IDL.Null,
|
|
35
|
+
'paid' : IDL.Null,
|
|
36
|
+
'failed' : IDL.Text,
|
|
37
|
+
});
|
|
38
|
+
const Money = IDL.Record({ 'currency' : IDL.Text, 'amount' : IDL.Nat64 });
|
|
39
|
+
const CardPaymentView = IDL.Record({
|
|
40
|
+
'url' : IDL.Opt(IDL.Text),
|
|
41
|
+
'updatedAtNs' : IDL.Nat64,
|
|
42
|
+
'state' : CardPaymentState,
|
|
43
|
+
'amount' : Money,
|
|
44
|
+
});
|
|
45
|
+
const CardPaymentAnswer = IDL.Variant({
|
|
46
|
+
'ok' : CardPaymentView,
|
|
47
|
+
'err' : ProtocolError,
|
|
48
|
+
});
|
|
31
49
|
const Geo = IDL.Record({ 'lat' : IDL.Float64, 'lng' : IDL.Float64 });
|
|
32
50
|
const SpawnPlace = IDL.Record({ 'center' : Geo, 'atNs' : IDL.Nat64 });
|
|
33
51
|
const SimulatorError = IDL.Variant({
|
|
@@ -46,7 +64,6 @@ export const idlFactory = ({ IDL }) => {
|
|
|
46
64
|
'documentNumber' : IDL.Text,
|
|
47
65
|
});
|
|
48
66
|
const LicenceAnswer = IDL.Variant({ 'ok' : Licence, 'err' : ProtocolError });
|
|
49
|
-
const Money = IDL.Record({ 'currency' : IDL.Text, 'amount' : IDL.Nat64 });
|
|
50
67
|
const CompletedStatus = IDL.Record({ 'price' : Money });
|
|
51
68
|
const CancelledByDriverStatus = IDL.Record({ 'reason' : IDL.Text });
|
|
52
69
|
const RideStatus = IDL.Variant({
|
|
@@ -75,9 +92,11 @@ export const idlFactory = ({ IDL }) => {
|
|
|
75
92
|
'status' : RideStatus,
|
|
76
93
|
'requestId' : IDL.Text,
|
|
77
94
|
'positionAtNs' : IDL.Opt(IDL.Nat64),
|
|
95
|
+
'cardPayment' : IDL.Opt(CardPaymentView),
|
|
78
96
|
'price' : Money,
|
|
79
97
|
'etaToPickupSec' : IDL.Opt(IDL.Nat32),
|
|
80
98
|
'driver' : DriverCard,
|
|
99
|
+
'cardAccepted' : IDL.Opt(IDL.Bool),
|
|
81
100
|
'driverPosition' : IDL.Opt(Geo),
|
|
82
101
|
});
|
|
83
102
|
const RideAnswer = IDL.Variant({ 'ok' : RideView, 'err' : ProtocolError });
|
|
@@ -168,6 +187,11 @@ export const idlFactory = ({ IDL }) => {
|
|
|
168
187
|
'validUntilNs' : IDL.Nat64,
|
|
169
188
|
});
|
|
170
189
|
const Result_3 = IDL.Variant({ 'Ok' : SpawnResult, 'Err' : SimulatorError });
|
|
190
|
+
const CardPaymentArgs = IDL.Record({
|
|
191
|
+
'returnUrl' : IDL.Text,
|
|
192
|
+
'requestId' : IDL.Text,
|
|
193
|
+
'driverKey' : IDL.Text,
|
|
194
|
+
});
|
|
171
195
|
const SimRouteResult = IDL.Record({
|
|
172
196
|
'requestId' : IDL.Text,
|
|
173
197
|
'rideMeters' : IDL.Nat32,
|
|
@@ -179,6 +203,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
179
203
|
});
|
|
180
204
|
return IDL.Service({
|
|
181
205
|
'cancelRide' : IDL.Func([RideRef], [ProtocolAnswer], []),
|
|
206
|
+
'checkCardPayment' : IDL.Func([RideRef], [CardPaymentAnswer], []),
|
|
182
207
|
'getLastSpawn' : IDL.Func([], [Result], ['query']),
|
|
183
208
|
'getLicence' : IDL.Func([RideRef], [LicenceAnswer], ['query']),
|
|
184
209
|
'getRide' : IDL.Func([RideRef], [RideAnswer], ['query']),
|
|
@@ -193,6 +218,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
193
218
|
'setRouter' : IDL.Func([SetRouterArgs], [Result_2], []),
|
|
194
219
|
'setSpeedUp' : IDL.Func([SpeedUpArgs], [Result_2], []),
|
|
195
220
|
'spawnDrivers' : IDL.Func([SpawnArgs], [Result_3], []),
|
|
221
|
+
'startCardPayment' : IDL.Func([CardPaymentArgs], [CardPaymentAnswer], []),
|
|
196
222
|
'submitRoute' : IDL.Func([SimRouteResult], [Result_2], []),
|
|
197
223
|
});
|
|
198
224
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Identity } from "@icp-sdk/core/agent";
|
|
2
2
|
import type { ClaimCode as CandidClaimCode, DriverCanister as CandidDriverCanister } from "../../declarations/core/core.did.js";
|
|
3
3
|
import { type GroupOptions } from "../group/canister-actor.js";
|
|
4
|
-
import type { ClaimCodeView, DemoLeaseView, DriverCanisterView } from "../interfaces.js";
|
|
4
|
+
import type { ClaimCodeView, DemoLeaseView, DriverCanisterQuoteView, DriverCanisterView } from "../interfaces.js";
|
|
5
5
|
/** The fragment key of a claim link: `https://<canister>.icp0.io/#claim=<code>`. */
|
|
6
6
|
export declare const CLAIM_FRAGMENT_KEY = "claim";
|
|
7
7
|
/** F-20a: a code is 32 characters of base64url; the core refuses more than this. */
|
|
@@ -51,6 +51,25 @@ export declare class DriverCanistersActor {
|
|
|
51
51
|
* @throws Error with message `CriticalCanisterError` — the core could not be reached
|
|
52
52
|
*/
|
|
53
53
|
getMineAsyncUnsafe(): Promise<DriverCanisterView | undefined>;
|
|
54
|
+
/**
|
|
55
|
+
* F-1: the price of a driver canister now and the caller's account to pay to (stage,
|
|
56
|
+
* test and prod; the local replica gives canisters for free).
|
|
57
|
+
* @throws Error with message `CanisterError` — `NotAuthorized` (local), `RemoteCanisterError` (the CMC or the ledger did not answer)
|
|
58
|
+
* @throws Error with message `CallRefusedAtInspectionStage` — anonymous, or the daily limit
|
|
59
|
+
* @throws Error with message `CriticalCanisterError` — the core could not be reached
|
|
60
|
+
*/
|
|
61
|
+
quoteAsyncUnsafe(): Promise<DriverCanisterQuoteView>;
|
|
62
|
+
/**
|
|
63
|
+
* F-1 … F-4: the caller's ICP buys a driver canister: the core pays the CMC with all of
|
|
64
|
+
* the caller's account, gets a canister it controls and installs the driver in it with
|
|
65
|
+
* the caller as owner. The same call again finishes the same canister (F-3); one per
|
|
66
|
+
* person. Then `newClaimCodeAsyncUnsafe` hands it to the driver's principal (F-20).
|
|
67
|
+
* @throws Error with message `CanisterError` — `InvalidData` "NOT_ENOUGH: …" (pay more), or
|
|
68
|
+
* "being created" / "still processing" (try again), `RemoteCanisterError`
|
|
69
|
+
* @throws Error with message `CallRefusedAtInspectionStage` — anonymous, or the daily limit
|
|
70
|
+
* @throws Error with message `CriticalCanisterError` — the core could not be reached
|
|
71
|
+
*/
|
|
72
|
+
buyAsyncUnsafe(): Promise<DriverCanisterView>;
|
|
54
73
|
/**
|
|
55
74
|
* F-20c: a new claim code for the caller's running demo lease ("Nowy link"); the code
|
|
56
75
|
* before it stops working. Good for 15 minutes, once.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"driver-canisters-actor.d.ts","sourceRoot":"","sources":["../../src/actors/driver-canisters-actor.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,KAAK,EAAE,SAAS,IAAI,eAAe,EAAE,cAAc,IAAI,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAChI,OAAO,EAAkC,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/F,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"driver-canisters-actor.d.ts","sourceRoot":"","sources":["../../src/actors/driver-canisters-actor.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,KAAK,EAAE,SAAS,IAAI,eAAe,EAAE,cAAc,IAAI,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAChI,OAAO,EAAkC,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAC;A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;IACU,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAU/F"}
|
|
@@ -111,6 +111,31 @@ export class DriverCanistersActor {
|
|
|
111
111
|
throw err;
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* F-1: the price of a driver canister now and the caller's account to pay to (stage,
|
|
116
|
+
* test and prod; the local replica gives canisters for free).
|
|
117
|
+
* @throws Error with message `CanisterError` — `NotAuthorized` (local), `RemoteCanisterError` (the CMC or the ledger did not answer)
|
|
118
|
+
* @throws Error with message `CallRefusedAtInspectionStage` — anonymous, or the daily limit
|
|
119
|
+
* @throws Error with message `CriticalCanisterError` — the core could not be reached
|
|
120
|
+
*/
|
|
121
|
+
async quoteAsyncUnsafe() {
|
|
122
|
+
const quote = await executeAsyncUnsafe(async () => (await this.group.coreAsync()).quoteMyDriverCanister());
|
|
123
|
+
const hex = Array.from(quote.accountId, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
124
|
+
return { priceCycles: quote.priceCycles, xdrPermyriadPerIcp: quote.xdrPermyriadPerIcp, minimumE8s: quote.minimumE8s, suggestedE8s: quote.suggestedE8s, balanceE8s: quote.balanceE8s, accountIdHex: hex };
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* F-1 … F-4: the caller's ICP buys a driver canister: the core pays the CMC with all of
|
|
128
|
+
* the caller's account, gets a canister it controls and installs the driver in it with
|
|
129
|
+
* the caller as owner. The same call again finishes the same canister (F-3); one per
|
|
130
|
+
* person. Then `newClaimCodeAsyncUnsafe` hands it to the driver's principal (F-20).
|
|
131
|
+
* @throws Error with message `CanisterError` — `InvalidData` "NOT_ENOUGH: …" (pay more), or
|
|
132
|
+
* "being created" / "still processing" (try again), `RemoteCanisterError`
|
|
133
|
+
* @throws Error with message `CallRefusedAtInspectionStage` — anonymous, or the daily limit
|
|
134
|
+
* @throws Error with message `CriticalCanisterError` — the core could not be reached
|
|
135
|
+
*/
|
|
136
|
+
async buyAsyncUnsafe() {
|
|
137
|
+
return driverCanisterOf(await executeAsyncUnsafe(async () => (await this.group.coreAsync()).createMyDriverCanister()));
|
|
138
|
+
}
|
|
114
139
|
/**
|
|
115
140
|
* F-20c: a new claim code for the caller's running demo lease ("Nowy link"); the code
|
|
116
141
|
* before it stops working. Good for 15 minutes, once.
|
|
@@ -2,7 +2,7 @@ import type { Identity } from "@icp-sdk/core/agent";
|
|
|
2
2
|
import { type GroupOptions } from "../group/canister-actor.js";
|
|
3
3
|
import { TigiGroup } from "../group/group.js";
|
|
4
4
|
import { type Geo } from "../geo.js";
|
|
5
|
-
import type { ChatPlace, ChooseOutcome, LicenceView, RequestSnapshot, RideView, RouteLineView } from "../interfaces.js";
|
|
5
|
+
import type { CardPaymentView, ChatPlace, ChooseOutcome, LicenceView, RequestSnapshot, RideView, RouteLineView } from "../interfaces.js";
|
|
6
6
|
/** U-29: the rider's radius, and the radius after `WIDEN_AFTER_MS` without offers. */
|
|
7
7
|
export declare const SEARCH_RADIUS_METERS = 3000;
|
|
8
8
|
export declare const WIDE_RADIUS_METERS = 6000;
|
|
@@ -219,6 +219,23 @@ export declare class RideRequest {
|
|
|
219
219
|
* @throws Error with message `CriticalCanisterError` — the driver canister does not answer
|
|
220
220
|
*/
|
|
221
221
|
cancelRideAsyncUnsafe(): Promise<void>;
|
|
222
|
+
/**
|
|
223
|
+
* P-20 (D-2): the rider pays by card during the ride — the driver canister makes a Stripe
|
|
224
|
+
* Checkout session on the driver's account; send the rider to `url` while `open`. Again
|
|
225
|
+
* while it stands → the same page. Stripe sends the rider back to `returnUrl` with
|
|
226
|
+
* `card=paid` or `card=cancelled`: call `checkCardPaymentAsyncUnsafe` then.
|
|
227
|
+
* @param returnUrl - https, the rider's page of this ride
|
|
228
|
+
* @throws Error with message `CanisterError` — `invalidData` (the driver takes no cards, the ride has not started, too many tries, a bad `returnUrl`), `expired` (the ride ended), `NoCards` (an older driver canister), `NOT_ACCEPTED`, `notAuthorized`
|
|
229
|
+
* @throws Error with message `CallRefusedAtInspectionStage` — the daily limit of the driver canister
|
|
230
|
+
* @throws Error with message `CriticalCanisterError` — the driver canister does not answer
|
|
231
|
+
*/
|
|
232
|
+
startCardPaymentAsyncUnsafe(returnUrl: string): Promise<CardPaymentView>;
|
|
233
|
+
/**
|
|
234
|
+
* P-20: after Stripe sent the rider back — the driver canister asks Stripe now.
|
|
235
|
+
* @throws Error with message `CanisterError` — `notFound` (no card payment started), `NoCards`, `NOT_ACCEPTED`, `notAuthorized`
|
|
236
|
+
* @throws Error with message `CriticalCanisterError` — the driver canister does not answer
|
|
237
|
+
*/
|
|
238
|
+
checkCardPaymentAsyncUnsafe(): Promise<CardPaymentView>;
|
|
222
239
|
/**
|
|
223
240
|
* U-11, PR-23: the driver's licence, from the acceptance to the end of the ride.
|
|
224
241
|
* @throws Error with message `CanisterError` — `notFound` (no photo), `notAuthorized` (after the ride), `NOT_ACCEPTED`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rides-actor.d.ts","sourceRoot":"","sources":["../../src/actors/rides-actor.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAKpD,OAAO,EAAgJ,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC7M,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAA2B,KAAK,GAAG,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAa,eAAe,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"rides-actor.d.ts","sourceRoot":"","sources":["../../src/actors/rides-actor.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAKpD,OAAO,EAAgJ,K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;;;;;;;OAOG;IACU,uBAAuB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAW1E;;;;;;OAMG;IACU,sBAAsB,IAAI,OAAO,CAAC,WAAW,CAAC;IAoB3D;;;OAGG;IACU,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAO/C;;;;;OAKG;IACU,kBAAkB,IAAI,OAAO,CAAC,QAAQ,CAAC;IAOpD;;;;;OAKG;IACU,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAMnD;;;;;;;;;OASG;IACU,2BAA2B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAYrF;;;;OAIG;IACU,2BAA2B,IAAI,OAAO,CAAC,eAAe,CAAC;IAYpE;;;;OAIG;IACU,qBAAqB,IAAI,OAAO,CAAC,WAAW,CAAC;IAO1D;;;;;;;;;OASG;IACU,uBAAuB,IAAI,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAOtE;;;;;;OAMG;IACU,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IASnE,4IAA4I;IAC5I,OAAO,CAAC,WAAW;YAML,kBAAkB;YA2BlB,UAAU;IA8DxB,iHAAiH;YACnG,gBAAgB;IAS9B,6FAA6F;YAC/E,UAAU;YASV,kBAAkB;YAalB,mBAAmB;YAOnB,WAAW;CAG5B"}
|
|
@@ -437,6 +437,47 @@ export class RideRequest {
|
|
|
437
437
|
await executeProtocolAsyncUnsafe(async () => (await this.driverAsync(accepted.canister)).cancelRide({ requestId: this.state.requestId, driverKey: accepted.driverKey }));
|
|
438
438
|
this.freshNext = true;
|
|
439
439
|
}
|
|
440
|
+
/**
|
|
441
|
+
* P-20 (D-2): the rider pays by card during the ride — the driver canister makes a Stripe
|
|
442
|
+
* Checkout session on the driver's account; send the rider to `url` while `open`. Again
|
|
443
|
+
* while it stands → the same page. Stripe sends the rider back to `returnUrl` with
|
|
444
|
+
* `card=paid` or `card=cancelled`: call `checkCardPaymentAsyncUnsafe` then.
|
|
445
|
+
* @param returnUrl - https, the rider's page of this ride
|
|
446
|
+
* @throws Error with message `CanisterError` — `invalidData` (the driver takes no cards, the ride has not started, too many tries, a bad `returnUrl`), `expired` (the ride ended), `NoCards` (an older driver canister), `NOT_ACCEPTED`, `notAuthorized`
|
|
447
|
+
* @throws Error with message `CallRefusedAtInspectionStage` — the daily limit of the driver canister
|
|
448
|
+
* @throws Error with message `CriticalCanisterError` — the driver canister does not answer
|
|
449
|
+
*/
|
|
450
|
+
async startCardPaymentAsyncUnsafe(returnUrl) {
|
|
451
|
+
const accepted = await this.acceptedAsyncUnsafe();
|
|
452
|
+
try {
|
|
453
|
+
const payment = await executeProtocolAsyncUnsafe(async () => (await this.driverAsync(accepted.canister)).startCardPayment({ requestId: this.state.requestId, driverKey: accepted.driverKey, returnUrl }));
|
|
454
|
+
this.freshNext = true;
|
|
455
|
+
return cardPaymentOf(payment);
|
|
456
|
+
}
|
|
457
|
+
catch (err) {
|
|
458
|
+
if (isMethodMissingError(err))
|
|
459
|
+
throw canisterError("NoCards", "the driver canister is older than card payments");
|
|
460
|
+
throw err;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* P-20: after Stripe sent the rider back — the driver canister asks Stripe now.
|
|
465
|
+
* @throws Error with message `CanisterError` — `notFound` (no card payment started), `NoCards`, `NOT_ACCEPTED`, `notAuthorized`
|
|
466
|
+
* @throws Error with message `CriticalCanisterError` — the driver canister does not answer
|
|
467
|
+
*/
|
|
468
|
+
async checkCardPaymentAsyncUnsafe() {
|
|
469
|
+
const accepted = await this.acceptedAsyncUnsafe();
|
|
470
|
+
try {
|
|
471
|
+
const payment = await executeProtocolAsyncUnsafe(async () => (await this.driverAsync(accepted.canister)).checkCardPayment({ requestId: this.state.requestId, driverKey: accepted.driverKey }));
|
|
472
|
+
this.freshNext = true;
|
|
473
|
+
return cardPaymentOf(payment);
|
|
474
|
+
}
|
|
475
|
+
catch (err) {
|
|
476
|
+
if (isMethodMissingError(err))
|
|
477
|
+
throw canisterError("NoCards", "the driver canister is older than card payments");
|
|
478
|
+
throw err;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
440
481
|
/**
|
|
441
482
|
* U-11, PR-23: the driver's licence, from the acceptance to the end of the ride.
|
|
442
483
|
* @throws Error with message `CanisterError` — `notFound` (no photo), `notAuthorized` (after the ride), `NOT_ACCEPTED`
|
|
@@ -627,5 +668,13 @@ async function getRideOfAsyncUnsafe(identity, options, driver, requestId) {
|
|
|
627
668
|
positionAtMs: ride.positionAtNs[0] === undefined ? undefined : msOf(ride.positionAtNs[0]),
|
|
628
669
|
etaToPickupSec: ride.etaToPickupSec[0],
|
|
629
670
|
price: moneyOf(ride.price),
|
|
671
|
+
cardAccepted: ride.cardAccepted?.[0] === true,
|
|
672
|
+
cardPayment: ride.cardPayment?.[0] === undefined ? undefined : cardPaymentOf(ride.cardPayment[0]),
|
|
630
673
|
};
|
|
631
674
|
}
|
|
675
|
+
/** P-20: the protocol's card payment as the package gives it. */
|
|
676
|
+
function cardPaymentOf(payment) {
|
|
677
|
+
const state = Object.keys(payment.state)[0];
|
|
678
|
+
const failure = "failed" in payment.state ? payment.state.failed : undefined;
|
|
679
|
+
return { state, ...(failure === undefined ? {} : { failure }), amount: moneyOf(payment.amount), url: payment.url[0], updatedAtMs: msOf(payment.updatedAtNs) };
|
|
680
|
+
}
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -128,6 +128,22 @@ export interface RideView {
|
|
|
128
128
|
positionAtMs?: number;
|
|
129
129
|
etaToPickupSec?: number;
|
|
130
130
|
price: Money;
|
|
131
|
+
/** P-20: the driver takes cards — show "Zapłać kartą" once the ride is `inProgress`. False for an older driver canister. */
|
|
132
|
+
cardAccepted: boolean;
|
|
133
|
+
/** P-20: the rider's card payment of this ride, once started. */
|
|
134
|
+
cardPayment?: CardPaymentView;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* P-20: the rider's card payment — Stripe Checkout on the driver's own account.
|
|
138
|
+
* `open`: send the rider to `url`; `expired` / `failed`: "Zapłać kartą" may be tapped again.
|
|
139
|
+
*/
|
|
140
|
+
export interface CardPaymentView {
|
|
141
|
+
state: "creating" | "open" | "paid" | "expired" | "failed";
|
|
142
|
+
/** Why it failed (the driver canister's or Stripe's words), with `failed`. */
|
|
143
|
+
failure?: string;
|
|
144
|
+
amount: Money;
|
|
145
|
+
url?: string;
|
|
146
|
+
updatedAtMs: number;
|
|
131
147
|
}
|
|
132
148
|
/** The driver's licence, for the rider of an accepted ride until its end (U-11). */
|
|
133
149
|
export interface LicenceView {
|
|
@@ -203,6 +219,20 @@ export interface ChatPlace {
|
|
|
203
219
|
* A driver canister of the signed-in person: their own (`own`) or a demo canister they
|
|
204
220
|
* hold (`pool`). Its id is the driver's own address (`https://<canisterId>.icp0.io`).
|
|
205
221
|
*/
|
|
222
|
+
/**
|
|
223
|
+
* F-1 (user 2026-10-31): what a driver canister costs now (2 TC in ICP at the CMC's rate) and
|
|
224
|
+
* where to pay. Send `suggestedE8s` (the minimum with a margin for the rate) to
|
|
225
|
+
* `accountIdHex` — the core's ICP account for this person; all of it buys the canister.
|
|
226
|
+
*/
|
|
227
|
+
export interface DriverCanisterQuoteView {
|
|
228
|
+
priceCycles: bigint;
|
|
229
|
+
xdrPermyriadPerIcp: bigint;
|
|
230
|
+
minimumE8s: bigint;
|
|
231
|
+
suggestedE8s: bigint;
|
|
232
|
+
balanceE8s: bigint;
|
|
233
|
+
/** The ICP account identifier (64 hex) — what NNS and exchanges call the account number. */
|
|
234
|
+
accountIdHex: string;
|
|
235
|
+
}
|
|
206
236
|
export interface DriverCanisterView {
|
|
207
237
|
canisterId: string;
|
|
208
238
|
kind: "own" | "pool";
|