@amadeus-protocol/sdk 1.0.8 → 1.1.1

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 (200) hide show
  1. package/README.md +215 -30
  2. package/dist/api/chain.d.ts +144 -117
  3. package/dist/api/chain.d.ts.map +1 -1
  4. package/dist/api/chain.js +175 -146
  5. package/dist/api/chain.js.map +1 -1
  6. package/dist/api/contract.d.ts +78 -60
  7. package/dist/api/contract.d.ts.map +1 -1
  8. package/dist/api/contract.js +102 -75
  9. package/dist/api/contract.js.map +1 -1
  10. package/dist/api/epoch.d.ts +65 -66
  11. package/dist/api/epoch.d.ts.map +1 -1
  12. package/dist/api/epoch.js +90 -98
  13. package/dist/api/epoch.js.map +1 -1
  14. package/dist/api/peer.d.ts +77 -78
  15. package/dist/api/peer.d.ts.map +1 -1
  16. package/dist/api/peer.js +93 -94
  17. package/dist/api/peer.js.map +1 -1
  18. package/dist/api/proof.d.ts +44 -23
  19. package/dist/api/proof.d.ts.map +1 -1
  20. package/dist/api/proof.js +56 -29
  21. package/dist/api/proof.js.map +1 -1
  22. package/dist/api/transaction.d.ts +68 -69
  23. package/dist/api/transaction.d.ts.map +1 -1
  24. package/dist/api/transaction.js +84 -84
  25. package/dist/api/transaction.js.map +1 -1
  26. package/dist/api/wallet.d.ts +36 -37
  27. package/dist/api/wallet.d.ts.map +1 -1
  28. package/dist/api/wallet.js +47 -50
  29. package/dist/api/wallet.js.map +1 -1
  30. package/dist/client.d.ts +66 -68
  31. package/dist/client.d.ts.map +1 -1
  32. package/dist/client.js +231 -276
  33. package/dist/client.js.map +1 -1
  34. package/dist/constants.d.ts +13 -10
  35. package/dist/constants.d.ts.map +1 -1
  36. package/dist/constants.js +49 -45
  37. package/dist/constants.js.map +1 -1
  38. package/dist/contract-state.d.ts +6 -3
  39. package/dist/contract-state.d.ts.map +1 -1
  40. package/dist/contract-state.js +88 -106
  41. package/dist/contract-state.js.map +1 -1
  42. package/dist/contracts/abi-types.d.ts +32 -32
  43. package/dist/contracts/abi-types.d.ts.map +1 -1
  44. package/dist/contracts/coin.d.ts +13 -20
  45. package/dist/contracts/coin.d.ts.map +1 -1
  46. package/dist/contracts/coin.js +42 -38
  47. package/dist/contracts/coin.js.map +1 -1
  48. package/dist/contracts/contract-call.d.ts +14 -16
  49. package/dist/contracts/contract-call.d.ts.map +1 -1
  50. package/dist/contracts/contract-call.js +45 -54
  51. package/dist/contracts/contract-call.js.map +1 -1
  52. package/dist/contracts/contract.d.ts +24 -55
  53. package/dist/contracts/contract.d.ts.map +1 -1
  54. package/dist/contracts/contract.js +63 -101
  55. package/dist/contracts/contract.js.map +1 -1
  56. package/dist/contracts/lockup/abi.d.ts +54 -51
  57. package/dist/contracts/lockup/abi.d.ts.map +1 -1
  58. package/dist/contracts/lockup/abi.js +65 -74
  59. package/dist/contracts/lockup/abi.js.map +1 -1
  60. package/dist/contracts/lockup/helpers.d.ts +22 -18
  61. package/dist/contracts/lockup/helpers.d.ts.map +1 -1
  62. package/dist/contracts/lockup/helpers.js +44 -47
  63. package/dist/contracts/lockup/helpers.js.map +1 -1
  64. package/dist/contracts/lockup/parsers.d.ts +7 -3
  65. package/dist/contracts/lockup/parsers.d.ts.map +1 -1
  66. package/dist/contracts/lockup/parsers.js +51 -55
  67. package/dist/contracts/lockup/parsers.js.map +1 -1
  68. package/dist/contracts/lockup/storage-keys.d.ts +5 -2
  69. package/dist/contracts/lockup/storage-keys.d.ts.map +1 -1
  70. package/dist/contracts/lockup/storage-keys.js +54 -70
  71. package/dist/contracts/lockup/storage-keys.js.map +1 -1
  72. package/dist/contracts/lockup/types.d.ts +73 -70
  73. package/dist/contracts/lockup/types.d.ts.map +1 -1
  74. package/dist/contracts/lockup-prime/abi.d.ts +328 -325
  75. package/dist/contracts/lockup-prime/abi.d.ts.map +1 -1
  76. package/dist/contracts/lockup-prime/abi.js +397 -417
  77. package/dist/contracts/lockup-prime/abi.js.map +1 -1
  78. package/dist/contracts/lockup-prime/helpers.d.ts +35 -31
  79. package/dist/contracts/lockup-prime/helpers.d.ts.map +1 -1
  80. package/dist/contracts/lockup-prime/helpers.js +131 -137
  81. package/dist/contracts/lockup-prime/helpers.js.map +1 -1
  82. package/dist/contracts/lockup-prime/parsers.d.ts +9 -5
  83. package/dist/contracts/lockup-prime/parsers.d.ts.map +1 -1
  84. package/dist/contracts/lockup-prime/parsers.js +61 -61
  85. package/dist/contracts/lockup-prime/parsers.js.map +1 -1
  86. package/dist/contracts/lockup-prime/storage-keys.d.ts +7 -4
  87. package/dist/contracts/lockup-prime/storage-keys.d.ts.map +1 -1
  88. package/dist/contracts/lockup-prime/storage-keys.js +64 -80
  89. package/dist/contracts/lockup-prime/storage-keys.js.map +1 -1
  90. package/dist/contracts/lockup-prime/types.d.ts +92 -89
  91. package/dist/contracts/lockup-prime/types.d.ts.map +1 -1
  92. package/dist/contracts/lockup-prime/types.js +12 -13
  93. package/dist/contracts/lockup-prime/types.js.map +1 -1
  94. package/dist/contracts/nft/abi.d.ts +104 -0
  95. package/dist/contracts/nft/abi.d.ts.map +1 -0
  96. package/dist/contracts/nft/abi.js +135 -0
  97. package/dist/contracts/nft/abi.js.map +1 -0
  98. package/dist/contracts/nft/helpers.d.ts +21 -0
  99. package/dist/contracts/nft/helpers.d.ts.map +1 -0
  100. package/dist/contracts/nft/helpers.js +61 -0
  101. package/dist/contracts/nft/helpers.js.map +1 -0
  102. package/dist/contracts/nft/types.d.ts +47 -0
  103. package/dist/contracts/nft/types.d.ts.map +1 -0
  104. package/dist/conversion.d.ts +5 -2
  105. package/dist/conversion.d.ts.map +1 -1
  106. package/dist/conversion.js +45 -50
  107. package/dist/conversion.js.map +1 -1
  108. package/dist/crypto.d.ts +14 -16
  109. package/dist/crypto.d.ts.map +1 -1
  110. package/dist/crypto.js +121 -140
  111. package/dist/crypto.js.map +1 -1
  112. package/dist/encoding.d.ts +11 -8
  113. package/dist/encoding.d.ts.map +1 -1
  114. package/dist/encoding.js +123 -144
  115. package/dist/encoding.js.map +1 -1
  116. package/dist/encryption.d.ts +15 -12
  117. package/dist/encryption.d.ts.map +1 -1
  118. package/dist/encryption.js +119 -117
  119. package/dist/encryption.js.map +1 -1
  120. package/dist/explorer.d.ts +10 -7
  121. package/dist/explorer.d.ts.map +1 -1
  122. package/dist/explorer.js +51 -48
  123. package/dist/explorer.js.map +1 -1
  124. package/dist/formatters.d.ts +8 -5
  125. package/dist/formatters.d.ts.map +1 -1
  126. package/dist/formatters.js +67 -68
  127. package/dist/formatters.js.map +1 -1
  128. package/dist/index.d.ts +42 -55
  129. package/dist/index.js +39 -55
  130. package/dist/mnemonic.d.ts +12 -9
  131. package/dist/mnemonic.d.ts.map +1 -1
  132. package/dist/mnemonic.js +105 -114
  133. package/dist/mnemonic.js.map +1 -1
  134. package/dist/networks.d.ts +14 -17
  135. package/dist/networks.d.ts.map +1 -1
  136. package/dist/networks.js +40 -36
  137. package/dist/networks.js.map +1 -1
  138. package/dist/schemas.js +75 -79
  139. package/dist/schemas.js.map +1 -1
  140. package/dist/sdk.d.ts +69 -65
  141. package/dist/sdk.d.ts.map +1 -1
  142. package/dist/sdk.js +126 -117
  143. package/dist/sdk.js.map +1 -1
  144. package/dist/serialization.d.ts +8 -18
  145. package/dist/serialization.d.ts.map +1 -1
  146. package/dist/serialization.js +207 -260
  147. package/dist/serialization.js.map +1 -1
  148. package/dist/signing.js +67 -67
  149. package/dist/signing.js.map +1 -1
  150. package/dist/transaction-builder.d.ts +175 -184
  151. package/dist/transaction-builder.d.ts.map +1 -1
  152. package/dist/transaction-builder.js +295 -344
  153. package/dist/transaction-builder.js.map +1 -1
  154. package/dist/transaction-errors.d.ts +10 -12
  155. package/dist/transaction-errors.d.ts.map +1 -1
  156. package/dist/transaction-errors.js +145 -166
  157. package/dist/transaction-errors.js.map +1 -1
  158. package/dist/types.d.ts +530 -450
  159. package/dist/types.d.ts.map +1 -1
  160. package/dist/types.js +169 -183
  161. package/dist/types.js.map +1 -1
  162. package/dist/validation.d.ts +24 -26
  163. package/dist/validation.d.ts.map +1 -1
  164. package/dist/validation.js +194 -192
  165. package/dist/validation.js.map +1 -1
  166. package/package.json +4 -3
  167. package/dist/api/index.d.ts +0 -8
  168. package/dist/api/index.d.ts.map +0 -1
  169. package/dist/api/index.js +0 -8
  170. package/dist/api/index.js.map +0 -1
  171. package/dist/contracts/abi-types.js +0 -8
  172. package/dist/contracts/abi-types.js.map +0 -1
  173. package/dist/contracts/index.d.ts +0 -7
  174. package/dist/contracts/index.d.ts.map +0 -1
  175. package/dist/contracts/index.js +0 -7
  176. package/dist/contracts/index.js.map +0 -1
  177. package/dist/contracts/lockup/calls.d.ts +0 -23
  178. package/dist/contracts/lockup/calls.d.ts.map +0 -1
  179. package/dist/contracts/lockup/calls.js +0 -25
  180. package/dist/contracts/lockup/calls.js.map +0 -1
  181. package/dist/contracts/lockup/index.d.ts +0 -6
  182. package/dist/contracts/lockup/index.d.ts.map +0 -1
  183. package/dist/contracts/lockup/index.js +0 -6
  184. package/dist/contracts/lockup/index.js.map +0 -1
  185. package/dist/contracts/lockup/types.js +0 -7
  186. package/dist/contracts/lockup/types.js.map +0 -1
  187. package/dist/contracts/lockup-prime/calls.d.ts +0 -53
  188. package/dist/contracts/lockup-prime/calls.d.ts.map +0 -1
  189. package/dist/contracts/lockup-prime/calls.js +0 -60
  190. package/dist/contracts/lockup-prime/calls.js.map +0 -1
  191. package/dist/contracts/lockup-prime/index.d.ts +0 -6
  192. package/dist/contracts/lockup-prime/index.d.ts.map +0 -1
  193. package/dist/contracts/lockup-prime/index.js +0 -6
  194. package/dist/contracts/lockup-prime/index.js.map +0 -1
  195. package/dist/index.d.ts.map +0 -1
  196. package/dist/index.js.map +0 -1
  197. package/dist/schemas.d.ts +0 -67
  198. package/dist/schemas.d.ts.map +0 -1
  199. package/dist/signing.d.ts +0 -39
  200. package/dist/signing.d.ts.map +0 -1
