@actioncodes/protocol 1.0.1 → 1.0.2
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/README.md +1 -1
- package/dist/codegen.d.ts +13 -0
- package/dist/codegen.d.ts.map +1 -1
- package/dist/codegen.js +41 -1
- package/docs/README.md +1 -1
- 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 +10 -10
- package/docs/adapters/solana/solana/classes/SolanaAdapter.md +12 -12
- package/docs/adapters/solana/solana/type-aliases/SolanaTransaction.md +1 -1
- package/docs/codegen/classes/CodeGenerator.md +64 -12
- 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
package/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# 🛡️ Action Codes Protocol
|
2
2
|
|
3
|
-

|
4
4
|
|
5
5
|
**Action Codes Protocol** enables short-lived, cryptographically verifiable action codes that authorize blockchain transactions and intents without requiring live wallet sessions.
|
6
6
|
|
package/dist/codegen.d.ts
CHANGED
@@ -9,6 +9,18 @@ export declare class CodeGenerator {
|
|
9
9
|
* @returns True if prefix is valid, false otherwise
|
10
10
|
*/
|
11
11
|
static validatePrefix(prefix: string): boolean;
|
12
|
+
/**
|
13
|
+
* Validate generated code format
|
14
|
+
* @param code - The code to validate
|
15
|
+
* @returns True if code is valid, false otherwise
|
16
|
+
*/
|
17
|
+
static validateCodeFormat(code: string): boolean;
|
18
|
+
/**
|
19
|
+
* Validate that a code without prefix is exactly 8 digits and only numbers
|
20
|
+
* @param code - The code to validate
|
21
|
+
* @returns True if code is valid, false otherwise
|
22
|
+
*/
|
23
|
+
static validateCodeDigits(code: string): boolean;
|
12
24
|
/**
|
13
25
|
* Normalize prefix - convert "DEFAULT" to empty string, validate others
|
14
26
|
* @param prefix - The prefix to normalize
|
@@ -22,6 +34,7 @@ export declare class CodeGenerator {
|
|
22
34
|
* @param prefix - Optional namespace prefix (default: "DEFAULT")
|
23
35
|
* @param timestamp - UNIX timestamp in milliseconds (defaults to now)
|
24
36
|
* @returns Object containing code, issuedAt, and expiresAt timestamps
|
37
|
+
* @throws Error if generated code is invalid
|
25
38
|
*/
|
26
39
|
static generateCode(pubkey: string, prefix?: string, timestamp?: number): {
|
27
40
|
code: string;
|
package/dist/codegen.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../src/codegen.ts"],"names":[],"mappings":"AAGA,qBAAa,aAAa;IACtB,MAAM,CAAC,cAAc,SAAY;IACjC,MAAM,CAAC,WAAW,SAAe;IACjC,MAAM,CAAC,iBAAiB,SAAqB;IAC7C,MAAM,CAAC,iBAAiB,SAAqB;IAE7C;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAM9C;;;;;OAKG;IACH,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAQ9C
|
1
|
+
{"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../src/codegen.ts"],"names":[],"mappings":"AAGA,qBAAa,aAAa;IACtB,MAAM,CAAC,cAAc,SAAY;IACjC,MAAM,CAAC,WAAW,SAAe;IACjC,MAAM,CAAC,iBAAiB,SAAqB;IAC7C,MAAM,CAAC,iBAAiB,SAAqB;IAE7C;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAM9C;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAMhD;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAMhD;;;;;OAKG;IACH,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAQ9C;;;;;;;OAOG;IACH,MAAM,CAAC,YAAY,CACf,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,MAAkB,EAC1B,SAAS,GAAE,MAAmB,GAC/B;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE;IA8BxD;;;;;;OAMG;IACH,MAAM,CAAC,cAAc,CACjB,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,MAAkB,EAC1B,SAAS,CAAC,EAAE,MAAM,GACnB,MAAM;IAQT;;;;;;OAMG;IACH,MAAM,CAAC,eAAe,CAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,MAAM,GAAE,MAAkB,GAC3B,MAAM;IAIT;;;;;;;OAOG;IACH,MAAM,CAAC,YAAY,CACf,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,MAAM,GAAE,MAAkB,GAC3B,OAAO;IAgBV;;;;OAIG;IACH,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;CAGtD"}
|
package/dist/codegen.js
CHANGED
@@ -16,6 +16,30 @@ class CodeGenerator {
|
|
16
16
|
return false;
|
17
17
|
return /^[A-Za-z]+$/.test(prefix);
|
18
18
|
}
|
19
|
+
/**
|
20
|
+
* Validate generated code format
|
21
|
+
* @param code - The code to validate
|
22
|
+
* @returns True if code is valid, false otherwise
|
23
|
+
*/
|
24
|
+
static validateCodeFormat(code) {
|
25
|
+
if (!code || typeof code !== 'string')
|
26
|
+
return false;
|
27
|
+
if (code.length !== this.CODE_DIGITS)
|
28
|
+
return false;
|
29
|
+
return /^\d+$/.test(code);
|
30
|
+
}
|
31
|
+
/**
|
32
|
+
* Validate that a code without prefix is exactly 8 digits and only numbers
|
33
|
+
* @param code - The code to validate
|
34
|
+
* @returns True if code is valid, false otherwise
|
35
|
+
*/
|
36
|
+
static validateCodeDigits(code) {
|
37
|
+
if (!code || typeof code !== 'string')
|
38
|
+
return false;
|
39
|
+
if (code.length !== constants_1.CODE_LENGTH)
|
40
|
+
return false;
|
41
|
+
return /^[0-9]{8}$/.test(code);
|
42
|
+
}
|
19
43
|
/**
|
20
44
|
* Normalize prefix - convert "DEFAULT" to empty string, validate others
|
21
45
|
* @param prefix - The prefix to normalize
|
@@ -36,6 +60,7 @@ class CodeGenerator {
|
|
36
60
|
* @param prefix - Optional namespace prefix (default: "DEFAULT")
|
37
61
|
* @param timestamp - UNIX timestamp in milliseconds (defaults to now)
|
38
62
|
* @returns Object containing code, issuedAt, and expiresAt timestamps
|
63
|
+
* @throws Error if generated code is invalid
|
39
64
|
*/
|
40
65
|
static generateCode(pubkey, prefix = "DEFAULT", timestamp = Date.now()) {
|
41
66
|
const normalizedPrefix = this.normalizePrefix(prefix);
|
@@ -46,8 +71,16 @@ class CodeGenerator {
|
|
46
71
|
const code = raw % mod;
|
47
72
|
const issuedAt = timestamp;
|
48
73
|
const expiresAt = issuedAt + this.TIME_WINDOW_MS;
|
74
|
+
const generatedCode = code.toString().padStart(this.CODE_DIGITS, "0");
|
75
|
+
// Validate the generated code
|
76
|
+
if (!this.validateCodeFormat(generatedCode)) {
|
77
|
+
throw new Error(`Generated code validation failed: ${generatedCode}`);
|
78
|
+
}
|
79
|
+
if (!this.validateCodeDigits(generatedCode)) {
|
80
|
+
throw new Error(`Generated code must be exactly 8 digits: ${generatedCode}`);
|
81
|
+
}
|
49
82
|
return {
|
50
|
-
code:
|
83
|
+
code: generatedCode,
|
51
84
|
issuedAt,
|
52
85
|
expiresAt
|
53
86
|
};
|
@@ -85,6 +118,13 @@ class CodeGenerator {
|
|
85
118
|
* @returns True if code matches expected code and timestamp is valid
|
86
119
|
*/
|
87
120
|
static validateCode(code, pubkey, timestamp, prefix = "DEFAULT") {
|
121
|
+
// First validate the code format
|
122
|
+
if (!this.validateCodeFormat(code)) {
|
123
|
+
return false;
|
124
|
+
}
|
125
|
+
if (!this.validateCodeDigits(code)) {
|
126
|
+
return false;
|
127
|
+
}
|
88
128
|
const expectedCode = this.getExpectedCode(pubkey, timestamp, prefix);
|
89
129
|
const now = Date.now();
|
90
130
|
const isTimeValid = timestamp >= 0 && timestamp <= now && now <= timestamp + this.TIME_WINDOW_MS;
|
package/docs/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
# 🛡️ Action Codes Protocol
|
6
6
|
|
7
|
-

|
8
8
|
|
9
9
|
**Action Codes Protocol** enables short-lived, cryptographically verifiable action codes that authorize blockchain transactions and intents without requiring live wallet sessions.
|
10
10
|
|
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
# Class: ActionCode
|
8
8
|
|
9
|
-
Defined in: [actioncode.ts:32](https://github.com/otaprotocol/actioncodes/blob/
|
9
|
+
Defined in: [actioncode.ts:32](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L32)
|
10
10
|
|
11
11
|
## Constructors
|
12
12
|
|
@@ -14,7 +14,7 @@ Defined in: [actioncode.ts:32](https://github.com/otaprotocol/actioncodes/blob/f
|
|
14
14
|
|
15
15
|
> **new ActionCode**(`fields`): `ActionCode`
|
16
16
|
|
17
|
-
Defined in: [actioncode.ts:33](https://github.com/otaprotocol/actioncodes/blob/
|
17
|
+
Defined in: [actioncode.ts:33](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L33)
|
18
18
|
|
19
19
|
#### Parameters
|
20
20
|
|
@@ -34,7 +34,7 @@ Defined in: [actioncode.ts:33](https://github.com/otaprotocol/actioncodes/blob/f
|
|
34
34
|
|
35
35
|
> **get** **chain**(): `string`
|
36
36
|
|
37
|
-
Defined in: [actioncode.ts:95](https://github.com/otaprotocol/actioncodes/blob/
|
37
|
+
Defined in: [actioncode.ts:95](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L95)
|
38
38
|
|
39
39
|
Get the target chain for this action code
|
40
40
|
|
@@ -52,7 +52,7 @@ Chain identifier (e.g., "solana", "evm")
|
|
52
52
|
|
53
53
|
> **get** **code**(): `string`
|
54
54
|
|
55
|
-
Defined in: [actioncode.ts:111](https://github.com/otaprotocol/actioncodes/blob/
|
55
|
+
Defined in: [actioncode.ts:111](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L111)
|
56
56
|
|
57
57
|
Get the action code string
|
58
58
|
|
@@ -70,7 +70,7 @@ The 8-character action code
|
|
70
70
|
|
71
71
|
> **get** **codeHash**(): `string`
|
72
72
|
|
73
|
-
Defined in: [actioncode.ts:217](https://github.com/otaprotocol/actioncodes/blob/
|
73
|
+
Defined in: [actioncode.ts:217](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L217)
|
74
74
|
|
75
75
|
Get the code hash for this action code
|
76
76
|
it is also used in the protocol meta as the code id
|
@@ -89,7 +89,7 @@ Code hash string
|
|
89
89
|
|
90
90
|
> **get** **description**(): `undefined` \| `string`
|
91
91
|
|
92
|
-
Defined in: [actioncode.ts:151](https://github.com/otaprotocol/actioncodes/blob/
|
92
|
+
Defined in: [actioncode.ts:151](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L151)
|
93
93
|
|
94
94
|
Get a human-readable description of the action
|
95
95
|
|
@@ -107,7 +107,7 @@ Description string or undefined
|
|
107
107
|
|
108
108
|
> **get** **displayString**(): `string`
|
109
109
|
|
110
|
-
Defined in: [actioncode.ts:183](https://github.com/otaprotocol/actioncodes/blob/
|
110
|
+
Defined in: [actioncode.ts:183](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L183)
|
111
111
|
|
112
112
|
Get a human-readable display string for the action code
|
113
113
|
|
@@ -125,7 +125,7 @@ Formatted display string
|
|
125
125
|
|
126
126
|
> **get** **encoded**(): `string`
|
127
127
|
|
128
|
-
Defined in: [actioncode.ts:47](https://github.com/otaprotocol/actioncodes/blob/
|
128
|
+
Defined in: [actioncode.ts:47](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L47)
|
129
129
|
|
130
130
|
##### Returns
|
131
131
|
|
@@ -139,7 +139,7 @@ Defined in: [actioncode.ts:47](https://github.com/otaprotocol/actioncodes/blob/f
|
|
139
139
|
|
140
140
|
> **get** **expired**(): `boolean`
|
141
141
|
|
142
|
-
Defined in: [actioncode.ts:87](https://github.com/otaprotocol/actioncodes/blob/
|
142
|
+
Defined in: [actioncode.ts:87](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L87)
|
143
143
|
|
144
144
|
Check if the action code has expired
|
145
145
|
|
@@ -157,7 +157,7 @@ True if the code has expired
|
|
157
157
|
|
158
158
|
> **get** **json**(): [`ActionCodeFields`](../interfaces/ActionCodeFields.md)
|
159
159
|
|
160
|
-
Defined in: [actioncode.ts:68](https://github.com/otaprotocol/actioncodes/blob/
|
160
|
+
Defined in: [actioncode.ts:68](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L68)
|
161
161
|
|
162
162
|
##### Returns
|
163
163
|
|
@@ -171,7 +171,7 @@ Defined in: [actioncode.ts:68](https://github.com/otaprotocol/actioncodes/blob/f
|
|
171
171
|
|
172
172
|
> **get** **metadata**(): `undefined` \| [`ActionCodeMetadata`](../interfaces/ActionCodeMetadata.md)
|
173
173
|
|
174
|
-
Defined in: [actioncode.ts:143](https://github.com/otaprotocol/actioncodes/blob/
|
174
|
+
Defined in: [actioncode.ts:143](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L143)
|
175
175
|
|
176
176
|
Get metadata associated with this action code
|
177
177
|
|
@@ -189,7 +189,7 @@ Metadata object or undefined
|
|
189
189
|
|
190
190
|
> **get** **params**(): `undefined` \| `Record`\<`string`, `any`\>
|
191
191
|
|
192
|
-
Defined in: [actioncode.ts:159](https://github.com/otaprotocol/actioncodes/blob/
|
192
|
+
Defined in: [actioncode.ts:159](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L159)
|
193
193
|
|
194
194
|
Get parameters associated with this action
|
195
195
|
|
@@ -207,7 +207,7 @@ Parameters object or undefined
|
|
207
207
|
|
208
208
|
> **get** **prefix**(): `string`
|
209
209
|
|
210
|
-
Defined in: [actioncode.ts:119](https://github.com/otaprotocol/actioncodes/blob/
|
210
|
+
Defined in: [actioncode.ts:119](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L119)
|
211
211
|
|
212
212
|
Get the prefix used for this action code
|
213
213
|
|
@@ -225,7 +225,7 @@ Normalized prefix
|
|
225
225
|
|
226
226
|
> **get** **pubkey**(): `string`
|
227
227
|
|
228
|
-
Defined in: [actioncode.ts:127](https://github.com/otaprotocol/actioncodes/blob/
|
228
|
+
Defined in: [actioncode.ts:127](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L127)
|
229
229
|
|
230
230
|
Get the user's public key
|
231
231
|
|
@@ -243,7 +243,7 @@ User's public key
|
|
243
243
|
|
244
244
|
> **get** **remainingTime**(): `number`
|
245
245
|
|
246
|
-
Defined in: [actioncode.ts:78](https://github.com/otaprotocol/actioncodes/blob/
|
246
|
+
Defined in: [actioncode.ts:78](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L78)
|
247
247
|
|
248
248
|
Get remaining time in milliseconds until expiration
|
249
249
|
|
@@ -261,7 +261,7 @@ Remaining time in milliseconds, or 0 if expired
|
|
261
261
|
|
262
262
|
> **get** **remainingTimeString**(): `string`
|
263
263
|
|
264
|
-
Defined in: [actioncode.ts:196](https://github.com/otaprotocol/actioncodes/blob/
|
264
|
+
Defined in: [actioncode.ts:196](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L196)
|
265
265
|
|
266
266
|
Get a formatted time string showing remaining time
|
267
267
|
|
@@ -279,7 +279,7 @@ Human-readable time string (e.g., "1m 30s remaining")
|
|
279
279
|
|
280
280
|
> **get** **signature**(): `string`
|
281
281
|
|
282
|
-
Defined in: [actioncode.ts:175](https://github.com/otaprotocol/actioncodes/blob/
|
282
|
+
Defined in: [actioncode.ts:175](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L175)
|
283
283
|
|
284
284
|
Get the user's signature
|
285
285
|
|
@@ -297,7 +297,7 @@ User's signature string
|
|
297
297
|
|
298
298
|
> **get** **status**(): [`ActionCodeStatus`](../type-aliases/ActionCodeStatus.md)
|
299
299
|
|
300
|
-
Defined in: [actioncode.ts:103](https://github.com/otaprotocol/actioncodes/blob/
|
300
|
+
Defined in: [actioncode.ts:103](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L103)
|
301
301
|
|
302
302
|
Get the current status of the action code
|
303
303
|
|
@@ -315,7 +315,7 @@ Current status
|
|
315
315
|
|
316
316
|
> **get** **timestamp**(): `number`
|
317
317
|
|
318
|
-
Defined in: [actioncode.ts:167](https://github.com/otaprotocol/actioncodes/blob/
|
318
|
+
Defined in: [actioncode.ts:167](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L167)
|
319
319
|
|
320
320
|
Get the timestamp when the code was generated
|
321
321
|
|
@@ -333,7 +333,7 @@ Timestamp in milliseconds
|
|
333
333
|
|
334
334
|
> **get** **transaction**(): `undefined` \| [`ActionCodeTransaction`](../interfaces/ActionCodeTransaction.md)
|
335
335
|
|
336
|
-
Defined in: [actioncode.ts:135](https://github.com/otaprotocol/actioncodes/blob/
|
336
|
+
Defined in: [actioncode.ts:135](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L135)
|
337
337
|
|
338
338
|
Get the transaction data (chain-specific)
|
339
339
|
|
@@ -349,7 +349,7 @@ Transaction data or undefined
|
|
349
349
|
|
350
350
|
> **isValid**(`protocol`): `boolean`
|
351
351
|
|
352
|
-
Defined in: [actioncode.ts:51](https://github.com/otaprotocol/actioncodes/blob/
|
352
|
+
Defined in: [actioncode.ts:51](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L51)
|
353
353
|
|
354
354
|
#### Parameters
|
355
355
|
|
@@ -367,7 +367,7 @@ Defined in: [actioncode.ts:51](https://github.com/otaprotocol/actioncodes/blob/f
|
|
367
367
|
|
368
368
|
> `static` **fromEncoded**(`encoded`): `ActionCode`
|
369
369
|
|
370
|
-
Defined in: [actioncode.ts:42](https://github.com/otaprotocol/actioncodes/blob/
|
370
|
+
Defined in: [actioncode.ts:42](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L42)
|
371
371
|
|
372
372
|
#### Parameters
|
373
373
|
|
@@ -385,7 +385,7 @@ Defined in: [actioncode.ts:42](https://github.com/otaprotocol/actioncodes/blob/f
|
|
385
385
|
|
386
386
|
> `static` **fromPayload**(`input`): `ActionCode`
|
387
387
|
|
388
|
-
Defined in: [actioncode.ts:35](https://github.com/otaprotocol/actioncodes/blob/
|
388
|
+
Defined in: [actioncode.ts:35](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L35)
|
389
389
|
|
390
390
|
#### Parameters
|
391
391
|
|
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
# Interface: ActionCodeFields
|
8
8
|
|
9
|
-
Defined in: [actioncode.ts:19](https://github.com/otaprotocol/actioncodes/blob/
|
9
|
+
Defined in: [actioncode.ts:19](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L19)
|
10
10
|
|
11
11
|
## Properties
|
12
12
|
|
@@ -14,7 +14,7 @@ Defined in: [actioncode.ts:19](https://github.com/otaprotocol/actioncodes/blob/f
|
|
14
14
|
|
15
15
|
> **chain**: `"solana"`
|
16
16
|
|
17
|
-
Defined in: [actioncode.ts:25](https://github.com/otaprotocol/actioncodes/blob/
|
17
|
+
Defined in: [actioncode.ts:25](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L25)
|
18
18
|
|
19
19
|
***
|
20
20
|
|
@@ -22,7 +22,7 @@ Defined in: [actioncode.ts:25](https://github.com/otaprotocol/actioncodes/blob/f
|
|
22
22
|
|
23
23
|
> **code**: `string`
|
24
24
|
|
25
|
-
Defined in: [actioncode.ts:20](https://github.com/otaprotocol/actioncodes/blob/
|
25
|
+
Defined in: [actioncode.ts:20](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L20)
|
26
26
|
|
27
27
|
***
|
28
28
|
|
@@ -30,7 +30,7 @@ Defined in: [actioncode.ts:20](https://github.com/otaprotocol/actioncodes/blob/f
|
|
30
30
|
|
31
31
|
> **expiresAt**: `number`
|
32
32
|
|
33
|
-
Defined in: [actioncode.ts:28](https://github.com/otaprotocol/actioncodes/blob/
|
33
|
+
Defined in: [actioncode.ts:28](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L28)
|
34
34
|
|
35
35
|
***
|
36
36
|
|
@@ -38,7 +38,7 @@ Defined in: [actioncode.ts:28](https://github.com/otaprotocol/actioncodes/blob/f
|
|
38
38
|
|
39
39
|
> `optional` **metadata**: [`ActionCodeMetadata`](ActionCodeMetadata.md)
|
40
40
|
|
41
|
-
Defined in: [actioncode.ts:27](https://github.com/otaprotocol/actioncodes/blob/
|
41
|
+
Defined in: [actioncode.ts:27](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L27)
|
42
42
|
|
43
43
|
***
|
44
44
|
|
@@ -46,7 +46,7 @@ Defined in: [actioncode.ts:27](https://github.com/otaprotocol/actioncodes/blob/f
|
|
46
46
|
|
47
47
|
> **prefix**: `string`
|
48
48
|
|
49
|
-
Defined in: [actioncode.ts:21](https://github.com/otaprotocol/actioncodes/blob/
|
49
|
+
Defined in: [actioncode.ts:21](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L21)
|
50
50
|
|
51
51
|
***
|
52
52
|
|
@@ -54,7 +54,7 @@ Defined in: [actioncode.ts:21](https://github.com/otaprotocol/actioncodes/blob/f
|
|
54
54
|
|
55
55
|
> **pubkey**: `string`
|
56
56
|
|
57
|
-
Defined in: [actioncode.ts:22](https://github.com/otaprotocol/actioncodes/blob/
|
57
|
+
Defined in: [actioncode.ts:22](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L22)
|
58
58
|
|
59
59
|
***
|
60
60
|
|
@@ -62,7 +62,7 @@ Defined in: [actioncode.ts:22](https://github.com/otaprotocol/actioncodes/blob/f
|
|
62
62
|
|
63
63
|
> **signature**: `string`
|
64
64
|
|
65
|
-
Defined in: [actioncode.ts:24](https://github.com/otaprotocol/actioncodes/blob/
|
65
|
+
Defined in: [actioncode.ts:24](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L24)
|
66
66
|
|
67
67
|
***
|
68
68
|
|
@@ -70,7 +70,7 @@ Defined in: [actioncode.ts:24](https://github.com/otaprotocol/actioncodes/blob/f
|
|
70
70
|
|
71
71
|
> **status**: [`ActionCodeStatus`](../type-aliases/ActionCodeStatus.md)
|
72
72
|
|
73
|
-
Defined in: [actioncode.ts:29](https://github.com/otaprotocol/actioncodes/blob/
|
73
|
+
Defined in: [actioncode.ts:29](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L29)
|
74
74
|
|
75
75
|
***
|
76
76
|
|
@@ -78,7 +78,7 @@ Defined in: [actioncode.ts:29](https://github.com/otaprotocol/actioncodes/blob/f
|
|
78
78
|
|
79
79
|
> **timestamp**: `number`
|
80
80
|
|
81
|
-
Defined in: [actioncode.ts:23](https://github.com/otaprotocol/actioncodes/blob/
|
81
|
+
Defined in: [actioncode.ts:23](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L23)
|
82
82
|
|
83
83
|
***
|
84
84
|
|
@@ -86,4 +86,4 @@ Defined in: [actioncode.ts:23](https://github.com/otaprotocol/actioncodes/blob/f
|
|
86
86
|
|
87
87
|
> `optional` **transaction**: [`ActionCodeTransaction`](ActionCodeTransaction.md)
|
88
88
|
|
89
|
-
Defined in: [actioncode.ts:26](https://github.com/otaprotocol/actioncodes/blob/
|
89
|
+
Defined in: [actioncode.ts:26](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L26)
|
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
# Interface: ActionCodeMetadata
|
8
8
|
|
9
|
-
Defined in: [actioncode.ts:8](https://github.com/otaprotocol/actioncodes/blob/
|
9
|
+
Defined in: [actioncode.ts:8](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L8)
|
10
10
|
|
11
11
|
## Properties
|
12
12
|
|
@@ -14,7 +14,7 @@ Defined in: [actioncode.ts:8](https://github.com/otaprotocol/actioncodes/blob/fa
|
|
14
14
|
|
15
15
|
> `optional` **description**: `string`
|
16
16
|
|
17
|
-
Defined in: [actioncode.ts:9](https://github.com/otaprotocol/actioncodes/blob/
|
17
|
+
Defined in: [actioncode.ts:9](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L9)
|
18
18
|
|
19
19
|
***
|
20
20
|
|
@@ -22,4 +22,4 @@ Defined in: [actioncode.ts:9](https://github.com/otaprotocol/actioncodes/blob/fa
|
|
22
22
|
|
23
23
|
> `optional` **params**: `Record`\<`string`, `any`\>
|
24
24
|
|
25
|
-
Defined in: [actioncode.ts:10](https://github.com/otaprotocol/actioncodes/blob/
|
25
|
+
Defined in: [actioncode.ts:10](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/actioncode.ts#L10)
|
@@ -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/6e0359c879f763df764595dbea0cb596eff80113/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/f
|
|
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/6e0359c879f763df764595dbea0cb596eff80113/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/f
|
|
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/6e0359c879f763df764595dbea0cb596eff80113/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/f
|
|
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/6e0359c879f763df764595dbea0cb596eff80113/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/6e0359c879f763df764595dbea0cb596eff80113/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/6e0359c879f763df764595dbea0cb596eff80113/src/adapters/base.ts#L9)
|
10
10
|
|
11
11
|
Base adapter class for chain-specific protocol meta operations
|
12
12
|
|
@@ -38,7 +38,7 @@ 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/6e0359c879f763df764595dbea0cb596eff80113/src/adapters/base.ts#L10)
|
42
42
|
|
43
43
|
## Methods
|
44
44
|
|
@@ -46,7 +46,7 @@ Defined in: [adapters/base.ts:10](https://github.com/otaprotocol/actioncodes/blo
|
|
46
46
|
|
47
47
|
> `abstract` **decode**(`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/6e0359c879f763df764595dbea0cb596eff80113/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:50](https://github.com/otaprotocol/actioncodes/blob/
|
73
|
+
Defined in: [adapters/base.ts:50](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/adapters/base.ts#L50)
|
74
74
|
|
75
75
|
Detect tampered transactions by cross-checking metadata
|
76
76
|
|
@@ -106,7 +106,7 @@ True if transaction is valid and not tampered
|
|
106
106
|
|
107
107
|
> `abstract` **encode**(`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/6e0359c879f763df764595dbea0cb596eff80113/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:96](https://github.com/otaprotocol/actioncodes/blob/
|
133
|
+
Defined in: [adapters/base.ts:96](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/adapters/base.ts#L96)
|
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:41](https://github.com/otaprotocol/actioncodes/blob/
|
169
|
+
Defined in: [adapters/base.ts:41](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/adapters/base.ts#L41)
|
170
170
|
|
171
171
|
Check if the issuer has signed the transaction
|
172
172
|
|
@@ -196,7 +196,7 @@ True if issuer has signed
|
|
196
196
|
|
197
197
|
> `abstract` **validate**(`tx`, `authorities`, `expectedPrefix?`): `boolean`
|
198
198
|
|
199
|
-
Defined in: [adapters/base.ts:33](https://github.com/otaprotocol/actioncodes/blob/
|
199
|
+
Defined in: [adapters/base.ts:33](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/adapters/base.ts#L33)
|
200
200
|
|
201
201
|
Validate transaction with protocol meta and authority list
|
202
202
|
|
@@ -232,7 +232,7 @@ True if transaction is valid
|
|
232
232
|
|
233
233
|
> `abstract` `protected` **validateTransactionIntegrity**(`tx`, `meta`): `boolean`
|
234
234
|
|
235
|
-
Defined in: [adapters/base.ts:87](https://github.com/otaprotocol/actioncodes/blob/
|
235
|
+
Defined in: [adapters/base.ts:87](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/adapters/base.ts#L87)
|
236
236
|
|
237
237
|
Chain-specific transaction integrity validation
|
238
238
|
Override this method for additional validation logic
|
@@ -263,7 +263,7 @@ True if transaction integrity is valid
|
|
263
263
|
|
264
264
|
> `abstract` **verifyCodeSignature**(`actionCode`): `boolean`
|
265
265
|
|
266
|
-
Defined in: [adapters/base.ts:107](https://github.com/otaprotocol/actioncodes/blob/
|
266
|
+
Defined in: [adapters/base.ts:107](https://github.com/otaprotocol/actioncodes/blob/6e0359c879f763df764595dbea0cb596eff80113/src/adapters/base.ts#L107)
|
267
267
|
|
268
268
|
Verify the code signature
|
269
269
|
This is specific to the chain and should be implemented by the concrete adapter
|