@shipload/sdk 0.2.0 → 0.3.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/lib/shipload.d.ts CHANGED
@@ -1,31 +1,6 @@
1
- import { Checksum256Type, Blob, ABI, Struct, Name, UInt64, NameType, UInt64Type, Action, Int64, Checksum256, UInt16, UInt32, TimePoint, UInt8, BlockTimestamp, Int64Type, Checksum512 } from '@wharfkit/antelope';
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';
2
2
  import { Contract as Contract$2, PartialBy, ContractArgs, ActionOptions, Table } from '@wharfkit/contract';
3
-
4
- declare function hash(seed: Checksum256Type, string: string): string;
5
-
6
- declare function distance(ship: Types.ship_row): number;
7
- declare function lerp(origin: Coordinates, destination: Coordinates, time: number): {
8
- x: number;
9
- y: number;
10
- };
11
- declare function rotation(origin: Coordinates, destination: Coordinates): number;
12
-
13
- interface Coordinates {
14
- x: number;
15
- y: number;
16
- }
17
- interface CameraPosition extends Coordinates {
18
- z: number;
19
- }
20
- interface Dimensions {
21
- width: number;
22
- height: number;
23
- }
24
- interface Distance {
25
- origin: Coordinates;
26
- destination: Coordinates;
27
- distance: number;
28
- }
3
+ import { ChainDefinition } from '@wharfkit/session';
29
4
 
30
5
  declare const abiBlob$1: Blob;
31
6
  declare const abi$1: ABI;
@@ -125,7 +100,6 @@ declare namespace Types {
125
100
  id: UInt64;
126
101
  }
