@actioncodes/protocol 1.1.2 → 1.1.4
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 +6 -0
- package/dist/adapters/base.d.ts.map +1 -1
- package/dist/adapters/solana/solana.d.ts +8 -1
- package/dist/adapters/solana/solana.d.ts.map +1 -1
- package/dist/adapters/solana/solana.js +104 -0
- 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 +40 -12
- package/docs/adapters/solana/solana/classes/SolanaAdapter.md +48 -14
- 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 +3 -2
package/dist/adapters/base.d.ts
CHANGED
@@ -82,5 +82,11 @@ export declare abstract class BaseChainAdapter<T = any> {
|
|
82
82
|
* @returns Promise that resolves to the signed transaction
|
83
83
|
*/
|
84
84
|
abstract signWithProtocolKey(actionCode: ActionCode, key: any): Promise<ActionCode>;
|
85
|
+
/**
|
86
|
+
* Verify the finalized transaction
|
87
|
+
* @param tx - The finalized transaction to verify
|
88
|
+
* @returns True if the transaction is valid
|
89
|
+
*/
|
90
|
+
abstract verifyFinalizedTransaction(tx: any, actionCode: ActionCode): boolean;
|
85
91
|
}
|
86
92
|
//# sourceMappingURL=base.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/adapters/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC;;;GAGG;AACH,8BAAsB,gBAAgB,CAAC,CAAC,GAAG,GAAG;IAC1C,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEhC;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,IAAI,EAAE,cAAc,GAAG,GAAG;IAE9C;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,GAAG,cAAc,GAAG,IAAI;IAEjD;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,MAAM;IAEvE;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO;IAEjF;;;;;OAKG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO;IAE3D;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,cAAc,GAAE,MAAkB,GAAG,OAAO;IA8B1F;;;;;;OAMG;IACH,SAAS,CAAC,QAAQ,CAAC,4BAA4B,CAAC,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO;IAErF;;;;;;OAMG;IACH,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAE,MAA6B,GAAG,MAAM;IAIvG;;;;;;OAMG;IACH,QAAQ,CAAC,mBAAmB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO;IAE7D;;;;;;;;OAQG;IACH,QAAQ,CAAC,mBAAmB,CACxB,UAAU,EAAE,UAAU,EACtB,GAAG,EAAE,GAAG,GACT,OAAO,CAAC,UAAU,CAAC;
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/adapters/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC;;;GAGG;AACH,8BAAsB,gBAAgB,CAAC,CAAC,GAAG,GAAG;IAC1C,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEhC;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,IAAI,EAAE,cAAc,GAAG,GAAG;IAE9C;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,GAAG,cAAc,GAAG,IAAI;IAEjD;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,MAAM;IAEvE;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO;IAEjF;;;;;OAKG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO;IAE3D;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,cAAc,GAAE,MAAkB,GAAG,OAAO;IA8B1F;;;;;;OAMG;IACH,SAAS,CAAC,QAAQ,CAAC,4BAA4B,CAAC,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO;IAErF;;;;;;OAMG;IACH,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAE,MAA6B,GAAG,MAAM;IAIvG;;;;;;OAMG;IACH,QAAQ,CAAC,mBAAmB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO;IAE7D;;;;;;;;OAQG;IACH,QAAQ,CAAC,mBAAmB,CACxB,UAAU,EAAE,UAAU,EACtB,GAAG,EAAE,GAAG,GACT,OAAO,CAAC,UAAU,CAAC;IAEtB;;;;OAIG;IACH,QAAQ,CAAC,0BAA0B,CAAC,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO;CAChF"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Transaction, TransactionInstruction, VersionedTransaction, Keypair } from '@solana/web3.js';
|
1
|
+
import { Transaction, TransactionInstruction, VersionedTransaction, Keypair, VersionedTransactionResponse } from '@solana/web3.js';
|
2
2
|
import { ProtocolMetaV1 } from '../../meta';
|
3
3
|
import { BaseChainAdapter } from '../base';
|
4
4
|
import { ActionCode } from '../../actioncode';
|
@@ -94,5 +94,12 @@ export declare class SolanaAdapter extends BaseChainAdapter<SolanaTransaction> {
|
|
94
94
|
* @returns Promise that resolves to the signed action code
|
95
95
|
*/
|
96
96
|
signWithProtocolKey(actionCode: ActionCode, key: Keypair): Promise<ActionCode>;
|
97
|
+
/**
|
98
|
+
* Verify the finalized transaction from blockchain
|
99
|
+
* @param tx - The finalized transaction response from blockchain
|
100
|
+
* @param actionCode - The action code to verify against
|
101
|
+
* @returns True if the transaction is valid and matches the action code
|
102
|
+
*/
|
103
|
+
verifyFinalizedTransaction(tx: VersionedTransactionResponse, actionCode: ActionCode): boolean;
|
97
104
|
}
|
98
105
|
//# sourceMappingURL=solana.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solana.d.ts","sourceRoot":"","sources":["../../../src/adapters/solana/solana.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,sBAAsB,EACtB,oBAAoB,EAGpB,OAAO,
|
1
|
+
{"version":3,"file":"solana.d.ts","sourceRoot":"","sources":["../../../src/adapters/solana/solana.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,sBAAsB,EACtB,oBAAoB,EAGpB,OAAO,EACP,4BAA4B,EAC/B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,cAAc,EAAsB,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,oBAAoB,CAAC;AAEnE;;;GAGG;AACH,qBAAa,aAAc,SAAQ,gBAAgB,CAAC,iBAAiB,CAAC;IAClE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAmB;IAE1D,QAAQ,CAAC,KAAK,YAAY;IAE1B;;;;OAIG;IACH,UAAU,CAAC,IAAI,EAAE,cAAc,GAAG,sBAAsB;IAgBxD;;;;OAIG;IACH,UAAU,CAAC,EAAE,EAAE,iBAAiB,GAAG,MAAM,GAAG,cAAc,GAAG,IAAI;IAoBjE;;;;OAIG;IACI,sBAAsB,CAAC,YAAY,EAAE,MAAM,GAAG,iBAAiB;IActE;;;;;OAKG;IACH,UAAU,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,MAAM;IA2E9D;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,cAAc,GAAE,MAAkB,GAAG,OAAO;IAInG;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,EAAE,iBAAiB,GAAG,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO;IAoB3E;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAqB/B;;OAEG;IACH,OAAO,CAAC,0BAA0B;IAUlC;;OAEG;IACH,OAAO,CAAC,eAAe;IAuBvB;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAMhC;;OAEG;IACH,OAAO,CAAC,2BAA2B;IAenC;;;;;OAKG;IACH,SAAS,CAAC,4BAA4B,CAAC,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO;IA6BrF,mBAAmB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO;IAa3D;;;;OAIG;IACH,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI;IAI7D;;;;;OAKG;IACG,mBAAmB,CACrB,UAAU,EAAE,UAAU,EACtB,GAAG,EAAE,OAAO,GACb,OAAO,CAAC,UAAU,CAAC;IAyCtB;;;;;OAKG;IACH,0BAA0B,CAAC,EAAE,EAAE,4BAA4B,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO;CAwHhG"}
|
@@ -388,6 +388,110 @@ class SolanaAdapter extends base_1.BaseChainAdapter {
|
|
388
388
|
throw new Error(`Failed to sign transaction with protocol key: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
389
389
|
}
|
390
390
|
}
|
391
|
+
/**
|
392
|
+
* Verify the finalized transaction from blockchain
|
393
|
+
* @param tx - The finalized transaction response from blockchain
|
394
|
+
* @param actionCode - The action code to verify against
|
395
|
+
* @returns True if the transaction is valid and matches the action code
|
396
|
+
*/
|
397
|
+
verifyFinalizedTransaction(tx, actionCode) {
|
398
|
+
try {
|
399
|
+
// Handle null/undefined transaction
|
400
|
+
if (tx.transaction === null || tx.transaction === undefined) {
|
401
|
+
return false;
|
402
|
+
}
|
403
|
+
// Both legacy and versioned responses have message and signatures
|
404
|
+
const response = tx.transaction;
|
405
|
+
if (!response.message || !response.signatures) {
|
406
|
+
return false;
|
407
|
+
}
|
408
|
+
let transaction;
|
409
|
+
// Check if it's a versioned transaction by looking at the message structure
|
410
|
+
if (response.message instanceof web3_js_1.MessageV0) {
|
411
|
+
// Versioned transaction - reconstruct from message and signatures
|
412
|
+
transaction = new web3_js_1.VersionedTransaction(response.message);
|
413
|
+
// Note: In a real scenario, signatures would be attached, but for testing we just need the message
|
414
|
+
}
|
415
|
+
else {
|
416
|
+
// Legacy transaction - reconstruct from compiled message and signatures
|
417
|
+
const compiledMessage = response.message;
|
418
|
+
transaction = web3_js_1.Transaction.populate(compiledMessage, response.signatures);
|
419
|
+
}
|
420
|
+
const meta = this.decodeMeta(transaction);
|
421
|
+
if (!meta) {
|
422
|
+
return false; // No protocol meta found
|
423
|
+
}
|
424
|
+
if (!meta.iss) {
|
425
|
+
return false; // No issuer field in meta
|
426
|
+
}
|
427
|
+
if (!actionCode.codeHash) {
|
428
|
+
return false; // No codeHash available
|
429
|
+
}
|
430
|
+
if (!meta.id || meta.id !== actionCode.codeHash) {
|
431
|
+
return false; // ID doesn't match expected value
|
432
|
+
}
|
433
|
+
if (meta.prefix !== actionCode.prefix) {
|
434
|
+
return false;
|
435
|
+
}
|
436
|
+
if (meta.initiator !== actionCode.pubkey) {
|
437
|
+
return false;
|
438
|
+
}
|
439
|
+
let userPubkey = null;
|
440
|
+
try {
|
441
|
+
userPubkey = new web3_js_1.PublicKey(actionCode.pubkey);
|
442
|
+
}
|
443
|
+
catch (error) {
|
444
|
+
return false;
|
445
|
+
}
|
446
|
+
if (userPubkey) {
|
447
|
+
if (transaction instanceof web3_js_1.VersionedTransaction) {
|
448
|
+
const message = transaction.message;
|
449
|
+
if (message instanceof web3_js_1.MessageV0) {
|
450
|
+
// Check if user's public key is in the static account keys
|
451
|
+
const userKeyIndex = message.staticAccountKeys.findIndex(key => key.equals(userPubkey));
|
452
|
+
if (userKeyIndex === -1) {
|
453
|
+
return false; // User's key not found in transaction
|
454
|
+
}
|
455
|
+
// Check if user's key is a signer (first bit of header indicates signer status)
|
456
|
+
const isUserSigner = (message.header.numRequiredSignatures > 0) &&
|
457
|
+
(userKeyIndex < message.header.numRequiredSignatures);
|
458
|
+
if (!isUserSigner) {
|
459
|
+
return false; // User didn't sign the transaction
|
460
|
+
}
|
461
|
+
}
|
462
|
+
else {
|
463
|
+
return false; // Unsupported message type
|
464
|
+
}
|
465
|
+
}
|
466
|
+
else if (transaction instanceof web3_js_1.Transaction) {
|
467
|
+
// For legacy transactions, check if user's key is in the account keys
|
468
|
+
const accountKeys = transaction.compileMessage().accountKeys;
|
469
|
+
const userKeyIndex = accountKeys.findIndex(key => key.equals(userPubkey));
|
470
|
+
if (userKeyIndex === -1) {
|
471
|
+
return false; // User's key not found in transaction
|
472
|
+
}
|
473
|
+
// Check if user's key is a signer
|
474
|
+
const isUserSigner = userKeyIndex < transaction.compileMessage().header.numRequiredSignatures;
|
475
|
+
if (!isUserSigner) {
|
476
|
+
return false; // User didn't sign the transaction
|
477
|
+
}
|
478
|
+
}
|
479
|
+
else {
|
480
|
+
return false; // Invalid transaction type
|
481
|
+
}
|
482
|
+
}
|
483
|
+
// 5. Check that tx is signed by protocol (issuer)
|
484
|
+
if (!this.hasIssuerSignature(transaction, meta.iss)) {
|
485
|
+
return false; // Protocol didn't sign the transaction
|
486
|
+
}
|
487
|
+
// All checks passed
|
488
|
+
return true;
|
489
|
+
}
|
490
|
+
catch (error) {
|
491
|
+
// If any error occurs during verification, return false
|
492
|
+
return false;
|
493
|
+
}
|
494
|
+
}
|
391
495
|
}
|
392
496
|
exports.SolanaAdapter = SolanaAdapter;
|
393
497
|
SolanaAdapter.MEMO_PROGRAM_ID = spl_memo_1.MEMO_PROGRAM_ID;
|
@@ -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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/8
|
|
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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/8
|
|
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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/8
|
|
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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/8
|
|
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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/8
|
|
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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/8
|
|
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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/8
|
|
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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/8
|
|
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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/8
|
|
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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/8
|
|
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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/8
|
|
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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/8
|
|
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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/8
|
|
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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/8
|
|
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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/8
|
|
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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/8
|
|
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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/8a
|
|
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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/8a
|
|
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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/8
|
|
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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/8
|
|
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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/8
|
|
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/a8b35c1388affc2365ea89beead5f92a97b38de7/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/a8b35c1388affc2365ea89beead5f92a97b38de7/src/actioncode.ts#L6)
|