@shipload/sdk 1.0.0-next.32 → 1.0.0-next.34

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.
@@ -30,15 +30,15 @@
30
30
  },
31
31
  {
32
32
  "outputItemId": 10002,
33
- "outputMass": 6000,
33
+ "outputMass": 4000,
34
34
  "inputs": [
35
35
  {
36
36
  "itemId": 401,
37
- "quantity": 6
37
+ "quantity": 5
38
38
  },
39
39
  {
40
40
  "itemId": 501,
41
- "quantity": 9
41
+ "quantity": 5
42
42
  }
43
43
  ],
44
44
  "statSlots": [
@@ -92,15 +92,15 @@
92
92
  },
93
93
  {
94
94
  "outputItemId": 10004,
95
- "outputMass": 6000,
95
+ "outputMass": 4000,
96
96
  "inputs": [
97
97
  {
98
98
  "itemId": 201,
99
- "quantity": 6
99
+ "quantity": 5
100
100
  },
101
101
  {
102
102
  "itemId": 101,
103
- "quantity": 9
103
+ "quantity": 5
104
104
  }
105
105
  ],
106
106
  "statSlots": [
@@ -125,15 +125,15 @@
125
125
  },
126
126
  {
127
127
  "outputItemId": 10005,
128
- "outputMass": 6000,
128
+ "outputMass": 4000,
129
129
  "inputs": [
130
130
  {
131
131
  "itemId": 101,
132
- "quantity": 6
132
+ "quantity": 5
133
133
  },
134
134
  {
135
135
  "itemId": 301,
136
- "quantity": 9
136
+ "quantity": 5
137
137
  }
138
138
  ],
139
139
  "statSlots": [
@@ -245,15 +245,15 @@
245
245
  },
246
246
  {
247
247
  "outputItemId": 10009,
248
- "outputMass": 6000,
248
+ "outputMass": 4000,
249
249
  "inputs": [
250
250
  {
251
251
  "itemId": 301,
252
- "quantity": 6
252
+ "quantity": 5
253
253
  },
254
254
  {
255
255
  "itemId": 401,
256
- "quantity": 9
256
+ "quantity": 5
257
257
  }
258
258
  ],
259
259
  "statSlots": [
@@ -278,15 +278,15 @@
278
278
  },
279
279
  {
280
280
  "outputItemId": 10010,
281
- "outputMass": 6000,
281
+ "outputMass": 4000,
282
282
  "inputs": [
283
283
  {
284
284
  "itemId": 501,
285
- "quantity": 6
285
+ "quantity": 5
286
286
  },
287
287
  {
288
288
  "itemId": 201,
289
- "quantity": 9
289
+ "quantity": 5
290
290
  }
291
291
  ],
292
292
  "statSlots": [
@@ -311,7 +311,7 @@
311
311
  },
312
312
  {
313
313
  "outputItemId": 10100,
314
- "outputMass": 900000,
314
+ "outputMass": 960000,
315
315
  "inputs": [
316
316
  {
317
317
  "itemId": 10003,
@@ -340,7 +340,7 @@
340
340
  },
341
341
  {
342
342
  "outputItemId": 10101,
343
- "outputMass": 1400000,
343
+ "outputMass": 960000,
344
344
  "inputs": [
345
345
  {
346
346
  "itemId": 10004,
@@ -369,7 +369,7 @@
369
369
  },
370
370
  {
371
371
  "outputItemId": 10102,
372
- "outputMass": 1200000,
372
+ "outputMass": 960000,
373
373
  "inputs": [
374
374
  {
375
375
  "itemId": 10005,
@@ -418,7 +418,7 @@
418
418
  },
419
419
  {
420
420
  "outputItemId": 10103,
421
- "outputMass": 1000000,
421
+ "outputMass": 960000,
422
422
  "inputs": [
423
423
  {
424
424
  "itemId": 10007,
@@ -447,7 +447,7 @@
447
447
  },
448
448
  {
449
449
  "outputItemId": 10104,
450
- "outputMass": 1200000,
450
+ "outputMass": 960000,
451
451
  "inputs": [
452
452
  {
453
453
  "itemId": 10008,
@@ -480,7 +480,7 @@
480
480
  },
481
481
  {
482
482
  "outputItemId": 10105,
483
- "outputMass": 1200000,
483
+ "outputMass": 960000,
484
484
  "inputs": [
485
485
  {
486
486
  "itemId": 10001,
@@ -529,7 +529,7 @@
529
529
  },
530
530
  {
531
531
  "outputItemId": 10106,
532
- "outputMass": 1400000,
532
+ "outputMass": 960000,
533
533
  "inputs": [
534
534
  {
535
535
  "itemId": 10004,
@@ -570,7 +570,7 @@
570
570
  },
571
571
  {
572
572
  "outputItemId": 10107,
573
- "outputMass": 1400000,
573
+ "outputMass": 960000,
574
574
  "inputs": [
575
575
  {
576
576
  "itemId": 10004,
@@ -602,7 +602,7 @@
602
602
  },
603
603
  {
604
604
  "outputItemId": 10108,
605
- "outputMass": 1000000,
605
+ "outputMass": 960000,
606
606
  "inputs": [
607
607
  {
608
608
  "itemId": 10003,
@@ -651,7 +651,7 @@
651
651
  },
652
652
  {
653
653
  "outputItemId": 10200,
654
- "outputMass": 1500000,
654
+ "outputMass": 1300000,
655
655
  "inputs": [
656
656
  {
657
657
  "itemId": 10001,
@@ -700,7 +700,7 @@
700
700
  },
701
701
  {
702
702
  "outputItemId": 10201,
703
- "outputMass": 2300000,
703
+ "outputMass": 1900000,
704
704
  "inputs": [
705
705
  {
706
706
  "itemId": 10001,
@@ -749,7 +749,7 @@
749
749
  },
750
750
  {
751
751
  "outputItemId": 10202,
752
- "outputMass": 5800000,
752
+ "outputMass": 4800000,
753
753
  "inputs": [
754
754
  {
755
755
  "itemId": 10001,
@@ -798,7 +798,7 @@
798
798
  },
799
799
  {
800
800
  "outputItemId": 10203,
801
- "outputMass": 4400000,
801
+ "outputMass": 3700000,
802
802
  "inputs": [
803
803
  {
804
804
  "itemId": 10001,
@@ -847,7 +847,7 @@
847
847
  },
848
848
  {
849
849
  "outputItemId": 10204,
850
- "outputMass": 5500000,
850
+ "outputMass": 4600000,
851
851
  "inputs": [
852
852
  {
853
853
  "itemId": 10001,
@@ -97,7 +97,7 @@ export function computeLoaderCapabilities(stats: Record<string, number>): {
97
97
 
98
98
  return {
99
99
  mass: Math.max(200, 2000 - Math.floor(insulation * 2)),
100
- thrust: 1 + Math.floor(plasticity / 500),
100
+ thrust: 1 + Math.floor((plasticity * plasticity) / 10000),
101
101
  quantity: 1,
102
102
  }
103
103
  }
@@ -65,6 +65,8 @@ export type {
65
65
  Reservation,
66
66
  } from './managers'
67
67
  export type {EntityRefInput} from './managers/actions'
68
+ export type {WrapDeposit} from './managers/nft'
69
+ export {resolveLockedAmount} from './managers/nft'
68
70
 
69
71
  export {
70
72
  getItem,
@@ -65,6 +65,12 @@ export class ActionsManager extends BaseManager {
65
65
  return this.server.action('resolve', params)
66
66
  }
67
67
 
68
+ resolveall(owner: NameType): Action {
69
+ return this.server.action('resolveall', {
70
+ owner: Name.from(owner),
71
+ })
72
+ }
73
+
68
74
  cancel(entityId: UInt64Type, laneKey: number, count: UInt64Type): Action {
69
75
  return this.server.action('cancel', {
70
76
  id: UInt64.from(entityId),
@@ -46,6 +46,7 @@ export interface SourceCargoStack {
46
46
 
47
47
  export interface FinalizerEntityRef {
48
48
  entityId: UInt64
49
+ entityType: Name
49
50
  name: string
50
51
  capability: FinalizerCapability
51
52
  crafterSpeed: number
@@ -71,7 +71,8 @@ export class ConstructionManager extends BaseManager {
71
71
  if (speed === undefined) continue
72
72
  out.push({
73
73
  entityId: entity.id,
74
- name: entity.id.toString(),
74
+ entityType: entity.type,
75
+ name: entity.entity_name,
75
76
  capability: 'crafter',
76
77
  crafterSpeed: speed,
77
78
  estimatedDuration: this.estimateFinalizeDuration(target, speed),
@@ -0,0 +1,14 @@
1
+ import {describe, expect, test} from 'bun:test'
2
+ import {resolveLockedAmount} from './nft'
3
+
4
+ describe('resolveLockedAmount', () => {
5
+ test('no fee refunds the full cost', () => {
6
+ expect(resolveLockedAmount(5_0000n, 0)).toBe(5_0000n)
7
+ })
8
+ test('2% fee floors the fee and refunds the remainder', () => {
9
+ expect(resolveLockedAmount(5_0000n, 200)).toBe(4_9000n)
10
+ })
11
+ test('rounding floors the fee (contract uses integer division)', () => {
12
+ expect(resolveLockedAmount(101n, 250)).toBe(99n) // fee = floor(101*250/10000)=2
13
+ })
14
+ })
@@ -1,12 +1,26 @@
1
1
  import {UInt64, type UInt64Type} from '@wharfkit/antelope'
2
2
  import {BaseManager} from './base'
3
- import type {ServerContract} from '../contracts'
3
+ import type {PlatformContract, ServerContract} from '../contracts'
4
4
 
5
5
  export interface NftConfigForItem {
6
6
  templateId: number
7
7
  schemaName: string
8
8
  }
9
9
 
10
+ export interface WrapDeposit {
11
+ cost: bigint
12
+ refund: bigint
13
+ feePct: number
14
+ symbol: string
15
+ precision: number
16
+ tokenContract: string
17
+ }
18
+
19
+ export function resolveLockedAmount(cost: bigint, feePctBasisPoints: number): bigint {
20
+ const fee = (cost * BigInt(feePctBasisPoints)) / 10_000n
21
+ return cost - fee
22
+ }
23
+
10
24
  export class NftManager extends BaseManager {
11
25
  private cache = new Map<string, NftConfigForItem | null>()
12
26
 
@@ -25,4 +39,32 @@ export class NftManager extends BaseManager {
25
39
  this.cache.set(key, result)
26
40
  return result ?? undefined
27
41
  }
42
+
43
+ async getWrapDeposit(itemType: number, tier: number): Promise<WrapDeposit | null> {
44
+ const key = UInt64.from((BigInt(itemType) << 8n) | BigInt(tier))
45
+ const costRow = (await this.server.table('wrapcost').get(key)) as
46
+ | ServerContract.Types.wrapcost_row
47
+ | undefined
48
+ const cost = costRow ? BigInt(costRow.amount.toString()) : 0n
49
+ if (cost === 0n) return null
50
+
51
+ const cfg = (await this.server.table('wrapconfig').get()) as
52
+ | ServerContract.Types.wrapconfig_row
53
+ | undefined
54
+ const feePctBasisPoints = cfg ? Number(cfg.fee_pct) : 0
55
+
56
+ const depositCfg = (await this.platform.table('depositcfg').get()) as
57
+ | PlatformContract.Types.depositcfg_row
58
+ | undefined
59
+ if (!depositCfg) return null
60
+
61
+ return {
62
+ cost,
63
+ refund: resolveLockedAmount(cost, feePctBasisPoints),
64
+ feePct: feePctBasisPoints / 100,
65
+ symbol: depositCfg.token_symbol.code.toString(),
66
+ precision: depositCfg.token_symbol.precision,
67
+ tokenContract: depositCfg.token_contract.toString(),
68
+ }
69
+ }
28
70
  }
@@ -79,13 +79,10 @@ export class PlotManager extends BaseManager {
79
79
  }
80
80
 
81
81
  let state: BuildableTarget['state']
82
- const taskType = activeTask?.type.toNumber()
83
82
  if (scheduledBuild?.hasStarted) {
84
83
  state = 'finalizing'
85
84
  } else if (scheduledBuild) {
86
85
  state = 'scheduled'
87
- } else if (taskType === TaskType.CLAIMPLOT) {
88
- state = 'initializing'
89
86
  } else if (progress.isComplete) {
90
87
  state = 'ready'
91
88
  } else {
@@ -57,7 +57,7 @@ export const computeGathererDrain = (con: number): number =>
57
57
  export const computeGathererDepth = (tol: number, tier: number): number =>
58
58
  gathererDepthForTier(tol, tier)
59
59
  export const computeLoaderMass = (ins: number): number => Math.max(200, 2000 - ins * 2)
60
- export const computeLoaderThrust = (pla: number): number => 1 + idiv(pla, 500)
60
+ export const computeLoaderThrust = (pla: number): number => 1 + idiv(pla * pla, 10000)
61
61
  export const computeCrafterSpeed = (rea: number): number => 100 + idiv(rea * 4, 5)
62
62
  export const computeCrafterDrain = (fin: number): number => Math.max(5, 30 - idiv(fin, 33))
63
63
  export const computeHaulerCapacity = (fin: number): number => Math.max(1, 1 + idiv(fin, 400))
@@ -31,13 +31,14 @@ export function composeIdleResolve(
31
31
  add(blocker.id)
32
32
  }
33
33
 
34
- for (const hold of blocker.holds ?? []) {
35
- const counterpartId = hold.counterpart.entity_id
36
- if (lookupCounterpart) {
34
+ // Without a lookup we cannot confirm the counterpart has a completed task, so skip it.
35
+ if (lookupCounterpart) {
36
+ for (const hold of blocker.holds ?? []) {
37
+ const counterpartId = hold.counterpart.entity_id
37
38
  const counterpart = lookupCounterpart(counterpartId)
38
39
  if (!counterpart || !hasResolvable(counterpart, now)) continue
40
+ add(counterpartId)
39
41
  }
40
- add(counterpartId)
41
42
  }
42
43
 
43
44
  return [...ids.map((id) => actions.resolve(id)), action]