@attocash/cli 0.2.3 → 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.
Files changed (137) hide show
  1. package/README.md +148 -7
  2. package/dist/application/app.d.ts +34 -3
  3. package/dist/application/app.js +138 -126
  4. package/dist/application/operations.d.ts +3 -0
  5. package/dist/application/operations.js +30 -8
  6. package/dist/cli/cli.d.ts +1 -0
  7. package/dist/cli/cli.js +101 -13
  8. package/dist/cli/onboarding.d.ts +13 -0
  9. package/dist/cli/onboarding.js +99 -2
  10. package/dist/cli/output.js +18 -2
  11. package/dist/doctor/profile.js +2 -1
  12. package/dist/internal-marketplace.d.ts +25 -0
  13. package/dist/internal-marketplace.js +50 -0
  14. package/dist/marketplace/approval-files.d.ts +3 -0
  15. package/dist/marketplace/approval-files.js +97 -0
  16. package/dist/marketplace/approval-preview.d.ts +2 -0
  17. package/dist/marketplace/approval-preview.js +86 -0
  18. package/dist/marketplace/proof-approval.d.ts +82 -0
  19. package/dist/marketplace/proof-approval.js +671 -0
  20. package/dist/marketplace/topups.d.ts +82 -0
  21. package/dist/marketplace/topups.js +485 -0
  22. package/dist/network/batching.d.ts +2 -0
  23. package/dist/network/batching.js +23 -0
  24. package/dist/network/entry.d.ts +2 -0
  25. package/dist/network/entry.js +35 -0
  26. package/dist/network/reader.d.ts +2 -0
  27. package/dist/network/reader.js +125 -37
  28. package/dist/spending/approval.d.ts +5 -0
  29. package/dist/spending/approval.js +2 -0
  30. package/dist/spending/atto-x402.d.ts +31 -0
  31. package/dist/spending/atto-x402.js +174 -0
  32. package/dist/spending/ledger.d.ts +74 -2
  33. package/dist/spending/ledger.js +298 -7
  34. package/dist/spending/payments.d.ts +105 -5
  35. package/dist/spending/payments.js +795 -11
  36. package/dist/storage/recovery-seed.d.ts +13 -0
  37. package/dist/storage/recovery-seed.js +93 -0
  38. package/dist/storage/state.d.ts +4 -0
  39. package/dist/storage/state.js +32 -2
  40. package/dist/wallet/receive.d.ts +39 -0
  41. package/dist/wallet/receive.js +264 -0
  42. package/dist/wallet/signing.d.ts +1 -0
  43. package/dist/wallet/signing.js +37 -21
  44. package/dist/wallet/types.d.ts +1 -0
  45. package/node_modules/@attocash/commons-core/Kotlin-DateTime-library-kotlinx-datetime.mjs +1922 -1918
  46. package/node_modules/@attocash/commons-core/Kotlin-DateTime-library-kotlinx-datetime.mjs.map +1 -1
  47. package/node_modules/@attocash/commons-core/README.md +9 -0
  48. package/node_modules/@attocash/commons-core/commons-commons-core.d.mts +10 -0
  49. package/node_modules/@attocash/commons-core/commons-commons-core.mjs +2543 -2434
  50. package/node_modules/@attocash/commons-core/commons-commons-core.mjs.map +1 -1
  51. package/node_modules/@attocash/commons-core/kotlin-kotlin-stdlib.mjs +4695 -4227
  52. package/node_modules/@attocash/commons-core/kotlin-kotlin-stdlib.mjs.map +1 -1
  53. package/node_modules/@attocash/commons-core/kotlin_org_jetbrains_kotlin_kotlin_dom_api_compat.mjs.map +1 -1
  54. package/node_modules/@attocash/commons-core/kotlinx-io-kotlinx-io-bytestring.mjs +60 -60
  55. package/node_modules/@attocash/commons-core/kotlinx-io-kotlinx-io-bytestring.mjs.map +1 -1
  56. package/node_modules/@attocash/commons-core/kotlinx-io-kotlinx-io-core.mjs +651 -631
  57. package/node_modules/@attocash/commons-core/kotlinx-io-kotlinx-io-core.mjs.map +1 -1
  58. package/node_modules/@attocash/commons-core/kotlinx-serialization-kotlinx-serialization-core.mjs +2294 -2295
  59. package/node_modules/@attocash/commons-core/kotlinx-serialization-kotlinx-serialization-core.mjs.map +1 -1
  60. package/node_modules/@attocash/commons-core/kotlinx-serialization-kotlinx-serialization-json.mjs +1732 -1701
  61. package/node_modules/@attocash/commons-core/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -1
  62. package/node_modules/@attocash/commons-core/package.json +1 -1
  63. package/node_modules/@attocash/commons-node/commons-commons-node.d.mts +1 -0
  64. package/node_modules/@attocash/commons-node/commons-commons-node.mjs +873 -847
  65. package/node_modules/@attocash/commons-node/commons-commons-node.mjs.map +1 -1
  66. package/node_modules/@attocash/commons-node/kotlin-logging.mjs +109 -109
  67. package/node_modules/@attocash/commons-node/kotlin-logging.mjs.map +1 -1
  68. package/node_modules/@attocash/commons-node/kotlinx-serialization-kotlinx-serialization-json.mjs +1732 -1701
  69. package/node_modules/@attocash/commons-node/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -1
  70. package/node_modules/@attocash/commons-node/package.json +3 -3
  71. package/node_modules/@attocash/commons-node-remote/commons-commons-node-remote.d.mts +1 -0
  72. package/node_modules/@attocash/commons-node-remote/commons-commons-node-remote.mjs +674 -640
  73. package/node_modules/@attocash/commons-node-remote/commons-commons-node-remote.mjs.map +1 -1
  74. package/node_modules/@attocash/commons-node-remote/kotlin-logging.mjs +109 -109
  75. package/node_modules/@attocash/commons-node-remote/kotlin-logging.mjs.map +1 -1
  76. package/node_modules/@attocash/commons-node-remote/kotlinx-browser.mjs.map +1 -1
  77. package/node_modules/@attocash/commons-node-remote/kotlinx-serialization-kotlinx-serialization-json-io.mjs.map +1 -1
  78. package/node_modules/@attocash/commons-node-remote/kotlinx-serialization-kotlinx-serialization-json.mjs +1732 -1701
  79. package/node_modules/@attocash/commons-node-remote/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -1
  80. package/node_modules/@attocash/commons-node-remote/package.json +4 -4
  81. package/node_modules/@attocash/commons-transport/commons-commons-transport.d.mts +1 -0
  82. package/node_modules/@attocash/commons-transport/commons-commons-transport.mjs +52 -51
  83. package/node_modules/@attocash/commons-transport/commons-commons-transport.mjs.map +1 -1
  84. package/node_modules/@attocash/commons-transport/kotlinx-atomicfu.mjs +13 -13
  85. package/node_modules/@attocash/commons-transport/kotlinx-atomicfu.mjs.map +1 -1
  86. package/node_modules/@attocash/commons-transport/kotlinx-browser.mjs.map +1 -1
  87. package/node_modules/@attocash/commons-transport/kotlinx-coroutines-core.mjs +2639 -2608
  88. package/node_modules/@attocash/commons-transport/kotlinx-coroutines-core.mjs.map +1 -1
  89. package/node_modules/@attocash/commons-transport/kotlinx-serialization-kotlinx-serialization-json-io.mjs.map +1 -1
  90. package/node_modules/@attocash/commons-transport/kotlinx-serialization-kotlinx-serialization-json.mjs +1732 -1701
  91. package/node_modules/@attocash/commons-transport/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -1
  92. package/node_modules/@attocash/commons-transport/ktor-ktor-client-content-negotiation.mjs +411 -196
  93. package/node_modules/@attocash/commons-transport/ktor-ktor-client-content-negotiation.mjs.map +1 -1
  94. package/node_modules/@attocash/commons-transport/ktor-ktor-client-core.mjs +2115 -1976
  95. package/node_modules/@attocash/commons-transport/ktor-ktor-client-core.mjs.map +1 -1
  96. package/node_modules/@attocash/commons-transport/ktor-ktor-events.mjs +7 -7
  97. package/node_modules/@attocash/commons-transport/ktor-ktor-events.mjs.map +1 -1
  98. package/node_modules/@attocash/commons-transport/ktor-ktor-http-cio.mjs +385 -384
  99. package/node_modules/@attocash/commons-transport/ktor-ktor-http-cio.mjs.map +1 -1
  100. package/node_modules/@attocash/commons-transport/ktor-ktor-http.mjs +1261 -1185
  101. package/node_modules/@attocash/commons-transport/ktor-ktor-http.mjs.map +1 -1
  102. package/node_modules/@attocash/commons-transport/ktor-ktor-io.mjs +668 -656
  103. package/node_modules/@attocash/commons-transport/ktor-ktor-io.mjs.map +1 -1
  104. package/node_modules/@attocash/commons-transport/ktor-ktor-openapi-schema.mjs +89 -0
  105. package/node_modules/@attocash/commons-transport/ktor-ktor-openapi-schema.mjs.map +1 -0
  106. package/node_modules/@attocash/commons-transport/ktor-ktor-serialization-kotlinx-json.mjs +9 -9
  107. package/node_modules/@attocash/commons-transport/ktor-ktor-serialization-kotlinx-json.mjs.map +1 -1
  108. package/node_modules/@attocash/commons-transport/ktor-ktor-serialization-kotlinx.mjs +120 -128
  109. package/node_modules/@attocash/commons-transport/ktor-ktor-serialization-kotlinx.mjs.map +1 -1
  110. package/node_modules/@attocash/commons-transport/ktor-ktor-serialization.mjs +46 -49
  111. package/node_modules/@attocash/commons-transport/ktor-ktor-serialization.mjs.map +1 -1
  112. package/node_modules/@attocash/commons-transport/ktor-ktor-sse.mjs.map +1 -1
  113. package/node_modules/@attocash/commons-transport/ktor-ktor-utils.mjs +1041 -985
  114. package/node_modules/@attocash/commons-transport/ktor-ktor-utils.mjs.map +1 -1
  115. package/node_modules/@attocash/commons-transport/ktor-ktor-websocket-serialization.mjs.map +1 -1
  116. package/node_modules/@attocash/commons-transport/ktor-ktor-websockets.mjs +530 -455
  117. package/node_modules/@attocash/commons-transport/ktor-ktor-websockets.mjs.map +1 -1
  118. package/node_modules/@attocash/commons-transport/package.json +4 -4
  119. package/node_modules/@attocash/commons-worker/commons-commons-worker.d.mts +1 -0
  120. package/node_modules/@attocash/commons-worker/commons-commons-worker.mjs +230 -226
  121. package/node_modules/@attocash/commons-worker/commons-commons-worker.mjs.map +1 -1
  122. package/node_modules/@attocash/commons-worker/kotlin-logging.mjs +109 -109
  123. package/node_modules/@attocash/commons-worker/kotlin-logging.mjs.map +1 -1
  124. package/node_modules/@attocash/commons-worker/kotlinx-serialization-kotlinx-serialization-json.mjs +1732 -1701
  125. package/node_modules/@attocash/commons-worker/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -1
  126. package/node_modules/@attocash/commons-worker/package.json +3 -3
  127. package/node_modules/@attocash/commons-worker-remote/commons-commons-worker-remote.d.mts +1 -0
  128. package/node_modules/@attocash/commons-worker-remote/commons-commons-worker-remote.mjs +91 -86
  129. package/node_modules/@attocash/commons-worker-remote/commons-commons-worker-remote.mjs.map +1 -1
  130. package/node_modules/@attocash/commons-worker-remote/kotlin-logging.mjs +109 -109
  131. package/node_modules/@attocash/commons-worker-remote/kotlin-logging.mjs.map +1 -1
  132. package/node_modules/@attocash/commons-worker-remote/kotlinx-browser.mjs.map +1 -1
  133. package/node_modules/@attocash/commons-worker-remote/kotlinx-serialization-kotlinx-serialization-json-io.mjs.map +1 -1
  134. package/node_modules/@attocash/commons-worker-remote/kotlinx-serialization-kotlinx-serialization-json.mjs +1732 -1701
  135. package/node_modules/@attocash/commons-worker-remote/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -1
  136. package/node_modules/@attocash/commons-worker-remote/package.json +4 -4
  137. package/package.json +9 -5
