@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,95 @@
|
|
1
|
+
[**@actioncodes/protocol**](../../README.md)
|
2
|
+
|
3
|
+
***
|
4
|
+
|
5
|
+
[@actioncodes/protocol](../../modules.md) / [actioncode](../README.md) / ActionCodeFields
|
6
|
+
|
7
|
+
# Interface: ActionCodeFields\<T\>
|
8
|
+
|
9
|
+
Defined in: [actioncode.ts:17](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/actioncode.ts#L17)
|
10
|
+
|
11
|
+
## Type Parameters
|
12
|
+
|
13
|
+
### T
|
14
|
+
|
15
|
+
`T`
|
16
|
+
|
17
|
+
## Properties
|
18
|
+
|
19
|
+
### chain
|
20
|
+
|
21
|
+
> **chain**: `"solana"`
|
22
|
+
|
23
|
+
Defined in: [actioncode.ts:23](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/actioncode.ts#L23)
|
24
|
+
|
25
|
+
***
|
26
|
+
|
27
|
+
### code
|
28
|
+
|
29
|
+
> **code**: `string`
|
30
|
+
|
31
|
+
Defined in: [actioncode.ts:18](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/actioncode.ts#L18)
|
32
|
+
|
33
|
+
***
|
34
|
+
|
35
|
+
### expiresAt
|
36
|
+
|
37
|
+
> **expiresAt**: `number`
|
38
|
+
|
39
|
+
Defined in: [actioncode.ts:26](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/actioncode.ts#L26)
|
40
|
+
|
41
|
+
***
|
42
|
+
|
43
|
+
### metadata?
|
44
|
+
|
45
|
+
> `optional` **metadata**: [`ActionCodeMetadata`](ActionCodeMetadata.md)
|
46
|
+
|
47
|
+
Defined in: [actioncode.ts:25](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/actioncode.ts#L25)
|
48
|
+
|
49
|
+
***
|
50
|
+
|
51
|
+
### prefix
|
52
|
+
|
53
|
+
> **prefix**: `string`
|
54
|
+
|
55
|
+
Defined in: [actioncode.ts:19](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/actioncode.ts#L19)
|
56
|
+
|
57
|
+
***
|
58
|
+
|
59
|
+
### pubkey
|
60
|
+
|
61
|
+
> **pubkey**: `string`
|
62
|
+
|
63
|
+
Defined in: [actioncode.ts:20](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/actioncode.ts#L20)
|
64
|
+
|
65
|
+
***
|
66
|
+
|
67
|
+
### signature
|
68
|
+
|
69
|
+
> **signature**: `string`
|
70
|
+
|
71
|
+
Defined in: [actioncode.ts:22](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/actioncode.ts#L22)
|
72
|
+
|
73
|
+
***
|
74
|
+
|
75
|
+
### status
|
76
|
+
|
77
|
+
> **status**: [`ActionCodeStatus`](../type-aliases/ActionCodeStatus.md)
|
78
|
+
|
79
|
+
Defined in: [actioncode.ts:27](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/actioncode.ts#L27)
|
80
|
+
|
81
|
+
***
|
82
|
+
|
83
|
+
### timestamp
|
84
|
+
|
85
|
+
> **timestamp**: `number`
|
86
|
+
|
87
|
+
Defined in: [actioncode.ts:21](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/actioncode.ts#L21)
|
88
|
+
|
89
|
+
***
|
90
|
+
|
91
|
+
### transaction?
|
92
|
+
|
93
|
+
> `optional` **transaction**: [`ActionCodeTransaction`](ActionCodeTransaction.md)\<`T`\>
|
94
|
+
|
95
|
+
Defined in: [actioncode.ts:24](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/actioncode.ts#L24)
|
@@ -0,0 +1,25 @@
|
|
1
|
+
[**@actioncodes/protocol**](../../README.md)
|
2
|
+
|
3
|
+
***
|
4
|
+
|
5
|
+
[@actioncodes/protocol](../../modules.md) / [actioncode](../README.md) / ActionCodeMetadata
|
6
|
+
|
7
|
+
# Interface: ActionCodeMetadata
|
8
|
+
|
9
|
+
Defined in: [actioncode.ts:6](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/actioncode.ts#L6)
|
10
|
+
|
11
|
+
## Properties
|
12
|
+
|
13
|
+
### description?
|
14
|
+
|
15
|
+
> `optional` **description**: `string`
|
16
|
+
|
17
|
+
Defined in: [actioncode.ts:7](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/actioncode.ts#L7)
|
18
|
+
|
19
|
+
***
|
20
|
+
|
21
|
+
### params?
|
22
|
+
|
23
|
+
> `optional` **params**: `Record`\<`string`, `any`\>
|
24
|
+
|
25
|
+
Defined in: [actioncode.ts:8](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/actioncode.ts#L8)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
[**@actioncodes/protocol**](../../README.md)
|
2
|
+
|
3
|
+
***
|
4
|
+
|
5
|
+
[@actioncodes/protocol](../../modules.md) / [actioncode](../README.md) / ActionCodeTransaction
|
6
|
+
|
7
|
+
# Interface: ActionCodeTransaction\<T\>
|
8
|
+
|
9
|
+
Defined in: [actioncode.ts:11](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/actioncode.ts#L11)
|
10
|
+
|
11
|
+
## Type Parameters
|
12
|
+
|
13
|
+
### T
|
14
|
+
|
15
|
+
`T`
|
16
|
+
|
17
|
+
## Properties
|
18
|
+
|
19
|
+
### transaction?
|
20
|
+
|
21
|
+
> `optional` **transaction**: `T`
|
22
|
+
|
23
|
+
Defined in: [actioncode.ts:12](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/actioncode.ts#L12)
|
24
|
+
|
25
|
+
***
|
26
|
+
|
27
|
+
### txSignature?
|
28
|
+
|
29
|
+
> `optional` **txSignature**: `string`
|
30
|
+
|
31
|
+
Defined in: [actioncode.ts:13](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/actioncode.ts#L13)
|
32
|
+
|
33
|
+
***
|
34
|
+
|
35
|
+
### txType?
|
36
|
+
|
37
|
+
> `optional` **txType**: `string`
|
38
|
+
|
39
|
+
Defined in: [actioncode.ts:14](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/actioncode.ts#L14)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
[**@actioncodes/protocol**](../../README.md)
|
2
|
+
|
3
|
+
***
|
4
|
+
|
5
|
+
[@actioncodes/protocol](../../modules.md) / [actioncode](../README.md) / ActionCodeStatus
|
6
|
+
|
7
|
+
# Type Alias: ActionCodeStatus
|
8
|
+
|
9
|
+
> **ActionCodeStatus** = `"pending"` \| `"resolved"` \| `"finalized"` \| `"expired"` \| `"error"`
|
10
|
+
|
11
|
+
Defined in: [actioncode.ts:4](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/actioncode.ts#L4)
|
@@ -0,0 +1,222 @@
|
|
1
|
+
[**@actioncodes/protocol**](../../../README.md)
|
2
|
+
|
3
|
+
***
|
4
|
+
|
5
|
+
[@actioncodes/protocol](../../../modules.md) / [adapters/base](../README.md) / BaseChainAdapter
|
6
|
+
|
7
|
+
# Class: `abstract` BaseChainAdapter\<T\>
|
8
|
+
|
9
|
+
Defined in: [adapters/base.ts:7](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/adapters/base.ts#L7)
|
10
|
+
|
11
|
+
Base adapter class for chain-specific protocol meta operations
|
12
|
+
|
13
|
+
## Extended by
|
14
|
+
|
15
|
+
- [`SolanaAdapter`](../../solana/solana/classes/SolanaAdapter.md)
|
16
|
+
|
17
|
+
## Type Parameters
|
18
|
+
|
19
|
+
### T
|
20
|
+
|
21
|
+
`T` = `any`
|
22
|
+
|
23
|
+
Chain-specific transaction type
|
24
|
+
|
25
|
+
## Constructors
|
26
|
+
|
27
|
+
### Constructor
|
28
|
+
|
29
|
+
> **new BaseChainAdapter**\<`T`\>(): `BaseChainAdapter`\<`T`\>
|
30
|
+
|
31
|
+
#### Returns
|
32
|
+
|
33
|
+
`BaseChainAdapter`\<`T`\>
|
34
|
+
|
35
|
+
## Properties
|
36
|
+
|
37
|
+
### chain
|
38
|
+
|
39
|
+
> `abstract` `readonly` **chain**: `string`
|
40
|
+
|
41
|
+
Defined in: [adapters/base.ts:8](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/adapters/base.ts#L8)
|
42
|
+
|
43
|
+
## Methods
|
44
|
+
|
45
|
+
### decode()
|
46
|
+
|
47
|
+
> `abstract` **decode**(`tx`): `null` \| [`ProtocolMetaV1`](../../../meta/interfaces/ProtocolMetaV1.md)
|
48
|
+
|
49
|
+
Defined in: [adapters/base.ts:22](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/adapters/base.ts#L22)
|
50
|
+
|
51
|
+
Decode protocol meta from chain-specific transaction
|
52
|
+
|
53
|
+
#### Parameters
|
54
|
+
|
55
|
+
##### tx
|
56
|
+
|
57
|
+
`T`
|
58
|
+
|
59
|
+
Chain-specific transaction
|
60
|
+
|
61
|
+
#### Returns
|
62
|
+
|
63
|
+
`null` \| [`ProtocolMetaV1`](../../../meta/interfaces/ProtocolMetaV1.md)
|
64
|
+
|
65
|
+
Decoded ProtocolMetaV1 or null
|
66
|
+
|
67
|
+
***
|
68
|
+
|
69
|
+
### detectTampering()
|
70
|
+
|
71
|
+
> **detectTampering**(`tx`, `authorities`, `expectedPrefix`): `boolean`
|
72
|
+
|
73
|
+
Defined in: [adapters/base.ts:48](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/adapters/base.ts#L48)
|
74
|
+
|
75
|
+
Detect tampered transactions by cross-checking metadata
|
76
|
+
|
77
|
+
#### Parameters
|
78
|
+
|
79
|
+
##### tx
|
80
|
+
|
81
|
+
`T`
|
82
|
+
|
83
|
+
Chain-specific transaction
|
84
|
+
|
85
|
+
##### authorities
|
86
|
+
|
87
|
+
`string`[]
|
88
|
+
|
89
|
+
Array of valid protocol authority identifiers
|
90
|
+
|
91
|
+
##### expectedPrefix
|
92
|
+
|
93
|
+
`string` = `'DEFAULT'`
|
94
|
+
|
95
|
+
Expected protocol prefix
|
96
|
+
|
97
|
+
#### Returns
|
98
|
+
|
99
|
+
`boolean`
|
100
|
+
|
101
|
+
True if transaction is valid and not tampered
|
102
|
+
|
103
|
+
***
|
104
|
+
|
105
|
+
### encode()
|
106
|
+
|
107
|
+
> `abstract` **encode**(`meta`): `any`
|
108
|
+
|
109
|
+
Defined in: [adapters/base.ts:15](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/adapters/base.ts#L15)
|
110
|
+
|
111
|
+
Encode protocol meta for this chain
|
112
|
+
|
113
|
+
#### Parameters
|
114
|
+
|
115
|
+
##### meta
|
116
|
+
|
117
|
+
[`ProtocolMetaV1`](../../../meta/interfaces/ProtocolMetaV1.md)
|
118
|
+
|
119
|
+
ProtocolMetaV1 object
|
120
|
+
|
121
|
+
#### Returns
|
122
|
+
|
123
|
+
`any`
|
124
|
+
|
125
|
+
Chain-specific encoded data
|
126
|
+
|
127
|
+
***
|
128
|
+
|
129
|
+
### hasIssuerSignature()
|
130
|
+
|
131
|
+
> `abstract` **hasIssuerSignature**(`tx`, `issuer`): `boolean`
|
132
|
+
|
133
|
+
Defined in: [adapters/base.ts:39](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/adapters/base.ts#L39)
|
134
|
+
|
135
|
+
Check if the issuer has signed the transaction
|
136
|
+
|
137
|
+
#### Parameters
|
138
|
+
|
139
|
+
##### tx
|
140
|
+
|
141
|
+
`T`
|
142
|
+
|
143
|
+
Chain-specific transaction
|
144
|
+
|
145
|
+
##### issuer
|
146
|
+
|
147
|
+
`string`
|
148
|
+
|
149
|
+
Issuer public key to check
|
150
|
+
|
151
|
+
#### Returns
|
152
|
+
|
153
|
+
`boolean`
|
154
|
+
|
155
|
+
True if issuer has signed
|
156
|
+
|
157
|
+
***
|
158
|
+
|
159
|
+
### validate()
|
160
|
+
|
161
|
+
> `abstract` **validate**(`tx`, `authorities`, `expectedPrefix?`): `boolean`
|
162
|
+
|
163
|
+
Defined in: [adapters/base.ts:31](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/adapters/base.ts#L31)
|
164
|
+
|
165
|
+
Validate transaction with protocol meta and authority list
|
166
|
+
|
167
|
+
#### Parameters
|
168
|
+
|
169
|
+
##### tx
|
170
|
+
|
171
|
+
`T`
|
172
|
+
|
173
|
+
Chain-specific transaction
|
174
|
+
|
175
|
+
##### authorities
|
176
|
+
|
177
|
+
`string`[]
|
178
|
+
|
179
|
+
Array of valid protocol authority identifiers
|
180
|
+
|
181
|
+
##### expectedPrefix?
|
182
|
+
|
183
|
+
`string`
|
184
|
+
|
185
|
+
Expected protocol prefix (default: 'DEFAULT')
|
186
|
+
|
187
|
+
#### Returns
|
188
|
+
|
189
|
+
`boolean`
|
190
|
+
|
191
|
+
True if transaction is valid
|
192
|
+
|
193
|
+
***
|
194
|
+
|
195
|
+
### validateTransactionIntegrity()
|
196
|
+
|
197
|
+
> `abstract` `protected` **validateTransactionIntegrity**(`tx`, `meta`): `boolean`
|
198
|
+
|
199
|
+
Defined in: [adapters/base.ts:85](https://github.com/otaprotocol/actioncodes/blob/b4bc06f6d42b5f06660c6f068ac123b4cd9daff7/src/adapters/base.ts#L85)
|
200
|
+
|
201
|
+
Chain-specific transaction integrity validation
|
202
|
+
Override this method for additional validation logic
|
203
|
+
|
204
|
+
#### Parameters
|
205
|
+
|
206
|
+
##### tx
|
207
|
+
|
208
|
+
`T`
|
209
|
+
|
210
|
+
Chain-specific transaction
|
211
|
+
|
212
|
+
##### meta
|
213
|
+
|
214
|
+
[`ProtocolMetaV1`](../../../meta/interfaces/ProtocolMetaV1.md)
|
215
|
+
|
216
|
+
Decoded protocol meta
|
217
|
+
|
218
|
+
#### Returns
|
219
|
+
|
220
|
+
`boolean`
|
221
|
+
|
222
|
+
True if transaction integrity is valid
|
@@ -0,0 +1,19 @@
|
|
1
|
+
[**@actioncodes/protocol**](../../README.md)
|
2
|
+
|
3
|
+
***
|
4
|
+
|
5
|
+
[@actioncodes/protocol](../../modules.md) / adapters/solana
|
6
|
+
|
7
|
+
# adapters/solana
|
8
|
+
|
9
|
+
## References
|
10
|
+
|
11
|
+
### SolanaAdapter
|
12
|
+
|
13
|
+
Re-exports [SolanaAdapter](solana/classes/SolanaAdapter.md)
|
14
|
+
|
15
|
+
***
|
16
|
+
|
17
|
+
### SolanaTransaction
|
18
|
+
|
19
|
+
Re-exports [SolanaTransaction](solana/type-aliases/SolanaTransaction.md)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
[**@actioncodes/protocol**](../../../README.md)
|
2
|
+
|
3
|
+
***
|
4
|
+
|
5
|
+
[@actioncodes/protocol](../../../modules.md) / adapters/solana/solana
|
6
|
+
|
7
|
+
# adapters/solana/solana
|
8
|
+
|
9
|
+
## Classes
|
10
|
+
|
11
|
+
- [SolanaAdapter](classes/SolanaAdapter.md)
|
12
|
+
|
13
|
+
## Type Aliases
|
14
|
+
|
15
|
+
- [SolanaTransaction](type-aliases/SolanaTransaction.md)
|