127
102
  class buygoods extends Struct {
128
- buyer: Name;
129
103
  ship_id: UInt64;
130
104
  good_id: UInt64;
131
105
  quantity: UInt64;
@@ -135,6 +109,7 @@ declare namespace Types {
135
109
  ship_id: UInt64;
136
110
  good_id: UInt64;
137
111
  quantity: UInt64;
112
+ loaded: UInt64;
138
113
  }
139
114
  class cleartable extends Struct {
140
115
  table_name: Name;
@@ -152,6 +127,10 @@ declare namespace Types {
152
127
  id: UInt64;
153
128
  destination: coordinates;
154
129
  }
130
+ class good_price extends Struct {
131
+ id: UInt16;
132
+ price: UInt64;
133
+ }
155
134
  class hash extends Struct {
156
135
  value: string;
157
136
  }
@@ -168,13 +147,19 @@ declare namespace Types {
168
147
  quantity: UInt16;
169
148
  thrust: UInt32;
170
149
  }
150
+ class marketprice extends Struct {
151
+ location: coordinates;
152
+ good_id: UInt16;
153
+ }
154
+ class marketprices extends Struct {
155
+ location: coordinates;
156
+ }
171
157
  class player_row extends Struct {
172
158
  owner: Name;
173
159
  balance: UInt64;
174
160
  debt: UInt64;
175
161
  }
176
162
  class sellgoods extends Struct {
177
- seller: Name;
178
163
  ship_id: UInt64;
179
164
  good_id: UInt64;
180
165
  quantity: UInt64;
@@ -183,10 +168,12 @@ declare namespace Types {
183
168
  key: Name;
184
169
  value: UInt64;
185
170
  }
171
+ class ship_state extends Struct {
172
+ energy: UInt32;
173
+ }
186
174
  class ship_stats extends Struct {
187
175
  capacity: UInt32;
188
176
  drain: UInt32;
189
- energy: UInt32;
190
177
  mass: UInt64;
191
178
  orbit: UInt16;
192
179
  recharge: UInt32;
@@ -204,6 +191,7 @@ declare namespace Types {
204
191
  location: coordinates;
205
192
  skin: UInt8;
206
193
  tier: UInt8;
194
+ state: ship_state;
207
195
  stats: ship_stats;
208
196
  loaders: loader_stats;
209
197
  travelplan?: travel_plan;
@@ -277,7 +265,6 @@ declare namespace ActionParams {
277
265
  id: UInt64Type;
278
266
  }
279
267
  interface buygoods {
280
- buyer: NameType;
281
268
  ship_id: UInt64Type;
282
269
  good_id: UInt64Type;
283
270
  quantity: UInt64Type;
@@ -304,8 +291,14 @@ declare namespace ActionParams {
304
291
  interface join {
305
292
  account: NameType;
306
293
  }
294
+ interface marketprice {
295
+ location: Type.coordinates;
296
+ good_id: UInt16Type;
297
+ }
298
+ interface marketprices {
299
+ location: Type.coordinates;
300
+ }
307
301
  interface sellgoods {
308
- seller: NameType;
309
302
  ship_id: UInt64Type;
310
303
  good_id: UInt64Type;
311
304
  quantity: UInt64Type;
@@ -332,6 +325,8 @@ interface ActionNameParams {
332
325
  hash: ActionParams.hash;
333
326
  init: ActionParams.init;
334
327
  join: ActionParams.join;
328
+ marketprice: ActionParams.marketprice;
329
+ marketprices: ActionParams.marketprices;
335
330
  sellgoods: ActionParams.sellgoods;
336
331
  test: ActionParams.test;
337
332
  travel: ActionParams.travel;
@@ -341,6 +336,8 @@ type ActionNames = keyof ActionNameParams;
341
336
  interface ActionReturnValues {
342
337
  esttravel: Types.travel_summary;
343
338
  hash: Checksum512;
339
+ marketprice: Types.good_price;
340
+ marketprices: Types.good_price[];
344
341
  }
345
342
  type ActionReturnNames = keyof ActionReturnValues;
346
343
  declare class Contract extends Contract$2 {
@@ -382,7 +379,79 @@ declare namespace server {
382
379
  };
383
380
  }
384
381
 
382
+ declare function hash(seed: Checksum256Type, string: string): Checksum512;
383
+ declare function hashBytes(seed: Checksum256Type, string: string): Uint8Array;
384
+
385
+ interface Coordinates {
386
+ x: number;
387
+ y: number;
388
+ }
389
+ interface CameraPosition extends Coordinates {
390
+ z: number;
391
+ }
392
+ interface Dimensions {
393
+ width: number;
394
+ height: number;
395
+ }
396
+ interface Distance {
397
+ origin: Coordinates;
398
+ destination: Coordinates;
399
+ distance: number;
400
+ }
401
+ interface Good {
402
+ id: UInt16;
403
+ name: string;
404
+ description: string;
405
+ base_price: UInt64;
406
+ mass: UInt64;
407
+ }
408
+ interface GoodPrice {
409
+ id: UInt16;
410
+ price: UInt64;
411
+ }
412
+
413
+ 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[];
422
+
423
+ declare const goods: Good[];
424
+ declare function getGood(good_id: UInt16Type): Good;
425
+
426
+ declare function marketprice(location: Coordinates, good_id: UInt16Type, gameSeed: Checksum256Type, epochSeed: Checksum256Type): Promise<UInt64>;
427
+ declare function marketprices(location: Coordinates, gameSeed: Checksum256Type, epochSeed: Checksum256Type): Promise<GoodPrice[]>;
428
+ declare function priceFromRoll(basePrice: UInt64Type, roll: number): UInt64;
429
+
430
+ declare const ERROR_SYSTEM_NOT_INITIALIZED = "System not initialized";
431
+ declare const GOOD_DOES_NOT_EXIST = "Good does not exist";
432
+ declare const GOOD_NOT_AVAILABLE_AT_LOCATION = "Good not available at location";
433
+ declare const PLAYER_NOT_FOUND = "Player not found";
434
+ declare const SHIP_NOT_FOUND = "Ship not found";
435
+ declare const SHIP_CANNOT_BUY_TRAVELING = "Ship cannot buy while traveling";
436
+ declare const INSUFFICIENT_BALANCE = "Insufficient balance";
437
+ declare const INSUFFICIENT_GOOD_QUANTITY = "Insufficient good quantity";
438
+ declare const REQUIRES_MORE_THAN_ONE = "Requires more than one";
439
+
440
+ interface ShiploadOptions {
441
+ contractName?: string;
442
+ client?: APIClient;
443
+ }
444
+ interface ShiploadConstructorOptions extends ShiploadOptions {
445
+ serverContract: Contract$2;
446
+ }
385
447
  declare class Shipload {
448
+ private client;
449
+ private server;
450
+ constructor(chain: ChainDefinition, { client, serverContract }: ShiploadConstructorOptions);
451
+ static load(chain: ChainDefinition, shiploadOptions: ShiploadOptions): Promise<Shipload>;
452
+ getState(): Promise<Types.state_row>;
453
+ marketprice(location: Coordinates, good_id: number): Promise<UInt64>;
454
+ marketprices(location: Coordinates): Promise<GoodPrice[]>;
386
455
  }
387
456
 
388
- export { CameraPosition, Coordinates, Dimensions, Distance, platform as PlatformContract, server as ServerContract, Shipload as default, distance, hash, lerp, rotation };
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 };