@@ -3,22 +3,26 @@ import {
3
3
  AutoCloseable1l5p57f9lp7kv as AutoCloseable,
4
4
  initMetadataForInterface1egvbzx539z91 as initMetadataForInterface,
5
5
  VOID3gxj6tk5isa35 as VOID,
6
- Unit_instance3vdlo4e4f5ggx as Unit_instance,
6
+ Unit_instance3kz1zqli6gr1r as Unit_instance,
7
+ $3l5vvh8yg0ier as $,
7
8
  Exceptiondt2hlxn7j7vw as Exception,
9
+ orPromise1iucc2to2udt2 as orPromise,
8
10
  constructCallableReference23y65rf941mch as constructCallableReference,
9
11
  HashMap1a0ld5kgwhmhv as HashMap,
10
12
  initMetadataForClassbxx6q50dy2s7 as initMetadataForClass,
11
- _UShort___get_data__impl__g02451joe1vsk2vach as _UShort___get_data__impl__g0245,
13
+ _UShort___get_data__impl__g02451raj6q6epxg1b as _UShort___get_data__impl__g0245,
12
14
  protoOf180f3jzyo7rfj as protoOf,
13
15
  toByte4i43936u611k as toByte,
14
16
  fromInt2ii0rejb1w62w as fromInt,
15
- _ULong___init__impl__c78o9k3fkiaf1q5xsf7 as _ULong___init__impl__c78o9k,
16
- _ULong___get_data__impl__fggpzb35t7vg7og3i8u as _ULong___get_data__impl__fggpzb,
17
+ _ULong___init__impl__c78o9k1vasxel72m2l4 as _ULong___init__impl__c78o9k,
18
+ _ULong___get_data__impl__fggpzbbo8lz7f8fnfy as _ULong___get_data__impl__fggpzb,
17
19
  multiply2k9eolhnz1bjv as multiply,
18
20
  add2suhfggl4zvkk as add,
21
+ ULong3f9k7s38t3rfp as ULong,
22
+ equals2au1ep9vhcato as equals,
19
23
  get_ONEazvfdh9ju3d4 as get_ONE,
20
24
  ulongDivide3e52ct8hxp5n7 as ulongDivide,
21
- LazyThreadSafetyMode_PUBLICATION_getInstance20ynwq7b0awd8 as LazyThreadSafetyMode_PUBLICATION_getInstance,
25
+ LazyThreadSafetyMode_PUBLICATION_getInstance23f213579at67 as LazyThreadSafetyMode_PUBLICATION_getInstance,
22
26
  lazy1261dae0bgscp as lazy,
23
27
  THROW_CCE2g6jy02ryeudk as THROW_CCE,
24
28
  initMetadataForObject1cxne3s9w65el as initMetadataForObject,
@@ -27,31 +31,31 @@ import {
27
31
  IllegalArgumentException2asla15b5jaob as IllegalArgumentException,
28
32
  toString1pkumu07cwy4m as toString,
29
33
  promisify1z0ncraq1ipzh as promisify,
30
- await335x4cz7ixnm4 as await_0,
31
- _UShort___init__impl__jigrne1zu56ujvuii2n as _UShort___init__impl__jigrne,
34
+ await3n7kedgocftsv as await_0,
35
+ _UShort___init__impl__jigrne1e3nphhrejdd8 as _UShort___init__impl__jigrne,
32
36
  } from '@attocash/commons-core/kotlin-kotlin-stdlib.mjs';
33
37
  import {
34
- Companion_instancer1aiy15xy072 as Companion_instance,
35
- Companion_instance1lv0f3n6qbbrs as Companion_instance_0,
38
+ Companion_instance2enxrnk22gxoi as Companion_instance,
39
+ Companion_instancew7paw1z24vb2 as Companion_instance_0,
36
40
  AttoWorkTarget3v4zqc5kfdpel as AttoWorkTarget,
37
41
  AttoWorkrxvyu0kmlxrx as AttoWork,
38
42
  toByteArray1xevcsrk0l409 as toByteArray,
39
43
  values1ix93lj72gxe9 as values,
40
- AttoInstantAsLongSerializer_getInstance28lzw2ejfk8eg as AttoInstantAsLongSerializer_getInstance,
41
- AttoWorkAsStringSerializer_getInstance2p64tpzgy1wj6 as AttoWorkAsStringSerializer_getInstance,
44
+ AttoInstantAsLongSerializer_getInstance22rctt7sygbd8 as AttoInstantAsLongSerializer_getInstance,
45
+ AttoWorkAsStringSerializer_getInstanceu9e83tntftv0 as AttoWorkAsStringSerializer_getInstance,
42
46
  toHexcxaq2tti5e5x as toHex,
43
47
  } from '@attocash/commons-core/commons-commons-core.mjs';
44
48
  import {
45
- Dispatchers_getInstance20p7pyqnrepag as Dispatchers_getInstance,
49
+ Dispatchers_getInstance128lm494a5r5s as Dispatchers_getInstance,
46
50
  asyncz02dsa2nb2zt as async,
47
51
  SupervisorJobythnfxkr3jxc as SupervisorJob,
48
52
  CoroutineScopelux7s7zphw7e as CoroutineScope,
49
53
  Mutex16li1l0asjv17 as Mutex,
50
54
  cancel36mj9lv3a0whl as cancel,
51
55
  Job13y4jkazwjho0 as Job,
52
- Key_instancebefxze3q9f64 as Key_instance,
56
+ Key_instancepi2bbb0csu5f as Key_instance,
53
57
  get_isActivehakov5bm97hw as get_isActive,
54
- yieldyvh2mab0488 as yield_0,
58
+ yield7e67oxleds6v as yield_0,
55
59
  CompletableDeferred2lnqvsbvx74d3 as CompletableDeferred,
56
60
  launch1c91vkjzdi9sd as launch,
57
61
  } from '@attocash/commons-transport/kotlinx-coroutines-core.mjs';
@@ -59,7 +63,7 @@ import {
59
63
  createSimpleEnumSerializer2guioz11kk1m0 as createSimpleEnumSerializer,
60
64
  PluginGeneratedSerialDescriptorqdzeg5asqhfg as PluginGeneratedSerialDescriptor,
61
65
  UnknownFieldExceptiona60e3a6v1xqo as UnknownFieldException,
62
- StringSerializer_getInstancerxlnwnlbnwri as StringSerializer_getInstance,
66
+ StringSerializer_getInstance1p9zda6r6kb23 as StringSerializer_getInstance,
63
67
  typeParametersSerializers2likxjr48tr7y as typeParametersSerializers,
64
68
  GeneratedSerializer1f7t7hssdd2ws as GeneratedSerializer,
65
69
  throwMissingFieldException2cmke0v3ynf14 as throwMissingFieldException,
@@ -70,149 +74,149 @@ var imul = Math.imul;
70
74
  //endregion
71
75
  //region block: pre-declaration
72
76
  class Companion {
73
- k3j(parallelism) {
77
+ cpu_o7vd24_k$(parallelism) {
74
78
  return new AttoWorkerCpu(parallelism);
75
79
  }
76
- l3j() {
80
+ cpu_246g_k$() {
77
81
  return defaultCpuWorker();
78
82
  }
79
83
  }
80
84
  class AttoWorker {}
81
85
  function *work(network, timestamp, target, $completion) {
82
- var threshold = Companion_instance.p2q(network, timestamp);
83
- return yield* this.m3j(threshold, target, $completion);
86
+ var threshold = Companion_instance.getThreshold_kx7vsl_k$(network, timestamp);
87
+ return yield* this.work_87s8mv_k$(threshold, target, $completion);
84
88
  }
85
89
  function *work_0(block, $completion) {
86
- var target = block.y2h();
87
- return yield* this.n3j(block.network, block.timestamp, target, $completion);
90
+ var target = block.getTarget_dhambr_k$();
91
+ return yield* this.work_qtc4fi_k$(block.network, block.timestamp, target, $completion);
88
92
  }
89
93
  class AttoWorkerCache {
90
94
  constructor(delegate, dispatcher) {
91
- dispatcher = dispatcher === VOID ? Dispatchers_getInstance().q32_1 : dispatcher;
92
- this.p3j_1 = delegate;
93
- this.q3j_1 = CoroutineScope(dispatcher.xl(SupervisorJob()));
94
- this.r3j_1 = Mutex();
95
- this.s3j_1 = HashMap.v8();
95
+ dispatcher = dispatcher === VOID ? Dispatchers_getInstance().Default_1 : dispatcher;
96
+ this.delegate_1 = delegate;
97
+ this.scope_1 = CoroutineScope(dispatcher.plus_s13ygv_k$(SupervisorJob()));
98
+ this.mutex_1 = Mutex();
99
+ this.cache_1 = HashMap.new_kotlin_collections_HashMap_2a5kxx_k$();
96
100
  }
97
- *m3j(threshold, target, $completion) {
101
+ *work_87s8mv_k$(threshold, target, $completion) {
98
102
  var deferred = yield* /*#__NOINLINE__*/delegateWork(this, target, AttoWorkerCache$work$slambda(this, threshold), $completion);
99
- var work = yield* deferred.d2u($completion);
103
+ var work = yield* deferred.await_4rdzbx_k$($completion);
100
104
  // Inline function 'kotlinx.coroutines.sync.withLock' call
101
- var this_0 = this.r3j_1;
102
- yield* this_0.c3h(null, $completion);
105
+ var this_0 = this.mutex_1;
106
+ yield* this_0.lock_ugrcvf_k$(null, $completion);
103
107
  var tmp;
104
108
  try {
105
- tmp = this.s3j_1.h4(target);
109
+ tmp = this.cache_1.remove_gppy8k_k$(target);
106
110
  }finally {
107
- this_0.o3g(null);
111
+ this_0.unlock_ulcrcl_k$(null);
108
112
  }
109
- if (Companion_instance.r2q(threshold, target, work.value)) {
113
+ if (Companion_instance.isValid_6d979i_k$(threshold, target, work.value)) {
110
114
  return work;
111
115
  }
112
- return yield* this.m3j(threshold, target, $completion);
116
+ return yield* this.work_87s8mv_k$(threshold, target, $completion);
113
117
  }
114
- *n3j(network, timestamp, target, $completion) {
118
+ *work_qtc4fi_k$(network, timestamp, target, $completion) {
115
119
  var deferred = yield* /*#__NOINLINE__*/delegateWork(this, target, AttoWorkerCache$work$slambda_0(this, network, timestamp), $completion);
116
- var work = yield* deferred.d2u($completion);
120
+ var work = yield* deferred.await_4rdzbx_k$($completion);
117
121
  // Inline function 'kotlinx.coroutines.sync.withLock' call
118
- var this_0 = this.r3j_1;
119
- yield* this_0.c3h(null, $completion);
122
+ var this_0 = this.mutex_1;
123
+ yield* this_0.lock_ugrcvf_k$(null, $completion);
120
124
  var tmp;
121
125
  try {
122
- tmp = this.s3j_1.h4(target);
126
+ tmp = this.cache_1.remove_gppy8k_k$(target);
123
127
  }finally {
124
- this_0.o3g(null);
128
+ this_0.unlock_ulcrcl_k$(null);
125
129
  }
126
- if (Companion_instance.t2q(network, timestamp, target, work.value)) {
130
+ if (Companion_instance.isValid_bw4l0h_k$(network, timestamp, target, work.value)) {
127
131
  return work;
128
132
  }
129
- return yield* this.n3j(network, timestamp, target, $completion);
133
+ return yield* this.work_qtc4fi_k$(network, timestamp, target, $completion);
130
134
  }
131
- *o3j(block, $completion) {
132
- var tmp = block.y2h();
135
+ *work_uniq4r_k$(block, $completion) {
136
+ var tmp = block.getTarget_dhambr_k$();
133
137
  var deferred = yield* /*#__NOINLINE__*/delegateWork(this, tmp, AttoWorkerCache$work$slambda_1(this, block), $completion);
134
- var work = yield* deferred.d2u($completion);
138
+ var work = yield* deferred.await_4rdzbx_k$($completion);
135
139
  // Inline function 'kotlinx.coroutines.sync.withLock' call
136
- var this_0 = this.r3j_1;
137
- yield* this_0.c3h(null, $completion);
140
+ var this_0 = this.mutex_1;
141
+ yield* this_0.lock_ugrcvf_k$(null, $completion);
138
142
  var tmp_0;
139
143
  try {
140
- tmp_0 = this.s3j_1.h4(block.y2h());
144
+ tmp_0 = this.cache_1.remove_gppy8k_k$(block.getTarget_dhambr_k$());
141
145
  }finally {
142
- this_0.o3g(null);
146
+ this_0.unlock_ulcrcl_k$(null);
143
147
  }
144
148
  var nextTarget = new AttoWorkTarget(block.hash.value);
145
149
  yield* /*#__NOINLINE__*/delegateWork(this, nextTarget, AttoWorkerCache$work$slambda_2(this, block), $completion);
146
150
  if (work.isValid(block)) {
147
151
  return work;
148
152
  }
149
- return yield* this.o3j(block, $completion);
153
+ return yield* this.work_uniq4r_k$(block, $completion);
150
154
  }
151
- q6() {
152
- this.s3j_1.j4();
153
- cancel(this.q3j_1);
154
- this.p3j_1.q6();
155
+ close_yn9xrc_k$() {
156
+ this.cache_1.clear_j9egeb_k$();
157
+ cancel(this.scope_1);
158
+ this.delegate_1.close_yn9xrc_k$();
155
159
  }
156
160
  }
157
161
  class AttoWorkerCpu {
158
162
  constructor(parallelism) {
159
- this.t3j_1 = parallelism;
160
- this.u3j_1 = SupervisorJob();
163
+ this.parallelism_1 = parallelism;
164
+ this.supervisorJob_1 = SupervisorJob();
161
165
  var tmp = this;
162
- var tmp_0 = Dispatchers_getInstance().q32_1;
166
+ var tmp_0 = Dispatchers_getInstance().Default_1;
163
167
  // Inline function 'kotlin.UShort.toInt' call
164
- var this_0 = this.t3j_1;
168
+ var this_0 = this.parallelism_1;
165
169
  var tmp$ret$0 = _UShort___get_data__impl__g0245(this_0) & 65535;
166
- tmp.v3j_1 = tmp_0.i2y(tmp$ret$0);
170
+ tmp.dispatcher_1 = tmp_0.limitedParallelism$default_fymcw7_k$(tmp$ret$0);
167
171
  }
168
- *m3j(threshold, target, $completion) {
169
- var workJob = Job(this.u3j_1);
172
+ *work_87s8mv_k$(threshold, target, $completion) {
173
+ var workJob = Job(this.supervisorJob_1);
170
174
  // Inline function 'kotlin.js.getCoroutineContext' call
171
- var tmp0_safe_receiver = $completion.sc().ed(Key_instance);
175
+ var tmp0_safe_receiver = $completion.get_context_h02k06_k$().get_y2st91_k$(Key_instance);
172
176
  var tmp;
173
177
  if (tmp0_safe_receiver == null) {
174
178
  tmp = null;
175
179
  } else {
176
- tmp = tmp0_safe_receiver.r2s(AttoWorkerCpu$work$lambda(workJob));
180
+ tmp = tmp0_safe_receiver.invokeOnCompletion_n6cffu_k$(AttoWorkerCpu$work$lambda(workJob));
177
181
  }
178
182
  var callerCancellation = tmp;
179
183
  try {
180
- var controller = new WorkerController(this.v3j_1.xl(workJob), this.t3j_1, threshold, target.s2q_1);
181
- return yield* controller.b3k($completion);
184
+ var controller = new WorkerController(this.dispatcher_1.plus_s13ygv_k$(workJob), this.parallelism_1, threshold, target.value_1);
185
+ return yield* controller.calculate_v9m4ne_k$($completion);
182
186
  }finally {
183
187
  if (callerCancellation == null)
184
188
  null;
185
189
  else {
186
- callerCancellation.d2v();
190
+ callerCancellation.dispose_3nnxhr_k$();
187
191
  }
188
- workJob.z2s();
192
+ workJob.cancel$default_8haxne_k$();
189
193
  }
190
194
  }
191
- q6() {
192
- this.u3j_1.z2s();
195
+ close_yn9xrc_k$() {
196
+ this.supervisorJob_1.cancel$default_8haxne_k$();
193
197
  }
194
198
  }
195
199
  class WorkerController {
196
200
  constructor(context, parallelism, threshold, target) {
197
- this.w3j_1 = parallelism;
198
- this.x3j_1 = threshold;
199
- this.y3j_1 = target;
200
- this.z3j_1 = CoroutineScope(context);
201
+ this.parallelism_1 = parallelism;
202
+ this.threshold_1 = threshold;
203
+ this.target_1 = target;
204
+ this.scope_1 = CoroutineScope(context);
201
205
  var tmp = this;
202
206
  // Inline function 'kotlin.apply' call
203
207
  var this_0 = CompletableDeferred();
204
- this_0.r2s(WorkerController$result$lambda(this));
205
- tmp.a3k_1 = this_0;
208
+ this_0.invokeOnCompletion_n6cffu_k$(WorkerController$result$lambda(this));
209
+ tmp.result_1 = this_0;
206
210
  }
207
- *b3k($completion) {
211
+ *calculate_v9m4ne_k$($completion) {
208
212
  var tmp0 = _ULong___init__impl__c78o9k(-1n);
209
213
  // Inline function 'kotlin.UShort.toULong' call
210
- var this_0 = this.w3j_1;
214
+ var this_0 = this.parallelism_1;
211
215
  // Inline function 'kotlin.ULong.div' call
212
216
  var other = _ULong___init__impl__c78o9k(fromInt(_UShort___get_data__impl__g0245(this_0)) & 65535n);
213
217
  var rangeSize = ulongDivide(tmp0, other);
214
218
  // Inline function 'kotlin.UShort.toInt' call
215
- var this_1 = this.w3j_1;
219
+ var this_1 = this.parallelism_1;
216
220
  // Inline function 'kotlin.repeat' call
217
221
  var times = _UShort___get_data__impl__g0245(this_1) & 65535;
218
222
  var inductionVariable = 0;
@@ -220,13 +224,13 @@ class WorkerController {
220
224
  do {
221
225
  var index = inductionVariable;
222
226
  inductionVariable = inductionVariable + 1 | 0;
223
- launch(this.z3j_1, VOID, VOID, WorkerController$calculate$slambda(index, rangeSize, this));
227
+ launch(this.scope_1, VOID, VOID, WorkerController$calculate$slambda(index, rangeSize, this));
224
228
  }
225
229
  while (inductionVariable < times);
226
230
  try {
227
- return yield* this.a3k_1.d2u($completion);
231
+ return yield* this.result_1.await_4rdzbx_k$($completion);
228
232
  }finally {
229
- cancel(this.z3j_1);
233
+ cancel(this.scope_1);
230
234
  }
231
235
  }
232
236
  }
@@ -238,81 +242,81 @@ class Companion_0 {
238
242
  // Inline function 'kotlin.arrayOf' call
239
243
  // Inline function 'kotlin.js.unsafeCast' call
240
244
  // Inline function 'kotlin.js.asDynamic' call
241
- tmp.c3k_1 = [lazy(tmp_0, AttoWorkerOperations$Request$Companion$$childSerializers$_anonymous__k0cb7d), null, null];
245
+ tmp.$childSerializers_1 = [lazy(tmp_0, AttoWorkerOperations$Request$Companion$$childSerializers$_anonymous__k0cb7d), null, null];
242
246
  }
243
247
  }
244
248
  class $serializer {
245
249
  constructor() {
246
250
  $serializer_instance = this;
247
251
  var tmp0_serialDesc = new PluginGeneratedSerialDescriptor('cash.atto.commons.worker.AttoWorkerOperations.Request', this, 3);
248
- tmp0_serialDesc.s16('network', false);
249
- tmp0_serialDesc.s16('timestamp', false);
250
- tmp0_serialDesc.s16('target', false);
251
- this.d3k_1 = tmp0_serialDesc;
252
- }
253
- e3k(encoder, value) {
254
- var tmp0_desc = this.d3k_1;
255
- var tmp1_output = encoder.ez(tmp0_desc);
256
- var tmp2_cached = Companion_getInstance_0().c3k_1;
257
- tmp1_output.v10(tmp0_desc, 0, tmp2_cached[0].b3(), value.f3k_1);
258
- tmp1_output.v10(tmp0_desc, 1, AttoInstantAsLongSerializer_getInstance(), value.g3k_1);
259
- tmp1_output.t10(tmp0_desc, 2, value.h3k_1);
260
- tmp1_output.fz(tmp0_desc);
261
- }
262
- qu(encoder, value) {
263
- return this.e3k(encoder, value instanceof Request ? value : THROW_CCE());
264
- }
265
- ru(decoder) {
266
- var tmp0_desc = this.d3k_1;
252
+ tmp0_serialDesc.addElement_5pzumi_k$('network', false);
253
+ tmp0_serialDesc.addElement_5pzumi_k$('timestamp', false);
254
+ tmp0_serialDesc.addElement_5pzumi_k$('target', false);
255
+ this.descriptor_1 = tmp0_serialDesc;
256
+ }
257
+ serialize_20rcyh_k$(encoder, value) {
258
+ var tmp0_desc = this.descriptor_1;
259
+ var tmp1_output = encoder.beginStructure_yljocp_k$(tmp0_desc);
260
+ var tmp2_cached = Companion_getInstance_0().$childSerializers_1;
261
+ tmp1_output.encodeSerializableElement_isqxcl_k$(tmp0_desc, 0, tmp2_cached[0].get_value_j01efc_k$(), value.network_1);
262
+ tmp1_output.encodeSerializableElement_isqxcl_k$(tmp0_desc, 1, AttoInstantAsLongSerializer_getInstance(), value.timestamp_1);
263
+ tmp1_output.encodeStringElement_1n5wu2_k$(tmp0_desc, 2, value.target_1);
264
+ tmp1_output.endStructure_1xqz0n_k$(tmp0_desc);
265
+ }
266
+ serialize_5ase3y_k$(encoder, value) {
267
+ return this.serialize_20rcyh_k$(encoder, value instanceof Request ? value : THROW_CCE());
268
+ }
269
+ deserialize_sy6x50_k$(decoder) {
270
+ var tmp0_desc = this.descriptor_1;
267
271
  var tmp1_flag = true;
268
272
  var tmp2_index = 0;
269
273
  var tmp3_bitMask0 = 0;
270
274
  var tmp4_local0 = null;
271
275
  var tmp5_local1 = null;
272
276
  var tmp6_local2 = null;
273
- var tmp7_input = decoder.ez(tmp0_desc);
274
- var tmp8_cached = Companion_getInstance_0().c3k_1;
275
- if (tmp7_input.tz()) {
276
- tmp4_local0 = tmp7_input.qz(tmp0_desc, 0, tmp8_cached[0].b3(), tmp4_local0);
277
+ var tmp7_input = decoder.beginStructure_yljocp_k$(tmp0_desc);
278
+ var tmp8_cached = Companion_getInstance_0().$childSerializers_1;
279
+ if (tmp7_input.decodeSequentially_xlblqy_k$()) {
280
+ tmp4_local0 = tmp7_input.decodeSerializableElement_uahnnv_k$(tmp0_desc, 0, tmp8_cached[0].get_value_j01efc_k$(), tmp4_local0);
277
281
  tmp3_bitMask0 = tmp3_bitMask0 | 1;
278
- tmp5_local1 = tmp7_input.qz(tmp0_desc, 1, AttoInstantAsLongSerializer_getInstance(), tmp5_local1);
282
+ tmp5_local1 = tmp7_input.decodeSerializableElement_uahnnv_k$(tmp0_desc, 1, AttoInstantAsLongSerializer_getInstance(), tmp5_local1);
279
283
  tmp3_bitMask0 = tmp3_bitMask0 | 2;
280
- tmp6_local2 = tmp7_input.oz(tmp0_desc, 2);
284
+ tmp6_local2 = tmp7_input.decodeStringElement_3oenpg_k$(tmp0_desc, 2);
281
285
  tmp3_bitMask0 = tmp3_bitMask0 | 4;
282
286
  } else
283
287
  while (tmp1_flag) {
284
- tmp2_index = tmp7_input.uz(tmp0_desc);
288
+ tmp2_index = tmp7_input.decodeElementIndex_bstkhp_k$(tmp0_desc);
285
289
  switch (tmp2_index) {
286
290
  case -1:
287
291
  tmp1_flag = false;
288
292
  break;
289
293
  case 0:
290
- tmp4_local0 = tmp7_input.qz(tmp0_desc, 0, tmp8_cached[0].b3(), tmp4_local0);
294
+ tmp4_local0 = tmp7_input.decodeSerializableElement_uahnnv_k$(tmp0_desc, 0, tmp8_cached[0].get_value_j01efc_k$(), tmp4_local0);
291
295
  tmp3_bitMask0 = tmp3_bitMask0 | 1;
292
296
  break;
293
297
  case 1:
294
- tmp5_local1 = tmp7_input.qz(tmp0_desc, 1, AttoInstantAsLongSerializer_getInstance(), tmp5_local1);
298
+ tmp5_local1 = tmp7_input.decodeSerializableElement_uahnnv_k$(tmp0_desc, 1, AttoInstantAsLongSerializer_getInstance(), tmp5_local1);
295
299
  tmp3_bitMask0 = tmp3_bitMask0 | 2;
296
300
  break;
297
301
  case 2:
298
- tmp6_local2 = tmp7_input.oz(tmp0_desc, 2);
302
+ tmp6_local2 = tmp7_input.decodeStringElement_3oenpg_k$(tmp0_desc, 2);
299
303
  tmp3_bitMask0 = tmp3_bitMask0 | 4;
300
304
  break;
301
305
  default:
302
- throw UnknownFieldException.lw(tmp2_index);
306
+ throw UnknownFieldException.new_kotlinx_serialization_UnknownFieldException_ecrf7z_k$(tmp2_index);
303
307
  }
304
308
  }
305
- tmp7_input.fz(tmp0_desc);
306
- return Request.i3k(tmp3_bitMask0, tmp4_local0, tmp5_local1, tmp6_local2, null);
309
+ tmp7_input.endStructure_1xqz0n_k$(tmp0_desc);
310
+ return Request.new_cash_atto_commons_worker_AttoWorkerOperations_Request_65dob1_k$(tmp3_bitMask0, tmp4_local0, tmp5_local1, tmp6_local2, null);
307
311
  }
308
- pu() {
309
- return this.d3k_1;
312
+ get_descriptor_wjt6a0_k$() {
313
+ return this.descriptor_1;
310
314
  }
311
- h17() {
315
+ childSerializers_5ghqw5_k$() {
312
316
  // Inline function 'kotlin.arrayOf' call
313
317
  // Inline function 'kotlin.js.unsafeCast' call
314
318
  // Inline function 'kotlin.js.asDynamic' call
315
- return [Companion_getInstance_0().c3k_1[0].b3(), AttoInstantAsLongSerializer_getInstance(), StringSerializer_getInstance()];
319
+ return [Companion_getInstance_0().$childSerializers_1[0].get_value_j01efc_k$(), AttoInstantAsLongSerializer_getInstance(), StringSerializer_getInstance()];
316
320
  }
317
321
  }
318
322
  class Companion_1 {}
@@ -320,50 +324,50 @@ class $serializer_0 {
320
324
  constructor() {
321
325
  $serializer_instance_0 = this;
322
326
  var tmp0_serialDesc = new PluginGeneratedSerialDescriptor('cash.atto.commons.worker.AttoWorkerOperations.Response', this, 1);
323
- tmp0_serialDesc.s16('work', false);
324
- this.j3k_1 = tmp0_serialDesc;
327
+ tmp0_serialDesc.addElement_5pzumi_k$('work', false);
328
+ this.descriptor_1 = tmp0_serialDesc;
325
329
  }
326
- k3k(encoder, value) {
327
- var tmp0_desc = this.j3k_1;
328
- var tmp1_output = encoder.ez(tmp0_desc);
329
- tmp1_output.v10(tmp0_desc, 0, AttoWorkAsStringSerializer_getInstance(), value.l3k_1);
330
- tmp1_output.fz(tmp0_desc);
330
+ serialize_ytgqsx_k$(encoder, value) {
331
+ var tmp0_desc = this.descriptor_1;
332
+ var tmp1_output = encoder.beginStructure_yljocp_k$(tmp0_desc);
333
+ tmp1_output.encodeSerializableElement_isqxcl_k$(tmp0_desc, 0, AttoWorkAsStringSerializer_getInstance(), value.work_1);
334
+ tmp1_output.endStructure_1xqz0n_k$(tmp0_desc);
331
335
  }
332
- qu(encoder, value) {
333
- return this.k3k(encoder, value instanceof Response ? value : THROW_CCE());
336
+ serialize_5ase3y_k$(encoder, value) {
337
+ return this.serialize_ytgqsx_k$(encoder, value instanceof Response ? value : THROW_CCE());
334
338
  }
335
- ru(decoder) {
336
- var tmp0_desc = this.j3k_1;
339
+ deserialize_sy6x50_k$(decoder) {
340
+ var tmp0_desc = this.descriptor_1;
337
341
  var tmp1_flag = true;
338
342
  var tmp2_index = 0;
339
343
  var tmp3_bitMask0 = 0;
340
344
  var tmp4_local0 = null;
341
- var tmp5_input = decoder.ez(tmp0_desc);
342
- if (tmp5_input.tz()) {
343
- tmp4_local0 = tmp5_input.qz(tmp0_desc, 0, AttoWorkAsStringSerializer_getInstance(), tmp4_local0);
345
+ var tmp5_input = decoder.beginStructure_yljocp_k$(tmp0_desc);
346
+ if (tmp5_input.decodeSequentially_xlblqy_k$()) {
347
+ tmp4_local0 = tmp5_input.decodeSerializableElement_uahnnv_k$(tmp0_desc, 0, AttoWorkAsStringSerializer_getInstance(), tmp4_local0);
344
348
  tmp3_bitMask0 = tmp3_bitMask0 | 1;
345
349
  } else
346
350
  while (tmp1_flag) {
347
- tmp2_index = tmp5_input.uz(tmp0_desc);
351
+ tmp2_index = tmp5_input.decodeElementIndex_bstkhp_k$(tmp0_desc);
348
352
  switch (tmp2_index) {
349
353
  case -1:
350
354
  tmp1_flag = false;
351
355
  break;
352
356
  case 0:
353
- tmp4_local0 = tmp5_input.qz(tmp0_desc, 0, AttoWorkAsStringSerializer_getInstance(), tmp4_local0);
357
+ tmp4_local0 = tmp5_input.decodeSerializableElement_uahnnv_k$(tmp0_desc, 0, AttoWorkAsStringSerializer_getInstance(), tmp4_local0);
354
358
  tmp3_bitMask0 = tmp3_bitMask0 | 1;
355
359
  break;
356
360
  default:
357
- throw UnknownFieldException.lw(tmp2_index);
361
+ throw UnknownFieldException.new_kotlinx_serialization_UnknownFieldException_ecrf7z_k$(tmp2_index);
358
362
  }
359
363
  }
360
- tmp5_input.fz(tmp0_desc);
361
- return Response.m3k(tmp3_bitMask0, tmp4_local0, null);
364
+ tmp5_input.endStructure_1xqz0n_k$(tmp0_desc);
365
+ return Response.new_cash_atto_commons_worker_AttoWorkerOperations_Response_z9gk0v_k$(tmp3_bitMask0, tmp4_local0, null);
362
366
  }
363
- pu() {
364
- return this.j3k_1;
367
+ get_descriptor_wjt6a0_k$() {
368
+ return this.descriptor_1;
365
369
  }
366
- h17() {
370
+ childSerializers_5ghqw5_k$() {
367
371
  // Inline function 'kotlin.arrayOf' call
368
372
  // Inline function 'kotlin.js.unsafeCast' call
369
373
  // Inline function 'kotlin.js.asDynamic' call
@@ -373,17 +377,17 @@ class $serializer_0 {
373
377
  class Request {
374
378
  constructor(network, timestamp, target) {
375
379
  Companion_getInstance_0();
376
- this.f3k_1 = network;
377
- this.g3k_1 = timestamp;
378
- this.h3k_1 = target;
380
+ this.network_1 = network;
381
+ this.timestamp_1 = timestamp;
382
+ this.target_1 = target;
379
383
  }
380
384
  toString() {
381
- return 'Request(network=' + this.f3k_1.toString() + ', timestamp=' + this.g3k_1.toString() + ', target=' + this.h3k_1 + ')';
385
+ return 'Request(network=' + this.network_1.toString() + ', timestamp=' + this.timestamp_1.toString() + ', target=' + this.target_1 + ')';
382
386
  }
383
387
  hashCode() {
384
- var result = this.f3k_1.hashCode();
385
- result = imul(result, 31) + this.g3k_1.hashCode() | 0;
386
- result = imul(result, 31) + getStringHashCode(this.h3k_1) | 0;
388
+ var result = this.network_1.hashCode();
389
+ result = imul(result, 31) + this.timestamp_1.hashCode() | 0;
390
+ result = imul(result, 31) + getStringHashCode(this.target_1) | 0;
387
391
  return result;
388
392
  }
389
393
  equals(other) {
@@ -391,63 +395,63 @@ class Request {
391
395
  return true;
392
396
  if (!(other instanceof Request))
393
397
  return false;
394
- if (!this.f3k_1.equals(other.f3k_1))
398
+ if (!this.network_1.equals(other.network_1))
395
399
  return false;
396
- if (!this.g3k_1.equals(other.g3k_1))
400
+ if (!this.timestamp_1.equals(other.timestamp_1))
397
401
  return false;
398
- if (!(this.h3k_1 === other.h3k_1))
402
+ if (!(this.target_1 === other.target_1))
399
403
  return false;
400
404
  return true;
401
405
  }
402
- static i3k(seen0, network, timestamp, target, serializationConstructorMarker) {
406
+ static new_cash_atto_commons_worker_AttoWorkerOperations_Request_65dob1_k$(seen0, network, timestamp, target, serializationConstructorMarker) {
403
407
  Companion_getInstance_0();
404
408
  if (!(7 === (7 & seen0))) {
405
- throwMissingFieldException(seen0, 7, $serializer_getInstance().d3k_1);
409
+ throwMissingFieldException(seen0, 7, $serializer_getInstance().descriptor_1);
406
410
  }
407
411
  var $this = createThis(this);
408
- $this.f3k_1 = network;
409
- $this.g3k_1 = timestamp;
410
- $this.h3k_1 = target;
412
+ $this.network_1 = network;
413
+ $this.timestamp_1 = timestamp;
414
+ $this.target_1 = target;
411
415
  return $this;
412
416
  }
413
417
  }
414
418
  class Response {
415
419
  constructor(work) {
416
- this.l3k_1 = work;
420
+ this.work_1 = work;
417
421
  }
418
422
  toString() {
419
- return 'Response(work=' + this.l3k_1.toString() + ')';
423
+ return 'Response(work=' + this.work_1.toString() + ')';
420
424
  }
421
425
  hashCode() {
422
- return this.l3k_1.hashCode();
426
+ return this.work_1.hashCode();
423
427
  }
424
428
  equals(other) {
425
429
  if (this === other)
426
430
  return true;
427
431
  if (!(other instanceof Response))
428
432
  return false;
429
- if (!this.l3k_1.equals(other.l3k_1))
433
+ if (!this.work_1.equals(other.work_1))
430
434
  return false;
431
435
  return true;
432
436
  }
433
- static m3k(seen0, work, serializationConstructorMarker) {
437
+ static new_cash_atto_commons_worker_AttoWorkerOperations_Response_z9gk0v_k$(seen0, work, serializationConstructorMarker) {
434
438
  if (!(1 === (1 & seen0))) {
435
- throwMissingFieldException(seen0, 1, $serializer_getInstance_0().j3k_1);
439
+ throwMissingFieldException(seen0, 1, $serializer_getInstance_0().descriptor_1);
436
440
  }
437
441
  var $this = createThis(this);
438
- $this.l3k_1 = work;
442
+ $this.work_1 = work;
439
443
  return $this;
440
444
  }
441
445
  }
442
446
  class AttoWorkerOperations {}
443
447
  function *work_1(network, timestamp, target, $completion) {
444
- var request = new Request(network, timestamp, toHex(target.s2q_1));
445
- var response = yield* this.n3k(request, $completion);
446
- var work = response.l3k_1;
448
+ var request = new Request(network, timestamp, toHex(target.value_1));
449
+ var response = yield* this.work_s1kcy2_k$(request, $completion);
450
+ var work = response.work_1;
447
451
  // Inline function 'kotlin.require' call
448
- if (!Companion_instance.t2q(network, timestamp, target, work.value)) {
449
- var message = 'Worker returned invalid work for network=' + network.toString() + ' timestamp=' + timestamp.toString() + ' target=' + toHex(target.s2q_1);
450
- throw IllegalArgumentException.n2(toString(message));
452
+ if (!Companion_instance.isValid_bw4l0h_k$(network, timestamp, target, work.value)) {
453
+ var message = 'Worker returned invalid work for network=' + network.toString() + ' timestamp=' + timestamp.toString() + ' target=' + toHex(target.value_1);
454
+ throw IllegalArgumentException.new_kotlin_IllegalArgumentException_sfqr8_k$(toString(message));
451
455
  }
452
456
  return work;
453
457
  }
@@ -455,35 +459,35 @@ class AttoWorkerAsync {
455
459
  constructor(worker, dispatcher) {
456
460
  this.worker = worker;
457
461
  }
458
- o3k() {
462
+ get_worker_lh5cp3_k$() {
459
463
  return this.worker;
460
464
  }
461
- *m3j(threshold, target, $completion) {
462
- return yield* this.worker.m3j(threshold, target, $completion);
465
+ *work_87s8mv_k$(threshold, target, $completion) {
466
+ return yield* this.worker.work_87s8mv_k$(threshold, target, $completion);
463
467
  }
464
468
  workThreshold(threshold, target) {
465
- return promisify(($completion) => this.m3j(threshold, target, $completion));
469
+ return promisify(($completion) => this.work_87s8mv_k$(threshold, target, $completion));
466
470
  }
467
- *p3k(threshold, target, $completion) {
468
- return this.workThreshold === protoOf(AttoWorkerAsync).workThreshold ? (yield* this.m3j(threshold, target, $completion)) : (yield* await_0(this.workThreshold(threshold, target), $completion));
471
+ *work$suspendBridge_bi9o6u_k$(threshold, target, $completion) {
472
+ return this.workThreshold === protoOf(AttoWorkerAsync).workThreshold ? (yield* this.work_87s8mv_k$(threshold, target, $completion)) : (yield* await_0(this.workThreshold(threshold, target), $completion));
469
473
  }
470
- *n3j(network, timestamp, target, $completion) {
471
- return yield* this.worker.n3j(network, timestamp, target, $completion);
474
+ *work_qtc4fi_k$(network, timestamp, target, $completion) {
475
+ return yield* this.worker.work_qtc4fi_k$(network, timestamp, target, $completion);
472
476
  }
473
477
  workNetwork(network, timestamp, target) {
474
- return promisify(($completion) => this.n3j(network, timestamp, target, $completion));
478
+ return promisify(($completion) => this.work_qtc4fi_k$(network, timestamp, target, $completion));
475
479
  }
476
- *q3k(network, timestamp, target, $completion) {
477
- return this.workNetwork === protoOf(AttoWorkerAsync).workNetwork ? (yield* this.n3j(network, timestamp, target, $completion)) : (yield* await_0(this.workNetwork(network, timestamp, target), $completion));
480
+ *work$suspendBridge_i98mdt_k$(network, timestamp, target, $completion) {
481
+ return this.workNetwork === protoOf(AttoWorkerAsync).workNetwork ? (yield* this.work_qtc4fi_k$(network, timestamp, target, $completion)) : (yield* await_0(this.workNetwork(network, timestamp, target), $completion));
478
482
  }
479
- *o3j(block, $completion) {
480
- return yield* this.worker.o3j(block, $completion);
483
+ *work_uniq4r_k$(block, $completion) {
484
+ return yield* this.worker.work_uniq4r_k$(block, $completion);
481
485
  }
482
486
  workBlock(block) {
483
- return promisify(($completion) => this.o3j(block, $completion));
487
+ return promisify(($completion) => this.work_uniq4r_k$(block, $completion));
484
488
  }
485
- *r3k(block, $completion) {
486
- return this.workBlock === protoOf(AttoWorkerAsync).workBlock ? (yield* this.o3j(block, $completion)) : (yield* await_0(this.workBlock(block), $completion));
489
+ *work$suspendBridge_24k5lg_k$(block, $completion) {
490
+ return this.workBlock === protoOf(AttoWorkerAsync).workBlock ? (yield* this.work_uniq4r_k$(block, $completion)) : (yield* await_0(this.workBlock(block), $completion));
487
491
  }
488
492
  }
489
493
  //endregion
@@ -495,92 +499,92 @@ function toAsync(_this__u8e3s4, dispatcher) {
495
499
  return new AttoWorkerAsync(_this__u8e3s4, dispatcher);
496
500
  }
497
501
  function cached(_this__u8e3s4, dispatcher) {
498
- dispatcher = dispatcher === VOID ? Dispatchers_getInstance().q32_1 : dispatcher;
502
+ dispatcher = dispatcher === VOID ? Dispatchers_getInstance().Default_1 : dispatcher;
499
503
  return new AttoWorkerCache(_this__u8e3s4, dispatcher);
500
504
  }
501
505
  function *delegateWork($this, target, delegate, $completion) {
502
506
  // Inline function 'kotlinx.coroutines.sync.withLock' call
503
- var this_0 = $this.r3j_1;
504
- yield* this_0.c3h(null, $completion);
507
+ var this_0 = $this.mutex_1;
508
+ yield* this_0.lock_ugrcvf_k$(null, $completion);
505
509
  var tmp;
506
510
  try {
507
- var deferred = $this.s3j_1.o4(target);
511
+ var deferred = $this.cache_1.get_wei43m_k$(target);
508
512
  if (!(deferred == null)) {
509
513
  return deferred;
510
514
  }
511
- deferred = async($this.q3j_1, VOID, VOID, AttoWorkerCache$delegateWork$slambda(delegate, target, $this));
512
- var tmp0 = $this.s3j_1;
515
+ deferred = async($this.scope_1, VOID, VOID, AttoWorkerCache$delegateWork$slambda(delegate, target, $this));
516
+ var tmp0 = $this.cache_1;
513
517
  // Inline function 'kotlin.collections.set' call
514
518
  var value = deferred;
515
- tmp0.g4(target, value);
519
+ tmp0.put_4fpzoq_k$(target, value);
516
520
  return deferred;
517
521
  }finally {
518
- this_0.o3g(null);
522
+ this_0.unlock_ulcrcl_k$(null);
519
523
  }
520
524
  }
521
525
  function AttoWorkerCache$delegateWork$slambda($delegate, $target, this$0) {
522
- return constructCallableReference(function *($this$async, $completion) {
526
+ return constructCallableReference(($this$async, $completion) => orPromise($completion, function *($completion) {
523
527
  var tmp;
524
528
  try {
525
- return yield* $delegate($target, $completion);
529
+ return yield* $($delegate($target, $completion), $completion);
526
530
  } catch ($p) {
527
531
  var tmp_0;
528
532
  if ($p instanceof Exception) {
529
533
  var e = $p;
530
534
  // Inline function 'kotlinx.coroutines.sync.withLock' call
531
- var this_0 = this$0.r3j_1;
532
- yield* this_0.c3h(null, $completion);
535
+ var this_0 = this$0.mutex_1;
536
+ yield* this_0.lock_ugrcvf_k$(null, $completion);
533
537
  var tmp_1;
534
538
  try {
535
- tmp_1 = this$0.s3j_1.h4($target);
539
+ tmp_1 = this$0.cache_1.remove_gppy8k_k$($target);
536
540
  }finally {
537
- this_0.o3g(null);
541
+ this_0.unlock_ulcrcl_k$(null);
538
542
  }
539
543
  throw e;
540
544
  } else {
541
545
  throw $p;
542
546
  }
543
547
  }
544
- }, 1);
548
+ }), 1);
545
549
  }
546
550
  function AttoWorkerCache$work$slambda(this$0, $threshold) {
547
- return constructCallableReference(function *(it, $completion) {
548
- return yield* this$0.p3j_1.m3j($threshold, it, $completion);
549
- }, 1);
551
+ return constructCallableReference((it, $completion) => orPromise($completion, function *($completion) {
552
+ return yield* this$0.delegate_1.work_87s8mv_k$($threshold, it, $completion);
553
+ }), 1);
550
554
  }
551
555
  function AttoWorkerCache$work$slambda_0(this$0, $network, $timestamp) {
552
- return constructCallableReference(function *(it, $completion) {
553
- return yield* this$0.p3j_1.n3j($network, $timestamp, it, $completion);
554
- }, 1);
556
+ return constructCallableReference((it, $completion) => orPromise($completion, function *($completion) {
557
+ return yield* this$0.delegate_1.work_qtc4fi_k$($network, $timestamp, it, $completion);
558
+ }), 1);
555
559
  }
556
560
  function AttoWorkerCache$work$slambda_1(this$0, $block) {
557
- return constructCallableReference(function *(it, $completion) {
558
- return yield* this$0.p3j_1.o3j($block, $completion);
559
- }, 1);
561
+ return constructCallableReference((it, $completion) => orPromise($completion, function *($completion) {
562
+ return yield* this$0.delegate_1.work_uniq4r_k$($block, $completion);
563
+ }), 1);
560
564
  }
561
565
  function AttoWorkerCache$work$slambda_2(this$0, $block) {
562
- return constructCallableReference(function *(it, $completion) {
563
- return yield* this$0.p3j_1.n3j($block.network, Companion_instance_0.now(), it, $completion);
564
- }, 1);
566
+ return constructCallableReference((it, $completion) => orPromise($completion, function *($completion) {
567
+ return yield* this$0.delegate_1.work_qtc4fi_k$($block.network, Companion_instance_0.now(), it, $completion);
568
+ }), 1);
565
569
  }
566
570
  function AttoWorkerCpu$work$lambda($workJob) {
567
571
  return (cause) => {
568
572
  var tmp;
569
573
  if (!(cause == null)) {
570
- $workJob.z2s();
574
+ $workJob.cancel$default_8haxne_k$();
571
575
  tmp = Unit_instance;
572
576
  }
573
577
  return Unit_instance;
574
578
  };
575
579
  }
576
580
  function tryComplete($this, work) {
577
- if (!Companion_instance.q2q($this.x3j_1, $this.y3j_1, work)) {
581
+ if (!Companion_instance.isValid_6ggp82_k$($this.threshold_1, $this.target_1, work)) {
578
582
  return false;
579
583
  }
580
584
  // Inline function 'kotlin.collections.copyOf' call
581
585
  // Inline function 'kotlin.js.asDynamic' call
582
586
  var tmp$ret$0 = work.slice();
583
- return $this.a3k_1.c2y(new AttoWork(tmp$ret$0));
587
+ return $this.result_1.complete_ixf84q_k$(new AttoWork(tmp$ret$0));
584
588
  }
585
589
  function incrementByteArray($this, byteArray) {
586
590
  var carry = 1;
@@ -598,12 +602,12 @@ function incrementByteArray($this, byteArray) {
598
602
  }
599
603
  function WorkerController$result$lambda(this$0) {
600
604
  return (it) => {
601
- cancel(this$0.z3j_1);
605
+ cancel(this$0.scope_1);
602
606
  return Unit_instance;
603
607
  };
604
608
  }
605
609
  function WorkerController$calculate$slambda($i, $rangeSize, this$0) {
606
- return constructCallableReference(function *($this$launch, $completion) {
610
+ return constructCallableReference(($this$launch, $completion) => orPromise($completion, function *($completion) {
607
611
  // Inline function 'kotlin.toULong' call
608
612
  var this_0 = $i;
609
613
  var tmp0 = _ULong___init__impl__c78o9k(fromInt(this_0));
@@ -616,7 +620,7 @@ function WorkerController$calculate$slambda($i, $rangeSize, this$0) {
616
620
  var work = toByteArray(start);
617
621
  var current = start;
618
622
  var iterationsUntilYield = 4096;
619
- while (!(current === end) && get_isActive($this$launch)) {
623
+ while (!equals(new ULong(current), new ULong(end)) && get_isActive($this$launch)) {
620
624
  if (tryComplete(this$0, work))
621
625
  return Unit_instance;
622
626
  incrementByteArray(this$0, work);
@@ -630,7 +634,7 @@ function WorkerController$calculate$slambda($i, $rangeSize, this$0) {
630
634
  }
631
635
  }
632
636
  return Unit_instance;
633
- }, 1);
637
+ }), 1);
634
638
  }
635
639
  function AttoWorkerOperations$Request$Companion$$childSerializers$_anonymous__k0cb7d() {
636
640
  return createSimpleEnumSerializer('cash.atto.commons.AttoNetwork', values());
@@ -658,21 +662,21 @@ function $serializer_getInstance_0() {
658
662
  return $serializer_instance_0;
659
663
  }
660
664
  function defaultCpuWorker() {
661
- return Companion_instance_1.k3j(_UShort___init__impl__jigrne(1));
665
+ return Companion_instance_1.cpu_o7vd24_k$(_UShort___init__impl__jigrne(1));
662
666
  }
663
667
  //region block: post-declaration
664
668
  initMetadataForCompanion(Companion);
665
669
  initMetadataForInterface(AttoWorker, 'AttoWorker', VOID, VOID, [AutoCloseable], [2, 3, 1]);
666
670
  initMetadataForClass(AttoWorkerCache, 'AttoWorkerCache', VOID, VOID, [AttoWorker], [2, 3, 1]);
667
- protoOf(AttoWorkerCpu).n3j = work;
668
- protoOf(AttoWorkerCpu).o3j = work_0;
671
+ protoOf(AttoWorkerCpu).work_qtc4fi_k$ = work;
672
+ protoOf(AttoWorkerCpu).work_uniq4r_k$ = work_0;
669
673
  initMetadataForClass(AttoWorkerCpu, 'AttoWorkerCpu', VOID, VOID, [AttoWorker], [2, 3, 1]);
670
674
  initMetadataForClass(WorkerController, 'WorkerController', VOID, VOID, VOID, [0]);
671
675
  initMetadataForCompanion(Companion_0);
672
- protoOf($serializer).i17 = typeParametersSerializers;
676
+ protoOf($serializer).typeParametersSerializers_fr94fx_k$ = typeParametersSerializers;
673
677
  initMetadataForObject($serializer, '$serializer', VOID, VOID, [GeneratedSerializer]);
674
678
  initMetadataForCompanion(Companion_1);
675
- protoOf($serializer_0).i17 = typeParametersSerializers;
679
+ protoOf($serializer_0).typeParametersSerializers_fr94fx_k$ = typeParametersSerializers;
676
680
  initMetadataForObject($serializer_0, '$serializer', VOID, VOID, [GeneratedSerializer]);
677
681
  initMetadataForClass(Request, 'Request', VOID, VOID, VOID, VOID, VOID, {0: $serializer_getInstance});
678
682
  initMetadataForClass(Response, 'Response', VOID, VOID, VOID, VOID, VOID, {0: $serializer_getInstance_0});
@@ -693,9 +697,9 @@ export {
693
697
  AttoWorkerOperations as AttoWorkerOperations1gnkwfcdzd0wa,
694
698
  cached as cached1s4yf99twpuut,
695
699
  toAsync as toAsync10i9ow1f352l5,
696
- Companion_instance_1 as Companion_instance1kp6jnubfith,
697
- work_0 as work3q0nhsjbo6lx9,
698
- work_1 as work2x6e1hnelgs5b,
700
+ Companion_instance_1 as Companion_instance7s716lzs1l85,
701
+ work_0 as work1yjb62hcp0x3a,
702
+ work_1 as work3lctluiffi34a,
699
703
  };
700
704
  //endregion
701
705