@actioncodes/protocol 1.1.6 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actioncode.d.ts +4 -0
- package/dist/actioncode.d.ts.map +1 -1
- package/dist/actioncode.js +3 -0
- package/dist/adapters/base.d.ts +1 -0
- package/dist/adapters/base.d.ts.map +1 -1
- package/dist/adapters/solana/solana.d.ts +8 -0
- package/dist/adapters/solana/solana.d.ts.map +1 -1
- package/dist/adapters/solana/solana.js +30 -7
- package/dist/protocol.d.ts +13 -4
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +85 -18
- package/docs/actioncode/classes/ActionCode.md +37 -23
- package/docs/actioncode/interfaces/ActionCodeFields.md +11 -11
- package/docs/actioncode/interfaces/ActionCodeMetadata.md +3 -3
- package/docs/actioncode/interfaces/ActionCodeTransaction.md +28 -4
- package/docs/actioncode/type-aliases/ActionCodeStatus.md +1 -1
- package/docs/adapters/base/classes/BaseChainAdapter.md +39 -13
- package/docs/adapters/solana/solana/classes/SolanaAdapter.md +55 -15
- 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 +68 -26
- package/docs/protocol/interfaces/ProtocolConfig.md +7 -7
- package/package.json +1 -1
package/dist/actioncode.d.ts
CHANGED
@@ -9,6 +9,9 @@ export interface ActionCodeTransaction {
|
|
9
9
|
transaction?: string;
|
10
10
|
txSignature?: string;
|
11
11
|
txType?: string;
|
12
|
+
message?: string;
|
13
|
+
signedMessage?: string;
|
14
|
+
intentType?: 'transaction' | 'sign-only';
|
12
15
|
}
|
13
16
|
export interface ActionCodeFields {
|
14
17
|
code: string;
|
@@ -111,5 +114,6 @@ export declare class ActionCode {
|
|
111
114
|
* @returns Code hash string
|
112
115
|
*/
|
113
116
|
get codeHash(): string;
|
117
|
+
get intentType(): 'transaction' | 'sign-only';
|
114
118
|
}
|
115
119
|
//# sourceMappingURL=actioncode.d.ts.map
|
package/dist/actioncode.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"actioncode.d.ts","sourceRoot":"","sources":["../src/actioncode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAGjD,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,UAAU,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC;AAE1F,MAAM,WAAW,kBAAkB;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,qBAAqB;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;
|
1
|
+
{"version":3,"file":"actioncode.d.ts","sourceRoot":"","sources":["../src/actioncode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CA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AI,aAAa,IAAI,MAAM,CAG1B;IAED;;;OAGG;IACH,IAAI,OAAO,IAAI,OAAO,CAErB;IAED;;;OAGG;IACH,IAAI,KAAK,IAAI,MAAM,CAElB;IAED;;;OAGG;IACH,IAAI,MAAM,IAAI,gBAAgB,CAE7B;IAED;;;OAGG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;OAGG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;;OAGG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;;OAGG;IACH,IAAI,WAAW,IAAI,qBAAqB,GAAG,SAAS,CAEnD;IAED;;;OAGG;IACH,IAAI,QAAQ,IAAI,gBAAgB,CAAC,UAAU,CAAC,GAAG,SAAS,CAEvD;IAED;;;OAGG;IACH,IAAI,WAAW,IAAI,MAAM,GAAG,SAAS,CAEpC;IAED;;;OAGG;IACH,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAE5C;IAED;;;OAGG;IACH,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED;;;OAGG;IACH,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED;;;OAGG;IACH,IAAI,aAAa,IAAI,MAAM,CAO1B;IAED;;;OAGG;IACH,IAAI,mBAAmB,IAAI,MAAM,CAchC;IAED;;;;OAIG;IACH,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,IAAI,UAAU,IAAI,aAAa,GAAG,WAAW,CAE5C;CACJ"}
|
package/dist/actioncode.js
CHANGED
@@ -163,5 +163,8 @@ class ActionCode {
|
|
163
163
|
get codeHash() {
|
164
164
|
return codegen_1.CodeGenerator.deriveCodeHash(this.fields.pubkey, this.fields.prefix, this.fields.timestamp);
|
165
165
|
}
|
166
|
+
get intentType() {
|
167
|
+
return this.fields.transaction?.intentType || 'transaction';
|
168
|
+
}
|
166
169
|
}
|
167
170
|
exports.ActionCode = ActionCode;
|
package/dist/adapters/base.d.ts
CHANGED
@@ -88,5 +88,6 @@ export declare abstract class BaseChainAdapter<T = any> {
|
|
88
88
|
* @returns True if the transaction is valid
|
89
89
|
*/
|
90
90
|
abstract verifyFinalizedTransaction(tx: any, actionCode: ActionCode): boolean;
|
91
|
+
abstract validateSignedMessage(message: string, signedMessage: string, pubkey: string): boolean;
|
91
92
|
}
|
92
93
|
//# 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,CAA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AAC,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;IAE7E,QAAQ,CAAC,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO;CAClG"}
|
@@ -101,5 +101,13 @@ export declare class SolanaAdapter extends BaseChainAdapter<SolanaTransaction> {
|
|
101
101
|
* @returns True if the transaction is valid and matches the action code
|
102
102
|
*/
|
103
103
|
verifyFinalizedTransaction(tx: VersionedTransactionResponse, actionCode: ActionCode): boolean;
|
104
|
+
/**
|
105
|
+
* Validate a signed message for sign-only mode
|
106
|
+
* @param message - The message that was signed
|
107
|
+
* @param signedMessage - The signed message (base64 or hex)
|
108
|
+
* @param pubkey - The public key that should have signed the message
|
109
|
+
* @returns True if the signature is valid
|
110
|
+
*/
|
111
|
+
validateSignedMessage(message: string, signedMessage: string, pubkey: string): boolean;
|
104
112
|
}
|
105
113
|
//# 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,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;AAI9C;;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,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42
|
const meta_1 = require("../../meta");
|
43
43
|
const base_1 = require("../base");
|
44
44
|
const nacl = __importStar(require("tweetnacl"));
|
45
|
+
const actioncode_1 = require("../../actioncode");
|
45
46
|
const buffer_1 = require("buffer");
|
46
47
|
const bs58_1 = __importDefault(require("bs58"));
|
47
48
|
/**
|
@@ -380,13 +381,15 @@ class SolanaAdapter extends base_1.BaseChainAdapter {
|
|
380
381
|
else {
|
381
382
|
throw new Error('Invalid transaction type');
|
382
383
|
}
|
383
|
-
const
|
384
|
-
transaction
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
384
|
+
const updatedTransaction = {
|
385
|
+
...actionCode.transaction,
|
386
|
+
transaction: tx.serialize({ requireAllSignatures: false }).toString('base64'),
|
387
|
+
};
|
388
|
+
const updatedFields = {
|
389
|
+
...actionCode.json,
|
390
|
+
transaction: updatedTransaction,
|
391
|
+
};
|
392
|
+
return actioncode_1.ActionCode.fromPayload(updatedFields);
|
390
393
|
}
|
391
394
|
catch (error) {
|
392
395
|
throw new Error(`Failed to sign transaction with protocol key: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
@@ -496,6 +499,26 @@ class SolanaAdapter extends base_1.BaseChainAdapter {
|
|
496
499
|
return false;
|
497
500
|
}
|
498
501
|
}
|
502
|
+
/**
|
503
|
+
* Validate a signed message for sign-only mode
|
504
|
+
* @param message - The message that was signed
|
505
|
+
* @param signedMessage - The signed message (base64 or hex)
|
506
|
+
* @param pubkey - The public key that should have signed the message
|
507
|
+
* @returns True if the signature is valid
|
508
|
+
*/
|
509
|
+
validateSignedMessage(message, signedMessage, pubkey) {
|
510
|
+
try {
|
511
|
+
// Decode the public key (base58)
|
512
|
+
const publicKeyBytes = bs58_1.default.decode(pubkey);
|
513
|
+
// Decode the signature as base58 (Solana convention)
|
514
|
+
const signature = bs58_1.default.decode(signedMessage);
|
515
|
+
const messageBuffer = buffer_1.Buffer.from(message, 'utf8');
|
516
|
+
return nacl.sign.detached.verify(messageBuffer, signature, publicKeyBytes);
|
517
|
+
}
|
518
|
+
catch (e) {
|
519
|
+
return false;
|
520
|
+
}
|
521
|
+
}
|
499
522
|
}
|
500
523
|
exports.SolanaAdapter = SolanaAdapter;
|
501
524
|
SolanaAdapter.MEMO_PROGRAM_ID = spl_memo_1.MEMO_PROGRAM_ID;
|
package/dist/protocol.d.ts
CHANGED
@@ -52,7 +52,7 @@ export declare class ActionCodesProtocol {
|
|
52
52
|
*/
|
53
53
|
getChainAdapter<T = any>(chain: string): BaseChainAdapter<T> | undefined;
|
54
54
|
/**
|
55
|
-
* Validate an action code
|
55
|
+
* Validate an action code, checking intent type and required fields
|
56
56
|
* @param actionCode - ActionCode to validate
|
57
57
|
* @returns True if valid
|
58
58
|
*/
|
@@ -78,12 +78,21 @@ export declare class ActionCodesProtocol {
|
|
78
78
|
*/
|
79
79
|
attachTransaction(actionCode: ActionCode, transaction: string, issuer: string, params?: string, txType?: string): ActionCode;
|
80
80
|
/**
|
81
|
-
*
|
81
|
+
* Attach a message to an action code (sign-only mode, resolved state)
|
82
|
+
* @param actionCode - ActionCode to attach message to
|
83
|
+
* @param message - The message that will be signed
|
84
|
+
* @param params - Optional parameters for protocol meta
|
85
|
+
* @param messageType - Optional message type
|
86
|
+
* @returns Updated ActionCode with transaction containing message
|
87
|
+
*/
|
88
|
+
attachMessage(actionCode: ActionCode, message: string, params?: string, messageType?: string): ActionCode;
|
89
|
+
/**
|
90
|
+
* Finalize an action code based on its intent type
|
82
91
|
* @param actionCode - ActionCode to finalize
|
83
|
-
* @param
|
92
|
+
* @param signature - Transaction signature (for transaction intent) or signed message (for sign-only intent)
|
84
93
|
* @returns Updated ActionCode
|
85
94
|
*/
|
86
|
-
finalizeActionCode(actionCode: ActionCode,
|
95
|
+
finalizeActionCode(actionCode: ActionCode, signature: string): ActionCode;
|
87
96
|
/**
|
88
97
|
* Create protocol meta for a transaction
|
89
98
|
* @param actionCode - ActionCode to create meta for
|
package/dist/protocol.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC5D,OAAO,EAAE,UAAU,EAA2C,MAAM,cAAc,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAA8D,cAAc,EAA2C,MAAM,aAAa,CAAC;AAElJ;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B,uBAAuB;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,sCAAsC;IACtC,aAAa,EAAE,MAAM,CAAC;IACtB,+BAA+B;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,4BAA4B;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,4BAA4B;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,4BAA4B;IAC5B,eAAe,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;GAKG;AACH,qBAAa,mBAAmB;IAC5B,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,QAAQ,CAAiD;gBAErD,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC;IAY5C;;;OAGG;IACH,eAAe,CAAC,CAAC,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,IAAI;IAItD;;;OAGG;IACH,mBAAmB,IAAI,MAAM,EAAE;IAI/B;;;;OAIG;IACH,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAIxC;;;;OAIG;IACH,eAAe,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAAC,CAAC,CAAC,GAAG,SAAS;IAIxE;;;;OAIG;IACH,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO;
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"A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,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EAAE,EACrB,cAAc,CAAC,EAAE,MAAM,GACxB,OAAO;IASV;;;;;OAKG;IACH,uBAAuB,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI;IAShF;;;OAGG;IACH,SAAS,IAAI,cAAc;IAI3B;;;OAGG;IACH,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI;IAIpD;;;OAGG;IACH,MAAM,CAAC,MAAM,IAAI,mBAAmB;IAIpC;;;;OAIG;IACH,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,mBAAmB;CAGhF;AAGD,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACxF,YAAY,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAG7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/protocol.js
CHANGED
@@ -55,7 +55,7 @@ class ActionCodesProtocol {
|
|
55
55
|
return this.adapters.get(chain);
|
56
56
|
}
|
57
57
|
/**
|
58
|
-
* Validate an action code
|
58
|
+
* Validate an action code, checking intent type and required fields
|
59
59
|
* @param actionCode - ActionCode to validate
|
60
60
|
* @returns True if valid
|
61
61
|
*/
|
@@ -64,11 +64,22 @@ class ActionCodesProtocol {
|
|
64
64
|
if (!this.isChainSupported(chain)) {
|
65
65
|
return false;
|
66
66
|
}
|
67
|
-
// Basic validation - check if expired
|
68
67
|
if (actionCode.expired) {
|
69
68
|
return false;
|
70
69
|
}
|
71
|
-
|
70
|
+
const tx = actionCode.transaction;
|
71
|
+
const adapter = this.getChainAdapter(chain);
|
72
|
+
// Only require transaction/message for resolved/finalized
|
73
|
+
if (actionCode.intentType === 'transaction') {
|
74
|
+
if ((actionCode.status === 'resolved' || actionCode.status === 'finalized') && (!tx || !tx.transaction))
|
75
|
+
return false;
|
76
|
+
}
|
77
|
+
else if (actionCode.intentType === 'sign-only') {
|
78
|
+
if ((actionCode.status === 'resolved' || actionCode.status === 'finalized') && (!tx || !tx.message))
|
79
|
+
return false;
|
80
|
+
if (actionCode.status === 'finalized' && (!tx || !tx.signedMessage || !adapter || !adapter.validateSignedMessage(tx.message || '', tx.signedMessage, actionCode.pubkey)))
|
81
|
+
return false;
|
82
|
+
}
|
72
83
|
return true;
|
73
84
|
}
|
74
85
|
/**
|
@@ -155,28 +166,84 @@ class ActionCodesProtocol {
|
|
155
166
|
return actioncode_1.ActionCode.fromPayload(updatedFields);
|
156
167
|
}
|
157
168
|
/**
|
158
|
-
*
|
169
|
+
* Attach a message to an action code (sign-only mode, resolved state)
|
170
|
+
* @param actionCode - ActionCode to attach message to
|
171
|
+
* @param message - The message that will be signed
|
172
|
+
* @param params - Optional parameters for protocol meta
|
173
|
+
* @param messageType - Optional message type
|
174
|
+
* @returns Updated ActionCode with transaction containing message
|
175
|
+
*/
|
176
|
+
attachMessage(actionCode, message, params, messageType) {
|
177
|
+
const chain = actionCode.chain;
|
178
|
+
if (!this.isChainSupported(chain)) {
|
179
|
+
throw new Error(`Chain '${chain}' is not supported`);
|
180
|
+
}
|
181
|
+
const adapter = this.getChainAdapter(chain);
|
182
|
+
if (!adapter) {
|
183
|
+
throw new Error(`No adapter found for chain '${chain}'`);
|
184
|
+
}
|
185
|
+
const updatedFields = {
|
186
|
+
...actionCode.json,
|
187
|
+
transaction: {
|
188
|
+
...actionCode.transaction,
|
189
|
+
message,
|
190
|
+
txType: messageType,
|
191
|
+
intentType: 'sign-only'
|
192
|
+
},
|
193
|
+
status: 'resolved',
|
194
|
+
metadata: params ? { params: JSON.parse(params) } : undefined
|
195
|
+
};
|
196
|
+
const updatedActionCode = actioncode_1.ActionCode.fromPayload(updatedFields);
|
197
|
+
if (!this.validateActionCode(updatedActionCode)) {
|
198
|
+
throw new Error('Invalid action code after attaching message');
|
199
|
+
}
|
200
|
+
return updatedActionCode;
|
201
|
+
}
|
202
|
+
/**
|
203
|
+
* Finalize an action code based on its intent type
|
159
204
|
* @param actionCode - ActionCode to finalize
|
160
|
-
* @param
|
205
|
+
* @param signature - Transaction signature (for transaction intent) or signed message (for sign-only intent)
|
161
206
|
* @returns Updated ActionCode
|
162
207
|
*/
|
163
|
-
finalizeActionCode(actionCode,
|
208
|
+
finalizeActionCode(actionCode, signature) {
|
164
209
|
const currentTransaction = actionCode.transaction;
|
165
210
|
if (!currentTransaction) {
|
166
211
|
throw new Error('Cannot finalize ActionCode without attached transaction');
|
167
212
|
}
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
213
|
+
if (actionCode.intentType === 'transaction') {
|
214
|
+
// Transaction intent: require txSignature
|
215
|
+
const updatedTransaction = {
|
216
|
+
...currentTransaction,
|
217
|
+
txSignature: signature,
|
218
|
+
intentType: 'transaction'
|
219
|
+
};
|
220
|
+
const updatedFields = {
|
221
|
+
...actionCode.json,
|
222
|
+
transaction: updatedTransaction,
|
223
|
+
status: 'finalized'
|
224
|
+
};
|
225
|
+
return actioncode_1.ActionCode.fromPayload(updatedFields);
|
226
|
+
}
|
227
|
+
else if (actionCode.intentType === 'sign-only') {
|
228
|
+
// Sign-only intent: require signedMessage
|
229
|
+
if (!currentTransaction.signedMessage && !signature) {
|
230
|
+
throw new Error('Cannot finalize sign-only ActionCode without signed message');
|
231
|
+
}
|
232
|
+
const updatedTransaction = {
|
233
|
+
...currentTransaction,
|
234
|
+
signedMessage: signature,
|
235
|
+
intentType: 'sign-only'
|
236
|
+
};
|
237
|
+
const updatedFields = {
|
238
|
+
...actionCode.json,
|
239
|
+
transaction: updatedTransaction,
|
240
|
+
status: 'finalized'
|
241
|
+
};
|
242
|
+
return actioncode_1.ActionCode.fromPayload(updatedFields);
|
243
|
+
}
|
244
|
+
else {
|
245
|
+
throw new Error('Unknown intent type for ActionCode finalization');
|
246
|
+
}
|
180
247
|
}
|
181
248
|
/**
|
182
249
|
* Create protocol meta for a transaction
|
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
# Class: ActionCode
|
8
8
|
|
9
|
-
Defined in: [actioncode.ts:
|
9
|
+
Defined in: [actioncode.ts:35](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L35)
|
10
10
|
|
11
11
|
## Constructors
|
12
12
|
|
@@ -14,7 +14,7 @@ Defined in: [actioncode.ts:32](https://github.com/otaprotocol/actioncodes/blob/a
|
|
14
14
|
|
15
15
|
> **new ActionCode**(`fields`): `ActionCode`
|
16
16
|
|
17
|
-
Defined in: [actioncode.ts:
|
17
|
+
Defined in: [actioncode.ts:36](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L36)
|
18
18
|
|
19
19
|
#### Parameters
|
20
20
|
|
@@ -34,7 +34,7 @@ Defined in: [actioncode.ts:33](https://github.com/otaprotocol/actioncodes/blob/a
|
|
34
34
|
|
35
35
|
> **get** **chain**(): `string`
|
36
36
|
|
37
|
-
Defined in: [actioncode.ts:
|
37
|
+
Defined in: [actioncode.ts:98](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L98)
|
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:
|
55
|
+
Defined in: [actioncode.ts:114](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L114)
|
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:
|
73
|
+
Defined in: [actioncode.ts:220](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L220)
|
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:
|
92
|
+
Defined in: [actioncode.ts:154](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L154)
|
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:
|
110
|
+
Defined in: [actioncode.ts:186](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L186)
|
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:
|
128
|
+
Defined in: [actioncode.ts:50](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L50)
|
129
129
|
|
130
130
|
##### Returns
|
131
131
|
|
@@ -139,7 +139,7 @@ Defined in: [actioncode.ts:47](https://github.com/otaprotocol/actioncodes/blob/a
|
|
139
139
|
|
140
140
|
> **get** **expired**(): `boolean`
|
141
141
|
|
142
|
-
Defined in: [actioncode.ts:
|
142
|
+
Defined in: [actioncode.ts:90](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L90)
|
143
143
|
|
144
144
|
Check if the action code has expired
|
145
145
|
|
@@ -151,13 +151,27 @@ True if the code has expired
|
|
151
151
|
|
152
152
|
***
|
153
153
|
|
154
|
+
### intentType
|
155
|
+
|
156
|
+
#### Get Signature
|
157
|
+
|
158
|
+
> **get** **intentType**(): `"transaction"` \| `"sign-only"`
|
159
|
+
|
160
|
+
Defined in: [actioncode.ts:224](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L224)
|
161
|
+
|
162
|
+
##### Returns
|
163
|
+
|
164
|
+
`"transaction"` \| `"sign-only"`
|
165
|
+
|
166
|
+
***
|
167
|
+
|
154
168
|
### json
|
155
169
|
|
156
170
|
#### Get Signature
|
157
171
|
|
158
172
|
> **get** **json**(): [`ActionCodeFields`](../interfaces/ActionCodeFields.md)
|
159
173
|
|
160
|
-
Defined in: [actioncode.ts:
|
174
|
+
Defined in: [actioncode.ts:71](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L71)
|
161
175
|
|
162
176
|
##### Returns
|
163
177
|
|
@@ -171,7 +185,7 @@ Defined in: [actioncode.ts:68](https://github.com/otaprotocol/actioncodes/blob/a
|
|
171
185
|
|
172
186
|
> **get** **metadata**(): `undefined` \| [`ActionCodeMetadata`](../interfaces/ActionCodeMetadata.md)
|
173
187
|
|
174
|
-
Defined in: [actioncode.ts:
|
188
|
+
Defined in: [actioncode.ts:146](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L146)
|
175
189
|
|
176
190
|
Get metadata associated with this action code
|
177
191
|
|
@@ -189,7 +203,7 @@ Metadata object or undefined
|
|
189
203
|
|
190
204
|
> **get** **params**(): `undefined` \| `Record`\<`string`, `any`\>
|
191
205
|
|
192
|
-
Defined in: [actioncode.ts:
|
206
|
+
Defined in: [actioncode.ts:162](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L162)
|
193
207
|
|
194
208
|
Get parameters associated with this action
|
195
209
|
|
@@ -207,7 +221,7 @@ Parameters object or undefined
|
|
207
221
|
|
208
222
|
> **get** **prefix**(): `string`
|
209
223
|
|
210
|
-
Defined in: [actioncode.ts:
|
224
|
+
Defined in: [actioncode.ts:122](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L122)
|
211
225
|
|
212
226
|
Get the prefix used for this action code
|
213
227
|
|
@@ -225,7 +239,7 @@ Normalized prefix
|
|
225
239
|
|
226
240
|
> **get** **pubkey**(): `string`
|
227
241
|
|
228
|
-
Defined in: [actioncode.ts:
|
242
|
+
Defined in: [actioncode.ts:130](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L130)
|
229
243
|
|
230
244
|
Get the user's public key
|
231
245
|
|
@@ -243,7 +257,7 @@ User's public key
|
|
243
257
|
|
244
258
|
> **get** **remainingTime**(): `number`
|
245
259
|
|
246
|
-
Defined in: [actioncode.ts:
|
260
|
+
Defined in: [actioncode.ts:81](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L81)
|
247
261
|
|
248
262
|
Get remaining time in milliseconds until expiration
|
249
263
|
|
@@ -261,7 +275,7 @@ Remaining time in milliseconds, or 0 if expired
|
|
261
275
|
|
262
276
|
> **get** **remainingTimeString**(): `string`
|
263
277
|
|
264
|
-
Defined in: [actioncode.ts:
|
278
|
+
Defined in: [actioncode.ts:199](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L199)
|
265
279
|
|
266
280
|
Get a formatted time string showing remaining time
|
267
281
|
|
@@ -279,7 +293,7 @@ Human-readable time string (e.g., "1m 30s remaining")
|
|
279
293
|
|
280
294
|
> **get** **signature**(): `string`
|
281
295
|
|
282
|
-
Defined in: [actioncode.ts:
|
296
|
+
Defined in: [actioncode.ts:178](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L178)
|
283
297
|
|
284
298
|
Get the user's signature
|
285
299
|
|
@@ -297,7 +311,7 @@ User's signature string
|
|
297
311
|
|
298
312
|
> **get** **status**(): [`ActionCodeStatus`](../type-aliases/ActionCodeStatus.md)
|
299
313
|
|
300
|
-
Defined in: [actioncode.ts:
|
314
|
+
Defined in: [actioncode.ts:106](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L106)
|
301
315
|
|
302
316
|
Get the current status of the action code
|
303
317
|
|
@@ -315,7 +329,7 @@ Current status
|
|
315
329
|
|
316
330
|
> **get** **timestamp**(): `number`
|
317
331
|
|
318
|
-
Defined in: [actioncode.ts:
|
332
|
+
Defined in: [actioncode.ts:170](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L170)
|
319
333
|
|
320
334
|
Get the timestamp when the code was generated
|
321
335
|
|
@@ -333,7 +347,7 @@ Timestamp in milliseconds
|
|
333
347
|
|
334
348
|
> **get** **transaction**(): `undefined` \| [`ActionCodeTransaction`](../interfaces/ActionCodeTransaction.md)
|
335
349
|
|
336
|
-
Defined in: [actioncode.ts:
|
350
|
+
Defined in: [actioncode.ts:138](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L138)
|
337
351
|
|
338
352
|
Get the transaction data (chain-specific)
|
339
353
|
|
@@ -349,7 +363,7 @@ Transaction data or undefined
|
|
349
363
|
|
350
364
|
> **isValid**(`protocol`): `boolean`
|
351
365
|
|
352
|
-
Defined in: [actioncode.ts:
|
366
|
+
Defined in: [actioncode.ts:54](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L54)
|
353
367
|
|
354
368
|
#### Parameters
|
355
369
|
|
@@ -367,7 +381,7 @@ Defined in: [actioncode.ts:51](https://github.com/otaprotocol/actioncodes/blob/a
|
|
367
381
|
|
368
382
|
> `static` **fromEncoded**(`encoded`): `ActionCode`
|
369
383
|
|
370
|
-
Defined in: [actioncode.ts:
|
384
|
+
Defined in: [actioncode.ts:45](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L45)
|
371
385
|
|
372
386
|
#### Parameters
|
373
387
|
|
@@ -385,7 +399,7 @@ Defined in: [actioncode.ts:42](https://github.com/otaprotocol/actioncodes/blob/a
|
|
385
399
|
|
386
400
|
> `static` **fromPayload**(`input`): `ActionCode`
|
387
401
|
|
388
|
-
Defined in: [actioncode.ts:
|
402
|
+
Defined in: [actioncode.ts:38](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L38)
|
389
403
|
|
390
404
|
#### Parameters
|
391
405
|
|
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
# Interface: ActionCodeFields
|
8
8
|
|
9
|
-
Defined in: [actioncode.ts:
|
9
|
+
Defined in: [actioncode.ts:22](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L22)
|
10
10
|
|
11
11
|
## Properties
|
12
12
|
|
@@ -14,7 +14,7 @@ Defined in: [actioncode.ts:19](https://github.com/otaprotocol/actioncodes/blob/a
|
|
14
14
|
|
15
15
|
> **chain**: `"solana"`
|
16
16
|
|
17
|
-
Defined in: [actioncode.ts:
|
17
|
+
Defined in: [actioncode.ts:28](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L28)
|
18
18
|
|
19
19
|
***
|
20
20
|
|
@@ -22,7 +22,7 @@ Defined in: [actioncode.ts:25](https://github.com/otaprotocol/actioncodes/blob/a
|
|
22
22
|
|
23
23
|
> **code**: `string`
|
24
24
|
|
25
|
-
Defined in: [actioncode.ts:
|
25
|
+
Defined in: [actioncode.ts:23](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L23)
|
26
26
|
|
27
27
|
***
|
28
28
|
|
@@ -30,7 +30,7 @@ Defined in: [actioncode.ts:20](https://github.com/otaprotocol/actioncodes/blob/a
|
|
30
30
|
|
31
31
|
> **expiresAt**: `number`
|
32
32
|
|
33
|
-
Defined in: [actioncode.ts:
|
33
|
+
Defined in: [actioncode.ts:31](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L31)
|
34
34
|
|
35
35
|
***
|
36
36
|
|
@@ -38,7 +38,7 @@ Defined in: [actioncode.ts:28](https://github.com/otaprotocol/actioncodes/blob/a
|
|
38
38
|
|
39
39
|
> `optional` **metadata**: [`ActionCodeMetadata`](ActionCodeMetadata.md)
|
40
40
|
|
41
|
-
Defined in: [actioncode.ts:
|
41
|
+
Defined in: [actioncode.ts:30](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L30)
|
42
42
|
|
43
43
|
***
|
44
44
|
|
@@ -46,7 +46,7 @@ Defined in: [actioncode.ts:27](https://github.com/otaprotocol/actioncodes/blob/a
|
|
46
46
|
|
47
47
|
> **prefix**: `string`
|
48
48
|
|
49
|
-
Defined in: [actioncode.ts:
|
49
|
+
Defined in: [actioncode.ts:24](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L24)
|
50
50
|
|
51
51
|
***
|
52
52
|
|
@@ -54,7 +54,7 @@ Defined in: [actioncode.ts:21](https://github.com/otaprotocol/actioncodes/blob/a
|
|
54
54
|
|
55
55
|
> **pubkey**: `string`
|
56
56
|
|
57
|
-
Defined in: [actioncode.ts:
|
57
|
+
Defined in: [actioncode.ts:25](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L25)
|
58
58
|
|
59
59
|
***
|
60
60
|
|
@@ -62,7 +62,7 @@ Defined in: [actioncode.ts:22](https://github.com/otaprotocol/actioncodes/blob/a
|
|
62
62
|
|
63
63
|
> **signature**: `string`
|
64
64
|
|
65
|
-
Defined in: [actioncode.ts:
|
65
|
+
Defined in: [actioncode.ts:27](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L27)
|
66
66
|
|
67
67
|
***
|
68
68
|
|
@@ -70,7 +70,7 @@ Defined in: [actioncode.ts:24](https://github.com/otaprotocol/actioncodes/blob/a
|
|
70
70
|
|
71
71
|
> **status**: [`ActionCodeStatus`](../type-aliases/ActionCodeStatus.md)
|
72
72
|
|
73
|
-
Defined in: [actioncode.ts:
|
73
|
+
Defined in: [actioncode.ts:32](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L32)
|
74
74
|
|
75
75
|
***
|
76
76
|
|
@@ -78,7 +78,7 @@ Defined in: [actioncode.ts:29](https://github.com/otaprotocol/actioncodes/blob/a
|
|
78
78
|
|
79
79
|
> **timestamp**: `number`
|
80
80
|
|
81
|
-
Defined in: [actioncode.ts:
|
81
|
+
Defined in: [actioncode.ts:26](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L26)
|
82
82
|
|
83
83
|
***
|
84
84
|
|
@@ -86,4 +86,4 @@ Defined in: [actioncode.ts:23](https://github.com/otaprotocol/actioncodes/blob/a
|
|
86
86
|
|
87
87
|
> `optional` **transaction**: [`ActionCodeTransaction`](ActionCodeTransaction.md)
|
88
88
|
|
89
|
-
Defined in: [actioncode.ts:
|
89
|
+
Defined in: [actioncode.ts:29](https://github.com/otaprotocol/actioncodes/blob/d0ef10ae3bd279eafa4f9f7708c521c6ab240398/src/actioncode.ts#L29)
|