@@ -1,420 +1,400 @@
1
+ //#region src/contracts/lockup-prime/abi.ts
1
2
  /**
2
- * LockupPrime Smart Contract ABI
3
- *
4
- * Standard ABI format
5
- * Based on: /root/node/ex/native/rdb/src/consensus/bic/lockup_prime.rs
6
- */
7
- export const LOCKUP_PRIME_ABI = {
8
- contractName: 'LockupPrime',
9
- contractVersion: '1.0.0',
10
- abi: [
11
- {
12
- type: 'function',
13
- name: 'lock',
14
- inputs: [
15
- {
16
- name: 'amount',
17
- type: 'string',
18
- description: 'Amount in flat units (as string, must be > 1 flat unit)',
19
- validation: {
20
- min: '1',
21
- type: 'i128'
22
- }
23
- },
24
- {
25
- name: 'tier',
26
- type: 'string',
27
- description: 'Lock tier',
28
- enum: ['7d', '30d', '90d', '180d', '365d']
29
- }
30
- ],
31
- outputs: [],
32
- stateMutability: 'nonpayable',
33
- description: 'Lock AMA tokens for a specified tier to earn PRIME points',
34
- requirements: [
35
- 'amount > 1 flat unit',
36
- 'sufficient AMA balance',
37
- 'amount and tier must be UTF-8 encoded strings'
38
- ],
39
- storage: {
40
- writes: [
41
- {
42
- key: 'bic:lockup_prime:vault:{caller}:{vault_index}',
43
- value: '{tier}-{multiplier}-{unlock_epoch}-{amount}',
44
- description: 'Creates a new vault entry'
45
- },
46
- {
47
- key: 'bic:lockup_prime:unique_index',
48
- operation: 'increment',
49
- description: 'Increments global vault index counter'
50
- },
51
- {
52
- key: 'bic:coin:balance:{caller}:AMA',
53
- operation: 'decrement',
54
- amount: 'amount',
55
- description: "Deducts AMA from caller's balance"
56
- }
57
- ],
58
- reads: [
59
- {
60
- key: 'bic:coin:balance:{caller}:AMA',
61
- description: "Checks caller's AMA balance"
62
- }
63
- ]
64
- }
65
- },
66
- {
67
- type: 'function',
68
- name: 'unlock',
69
- inputs: [
70
- {
71
- name: 'vaultIndex',
72
- type: 'string',
73
- description: 'Vault index to unlock (as string, e.g., "0", "1", "2")'
74
- }
75
- ],
76
- outputs: [],
77
- stateMutability: 'nonpayable',
78
- description: 'Unlock a vault and receive PRIME points (or penalty if early)',
79
- requirements: ['vault must exist', 'vault must belong to caller'],
80
- storage: {
81
- reads: [
82
- {
83
- key: 'bic:lockup_prime:vault:{caller}:{vault_index}',
84
- value: '{tier}-{multiplier}-{unlock_epoch}-{amount}',
85
- description: 'Reads vault data'
86
- }
87
- ],
88
- writes: [
89
- {
90
- key: 'bic:lockup_prime:vault:{caller}:{vault_index}',
91
- operation: 'delete',
92
- description: 'Deletes vault after unlock'
93
- },
94
- {
95
- condition: 'if current_epoch < unlock_epoch (early unlock)',
96
- writes: [
97
- {
98
- key: 'bic:coin:balance:{treasury}:AMA',
99
- operation: 'increment',
100
- amount: 'penalty (25% of amount)',
101
- description: 'Penalty sent to treasury'
102
- },
103
- {
104
- key: 'bic:lockup:vault:{caller}:{index}',
105
- operation: 'create',
106
- amount: 'disbursement (75% of amount)',
107
- duration: '5 epochs',
108
- description: 'Remaining amount locked for 5 epochs'
109
- }
110
- ]
111
- },
112
- {
113
- condition: 'if current_epoch >= unlock_epoch (normal unlock)',
114
- writes: [
115
- {
116
- key: 'bic:coin:balance:{caller}:PRIME',
117
- operation: 'mint',
118
- amount: 'amount * multiplier',
119
- description: 'Mints PRIME points'
120
- },
121
- {
122
- key: 'bic:coin:balance:{caller}:AMA',
123
- operation: 'increment',
124
- amount: 'amount',
125
- description: 'Returns locked AMA'
126
- }
127
- ]
128
- }
129
- ]
130
- }
131
- },
132
- {
133
- type: 'function',
134
- name: 'daily_checkin',
135
- inputs: [
136
- {
137
- name: 'vaultIndex',
138
- type: 'string',
139
- description: 'Vault index for checkin (as string, e.g., "0", "1", "2")'
140
- }
141
- ],
142
- outputs: [],
143
- stateMutability: 'nonpayable',
144
- description: 'Daily checkin to earn bonus PRIME points and maintain streak',
145
- requirements: [
146
- 'vault must exist',
147
- 'must be within 2-epoch checkin window',
148
- 'vault must belong to caller'
149
- ],
150
- storage: {
151
- reads: [
152
- {
153
- key: 'bic:lockup_prime:vault:{caller}:{vault_index}',
154
- value: '{tier}-{multiplier}-{unlock_epoch}-{amount}',
155
- description: 'Reads vault amount for bonus calculation'
156
- },
157
- {
158
- key: 'bic:lockup_prime:next_checkin_epoch:{caller}',
159
- value: 'epoch (as string)',
160
- description: 'Next allowed checkin epoch'
161
- }
162
- ],
163
- writes: [
164
- {
165
- condition: 'if delta == 0 || delta == 1 (valid checkin)',
166
- writes: [
167
- {
168
- key: 'bic:lockup_prime:next_checkin_epoch:{caller}',
169
- value: 'current_epoch + 2',
170
- description: 'Updates next checkin epoch'
171
- },
172
- {
173
- key: 'bic:coin:balance:{caller}:PRIME',
174
- operation: 'mint',
175
- amount: 'unlock_amount / 100',
176
- description: 'Daily bonus (1% of locked amount)'
177
- },
178
- {
179
- key: 'bic:lockup_prime:daily_streak:{caller}',
180
- operation: 'increment',
181
- description: 'Increments streak counter'
182
- },
183
- {
184
- condition: 'if streak >= 30',
185
- writes: [
186
- {
187
- key: 'bic:lockup_prime:daily_streak:{caller}',
188
- value: '0',
189
- description: 'Resets streak after bonus'
190
- },
191
- {
192
- key: 'bic:coin:balance:{caller}:PRIME',
193
- operation: 'mint',
194
- amount: 'daily_bonus * 30',
195
- description: 'Streak bonus (30x daily bonus)'
196
- }
197
- ]
198
- }
199
- ]
200
- },
201
- {
202
- condition: 'if delta > 2 (missed checkin)',
203
- writes: [
204
- {
205
- key: 'bic:lockup_prime:next_checkin_epoch:{caller}',
206
- value: 'current_epoch + 2',
207
- description: 'Resets next checkin epoch'
208
- },
209
- {
210
- key: 'bic:lockup_prime:daily_streak:{caller}',
211
- value: '0',
212
- description: 'Resets streak to 0'
213
- }
214
- ]
215
- }
216
- ]
217
- }
218
- }
219
- ],
220
- errors: [
221
- {
222
- name: 'invalid_args',
223
- code: 'INVALID_ARGS',
224
- description: 'Invalid number of arguments'
225
- },
226
- {
227
- name: 'invalid_amount',
228
- code: 'INVALID_AMOUNT',
229
- description: 'Amount must be > 1 flat unit and valid i128'
230
- },
231
- {
232
- name: 'invalid_tier',
233
- code: 'INVALID_TIER',
234
- description: 'Tier must be one of: 7d, 30d, 90d, 180d, 365d'
235
- },
236
- {
237
- name: 'insufficient_funds',
238
- code: 'INSUFFICIENT_FUNDS',
239
- description: 'Insufficient AMA balance'
240
- },
241
- {
242
- name: 'invalid_vault',
243
- code: 'INVALID_VAULT',
244
- description: 'Vault does not exist or does not belong to caller'
245
- },
246
- {
247
- name: 'invalid_multiplier',
248
- code: 'INVALID_MULTIPLIER',
249
- description: 'Invalid multiplier value in vault data'
250
- },
251
- {
252
- name: 'invalid_unlock_epoch',
253
- code: 'INVALID_UNLOCK_EPOCH',
254
- description: 'Invalid unlock epoch value in vault data'
255
- },
256
- {
257
- name: 'invalid_unlock_amount',
258
- code: 'INVALID_UNLOCK_AMOUNT',
259
- description: 'Invalid unlock amount value in vault data'
260
- },
261
- {
262
- name: 'invalid_next_checkin_epoch',
263
- code: 'INVALID_NEXT_CHECKIN_EPOCH',
264
- description: 'Invalid next checkin epoch value'
265
- }
266
- ],
267
- storage: {
268
- keys: [
269
- {
270
- name: 'vault',
271
- pattern: 'bic:lockup_prime:vault:{account}:{vault_index}',
272
- type: 'mapping',
273
- description: 'Vault data for each account and vault index',
274
- valueFormat: '{tier}-{multiplier}-{unlock_epoch}-{amount}',
275
- valueSchema: {
276
- tier: {
277
- type: 'string',
278
- enum: ['7d', '30d', '90d', '180d', '365d']
279
- },
280
- multiplier: {
281
- type: 'string',
282
- description: 'Multiplier as string (e.g., "17", "27")',
283
- parseAs: 'u64'
284
- },
285
- unlock_epoch: {
286
- type: 'string',
287
- description: 'Unlock epoch as string',
288
- parseAs: 'u64'
289
- },
290
- amount: {
291
- type: 'string',
292
- description: 'Locked amount in flat units as string',
293
- parseAs: 'u64'
294
- }
295
- },
296
- query: {
297
- method: 'POST',
298
- endpoint: '/api/contract/get_prefix',
299
- prefix: 'bic:lockup_prime:vault:{account_binary}:',
300
- description: 'Get all vaults for an account. Returns array of [key, value] tuples.'
301
- }
302
- },
303
- {
304
- name: 'daily_streak',
305
- pattern: 'bic:lockup_prime:daily_streak:{account}',
306
- type: 'value',
307
- description: 'Current daily checkin streak count',
308
- valueFormat: 'string (number)',
309
- valueSchema: {
310
- type: 'string',
311
- parseAs: 'u64',
312
- description: 'Streak count as string (e.g., "5", "0")'
313
- },
314
- query: {
315
- method: 'POST',
316
- endpoint: '/api/contract/get',
317
- key: 'bic:lockup_prime:daily_streak:{account_binary}',
318
- description: 'Get daily streak for an account'
319
- }
320
- },
321
- {
322
- name: 'next_checkin_epoch',
323
- pattern: 'bic:lockup_prime:next_checkin_epoch:{account}',
324
- type: 'value',
325
- description: 'Next epoch when checkin is allowed',
326
- valueFormat: 'string (number)',
327
- valueSchema: {
328
- type: 'string',
329
- parseAs: 'u64',
330
- description: 'Epoch as string (e.g., "145", "200")'
331
- },
332
- query: {
333
- method: 'POST',
334
- endpoint: '/api/contract/get',
335
- key: 'bic:lockup_prime:next_checkin_epoch:{account_binary}',
336
- description: 'Get next checkin epoch for an account'
337
- }
338
- },
339
- {
340
- name: 'unique_index',
341
- pattern: 'bic:lockup_prime:unique_index',
342
- type: 'value',
343
- description: 'Global vault index counter',
344
- valueFormat: 'string (number)',
345
- valueSchema: {
346
- type: 'string',
347
- parseAs: 'u64',
348
- description: 'Global counter as string'
349
- },
350
- query: {
351
- method: 'POST',
352
- endpoint: '/api/contract/get',
353
- key: 'bic:lockup_prime:unique_index',
354
- description: 'Get global vault index counter'
355
- }
356
- }
357
- ]
358
- },
359
- constants: {
360
- tiers: {
361
- '7d': {
362
- epochs: 10,
363
- multiplier: 13,
364
- label: '7 Days'
365
- },
366
- '30d': {
367
- epochs: 45,
368
- multiplier: 17,
369
- label: '30 Days'
370
- },
371
- '90d': {
372
- epochs: 135,
373
- multiplier: 27,
374
- label: '90 Days'
375
- },
376
- '180d': {
377
- epochs: 270,
378
- multiplier: 35,
379
- label: '180 Days'
380
- },
381
- '365d': {
382
- epochs: 547,
383
- multiplier: 54,
384
- label: '365 Days'
385
- }
386
- },
387
- values: {
388
- MIN_LOCK_AMOUNT: '1',
389
- DAILY_BONUS_PERCENTAGE: '100',
390
- STREAK_BONUS_THRESHOLD: '30',
391
- STREAK_BONUS_MULTIPLIER: '30',
392
- EARLY_UNLOCK_PENALTY: '0.25',
393
- EARLY_UNLOCK_LOCK_DURATION: '5',
394
- CHECKIN_WINDOW: '2'
395
- }
396
- },
397
- encoding: {
398
- args: {
399
- format: 'UTF-8 encoded strings',
400
- description: 'All function arguments must be UTF-8 encoded as Uint8Array using TextEncoder',
401
- example: {
402
- lock: [
403
- "new TextEncoder().encode('1000000000000')",
404
- "new TextEncoder().encode('30d')"
405
- ]
406
- }
407
- },
408
- storage: {
409
- keys: {
410
- format: 'Binary (48 bytes for account)',
411
- description: 'Storage keys use binary account addresses, not base58'
412
- },
413
- values: {
414
- format: 'UTF-8 strings',
415
- description: 'All storage values are UTF-8 encoded strings'
416
- }
417
- }
418
- }
3
+ * LockupPrime Smart Contract ABI
4
+ *
5
+ * Standard ABI format
6
+ * Based on: /root/node/ex/native/rdb/src/consensus/bic/lockup_prime.rs
7
+ */
8
+ const LOCKUP_PRIME_ABI = {
9
+ contractName: "LockupPrime",
10
+ contractVersion: "1.0.0",
11
+ abi: [
12
+ {
13
+ type: "function",
14
+ name: "lock",
15
+ inputs: [{
16
+ name: "amount",
17
+ type: "string",
18
+ description: "Amount in flat units (as string, must be > 1 flat unit)",
19
+ validation: {
20
+ min: "1",
21
+ type: "i128"
22
+ }
23
+ }, {
24
+ name: "tier",
25
+ type: "string",
26
+ description: "Lock tier",
27
+ enum: [
28
+ "7d",
29
+ "30d",
30
+ "90d",
31
+ "180d",
32
+ "365d"
33
+ ]
34
+ }],
35
+ outputs: [],
36
+ stateMutability: "nonpayable",
37
+ description: "Lock AMA tokens for a specified tier to earn PRIME points",
38
+ requirements: [
39
+ "amount > 1 flat unit",
40
+ "sufficient AMA balance",
41
+ "amount and tier must be UTF-8 encoded strings"
42
+ ],
43
+ storage: {
44
+ writes: [
45
+ {
46
+ key: "bic:lockup_prime:vault:{caller}:{vault_index}",
47
+ value: "{tier}-{multiplier}-{unlock_epoch}-{amount}",
48
+ description: "Creates a new vault entry"
49
+ },
50
+ {
51
+ key: "bic:lockup_prime:unique_index",
52
+ operation: "increment",
53
+ description: "Increments global vault index counter"
54
+ },
55
+ {
56
+ key: "bic:coin:balance:{caller}:AMA",
57
+ operation: "decrement",
58
+ amount: "amount",
59
+ description: "Deducts AMA from caller's balance"
60
+ }
61
+ ],
62
+ reads: [{
63
+ key: "bic:coin:balance:{caller}:AMA",
64
+ description: "Checks caller's AMA balance"
65
+ }]
66
+ }
67
+ },
68
+ {
69
+ type: "function",
70
+ name: "unlock",
71
+ inputs: [{
72
+ name: "vaultIndex",
73
+ type: "string",
74
+ description: "Vault index to unlock (as string, e.g., \"0\", \"1\", \"2\")"
75
+ }],
76
+ outputs: [],
77
+ stateMutability: "nonpayable",
78
+ description: "Unlock a vault and receive PRIME points (or penalty if early)",
79
+ requirements: ["vault must exist", "vault must belong to caller"],
80
+ storage: {
81
+ reads: [{
82
+ key: "bic:lockup_prime:vault:{caller}:{vault_index}",
83
+ value: "{tier}-{multiplier}-{unlock_epoch}-{amount}",
84
+ description: "Reads vault data"
85
+ }],
86
+ writes: [
87
+ {
88
+ key: "bic:lockup_prime:vault:{caller}:{vault_index}",
89
+ operation: "delete",
90
+ description: "Deletes vault after unlock"
91
+ },
92
+ {
93
+ condition: "if current_epoch < unlock_epoch (early unlock)",
94
+ writes: [{
95
+ key: "bic:coin:balance:{treasury}:AMA",
96
+ operation: "increment",
97
+ amount: "penalty (25% of amount)",
98
+ description: "Penalty sent to treasury"
99
+ }, {
100
+ key: "bic:lockup:vault:{caller}:{index}",
101
+ operation: "create",
102
+ amount: "disbursement (75% of amount)",
103
+ duration: "5 epochs",
104
+ description: "Remaining amount locked for 5 epochs"
105
+ }]
106
+ },
107
+ {
108
+ condition: "if current_epoch >= unlock_epoch (normal unlock)",
109
+ writes: [{
110
+ key: "bic:coin:balance:{caller}:PRIME",
111
+ operation: "mint",
112
+ amount: "amount * multiplier",
113
+ description: "Mints PRIME points"
114
+ }, {
115
+ key: "bic:coin:balance:{caller}:AMA",
116
+ operation: "increment",
117
+ amount: "amount",
118
+ description: "Returns locked AMA"
119
+ }]
120
+ }
121
+ ]
122
+ }
123
+ },
124
+ {
125
+ type: "function",
126
+ name: "daily_checkin",
127
+ inputs: [{
128
+ name: "vaultIndex",
129
+ type: "string",
130
+ description: "Vault index for checkin (as string, e.g., \"0\", \"1\", \"2\")"
131
+ }],
132
+ outputs: [],
133
+ stateMutability: "nonpayable",
134
+ description: "Daily checkin to earn bonus PRIME points and maintain streak",
135
+ requirements: [
136
+ "vault must exist",
137
+ "must be within 2-epoch checkin window",
138
+ "vault must belong to caller"
139
+ ],
140
+ storage: {
141
+ reads: [{
142
+ key: "bic:lockup_prime:vault:{caller}:{vault_index}",
143
+ value: "{tier}-{multiplier}-{unlock_epoch}-{amount}",
144
+ description: "Reads vault amount for bonus calculation"
145
+ }, {
146
+ key: "bic:lockup_prime:next_checkin_epoch:{caller}",
147
+ value: "epoch (as string)",
148
+ description: "Next allowed checkin epoch"
149
+ }],
150
+ writes: [{
151
+ condition: "if delta == 0 || delta == 1 (valid checkin)",
152
+ writes: [
153
+ {
154
+ key: "bic:lockup_prime:next_checkin_epoch:{caller}",
155
+ value: "current_epoch + 2",
156
+ description: "Updates next checkin epoch"
157
+ },
158
+ {
159
+ key: "bic:coin:balance:{caller}:PRIME",
160
+ operation: "mint",
161
+ amount: "unlock_amount / 100",
162
+ description: "Daily bonus (1% of locked amount)"
163
+ },
164
+ {
165
+ key: "bic:lockup_prime:daily_streak:{caller}",
166
+ operation: "increment",
167
+ description: "Increments streak counter"
168
+ },
169
+ {
170
+ condition: "if streak >= 30",
171
+ writes: [{
172
+ key: "bic:lockup_prime:daily_streak:{caller}",
173
+ value: "0",
174
+ description: "Resets streak after bonus"
175
+ }, {
176
+ key: "bic:coin:balance:{caller}:PRIME",
177
+ operation: "mint",
178
+ amount: "daily_bonus * 30",
179
+ description: "Streak bonus (30x daily bonus)"
180
+ }]
181
+ }
182
+ ]
183
+ }, {
184
+ condition: "if delta > 2 (missed checkin)",
185
+ writes: [{
186
+ key: "bic:lockup_prime:next_checkin_epoch:{caller}",
187
+ value: "current_epoch + 2",
188
+ description: "Resets next checkin epoch"
189
+ }, {
190
+ key: "bic:lockup_prime:daily_streak:{caller}",
191
+ value: "0",
192
+ description: "Resets streak to 0"
193
+ }]
194
+ }]
195
+ }
196
+ }
197
+ ],
198
+ errors: [
199
+ {
200
+ name: "invalid_args",
201
+ code: "INVALID_ARGS",
202
+ description: "Invalid number of arguments"
203
+ },
204
+ {
205
+ name: "invalid_amount",
206
+ code: "INVALID_AMOUNT",
207
+ description: "Amount must be > 1 flat unit and valid i128"
208
+ },
209
+ {
210
+ name: "invalid_tier",
211
+ code: "INVALID_TIER",
212
+ description: "Tier must be one of: 7d, 30d, 90d, 180d, 365d"
213
+ },
214
+ {
215
+ name: "insufficient_funds",
216
+ code: "INSUFFICIENT_FUNDS",
217
+ description: "Insufficient AMA balance"
218
+ },
219
+ {
220
+ name: "invalid_vault",
221
+ code: "INVALID_VAULT",
222
+ description: "Vault does not exist or does not belong to caller"
223
+ },
224
+ {
225
+ name: "invalid_multiplier",
226
+ code: "INVALID_MULTIPLIER",
227
+ description: "Invalid multiplier value in vault data"
228
+ },
229
+ {
230
+ name: "invalid_unlock_epoch",
231
+ code: "INVALID_UNLOCK_EPOCH",
232
+ description: "Invalid unlock epoch value in vault data"
233
+ },
234
+ {
235
+ name: "invalid_unlock_amount",
236
+ code: "INVALID_UNLOCK_AMOUNT",
237
+ description: "Invalid unlock amount value in vault data"
238
+ },
239
+ {
240
+ name: "invalid_next_checkin_epoch",
241
+ code: "INVALID_NEXT_CHECKIN_EPOCH",
242
+ description: "Invalid next checkin epoch value"
243
+ }
244
+ ],
245
+ storage: { keys: [
246
+ {
247
+ name: "vault",
248
+ pattern: "bic:lockup_prime:vault:{account}:{vault_index}",
249
+ type: "mapping",
250
+ description: "Vault data for each account and vault index",
251
+ valueFormat: "{tier}-{multiplier}-{unlock_epoch}-{amount}",
252
+ valueSchema: {
253
+ tier: {
254
+ type: "string",
255
+ enum: [
256
+ "7d",
257
+ "30d",
258
+ "90d",
259
+ "180d",
260
+ "365d"
261
+ ]
262
+ },
263
+ multiplier: {
264
+ type: "string",
265
+ description: "Multiplier as string (e.g., \"17\", \"27\")",
266
+ parseAs: "u64"
267
+ },
268
+ unlock_epoch: {
269
+ type: "string",
270
+ description: "Unlock epoch as string",
271
+ parseAs: "u64"
272
+ },
273
+ amount: {
274
+ type: "string",
275
+ description: "Locked amount in flat units as string",
276
+ parseAs: "u64"
277
+ }
278
+ },
279
+ query: {
280
+ method: "POST",
281
+ endpoint: "/api/contract/get_prefix",
282
+ prefix: "bic:lockup_prime:vault:{account_binary}:",
283
+ description: "Get all vaults for an account. Returns array of [key, value] tuples."
284
+ }
285
+ },
286
+ {
287
+ name: "daily_streak",
288
+ pattern: "bic:lockup_prime:daily_streak:{account}",
289
+ type: "value",
290
+ description: "Current daily checkin streak count",
291
+ valueFormat: "string (number)",
292
+ valueSchema: {
293
+ type: "string",
294
+ parseAs: "u64",
295
+ description: "Streak count as string (e.g., \"5\", \"0\")"
296
+ },
297
+ query: {
298
+ method: "POST",
299
+ endpoint: "/api/contract/get",
300
+ key: "bic:lockup_prime:daily_streak:{account_binary}",
301
+ description: "Get daily streak for an account"
302
+ }
303
+ },
304
+ {
305
+ name: "next_checkin_epoch",
306
+ pattern: "bic:lockup_prime:next_checkin_epoch:{account}",
307
+ type: "value",
308
+ description: "Next epoch when checkin is allowed",
309
+ valueFormat: "string (number)",
310
+ valueSchema: {
311
+ type: "string",
312
+ parseAs: "u64",
313
+ description: "Epoch as string (e.g., \"145\", \"200\")"
314
+ },
315
+ query: {
316
+ method: "POST",
317
+ endpoint: "/api/contract/get",
318
+ key: "bic:lockup_prime:next_checkin_epoch:{account_binary}",
319
+ description: "Get next checkin epoch for an account"
320
+ }
321
+ },
322
+ {
323
+ name: "unique_index",
324
+ pattern: "bic:lockup_prime:unique_index",
325
+ type: "value",
326
+ description: "Global vault index counter",
327
+ valueFormat: "string (number)",
328
+ valueSchema: {
329
+ type: "string",
330
+ parseAs: "u64",
331
+ description: "Global counter as string"
332
+ },
333
+ query: {
334
+ method: "POST",
335
+ endpoint: "/api/contract/get",
336
+ key: "bic:lockup_prime:unique_index",
337
+ description: "Get global vault index counter"
338
+ }
339
+ }
340
+ ] },
341
+ constants: {
342
+ tiers: {
343
+ "7d": {
344
+ epochs: 10,
345
+ multiplier: 13,
346
+ label: "7 Days"
347
+ },
348
+ "30d": {
349
+ epochs: 45,
350
+ multiplier: 17,
351
+ label: "30 Days"
352
+ },
353
+ "90d": {
354
+ epochs: 135,
355
+ multiplier: 27,
356
+ label: "90 Days"
357
+ },
358
+ "180d": {
359
+ epochs: 270,
360
+ multiplier: 35,
361
+ label: "180 Days"
362
+ },
363
+ "365d": {
364
+ epochs: 547,
365
+ multiplier: 54,
366
+ label: "365 Days"
367
+ }
368
+ },
369
+ values: {
370
+ MIN_LOCK_AMOUNT: "1",
371
+ DAILY_BONUS_PERCENTAGE: "100",
372
+ STREAK_BONUS_THRESHOLD: "30",
373
+ STREAK_BONUS_MULTIPLIER: "30",
374
+ EARLY_UNLOCK_PENALTY: "0.25",
375
+ EARLY_UNLOCK_LOCK_DURATION: "5",
376
+ CHECKIN_WINDOW: "2"
377
+ }
378
+ },
379
+ encoding: {
380
+ args: {
381
+ format: "UTF-8 encoded strings",
382
+ description: "All function arguments must be UTF-8 encoded as Uint8Array using TextEncoder",
383
+ example: { lock: ["new TextEncoder().encode('1000000000000')", "new TextEncoder().encode('30d')"] }
384
+ },
385
+ storage: {
386
+ keys: {
387
+ format: "Binary (48 bytes for account)",
388
+ description: "Storage keys use binary account addresses, not base58"
389
+ },
390
+ values: {
391
+ format: "UTF-8 strings",
392
+ description: "All storage values are UTF-8 encoded strings"
393
+ }
394
+ }
395
+ }
419
396
  };
397
+ //#endregion
398
+ export { LOCKUP_PRIME_ABI };
399
+
420
400
  //# sourceMappingURL=abi.js.map