catapultar 0.1.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.
Files changed (67) hide show
  1. package/LICENSE +165 -0
  2. package/README.md +161 -0
  3. package/dist/abi/CATValidator.d.ts +174 -0
  4. package/dist/abi/CATValidator.d.ts.map +1 -0
  5. package/dist/abi/CATValidator.js +225 -0
  6. package/dist/abi/CATValidator.js.map +1 -0
  7. package/dist/abi/catapultarFactoryV0.0.1.d.ts +2 -0
  8. package/dist/abi/catapultarFactoryV0.0.1.d.ts.map +1 -0
  9. package/dist/abi/catapultarFactoryV0.0.1.js +1 -0
  10. package/dist/abi/catapultarFactoryV0.0.1.js.map +1 -0
  11. package/dist/abi/catapultarFactoryV0.1.0.d.ts +175 -0
  12. package/dist/abi/catapultarFactoryV0.1.0.d.ts.map +1 -0
  13. package/dist/abi/catapultarFactoryV0.1.0.js +229 -0
  14. package/dist/abi/catapultarFactoryV0.1.0.js.map +1 -0
  15. package/dist/abi/catapultarV0.0.1.d.ts +2 -0
  16. package/dist/abi/catapultarV0.0.1.d.ts.map +1 -0
  17. package/dist/abi/catapultarV0.0.1.js +1 -0
  18. package/dist/abi/catapultarV0.0.1.js.map +1 -0
  19. package/dist/abi/catapultarV0.1.0.d.ts +409 -0
  20. package/dist/abi/catapultarV0.1.0.d.ts.map +1 -0
  21. package/dist/abi/catapultarV0.1.0.js +528 -0
  22. package/dist/abi/catapultarV0.1.0.js.map +1 -0
  23. package/dist/abi/mockerc20.d.ts +342 -0
  24. package/dist/abi/mockerc20.d.ts.map +1 -0
  25. package/dist/abi/mockerc20.js +443 -0
  26. package/dist/abi/mockerc20.js.map +1 -0
  27. package/dist/catapultar/account.d.ts +86 -0
  28. package/dist/catapultar/account.d.ts.map +1 -0
  29. package/dist/catapultar/account.js +408 -0
  30. package/dist/catapultar/account.js.map +1 -0
  31. package/dist/catapultar/catapultar.d.ts +143 -0
  32. package/dist/catapultar/catapultar.d.ts.map +1 -0
  33. package/dist/catapultar/catapultar.js +200 -0
  34. package/dist/catapultar/catapultar.js.map +1 -0
  35. package/dist/config.d.ts +14 -0
  36. package/dist/config.d.ts.map +1 -0
  37. package/dist/config.js +24 -0
  38. package/dist/config.js.map +1 -0
  39. package/dist/index.d.ts +7 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +6 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/transaction/constrainedtransaction.d.ts +57 -0
  44. package/dist/transaction/constrainedtransaction.d.ts.map +1 -0
  45. package/dist/transaction/constrainedtransaction.js +191 -0
  46. package/dist/transaction/constrainedtransaction.js.map +1 -0
  47. package/dist/transaction/transaction.d.ts +88 -0
  48. package/dist/transaction/transaction.d.ts.map +1 -0
  49. package/dist/transaction/transaction.js +185 -0
  50. package/dist/transaction/transaction.js.map +1 -0
  51. package/dist/types/types.d.ts +144 -0
  52. package/dist/types/types.d.ts.map +1 -0
  53. package/dist/types/types.js +53 -0
  54. package/dist/types/types.js.map +1 -0
  55. package/dist/utils/helpers.d.ts +31 -0
  56. package/dist/utils/helpers.d.ts.map +1 -0
  57. package/dist/utils/helpers.js +65 -0
  58. package/dist/utils/helpers.js.map +1 -0
  59. package/dist/utils/signature.d.ts +3 -0
  60. package/dist/utils/signature.d.ts.map +1 -0
  61. package/dist/utils/signature.js +10 -0
  62. package/dist/utils/signature.js.map +1 -0
  63. package/dist/utils/viem.d.ts +3 -0
  64. package/dist/utils/viem.d.ts.map +1 -0
  65. package/dist/utils/viem.js +10 -0
  66. package/dist/utils/viem.js.map +1 -0
  67. package/package.json +63 -0
