@actioncodes/protocol 1.0.3 → 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.
- package/dist/adapters/base.d.ts +19 -2
- package/dist/adapters/base.d.ts.map +1 -1
- package/dist/adapters/base.js +1 -1
- package/dist/adapters/solana/solana.d.ts +16 -3
- package/dist/adapters/solana/solana.d.ts.map +1 -1
- package/dist/adapters/solana/solana.js +107 -14
- package/dist/protocol.js +3 -3
- package/docs/actioncode/classes/ActionCode.md +23 -23
- package/docs/actioncode/interfaces/ActionCodeFields.md +11 -11
- package/docs/actioncode/interfaces/ActionCodeMetadata.md +3 -3
- package/docs/actioncode/interfaces/ActionCodeTransaction.md +4 -4
- package/docs/actioncode/type-aliases/ActionCodeStatus.md +1 -1
- package/docs/adapters/base/classes/BaseChainAdapter.md +72 -14
- package/docs/adapters/solana/solana/classes/SolanaAdapter.md +97 -33
- package/docs/adapters/solana/solana/type-aliases/SolanaTransaction.md +1 -1
- package/docs/codegen/classes/CodeGenerator.md +14 -14
- package/docs/constants/type-aliases/SupportedChain.md +1 -1
- package/docs/constants/variables/CODE_LENGTH.md +1 -1
- package/docs/constants/variables/CODE_TTL.md +1 -1
- package/docs/constants/variables/MAX_PREFIX_LENGTH.md +1 -1
- package/docs/constants/variables/MIN_PREFIX_LENGTH.md +1 -1
- package/docs/constants/variables/PROTOCOL_CODE_PREFIX.md +1 -1
- package/docs/constants/variables/PROTOCOL_PREFIX.md +1 -1
- package/docs/constants/variables/PROTOCOL_VERSION.md +1 -1
- package/docs/constants/variables/SUPPORTED_CHAINS.md +1 -1
- package/docs/meta/classes/ProtocolMetaParser.md +6 -6
- package/docs/meta/interfaces/ProtocolMetaV1.md +7 -7
- package/docs/protocol/classes/ActionCodesProtocol.md +21 -21
- package/docs/protocol/interfaces/ProtocolConfig.md +7 -7
- package/package.json +1 -1
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
# Interface: ActionCodeTransaction
|
8
8
|
|
9
|
-
Defined in: [actioncode.ts:13](https://github.com/otaprotocol/actioncodes/blob/
|
9
|
+
Defined in: [actioncode.ts:13](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/actioncode.ts#L13)
|
10
10
|
|
11
11
|
## Properties
|
12
12
|
|
@@ -14,7 +14,7 @@ Defined in: [actioncode.ts:13](https://github.com/otaprotocol/actioncodes/blob/0
|
|
14
14
|
|
15
15
|
> `optional` **transaction**: `string`
|
16
16
|
|
17
|
-
Defined in: [actioncode.ts:14](https://github.com/otaprotocol/actioncodes/blob/
|
17
|
+
Defined in: [actioncode.ts:14](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/actioncode.ts#L14)
|
18
18
|
|
19
19
|
***
|
20
20
|
|
@@ -22,7 +22,7 @@ Defined in: [actioncode.ts:14](https://github.com/otaprotocol/actioncodes/blob/0
|
|
22
22
|
|
23
23
|
> `optional` **txSignature**: `string`
|
24
24
|
|
25
|
-
Defined in: [actioncode.ts:15](https://github.com/otaprotocol/actioncodes/blob/
|
25
|
+
Defined in: [actioncode.ts:15](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/actioncode.ts#L15)
|
26
26
|
|
27
27
|
***
|
28
28
|
|
@@ -30,4 +30,4 @@ Defined in: [actioncode.ts:15](https://github.com/otaprotocol/actioncodes/blob/0
|
|
30
30
|
|
31
31
|
> `optional` **txType**: `string`
|
32
32
|
|
33
|
-
Defined in: [actioncode.ts:16](https://github.com/otaprotocol/actioncodes/blob/
|
33
|
+
Defined in: [actioncode.ts:16](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/actioncode.ts#L16)
|
@@ -8,4 +8,4 @@
|
|
8
8
|
|
9
9
|
> **ActionCodeStatus** = `"pending"` \| `"resolved"` \| `"finalized"` \| `"expired"` \| `"error"`
|
10
10
|
|
11
|
-
Defined in: [actioncode.ts:6](https://github.com/otaprotocol/actioncodes/blob/
|
11
|
+
Defined in: [actioncode.ts:6](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/actioncode.ts#L6)
|
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
# Class: `abstract` BaseChainAdapter\<T\>
|
8
8
|
|
9
|
-
Defined in: [adapters/base.ts:9](https://github.com/otaprotocol/actioncodes/blob/
|
9
|
+
Defined in: [adapters/base.ts:9](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/adapters/base.ts#L9)
|
10
10
|
|
11
11
|
Base adapter class for chain-specific protocol meta operations
|
12
12
|
|
@@ -38,15 +38,15 @@ Chain-specific transaction type
|
|
38
38
|
|
39
39
|
> `abstract` `readonly` **chain**: `string`
|
40
40
|
|
41
|
-
Defined in: [adapters/base.ts:10](https://github.com/otaprotocol/actioncodes/blob/
|
41
|
+
Defined in: [adapters/base.ts:10](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/adapters/base.ts#L10)
|
42
42
|
|
43
43
|
## Methods
|
44
44
|
|
45
|
-
###
|
45
|
+
### decodeMeta()
|
46
46
|
|
47
|
-
> `abstract` **
|
47
|
+
> `abstract` **decodeMeta**(`tx`): `null` \| [`ProtocolMetaV1`](../../../meta/interfaces/ProtocolMetaV1.md)
|
48
48
|
|
49
|
-
Defined in: [adapters/base.ts:24](https://github.com/otaprotocol/actioncodes/blob/
|
49
|
+
Defined in: [adapters/base.ts:24](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/adapters/base.ts#L24)
|
50
50
|
|
51
51
|
Decode protocol meta from chain-specific transaction
|
52
52
|
|
@@ -70,7 +70,7 @@ Decoded ProtocolMetaV1 or null
|
|
70
70
|
|
71
71
|
> **detectTampering**(`tx`, `authorities`, `expectedPrefix`): `boolean`
|
72
72
|
|
73
|
-
Defined in: [adapters/base.ts:
|
73
|
+
Defined in: [adapters/base.ts:58](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/adapters/base.ts#L58)
|
74
74
|
|
75
75
|
Detect tampered transactions by cross-checking metadata
|
76
76
|
|
@@ -102,11 +102,11 @@ True if transaction is valid and not tampered
|
|
102
102
|
|
103
103
|
***
|
104
104
|
|
105
|
-
###
|
105
|
+
### encodeMeta()
|
106
106
|
|
107
|
-
> `abstract` **
|
107
|
+
> `abstract` **encodeMeta**(`meta`): `any`
|
108
108
|
|
109
|
-
Defined in: [adapters/base.ts:17](https://github.com/otaprotocol/actioncodes/blob/
|
109
|
+
Defined in: [adapters/base.ts:17](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/adapters/base.ts#L17)
|
110
110
|
|
111
111
|
Encode protocol meta for this chain
|
112
112
|
|
@@ -130,7 +130,7 @@ Chain-specific encoded data
|
|
130
130
|
|
131
131
|
> **getCodeSignatureMessage**(`code`, `timestamp`, `prefix`): `string`
|
132
132
|
|
133
|
-
Defined in: [adapters/base.ts:
|
133
|
+
Defined in: [adapters/base.ts:104](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/adapters/base.ts#L104)
|
134
134
|
|
135
135
|
Get the code signature message
|
136
136
|
|
@@ -166,7 +166,7 @@ The code signature message
|
|
166
166
|
|
167
167
|
> `abstract` **hasIssuerSignature**(`tx`, `issuer`): `boolean`
|
168
168
|
|
169
|
-
Defined in: [adapters/base.ts:
|
169
|
+
Defined in: [adapters/base.ts:49](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/adapters/base.ts#L49)
|
170
170
|
|
171
171
|
Check if the issuer has signed the transaction
|
172
172
|
|
@@ -192,11 +192,69 @@ True if issuer has signed
|
|
192
192
|
|
193
193
|
***
|
194
194
|
|
195
|
+
### injectMeta()
|
196
|
+
|
197
|
+
> `abstract` **injectMeta**(`tx`, `meta`): `T`
|
198
|
+
|
199
|
+
Defined in: [adapters/base.ts:32](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/adapters/base.ts#L32)
|
200
|
+
|
201
|
+
Inject protocol meta into chain-specific transaction
|
202
|
+
|
203
|
+
#### Parameters
|
204
|
+
|
205
|
+
##### tx
|
206
|
+
|
207
|
+
`T`
|
208
|
+
|
209
|
+
Chain-specific transaction
|
210
|
+
|
211
|
+
##### meta
|
212
|
+
|
213
|
+
[`ProtocolMetaV1`](../../../meta/interfaces/ProtocolMetaV1.md)
|
214
|
+
|
215
|
+
ProtocolMetaV1 object
|
216
|
+
|
217
|
+
#### Returns
|
218
|
+
|
219
|
+
`T`
|
220
|
+
|
221
|
+
Chain-specific transaction with injected meta
|
222
|
+
|
223
|
+
***
|
224
|
+
|
225
|
+
### signWithProtocolKey()
|
226
|
+
|
227
|
+
> `abstract` **signWithProtocolKey**(`actionCode`, `key`): `Promise`\<[`ActionCode`](../../../actioncode/classes/ActionCode.md)\>
|
228
|
+
|
229
|
+
Defined in: [adapters/base.ts:126](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/adapters/base.ts#L126)
|
230
|
+
|
231
|
+
Sign the transaction with the protocol key using a callback approach
|
232
|
+
This method should be implemented by each chain-specific adapter to handle
|
233
|
+
the chain's specific signing mechanism asynchronously
|
234
|
+
|
235
|
+
#### Parameters
|
236
|
+
|
237
|
+
##### actionCode
|
238
|
+
|
239
|
+
[`ActionCode`](../../../actioncode/classes/ActionCode.md)
|
240
|
+
|
241
|
+
##### key
|
242
|
+
|
243
|
+
`any`
|
244
|
+
|
245
|
+
#### Returns
|
246
|
+
|
247
|
+
`Promise`\<[`ActionCode`](../../../actioncode/classes/ActionCode.md)\>
|
248
|
+
|
249
|
+
Promise that resolves to the signed transaction
|
250
|
+
|
251
|
+
***
|
252
|
+
|
195
253
|
### validate()
|
196
254
|
|
197
255
|
> `abstract` **validate**(`tx`, `authorities`, `expectedPrefix?`): `boolean`
|
198
256
|
|
199
|
-
Defined in: [adapters/base.ts:
|
257
|
+
Defined in: [adapters/base.ts:41](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/adapters/base.ts#L41)
|
200
258
|
|
201
259
|
Validate transaction with protocol meta and authority list
|
202
260
|
|
@@ -232,7 +290,7 @@ True if transaction is valid
|
|
232
290
|
|
233
291
|
> `abstract` `protected` **validateTransactionIntegrity**(`tx`, `meta`): `boolean`
|
234
292
|
|
235
|
-
Defined in: [adapters/base.ts:
|
293
|
+
Defined in: [adapters/base.ts:95](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/adapters/base.ts#L95)
|
236
294
|
|
237
295
|
Chain-specific transaction integrity validation
|
238
296
|
Override this method for additional validation logic
|
@@ -263,7 +321,7 @@ True if transaction integrity is valid
|
|
263
321
|
|
264
322
|
> `abstract` **verifyCodeSignature**(`actionCode`): `boolean`
|
265
323
|
|
266
|
-
Defined in: [adapters/base.ts:
|
324
|
+
Defined in: [adapters/base.ts:115](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/adapters/base.ts#L115)
|
267
325
|
|
268
326
|
Verify the code signature
|
269
327
|
This is specific to the chain and should be implemented by the concrete adapter
|
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
# Class: SolanaAdapter
|
8
8
|
|
9
|
-
Defined in: [adapters/solana/solana.ts:
|
9
|
+
Defined in: [adapters/solana/solana.ts:25](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/adapters/solana/solana.ts#L25)
|
10
10
|
|
11
11
|
Simple Solana adapter for protocol meta operations
|
12
12
|
Supports both legacy and versioned transactions
|
@@ -35,7 +35,7 @@ Supports both legacy and versioned transactions
|
|
35
35
|
|
36
36
|
> `readonly` **chain**: `"solana"` = `'solana'`
|
37
37
|
|
38
|
-
Defined in: [adapters/solana/solana.ts:
|
38
|
+
Defined in: [adapters/solana/solana.ts:28](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/adapters/solana/solana.ts#L28)
|
39
39
|
|
40
40
|
#### Overrides
|
41
41
|
|
@@ -43,55 +43,55 @@ Defined in: [adapters/solana/solana.ts:27](https://github.com/otaprotocol/action
|
|
43
43
|
|
44
44
|
## Methods
|
45
45
|
|
46
|
-
###
|
46
|
+
### decodeFromBase64()
|
47
47
|
|
48
|
-
> **
|
48
|
+
> **decodeFromBase64**(`base64String`): `null` \| [`ProtocolMetaV1`](../../../../meta/interfaces/ProtocolMetaV1.md)
|
49
49
|
|
50
|
-
Defined in: [adapters/solana/solana.ts:
|
50
|
+
Defined in: [adapters/solana/solana.ts:278](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/adapters/solana/solana.ts#L278)
|
51
51
|
|
52
|
-
Decode protocol meta from
|
52
|
+
Decode protocol meta from base64 string (for backward compatibility)
|
53
53
|
|
54
54
|
#### Parameters
|
55
55
|
|
56
|
-
#####
|
56
|
+
##### base64String
|
57
57
|
|
58
|
-
|
58
|
+
`string`
|
59
59
|
|
60
|
-
|
60
|
+
Base64 encoded transaction
|
61
61
|
|
62
62
|
#### Returns
|
63
63
|
|
64
64
|
`null` \| [`ProtocolMetaV1`](../../../../meta/interfaces/ProtocolMetaV1.md)
|
65
65
|
|
66
|
-
Decoded ProtocolMetaV1 or null
|
67
|
-
|
68
|
-
#### Overrides
|
69
|
-
|
70
|
-
[`BaseChainAdapter`](../../../base/classes/BaseChainAdapter.md).[`decode`](../../../base/classes/BaseChainAdapter.md#decode)
|
66
|
+
Decoded ProtocolMetaV1 or null
|
71
67
|
|
72
68
|
***
|
73
69
|
|
74
|
-
###
|
70
|
+
### decodeMeta()
|
75
71
|
|
76
|
-
> **
|
72
|
+
> **decodeMeta**(`tx`): `null` \| [`ProtocolMetaV1`](../../../../meta/interfaces/ProtocolMetaV1.md)
|
77
73
|
|
78
|
-
Defined in: [adapters/solana/solana.ts:
|
74
|
+
Defined in: [adapters/solana/solana.ts:56](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/adapters/solana/solana.ts#L56)
|
79
75
|
|
80
|
-
Decode protocol meta from
|
76
|
+
Decode protocol meta from Solana transaction (legacy or versioned)
|
81
77
|
|
82
78
|
#### Parameters
|
83
79
|
|
84
|
-
#####
|
80
|
+
##### tx
|
85
81
|
|
86
|
-
`
|
82
|
+
[`SolanaTransaction`](../type-aliases/SolanaTransaction.md)
|
87
83
|
|
88
|
-
|
84
|
+
The Solana transaction
|
89
85
|
|
90
86
|
#### Returns
|
91
87
|
|
92
88
|
`null` \| [`ProtocolMetaV1`](../../../../meta/interfaces/ProtocolMetaV1.md)
|
93
89
|
|
94
|
-
Decoded ProtocolMetaV1 or null
|
90
|
+
Decoded ProtocolMetaV1 or null if not found
|
91
|
+
|
92
|
+
#### Overrides
|
93
|
+
|
94
|
+
[`BaseChainAdapter`](../../../base/classes/BaseChainAdapter.md).[`decodeMeta`](../../../base/classes/BaseChainAdapter.md#decodemeta)
|
95
95
|
|
96
96
|
***
|
97
97
|
|
@@ -99,7 +99,7 @@ Decoded ProtocolMetaV1 or null
|
|
99
99
|
|
100
100
|
> **detectTampering**(`tx`, `authorities`, `expectedPrefix`): `boolean`
|
101
101
|
|
102
|
-
Defined in: [adapters/base.ts:
|
102
|
+
Defined in: [adapters/base.ts:58](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/adapters/base.ts#L58)
|
103
103
|
|
104
104
|
Detect tampered transactions by cross-checking metadata
|
105
105
|
|
@@ -135,11 +135,11 @@ True if transaction is valid and not tampered
|
|
135
135
|
|
136
136
|
***
|
137
137
|
|
138
|
-
###
|
138
|
+
### encodeMeta()
|
139
139
|
|
140
|
-
> **
|
140
|
+
> **encodeMeta**(`meta`): `TransactionInstruction`
|
141
141
|
|
142
|
-
Defined in: [adapters/solana/solana.ts:
|
142
|
+
Defined in: [adapters/solana/solana.ts:35](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/adapters/solana/solana.ts#L35)
|
143
143
|
|
144
144
|
Encode protocol meta as a Solana memo instruction
|
145
145
|
|
@@ -159,7 +159,7 @@ TransactionInstruction for the memo
|
|
159
159
|
|
160
160
|
#### Overrides
|
161
161
|
|
162
|
-
[`BaseChainAdapter`](../../../base/classes/BaseChainAdapter.md).[`
|
162
|
+
[`BaseChainAdapter`](../../../base/classes/BaseChainAdapter.md).[`encodeMeta`](../../../base/classes/BaseChainAdapter.md#encodemeta)
|
163
163
|
|
164
164
|
***
|
165
165
|
|
@@ -167,7 +167,7 @@ TransactionInstruction for the memo
|
|
167
167
|
|
168
168
|
> **getCodeSignatureMessage**(`code`, `timestamp`, `prefix`): `string`
|
169
169
|
|
170
|
-
Defined in: [adapters/base.ts:
|
170
|
+
Defined in: [adapters/base.ts:104](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/adapters/base.ts#L104)
|
171
171
|
|
172
172
|
Get the code signature message
|
173
173
|
|
@@ -207,7 +207,7 @@ The code signature message
|
|
207
207
|
|
208
208
|
> **hasIssuerSignature**(`tx`, `issuer`): `boolean`
|
209
209
|
|
210
|
-
Defined in: [adapters/solana/solana.ts:
|
210
|
+
Defined in: [adapters/solana/solana.ts:137](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/adapters/solana/solana.ts#L137)
|
211
211
|
|
212
212
|
Check if the issuer has signed the transaction
|
213
213
|
|
@@ -237,11 +237,75 @@ True if issuer has signed
|
|
237
237
|
|
238
238
|
***
|
239
239
|
|
240
|
+
### injectMeta()
|
241
|
+
|
242
|
+
> **injectMeta**(`tx`, `meta`): [`SolanaTransaction`](../type-aliases/SolanaTransaction.md)
|
243
|
+
|
244
|
+
Defined in: [adapters/solana/solana.ts:73](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/adapters/solana/solana.ts#L73)
|
245
|
+
|
246
|
+
Inject protocol meta into Solana transaction
|
247
|
+
|
248
|
+
#### Parameters
|
249
|
+
|
250
|
+
##### tx
|
251
|
+
|
252
|
+
[`SolanaTransaction`](../type-aliases/SolanaTransaction.md)
|
253
|
+
|
254
|
+
The Solana transaction
|
255
|
+
|
256
|
+
##### meta
|
257
|
+
|
258
|
+
[`ProtocolMetaV1`](../../../../meta/interfaces/ProtocolMetaV1.md)
|
259
|
+
|
260
|
+
ProtocolMetaV1 object
|
261
|
+
|
262
|
+
#### Returns
|
263
|
+
|
264
|
+
[`SolanaTransaction`](../type-aliases/SolanaTransaction.md)
|
265
|
+
|
266
|
+
Solana transaction with injected meta
|
267
|
+
|
268
|
+
#### Overrides
|
269
|
+
|
270
|
+
[`BaseChainAdapter`](../../../base/classes/BaseChainAdapter.md).[`injectMeta`](../../../base/classes/BaseChainAdapter.md#injectmeta)
|
271
|
+
|
272
|
+
***
|
273
|
+
|
274
|
+
### signWithProtocolKey()
|
275
|
+
|
276
|
+
> **signWithProtocolKey**(`actionCode`, `key`): `Promise`\<[`ActionCode`](../../../../actioncode/classes/ActionCode.md)\>
|
277
|
+
|
278
|
+
Defined in: [adapters/solana/solana.ts:336](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/adapters/solana/solana.ts#L336)
|
279
|
+
|
280
|
+
Sign the transaction with the protocol key using a callback approach
|
281
|
+
|
282
|
+
#### Parameters
|
283
|
+
|
284
|
+
##### actionCode
|
285
|
+
|
286
|
+
[`ActionCode`](../../../../actioncode/classes/ActionCode.md)
|
287
|
+
|
288
|
+
##### key
|
289
|
+
|
290
|
+
`Keypair`
|
291
|
+
|
292
|
+
#### Returns
|
293
|
+
|
294
|
+
`Promise`\<[`ActionCode`](../../../../actioncode/classes/ActionCode.md)\>
|
295
|
+
|
296
|
+
Promise that resolves to the signed transaction
|
297
|
+
|
298
|
+
#### Overrides
|
299
|
+
|
300
|
+
[`BaseChainAdapter`](../../../base/classes/BaseChainAdapter.md).[`signWithProtocolKey`](../../../base/classes/BaseChainAdapter.md#signwithprotocolkey)
|
301
|
+
|
302
|
+
***
|
303
|
+
|
240
304
|
### validate()
|
241
305
|
|
242
306
|
> **validate**(`tx`, `authorities`, `expectedPrefix`): `boolean`
|
243
307
|
|
244
|
-
Defined in: [adapters/solana/solana.ts:
|
308
|
+
Defined in: [adapters/solana/solana.ts:127](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/adapters/solana/solana.ts#L127)
|
245
309
|
|
246
310
|
Validate transaction with protocol meta and authority list
|
247
311
|
|
@@ -281,7 +345,7 @@ True if transaction is valid
|
|
281
345
|
|
282
346
|
> **validateFromBase64**(`base64String`, `authorities`, `expectedPrefix`): `boolean`
|
283
347
|
|
284
|
-
Defined in: [adapters/solana/solana.ts:
|
348
|
+
Defined in: [adapters/solana/solana.ts:301](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/adapters/solana/solana.ts#L301)
|
285
349
|
|
286
350
|
Validate base64 transaction (for backward compatibility)
|
287
351
|
|
@@ -317,7 +381,7 @@ True if transaction is valid
|
|
317
381
|
|
318
382
|
> `protected` **validateTransactionIntegrity**(`tx`, `meta`): `boolean`
|
319
383
|
|
320
|
-
Defined in: [adapters/solana/solana.ts:
|
384
|
+
Defined in: [adapters/solana/solana.ts:244](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/adapters/solana/solana.ts#L244)
|
321
385
|
|
322
386
|
Validate Solana transaction integrity with additional checks
|
323
387
|
|
@@ -351,7 +415,7 @@ True if transaction integrity is valid
|
|
351
415
|
|
352
416
|
> **verifyCodeSignature**(`actionCode`): `boolean`
|
353
417
|
|
354
|
-
Defined in: [adapters/solana/solana.ts:
|
418
|
+
Defined in: [adapters/solana/solana.ts:318](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/adapters/solana/solana.ts#L318)
|
355
419
|
|
356
420
|
Verify the code signature
|
357
421
|
This is specific to the chain and should be implemented by the concrete adapter
|
@@ -8,6 +8,6 @@
|
|
8
8
|
|
9
9
|
> **SolanaTransaction** = `Transaction` \| `VersionedTransaction`
|
10
10
|
|
11
|
-
Defined in: [adapters/solana/solana.ts:
|
11
|
+
Defined in: [adapters/solana/solana.ts:19](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/adapters/solana/solana.ts#L19)
|
12
12
|
|
13
13
|
Solana transaction type union
|
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
# Class: CodeGenerator
|
8
8
|
|
9
|
-
Defined in: [codegen.ts:4](https://github.com/otaprotocol/actioncodes/blob/
|
9
|
+
Defined in: [codegen.ts:4](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/codegen.ts#L4)
|
10
10
|
|
11
11
|
## Constructors
|
12
12
|
|
@@ -24,7 +24,7 @@ Defined in: [codegen.ts:4](https://github.com/otaprotocol/actioncodes/blob/007a9
|
|
24
24
|
|
25
25
|
> `static` **CODE\_DIGITS**: `number` = `CODE_LENGTH`
|
26
26
|
|
27
|
-
Defined in: [codegen.ts:6](https://github.com/otaprotocol/actioncodes/blob/
|
27
|
+
Defined in: [codegen.ts:6](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/codegen.ts#L6)
|
28
28
|
|
29
29
|
***
|
30
30
|
|
@@ -32,7 +32,7 @@ Defined in: [codegen.ts:6](https://github.com/otaprotocol/actioncodes/blob/007a9
|
|
32
32
|
|
33
33
|
> `static` **MAX\_PREFIX\_LENGTH**: `number`
|
34
34
|
|
35
|
-
Defined in: [codegen.ts:8](https://github.com/otaprotocol/actioncodes/blob/
|
35
|
+
Defined in: [codegen.ts:8](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/codegen.ts#L8)
|
36
36
|
|
37
37
|
***
|
38
38
|
|
@@ -40,7 +40,7 @@ Defined in: [codegen.ts:8](https://github.com/otaprotocol/actioncodes/blob/007a9
|
|
40
40
|
|
41
41
|
> `static` **MIN\_PREFIX\_LENGTH**: `number`
|
42
42
|
|
43
|
-
Defined in: [codegen.ts:7](https://github.com/otaprotocol/actioncodes/blob/
|
43
|
+
Defined in: [codegen.ts:7](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/codegen.ts#L7)
|
44
44
|
|
45
45
|
***
|
46
46
|
|
@@ -48,7 +48,7 @@ Defined in: [codegen.ts:7](https://github.com/otaprotocol/actioncodes/blob/007a9
|
|
48
48
|
|
49
49
|
> `static` **TIME\_WINDOW\_MS**: `number` = `CODE_TTL`
|
50
50
|
|
51
|
-
Defined in: [codegen.ts:5](https://github.com/otaprotocol/actioncodes/blob/
|
51
|
+
Defined in: [codegen.ts:5](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/codegen.ts#L5)
|
52
52
|
|
53
53
|
## Methods
|
54
54
|
|
@@ -56,7 +56,7 @@ Defined in: [codegen.ts:5](https://github.com/otaprotocol/actioncodes/blob/007a9
|
|
56
56
|
|
57
57
|
> `static` **deriveCodeHash**(`pubkey`, `prefix`, `timestamp?`): `string`
|
58
58
|
|
59
|
-
Defined in: [codegen.ts:167](https://github.com/otaprotocol/actioncodes/blob/
|
59
|
+
Defined in: [codegen.ts:167](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/codegen.ts#L167)
|
60
60
|
|
61
61
|
Derive the full SHA-256 hash for storage or encryption key generation
|
62
62
|
|
@@ -92,7 +92,7 @@ Full SHA-256 hash string
|
|
92
92
|
|
93
93
|
> `static` **generateCode**(`pubkey`, `prefix`, `timestamp`): `object`
|
94
94
|
|
95
|
-
Defined in: [codegen.ts:123](https://github.com/otaprotocol/actioncodes/blob/
|
95
|
+
Defined in: [codegen.ts:123](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/codegen.ts#L123)
|
96
96
|
|
97
97
|
Generate a deterministic 8-digit code based on public key, prefix, and timestamp
|
98
98
|
|
@@ -144,7 +144,7 @@ Error if generated code is invalid
|
|
144
144
|
|
145
145
|
> `static` **getExpectedCode**(`pubkey`, `timestamp`, `prefix`): `string`
|
146
146
|
|
147
|
-
Defined in: [codegen.ts:186](https://github.com/otaprotocol/actioncodes/blob/
|
147
|
+
Defined in: [codegen.ts:186](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/codegen.ts#L186)
|
148
148
|
|
149
149
|
Get the expected code for a given public key and timestamp
|
150
150
|
|
@@ -180,7 +180,7 @@ Full code string with prefix + 8 digits
|
|
180
180
|
|
181
181
|
> `static` **isValidTimestamp**(`timestamp`): `boolean`
|
182
182
|
|
183
|
-
Defined in: [codegen.ts:228](https://github.com/otaprotocol/actioncodes/blob/
|
183
|
+
Defined in: [codegen.ts:228](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/codegen.ts#L228)
|
184
184
|
|
185
185
|
Check if a timestamp falls within a valid time window
|
186
186
|
|
@@ -204,7 +204,7 @@ True if timestamp is valid
|
|
204
204
|
|
205
205
|
> `static` **normalizePrefix**(`prefix`): `string`
|
206
206
|
|
207
|
-
Defined in: [codegen.ts:107](https://github.com/otaprotocol/actioncodes/blob/
|
207
|
+
Defined in: [codegen.ts:107](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/codegen.ts#L107)
|
208
208
|
|
209
209
|
Normalize prefix - convert PROTOCOL_CODE_PREFIX to empty string, validate others
|
210
210
|
|
@@ -232,7 +232,7 @@ Error if prefix is invalid
|
|
232
232
|
|
233
233
|
> `static` **validateCode**(`code`, `pubkey`, `timestamp`, `prefix`): `boolean`
|
234
234
|
|
235
|
-
Defined in: [codegen.ts:202](https://github.com/otaprotocol/actioncodes/blob/
|
235
|
+
Defined in: [codegen.ts:202](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/codegen.ts#L202)
|
236
236
|
|
237
237
|
Validate if a code matches the expected code for a given public key and timestamp
|
238
238
|
|
@@ -274,7 +274,7 @@ True if code matches expected code and timestamp is valid
|
|
274
274
|
|
275
275
|
> `static` **validateCodeDigits**(`code`): `boolean`
|
276
276
|
|
277
|
-
Defined in: [codegen.ts:67](https://github.com/otaprotocol/actioncodes/blob/
|
277
|
+
Defined in: [codegen.ts:67](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/codegen.ts#L67)
|
278
278
|
|
279
279
|
Validate that the numeric part of a code is exactly 8 digits
|
280
280
|
|
@@ -298,7 +298,7 @@ True if numeric part is valid, false otherwise
|
|
298
298
|
|
299
299
|
> `static` **validateCodeFormat**(`code`): `boolean`
|
300
300
|
|
301
|
-
Defined in: [codegen.ts:26](https://github.com/otaprotocol/actioncodes/blob/
|
301
|
+
Defined in: [codegen.ts:26](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/codegen.ts#L26)
|
302
302
|
|
303
303
|
Validate generated code format (prefix + exactly 8 digits)
|
304
304
|
|
@@ -322,7 +322,7 @@ True if code is valid, false otherwise
|
|
322
322
|
|
323
323
|
> `static` **validatePrefix**(`prefix`): `boolean`
|
324
324
|
|
325
|
-
Defined in: [codegen.ts:15](https://github.com/otaprotocol/actioncodes/blob/
|
325
|
+
Defined in: [codegen.ts:15](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/codegen.ts#L15)
|
326
326
|
|
327
327
|
Validate prefix format
|
328
328
|
|
@@ -8,4 +8,4 @@
|
|
8
8
|
|
9
9
|
> **SupportedChain** = *typeof* [`SUPPORTED_CHAINS`](../variables/SUPPORTED_CHAINS.md)\[`number`\]
|
10
10
|
|
11
|
-
Defined in: [constants.ts:9](https://github.com/otaprotocol/actioncodes/blob/
|
11
|
+
Defined in: [constants.ts:9](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/constants.ts#L9)
|
@@ -8,4 +8,4 @@
|
|
8
8
|
|
9
9
|
> `const` **CODE\_LENGTH**: `8` = `8`
|
10
10
|
|
11
|
-
Defined in: [constants.ts:3](https://github.com/otaprotocol/actioncodes/blob/
|
11
|
+
Defined in: [constants.ts:3](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/constants.ts#L3)
|
@@ -8,4 +8,4 @@
|
|
8
8
|
|
9
9
|
> `const` **CODE\_TTL**: `number`
|
10
10
|
|
11
|
-
Defined in: [constants.ts:4](https://github.com/otaprotocol/actioncodes/blob/
|
11
|
+
Defined in: [constants.ts:4](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/constants.ts#L4)
|
@@ -8,4 +8,4 @@
|
|
8
8
|
|
9
9
|
> `const` **MAX\_PREFIX\_LENGTH**: `12` = `12`
|
10
10
|
|
11
|
-
Defined in: [constants.ts:7](https://github.com/otaprotocol/actioncodes/blob/
|
11
|
+
Defined in: [constants.ts:7](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/constants.ts#L7)
|
@@ -8,4 +8,4 @@
|
|
8
8
|
|
9
9
|
> `const` **MIN\_PREFIX\_LENGTH**: `3` = `3`
|
10
10
|
|
11
|
-
Defined in: [constants.ts:6](https://github.com/otaprotocol/actioncodes/blob/
|
11
|
+
Defined in: [constants.ts:6](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/constants.ts#L6)
|
@@ -8,4 +8,4 @@
|
|
8
8
|
|
9
9
|
> `const` **PROTOCOL\_CODE\_PREFIX**: `"DEFAULT"` = `"DEFAULT"`
|
10
10
|
|
11
|
-
Defined in: [constants.ts:5](https://github.com/otaprotocol/actioncodes/blob/
|
11
|
+
Defined in: [constants.ts:5](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/constants.ts#L5)
|
@@ -8,4 +8,4 @@
|
|
8
8
|
|
9
9
|
> `const` **PROTOCOL\_PREFIX**: `"actioncodes"` = `"actioncodes"`
|
10
10
|
|
11
|
-
Defined in: [constants.ts:2](https://github.com/otaprotocol/actioncodes/blob/
|
11
|
+
Defined in: [constants.ts:2](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/constants.ts#L2)
|
@@ -8,4 +8,4 @@
|
|
8
8
|
|
9
9
|
> `const` **PROTOCOL\_VERSION**: `"1"` = `"1"`
|
10
10
|
|
11
|
-
Defined in: [constants.ts:1](https://github.com/otaprotocol/actioncodes/blob/
|
11
|
+
Defined in: [constants.ts:1](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/constants.ts#L1)
|
@@ -8,4 +8,4 @@
|
|
8
8
|
|
9
9
|
> `const` **SUPPORTED\_CHAINS**: readonly \[`"solana"`\]
|
10
10
|
|
11
|
-
Defined in: [constants.ts:8](https://github.com/otaprotocol/actioncodes/blob/
|
11
|
+
Defined in: [constants.ts:8](https://github.com/otaprotocol/actioncodes/blob/57f8663219c9af5c455731c797e721cd72058ff4/src/constants.ts#L8)
|