@artblocks/abx-cli 0.1.0-alpha.7 → 0.1.0-alpha.70

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 (197) hide show
  1. package/CHANGELOG.md +298 -0
  2. package/assets/renderer-scaffold/README.md +44 -13
  3. package/assets/renderer-scaffold/foundry.toml +5 -0
  4. package/assets/renderer-scaffold/remappings.txt +1 -1
  5. package/assets/renderer-scaffold/script/DeployHooks.s.sol +24 -0
  6. package/assets/renderer-scaffold/script/Preview.s.sol +99 -0
  7. package/assets/renderer-scaffold/src/MyHooks.sol +20 -0
  8. package/assets/renderer-scaffold/src/MyRenderer.sol +4 -4
  9. package/assets/renderer-scaffold/src/MyTraits.sol +2 -2
  10. package/assets/renderer-scaffold/test/MyRenderer.t.sol +60 -3
  11. package/dist/bin.d.ts +26 -0
  12. package/dist/bin.d.ts.map +1 -0
  13. package/dist/bin.js +63 -0
  14. package/dist/bin.js.map +1 -0
  15. package/dist/capabilities.d.ts +132 -0
  16. package/dist/capabilities.d.ts.map +1 -0
  17. package/dist/capabilities.js +175 -0
  18. package/dist/capabilities.js.map +1 -0
  19. package/dist/commands/auth.d.ts +54 -0
  20. package/dist/commands/auth.d.ts.map +1 -0
  21. package/dist/commands/auth.js +483 -0
  22. package/dist/commands/auth.js.map +1 -0
  23. package/dist/commands/contract.d.ts +19 -0
  24. package/dist/commands/contract.d.ts.map +1 -0
  25. package/dist/commands/contract.js +171 -0
  26. package/dist/commands/contract.js.map +1 -0
  27. package/dist/commands/deploy.d.ts +296 -0
  28. package/dist/commands/deploy.d.ts.map +1 -0
  29. package/dist/commands/deploy.js +5736 -0
  30. package/dist/commands/deploy.js.map +1 -0
  31. package/dist/commands/feedback.d.ts +7 -0
  32. package/dist/commands/feedback.d.ts.map +1 -0
  33. package/dist/commands/feedback.js +154 -0
  34. package/dist/commands/feedback.js.map +1 -0
  35. package/dist/commands/maintenance.d.ts +4 -0
  36. package/dist/commands/maintenance.d.ts.map +1 -0
  37. package/dist/commands/maintenance.js +114 -0
  38. package/dist/commands/maintenance.js.map +1 -0
  39. package/dist/commands/project.d.ts +458 -0
  40. package/dist/commands/project.d.ts.map +1 -0
  41. package/dist/commands/project.js +1837 -0
  42. package/dist/commands/project.js.map +1 -0
  43. package/dist/commands/reads.d.ts +85 -0
  44. package/dist/commands/reads.d.ts.map +1 -0
  45. package/dist/commands/reads.js +881 -0
  46. package/dist/commands/reads.js.map +1 -0
  47. package/dist/commands/scaffold.d.ts +89 -0
  48. package/dist/commands/scaffold.d.ts.map +1 -0
  49. package/dist/commands/scaffold.js +741 -0
  50. package/dist/commands/scaffold.js.map +1 -0
  51. package/dist/commands/service.d.ts +67 -0
  52. package/dist/commands/service.d.ts.map +1 -0
  53. package/dist/commands/service.js +761 -0
  54. package/dist/commands/service.js.map +1 -0
  55. package/dist/commands/storage.d.ts +51 -0
  56. package/dist/commands/storage.d.ts.map +1 -0
  57. package/dist/commands/storage.js +399 -0
  58. package/dist/commands/storage.js.map +1 -0
  59. package/dist/commands/submit-app.d.ts +102 -0
  60. package/dist/commands/submit-app.d.ts.map +1 -0
  61. package/dist/commands/submit-app.js +638 -0
  62. package/dist/commands/submit-app.js.map +1 -0
  63. package/dist/config.d.ts +94 -2
  64. package/dist/config.d.ts.map +1 -1
  65. package/dist/config.js +332 -12
  66. package/dist/config.js.map +1 -1
  67. package/dist/conformance.d.ts +31 -0
  68. package/dist/conformance.d.ts.map +1 -0
  69. package/dist/conformance.js +400 -0
  70. package/dist/conformance.js.map +1 -0
  71. package/dist/contract-read-error.d.ts +5 -0
  72. package/dist/contract-read-error.d.ts.map +1 -0
  73. package/dist/contract-read-error.js +37 -0
  74. package/dist/contract-read-error.js.map +1 -0
  75. package/dist/creator-agent.d.ts +40 -0
  76. package/dist/creator-agent.d.ts.map +1 -0
  77. package/dist/creator-agent.js +206 -0
  78. package/dist/creator-agent.js.map +1 -0
  79. package/dist/creator-signer.d.ts +52 -0
  80. package/dist/creator-signer.d.ts.map +1 -0
  81. package/dist/creator-signer.js +225 -0
  82. package/dist/creator-signer.js.map +1 -0
  83. package/dist/deploy-plan.d.ts +218 -0
  84. package/dist/deploy-plan.d.ts.map +1 -0
  85. package/dist/deploy-plan.js +20 -0
  86. package/dist/deploy-plan.js.map +1 -0
  87. package/dist/deps.d.ts +6 -39
  88. package/dist/deps.d.ts.map +1 -1
  89. package/dist/deps.js +4 -68
  90. package/dist/deps.js.map +1 -1
  91. package/dist/errors.d.ts +22 -0
  92. package/dist/errors.d.ts.map +1 -0
  93. package/dist/errors.js +32 -0
  94. package/dist/errors.js.map +1 -0
  95. package/dist/flag-allowlists.d.ts +53 -0
  96. package/dist/flag-allowlists.d.ts.map +1 -0
  97. package/dist/flag-allowlists.js +188 -0
  98. package/dist/flag-allowlists.js.map +1 -0
  99. package/dist/flags.d.ts +53 -0
  100. package/dist/flags.d.ts.map +1 -1
  101. package/dist/flags.js +151 -1
  102. package/dist/flags.js.map +1 -1
  103. package/dist/jsonout.d.ts +37 -0
  104. package/dist/jsonout.d.ts.map +1 -0
  105. package/dist/jsonout.js +79 -0
  106. package/dist/jsonout.js.map +1 -0
  107. package/dist/kind.d.ts +57 -0
  108. package/dist/kind.d.ts.map +1 -0
  109. package/dist/kind.js +122 -0
  110. package/dist/kind.js.map +1 -0
  111. package/dist/main.js +875 -5214
  112. package/dist/main.js.map +1 -1
  113. package/dist/mintpage.d.ts +17 -2
  114. package/dist/mintpage.d.ts.map +1 -1
  115. package/dist/mintpage.js +241 -54
  116. package/dist/mintpage.js.map +1 -1
  117. package/dist/output.d.ts +184 -0
  118. package/dist/output.d.ts.map +1 -0
  119. package/dist/output.js +774 -0
  120. package/dist/output.js.map +1 -0
  121. package/dist/ownerops.d.ts +450 -57
  122. package/dist/ownerops.d.ts.map +1 -1
  123. package/dist/ownerops.js +2232 -379
  124. package/dist/ownerops.js.map +1 -1
  125. package/dist/preview.d.ts +23 -5
  126. package/dist/preview.d.ts.map +1 -1
  127. package/dist/preview.js +95 -43
  128. package/dist/preview.js.map +1 -1
  129. package/dist/provision.d.ts +3 -13
  130. package/dist/provision.d.ts.map +1 -1
  131. package/dist/provision.js +19 -21
  132. package/dist/provision.js.map +1 -1
  133. package/dist/remote.d.ts +169 -52
  134. package/dist/remote.d.ts.map +1 -1
  135. package/dist/remote.js +488 -46
  136. package/dist/remote.js.map +1 -1
  137. package/dist/riskgate.d.ts +101 -0
  138. package/dist/riskgate.d.ts.map +1 -0
  139. package/dist/riskgate.js +343 -0
  140. package/dist/riskgate.js.map +1 -0
  141. package/dist/scaffold.d.ts +12 -0
  142. package/dist/scaffold.d.ts.map +1 -0
  143. package/dist/scaffold.js +56 -0
  144. package/dist/scaffold.js.map +1 -0
  145. package/dist/schema.d.ts +36 -1
  146. package/dist/schema.d.ts.map +1 -1
  147. package/dist/schema.js +121 -26
  148. package/dist/schema.js.map +1 -1
  149. package/dist/script-chunks.d.ts +8 -0
  150. package/dist/script-chunks.d.ts.map +1 -0
  151. package/dist/script-chunks.js +35 -0
  152. package/dist/script-chunks.js.map +1 -0
  153. package/dist/served.d.ts +30 -0
  154. package/dist/served.d.ts.map +1 -0
  155. package/dist/served.js +112 -0
  156. package/dist/served.js.map +1 -0
  157. package/dist/signer.d.ts +20 -1
  158. package/dist/signer.d.ts.map +1 -1
  159. package/dist/signer.js +110 -18
  160. package/dist/signer.js.map +1 -1
  161. package/dist/update-check.d.ts +55 -1
  162. package/dist/update-check.d.ts.map +1 -1
  163. package/dist/update-check.js +99 -9
  164. package/dist/update-check.js.map +1 -1
  165. package/package.json +16 -12
  166. package/skill/SKILL.md +211 -349
  167. package/skill/agents/openai.yaml +4 -0
  168. package/skill/reference/capabilities.md +195 -0
  169. package/skill/reference/code.md +236 -0
  170. package/skill/reference/creator-token.md +94 -0
  171. package/skill/reference/deploy.md +177 -0
  172. package/skill/reference/diagnose.md +178 -0
  173. package/skill/reference/hosting.md +192 -92
  174. package/skill/reference/operate.md +237 -0
  175. package/skill/reference/services.md +167 -0
  176. package/skill/reference/setup.md +219 -36
  177. package/assets/renderer-scaffold/src/interfaces/IAbxFieldRenderer.sol +0 -32
  178. package/assets/renderer-scaffold/src/interfaces/IAbxParams.sol +0 -26
  179. package/dist/inspect.d.ts +0 -48
  180. package/dist/inspect.d.ts.map +0 -1
  181. package/dist/inspect.js +0 -184
  182. package/dist/inspect.js.map +0 -1
  183. package/dist/migrate.d.ts +0 -65
  184. package/dist/migrate.d.ts.map +0 -1
  185. package/dist/migrate.js +0 -180
  186. package/dist/migrate.js.map +0 -1
  187. package/dist/onchain-uri.d.ts +0 -97
  188. package/dist/onchain-uri.d.ts.map +0 -1
  189. package/dist/onchain-uri.js +0 -243
  190. package/dist/onchain-uri.js.map +0 -1
  191. package/dist/upload.d.ts +0 -28
  192. package/dist/upload.d.ts.map +0 -1
  193. package/dist/upload.js +0 -41
  194. package/dist/upload.js.map +0 -1
  195. package/skill/reference/code-projects.md +0 -246
  196. package/skill/reference/operating.md +0 -116
  197. package/skill/reference/troubleshooting.md +0 -28
