@shipload/sdk 0.3.0 → 0.3.2

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/shipload.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Blob, ABI, Struct, Name, UInt64, NameType, UInt64Type, Action, Int64, UInt16, Checksum256, UInt32, TimePoint, UInt8, BlockTimestamp, Int64Type, Checksum256Type, UInt16Type, Checksum512, APIClient } from '@wharfkit/antelope';
1
+ import { Blob, ABI, Struct, Name, UInt64, Checksum256, UInt32, TimePointSec, Checksum256Type, UInt32Type, NameType, UInt64Type, Action, UInt16, Int64, TimePoint, UInt8, BlockTimestamp, Int64Type, UInt16Type, Checksum512, APIClient } from '@wharfkit/antelope';
2
2
  import { Contract as Contract$2, PartialBy, ContractArgs, ActionOptions, Table } from '@wharfkit/contract';
3
3
  import { ChainDefinition } from '@wharfkit/session';
4
4
 
@@ -17,31 +17,81 @@ declare namespace Types$1 {
17
17
  class enable extends Struct {
18
18
  enabled: boolean;
19
19
  }
20
+ class enablegame extends Struct {
21
+ contract: Name;
22
+ enabled: boolean;
23
+ }
20
24
  class foundcompany extends Struct {
21
25
  account: Name;
22
26
  name: string;
23
27
  }
28
+ class game_config extends Struct {
29
+ seed: Checksum256;
30
+ epochtime: UInt32;
31
+ }
32
+ class game_meta extends Struct {
33
+ name: string;
34
+ description: string;
35
+ url: string;
36
+ version: string;
37
+ }
38
+ class game_state extends Struct {
39
+ enabled: boolean;
40
+ start: TimePointSec;
41
+ end: TimePointSec;
42
+ }
43
+ class game_row extends Struct {
44
+ contract: Name;
45
+ config: game_config;
46
+ meta: game_meta;
47
+ state: game_state;
48
+ }
49
+ class startgame extends Struct {
50
+ contract: Name;
51
+ config: game_config;
52
+ meta: game_meta;
53
+ state: game_state;
54
+ }
24
55
  class state_row extends Struct {
25
56
  enabled: boolean;
26
57
  }
27
- class test extends Struct {
28
- data: string;
58
+ class updategame extends Struct {
59
+ contract: Name;
60
+ meta: game_meta;
29
61
  }
30
62
  class wipe extends Struct {
31
63
  }
32
64
  }
33
65
  declare const TableMap$1: {
34
66
  company: typeof Types$1.company_row;
67
+ games: typeof Types$1.game_row;
35
68
  state: typeof Types$1.state_row;
36
69
  };
37
70
  interface TableTypes$1 {
38
71
  company: Types$1.company_row;
72
+ games: Types$1.game_row;
39
73
  state: Types$1.state_row;
40
74
  }
41
75
  type RowType$1<T> = T extends keyof TableTypes$1 ? TableTypes$1[T] : any;
42
76
  type TableNames$1 = keyof TableTypes$1;
43
77
  declare namespace ActionParams$1 {
44
- namespace Type { }
78
+ namespace Type {
79
+ interface game_config {
80
+ seed: Checksum256Type;
81
+ epochtime: UInt32Type;
82
+ }
83
+ interface game_meta {
84
+ name: string;
85
+ description: string;
86
+ url: string;
87
+ version: string;
88
+ }
89
+ interface game_state {
90
+ enabled: boolean;
91
+ start: TimePointSec;
92
+ end: TimePointSec;
93
+ }
94
+ }
45
95
  interface cleartable {
46
96
  table_name: NameType;
47
97
  scope?: NameType;
@@ -50,12 +100,23 @@ declare namespace ActionParams$1 {
50
100
  interface enable {
51
101
  enabled: boolean;
52
102
  }
103
+ interface enablegame {
104
+ contract: NameType;
105
+ enabled: boolean;
106
+ }
53
107
  interface foundcompany {
54
108
  account: NameType;
55
109
  name: string;
56
110
  }
57
- interface test {
58
- data: string;
111
+ interface startgame {
112
+ contract: NameType;
113
+ config: Type.game_config;
114
+ meta: Type.game_meta;
115
+ state: Type.game_state;
116
+ }
117
+ interface updategame {
118
+ contract: NameType;
119
+ meta: Type.game_meta;
59
120
  }
60
121
  interface wipe {
61
122
  }
@@ -63,8 +124,10 @@ declare namespace ActionParams$1 {
63
124
  interface ActionNameParams$1 {
64
125
  cleartable: ActionParams$1.cleartable;
65
126
  enable: ActionParams$1.enable;
127
+ enablegame: ActionParams$1.enablegame;
66
128
  foundcompany: ActionParams$1.foundcompany;
67
- test: ActionParams$1.test;
129
+ startgame: ActionParams$1.startgame;
130
+ updategame: ActionParams$1.updategame;
68
131
  wipe: ActionParams$1.wipe;
69
132
  }
70
133
  type ActionNames$1 = keyof ActionNameParams$1;
@@ -94,6 +157,8 @@ declare const abiBlob: Blob;
94
157
  declare const abi: ABI;
95
158
  declare namespace Types {
96
159
  class advance extends Struct {
160
+ reveal: string;
161
+ commit: Checksum256;
97
162
  }
98
163
  class arrive extends Struct {
99
164
  owner: Name;
@@ -108,14 +173,17 @@ declare namespace Types {
108
173
  id: UInt64;
109
174
  ship_id: UInt64;
110
175
  good_id: UInt64;
111
- quantity: UInt64;
112
- loaded: UInt64;
176
+ quantity: UInt16;
177
+ loaded: UInt16;
113
178
  }
114
179
  class cleartable extends Struct {
115
180
  table_name: Name;
116
181
  scope?: Name;
117
182
  max_rows?: UInt64;
118
183
  }
184
+ class commit extends Struct {
185
+ commit: Checksum256;
186
+ }
119
187
  class coordinates extends Struct {
120
188
  x: Int64;
121
189
  y: Int64;
@@ -123,10 +191,6 @@ declare namespace Types {
123
191
  class enable extends Struct {
124
192
  enabled: boolean;
125
193
  }
126
- class esttravel extends Struct {
127
- id: UInt64;
128
- destination: coordinates;
129
- }
130
194
  class good_price extends Struct {
131
195
  id: UInt16;
132
196
  price: UInt64;
@@ -134,15 +198,16 @@ declare namespace Types {
134
198
  class hash extends Struct {
135
199
  value: string;
136
200
  }
201
+ class hash512 extends Struct {
202
+ value: string;
203
+ }
137
204
  class init extends Struct {
138
205
  seed: Checksum256;
139
- epochseed: Checksum256;
140
206
  }
141
207
  class join extends Struct {
142
208
  account: Name;
143
209
  }
144
210
  class loader_stats extends Struct {
145
- capacity: UInt16;
146
211
  mass: UInt32;
147
212
  quantity: UInt16;
148
213
  thrust: UInt32;
@@ -159,6 +224,9 @@ declare namespace Types {
159
224
  balance: UInt64;
160
225
  debt: UInt64;
161
226
  }
227
+ class salt extends Struct {
228
+ salt: UInt64;
229
+ }
162
230
  class sellgoods extends Struct {
163
231
  ship_id: UInt64;
164
232
  good_id: UInt64;
@@ -199,9 +267,16 @@ declare namespace Types {
199
267
  class state_row extends Struct {
200
268
  enabled: boolean;
201
269
  epoch: UInt64;
202
- epochseed: Checksum256;
203
- genesis: BlockTimestamp;
270
+ salt: UInt64;
204
271
  seed: Checksum256;
272
+ commit: Checksum256;
273
+ genesis: BlockTimestamp;
274
+ }
275
+ class travel extends Struct {
276
+ owner: Name;
277
+ id: UInt64;
278
+ destination: coordinates;
279
+ recharge: boolean;
205
280
  }
206
281
  class travel_summary extends Struct {
207
282
  stats: ship_stats;
@@ -217,18 +292,9 @@ declare namespace Types {
217
292
  loadtime: UInt64;
218
293
  time: UInt64;
219
294
  }
220
- class summary_row extends Struct {
221
- key: Name;
222
- value: travel_summary;
223
- }
224
- class test extends Struct {
225
- data: string;
226
- }
227
- class travel extends Struct {
228
- owner: Name;
295
+ class traveltime extends Struct {
229
296
  id: UInt64;
230
297
  destination: coordinates;
231
- recharge: boolean;
232
298
  }
233
299
  class wipe extends Struct {
234
300
  }
@@ -239,7 +305,6 @@ declare const TableMap: {
239
305
  sequence: typeof Types.sequence_row;
240
306
  ship: typeof Types.ship_row;
241
307
  state: typeof Types.state_row;
242
- summary: typeof Types.summary_row;
243
308
  };
244
309
  interface TableTypes {
245
310
  cargo: Types.cargo_row;
@@ -247,7 +312,6 @@ interface TableTypes {
247
312
  sequence: Types.sequence_row;
248
313
  ship: Types.ship_row;
249
314
  state: Types.state_row;
250
- summary: Types.summary_row;
251
315
  }
252
316
  type RowType<T> = T extends keyof TableTypes ? TableTypes[T] : any;
253
317
  type TableNames = keyof TableTypes;
@@ -259,6 +323,8 @@ declare namespace ActionParams {
259
323
  }
260
324
  }
261
325
  interface advance {
326
+ reveal: string;
327
+ commit: Checksum256Type;
262
328
  }
263
329
  interface arrive {
264
330
  owner: NameType;
@@ -274,19 +340,20 @@ declare namespace ActionParams {
274
340
  scope?: NameType;
275
341
  max_rows?: UInt64Type;
276
342
  }
343
+ interface commit {
344
+ commit: Checksum256Type;
345
+ }
277
346
  interface enable {
278
347
  enabled: boolean;
279
348
  }
280
- interface esttravel {
281
- id: UInt64Type;
282
- destination: Type.coordinates;
283
- }
284
349
  interface hash {
285
350
  value: string;
286
351
  }
352
+ interface hash512 {
353
+ value: string;
354
+ }
287
355
  interface init {
288
356
  seed: Checksum256Type;
289
- epochseed: Checksum256Type;
290
357
  }
291
358
  interface join {
292
359
  account: NameType;
@@ -298,20 +365,24 @@ declare namespace ActionParams {
298
365
  interface marketprices {
299
366
  location: Type.coordinates;
300
367
  }
368
+ interface salt {
369
+ salt: UInt64Type;
370
+ }
301
371
  interface sellgoods {
302
372
  ship_id: UInt64Type;
303
373
  good_id: UInt64Type;
304
374
  quantity: UInt64Type;
305
375
  }
306
- interface test {
307
- data: string;
308
- }
309
376
  interface travel {
310
377
  owner: NameType;
311
378
  id: UInt64Type;
312
379
  destination: Type.coordinates;
313
380
  recharge: boolean;
314
381
  }
382
+ interface traveltime {
383
+ id: UInt64Type;
384
+ destination: Type.coordinates;
385
+ }
315
386
  interface wipe {
316
387
  }
317
388
  }
@@ -320,24 +391,27 @@ interface ActionNameParams {
320
391
  arrive: ActionParams.arrive;
321
392
  buygoods: ActionParams.buygoods;
322
393
  cleartable: ActionParams.cleartable;
394
+ commit: ActionParams.commit;
323
395
  enable: ActionParams.enable;
324
- esttravel: ActionParams.esttravel;
325
396
  hash: ActionParams.hash;
397
+ hash512: ActionParams.hash512;
326
398
  init: ActionParams.init;
327
399
  join: ActionParams.join;
328
400
  marketprice: ActionParams.marketprice;
329
401
  marketprices: ActionParams.marketprices;
402
+ salt: ActionParams.salt;
330
403
  sellgoods: ActionParams.sellgoods;
331
- test: ActionParams.test;
332
404
  travel: ActionParams.travel;
405
+ traveltime: ActionParams.traveltime;
333
406
  wipe: ActionParams.wipe;
334
407
  }
335
408
  type ActionNames = keyof ActionNameParams;
336
409
  interface ActionReturnValues {
337
- esttravel: Types.travel_summary;
338
- hash: Checksum512;
410
+ hash: Checksum256;
411
+ hash512: Checksum512;
339
412
  marketprice: Types.good_price;
340
413
  marketprices: Types.good_price[];
414
+ traveltime: Types.travel_summary;
341
415
  }
342
416
  type ActionReturnNames = keyof ActionReturnValues;
343
417
  declare class Contract extends Contract$2 {
@@ -379,8 +453,10 @@ declare namespace server {
379
453
  };
380
454
  }
381
455
 
456
+ declare function getCurrentEpoch(game: Types$1.game_row, state: Types.state_row): Promise<number>;
457
+
382
458
  declare function hash(seed: Checksum256Type, string: string): Checksum512;
383
- declare function hashBytes(seed: Checksum256Type, string: string): Uint8Array;
459
+ declare function hash512(seed: Checksum256Type, string: string): Checksum512;
384
460
 
385
461
  interface Coordinates {
386
462
  x: number;
@@ -394,9 +470,9 @@ interface Dimensions {
394
470
  height: number;
395
471
  }
396
472
  interface Distance {
397
- origin: Coordinates;
398
- destination: Coordinates;
399
- distance: number;
473
+ origin: ActionParams.Type.coordinates;
474
+ destination: ActionParams.Type.coordinates;
475
+ distance: UInt16;
400
476
  }
401
477
  interface Good {
402
478
  id: UInt16;
@@ -411,14 +487,12 @@ interface GoodPrice {
411
487
  }
412
488
 
413
489
  declare function distanceTraveled(ship: Types.ship_row): number;
414
- declare function distanceBetweenPoints(x1: number, y1: number, x2: number, y2: number): number;
415
- declare function lerp(origin: Coordinates, destination: Coordinates, time: number): {
416
- x: number;
417
- y: number;
418
- };
419
- declare function rotation(origin: Coordinates, destination: Coordinates): number;
420
- declare function hasPlanet(seed: Checksum256, coords: Coordinates): boolean;
421
- declare function findNearbyPlanets(seed: Checksum256, origin: Coordinates, maxDistance?: number): Distance[];
490
+ declare function distanceBetweenCoordinates(origin: ActionParams.Type.coordinates, destination: ActionParams.Type.coordinates): UInt16;
491
+ declare function distanceBetweenPoints(x1: UInt64Type, y1: UInt64Type, x2: UInt64Type, y2: UInt64Type): UInt16;
492
+ declare function lerp(origin: ActionParams.Type.coordinates, destination: ActionParams.Type.coordinates, time: number): ActionParams.Type.coordinates;
493
+ declare function rotation(origin: ActionParams.Type.coordinates, destination: ActionParams.Type.coordinates): number;
494
+ declare function hasPlanet(seed: Checksum256, coordinates: ActionParams.Type.coordinates): boolean;
495
+ declare function findNearbyPlanets(seed: Checksum256, origin: ActionParams.Type.coordinates, maxDistance?: UInt16Type): Distance[];
422
496
 
423
497
  declare const goods: Good[];
424
498
  declare function getGood(good_id: UInt16Type): Good;
@@ -438,20 +512,24 @@ declare const INSUFFICIENT_GOOD_QUANTITY = "Insufficient good quantity";
438
512
  declare const REQUIRES_MORE_THAN_ONE = "Requires more than one";
439
513
 
440
514
  interface ShiploadOptions {
441
- contractName?: string;
515
+ platformContractName?: string;
516
+ serverContractName?: string;
442
517
  client?: APIClient;
443
518
  }
444
519
  interface ShiploadConstructorOptions extends ShiploadOptions {
520
+ platformContract: Contract$2;
445
521
  serverContract: Contract$2;
446
522
  }
447
523
  declare class Shipload {
448
- private client;
449
- private server;
450
- constructor(chain: ChainDefinition, { client, serverContract }: ShiploadConstructorOptions);
524
+ client: APIClient;
525
+ server: Contract$2;
526
+ platform: Contract$2;
527
+ constructor(chain: ChainDefinition, { client, platformContract, serverContract }: ShiploadConstructorOptions);
451
528
  static load(chain: ChainDefinition, shiploadOptions: ShiploadOptions): Promise<Shipload>;
529
+ getGame(): Promise<Types$1.game_row>;
452
530
  getState(): Promise<Types.state_row>;
453
531
  marketprice(location: Coordinates, good_id: number): Promise<UInt64>;
454
532
  marketprices(location: Coordinates): Promise<GoodPrice[]>;
455
533
  }
456
534
 
457
- export { CameraPosition, Coordinates, Dimensions, Distance, ERROR_SYSTEM_NOT_INITIALIZED, GOOD_DOES_NOT_EXIST, GOOD_NOT_AVAILABLE_AT_LOCATION, Good, GoodPrice, INSUFFICIENT_BALANCE, INSUFFICIENT_GOOD_QUANTITY, PLAYER_NOT_FOUND, platform as PlatformContract, REQUIRES_MORE_THAN_ONE, SHIP_CANNOT_BUY_TRAVELING, SHIP_NOT_FOUND, server as ServerContract, Shipload as default, distanceBetweenPoints, distanceTraveled, findNearbyPlanets, getGood, goods, hasPlanet, hash, hashBytes, lerp, marketprice, marketprices, priceFromRoll, rotation };
535
+ export { CameraPosition, Coordinates, Dimensions, Distance, ERROR_SYSTEM_NOT_INITIALIZED, GOOD_DOES_NOT_EXIST, GOOD_NOT_AVAILABLE_AT_LOCATION, Good, GoodPrice, INSUFFICIENT_BALANCE, INSUFFICIENT_GOOD_QUANTITY, PLAYER_NOT_FOUND, platform as PlatformContract, REQUIRES_MORE_THAN_ONE, SHIP_CANNOT_BUY_TRAVELING, SHIP_NOT_FOUND, server as ServerContract, Shipload as default, distanceBetweenCoordinates, distanceBetweenPoints, distanceTraveled, findNearbyPlanets, getCurrentEpoch, getGood, goods, hasPlanet, hash, hash512, lerp, marketprice, marketprices, priceFromRoll, rotation };