@actioncodes/protocol 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +55 -0
- package/dist/actioncode.d.ts +114 -0
- package/dist/actioncode.d.ts.map +1 -0
- package/dist/actioncode.js +159 -0
- package/dist/adapters/base.d.ts +52 -0
- package/dist/adapters/base.d.ts.map +1 -0
- package/dist/adapters/base.js +41 -0
- package/dist/adapters/solana/index.d.ts +2 -0
- package/dist/adapters/solana/index.d.ts.map +1 -0
- package/dist/adapters/solana/index.js +17 -0
- package/dist/adapters/solana/solana.d.ts +84 -0
- package/dist/adapters/solana/solana.d.ts.map +1 -0
- package/dist/adapters/solana/solana.js +223 -0
- package/dist/codegen.d.ts +73 -0
- package/dist/codegen.d.ts.map +1 -0
- package/dist/codegen.js +118 -0
- package/dist/constants.d.ts +10 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +11 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/meta.d.ts +54 -0
- package/dist/meta.d.ts.map +1 -0
- package/dist/meta.js +91 -0
- package/dist/protocol.d.ts +167 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +280 -0
- package/docs/README.md +59 -0
- package/docs/_media/LICENSE +201 -0
- package/docs/_media/README.md +28 -0
- package/docs/actioncode/README.md +21 -0
- package/docs/actioncode/classes/ActionCode.md +412 -0
- package/docs/actioncode/interfaces/ActionCodeFields.md +95 -0
- package/docs/actioncode/interfaces/ActionCodeMetadata.md +25 -0
- package/docs/actioncode/interfaces/ActionCodeTransaction.md +39 -0
- package/docs/actioncode/type-aliases/ActionCodeStatus.md +11 -0
- package/docs/adapters/base/README.md +11 -0
- package/docs/adapters/base/classes/BaseChainAdapter.md +222 -0
- package/docs/adapters/solana/README.md +19 -0
- package/docs/adapters/solana/solana/README.md +15 -0
- package/docs/adapters/solana/solana/classes/SolanaAdapter.md +306 -0
- package/docs/adapters/solana/solana/type-aliases/SolanaTransaction.md +13 -0
- package/docs/codegen/README.md +11 -0
- package/docs/codegen/classes/CodeGenerator.md +337 -0
- package/docs/constants/README.md +22 -0
- package/docs/constants/type-aliases/SupportedChain.md +11 -0
- package/docs/constants/variables/CODE_LENGTH.md +11 -0
- package/docs/constants/variables/CODE_TTL.md +11 -0
- package/docs/constants/variables/MAX_PREFIX_LENGTH.md +11 -0
- package/docs/constants/variables/MIN_PREFIX_LENGTH.md +11 -0
- package/docs/constants/variables/PROTOCOL_CODE_PREFIX.md +11 -0
- package/docs/constants/variables/PROTOCOL_PREFIX.md +11 -0
- package/docs/constants/variables/PROTOCOL_VERSION.md +11 -0
- package/docs/constants/variables/SUPPORTED_CHAINS.md +11 -0
- package/docs/index/README.md +139 -0
- package/docs/meta/README.md +15 -0
- package/docs/meta/classes/ProtocolMetaParser.md +177 -0
- package/docs/meta/interfaces/ProtocolMetaV1.md +59 -0
- package/docs/modules.md +17 -0
- package/docs/protocol/README.md +51 -0
- package/docs/protocol/classes/ActionCodesProtocol.md +616 -0
- package/docs/protocol/interfaces/ProtocolConfig.md +71 -0
- package/package.json +90 -0
@@ -0,0 +1,616 @@
|
|
1
|
+
[**@actioncodes/protocol**](../../README.md)
|
2
|
+
|
3
|
+
***
|
4
|
+
|
5
|
+
[@actioncodes/protocol](../../modules.md) / [protocol](../README.md) / ActionCodesProtocol
|
6
|
+
|
7
|
+
# Class: ActionCodesProtocol
|
8
|
+
|
9
|
+
Defined in: [protocol.ts:31](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/protocol.ts#L31)
|
10
|
+
|
11
|
+
OTA Protocol - Main entry point for the One-Time Action Code Protocol
|
12
|
+
|
13
|
+
Provides a unified interface for generating, validating, and managing
|
14
|
+
action codes across multiple blockchain networks.
|
15
|
+
|
16
|
+
## Constructors
|
17
|
+
|
18
|
+
### Constructor
|
19
|
+
|
20
|
+
> **new ActionCodesProtocol**(`config?`): `ActionCodesProtocol`
|
21
|
+
|
22
|
+
Defined in: [protocol.ts:35](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/protocol.ts#L35)
|
23
|
+
|
24
|
+
#### Parameters
|
25
|
+
|
26
|
+
##### config?
|
27
|
+
|
28
|
+
`Partial`\<[`ProtocolConfig`](../interfaces/ProtocolConfig.md)\>
|
29
|
+
|
30
|
+
#### Returns
|
31
|
+
|
32
|
+
`ActionCodesProtocol`
|
33
|
+
|
34
|
+
## Methods
|
35
|
+
|
36
|
+
### attachTransaction()
|
37
|
+
|
38
|
+
> **attachTransaction**(`actionCode`, `transaction`, `txType?`): [`ActionCode`](../../actioncode/classes/ActionCode.md)\<`string`\>
|
39
|
+
|
40
|
+
Defined in: [protocol.ts:155](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/protocol.ts#L155)
|
41
|
+
|
42
|
+
Attach a transaction to an action code
|
43
|
+
|
44
|
+
#### Parameters
|
45
|
+
|
46
|
+
##### actionCode
|
47
|
+
|
48
|
+
[`ActionCode`](../../actioncode/classes/ActionCode.md)\<`string`\>
|
49
|
+
|
50
|
+
ActionCode to attach transaction to
|
51
|
+
|
52
|
+
##### transaction
|
53
|
+
|
54
|
+
`string`
|
55
|
+
|
56
|
+
Chain-specific transaction data
|
57
|
+
|
58
|
+
##### txType?
|
59
|
+
|
60
|
+
`string`
|
61
|
+
|
62
|
+
Optional transaction type
|
63
|
+
|
64
|
+
#### Returns
|
65
|
+
|
66
|
+
[`ActionCode`](../../actioncode/classes/ActionCode.md)\<`string`\>
|
67
|
+
|
68
|
+
Updated ActionCode
|
69
|
+
|
70
|
+
***
|
71
|
+
|
72
|
+
### createProtocolMeta()
|
73
|
+
|
74
|
+
> **createProtocolMeta**(`actionCode`, `issuer?`, `params?`): [`ProtocolMetaV1`](../../meta/interfaces/ProtocolMetaV1.md)
|
75
|
+
|
76
|
+
Defined in: [protocol.ts:220](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/protocol.ts#L220)
|
77
|
+
|
78
|
+
Create protocol meta for a transaction
|
79
|
+
|
80
|
+
#### Parameters
|
81
|
+
|
82
|
+
##### actionCode
|
83
|
+
|
84
|
+
[`ActionCode`](../../actioncode/classes/ActionCode.md)\<`string`\>
|
85
|
+
|
86
|
+
ActionCode to create meta for
|
87
|
+
|
88
|
+
##### issuer?
|
89
|
+
|
90
|
+
`string`
|
91
|
+
|
92
|
+
Optional issuer public key
|
93
|
+
|
94
|
+
##### params?
|
95
|
+
|
96
|
+
`string`
|
97
|
+
|
98
|
+
Optional parameters
|
99
|
+
|
100
|
+
#### Returns
|
101
|
+
|
102
|
+
[`ProtocolMetaV1`](../../meta/interfaces/ProtocolMetaV1.md)
|
103
|
+
|
104
|
+
ProtocolMetaV1 object
|
105
|
+
|
106
|
+
***
|
107
|
+
|
108
|
+
### decodeProtocolMeta()
|
109
|
+
|
110
|
+
> **decodeProtocolMeta**(`transaction`, `chain`): `null` \| [`ProtocolMetaV1`](../../meta/interfaces/ProtocolMetaV1.md)
|
111
|
+
|
112
|
+
Defined in: [protocol.ts:254](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/protocol.ts#L254)
|
113
|
+
|
114
|
+
Decode protocol meta from a transaction
|
115
|
+
|
116
|
+
#### Parameters
|
117
|
+
|
118
|
+
##### transaction
|
119
|
+
|
120
|
+
`any`
|
121
|
+
|
122
|
+
Chain-specific transaction
|
123
|
+
|
124
|
+
##### chain
|
125
|
+
|
126
|
+
`string`
|
127
|
+
|
128
|
+
Source chain
|
129
|
+
|
130
|
+
#### Returns
|
131
|
+
|
132
|
+
`null` \| [`ProtocolMetaV1`](../../meta/interfaces/ProtocolMetaV1.md)
|
133
|
+
|
134
|
+
Decoded ProtocolMetaV1 or null
|
135
|
+
|
136
|
+
***
|
137
|
+
|
138
|
+
### decodeProtocolMetaTyped()
|
139
|
+
|
140
|
+
> **decodeProtocolMetaTyped**\<`T`\>(`transaction`, `chain`): `null` \| [`ProtocolMetaV1`](../../meta/interfaces/ProtocolMetaV1.md)
|
141
|
+
|
142
|
+
Defined in: [protocol.ts:335](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/protocol.ts#L335)
|
143
|
+
|
144
|
+
Decode protocol meta with type safety
|
145
|
+
|
146
|
+
#### Type Parameters
|
147
|
+
|
148
|
+
##### T
|
149
|
+
|
150
|
+
`T`
|
151
|
+
|
152
|
+
#### Parameters
|
153
|
+
|
154
|
+
##### transaction
|
155
|
+
|
156
|
+
`T`
|
157
|
+
|
158
|
+
Chain-specific transaction
|
159
|
+
|
160
|
+
##### chain
|
161
|
+
|
162
|
+
`string`
|
163
|
+
|
164
|
+
Source chain
|
165
|
+
|
166
|
+
#### Returns
|
167
|
+
|
168
|
+
`null` \| [`ProtocolMetaV1`](../../meta/interfaces/ProtocolMetaV1.md)
|
169
|
+
|
170
|
+
Decoded ProtocolMetaV1 or null
|
171
|
+
|
172
|
+
***
|
173
|
+
|
174
|
+
### detectTampering()
|
175
|
+
|
176
|
+
> **detectTampering**\<`T`\>(`transaction`, `chain`, `authorities`, `expectedPrefix?`): `boolean`
|
177
|
+
|
178
|
+
Defined in: [protocol.ts:315](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/protocol.ts#L315)
|
179
|
+
|
180
|
+
Detect tampered transactions with type safety
|
181
|
+
|
182
|
+
#### Type Parameters
|
183
|
+
|
184
|
+
##### T
|
185
|
+
|
186
|
+
`T`
|
187
|
+
|
188
|
+
#### Parameters
|
189
|
+
|
190
|
+
##### transaction
|
191
|
+
|
192
|
+
`T`
|
193
|
+
|
194
|
+
Chain-specific transaction
|
195
|
+
|
196
|
+
##### chain
|
197
|
+
|
198
|
+
`string`
|
199
|
+
|
200
|
+
Source chain
|
201
|
+
|
202
|
+
##### authorities
|
203
|
+
|
204
|
+
`string`[]
|
205
|
+
|
206
|
+
Array of valid protocol authority identifiers
|
207
|
+
|
208
|
+
##### expectedPrefix?
|
209
|
+
|
210
|
+
`string`
|
211
|
+
|
212
|
+
Expected protocol prefix
|
213
|
+
|
214
|
+
#### Returns
|
215
|
+
|
216
|
+
`boolean`
|
217
|
+
|
218
|
+
True if transaction is valid and not tampered
|
219
|
+
|
220
|
+
***
|
221
|
+
|
222
|
+
### encodeProtocolMeta()
|
223
|
+
|
224
|
+
> **encodeProtocolMeta**(`meta`, `chain`): `any`
|
225
|
+
|
226
|
+
Defined in: [protocol.ts:239](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/protocol.ts#L239)
|
227
|
+
|
228
|
+
Encode protocol meta for a specific chain
|
229
|
+
|
230
|
+
#### Parameters
|
231
|
+
|
232
|
+
##### meta
|
233
|
+
|
234
|
+
[`ProtocolMetaV1`](../../meta/interfaces/ProtocolMetaV1.md)
|
235
|
+
|
236
|
+
ProtocolMetaV1 object
|
237
|
+
|
238
|
+
##### chain
|
239
|
+
|
240
|
+
`string`
|
241
|
+
|
242
|
+
Target chain
|
243
|
+
|
244
|
+
#### Returns
|
245
|
+
|
246
|
+
`any`
|
247
|
+
|
248
|
+
Chain-specific encoded meta
|
249
|
+
|
250
|
+
***
|
251
|
+
|
252
|
+
### finalizeActionCode()
|
253
|
+
|
254
|
+
> **finalizeActionCode**(`actionCode`, `txSignature`): [`ActionCode`](../../actioncode/classes/ActionCode.md)\<`string`\>
|
255
|
+
|
256
|
+
Defined in: [protocol.ts:188](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/protocol.ts#L188)
|
257
|
+
|
258
|
+
Finalize an action code with transaction signature
|
259
|
+
|
260
|
+
#### Parameters
|
261
|
+
|
262
|
+
##### actionCode
|
263
|
+
|
264
|
+
[`ActionCode`](../../actioncode/classes/ActionCode.md)\<`string`\>
|
265
|
+
|
266
|
+
ActionCode to finalize
|
267
|
+
|
268
|
+
##### txSignature
|
269
|
+
|
270
|
+
`string`
|
271
|
+
|
272
|
+
Transaction signature
|
273
|
+
|
274
|
+
#### Returns
|
275
|
+
|
276
|
+
[`ActionCode`](../../actioncode/classes/ActionCode.md)\<`string`\>
|
277
|
+
|
278
|
+
Updated ActionCode
|
279
|
+
|
280
|
+
***
|
281
|
+
|
282
|
+
### generateActionCode()
|
283
|
+
|
284
|
+
> **generateActionCode**(`pubkey`, `signature`, `chain`, `prefix?`, `timestamp?`): [`ActionCode`](../../actioncode/classes/ActionCode.md)\<`string`\>
|
285
|
+
|
286
|
+
Defined in: [protocol.ts:90](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/protocol.ts#L90)
|
287
|
+
|
288
|
+
Generate an action code for a specific chain
|
289
|
+
|
290
|
+
#### Parameters
|
291
|
+
|
292
|
+
##### pubkey
|
293
|
+
|
294
|
+
`string`
|
295
|
+
|
296
|
+
User's public key
|
297
|
+
|
298
|
+
##### signature
|
299
|
+
|
300
|
+
`string`
|
301
|
+
|
302
|
+
User's signature
|
303
|
+
|
304
|
+
##### chain
|
305
|
+
|
306
|
+
`"solana"`
|
307
|
+
|
308
|
+
Target chain
|
309
|
+
|
310
|
+
##### prefix?
|
311
|
+
|
312
|
+
`string`
|
313
|
+
|
314
|
+
Optional prefix (defaults to config defaultPrefix)
|
315
|
+
|
316
|
+
##### timestamp?
|
317
|
+
|
318
|
+
`number`
|
319
|
+
|
320
|
+
Optional timestamp (defaults to now)
|
321
|
+
|
322
|
+
#### Returns
|
323
|
+
|
324
|
+
[`ActionCode`](../../actioncode/classes/ActionCode.md)\<`string`\>
|
325
|
+
|
326
|
+
ActionCode object
|
327
|
+
|
328
|
+
***
|
329
|
+
|
330
|
+
### getChainAdapter()
|
331
|
+
|
332
|
+
> **getChainAdapter**\<`T`\>(`chain`): `undefined` \| [`BaseChainAdapter`](../../adapters/base/classes/BaseChainAdapter.md)\<`T`\>
|
333
|
+
|
334
|
+
Defined in: [protocol.ts:77](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/protocol.ts#L77)
|
335
|
+
|
336
|
+
Get chain adapter with proper typing
|
337
|
+
|
338
|
+
#### Type Parameters
|
339
|
+
|
340
|
+
##### T
|
341
|
+
|
342
|
+
`T` = `any`
|
343
|
+
|
344
|
+
#### Parameters
|
345
|
+
|
346
|
+
##### chain
|
347
|
+
|
348
|
+
`string`
|
349
|
+
|
350
|
+
Chain identifier
|
351
|
+
|
352
|
+
#### Returns
|
353
|
+
|
354
|
+
`undefined` \| [`BaseChainAdapter`](../../adapters/base/classes/BaseChainAdapter.md)\<`T`\>
|
355
|
+
|
356
|
+
Chain adapter or undefined
|
357
|
+
|
358
|
+
***
|
359
|
+
|
360
|
+
### getConfig()
|
361
|
+
|
362
|
+
> **getConfig**(): [`ProtocolConfig`](../interfaces/ProtocolConfig.md)
|
363
|
+
|
364
|
+
Defined in: [protocol.ts:348](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/protocol.ts#L348)
|
365
|
+
|
366
|
+
Get protocol configuration
|
367
|
+
|
368
|
+
#### Returns
|
369
|
+
|
370
|
+
[`ProtocolConfig`](../interfaces/ProtocolConfig.md)
|
371
|
+
|
372
|
+
Current protocol configuration
|
373
|
+
|
374
|
+
***
|
375
|
+
|
376
|
+
### getRegisteredChains()
|
377
|
+
|
378
|
+
> **getRegisteredChains**(): `string`[]
|
379
|
+
|
380
|
+
Defined in: [protocol.ts:59](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/protocol.ts#L59)
|
381
|
+
|
382
|
+
Get registered chain adapters
|
383
|
+
|
384
|
+
#### Returns
|
385
|
+
|
386
|
+
`string`[]
|
387
|
+
|
388
|
+
Array of registered chain identifiers
|
389
|
+
|
390
|
+
***
|
391
|
+
|
392
|
+
### isChainSupported()
|
393
|
+
|
394
|
+
> **isChainSupported**(`chain`): `boolean`
|
395
|
+
|
396
|
+
Defined in: [protocol.ts:68](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/protocol.ts#L68)
|
397
|
+
|
398
|
+
Check if a chain is supported
|
399
|
+
|
400
|
+
#### Parameters
|
401
|
+
|
402
|
+
##### chain
|
403
|
+
|
404
|
+
`string`
|
405
|
+
|
406
|
+
Chain identifier
|
407
|
+
|
408
|
+
#### Returns
|
409
|
+
|
410
|
+
`boolean`
|
411
|
+
|
412
|
+
True if chain is supported
|
413
|
+
|
414
|
+
***
|
415
|
+
|
416
|
+
### registerAdapter()
|
417
|
+
|
418
|
+
> **registerAdapter**\<`T`\>(`adapter`): `void`
|
419
|
+
|
420
|
+
Defined in: [protocol.ts:51](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/protocol.ts#L51)
|
421
|
+
|
422
|
+
Register a chain adapter
|
423
|
+
|
424
|
+
#### Type Parameters
|
425
|
+
|
426
|
+
##### T
|
427
|
+
|
428
|
+
`T`
|
429
|
+
|
430
|
+
#### Parameters
|
431
|
+
|
432
|
+
##### adapter
|
433
|
+
|
434
|
+
[`BaseChainAdapter`](../../adapters/base/classes/BaseChainAdapter.md)\<`T`\>
|
435
|
+
|
436
|
+
Chain adapter implementation
|
437
|
+
|
438
|
+
#### Returns
|
439
|
+
|
440
|
+
`void`
|
441
|
+
|
442
|
+
***
|
443
|
+
|
444
|
+
### updateConfig()
|
445
|
+
|
446
|
+
> **updateConfig**(`updates`): `void`
|
447
|
+
|
448
|
+
Defined in: [protocol.ts:356](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/protocol.ts#L356)
|
449
|
+
|
450
|
+
Update protocol configuration
|
451
|
+
|
452
|
+
#### Parameters
|
453
|
+
|
454
|
+
##### updates
|
455
|
+
|
456
|
+
`Partial`\<[`ProtocolConfig`](../interfaces/ProtocolConfig.md)\>
|
457
|
+
|
458
|
+
Configuration updates
|
459
|
+
|
460
|
+
#### Returns
|
461
|
+
|
462
|
+
`void`
|
463
|
+
|
464
|
+
***
|
465
|
+
|
466
|
+
### validateActionCode()
|
467
|
+
|
468
|
+
> **validateActionCode**(`actionCode`): `boolean`
|
469
|
+
|
470
|
+
Defined in: [protocol.ts:132](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/protocol.ts#L132)
|
471
|
+
|
472
|
+
Validate an action code
|
473
|
+
|
474
|
+
#### Parameters
|
475
|
+
|
476
|
+
##### actionCode
|
477
|
+
|
478
|
+
[`ActionCode`](../../actioncode/classes/ActionCode.md)\<`string`\>
|
479
|
+
|
480
|
+
ActionCode to validate
|
481
|
+
|
482
|
+
#### Returns
|
483
|
+
|
484
|
+
`boolean`
|
485
|
+
|
486
|
+
True if valid
|
487
|
+
|
488
|
+
***
|
489
|
+
|
490
|
+
### validateTransaction()
|
491
|
+
|
492
|
+
> **validateTransaction**(`transaction`, `chain`, `authorities`, `expectedPrefix?`): `boolean`
|
493
|
+
|
494
|
+
Defined in: [protocol.ts:271](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/protocol.ts#L271)
|
495
|
+
|
496
|
+
Validate a transaction with protocol meta
|
497
|
+
|
498
|
+
#### Parameters
|
499
|
+
|
500
|
+
##### transaction
|
501
|
+
|
502
|
+
`any`
|
503
|
+
|
504
|
+
Chain-specific transaction
|
505
|
+
|
506
|
+
##### chain
|
507
|
+
|
508
|
+
`string`
|
509
|
+
|
510
|
+
Source chain
|
511
|
+
|
512
|
+
##### authorities
|
513
|
+
|
514
|
+
`string`[]
|
515
|
+
|
516
|
+
Array of valid protocol authority identifiers
|
517
|
+
|
518
|
+
##### expectedPrefix?
|
519
|
+
|
520
|
+
`string`
|
521
|
+
|
522
|
+
Expected protocol prefix
|
523
|
+
|
524
|
+
#### Returns
|
525
|
+
|
526
|
+
`boolean`
|
527
|
+
|
528
|
+
True if transaction is valid
|
529
|
+
|
530
|
+
***
|
531
|
+
|
532
|
+
### validateTransactionTyped()
|
533
|
+
|
534
|
+
> **validateTransactionTyped**\<`T`\>(`transaction`, `chain`, `authorities`, `expectedPrefix?`): `boolean`
|
535
|
+
|
536
|
+
Defined in: [protocol.ts:293](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/protocol.ts#L293)
|
537
|
+
|
538
|
+
Type-safe transaction validation for specific chains
|
539
|
+
|
540
|
+
#### Type Parameters
|
541
|
+
|
542
|
+
##### T
|
543
|
+
|
544
|
+
`T`
|
545
|
+
|
546
|
+
#### Parameters
|
547
|
+
|
548
|
+
##### transaction
|
549
|
+
|
550
|
+
`T`
|
551
|
+
|
552
|
+
Chain-specific transaction
|
553
|
+
|
554
|
+
##### chain
|
555
|
+
|
556
|
+
`string`
|
557
|
+
|
558
|
+
Source chain
|
559
|
+
|
560
|
+
##### authorities
|
561
|
+
|
562
|
+
`string`[]
|
563
|
+
|
564
|
+
Array of valid protocol authority identifiers
|
565
|
+
|
566
|
+
##### expectedPrefix?
|
567
|
+
|
568
|
+
`string`
|
569
|
+
|
570
|
+
Expected protocol prefix
|
571
|
+
|
572
|
+
#### Returns
|
573
|
+
|
574
|
+
`boolean`
|
575
|
+
|
576
|
+
True if transaction is valid
|
577
|
+
|
578
|
+
***
|
579
|
+
|
580
|
+
### create()
|
581
|
+
|
582
|
+
> `static` **create**(): `ActionCodesProtocol`
|
583
|
+
|
584
|
+
Defined in: [protocol.ts:364](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/protocol.ts#L364)
|
585
|
+
|
586
|
+
Create a new protocol instance with default configuration
|
587
|
+
|
588
|
+
#### Returns
|
589
|
+
|
590
|
+
`ActionCodesProtocol`
|
591
|
+
|
592
|
+
New protocol instance
|
593
|
+
|
594
|
+
***
|
595
|
+
|
596
|
+
### createWithConfig()
|
597
|
+
|
598
|
+
> `static` **createWithConfig**(`config`): `ActionCodesProtocol`
|
599
|
+
|
600
|
+
Defined in: [protocol.ts:373](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/protocol.ts#L373)
|
601
|
+
|
602
|
+
Create a new protocol instance with custom configuration
|
603
|
+
|
604
|
+
#### Parameters
|
605
|
+
|
606
|
+
##### config
|
607
|
+
|
608
|
+
`Partial`\<[`ProtocolConfig`](../interfaces/ProtocolConfig.md)\>
|
609
|
+
|
610
|
+
Custom configuration
|
611
|
+
|
612
|
+
#### Returns
|
613
|
+
|
614
|
+
`ActionCodesProtocol`
|
615
|
+
|
616
|
+
New protocol instance
|
@@ -0,0 +1,71 @@
|
|
1
|
+
[**@actioncodes/protocol**](../../README.md)
|
2
|
+
|
3
|
+
***
|
4
|
+
|
5
|
+
[@actioncodes/protocol](../../modules.md) / [protocol](../README.md) / ProtocolConfig
|
6
|
+
|
7
|
+
# Interface: ProtocolConfig
|
8
|
+
|
9
|
+
Defined in: [protocol.ts:10](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/protocol.ts#L10)
|
10
|
+
|
11
|
+
OTA Protocol Configuration
|
12
|
+
|
13
|
+
## Properties
|
14
|
+
|
15
|
+
### codeLength
|
16
|
+
|
17
|
+
> **codeLength**: `number`
|
18
|
+
|
19
|
+
Defined in: [protocol.ts:18](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/protocol.ts#L18)
|
20
|
+
|
21
|
+
Code length in digits
|
22
|
+
|
23
|
+
***
|
24
|
+
|
25
|
+
### codeTTL
|
26
|
+
|
27
|
+
> **codeTTL**: `number`
|
28
|
+
|
29
|
+
Defined in: [protocol.ts:16](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/protocol.ts#L16)
|
30
|
+
|
31
|
+
Code TTL in milliseconds
|
32
|
+
|
33
|
+
***
|
34
|
+
|
35
|
+
### defaultPrefix
|
36
|
+
|
37
|
+
> **defaultPrefix**: `string`
|
38
|
+
|
39
|
+
Defined in: [protocol.ts:14](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/protocol.ts#L14)
|
40
|
+
|
41
|
+
Default prefix for action codes
|
42
|
+
|
43
|
+
***
|
44
|
+
|
45
|
+
### maxPrefixLength
|
46
|
+
|
47
|
+
> **maxPrefixLength**: `number`
|
48
|
+
|
49
|
+
Defined in: [protocol.ts:20](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/protocol.ts#L20)
|
50
|
+
|
51
|
+
Maximum prefix length
|
52
|
+
|
53
|
+
***
|
54
|
+
|
55
|
+
### minPrefixLength
|
56
|
+
|
57
|
+
> **minPrefixLength**: `number`
|
58
|
+
|
59
|
+
Defined in: [protocol.ts:22](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/protocol.ts#L22)
|
60
|
+
|
61
|
+
Minimum prefix length
|
62
|
+
|
63
|
+
***
|
64
|
+
|
65
|
+
### version
|
66
|
+
|
67
|
+
> **version**: `string`
|
68
|
+
|
69
|
+
Defined in: [protocol.ts:12](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/protocol.ts#L12)
|
70
|
+
|
71
|
+
Protocol version
|