@@ -0,0 +1,206 @@
1
+ import { Chacha20Poly1305 } from '@hpke/chacha20poly1305';
2
+ import { CipherSuite, DhkemP256HkdfSha256, HkdfSha256 } from '@hpke/core';
3
+ import { generateAuthorizationSignature } from '@privy-io/node';
4
+ const OAUTH = 'https://auth.privy.io/api/oauth/v2';
5
+ const WALLET_API = 'https://api.privy.io/v1/wallets';
6
+ const DEVICE_GRANT = 'urn:ietf:params:oauth:grant-type:device_code';
7
+ export class CreatorAuthorizationError extends Error {
8
+ code;
9
+ constructor(code) {
10
+ super(`Creator wallet authorization: ${code}`);
11
+ this.code = code;
12
+ this.name = 'CreatorAuthorizationError';
13
+ }
14
+ }
15
+ function object(value) {
16
+ if (!value || typeof value !== 'object' || Array.isArray(value))
17
+ throw new CreatorAuthorizationError('invalid_response');
18
+ return value;
19
+ }
20
+ function string(value) {
21
+ if (typeof value !== 'string' || !value || value.length > 16_384)
22
+ throw new CreatorAuthorizationError('invalid_response');
23
+ return value;
24
+ }
25
+ function verificationUrl(value) {
26
+ const raw = string(value);
27
+ let parsed;
28
+ try {
29
+ parsed = new URL(raw);
30
+ }
31
+ catch {
32
+ throw new CreatorAuthorizationError('invalid_verification_url');
33
+ }
34
+ const local = parsed.hostname === 'localhost' || parsed.hostname === '127.0.0.1' || parsed.hostname === '[::1]';
35
+ if (parsed.username || parsed.password || (parsed.protocol !== 'https:' && !(local && parsed.protocol === 'http:'))) {
36
+ throw new CreatorAuthorizationError('invalid_verification_url');
37
+ }
38
+ return parsed.toString();
39
+ }
40
+ function seconds(value) {
41
+ if (typeof value !== 'number' || !Number.isFinite(value) || value <= 0 || value > 86_400) {
42
+ throw new CreatorAuthorizationError('invalid_response');
43
+ }
44
+ return value * 1_000;
45
+ }
46
+ function base64(value) {
47
+ const encoded = string(value);
48
+ if (!/^[A-Za-z0-9+/]+={0,2}$/.test(encoded))
49
+ throw new CreatorAuthorizationError('invalid_response');
50
+ return new Uint8Array(Buffer.from(encoded, 'base64'));
51
+ }
52
+ /** Ephemeral Privy device session. Tokens and the decrypted signing key never leave this instance. */
53
+ export class CreatorAgentAuthorization {
54
+ #appId;
55
+ #fetch;
56
+ #device;
57
+ #accessToken;
58
+ #authorizationKey;
59
+ #keyExpiresAt = 0;
60
+ #wallets = [];
61
+ constructor(options) {
62
+ if (!/^[A-Za-z0-9_-]{1,200}$/.test(options.appId))
63
+ throw new CreatorAuthorizationError('invalid_app_id');
64
+ this.#appId = options.appId;
65
+ this.#fetch = options.fetchImpl ?? fetch;
66
+ }
67
+ async #request(path, body, token) {
68
+ try {
69
+ const response = await this.#fetch(`${OAUTH}/${path}`, {
70
+ method: 'POST',
71
+ redirect: 'error',
72
+ signal: AbortSignal.timeout(15_000),
73
+ headers: {
74
+ 'content-type': 'application/json',
75
+ 'privy-app-id': this.#appId,
76
+ ...(token ? { authorization: `Bearer ${token}`, 'privy-grant-type': 'device_code' } : {}),
77
+ },
78
+ body: JSON.stringify(body),
79
+ });
80
+ const text = await response.text();
81
+ if (text.length > 65_536)
82
+ throw new CreatorAuthorizationError('invalid_response');
83
+ return { response, data: object(JSON.parse(text)) };
84
+ }
85
+ catch (error) {
86
+ if (error instanceof CreatorAuthorizationError)
87
+ throw error;
88
+ throw new CreatorAuthorizationError('request_failed');
89
+ }
90
+ }
91
+ async start() {
92
+ if (this.#device)
93
+ throw new CreatorAuthorizationError('already_started');
94
+ const { response, data } = await this.#request('device_authorization', {});
95
+ if (!response.ok)
96
+ throw new CreatorAuthorizationError('device_authorization_failed');
97
+ const expiresAt = Date.now() + seconds(data.expires_in);
98
+ this.#device = {
99
+ code: string(data.device_code),
100
+ expiresAt,
101
+ interval: data.interval === undefined ? 5_000 : seconds(data.interval),
102
+ };
103
+ return {
104
+ userCode: string(data.user_code),
105
+ verificationUri: verificationUrl(data.verification_uri),
106
+ ...(data.verification_uri_complete ? { verificationUriComplete: verificationUrl(data.verification_uri_complete) } : {}),
107
+ };
108
+ }
109
+ async wait() {
110
+ const device = this.#device;
111
+ if (!device)
112
+ throw new CreatorAuthorizationError('not_started');
113
+ for (;;) {
114
+ const remaining = device.expiresAt - Date.now();
115
+ if (remaining <= 0)
116
+ throw new CreatorAuthorizationError('expired');
117
+ await new Promise((resolve) => setTimeout(resolve, Math.min(device.interval, remaining)));
118
+ const { response, data } = await this.#request('token', { grant_type: DEVICE_GRANT, device_code: device.code });
119
+ if (response.ok) {
120
+ this.#accessToken = string(data.access_token);
121
+ await this.#authenticate();
122
+ this.#device = undefined;
123
+ return this.#wallets.map((wallet) => ({ ...wallet }));
124
+ }
125
+ const code = typeof data.error === 'string' ? data.error : '';
126
+ if (response.status === 400 && (code === 'authorization_pending' || code === 'slow_down')) {
127
+ if (code === 'slow_down')
128
+ device.interval += 5_000;
129
+ continue;
130
+ }
131
+ throw new CreatorAuthorizationError(code === 'access_denied' ? 'access_denied' : 'provider_error');
132
+ }
133
+ }
134
+ async #authenticate() {
135
+ if (!this.#accessToken)
136
+ throw new CreatorAuthorizationError('login_required');
137
+ try {
138
+ const suite = new CipherSuite({ kem: new DhkemP256HkdfSha256(), kdf: new HkdfSha256(), aead: new Chacha20Poly1305() });
139
+ const pair = await suite.kem.generateKeyPair();
140
+ const publicKey = await globalThis.crypto.subtle.exportKey('spki', pair.publicKey);
141
+ const { response, data } = await this.#request('wallets/authenticate', { encryption_type: 'HPKE', recipient_public_key: Buffer.from(publicKey).toString('base64') }, this.#accessToken);
142
+ if (!response.ok)
143
+ throw new CreatorAuthorizationError('wallet_authentication_failed');
144
+ const encrypted = object(data.encrypted_authorization_key);
145
+ const expiresAt = typeof data.expires_at === 'number' ? data.expires_at : Date.parse(string(data.expires_at));
146
+ if (!Number.isFinite(expiresAt) || expiresAt <= Date.now() + 5_000)
147
+ throw new CreatorAuthorizationError('expired_signing_key');
148
+ if (!Array.isArray(data.wallets))
149
+ throw new CreatorAuthorizationError('invalid_response');
150
+ const wallets = data.wallets.map((value) => {
151
+ const wallet = object(value);
152
+ return { id: string(wallet.id), address: string(wallet.address), chainType: string(wallet.chain_type) };
153
+ });
154
+ const recipient = await suite.createRecipientContext({ recipientKey: pair.privateKey, enc: base64(encrypted.encapsulated_key) });
155
+ const bytes = new Uint8Array(await recipient.open(base64(encrypted.ciphertext)));
156
+ try {
157
+ this.#authorizationKey = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
158
+ this.#keyExpiresAt = expiresAt;
159
+ this.#wallets = wallets;
160
+ }
161
+ finally {
162
+ bytes.fill(0);
163
+ }
164
+ this.#accessToken = undefined;
165
+ }
166
+ catch (error) {
167
+ if (error instanceof CreatorAuthorizationError)
168
+ throw error;
169
+ throw new CreatorAuthorizationError('key_exchange_failed');
170
+ }
171
+ }
172
+ sign(input) {
173
+ if (!this.#authorizationKey || this.#keyExpiresAt <= Date.now())
174
+ throw new CreatorAuthorizationError('authorization_expired');
175
+ if (!/^[A-Za-z0-9_-]{1,200}$/.test(input.walletId) || !/^[A-Za-z0-9_-]{1,200}$/.test(input.idempotencyKey)) {
176
+ throw new CreatorAuthorizationError('invalid_request');
177
+ }
178
+ if (input.body.method !== 'eth_sendTransaction')
179
+ throw new CreatorAuthorizationError('unsupported_method');
180
+ if (!this.#wallets.some((wallet) => wallet.id === input.walletId && wallet.chainType === 'ethereum')) {
181
+ throw new CreatorAuthorizationError('wallet_not_authorized');
182
+ }
183
+ const expiry = Number(input.requestExpiry);
184
+ if (!Number.isSafeInteger(expiry) || expiry <= Date.now() || expiry > Date.now() + 60_000 || expiry > this.#keyExpiresAt) {
185
+ throw new CreatorAuthorizationError('invalid_request_expiry');
186
+ }
187
+ const url = `${WALLET_API}/${encodeURIComponent(input.walletId)}/rpc`;
188
+ const headers = {
189
+ 'privy-app-id': this.#appId,
190
+ 'privy-idempotency-key': input.idempotencyKey,
191
+ 'privy-request-expiry': input.requestExpiry,
192
+ };
193
+ const signature = generateAuthorizationSignature({
194
+ authorizationPrivateKey: this.#authorizationKey,
195
+ input: { version: 1, method: 'POST', url, body: input.body, headers },
196
+ });
197
+ return { url, headers: { ...headers, 'privy-authorization-signature': signature } };
198
+ }
199
+ dispose() {
200
+ this.#device = undefined;
201
+ this.#accessToken = undefined;
202
+ this.#authorizationKey = undefined;
203
+ this.#wallets = [];
204
+ }
205
+ }
206
+ //# sourceMappingURL=creator-agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"creator-agent.js","sourceRoot":"","sources":["../src/creator-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAC,WAAW,EAAE,mBAAmB,EAAE,UAAU,EAAC,MAAM,YAAY,CAAC;AACxE,OAAO,EAAC,8BAA8B,EAAC,MAAM,gBAAgB,CAAC;AAE9D,MAAM,KAAK,GAAG,oCAAoC,CAAC;AACnD,MAAM,UAAU,GAAG,iCAAiC,CAAC;AACrD,MAAM,YAAY,GAAG,8CAA8C,CAAC;AAEpE,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IAC7B;IAArB,YA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AM,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAC;SACpE,CAAC,CAAC;QACH,OAAO,EAAC,GAAG,EAAE,OAAO,EAAE,EAAC,GAAG,OAAO,EAAE,+BAA+B,EAAE,SAAS,EAAC,EAAC,CAAC;IAClF,CAAC;IAED,OAAO;QACL,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QACzB,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;QAC9B,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC;QACnC,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;IACrB,CAAC;CACF"}
@@ -0,0 +1,52 @@
1
+ import { type Address, type Hex, type PreparedTx } from '@artblocks/abx-sdk';
2
+ import type { TransactionReceipt } from 'viem';
3
+ /** Preserve the exact RPC estimate across the JSON service boundary. This is a serialization
4
+ * guard, not a sponsorship-policy ceiling; real EVM transaction limits are many orders of
5
+ * magnitude below Number.MAX_SAFE_INTEGER. */
6
+ export declare function sponsoredGasLimit(gas: bigint): number;
7
+ /** Synchronous preflight for commands that may upload content before opening the signing lane. */
8
+ export declare function assertSponsorConfigured(chainKey: string): void;
9
+ /**
10
+ * Resolve the existing account-bound creator wallet for a sponsored preview without provisioning
11
+ * a wallet or opening an authorization grant. A dry run must use the signer that the real send
12
+ * will use; silently falling back to a local env key changes the CREATE2 salt, owner, royalty
13
+ * receiver, and mint recipient shown in the preview.
14
+ */
15
+ export declare function sponsoredPreviewAddress(chainKey: string, options?: {
16
+ env?: NodeJS.ProcessEnv;
17
+ fetchImpl?: typeof fetch;
18
+ }): Promise<Address>;
19
+ /** Resolve the account-bound creator wallet for a transaction plan. Real sponsored sends may
20
+ * provision the stable wallet just as `openSponsoredSession` does; dry runs call the wrapper above
21
+ * and remain strictly read-only. */
22
+ export declare function sponsoredWalletAddress(chainKey: string, options?: {
23
+ env?: NodeJS.ProcessEnv;
24
+ fetchImpl?: typeof fetch;
25
+ provision?: boolean;
26
+ }): Promise<Address>;
27
+ export interface SponsoredReceipt {
28
+ txHash: Hex;
29
+ receipt: TransactionReceipt;
30
+ }
31
+ export interface SponsoredSession {
32
+ address: Address;
33
+ send(tx: PreparedTx): Promise<SponsoredReceipt>;
34
+ close(): void;
35
+ }
36
+ /** Pure boundary check shared by every sponsored operation. Privy's sponsored relay requires a
37
+ * call target, so custom-contract deployments must already be expressed as a call to the keyless
38
+ * CREATE2 proxy before they reach this boundary. */
39
+ export declare function assertSponsoredPreparedTx(tx: PreparedTx, chainId: number): asserts tx is PreparedTx & {
40
+ to: Address;
41
+ };
42
+ /** Resolve the first-party wallet API from its public remote catalog. The env override is an
43
+ * explicit local/staging escape hatch; production callers discover the interface from the
44
+ * services catalog and do not need to know a deployment hostname. */
45
+ export declare function creatorApiUrl(chainId: number, env?: NodeJS.ProcessEnv): Promise<string>;
46
+ /**
47
+ * Open one short-lived creator authorization session. The human authorizes the agent once; every
48
+ * exact transaction in this CLI invocation is then signed by that same ephemeral grant. Neither the
49
+ * OAuth token nor the decrypted authorization key is written to disk or returned to callers.
50
+ */
51
+ export declare function openSponsoredSession(chainKey: string): Promise<SponsoredSession>;
52
+ //# sourceMappingURL=creator-signer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"creator-signer.d.ts","sourceRoot":"","sources":["../src/creator-signer.ts"],"names":[],"mappings":"AAEA,OAAO,EAWL,KAAK,OAAO,EACZ,KAAK,GAAG,EACR,KAAK,UAAU,EAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,MAAM,CAAC;AAM7C;;8CAE8C;AAC9C,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAMrD;AAED,kGAAkG;AAClG,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAE9D;AAaD;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAC3C,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,KAAK,CAAA;CAAM,GAChE,OAAO,CAAC,OAAO,CAAC,CAElB;AAED;;oCAEoC;AACpC,wBAAsB,sBAAsB,CAC1C,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAM,GACrF,OAAO,CAAC,OAAO,CAAC,CA2BlB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,GAAG,CAAC;IACZ,OAAO,EAAE,kBAAkB,CAAC;CAC7B;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,EAAE,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAChD,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;oDAEoD;AACpD,wBAAgB,yBAAyB,CACvC,EAAE,EAAE,UAAU,EACd,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,EAAE,IAAI,UAAU,GAAG;IAAC,EAAE,EAAE,OAAO,CAAA;CAAC,CAY1C;AAmBD;;qEAEqE;AACrE,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,CAW1G;AAmBD;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAgGtF"}
@@ -0,0 +1,225 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { spawn } from 'node:child_process';
3
+ import { AbxServiceClient, CREATOR_WALLET_INTERFACE, CreatorApiClient, makePublicClient, pinGas, resolveChain, resolveServiceInterfaceEndpoint, sleep, TxRevertedError, waitForCodeAt, } from '@artblocks/abx-sdk';
4
+ import { CreatorAgentAuthorization } from './creator-agent.js';
5
+ import { ABX_SERVICES_URL } from './remote.js';
6
+ const SPONSORABLE_BASE_CHAINS = new Set([8_453, 84_532]);
7
+ /** Preserve the exact RPC estimate across the JSON service boundary. This is a serialization
8
+ * guard, not a sponsorship-policy ceiling; real EVM transaction limits are many orders of
9
+ * magnitude below Number.MAX_SAFE_INTEGER. */
10
+ export function sponsoredGasLimit(gas) {
11
+ const limit = Number(gas);
12
+ if (!Number.isSafeInteger(limit) || limit <= 0) {
13
+ throw new Error(`Sponsored transaction gas estimate ${gas} cannot be represented safely.`);
14
+ }
15
+ return limit;
16
+ }
17
+ /** Synchronous preflight for commands that may upload content before opening the signing lane. */
18
+ export function assertSponsorConfigured(chainKey) {
19
+ assertSponsorConfiguredWithEnv(chainKey, process.env);
20
+ }
21
+ function assertSponsorConfiguredWithEnv(chainKey, env) {
22
+ if (!SPONSORABLE_BASE_CHAINS.has(resolveChain(chainKey).id)) {
23
+ throw new Error('--sponsor is supported on eligible Base networks (Base and Base Sepolia only) and still requires live provider and account eligibility. Use --send, --sign, or --unsigned on this network.');
24
+ }
25
+ if (!env.ABX_SERVICES_API_KEY) {
26
+ throw new Error('--sponsor needs ABX_SERVICES_API_KEY in your ignored .env. Run `abx auth login` first.');
27
+ }
28
+ }
29
+ /**
30
+ * Resolve the existing account-bound creator wallet for a sponsored preview without provisioning
31
+ * a wallet or opening an authorization grant. A dry run must use the signer that the real send
32
+ * will use; silently falling back to a local env key changes the CREATE2 salt, owner, royalty
33
+ * receiver, and mint recipient shown in the preview.
34
+ */
35
+ export async function sponsoredPreviewAddress(chainKey, options = {}) {
36
+ return sponsoredWalletAddress(chainKey, { ...options, provision: false });
37
+ }
38
+ /** Resolve the account-bound creator wallet for a transaction plan. Real sponsored sends may
39
+ * provision the stable wallet just as `openSponsoredSession` does; dry runs call the wrapper above
40
+ * and remain strictly read-only. */
41
+ export async function sponsoredWalletAddress(chainKey, options = {}) {
42
+ const env = options.env ?? process.env;
43
+ const chain = resolveChain(chainKey);
44
+ assertSponsorConfiguredWithEnv(chainKey, env);
45
+ const apiKey = env.ABX_SERVICES_API_KEY;
46
+ const api = new CreatorApiClient({
47
+ baseUrl: await creatorApiUrl(chain.id, env),
48
+ token: apiKey,
49
+ fetchImpl: options.fetchImpl,
50
+ });
51
+ let account = await api.account();
52
+ if (!account.wallet && options.provision) {
53
+ await api.provisionWallet();
54
+ account = await api.account();
55
+ }
56
+ if (!account.wallet || !account.capabilities.wallet) {
57
+ throw new Error(options.provision
58
+ ? 'ABX Services did not return the creator wallet after provisioning.'
59
+ : 'Sponsored dry run needs an existing ABX creator wallet, but this account has not provisioned one yet. ' +
60
+ 'Provision the wallet through ABX Services first, then rerun; the preview will not create external state.');
61
+ }
62
+ if (!account.capabilities.sponsorship || !account.capabilities.sponsoredChains.includes(chain.id)) {
63
+ throw new Error(`ABX gas sponsorship is not enabled for ${chain.name} on this account.`);
64
+ }
65
+ return account.wallet.address;
66
+ }
67
+ /** Pure boundary check shared by every sponsored operation. Privy's sponsored relay requires a
68
+ * call target, so custom-contract deployments must already be expressed as a call to the keyless
69
+ * CREATE2 proxy before they reach this boundary. */
70
+ export function assertSponsoredPreparedTx(tx, chainId) {
71
+ if (tx.chainId !== chainId) {
72
+ throw new Error(`Refusing sponsored transaction for chain ${tx.chainId}; expected ${chainId}.`);
73
+ }
74
+ if (BigInt(tx.value) !== 0n) {
75
+ throw new Error('ABX sponsorship never covers a transaction that transfers ETH.');
76
+ }
77
+ if (tx.to === null) {
78
+ throw new Error('ABX sponsorship requires a call target; use `abx deploy-contract --sponsor` to route exact initcode through CREATE2.');
79
+ }
80
+ }
81
+ function checkedCreatorApiUrl(raw) {
82
+ const parsed = new URL(raw);
83
+ const local = parsed.hostname === 'localhost' || parsed.hostname === '127.0.0.1' || parsed.hostname === '[::1]';
84
+ if (parsed.username ||
85
+ parsed.password ||
86
+ parsed.search ||
87
+ parsed.hash ||
88
+ (parsed.protocol !== 'https:' && !(local && parsed.protocol === 'http:'))) {
89
+ throw new Error('ABX_CREATORS_API_URL must be HTTPS (or localhost HTTP for development) without credentials, a query, or a fragment.');
90
+ }
91
+ return parsed.toString().replace(/\/+$/, '');
92
+ }
93
+ /** Resolve the first-party wallet API from its public remote catalog. The env override is an
94
+ * explicit local/staging escape hatch; production callers discover the interface from the
95
+ * services catalog and do not need to know a deployment hostname. */
96
+ export async function creatorApiUrl(chainId, env = process.env) {
97
+ if (env.ABX_CREATORS_API_URL)
98
+ return checkedCreatorApiUrl(env.ABX_CREATORS_API_URL);
99
+ const descriptor = await new AbxServiceClient({ baseUrl: ABX_SERVICES_URL, timeoutMs: 10_000 }).descriptor();
100
+ const endpoint = resolveServiceInterfaceEndpoint(ABX_SERVICES_URL, descriptor, CREATOR_WALLET_INTERFACE);
101
+ if (!endpoint) {
102
+ throw new Error('The ABX remote does not advertise an account-bound creator-wallet service. Use --send, --sign, or --unsigned.');
103
+ }
104
+ if (!endpoint.chains.includes(chainId)) {
105
+ throw new Error(`The ABX creator-wallet service does not support chain ${chainId}. Use --send, --sign, or --unsigned.`);
106
+ }
107
+ return endpoint.baseUrl;
108
+ }
109
+ function openBrowser(url) {
110
+ if (process.env.CI)
111
+ return;
112
+ try {
113
+ const command = process.platform === 'darwin'
114
+ ? { file: 'open', args: [url] }
115
+ : process.platform === 'win32'
116
+ ? { file: 'rundll32', args: ['url.dll,FileProtocolHandler', url] }
117
+ : { file: 'xdg-open', args: [url] };
118
+ const child = spawn(command.file, command.args, { detached: true, stdio: 'ignore' });
119
+ child.on('error', () => { });
120
+ child.unref();
121
+ }
122
+ catch {
123
+ // The complete URL and code are always printed below.
124
+ }
125
+ }
126
+ /**
127
+ * Open one short-lived creator authorization session. The human authorizes the agent once; every
128
+ * exact transaction in this CLI invocation is then signed by that same ephemeral grant. Neither the
129
+ * OAuth token nor the decrypted authorization key is written to disk or returned to callers.
130
+ */
131
+ export async function openSponsoredSession(chainKey) {
132
+ const chain = resolveChain(chainKey);
133
+ assertSponsorConfigured(chainKey);
134
+ const apiKey = process.env.ABX_SERVICES_API_KEY;
135
+ if (!apiKey)
136
+ throw new Error('ABX Services API key disappeared after sponsorship preflight.');
137
+ const api = new CreatorApiClient({ baseUrl: await creatorApiUrl(chain.id), token: apiKey });
138
+ const wallet = await api.provisionWallet();
139
+ const account = await api.account();
140
+ if (!account.wallet || account.wallet.address.toLowerCase() !== wallet.address.toLowerCase()) {
141
+ throw new Error('ABX Creators returned inconsistent wallet binding. Nothing was signed.');
142
+ }
143
+ if (!account.capabilities.sponsorship || !account.capabilities.sponsoredChains.includes(chain.id)) {
144
+ throw new Error(`ABX gas sponsorship is not enabled for ${chain.name} on this account.`);
145
+ }
146
+ const authorization = new CreatorAgentAuthorization({ appId: wallet.providerAppId });
147
+ try {
148
+ const device = await authorization.start();
149
+ const verificationUrl = device.verificationUriComplete ?? device.verificationUri;
150
+ console.log(`\n Authorize this agent once for the transaction group:`);
151
+ console.log(` ${verificationUrl}`);
152
+ console.log(` Code: ${device.userCode}\n`);
153
+ openBrowser(verificationUrl);
154
+ const wallets = await authorization.wait();
155
+ const authorized = wallets.find((candidate) => candidate.chainType === 'ethereum' && candidate.address.toLowerCase() === wallet.address.toLowerCase());
156
+ if (!authorized)
157
+ throw new Error(`Privy authorized a different wallet; expected ${wallet.address}.`);
158
+ const publicClient = makePublicClient({ chainKey });
159
+ let closed = false;
160
+ return {
161
+ address: wallet.address,
162
+ async send(tx) {
163
+ if (closed)
164
+ throw new Error('The creator authorization session is closed.');
165
+ assertSponsoredPreparedTx(tx, chain.id);
166
+ if (tx.gasFloor && tx.to)
167
+ await waitForCodeAt(publicClient, tx.to);
168
+ const gas = await pinGas(publicClient, {
169
+ from: wallet.address,
170
+ to: tx.to,
171
+ data: tx.data,
172
+ value: tx.value,
173
+ gasFloor: tx.gasFloor,
174
+ });
175
+ const operationId = `op_${randomUUID().replaceAll('-', '')}`;
176
+ const prepared = await api.prepare({
177
+ operationId,
178
+ chainId: chain.id,
179
+ to: tx.to,
180
+ value: tx.value,
181
+ data: tx.data,
182
+ gasLimit: sponsoredGasLimit(gas),
183
+ });
184
+ const signed = authorization.sign({
185
+ walletId: prepared.signingRequest.walletId,
186
+ body: prepared.signingRequest.body,
187
+ idempotencyKey: prepared.signingRequest.idempotencyKey,
188
+ requestExpiry: prepared.signingRequest.requestExpiry,
189
+ });
190
+ let operation = await api.submit(operationId, {
191
+ requestExpiry: prepared.signingRequest.requestExpiry,
192
+ data: tx.data,
193
+ signed,
194
+ });
195
+ const deadline = Date.now() + 180_000;
196
+ while (operation.state === 'prepared' ||
197
+ operation.state === 'submitting' ||
198
+ operation.state === 'pending' ||
199
+ operation.state === 'unknown') {
200
+ if (Date.now() >= deadline) {
201
+ throw new Error(`Sponsored operation ${operationId} could not be reconciled. It may have been submitted; check its status before doing anything else and do not retry it.`);
202
+ }
203
+ await sleep(1_500);
204
+ operation = await api.getOperation(operationId);
205
+ }
206
+ if (operation.state !== 'confirmed' || !operation.transactionHash) {
207
+ throw new Error(`Sponsored operation ${operationId} failed${operation.errorCode ? ` (${operation.errorCode})` : ''}.`);
208
+ }
209
+ const receipt = await publicClient.waitForTransactionReceipt({ hash: operation.transactionHash });
210
+ if (receipt.status !== 'success')
211
+ throw new TxRevertedError(tx.op, operation.transactionHash);
212
+ return { txHash: operation.transactionHash, receipt };
213
+ },
214
+ close() {
215
+ closed = true;
216
+ authorization.dispose();
217
+ },
218
+ };
219
+ }
220
+ catch (error) {
221
+ authorization.dispose();
222
+ throw error;
223
+ }
224
+ }
225
+ //# sourceMappingURL=creator-signer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"creator-signer.js","sourceRoot":"","sources":["../src/creator-signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AACvC,OAAO,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAC;AACzC,OAAO,EACL,gBAAgB,EAChB,w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