package/LICENSE ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
package/README.md ADDED
@@ -0,0 +1,161 @@
1
+ ## Catapultar Typescript Library
2
+
3
+ Catapultar is a compact TypeScript library for managing Catapultar smart accounts. It provides a reliable and portable wrapper around account and transaction flows to build, sign, and execute account-level operations reliably.
4
+
5
+ ## Key Features
6
+ - Utilities for interacting with the Catapultar smart account
7
+ - Ethers and viem compatibility.
8
+ - Natural language transaction creation.
9
+ - Helpers for account and factory interactions to simplify common tasks
10
+
11
+ ### Library Structure
12
+
13
+ 4 Main classes are exported:
14
+ - **BaseTransaction** — Minimal transaction interface without validation.
15
+ - **CatapultarAccount** — Catapultar Smart Account management.
16
+ - **CatapultarTx** — Creating transaction for existing smart accounts.
17
+ - **MetaCatapultarTx** — High level batch transactions.
18
+
19
+ Depending on your use case, you may prefer either a high level or low level transaction creation.
20
+
21
+ - **CatapultarTx** depends on **BaseTransaction** and **CatapultarAccount**.
22
+ - **MetaCatapultarTx** depends on **CatapultarTx**
23
+
24
+ ## Installation
25
+ This repository uses Bun. From the project root, install dependencies with:
26
+
27
+ ```bash
28
+ bun install
29
+ ```
30
+
31
+ ## Usage (Overview)
32
+ Catapultar is RPC-less by default. If an RPC is provided to the library, validation will be enhanced with on-chain information including:
33
+ - Nonce validation
34
+ - Account version selection
35
+ - Simulation
36
+ - EIP-1271 signature validation
37
+ - Get deployed transactions in transaction.
38
+
39
+ Catapultar is verioned, meaning accounts can be versioned to their respective version. Unless an RPC is provided to the library, it is important that the version of the account is provided to explicitly enable or disable flows.
40
+
41
+ ### Actionables (Signables and Executables)
42
+ While Catapultar uses viem under-the-hood, you need to bring your own execution and signing service / library. Catapultar exports actionable objects as either `Signable`-ish or `Executable` which are directly compatible with viem and almost directly compatible into Ethers. If you are using external signers, you need to port these objects.
43
+
44
+ Signable objects are exported as:
45
+ ```typescript
46
+ type Signable = {
47
+ domain: {
48
+ name: string;
49
+ version: string;
50
+ chainId?: bigint;
51
+ verifyingContract: `0x${string}`;
52
+ };
53
+ types: { /** Universal typed const */ };
54
+ primaryType: string;
55
+ message: { /** Typed Message */};
56
+ }
57
+ ```
58
+ Note that Ether's "`Signable`" looks like:
59
+ ```typescript
60
+ type EthersSignable = {
61
+ domain: {
62
+ name: string;
63
+ version: string;
64
+ chainId?: bigint;
65
+ verifyingContract: `0x${string}`;
66
+ };
67
+ types: { /** Universal typed const */ };
68
+ data: { /** Typed Message */};
69
+ }
70
+ ```
71
+
72
+ Executable objects are exported as:
73
+ ```typescript
74
+ type Executable = {
75
+ to: `0x${string}`;
76
+ value: bigint;
77
+ data: `0x${string}`;
78
+ }
79
+ ```
80
+
81
+ ### Account deploy
82
+
83
+ TODO
84
+
85
+ ### Transaction Creation
86
+
87
+ ```typescript
88
+ const account = {
89
+ address,
90
+ chainId,
91
+ owner,
92
+ }
93
+ CatapultarTx;
94
+
95
+ const tx = new CatapultarTx({account});
96
+ const call = (await tx.addCalls(...calls).sign((v) => viemWalletClient.signTypedData({account, ...v}))).asCall();
97
+
98
+ viemWalletClient.sendTransaction({
99
+ account,
100
+ ...call // unpack call into viem.
101
+ });
102
+ ```
103
+
104
+ ### Embed
105
+
106
+ In some cases, you may want to execute an action on behalf of another user — they are the primary custodian but a pre-approved call has been configured.
107
+ Catapultar can be configured for this use case by embedded a call (or signature) digest.
108
+
109
+ To create embedded accounts, use **BaseTransaction**.
110
+
111
+ ```typescript
112
+ const embeddedCalls: {to: `0x${string}`, data: `0x${string}`, value: bigint}[];
113
+
114
+ const tx = new BaseTransaction();
115
+
116
+ tx.setRandomNonce();
117
+ tx.setMode(ExecutionMode.RaiseRevert);
118
+ tx.addCalls(...embeddedCalls);
119
+
120
+
121
+ const context = tx.asAccount(...);
122
+ // {
123
+ // deployCall // Call to deploy the account. Save, if lost account may not be recoverable.
124
+ // actionCall, // Call to call on the account.
125
+ // callDigest, // Digest of the embedded call. Can be ignored.
126
+ // address, // Address of the contract once deployed.
127
+ // }
128
+ ```
129
+
130
+ ### Constrained Asset Transaction (CAT)
131
+
132
+ CATs are transactions that can be executed using an account's assets given a certain output. In an intent factory use case, you may want to generate an account with a CAT embedded to later execute arbitrary data against it.
133
+
134
+ To create a CAT use **ConstrainedAssetTransaction**. You can then convert it to a **BaseTransaction** to get the embedded account.
135
+
136
+ ```typescript
137
+ const executor: `0x${string}`;
138
+ const allowances: { token: `0x${string}`; amount: bigint; }[];
139
+ const outcomes: { token: `0x${string}`; amount: bigint; destination: `0x${string}` }[];
140
+
141
+ const cat = new ConstrainedAssetTransaction({executor});
142
+ cat.addAllowances(...allowances);
143
+ cat.addOutcomes(...outcomes);
144
+
145
+ const tx = tx.asCatapultarAllowanceTransaction();
146
+ const context = tx.asAccount(...);
147
+
148
+ const entryCall = tx.asExecuteCall({address: context.address, ...})
149
+
150
+ // then you need to execute [context.deployCall, context.actionCall, entryCall]
151
+ ```
152
+
153
+ See `src/transaction/constrainedtransaction.spec.ts::create account and execute contained constraints` for an example.
154
+
155
+ ## Project Layout
156
+ - `src/catapultar/` — core account and factory logic
157
+ - `src/transaction/` — low level transaction logic
158
+ - `src/abi/` — Contract ABIs
159
+ - `src/types/` — shared TypeScript types
160
+ - `src/utils/` — helper utilities
161
+
@@ -0,0 +1,174 @@
1
+ export declare const CAT_VALIDATOR_ABI: readonly [{
2
+ readonly type: "constructor";
3
+ readonly inputs: readonly [];
4
+ readonly stateMutability: "nonpayable";
5
+ }, {
6
+ readonly type: "function";
7
+ readonly name: "CALL_PROXY";
8
+ readonly inputs: readonly [];
9
+ readonly outputs: readonly [{
10
+ readonly name: "";
11
+ readonly type: "address";
12
+ readonly internalType: "address";
13
+ }];
14
+ readonly stateMutability: "view";
15
+ }, {
16
+ readonly type: "function";
17
+ readonly name: "DOMAIN_SEPARATOR";
18
+ readonly inputs: readonly [];
19
+ readonly outputs: readonly [{
20
+ readonly name: "";
21
+ readonly type: "bytes32";
22
+ readonly internalType: "bytes32";
23
+ }];
24
+ readonly stateMutability: "view";
25
+ }, {
26
+ readonly type: "function";
27
+ readonly name: "eip712Domain";
28
+ readonly inputs: readonly [];
29
+ readonly outputs: readonly [{
30
+ readonly name: "fields";
31
+ readonly type: "bytes1";
32
+ readonly internalType: "bytes1";
33
+ }, {
34
+ readonly name: "name";
35
+ readonly type: "string";
36
+ readonly internalType: "string";
37
+ }, {
38
+ readonly name: "version";
39
+ readonly type: "string";
40
+ readonly internalType: "string";
41
+ }, {
42
+ readonly name: "chainId";
43
+ readonly type: "uint256";
44
+ readonly internalType: "uint256";
45
+ }, {
46
+ readonly name: "verifyingContract";
47
+ readonly type: "address";
48
+ readonly internalType: "address";
49
+ }, {
50
+ readonly name: "salt";
51
+ readonly type: "bytes32";
52
+ readonly internalType: "bytes32";
53
+ }, {
54
+ readonly name: "extensions";
55
+ readonly type: "uint256[]";
56
+ readonly internalType: "uint256[]";
57
+ }];
58
+ readonly stateMutability: "view";
59
+ }, {
60
+ readonly type: "function";
61
+ readonly name: "entry";
62
+ readonly inputs: readonly [{
63
+ readonly name: "execTarget";
64
+ readonly type: "address";
65
+ readonly internalType: "address";
66
+ }, {
67
+ readonly name: "execPayload";
68
+ readonly type: "bytes";
69
+ readonly internalType: "bytes";
70
+ }, {
71
+ readonly name: "account";
72
+ readonly type: "address";
73
+ readonly internalType: "address";
74
+ }, {
75
+ readonly name: "nonce";
76
+ readonly type: "uint256";
77
+ readonly internalType: "uint256";
78
+ }, {
79
+ readonly name: "allowances";
80
+ readonly type: "tuple[]";
81
+ readonly internalType: "struct AllowanceSpend[]";
82
+ readonly components: readonly [{
83
+ readonly name: "token";
84
+ readonly type: "address";
85
+ readonly internalType: "address";
86
+ }, {
87
+ readonly name: "allocated";
88
+ readonly type: "uint256";
89
+ readonly internalType: "uint256";
90
+ }, {
91
+ readonly name: "spend";
92
+ readonly type: "uint256";
93
+ readonly internalType: "uint256";
94
+ }];
95
+ }, {
96
+ readonly name: "outcomes";
97
+ readonly type: "tuple[]";
98
+ readonly internalType: "struct Outcome[]";
99
+ readonly components: readonly [{
100
+ readonly name: "token";
101
+ readonly type: "address";
102
+ readonly internalType: "address";
103
+ }, {
104
+ readonly name: "amount";
105
+ readonly type: "uint256";
106
+ readonly internalType: "uint256";
107
+ }, {
108
+ readonly name: "destination";
109
+ readonly type: "address";
110
+ readonly internalType: "address";
111
+ }];
112
+ }, {
113
+ readonly name: "signature";
114
+ readonly type: "bytes";
115
+ readonly internalType: "bytes";
116
+ }];
117
+ readonly outputs: readonly [];
118
+ readonly stateMutability: "nonpayable";
119
+ }, {
120
+ readonly type: "function";
121
+ readonly name: "spentNonces";
122
+ readonly inputs: readonly [{
123
+ readonly name: "";
124
+ readonly type: "address";
125
+ readonly internalType: "address";
126
+ }, {
127
+ readonly name: "";
128
+ readonly type: "uint256";
129
+ readonly internalType: "uint256";
130
+ }];
131
+ readonly outputs: readonly [{
132
+ readonly name: "";
133
+ readonly type: "bool";
134
+ readonly internalType: "bool";
135
+ }];
136
+ readonly stateMutability: "view";
137
+ }, {
138
+ readonly type: "error";
139
+ readonly name: "AllocationTooSmall";
140
+ readonly inputs: readonly [{
141
+ readonly name: "allocated";
142
+ readonly type: "uint256";
143
+ readonly internalType: "uint256";
144
+ }, {
145
+ readonly name: "spend";
146
+ readonly type: "uint256";
147
+ readonly internalType: "uint256";
148
+ }];
149
+ }, {
150
+ readonly type: "error";
151
+ readonly name: "BadSignature";
152
+ readonly inputs: readonly [];
153
+ }, {
154
+ readonly type: "error";
155
+ readonly name: "InvalidTokenAmount";
156
+ readonly inputs: readonly [{
157
+ readonly name: "expected";
158
+ readonly type: "uint256";
159
+ readonly internalType: "uint256";
160
+ }, {
161
+ readonly name: "received";
162
+ readonly type: "uint256";
163
+ readonly internalType: "uint256";
164
+ }];
165
+ }, {
166
+ readonly type: "error";
167
+ readonly name: "NonceAlreadySpent";
168
+ readonly inputs: readonly [];
169
+ }, {
170
+ readonly type: "error";
171
+ readonly name: "Reentrancy";
172
+ readonly inputs: readonly [];
173
+ }];
174
+ //# sourceMappingURL=CATValidator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CATValidator.d.ts","sourceRoot":"","sources":["../../src/abi/CATValidator.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+NpB,CAAC"}