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
@@ -0,0 +1,185 @@
1
+ import { encodeAbiParameters, encodeFunctionData, hashStruct } from "viem";
2
+ import { AccountPublicKeyType, CallsTyped, ExecutionMode, } from "../types/types.js";
3
+ import { asHex, pubkeyAsArray, random } from "../utils/helpers.js";
4
+ import { toCompactSignature } from "../utils/signature.js";
5
+ import { CatapultarAccount } from "../catapultar/account.js";
6
+ import CATAPULTAR_FACTORY_V0_1_0_ABI from "../abi/catapultarFactoryV0.1.0.js";
7
+ import CATAPULTAR_V0_1_0_ABI from "../abi/catapultarV0.1.0.js";
8
+ import { _factory } from "../config.js";
9
+ export class BaseTransaction {
10
+ constructor(opt) {
11
+ const { mode, nonce, calls = [], signature } = opt ?? {};
12
+ this.mode = mode;
13
+ this.nonce = nonce;
14
+ this.calls = calls;
15
+ this.signature = signature;
16
+ }
17
+ // --- Modify the existing transaction. This allows you to change how it has been defined --- //
18
+ /**
19
+ * Set the transaction nonce for the Catapultar transaction. Only 1 transaction can ever be executed for each nonce.
20
+ */
21
+ setNonce(nonce) {
22
+ if (nonce === 0n)
23
+ throw new Error(`Nonce 0 is not allowed. It cannot be differentiated from an invalid nonce.`);
24
+ this.nonce = nonce;
25
+ return this;
26
+ }
27
+ /**
28
+ * Generates a random uint256 nonce and sets it.
29
+ */
30
+ setRandomNonce() {
31
+ return this.setNonce(BigInt(random(32)));
32
+ }
33
+ /**
34
+ * Sets the Catapultar transaction mode.
35
+ */
36
+ setMode(mode) {
37
+ this.mode = mode;
38
+ return this;
39
+ }
40
+ /**
41
+ * Adds list of calls to the Catapultar transaction. The calls will be executed with the configured mode.
42
+ */
43
+ addCall(...calls) {
44
+ for (const call of calls) {
45
+ this.calls.push(call);
46
+ }
47
+ return this;
48
+ }
49
+ // --- Read objects relating to its construction --- ///
50
+ /**
51
+ * @returns Total value of all contained calls.
52
+ */
53
+ getTotalValue() {
54
+ return this.calls.map((c) => c.value).reduce((a, b) => a + b, 0n);
55
+ }
56
+ // --- Validation --- //
57
+ hasValidMode() {
58
+ if (this.mode === undefined)
59
+ return false;
60
+ return Object.values(ExecutionMode).includes(this.mode);
61
+ }
62
+ /**
63
+ * @returns Whether the a multichain execution mode is set.
64
+ */
65
+ hasMultichainMode() {
66
+ return (this.mode === ExecutionMode.RaiseRevertMultiChain ||
67
+ this.mode === ExecutionMode.SkipRevertMultiChain);
68
+ }
69
+ /**
70
+ * Returns the signature as a compact signature of 64 bytes instead of 65 bytes.
71
+ *
72
+ * @param Signature If provided, will act on the provided signature instead.
73
+ */
74
+ asCompactSignature(signature) {
75
+ const sig = signature ?? this.signature;
76
+ if (!sig)
77
+ throw new Error("A signature has to be provided");
78
+ if (sig.replace("0x", "").length === 64 * 2)
79
+ return sig;
80
+ // If this is not an ECDSA sig, lets not touch it.
81
+ if (sig.replace("0x", "").length !== 65 * 2)
82
+ return sig;
83
+ return toCompactSignature(sig);
84
+ }
85
+ /**
86
+ * @dev Opdata is nonce + signature packed.
87
+ * If no signature has been provided to the object, it will create the transaction without a signatures. This can be used to sub-batch the transaction.
88
+ */
89
+ getOpData(options) {
90
+ if (this.nonce === 0n)
91
+ throw new Error("Nonce 0 is not allowed. It cannot be differentiated from an invalid nonce.");
92
+ if (!this.nonce)
93
+ throw new Error("No nonce has been set");
94
+ const { compactSignature = true } = options ?? {};
95
+ if (this.signature) {
96
+ this.signature = compactSignature
97
+ ? this.asCompactSignature()
98
+ : this.signature;
99
+ }
100
+ if (this.signature) {
101
+ return `0x${asHex(this.nonce, 32)}${this.signature.replace("0x", "")}`;
102
+ }
103
+ else {
104
+ return asHex(this.nonce, 32, "0x");
105
+ }
106
+ }
107
+ getExecutionData() {
108
+ return encodeAbiParameters([{ type: "tuple[]", components: CallsTyped.Call }, { type: "bytes" }], [this.calls, this.getOpData()]);
109
+ }
110
+ // --- Convert the transaction object into actionable items --- //
111
+ /** @return As parameters for an execute call. */
112
+ asParameters() {
113
+ return {
114
+ mode: this.mode,
115
+ executionData: this.getExecutionData(),
116
+ metadata: {
117
+ value: this.getTotalValue(),
118
+ signature: this.signature,
119
+ },
120
+ };
121
+ }
122
+ /**
123
+ * @return As a call for further scheduling or manual transaction signing. If used for manual transaction.
124
+ */
125
+ asCallData() {
126
+ if (!this.hasValidMode())
127
+ throw new Error(`Mode incorrectly set: ${this.mode}`);
128
+ const executionData = this.getExecutionData();
129
+ const data = encodeFunctionData({
130
+ abi: CATAPULTAR_V0_1_0_ABI,
131
+ functionName: "execute",
132
+ args: [this.mode, executionData],
133
+ });
134
+ return {
135
+ value: 0n,
136
+ data,
137
+ };
138
+ }
139
+ /** Return the calls as an approval diget. This can be used to "embed" the calls into an account */
140
+ asDigest() {
141
+ if (this.nonce === 0n)
142
+ throw new Error(`Nonce 0 is not allowed. It cannot be differentiated from an invalid nonce.`);
143
+ if (!this.nonce)
144
+ throw new Error("Nonce has not been set");
145
+ if (!this.mode || !this.hasValidMode())
146
+ throw new Error("Mode has not been set");
147
+ if (this.calls.length === 0)
148
+ throw new Error("Calls have not been set");
149
+ return hashStruct({
150
+ types: CallsTyped,
151
+ primaryType: "Calls",
152
+ data: { nonce: this.nonce, mode: this.mode, calls: this.calls },
153
+ });
154
+ }
155
+ /** Generate an account with this action embedded. */
156
+ asAccount(opt) {
157
+ const callDigest = this.asDigest();
158
+ const { factory, template } = _factory(opt);
159
+ const address = CatapultarAccount.predict({
160
+ ...opt,
161
+ factory,
162
+ template,
163
+ callDigest,
164
+ isSignature: false,
165
+ });
166
+ const pubkeyArray = pubkeyAsArray(opt);
167
+ const deployCall = {
168
+ to: factory,
169
+ data: encodeFunctionData({
170
+ abi: CATAPULTAR_FACTORY_V0_1_0_ABI,
171
+ functionName: "deployWithDigest",
172
+ args: [opt.keyType, pubkeyArray, opt.salt, callDigest, false],
173
+ }),
174
+ value: 0n,
175
+ };
176
+ const actionCall = { ...this.asCallData(), to: address };
177
+ return {
178
+ deployCall,
179
+ actionCall,
180
+ callDigest,
181
+ address,
182
+ };
183
+ }
184
+ }
185
+ //# sourceMappingURL=transaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/transaction/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAC3E,OAAO,EACL,oBAAoB,EACpB,UAAU,EACV,aAAa,GAId,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KA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AC,CAAC;QAC5C,MAAM,OAAO,GAAG,iBAAiB,CAAC,OAAO,CAAC;YACxC,GAAG,GAAG;YACN,OAAO;YACP,QAAQ;YACR,UAAU;YACV,WAAW,EAAE,KAAK;SACnB,CAAC,CAAC;QAEH,MAAM,WAAW,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;QACvC,MAAM,UAAU,GAAG;YACjB,EAAE,EAAE,OAAO;YACX,IAAI,EAAE,kBAAkB,CAAC;gBACvB,GAAG,EAAE,6BAA6B;gBAClC,YAAY,EAAE,kBAAkB;gBAChC,IAAI,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,CAAC;aAC9D,CAAC;YACF,KAAK,EAAE,EAAE;SACV,CAAC;QACF,MAAM,UAAU,GAAG,EAAE,GAAG,IAAI,CAAC,UAAU,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC;QAEzD,OAAO;YACL,UAAU;YACV,UAAU;YACV,UAAU;YACV,OAAO;SACR,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,144 @@
1
+ /**
2
+ * @param RaiseRevert If a call fails, raise the revert message and do not spend the nonce.
3
+ * @param SkipRevert If a call fails, skip the call, emit an event. The nonce will be spent if the transaction does not run out of gas.
4
+ */
5
+ export declare enum ExecutionMode {
6
+ RaiseRevert = "0x0100000000007821000100000000000000000000000000000000000000000000",
7
+ SkipRevert = "0x0101000000007821000100000000000000000000000000000000000000000000",
8
+ RaiseRevertMultiChain = "0x0100010000007821000100000000000000000000000000000000000000000000",
9
+ SkipRevertMultiChain = "0x0101010000007821000100000000000000000000000000000000000000000000"
10
+ }
11
+ export declare enum AccountPublicKeyType {
12
+ ECDSAOrSmartContract = 0,
13
+ P256 = 1,
14
+ WebAuthnP256 = 2
15
+ }
16
+ export declare enum DigestApproval {
17
+ Unset = 0,
18
+ Call = 1,
19
+ Signature = 2
20
+ }
21
+ export type P256Points = [`0x${string}`, `0x${string}`];
22
+ export type AccountPublicVar<T extends AccountPublicKeyType> = T extends AccountPublicKeyType.ECDSAOrSmartContract ? `0x${string}` : P256Points;
23
+ export type WebAuthnSignature = {
24
+ authenticatorData: `0x${string}`;
25
+ clientDataJSON: string;
26
+ challengeIndex: number;
27
+ typeIndex: number;
28
+ r: bigint;
29
+ s: bigint;
30
+ };
31
+ export type KeyedSignature<T extends AccountPublicKeyType> = T extends AccountPublicKeyType.ECDSAOrSmartContract ? `0x${string}` : T extends AccountPublicKeyType.P256 ? `0x${string}` : WebAuthnSignature;
32
+ export type Version = `0.1.0` | "0.0.1";
33
+ export type Executable = Call;
34
+ export type AccountConstructorParams<V, RPC, AKT extends AccountPublicKeyType> = {
35
+ address: `0x${string}`;
36
+ accountPublicKeyType?: AKT;
37
+ pubkey: AccountPublicVar<AKT>;
38
+ name?: string;
39
+ version?: V;
40
+ } & (undefined extends RPC ? {
41
+ rpc?: RPC;
42
+ chainId?: number;
43
+ } : {
44
+ rpc: RPC;
45
+ chainId: number;
46
+ });
47
+ export type Call = {
48
+ to: `0x${string}`;
49
+ value: bigint;
50
+ data: `0x${string}`;
51
+ };
52
+ export type Calls = {
53
+ nonce: bigint;
54
+ mode: `0x${string}`;
55
+ calls: Call[];
56
+ };
57
+ export declare const CallsTyped: {
58
+ readonly Calls: readonly [{
59
+ readonly name: "nonce";
60
+ readonly type: "uint256";
61
+ }, {
62
+ readonly name: "mode";
63
+ readonly type: "bytes32";
64
+ }, {
65
+ readonly name: "calls";
66
+ readonly type: "Call[]";
67
+ }];
68
+ readonly Call: readonly [{
69
+ readonly name: "to";
70
+ readonly type: "address";
71
+ }, {
72
+ readonly name: "value";
73
+ readonly type: "uint256";
74
+ }, {
75
+ readonly name: "data";
76
+ readonly type: "bytes";
77
+ }];
78
+ };
79
+ export type Allowance = {
80
+ token: `0x${string}`;
81
+ amount: bigint;
82
+ };
83
+ export type AllowanceSpend = {
84
+ token: `0x${string}`;
85
+ allocated: bigint;
86
+ spend: bigint;
87
+ };
88
+ export type Outcome = {
89
+ token: `0x${string}`;
90
+ amount: bigint;
91
+ destination: `0x${string}`;
92
+ };
93
+ export type ExecutionConstraint = {
94
+ allowances: Allowance[];
95
+ outcomes: Outcome[];
96
+ executor: `0x${string}`;
97
+ nonce: bigint;
98
+ };
99
+ export declare const ExecutionConstraintTyped: {
100
+ readonly ExecutionConstraint: readonly [{
101
+ readonly name: "allowances";
102
+ readonly type: "Allowance[]";
103
+ }, {
104
+ readonly name: "outcomes";
105
+ readonly type: "Outcome[]";
106
+ }, {
107
+ readonly name: "executor";
108
+ readonly type: "address";
109
+ }, {
110
+ readonly name: "nonce";
111
+ readonly type: "uint256";
112
+ }];
113
+ readonly Allowance: readonly [{
114
+ readonly name: "token";
115
+ readonly type: "address";
116
+ }, {
117
+ readonly name: "amount";
118
+ readonly type: "uint256";
119
+ }];
120
+ readonly Outcome: readonly [{
121
+ readonly name: "token";
122
+ readonly type: "address";
123
+ }, {
124
+ readonly name: "amount";
125
+ readonly type: "uint256";
126
+ }, {
127
+ readonly name: "destination";
128
+ readonly type: "address";
129
+ }];
130
+ };
131
+ export type EmbeddedCall = {
132
+ callDigest: `0x${string}`;
133
+ isSignature: boolean;
134
+ };
135
+ export type Factory = {
136
+ factory: `0x${string}`;
137
+ template: `0x${string}`;
138
+ };
139
+ export type MaybeFactory = {} | Factory;
140
+ export type Pubkey<AKT extends AccountPublicKeyType> = {
141
+ keyType: AKT;
142
+ pubkey: AccountPublicVar<AKT>;
143
+ };
144
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oBAAY,aAAa;IACvB,WAAW,uEAAuE;IAClF,UAAU,uEAAuE;IACjF,qBAAqB,uEAAuE;IAC5F,oBAAoB,uEAAuE;CAC5F;AACD,oBAAY,oBAAoB;IAC9B,oBAAoB,IAAI;IACxB,IAAI,IAA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C1B,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,OAAO,EAAE,KAAK,MAAM,EAAE,CAAC;IACvB,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,EAAE,GAAG,OAAO,CAAC;AAExC,MAAM,MAAM,MAAM,CAAC,GAAG,SAAS,oBAAoB,IAAI;IACrD,OAAO,EAAE,GAAG,CAAC;IACb,MAAM,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC;CAC/B,CAAC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * @param RaiseRevert If a call fails, raise the revert message and do not spend the nonce.
3
+ * @param SkipRevert If a call fails, skip the call, emit an event. The nonce will be spent if the transaction does not run out of gas.
4
+ */
5
+ export var ExecutionMode;
6
+ (function (ExecutionMode) {
7
+ ExecutionMode["RaiseRevert"] = "0x0100000000007821000100000000000000000000000000000000000000000000";
8
+ ExecutionMode["SkipRevert"] = "0x0101000000007821000100000000000000000000000000000000000000000000";
9
+ ExecutionMode["RaiseRevertMultiChain"] = "0x0100010000007821000100000000000000000000000000000000000000000000";
10
+ ExecutionMode["SkipRevertMultiChain"] = "0x0101010000007821000100000000000000000000000000000000000000000000";
11
+ })(ExecutionMode || (ExecutionMode = {}));
12
+ export var AccountPublicKeyType;
13
+ (function (AccountPublicKeyType) {
14
+ AccountPublicKeyType[AccountPublicKeyType["ECDSAOrSmartContract"] = 0] = "ECDSAOrSmartContract";
15
+ AccountPublicKeyType[AccountPublicKeyType["P256"] = 1] = "P256";
16
+ AccountPublicKeyType[AccountPublicKeyType["WebAuthnP256"] = 2] = "WebAuthnP256";
17
+ })(AccountPublicKeyType || (AccountPublicKeyType = {}));
18
+ export var DigestApproval;
19
+ (function (DigestApproval) {
20
+ DigestApproval[DigestApproval["Unset"] = 0] = "Unset";
21
+ DigestApproval[DigestApproval["Call"] = 1] = "Call";
22
+ DigestApproval[DigestApproval["Signature"] = 2] = "Signature";
23
+ })(DigestApproval || (DigestApproval = {}));
24
+ export const CallsTyped = {
25
+ Calls: [
26
+ { name: "nonce", type: "uint256" },
27
+ { name: "mode", type: "bytes32" },
28
+ { name: "calls", type: "Call[]" },
29
+ ],
30
+ Call: [
31
+ { name: "to", type: "address" },
32
+ { name: "value", type: "uint256" },
33
+ { name: "data", type: "bytes" },
34
+ ],
35
+ };
36
+ export const ExecutionConstraintTyped = {
37
+ ExecutionConstraint: [
38
+ { name: "allowances", type: "Allowance[]" },
39
+ { name: "outcomes", type: "Outcome[]" },
40
+ { name: "executor", type: "address" },
41
+ { name: "nonce", type: "uint256" },
42
+ ],
43
+ Allowance: [
44
+ { name: "token", type: "address" },
45
+ { name: "amount", type: "uint256" },
46
+ ],
47
+ Outcome: [
48
+ { name: "token", type: "address" },
49
+ { name: "amount", type: "uint256" },
50
+ { name: "destination", type: "address" },
51
+ ],
52
+ };
53
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAN,IAAY,aAKX;AALD,WAAY,aAAa;IACvB,mGAAkF,CAAA;IAClF,kGAAiF,CAAA;IACjF,6GAA4F,CAAA;IAC5F,4GAA2F,CAAA;AAC7F,CAAC,EALW,aAAa,KAAb,aAAa,QAKxB;AACD,MAAM,CAAN,IAAY,oBAIX;AAJD,WAAY,oBAAoB;IAC9B,+FAAwB,CAAA;IACxB,+DAAQ,CAAA;IACR,+EAAgB,CAAA;AAClB,CAAC,EAJW,oBAAoB,KAApB,oBAAoB,QAI/B;AACD,MAAM,CAAN,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,qDAAS,CAAA;IACT,mDAAQ,CAAA;IACR,6DAAa,CAAA;AACf,CAAC,EAJW,cAAc,KAAd,cAAc,QAIzB;AAsED,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,KAAK,EAAE;QACL,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;QAClC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE;QACjC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE;KAClC;IACD,IAAI,EAAE;QACJ,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE;QAC/B,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;QAClC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE;KAChC;CACO,CAAC;AA4BX,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,mBAAmB,EAAE;QACnB,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE;QAC3C,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE;QACvC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE;QACrC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;KACnC;IACD,SAAS,EAAE;QACT,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;QAClC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE;KACpC;IACD,OAAO,EAAE;QACP,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;QAClC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE;QACnC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE;KACzC;CACO,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { AccountPublicKeyType, type Pubkey } from "../types/types.js";
2
+ /**
3
+ * Pads a string such that it has an even length OR until a specific minimum.
4
+ * @param s String to pad.
5
+ * @param minimal Optional length. Default 2.
6
+ * @param pad Value to pad with. Default: 0
7
+ */
8
+ export declare function padEven(s: string, minimal?: number, pad?: string): string;
9
+ /**
10
+ * Converts a number into a hex string.
11
+ * @param num Number to convert into hex. Takes Number or BigInt
12
+ * @param bytes How many bytes to pad the number to. Default: 1
13
+ * @param prefix Value to prefix the hex string with. Default: ''
14
+ * @returns Returns the provided value as a hex string.
15
+ */
16
+ export declare function asHex<T extends string = "">(num: number | bigint, bytes?: number, prefix?: T): `${T}${string}`;
17
+ /**
18
+ * Validate whether an a salt value contains a specific address as the initial values.
19
+ */
20
+ export declare function saltContainsAddress(address: `0x${string}`, salt: `0x${string}`): boolean;
21
+ /**
22
+ * Returns a random hex value.
23
+ * @param length Number of bytes to get.
24
+ */
25
+ export declare const random: (length: number) => `0x${string}`;
26
+ /**
27
+ * Takes an pubkey array of a key type and pubkey structure and after validation returns it as an array.
28
+ * @param options AccountPublicKeyType and pubkey. if ECDSA or smart contract, pubkey is provided as a 20 or 32 bytes string otherwise as an array.
29
+ */
30
+ export declare function pubkeyAsArray<AKT extends AccountPublicKeyType>(options: Pubkey<AKT>): import("../types/types.js").P256Points | [`0x${string}`];
31
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EAEpB,KAAK,MAAM,EACZ,MAAM,gBAAgB,CAAC;AAExB;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,SAAI,EAAE,GAAG,GAAE,MAAY,UAEhE;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,SAAS,MAAM,GAAG,EAAE,EACzC,GAAG,EAAE,MAAM,GAAG,MAAM,EACpB,KAAK,GAAE,MAAU,EACjB,MAAM,CAAC,EAAE,CAAC,GACT,GAAG,CAAC,GAAG,MAAM,EAAE,CAGjB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,KAAK,MAAM,EAAE,EACtB,IAAI,EAAE,KAAK,MAAM,EAAE,GAClB,OAAO,CAIT;AAED;;;GAGG;AACH,eAAO,MAAM,MAAM,GAAI,QAAQ,MAAM,KAAG,KAAK,MAAM,EAMxB,CAAC;AAE5B;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,SAAS,oBAAoB,EAC5D,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,yDAgCrB"}
@@ -0,0 +1,65 @@
1
+ import { AccountPublicKeyType, } from "../types/types.js";
2
+ /**
3
+ * Pads a string such that it has an even length OR until a specific minimum.
4
+ * @param s String to pad.
5
+ * @param minimal Optional length. Default 2.
6
+ * @param pad Value to pad with. Default: 0
7
+ */
8
+ export function padEven(s, minimal = 2, pad = "0") {
9
+ return s.padStart(((Math.max(s.length + 1, minimal) / 2) | 0) * 2, pad);
10
+ }
11
+ /**
12
+ * Converts a number into a hex string.
13
+ * @param num Number to convert into hex. Takes Number or BigInt
14
+ * @param bytes How many bytes to pad the number to. Default: 1
15
+ * @param prefix Value to prefix the hex string with. Default: ''
16
+ * @returns Returns the provided value as a hex string.
17
+ */
18
+ export function asHex(num, bytes = 1, prefix) {
19
+ const p = (prefix ?? "");
20
+ return `${p}${padEven(num.toString(16), bytes * 2)}`;
21
+ }
22
+ /**
23
+ * Validate whether an a salt value contains a specific address as the initial values.
24
+ */
25
+ export function saltContainsAddress(address, salt) {
26
+ const saltSlice = salt.slice(0, 42);
27
+ if (saltSlice === "0x0000000000000000000000000000000000000000")
28
+ return true;
29
+ return saltSlice === address;
30
+ }
31
+ /**
32
+ * Returns a random hex value.
33
+ * @param length Number of bytes to get.
34
+ */
35
+ export const random = (length) => `0x${Array.from(crypto.getRandomValues(new Uint8Array(Math.ceil((length * 2) / 2))), (b) => b.toString(16).padStart(2, "0"))
36
+ .join("")
37
+ .slice(0, length * 2)}`;
38
+ /**
39
+ * Takes an pubkey array of a key type and pubkey structure and after validation returns it as an array.
40
+ * @param options AccountPublicKeyType and pubkey. if ECDSA or smart contract, pubkey is provided as a 20 or 32 bytes string otherwise as an array.
41
+ */
42
+ export function pubkeyAsArray(options) {
43
+ if (options.keyType === AccountPublicKeyType.ECDSAOrSmartContract) {
44
+ if (typeof options.pubkey !== "string")
45
+ throw new Error(`PublicKeyType not expected ${typeof options.pubkey}`);
46
+ // Check pubkey is formatted correctly. Either 20 bytes or 32 bytes with first 12 bytes empty.
47
+ const pubkeyAddress = options.pubkey.replace("0x", "");
48
+ if (!(pubkeyAddress.length === 20 * 2 ||
49
+ (pubkeyAddress.length === 32 * 2 &&
50
+ pubkeyAddress.slice(0, 12 * 2) === "000000000000000000000000")))
51
+ throw new Error(`Pubkey address incorrectly formatted: ${pubkeyAddress}`);
52
+ // Validate that pubkey is `0x${string}`
53
+ return [`0x${padEven(pubkeyAddress, 64)}`];
54
+ }
55
+ else if (options.keyType === AccountPublicKeyType.P256 ||
56
+ options.keyType === AccountPublicKeyType.WebAuthnP256) {
57
+ if (options.pubkey.length !== 2)
58
+ throw new Error(`Invalid pubkey array ${options.pubkey}, length ${options.pubkey.length} !== 2`);
59
+ return options.pubkey;
60
+ }
61
+ else {
62
+ throw new Error(`PublicKeyType not supported ${options.keyType}`);
63
+ }
64
+ }
65
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,GAGrB,MAAM,gBAAgB,CAAC;AAExB;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,CAAS,EAAE,OAAO,GAAG,CAAC,EAAE,MAAc,GAAG;IAC/D,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,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,CAAC,MAAM,EAAE,CAAC,CAAC;QACzE,8FAA8F;QAC9F,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACvD,IACE,CAAC,CACC,aAAa,CAAC,MAAM,KAAK,EAAE,GAAG,CAAC;YAC/B,CAAC,aAAa,CAAC,MAAM,KAAK,EAAE,GAAG,CAAC;gBAC9B,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,KAAK,0BAA0B,CAAC,CACjE;YAED,MAAM,IAAI,KAAK,CAAC,yCAAyC,aAAa,EAAE,CAAC,CAAC;QAE5E,wCAAwC;QACxC,OAAO,CAAC,KAAK,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,EAAE,CAAoB,CAAC;IAChE,CAAC;SAAM,IACL,OAAO,CAAC,OAAO,KAAK,oBAAoB,CAAC,IAAI;QAC7C,OAAO,CAAC,OAAO,KAAK,oBAAoB,CAAC,YAAY,EACrD,CAAC;QACD,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC;YAC7B,MAAM,IAAI,KAAK,CACb,wBAAwB,OAAO,CAAC,MAAM,YAAY,OAAO,CAAC,MAAM,CAAC,MAAM,QAAQ,CAChF,CAAC;QACJ,OAAO,OAAO,CAAC,MAEd,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,+BAA+B,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IACpE,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function toCompactSignature(signature: `0x${string}`): `0x${string}`;
2
+ export declare function fromCompactSignature(signature: `0x${string}`): `0x${string}`;
3
+ //# sourceMappingURL=signature.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../../src/utils/signature.ts"],"names":[],"mappings":"AASA,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,KAAK,MAAM,EAAE,iBAG1D;AAED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,KAAK,MAAM,EAAE,iBAG5D"}
@@ -0,0 +1,10 @@
1
+ import { compactSignatureToSignature, parseCompactSignature, parseSignature, serializeCompactSignature, serializeSignature, signatureToCompactSignature, } from "viem";
2
+ export function toCompactSignature(signature) {
3
+ const sig = parseSignature(signature);
4
+ return serializeCompactSignature(signatureToCompactSignature(sig));
5
+ }
6
+ export function fromCompactSignature(signature) {
7
+ const compactSig = parseCompactSignature(signature);
8
+ return serializeSignature(compactSignatureToSignature(compactSig));
9
+ }
10
+ //# sourceMappingURL=signature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signature.js","sourceRoot":"","sources":["../../src/utils/signature.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAC3B,qBAAqB,EACrB,cAAc,EACd,yBAAyB,EACzB,kBAAkB,EAClB,2BAA2B,GAC5B,MAAM,MAAM,CAAC;AAEd,MAAM,UAAU,kBAAkB,CAAC,SAAwB;IACzD,MAAM,GAAG,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;IACtC,OAAO,yBAAyB,CAAC,2BAA2B,CAAC,GAAG,CAAC,CAAC,CAAC;AACrE,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,SAAwB;IAC3D,MAAM,UAAU,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC;IACpD,OAAO,kBAAkB,CAAC,2BAA2B,CAAC,UAAU,CAAC,CAAC,CAAC;AACrE,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Chain } from "viem";
2
+ export declare function getViemChainId(chainId: number): Chain | undefined;
3
+ //# sourceMappingURL=viem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viem.d.ts","sourceRoot":"","sources":["../../src/utils/viem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAOlC,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,CAKjE"}
@@ -0,0 +1,10 @@
1
+ import { mainnet, arbitrum, optimism } from "viem/chains";
2
+ import { extractChain } from "viem/utils";
3
+ const chains = [mainnet, arbitrum, optimism];
4
+ export function getViemChainId(chainId) {
5
+ return extractChain({
6
+ chains,
7
+ id: chainId,
8
+ });
9
+ }
10
+ //# sourceMappingURL=viem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viem.js","sourceRoot":"","sources":["../../src/utils/viem.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,MAAM,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAG7C,MAAM,UAAU,cAAc,CAAC,OAAe;IAC5C,OAAO,YAAY,CAAC;QAClB,MAAM;QACN,EAAE,EAAE,OAAmB;KACxB,CAAC,CAAC;AACL,CAAC"}
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "catapultar",
3
+ "description": "Interface for the Catapultar Smart Account",
4
+ "version": "0.1.0",
5
+ "license": "LGPL-3.0-only",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/lifinance/catapultar.git"
9
+ },
10
+ "bugs": {
11
+ "url": "https://github.com/lifinance/catapultar/issues"
12
+ },
13
+ "homepage": "https://github.com/lifinance/catapultar#readme",
14
+ "engines": {
15
+ "node": ">=20.0.0",
16
+ "bun": ">=1.3.5"
17
+ },
18
+ "main": "dist/index.js",
19
+ "types": "dist/index.d.ts",
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "module": "dist/index.js",
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/index.d.ts",
27
+ "import": "./dist/index.js",
28
+ "default": "./dist/index.js"
29
+ }
30
+ },
31
+ "type": "module",
32
+ "sideEffects": false,
33
+ "scripts": {
34
+ "clean": "rm -rf dist/",
35
+ "prebuild": "bun run clean",
36
+ "build": "tsc --project tsconfig.build.json && node ./scripts/rewrite-dist-imports.mjs",
37
+ "build:watch": "tsc --project tsconfig.build.json -w",
38
+ "lint:staged": "prettier -w",
39
+ "prepublishOnly": "bun run build && bun run test",
40
+ "test": "bun test --preload ./test/setup.ts",
41
+ "test:watch": "bun run test --watch",
42
+ "coverage": "bun run test --coverage",
43
+ "coverage:lcov": "bun run coverage --coverage-reporter='lcov' --coverage-dir='./'"
44
+ },
45
+ "lint-staged": {
46
+ "*.ts": [
47
+ "bun run lint:staged"
48
+ ]
49
+ },
50
+ "dependencies": {
51
+ "ox": "^0.10.6",
52
+ "viem": "^2.43.3"
53
+ },
54
+ "devDependencies": {
55
+ "@types/bun": "latest",
56
+ "bun": "^1.3.5",
57
+ "husky": "^9.1.7",
58
+ "lint-staged": "^16.2.7",
59
+ "prettier": "^3.7.4",
60
+ "prool": "^0.2.2",
61
+ "typescript": "^5.9.3"
62
+ }
63
+ }