@shipload/sdk 0.0.1 → 0.2.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 +387 -1
- package/lib/shipload.js +563 -1
- package/lib/shipload.js.map +1 -1
- package/lib/shipload.m.js +555 -1
- package/lib/shipload.m.js.map +1 -1
- package/package.json +55 -14
- package/src/contracts/platform.ts +106 -0
- package/src/contracts/server.ts +371 -0
- package/src/hash.ts +6 -0
- package/src/index-bundle.ts +7 -0
- package/src/index-module.ts +5 -0
- package/src/index.ts +6 -1
- package/src/ship.ts +1 -0
- package/src/shipload.ts +1 -0
- package/src/travel.ts +20 -0
- package/src/types.ts +19 -0
- package/.editorconfig +0 -12
- package/.eslintrc +0 -28
- package/.prettierrc +0 -8
- package/Makefile +0 -74
- package/rollup.config.js +0 -36
- package/tsconfig.json +0 -17
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type {Action, NameType, UInt64Type} from '@wharfkit/antelope'
|
|
2
|
+
import {ABI, Blob, Name, Struct, UInt64} from '@wharfkit/antelope'
|
|
3
|
+
import type {ActionOptions, ContractArgs, PartialBy, Table} from '@wharfkit/contract'
|
|
4
|
+
import {Contract as BaseContract} from '@wharfkit/contract'
|
|
5
|
+
export const abiBlob = Blob.from(
|
|
6
|
+
'DmVvc2lvOjphYmkvMS4yAAcKY2xlYXJ0YWJsZQADCnRhYmxlX25hbWUEbmFtZQVzY29wZQVuYW1lPwhtYXhfcm93cwd1aW50NjQ/C2NvbXBhbnlfcm93AAIHYWNjb3VudARuYW1lBG5hbWUGc3RyaW5nBmVuYWJsZQABB2VuYWJsZWQEYm9vbAxmb3VuZGNvbXBhbnkAAgdhY2NvdW50BG5hbWUEbmFtZQZzdHJpbmcJc3RhdGVfcm93AAEHZW5hYmxlZARib29sBHRlc3QAAQRkYXRhBnN0cmluZwR3aXBlAAAFAICKx+RrVEQKY2xlYXJ0YWJsZQAAAAAAqHjMVAZlbmFibGXzAS0tLQoKc3BlY192ZXJzaW9uOiAiMC4yLjAiCnRpdGxlOiBlbmFibGUKc3VtbWFyeTogJ0VuYWJsZS9kaXNhYmxlIHBsYXRmb3JtJwppY29uOiBodHRwczovL2F2YXRhcnMuZ2l0aHVidXNlcmNvbnRlbnQuY29tL3UvMTU4MTEzNzgyI2QzYmYyOTBmZGRlZGRiYjdkMzJhYTg5N2U5ZjdlOWUxM2EyYWU0NDk1NjE0MmUyM2ViNDdiNzcwOTZhMmVhOGQKCi0tLQoKRW5hYmxlIG9yIGRpc2FibGUgdGhlIHBsYXRmb3JtIGNvbnRyYWN0LuCnqZKiNDVdDGZvdW5kY29tcGFueYMCLS0tCgpzcGVjX3ZlcnNpb246ICIwLjIuMCIKdGl0bGU6IGZvdW5kY29tcGFueQpzdW1tYXJ5OiAnRm91bmQgYSBuZXcgY29tcGFueScKaWNvbjogaHR0cHM6Ly9hdmF0YXJzLmdpdGh1YnVzZXJjb250ZW50LmNvbS91LzE1ODExMzc4MiNkM2JmMjkwZmRkZWRkYmI3ZDMyYWE4OTdlOWY3ZTllMTNhMmFlNDQ5NTYxNDJlMjNlYjQ3Yjc3MDk2YTJlYThkCgotLS0KCkZvdW5kIGEgbmV3IGNvbXBhbnkgaW4gdGhlIFNoaXBsb2FkIHBsYXRmb3JtIGNvbnRyYWN0LgAAAAAAkLHKBHRlc3QAAAAAAACgquMEd2lwZQACAAAAwE9TJUUDaTY0AAALY29tcGFueV9yb3cAAAAAAJVNxgNpNjQAAAlzdGF0ZV9yb3cBE1NoaXBsb2FkIChQbGF0Zm9ybSkTU2hpcGxvYWQgKFBsYXRmb3JtKQAAAAA='
|
|
7
|
+
)
|
|
8
|
+
export const abi = ABI.from(abiBlob)
|
|
9
|
+
export namespace Types {
|
|
10
|
+
@Struct.type('cleartable')
|
|
11
|
+
export class cleartable extends Struct {
|
|
12
|
+
@Struct.field(Name)
|
|
13
|
+
table_name!: Name
|
|
14
|
+
@Struct.field(Name, {optional: true})
|
|
15
|
+
scope?: Name
|
|
16
|
+
@Struct.field(UInt64, {optional: true})
|
|
17
|
+
max_rows?: UInt64
|
|
18
|
+
}
|
|
19
|
+
@Struct.type('company_row')
|
|
20
|
+
export class company_row extends Struct {
|
|
21
|
+
@Struct.field(Name)
|
|
22
|
+
account!: Name
|
|
23
|
+
@Struct.field('string')
|
|
24
|
+
name!: string
|
|
25
|
+
}
|
|
26
|
+
@Struct.type('enable')
|
|
27
|
+
export class enable extends Struct {
|
|
28
|
+
@Struct.field('bool')
|
|
29
|
+
enabled!: boolean
|
|
30
|
+
}
|
|
31
|
+
@Struct.type('foundcompany')
|
|
32
|
+
export class foundcompany extends Struct {
|
|
33
|
+
@Struct.field(Name)
|
|
34
|
+
account!: Name
|
|
35
|
+
@Struct.field('string')
|
|
36
|
+
name!: string
|
|
37
|
+
}
|
|
38
|
+
@Struct.type('state_row')
|
|
39
|
+
export class state_row extends Struct {
|
|
40
|
+
@Struct.field('bool')
|
|
41
|
+
enabled!: boolean
|
|
42
|
+
}
|
|
43
|
+
@Struct.type('test')
|
|
44
|
+
export class test extends Struct {
|
|
45
|
+
@Struct.field('string')
|
|
46
|
+
data!: string
|
|
47
|
+
}
|
|
48
|
+
@Struct.type('wipe')
|
|
49
|
+
export class wipe extends Struct {}
|
|
50
|
+
}
|
|
51
|
+
export const TableMap = {
|
|
52
|
+
company: Types.company_row,
|
|
53
|
+
state: Types.state_row,
|
|
54
|
+
}
|
|
55
|
+
export interface TableTypes {
|
|
56
|
+
company: Types.company_row
|
|
57
|
+
state: Types.state_row
|
|
58
|
+
}
|
|
59
|
+
export type RowType<T> = T extends keyof TableTypes ? TableTypes[T] : any
|
|
60
|
+
export type TableNames = keyof TableTypes
|
|
61
|
+
export namespace ActionParams {
|
|
62
|
+
export namespace Type {}
|
|
63
|
+
export interface cleartable {
|
|
64
|
+
table_name: NameType
|
|
65
|
+
scope?: NameType
|
|
66
|
+
max_rows?: UInt64Type
|
|
67
|
+
}
|
|
68
|
+
export interface enable {
|
|
69
|
+
enabled: boolean
|
|
70
|
+
}
|
|
71
|
+
export interface foundcompany {
|
|
72
|
+
account: NameType
|
|
73
|
+
name: string
|
|
74
|
+
}
|
|
75
|
+
export interface test {
|
|
76
|
+
data: string
|
|
77
|
+
}
|
|
78
|
+
export interface wipe {}
|
|
79
|
+
}
|
|
80
|
+
export interface ActionNameParams {
|
|
81
|
+
cleartable: ActionParams.cleartable
|
|
82
|
+
enable: ActionParams.enable
|
|
83
|
+
foundcompany: ActionParams.foundcompany
|
|
84
|
+
test: ActionParams.test
|
|
85
|
+
wipe: ActionParams.wipe
|
|
86
|
+
}
|
|
87
|
+
export type ActionNames = keyof ActionNameParams
|
|
88
|
+
export class Contract extends BaseContract {
|
|
89
|
+
constructor(args: PartialBy<ContractArgs, 'abi' | 'account'>) {
|
|
90
|
+
super({
|
|
91
|
+
client: args.client,
|
|
92
|
+
abi: abi,
|
|
93
|
+
account: args.account || Name.from('platform.gm'),
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
action<T extends ActionNames>(
|
|
97
|
+
name: T,
|
|
98
|
+
data: ActionNameParams[T],
|
|
99
|
+
options?: ActionOptions
|
|
100
|
+
): Action {
|
|
101
|
+
return super.action(name, data, options)
|
|
102
|
+
}
|
|
103
|
+
table<T extends TableNames>(name: T, scope?: NameType): Table<RowType<T>> {
|
|
104
|
+
return super.table(name, scope, TableMap[name])
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
import type {Action, Checksum256Type, Int64Type, NameType, UInt64Type} from '@wharfkit/antelope'
|
|
2
|
+
import {
|
|
3
|
+
ABI,
|
|
4
|
+
Blob,
|
|
5
|
+
BlockTimestamp,
|
|
6
|
+
Checksum256,
|
|
7
|
+
Checksum512,
|
|
8
|
+
Int64,
|
|
9
|
+
Name,
|
|
10
|
+
Struct,
|
|
11
|
+
TimePoint,
|
|
12
|
+
UInt16,
|
|
13
|
+
UInt32,
|
|
14
|
+
UInt64,
|
|
15
|
+
UInt8,
|
|
16
|
+
} from '@wharfkit/antelope'
|
|
17
|
+
import type {ActionOptions, ContractArgs, PartialBy, Table} from '@wharfkit/contract'
|
|
18
|
+
import {Contract as BaseContract} from '@wharfkit/contract'
|
|
19
|
+
export const abiBlob = Blob.from(
|
|
20
|
+
'DmVvc2lvOjphYmkvMS4yABgHYWR2YW5jZQAABmFycml2ZQACBW93bmVyBG5hbWUCaWQGdWludDY0CGJ1eWdvb2RzAAQFYnV5ZXIEbmFtZQdzaGlwX2lkBnVpbnQ2NAdnb29kX2lkBnVpbnQ2NAhxdWFudGl0eQZ1aW50NjQJY2FyZ29fcm93AAQCaWQGdWludDY0B3NoaXBfaWQGdWludDY0B2dvb2RfaWQGdWludDY0CHF1YW50aXR5BnVpbnQ2NApjbGVhcnRhYmxlAAMKdGFibGVfbmFtZQRuYW1lBXNjb3BlBW5hbWU/CG1heF9yb3dzB3VpbnQ2ND8LY29vcmRpbmF0ZXMAAgF4BWludDY0AXkFaW50NjQGZW5hYmxlAAEHZW5hYmxlZARib29sCWVzdHRyYXZlbAACAmlkBnVpbnQ2NAtkZXN0aW5hdGlvbgtjb29yZGluYXRlcwRoYXNoAAEFdmFsdWUGc3RyaW5nBGluaXQAAgRzZWVkC2NoZWNrc3VtMjU2CWVwb2Noc2VlZAtjaGVja3N1bTI1NgRqb2luAAEHYWNjb3VudARuYW1lDGxvYWRlcl9zdGF0cwAECGNhcGFjaXR5BnVpbnQxNgRtYXNzBnVpbnQzMghxdWFudGl0eQZ1aW50MTYGdGhydXN0BnVpbnQzMgpwbGF5ZXJfcm93AAMFb3duZXIEbmFtZQdiYWxhbmNlBnVpbnQ2NARkZWJ0BnVpbnQ2NAlzZWxsZ29vZHMABAZzZWxsZXIEbmFtZQdzaGlwX2lkBnVpbnQ2NAdnb29kX2lkBnVpbnQ2NAhxdWFudGl0eQZ1aW50NjQMc2VxdWVuY2Vfcm93AAIDa2V5BG5hbWUFdmFsdWUGdWludDY0CHNoaXBfcm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50cmF2ZWxfc3VtbWFyeQAAAAAA0LBpC2NoZWNrc3VtNTEy'
|
|
21
|
+
)
|
|
22
|
+
export const abi = ABI.from(abiBlob)
|
|
23
|
+
export namespace Types {
|
|
24
|
+
@Struct.type('advance')
|
|
25
|
+
export class advance extends Struct {}
|
|
26
|
+
@Struct.type('arrive')
|
|
27
|
+
export class arrive extends Struct {
|
|
28
|
+
@Struct.field(Name)
|
|
29
|
+
owner!: Name
|
|
30
|
+
@Struct.field(UInt64)
|
|
31
|
+
id!: UInt64
|
|
32
|
+
}
|
|
33
|
+
@Struct.type('buygoods')
|
|
34
|
+
export class buygoods extends Struct {
|
|
35
|
+
@Struct.field(Name)
|
|
36
|
+
buyer!: Name
|
|
37
|
+
@Struct.field(UInt64)
|
|
38
|
+
ship_id!: UInt64
|
|
39
|
+
@Struct.field(UInt64)
|
|
40
|
+
good_id!: UInt64
|
|
41
|
+
@Struct.field(UInt64)
|
|
42
|
+
quantity!: UInt64
|
|
43
|
+
}
|
|
44
|
+
@Struct.type('cargo_row')
|
|
45
|
+
export class cargo_row extends Struct {
|
|
46
|
+
@Struct.field(UInt64)
|
|
47
|
+
id!: UInt64
|
|
48
|
+
@Struct.field(UInt64)
|
|
49
|
+
ship_id!: UInt64
|
|
50
|
+
@Struct.field(UInt64)
|
|
51
|
+
good_id!: UInt64
|
|
52
|
+
@Struct.field(UInt64)
|
|
53
|
+
quantity!: UInt64
|
|
54
|
+
}
|
|
55
|
+
@Struct.type('cleartable')
|
|
56
|
+
export class cleartable extends Struct {
|
|
57
|
+
@Struct.field(Name)
|
|
58
|
+
table_name!: Name
|
|
59
|
+
@Struct.field(Name, {optional: true})
|
|
60
|
+
scope?: Name
|
|
61
|
+
@Struct.field(UInt64, {optional: true})
|
|
62
|
+
max_rows?: UInt64
|
|
63
|
+
}
|
|
64
|
+
@Struct.type('coordinates')
|
|
65
|
+
export class coordinates extends Struct {
|
|
66
|
+
@Struct.field(Int64)
|
|
67
|
+
x!: Int64
|
|
68
|
+
@Struct.field(Int64)
|
|
69
|
+
y!: Int64
|
|
70
|
+
}
|
|
71
|
+
@Struct.type('enable')
|
|
72
|
+
export class enable extends Struct {
|
|
73
|
+
@Struct.field('bool')
|
|
74
|
+
enabled!: boolean
|
|
75
|
+
}
|
|
76
|
+
@Struct.type('esttravel')
|
|
77
|
+
export class esttravel extends Struct {
|
|
78
|
+
@Struct.field(UInt64)
|
|
79
|
+
id!: UInt64
|
|
80
|
+
@Struct.field(coordinates)
|
|
81
|
+
destination!: coordinates
|
|
82
|
+
}
|
|
83
|
+
@Struct.type('hash')
|
|
84
|
+
export class hash extends Struct {
|
|
85
|
+
@Struct.field('string')
|
|
86
|
+
value!: string
|
|
87
|
+
}
|
|
88
|
+
@Struct.type('init')
|
|
89
|
+
export class init extends Struct {
|
|
90
|
+
@Struct.field(Checksum256)
|
|
91
|
+
seed!: Checksum256
|
|
92
|
+
@Struct.field(Checksum256)
|
|
93
|
+
epochseed!: Checksum256
|
|
94
|
+
}
|
|
95
|
+
@Struct.type('join')
|
|
96
|
+
export class join extends Struct {
|
|
97
|
+
@Struct.field(Name)
|
|
98
|
+
account!: Name
|
|
99
|
+
}
|
|
100
|
+
@Struct.type('loader_stats')
|
|
101
|
+
export class loader_stats extends Struct {
|
|
102
|
+
@Struct.field(UInt16)
|
|
103
|
+
capacity!: UInt16
|
|
104
|
+
@Struct.field(UInt32)
|
|
105
|
+
mass!: UInt32
|
|
106
|
+
@Struct.field(UInt16)
|
|
107
|
+
quantity!: UInt16
|
|
108
|
+
@Struct.field(UInt32)
|
|
109
|
+
thrust!: UInt32
|
|
110
|
+
}
|
|
111
|
+
@Struct.type('player_row')
|
|
112
|
+
export class player_row extends Struct {
|
|
113
|
+
@Struct.field(Name)
|
|
114
|
+
owner!: Name
|
|
115
|
+
@Struct.field(UInt64)
|
|
116
|
+
balance!: UInt64
|
|
117
|
+
@Struct.field(UInt64)
|
|
118
|
+
debt!: UInt64
|
|
119
|
+
}
|
|
120
|
+
@Struct.type('sellgoods')
|
|
121
|
+
export class sellgoods extends Struct {
|
|
122
|
+
@Struct.field(Name)
|
|
123
|
+
seller!: Name
|
|
124
|
+
@Struct.field(UInt64)
|
|
125
|
+
ship_id!: UInt64
|
|
126
|
+
@Struct.field(UInt64)
|
|
127
|
+
good_id!: UInt64
|
|
128
|
+
@Struct.field(UInt64)
|
|
129
|
+
quantity!: UInt64
|
|
130
|
+
}
|
|
131
|
+
@Struct.type('sequence_row')
|
|
132
|
+
export class sequence_row extends Struct {
|
|
133
|
+
@Struct.field(Name)
|
|
134
|
+
key!: Name
|
|
135
|
+
@Struct.field(UInt64)
|
|
136
|
+
value!: UInt64
|
|
137
|
+
}
|
|
138
|
+
@Struct.type('ship_stats')
|
|
139
|
+
export class ship_stats extends Struct {
|
|
140
|
+
@Struct.field(UInt32)
|
|
141
|
+
capacity!: UInt32
|
|
142
|
+
@Struct.field(UInt32)
|
|
143
|
+
drain!: UInt32
|
|
144
|
+
@Struct.field(UInt32)
|
|
145
|
+
energy!: UInt32
|
|
146
|
+
@Struct.field(UInt64)
|
|
147
|
+
mass!: UInt64
|
|
148
|
+
@Struct.field(UInt16)
|
|
149
|
+
orbit!: UInt16
|
|
150
|
+
@Struct.field(UInt32)
|
|
151
|
+
recharge!: UInt32
|
|
152
|
+
@Struct.field(UInt64)
|
|
153
|
+
thrust!: UInt64
|
|
154
|
+
}
|
|
155
|
+
@Struct.type('travel_plan')
|
|
156
|
+
export class travel_plan extends Struct {
|
|
157
|
+
@Struct.field(coordinates)
|
|
158
|
+
destination!: coordinates
|
|
159
|
+
@Struct.field(TimePoint)
|
|
160
|
+
departure!: TimePoint
|
|
161
|
+
@Struct.field(UInt32)
|
|
162
|
+
duration!: UInt32
|
|
163
|
+
}
|
|
164
|
+
@Struct.type('ship_row')
|
|
165
|
+
export class ship_row extends Struct {
|
|
166
|
+
@Struct.field(UInt64)
|
|
167
|
+
id!: UInt64
|
|
168
|
+
@Struct.field(Name)
|
|
169
|
+
owner!: Name
|
|
170
|
+
@Struct.field('string')
|
|
171
|
+
name!: string
|
|
172
|
+
@Struct.field(coordinates)
|
|
173
|
+
location!: coordinates
|
|
174
|
+
@Struct.field(UInt8)
|
|
175
|
+
skin!: UInt8
|
|
176
|
+
@Struct.field(UInt8)
|
|
177
|
+
tier!: UInt8
|
|
178
|
+
@Struct.field(ship_stats)
|
|
179
|
+
stats!: ship_stats
|
|
180
|
+
@Struct.field(loader_stats)
|
|
181
|
+
loaders!: loader_stats
|
|
182
|
+
@Struct.field(travel_plan, {optional: true})
|
|
183
|
+
travelplan?: travel_plan
|
|
184
|
+
}
|
|
185
|
+
@Struct.type('state_row')
|
|
186
|
+
export class state_row extends Struct {
|
|
187
|
+
@Struct.field('bool')
|
|
188
|
+
enabled!: boolean
|
|
189
|
+
@Struct.field(UInt64)
|
|
190
|
+
epoch!: UInt64
|
|
191
|
+
@Struct.field(Checksum256)
|
|
192
|
+
epochseed!: Checksum256
|
|
193
|
+
@Struct.field(BlockTimestamp)
|
|
194
|
+
genesis!: BlockTimestamp
|
|
195
|
+
@Struct.field(Checksum256)
|
|
196
|
+
seed!: Checksum256
|
|
197
|
+
}
|
|
198
|
+
@Struct.type('travel_summary')
|
|
199
|
+
export class travel_summary extends Struct {
|
|
200
|
+
@Struct.field(ship_stats)
|
|
201
|
+
stats!: ship_stats
|
|
202
|
+
@Struct.field(loader_stats)
|
|
203
|
+
loaders!: loader_stats
|
|
204
|
+
@Struct.field(coordinates)
|
|
205
|
+
origin!: coordinates
|
|
206
|
+
@Struct.field(coordinates)
|
|
207
|
+
destination!: coordinates
|
|
208
|
+
@Struct.field(UInt64)
|
|
209
|
+
distance!: UInt64
|
|
210
|
+
@Struct.field(UInt64)
|
|
211
|
+
totalmass!: UInt64
|
|
212
|
+
@Struct.field(UInt64)
|
|
213
|
+
acceleration!: UInt64
|
|
214
|
+
@Struct.field(UInt64)
|
|
215
|
+
flighttime!: UInt64
|
|
216
|
+
@Struct.field(UInt64)
|
|
217
|
+
energyusage!: UInt64
|
|
218
|
+
@Struct.field(UInt64)
|
|
219
|
+
rechargetime!: UInt64
|
|
220
|
+
@Struct.field(UInt64)
|
|
221
|
+
loadtime!: UInt64
|
|
222
|
+
@Struct.field(UInt64)
|
|
223
|
+
time!: UInt64
|
|
224
|
+
}
|
|
225
|
+
@Struct.type('summary_row')
|
|
226
|
+
export class summary_row extends Struct {
|
|
227
|
+
@Struct.field(Name)
|
|
228
|
+
key!: Name
|
|
229
|
+
@Struct.field(travel_summary)
|
|
230
|
+
value!: travel_summary
|
|
231
|
+
}
|
|
232
|
+
@Struct.type('test')
|
|
233
|
+
export class test extends Struct {
|
|
234
|
+
@Struct.field('string')
|
|
235
|
+
data!: string
|
|
236
|
+
}
|
|
237
|
+
@Struct.type('travel')
|
|
238
|
+
export class travel extends Struct {
|
|
239
|
+
@Struct.field(Name)
|
|
240
|
+
owner!: Name
|
|
241
|
+
@Struct.field(UInt64)
|
|
242
|
+
id!: UInt64
|
|
243
|
+
@Struct.field(coordinates)
|
|
244
|
+
destination!: coordinates
|
|
245
|
+
@Struct.field('bool')
|
|
246
|
+
recharge!: boolean
|
|
247
|
+
}
|
|
248
|
+
@Struct.type('wipe')
|
|
249
|
+
export class wipe extends Struct {}
|
|
250
|
+
}
|
|
251
|
+
export const TableMap = {
|
|
252
|
+
cargo: Types.cargo_row,
|
|
253
|
+
player: Types.player_row,
|
|
254
|
+
sequence: Types.sequence_row,
|
|
255
|
+
ship: Types.ship_row,
|
|
256
|
+
state: Types.state_row,
|
|
257
|
+
summary: Types.summary_row,
|
|
258
|
+
}
|
|
259
|
+
export interface TableTypes {
|
|
260
|
+
cargo: Types.cargo_row
|
|
261
|
+
player: Types.player_row
|
|
262
|
+
sequence: Types.sequence_row
|
|
263
|
+
ship: Types.ship_row
|
|
264
|
+
state: Types.state_row
|
|
265
|
+
summary: Types.summary_row
|
|
266
|
+
}
|
|
267
|
+
export type RowType<T> = T extends keyof TableTypes ? TableTypes[T] : any
|
|
268
|
+
export type TableNames = keyof TableTypes
|
|
269
|
+
export namespace ActionParams {
|
|
270
|
+
export namespace Type {
|
|
271
|
+
export interface coordinates {
|
|
272
|
+
x: Int64Type
|
|
273
|
+
y: Int64Type
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
export interface advance {}
|
|
277
|
+
export interface arrive {
|
|
278
|
+
owner: NameType
|
|
279
|
+
id: UInt64Type
|
|
280
|
+
}
|
|
281
|
+
export interface buygoods {
|
|
282
|
+
buyer: NameType
|
|
283
|
+
ship_id: UInt64Type
|
|
284
|
+
good_id: UInt64Type
|
|
285
|
+
quantity: UInt64Type
|
|
286
|
+
}
|
|
287
|
+
export interface cleartable {
|
|
288
|
+
table_name: NameType
|
|
289
|
+
scope?: NameType
|
|
290
|
+
max_rows?: UInt64Type
|
|
291
|
+
}
|
|
292
|
+
export interface enable {
|
|
293
|
+
enabled: boolean
|
|
294
|
+
}
|
|
295
|
+
export interface esttravel {
|
|
296
|
+
id: UInt64Type
|
|
297
|
+
destination: Type.coordinates
|
|
298
|
+
}
|
|
299
|
+
export interface hash {
|
|
300
|
+
value: string
|
|
301
|
+
}
|
|
302
|
+
export interface init {
|
|
303
|
+
seed: Checksum256Type
|
|
304
|
+
epochseed: Checksum256Type
|
|
305
|
+
}
|
|
306
|
+
export interface join {
|
|
307
|
+
account: NameType
|
|
308
|
+
}
|
|
309
|
+
export interface sellgoods {
|
|
310
|
+
seller: NameType
|
|
311
|
+
ship_id: UInt64Type
|
|
312
|
+
good_id: UInt64Type
|
|
313
|
+
quantity: UInt64Type
|
|
314
|
+
}
|
|
315
|
+
export interface test {
|
|
316
|
+
data: string
|
|
317
|
+
}
|
|
318
|
+
export interface travel {
|
|
319
|
+
owner: NameType
|
|
320
|
+
id: UInt64Type
|
|
321
|
+
destination: Type.coordinates
|
|
322
|
+
recharge: boolean
|
|
323
|
+
}
|
|
324
|
+
export interface wipe {}
|
|
325
|
+
}
|
|
326
|
+
export interface ActionNameParams {
|
|
327
|
+
advance: ActionParams.advance
|
|
328
|
+
arrive: ActionParams.arrive
|
|
329
|
+
buygoods: ActionParams.buygoods
|
|
330
|
+
cleartable: ActionParams.cleartable
|
|
331
|
+
enable: ActionParams.enable
|
|
332
|
+
esttravel: ActionParams.esttravel
|
|
333
|
+
hash: ActionParams.hash
|
|
334
|
+
init: ActionParams.init
|
|
335
|
+
join: ActionParams.join
|
|
336
|
+
sellgoods: ActionParams.sellgoods
|
|
337
|
+
test: ActionParams.test
|
|
338
|
+
travel: ActionParams.travel
|
|
339
|
+
wipe: ActionParams.wipe
|
|
340
|
+
}
|
|
341
|
+
export type ActionNames = keyof ActionNameParams
|
|
342
|
+
export interface ActionReturnValues {
|
|
343
|
+
esttravel: Types.travel_summary
|
|
344
|
+
hash: Checksum512
|
|
345
|
+
}
|
|
346
|
+
export type ActionReturnNames = keyof ActionReturnValues
|
|
347
|
+
export class Contract extends BaseContract {
|
|
348
|
+
constructor(args: PartialBy<ContractArgs, 'abi' | 'account'>) {
|
|
349
|
+
super({
|
|
350
|
+
client: args.client,
|
|
351
|
+
abi: abi,
|
|
352
|
+
account: args.account || Name.from('shipload.gm'),
|
|
353
|
+
})
|
|
354
|
+
}
|
|
355
|
+
action<T extends ActionNames>(
|
|
356
|
+
name: T,
|
|
357
|
+
data: ActionNameParams[T],
|
|
358
|
+
options?: ActionOptions
|
|
359
|
+
): Action {
|
|
360
|
+
return super.action(name, data, options)
|
|
361
|
+
}
|
|
362
|
+
readonly<T extends ActionReturnNames>(
|
|
363
|
+
name: T,
|
|
364
|
+
data?: ActionNameParams[T]
|
|
365
|
+
): ActionReturnValues[T] {
|
|
366
|
+
return super.readonly(name, data) as unknown as ActionReturnValues[T]
|
|
367
|
+
}
|
|
368
|
+
table<T extends TableNames>(name: T, scope?: NameType): Table<RowType<T>> {
|
|
369
|
+
return super.table(name, scope, TableMap[name])
|
|
370
|
+
}
|
|
371
|
+
}
|
package/src/hash.ts
ADDED
package/src/index.ts
CHANGED
package/src/ship.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export class Ship {}
|
package/src/shipload.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export class Shipload {}
|
package/src/travel.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {Coordinates, ServerContract} from './index-module'
|
|
2
|
+
|
|
3
|
+
export function distance(ship: ServerContract.Types.ship_row): number {
|
|
4
|
+
if (ship.travelplan) {
|
|
5
|
+
const {departure, duration} = ship.travelplan
|
|
6
|
+
return (+new Date() - +departure.toDate()) / (Number(duration) * 1000)
|
|
7
|
+
}
|
|
8
|
+
return 0
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function lerp(origin: Coordinates, destination: Coordinates, time: number) {
|
|
12
|
+
return {
|
|
13
|
+
x: (1 - time) * origin.x + time * destination.x,
|
|
14
|
+
y: (1 - time) * origin.y + time * destination.y,
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function rotation(origin: Coordinates, destination: Coordinates) {
|
|
19
|
+
return Math.atan2(destination.y - origin.y, destination.x - origin.x) * (180 / Math.PI) + 90
|
|
20
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface Coordinates {
|
|
2
|
+
x: number
|
|
3
|
+
y: number
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface CameraPosition extends Coordinates {
|
|
7
|
+
z: number
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface Dimensions {
|
|
11
|
+
width: number
|
|
12
|
+
height: number
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface Distance {
|
|
16
|
+
origin: Coordinates
|
|
17
|
+
destination: Coordinates
|
|
18
|
+
distance: number
|
|
19
|
+
}
|
package/.editorconfig
DELETED
package/.eslintrc
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"root": true,
|
|
3
|
-
"ignorePatterns": ["lib/*", "tests/*", "node_modules/**"],
|
|
4
|
-
"extends": [
|
|
5
|
-
"eslint:recommended",
|
|
6
|
-
"plugin:@typescript-eslint/eslint-recommended",
|
|
7
|
-
"plugin:@typescript-eslint/recommended",
|
|
8
|
-
"plugin:prettier/recommended"
|
|
9
|
-
],
|
|
10
|
-
"rules": {
|
|
11
|
-
"prettier/prettier": "warn",
|
|
12
|
-
"no-console": "warn",
|
|
13
|
-
"sort-imports": [
|
|
14
|
-
"warn",
|
|
15
|
-
{
|
|
16
|
-
"ignoreCase": true,
|
|
17
|
-
"ignoreDeclarationSort": true
|
|
18
|
-
}
|
|
19
|
-
],
|
|
20
|
-
"@typescript-eslint/no-empty-interface": "off", // TODO: This should be removed before PR #1
|
|
21
|
-
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
22
|
-
"@typescript-eslint/no-explicit-any": "off",
|
|
23
|
-
"@typescript-eslint/no-namespace": "off",
|
|
24
|
-
"@typescript-eslint/no-non-null-assertion": "off",
|
|
25
|
-
"@typescript-eslint/no-empty-function": "warn",
|
|
26
|
-
"no-inner-declarations": "off"
|
|
27
|
-
}
|
|
28
|
-
}
|
package/.prettierrc
DELETED
package/Makefile
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
SHELL := /bin/bash
|
|
2
|
-
SRC_FILES := $(shell find src -name '*.ts')
|
|
3
|
-
TEST_FILES := $(shell find test/tests -name '*.ts')
|
|
4
|
-
BIN := ./node_modules/.bin
|
|
5
|
-
MOCHA_OPTS := -u tdd -r ts-node/register -r tsconfig-paths/register --extension ts
|
|
6
|
-
NYC_OPTS := --temp-dir build/nyc_output --report-dir build/coverage
|
|
7
|
-
|
|
8
|
-
lib: ${SRC_FILES} package.json tsconfig.json node_modules rollup.config.js
|
|
9
|
-
@${BIN}/rollup -c && touch lib
|
|
10
|
-
|
|
11
|
-
.PHONY: test
|
|
12
|
-
test: node_modules
|
|
13
|
-
@TS_NODE_PROJECT='./test/tsconfig.json' MOCK_DIR='./test/data' \
|
|
14
|
-
${BIN}/mocha ${MOCHA_OPTS} ${TEST_FILES} --no-timeout --grep '$(grep)'
|
|
15
|
-
|
|
16
|
-
test/watch: node_modules
|
|
17
|
-
@TS_NODE_PROJECT='./test/tsconfig.json' \
|
|
18
|
-
${BIN}/mocha --watch ${MOCHA_OPTS} ${TEST_FILES} --no-timeout --grep '$(grep)'
|
|
19
|
-
|
|
20
|
-
build/coverage: ${SRC_FILES} ${TEST_FILES} node_modules
|
|
21
|
-
@TS_NODE_PROJECT='./test/tsconfig.json' MOCK_DIR='./test/data' \
|
|
22
|
-
${BIN}/nyc ${NYC_OPTS} --reporter=html \
|
|
23
|
-
${BIN}/mocha ${MOCHA_OPTS} -R nyan ${TEST_FILES}
|
|
24
|
-
|
|
25
|
-
.PHONY: coverage
|
|
26
|
-
coverage: build/coverage
|
|
27
|
-
@open build/coverage/index.html
|
|
28
|
-
|
|
29
|
-
.PHONY: ci-test
|
|
30
|
-
ci-test: node_modules
|
|
31
|
-
@TS_NODE_PROJECT='./test/tsconfig.json' MOCK_DIR='./test/data' \
|
|
32
|
-
${BIN}/nyc ${NYC_OPTS} --reporter=text \
|
|
33
|
-
${BIN}/mocha ${MOCHA_OPTS} -R list ${TEST_FILES}
|
|
34
|
-
|
|
35
|
-
.PHONY: check
|
|
36
|
-
check: node_modules
|
|
37
|
-
@${BIN}/eslint src test --ext .ts --max-warnings 0 --format unix && echo "Ok"
|
|
38
|
-
|
|
39
|
-
.PHONY: format
|
|
40
|
-
format: node_modules
|
|
41
|
-
@${BIN}/eslint src --ext .ts --fix
|
|
42
|
-
|
|
43
|
-
.PHONY: docs
|
|
44
|
-
docs: build/docs
|
|
45
|
-
@open build/docs/index.html
|
|
46
|
-
|
|
47
|
-
build/docs: $(SRC_FILES) node_modules
|
|
48
|
-
@${BIN}/typedoc --out build/docs \
|
|
49
|
-
--excludeInternal --excludePrivate --excludeProtected \
|
|
50
|
-
--includeVersion --hideGenerator --readme none \
|
|
51
|
-
src/index.ts
|
|
52
|
-
|
|
53
|
-
build/pages: build/coverage build/docs
|
|
54
|
-
@mkdir -p build/pages
|
|
55
|
-
@cp -r build/docs/* build/pages/
|
|
56
|
-
@cp -r build/coverage build/pages/coverage
|
|
57
|
-
|
|
58
|
-
.PHONY: deploy-pages
|
|
59
|
-
deploy-pages: | clean lib build/pages node_modules
|
|
60
|
-
@${BIN}/gh-pages -d build/pages
|
|
61
|
-
|
|
62
|
-
build/browser.html: $(SRC_FILES) $(TEST_FILES) test/rollup.config.js node_modules
|
|
63
|
-
@${BIN}/rollup -c test/rollup.config.js
|
|
64
|
-
|
|
65
|
-
node_modules:
|
|
66
|
-
yarn install --non-interactive --frozen-lockfile --ignore-scripts
|
|
67
|
-
|
|
68
|
-
.PHONY: clean
|
|
69
|
-
clean:
|
|
70
|
-
rm -rf lib/ build/ build/browser.html
|
|
71
|
-
|
|
72
|
-
.PHONY: distclean
|
|
73
|
-
distclean: clean
|
|
74
|
-
rm -rf node_modules/
|