@andrewkimjoseph/celina-sdk 0.15.3 → 0.15.5
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/README.md +7 -8
- package/build/aa/create-aa-client.d.ts +2 -2
- package/build/aa/create-aa-client.js +1 -1
- package/build/aa/prepared-calls.d.ts +1 -1
- package/build/aa/prepared-calls.js +1 -1
- package/build/aa/types.d.ts +1 -1
- package/build/config/celina-tag.d.ts +9 -16
- package/build/config/celina-tag.js +21 -71
- package/build/config/celina-tag.js.map +1 -1
- package/build/config/sdk-config.d.ts +3 -5
- package/build/config/sdk-config.js.map +1 -1
- package/build/index.d.ts +9 -3
- package/build/index.js +9 -5
- package/build/index.js.map +1 -1
- package/build/services/agentkarma-lazy.d.ts +13 -0
- package/build/services/agentkarma-lazy.js +39 -0
- package/build/services/agentkarma-lazy.js.map +1 -0
- package/build/services/blockchain.service.d.ts +1 -1
- package/build/services/blockchain.service.js +1 -1
- package/build/services/transaction.service.d.ts +1 -1
- package/build/services/transaction.service.js +1 -1
- package/build/src/aa/create-aa-client.d.ts +2 -2
- package/build/src/aa/create-aa-client.js +1 -1
- package/build/src/aa/prepared-calls.d.ts +1 -1
- package/build/src/aa/prepared-calls.js +1 -1
- package/build/src/aa/types.d.ts +1 -1
- package/build/src/config/celina-tag.d.ts +9 -16
- package/build/src/config/celina-tag.js +21 -71
- package/build/src/config/celina-tag.js.map +1 -1
- package/build/src/config/sdk-config.d.ts +3 -5
- package/build/src/config/sdk-config.js.map +1 -1
- package/build/src/index.d.ts +9 -3
- package/build/src/index.js +9 -5
- package/build/src/index.js.map +1 -1
- package/build/src/services/agentkarma-lazy.d.ts +13 -0
- package/build/src/services/agentkarma-lazy.js +39 -0
- package/build/src/services/agentkarma-lazy.js.map +1 -0
- package/build/src/services/blockchain.service.d.ts +1 -1
- package/build/src/services/blockchain.service.js +1 -1
- package/build/src/services/transaction.service.d.ts +1 -1
- package/build/src/services/transaction.service.js +1 -1
- package/build/src/tools/domains/blockchain.js +2 -2
- package/build/src/tools/domains/blockchain.js.map +1 -1
- package/build/src/types/prepared.d.ts +1 -1
- package/build/tools/domains/blockchain.js +2 -2
- package/build/tools/domains/blockchain.js.map +1 -1
- package/build/types/prepared.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
# Celina SDK
|
|
6
6
|
|
|
7
|
+
> **Server-side only.** This package includes server-native dependencies (`@agentkarma/sdk`, `@celo/attribution-tags`) that cannot be bundled for the browser. Import it only from Node.js environments — API routes, background workers (BullMQ / Vercel Cron), or CLI scripts.
|
|
8
|
+
|
|
7
9
|
Celo mainnet library for frontend apps and agents: **reads**, **unsigned transaction preparation**, and optional **ERC-4337 AA** via `createAAClient` (app-owned gas sponsorship credentials).
|
|
8
10
|
|
|
9
11
|
Pair with [wagmi](https://wagmi.sh) / viem for EOA signing, or `createAAClient` for sponsored/batched UserOps.
|
|
@@ -14,7 +16,7 @@ Celina is layered from chain logic through agent tooling:
|
|
|
14
16
|
|
|
15
17
|
| Layer | Package | Role |
|
|
16
18
|
|-------|---------|------|
|
|
17
|
-
| **SDK** | `@andrewkimjoseph/celina-sdk` | Reads, gas estimates, `prepare*` flows (`chainId: 42220`),
|
|
19
|
+
| **SDK** | `@andrewkimjoseph/celina-sdk` | Reads, gas estimates, `prepare*` flows (`chainId: 42220`), ERC-8021 attribution, `createAAClient` |
|
|
18
20
|
| **MCP** | `@andrewkimjoseph/celina-mcp` | MCP tools for Cursor / Claude / LM Studio — stdio writes or hosted reads |
|
|
19
21
|
| **MCP host** | `celina-mcp-host` | Vercel Streamable HTTP — hosted reads (36 tools); no server-key writes; no sponsorship keys |
|
|
20
22
|
|
|
@@ -43,7 +45,7 @@ Before broadcasting prepared steps, call `simulatePreparedStep` from `@andrewkim
|
|
|
43
45
|
- [Quick start](https://andrewkimjoseph.gitbook.io/celina-sdk/getting-started/quick-start)
|
|
44
46
|
- [LLM tool catalog](docs/guides/tool-catalog.md) — `@andrewkimjoseph/celina-sdk/tools` for MCP and AI SDK hosts
|
|
45
47
|
- [Architecture](docs/concepts/architecture.md) — client composition and stack
|
|
46
|
-
- [Prepared flows](docs/concepts/prepared-flows.md) — `SerializedPreparedFlow` (`chainId: 42220`),
|
|
48
|
+
- [Prepared flows](docs/concepts/prepared-flows.md) — `SerializedPreparedFlow` (`chainId: 42220`), ERC-8021 Celina attribution
|
|
47
49
|
- [On-chain attribution](docs/guides/on-chain-attribution.md) — wire format, check vs verify, Celina vs AA tags
|
|
48
50
|
- [Account Abstraction](docs/guides/account-abstraction.md) — `createAAClient`, app-owned sponsorship, AA `attributionTags`
|
|
49
51
|
- [Prepared-step simulation](docs/guides/prepared-step-simulation.md) — `simulatePreparedStep` before wallet send
|
|
@@ -63,7 +65,7 @@ import { createCelinaClient } from "@andrewkimjoseph/celina-sdk";
|
|
|
63
65
|
|
|
64
66
|
const celina = createCelinaClient({
|
|
65
67
|
attributionTags: ["celo_862c21dd97a7", "my_app"],
|
|
66
|
-
//
|
|
68
|
+
// ERC-8021 → codes celina, celo_862c21dd97a7, my_app
|
|
67
69
|
});
|
|
68
70
|
|
|
69
71
|
await celina.token.getStablecoinBalances("0xYourAddress");
|
|
@@ -90,12 +92,9 @@ const reserveFlow = await celina.gooddollar.prepareReserveSwap(
|
|
|
90
92
|
|
|
91
93
|
All `prepare*` methods return a **`SerializedPreparedFlow`**: ordered unsigned steps for the user's wallet.
|
|
92
94
|
|
|
93
|
-
Every step with calldata gets **
|
|
94
|
-
|
|
95
|
-
1. **Legacy UTF-8** — `CELINA|TAG1|TAG2` (app tags uppercase; `celo_<12 hex>` lowercase)
|
|
96
|
-
2. **ERC-8021 Schema 0** — `toDataSuffix(["celina", ...])` via `@celo/attribution-tags` for Celo leaderboards and `verifyTx`
|
|
95
|
+
Every step with calldata gets an **ERC-8021 Schema 0** attribution suffix via `appendCelinaCalldataTag` — sends, Mento FX, Uniswap, Aave, and GoodDollar. Pass `step.data` to wagmi unchanged.
|
|
97
96
|
|
|
98
|
-
Optional `attributionTags` in `createCelinaClient({ attributionTags: [...] })`
|
|
97
|
+
Optional `attributionTags` in `createCelinaClient({ attributionTags: [...] })` set custom codes after platform `celina` (deduped, stable order). The same option on **`createAAClient`** tags at `sendPreparedFlow` time (omit for pass-through). Prepared flows expose **`chainId: 42220`**. List or check on-chain tags with `check_attribution_tag` (preferred) or `checkAttributionInCalldata`; use `verify_attribution_tag` / `verifyAttributionInCalldata` for raw layers (including historical legacy `CELINA|…` when present).
|
|
99
98
|
|
|
100
99
|
Before opening the wallet, simulate each step against current chain state with `@andrewkimjoseph/celina-sdk/simulation` (`simulatePreparedStep`). Local **celina-mcp** stdio writes use the same helper in `executePreparedFlow` before broadcast.
|
|
101
100
|
|
|
@@ -26,7 +26,7 @@ export type AAClient = {
|
|
|
26
26
|
attributionTags: string[] | undefined;
|
|
27
27
|
/**
|
|
28
28
|
* Submit `prepare*` output (ordered `steps` / prepared transactions) as sponsored UserOp(s).
|
|
29
|
-
* When `attributionTags` were set on this client, each step’s `data` is
|
|
29
|
+
* When `attributionTags` were set on this client, each step’s `data` is ERC-8021-tagged
|
|
30
30
|
* before submit; otherwise `data` is used as-is (including tags from `prepare*`).
|
|
31
31
|
*/
|
|
32
32
|
sendPreparedFlow: (flow: PreparedFlow | SerializedPreparedFlow, options?: SendPreparedFlowOptions) => Promise<SendPreparedFlowResult>;
|
|
@@ -38,7 +38,7 @@ export type AAClient = {
|
|
|
38
38
|
* and never stored by Celina. v1 supports `provider: "pimlico"`.
|
|
39
39
|
*
|
|
40
40
|
* Optional `attributionTags` are applied in `sendPreparedFlow` via
|
|
41
|
-
* `appendCelinaCalldataTag` (same
|
|
41
|
+
* `appendCelinaCalldataTag` (same ERC-8021 format as `prepare*`). Omit them to
|
|
42
42
|
* pass step calldata through unchanged.
|
|
43
43
|
*/
|
|
44
44
|
export declare function createAAClient(options: CreateAAClientOptions): Promise<AAClient>;
|
|
@@ -45,7 +45,7 @@ export async function deriveSmartAccountAddress(owner, publicClient) {
|
|
|
45
45
|
* and never stored by Celina. v1 supports `provider: "pimlico"`.
|
|
46
46
|
*
|
|
47
47
|
* Optional `attributionTags` are applied in `sendPreparedFlow` via
|
|
48
|
-
* `appendCelinaCalldataTag` (same
|
|
48
|
+
* `appendCelinaCalldataTag` (same ERC-8021 format as `prepare*`). Omit them to
|
|
49
49
|
* pass step calldata through unchanged.
|
|
50
50
|
*/
|
|
51
51
|
export async function createAAClient(options) {
|
|
@@ -2,7 +2,7 @@ import type { PreparedTx } from "../types/prepared.js";
|
|
|
2
2
|
import type { UserOpCall } from "./types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Map Celina prepared steps to smart-account `calls`.
|
|
5
|
-
* When `attributionTags` is provided, each step's `data` is
|
|
5
|
+
* When `attributionTags` is provided, each step's `data` is ERC-8021-tagged
|
|
6
6
|
* via {@link appendCelinaCalldataTag}; otherwise `data` is preserved as-is.
|
|
7
7
|
*/
|
|
8
8
|
export declare function preparedStepsToUserOpCalls(steps: PreparedTx[], attributionTags?: string[]): UserOpCall[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { appendCelinaCalldataTag } from "../config/celina-tag.js";
|
|
2
2
|
/**
|
|
3
3
|
* Map Celina prepared steps to smart-account `calls`.
|
|
4
|
-
* When `attributionTags` is provided, each step's `data` is
|
|
4
|
+
* When `attributionTags` is provided, each step's `data` is ERC-8021-tagged
|
|
5
5
|
* via {@link appendCelinaCalldataTag}; otherwise `data` is preserved as-is.
|
|
6
6
|
*/
|
|
7
7
|
export function preparedStepsToUserOpCalls(steps, attributionTags) {
|
package/build/aa/types.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export type CreateAAClientOptions = {
|
|
|
30
30
|
publicClient?: PublicClient;
|
|
31
31
|
/**
|
|
32
32
|
* Optional custom tags applied via `appendCelinaCalldataTag` on each step's `data`
|
|
33
|
-
* in `sendPreparedFlow` (
|
|
33
|
+
* in `sendPreparedFlow` (ERC-8021 Schema 0). When omitted, step data
|
|
34
34
|
* is passed through unchanged.
|
|
35
35
|
*/
|
|
36
36
|
attributionTags?: string[];
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { ERC_8021_MARKER } from "@celo/attribution-tags";
|
|
2
|
-
/** Legacy UTF-8 marker hex(`"CELINA"`) used inside the dual attribution suffix — not the full on-chain tag by itself. Full wire format is legacy `CELINA|…` plus an ERC-8021 Schema 0 suffix; see {@link appendCelinaCalldataTag}. */
|
|
3
|
-
export declare const CELINA_DATA_SUFFIX: `0x${string}`;
|
|
4
2
|
export { ERC_8021_MARKER };
|
|
5
3
|
/** Normalize custom attribution tags while preserving first-seen order. */
|
|
6
4
|
export declare function normalizeAttributionTags(tags?: string[]): string[];
|
|
7
|
-
/** Build deterministic attribution tag string that always starts with `CELINA`. */
|
|
8
|
-
export declare function buildCelinaAttributionTag(tags?: string[]): string;
|
|
9
5
|
/** Map client attribution tags to ERC-8021 Schema 0 codes (lowercase `[a-z0-9_]` only). */
|
|
10
6
|
export declare function toErc8021AttributionCodes(attributionTags?: string[]): string[];
|
|
11
7
|
/** Build ERC-8021 Schema 0 suffix hex for the given attribution tags. */
|
|
@@ -17,10 +13,7 @@ export declare function buildErc8021AttributionSuffix(attributionTags?: string[]
|
|
|
17
13
|
export declare function attributionDecodeWindow(data: `0x${string}`): `0x${string}`;
|
|
18
14
|
/** Strip a trailing ERC-8021 Schema 0/2 suffix when present. */
|
|
19
15
|
export declare function stripErc8021SuffixIfPresent(data: `0x${string}`): `0x${string}`;
|
|
20
|
-
/** Parse legacy UTF-8 `CELINA|TAG1|…` suffix from calldata (ignores trailing ERC-8021). */
|
|
21
|
-
export declare function parseCelinaLegacyAttributionSuffix(data: `0x${string}`): string[] | null;
|
|
22
16
|
export type AttributionVerificationResult = {
|
|
23
|
-
legacyTags: string[] | null;
|
|
24
17
|
erc8021: {
|
|
25
18
|
codes: string[];
|
|
26
19
|
schemaId: number;
|
|
@@ -31,25 +24,25 @@ export type AttributionVerificationResult = {
|
|
|
31
24
|
export type AttributionCheckResult = AttributionVerificationResult & {
|
|
32
25
|
tags: string[];
|
|
33
26
|
};
|
|
34
|
-
/** Merge
|
|
35
|
-
export declare function collectAttributionTags(
|
|
36
|
-
/** Decode
|
|
27
|
+
/** Merge ERC-8021 codes into custom tags (skips platform `celina`, dedupes). */
|
|
28
|
+
export declare function collectAttributionTags(erc8021Codes: string[] | null): string[];
|
|
29
|
+
/** Decode ERC-8021 attribution from calldata; optionally check for a tag. */
|
|
37
30
|
export declare function verifyAttributionInCalldata(data: `0x${string}`, tag?: string): AttributionVerificationResult;
|
|
38
31
|
/**
|
|
39
|
-
* Decode attribution from calldata with a unified custom `tags` list.
|
|
40
|
-
* Prefer this for
|
|
32
|
+
* Decode ERC-8021 attribution from calldata with a unified custom `tags` list.
|
|
33
|
+
* Prefer this for "what tags are on this tx?"; use {@link verifyAttributionInCalldata} for the raw layer only.
|
|
41
34
|
*/
|
|
42
35
|
export declare function checkAttributionInCalldata(data: `0x${string}`, tag?: string): AttributionCheckResult;
|
|
43
36
|
/**
|
|
44
|
-
* Append
|
|
37
|
+
* Append Celina ERC-8021 Schema 0 attribution to calldata (no legacy UTF-8 `CELINA|...`).
|
|
45
38
|
*
|
|
46
39
|
* Used by `prepare*` when `createCelinaClient({ attributionTags })` is set, and by
|
|
47
40
|
* `createAAClient({ attributionTags }).sendPreparedFlow` when AA tags are set.
|
|
48
41
|
*
|
|
49
42
|
* @param data - Original transaction calldata.
|
|
50
43
|
* @param attributionTags - Optional custom tags (same list semantics on Celina or AA client).
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
44
|
+
* ERC-8021: `toDataSuffix(["celina", ...])` with lowercase codes.
|
|
45
|
+
* Example: `["goclaim"]` -> codes `celina`, `goclaim`.
|
|
46
|
+
* Existing legacy UTF-8 on `data` is left in place; a matching ERC-8021 suffix is ensured.
|
|
54
47
|
*/
|
|
55
48
|
export declare function appendCelinaCalldataTag(data: `0x${string}`, attributionTags?: string[]): `0x${string}`;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { ERC_8021_MARKER, fromDataSuffix, toDataSuffix, } from "@celo/attribution-tags";
|
|
2
|
-
import { concat
|
|
3
|
-
/** Legacy UTF-8 marker hex(`"CELINA"`) used inside the dual attribution suffix — not the full on-chain tag by itself. Full wire format is legacy `CELINA|…` plus an ERC-8021 Schema 0 suffix; see {@link appendCelinaCalldataTag}. */
|
|
4
|
-
export const CELINA_DATA_SUFFIX = stringToHex("CELINA");
|
|
2
|
+
import { concat } from "viem";
|
|
5
3
|
export { ERC_8021_MARKER };
|
|
6
4
|
/** Celo Builders on-chain attribution tag: `celo_` + 12 hex chars (lowercase). */
|
|
7
5
|
const CELO_BUILDERS_TAG = /^celo_[0-9a-f]{12}$/i;
|
|
@@ -26,11 +24,6 @@ export function normalizeAttributionTags(tags) {
|
|
|
26
24
|
}
|
|
27
25
|
return [...deduped];
|
|
28
26
|
}
|
|
29
|
-
/** Build deterministic attribution tag string that always starts with `CELINA`. */
|
|
30
|
-
export function buildCelinaAttributionTag(tags) {
|
|
31
|
-
const normalized = normalizeAttributionTags(tags);
|
|
32
|
-
return normalized.length ? `CELINA|${normalized.join("|")}` : "CELINA";
|
|
33
|
-
}
|
|
34
27
|
/** Map client attribution tags to ERC-8021 Schema 0 codes (lowercase `[a-z0-9_]` only). */
|
|
35
28
|
export function toErc8021AttributionCodes(attributionTags) {
|
|
36
29
|
const codes = [CELINA_PLATFORM_ERC8021_CODE];
|
|
@@ -46,9 +39,6 @@ export function buildErc8021AttributionSuffix(attributionTags) {
|
|
|
46
39
|
? toDataSuffix(codes[0])
|
|
47
40
|
: toDataSuffix(codes);
|
|
48
41
|
}
|
|
49
|
-
function buildLegacyAttributionSuffixHex(attributionTags) {
|
|
50
|
-
return stringToHex(buildCelinaAttributionTag(attributionTags));
|
|
51
|
-
}
|
|
52
42
|
function sameCodeSets(a, b) {
|
|
53
43
|
if (a.length !== b.length)
|
|
54
44
|
return false;
|
|
@@ -133,55 +123,23 @@ export function stripErc8021SuffixIfPresent(data) {
|
|
|
133
123
|
return data;
|
|
134
124
|
return `0x${hex.slice(0, suffixStart)}`;
|
|
135
125
|
}
|
|
136
|
-
|
|
137
|
-
const LEGACY_ATTRIBUTION_TEXT = /^CELINA(?:\|[A-Za-z0-9_]+)*/;
|
|
138
|
-
/** Parse legacy UTF-8 `CELINA|TAG1|…` suffix from calldata (ignores trailing ERC-8021). */
|
|
139
|
-
export function parseCelinaLegacyAttributionSuffix(data) {
|
|
140
|
-
const body = stripErc8021SuffixIfPresent(data);
|
|
141
|
-
const celinaMarker = stringToHex("CELINA").slice(2).toLowerCase();
|
|
142
|
-
const lower = body.slice(2).toLowerCase();
|
|
143
|
-
const idx = lower.lastIndexOf(celinaMarker);
|
|
144
|
-
if (idx === -1)
|
|
145
|
-
return null;
|
|
146
|
-
try {
|
|
147
|
-
const suffixHex = `0x${body.slice(2).slice(idx)}`;
|
|
148
|
-
const text = hexToString(suffixHex);
|
|
149
|
-
if (!text.startsWith("CELINA"))
|
|
150
|
-
return null;
|
|
151
|
-
const printable = text.match(LEGACY_ATTRIBUTION_TEXT)?.[0];
|
|
152
|
-
if (!printable)
|
|
153
|
-
return null;
|
|
154
|
-
return printable.split("|");
|
|
155
|
-
}
|
|
156
|
-
catch {
|
|
157
|
-
return null;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
function tagMatchesVerification(tag, legacyTags, erc8021Codes) {
|
|
126
|
+
function tagMatchesVerification(tag, erc8021Codes) {
|
|
161
127
|
const normalized = normalizeAttributionTag(tag);
|
|
162
|
-
|
|
163
|
-
false;
|
|
164
|
-
const ercHit = erc8021Codes?.some((code) => code.toLowerCase() === normalized.toLowerCase()) ??
|
|
165
|
-
false;
|
|
166
|
-
return legacyHit || ercHit;
|
|
128
|
+
return (erc8021Codes?.some((code) => code.toLowerCase() === normalized.toLowerCase()) ??
|
|
129
|
+
false);
|
|
167
130
|
}
|
|
168
|
-
/** Merge
|
|
169
|
-
export function collectAttributionTags(
|
|
170
|
-
return normalizeAttributionTags([
|
|
171
|
-
...(legacyTags ?? []),
|
|
172
|
-
...(erc8021Codes ?? []),
|
|
173
|
-
]);
|
|
131
|
+
/** Merge ERC-8021 codes into custom tags (skips platform `celina`, dedupes). */
|
|
132
|
+
export function collectAttributionTags(erc8021Codes) {
|
|
133
|
+
return normalizeAttributionTags(erc8021Codes ?? []);
|
|
174
134
|
}
|
|
175
|
-
/** Decode
|
|
135
|
+
/** Decode ERC-8021 attribution from calldata; optionally check for a tag. */
|
|
176
136
|
export function verifyAttributionInCalldata(data, tag) {
|
|
177
137
|
const window = attributionDecodeWindow(data);
|
|
178
|
-
const legacyTags = parseCelinaLegacyAttributionSuffix(window);
|
|
179
138
|
const erc8021 = fromDataSuffix(window);
|
|
180
139
|
const matched = tag
|
|
181
|
-
? tagMatchesVerification(tag,
|
|
182
|
-
: Boolean(
|
|
140
|
+
? tagMatchesVerification(tag, erc8021?.codes ?? null)
|
|
141
|
+
: Boolean(erc8021?.codes.length);
|
|
183
142
|
return {
|
|
184
|
-
legacyTags,
|
|
185
143
|
erc8021: erc8021
|
|
186
144
|
? { codes: [...erc8021.codes], schemaId: erc8021.schemaId }
|
|
187
145
|
: null,
|
|
@@ -189,46 +147,38 @@ export function verifyAttributionInCalldata(data, tag) {
|
|
|
189
147
|
};
|
|
190
148
|
}
|
|
191
149
|
/**
|
|
192
|
-
* Decode attribution from calldata with a unified custom `tags` list.
|
|
193
|
-
* Prefer this for
|
|
150
|
+
* Decode ERC-8021 attribution from calldata with a unified custom `tags` list.
|
|
151
|
+
* Prefer this for "what tags are on this tx?"; use {@link verifyAttributionInCalldata} for the raw layer only.
|
|
194
152
|
*/
|
|
195
153
|
export function checkAttributionInCalldata(data, tag) {
|
|
196
154
|
const verified = verifyAttributionInCalldata(data, tag);
|
|
197
155
|
return {
|
|
198
156
|
...verified,
|
|
199
|
-
tags: collectAttributionTags(verified.
|
|
157
|
+
tags: collectAttributionTags(verified.erc8021?.codes ?? null),
|
|
200
158
|
};
|
|
201
159
|
}
|
|
202
160
|
/**
|
|
203
|
-
* Append
|
|
161
|
+
* Append Celina ERC-8021 Schema 0 attribution to calldata (no legacy UTF-8 `CELINA|...`).
|
|
204
162
|
*
|
|
205
163
|
* Used by `prepare*` when `createCelinaClient({ attributionTags })` is set, and by
|
|
206
164
|
* `createAAClient({ attributionTags }).sendPreparedFlow` when AA tags are set.
|
|
207
165
|
*
|
|
208
166
|
* @param data - Original transaction calldata.
|
|
209
167
|
* @param attributionTags - Optional custom tags (same list semantics on Celina or AA client).
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
168
|
+
* ERC-8021: `toDataSuffix(["celina", ...])` with lowercase codes.
|
|
169
|
+
* Example: `["goclaim"]` -> codes `celina`, `goclaim`.
|
|
170
|
+
* Existing legacy UTF-8 on `data` is left in place; a matching ERC-8021 suffix is ensured.
|
|
213
171
|
*/
|
|
214
172
|
export function appendCelinaCalldataTag(data, attributionTags) {
|
|
215
173
|
if (!data || data === "0x")
|
|
216
174
|
return data;
|
|
217
|
-
const legacyHex = buildLegacyAttributionSuffixHex(attributionTags);
|
|
218
|
-
const legacySuffix = legacyHex.slice(2);
|
|
219
175
|
const erc8021Hex = buildErc8021AttributionSuffix(attributionTags);
|
|
220
176
|
const expectedCodes = toErc8021AttributionCodes(attributionTags);
|
|
221
|
-
const
|
|
222
|
-
if (
|
|
177
|
+
const tip = fromDataSuffix(data);
|
|
178
|
+
if (tip && sameCodeSets(tip.codes, expectedCodes)) {
|
|
223
179
|
return data;
|
|
224
|
-
let result = stripErc8021SuffixIfPresent(data);
|
|
225
|
-
if (!result.toLowerCase().endsWith(legacySuffix.toLowerCase())) {
|
|
226
|
-
result = concat([result, legacyHex]);
|
|
227
|
-
}
|
|
228
|
-
const decoded = fromDataSuffix(result);
|
|
229
|
-
if (!decoded || !sameCodeSets(decoded.codes, expectedCodes)) {
|
|
230
|
-
result = concat([result, erc8021Hex]);
|
|
231
180
|
}
|
|
232
|
-
|
|
181
|
+
const without8021 = stripErc8021SuffixIfPresent(data);
|
|
182
|
+
return concat([without8021, erc8021Hex]);
|
|
233
183
|
}
|
|
234
184
|
//# sourceMappingURL=celina-tag.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"celina-tag.js","sourceRoot":"","sources":["../../src/config/celina-tag.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,cAAc,EACd,YAAY,GACb,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"celina-tag.js","sourceRoot":"","sources":["../../src/config/celina-tag.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,cAAc,EACd,YAAY,GACb,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAE9B,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,kFAAkF;AAClF,MAAM,iBAAiB,GAAG,sBAAsB,CAAC;AAEjD,MAAM,4BAA4B,GAAG,QAAQ,CAAC;AAE9C,SAAS,uBAAuB,CAAC,GAAW;IAC1C,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IAC3B,IAAI,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACpC,OAAO,OAAO,CAAC,WAAW,EAAE,CAAC;IAC/B,CAAC;IACD,OAAO,OAAO,CAAC,WAAW,EAAE,CAAC;AAC/B,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,wBAAwB,CAAC,IAAe;IACtD,IAAI,CAAC,IAAI,EAAE,MAAM;QAAE,OAAO,EAAE,CAAC;IAC7B,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,UAAU,GAAG,uBAAuB,CAA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CAAC,CAAC;IACjC,IAAI,GAAG,IAAI,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,aAAa,CAAC,EAAE,CAAC;QAClD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,WAAW,GAAG,2BAA2B,CAAC,IAAI,CAAC,CAAC;IACtD,OAAO,MAAM,CAAC,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -24,12 +24,10 @@ export interface SdkConfig {
|
|
|
24
24
|
*/
|
|
25
25
|
analyticsWalletAddress?: string;
|
|
26
26
|
/**
|
|
27
|
-
* Optional custom calldata attribution tags
|
|
28
|
-
*
|
|
29
|
-
* An ERC-8021 Schema 0 suffix (`toDataSuffix`) is also appended for Celo ecosystem
|
|
30
|
-
* leaderboards and `verifyTx` compatibility.
|
|
27
|
+
* Optional custom calldata attribution tags for ERC-8021 Schema 0 codes
|
|
28
|
+
* after platform `celina` on prepared transaction steps (deduped, stable order).
|
|
31
29
|
*
|
|
32
|
-
* App tags (e.g. `celeste_ai`) normalize to uppercase (`CELESTE_AI`).
|
|
30
|
+
* App tags (e.g. `celeste_ai`) normalize to uppercase (`CELESTE_AI`) then lowercase codes.
|
|
33
31
|
* Celo Builders on-chain tags matching `celo_<12 hex>` canonicalize to lowercase
|
|
34
32
|
* (e.g. `celo_862c21dd97a7`). The literal tag `CELINA` is never duplicated.
|
|
35
33
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-config.js","sourceRoot":"","sources":["../../src/config/sdk-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"sdk-config.js","sourceRoot":"","sources":["../../src/config/sdk-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAsC7E,iDAAiD;AACjD,MAAM,CAAC,MAAM,eAAe,GAAG,wBAAwB,CAAC;AAExD;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAyB;IACxD,MAAM,mBAAmB,GACvB,IAAI,EAAE,mBAAmB;QACzB,CAAC,OAAO,OAAO,KAAK,WAAW;YAC7B,CAAC,CAAE,OAAO,CAAC,GAAG,CAAC,sBAAoD;YACnE,CAAC,CAAC,SAAS,CAAC,CAAC;IAEjB,OAAO;QACL,MAAM,EAAE,IAAI,EAAE,MAAM,IAAI,eAAe;QACvC,SAAS,EAAE,IAAI,EAAE,SAAS;QAC1B,mBAAmB;QACnB,WAAW,EACT,IAAI,EAAE,WAAW;YACjB,CAAC,OAAO,OAAO,KAAK,WAAW;gBAC7B,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB;gBACjC,CAAC,CAAC,SAAS,CAAC;QAChB,gBAAgB,EAAE,IAAI,EAAE,gBAAgB;QACxC,eAAe,EAAE,IAAI,EAAE,eAAe;QACtC,iBAAiB,EACf,IAAI,EAAE,iBAAiB,IAAI,yBAAyB,EAAE;QACxD,sBAAsB,EAAE,IAAI,EAAE,sBAAsB;QACpD,eAAe,EAAE,IAAI,EAAE,eAAe;KACvC,CAAC;AACJ,CAAC"}
|
package/build/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type SdkConfig } from "./config/sdk-config.js";
|
|
2
2
|
import { AccountService } from "./services/account.service.js";
|
|
3
|
-
import { AgentKarmaService,
|
|
3
|
+
import type { AgentKarmaService, AgentKarmaServiceConfig } from "./services/agentkarma.service.js";
|
|
4
4
|
import { AaveService } from "./services/aave.service.js";
|
|
5
5
|
import { BlockchainService } from "./services/blockchain.service.js";
|
|
6
6
|
import { ContractService } from "./services/contract.service.js";
|
|
@@ -62,6 +62,12 @@ export interface CelinaClient {
|
|
|
62
62
|
/**
|
|
63
63
|
* Create a Celina client for Celo mainnet reads and unsigned tx preparation.
|
|
64
64
|
* No private keys — pass prepared `steps` to wagmi/viem for wallet signing.
|
|
65
|
+
*
|
|
66
|
+
* @remarks
|
|
67
|
+
* **Server-side only.** Celina SDK includes server-native dependencies
|
|
68
|
+
* (`@agentkarma/sdk`, `@celo/attribution-tags`) that cannot be bundled for
|
|
69
|
+
* the browser. Import only from Node.js environments — API routes, background
|
|
70
|
+
* workers, or CLI scripts.
|
|
65
71
|
*/
|
|
66
72
|
export declare function createCelinaClient(opts?: CelinaClientOptions): CelinaClient;
|
|
67
73
|
export type {
|
|
@@ -89,7 +95,7 @@ export type { ContractCallParams } from "./services/contract.service.js";
|
|
|
89
95
|
/** Aave V3 Celo pool address and supported asset symbols. */
|
|
90
96
|
export { AAVE_POOL, AAVE_SUPPORTED_SYMBOLS, resolveAaveAsset, } from "./config/aave.js";
|
|
91
97
|
export { CHAIN, DEFAULT_RPC_URL } from "./config/chains.js";
|
|
92
|
-
export { appendCelinaCalldataTag, attributionDecodeWindow,
|
|
98
|
+
export { appendCelinaCalldataTag, attributionDecodeWindow, buildErc8021AttributionSuffix, checkAttributionInCalldata, collectAttributionTags, ERC_8021_MARKER, normalizeAttributionTags, stripErc8021SuffixIfPresent, toErc8021AttributionCodes, verifyAttributionInCalldata, } from "./config/celina-tag.js";
|
|
93
99
|
export type { AttributionCheckResult, AttributionVerificationResult, } from "./config/celina-tag.js";
|
|
94
100
|
export { createAAClient, deriveSmartAccountAddress, GasSponsorshipService, preparedStepsToUserOpCalls, } from "./aa/index.js";
|
|
95
101
|
export type { AAClient, CreateAAClientOptions, GasSponsorshipConfig, GasSponsorshipProviderId, PimlicoGasSponsorshipConfig, SendPreparedFlowMode, SendPreparedFlowOptions, SendPreparedFlowResult, UserOpCall, } from "./aa/index.js";
|
|
@@ -105,7 +111,7 @@ export { clearSelfSessionsForTests } from "./services/self-session-store.js";
|
|
|
105
111
|
export { flushCelinaAnalytics } from "./analytics/amplitude.js";
|
|
106
112
|
export { runWithAnalyticsWallet } from "./analytics/wallet-context.js";
|
|
107
113
|
/** Optional read-only AgentKarma reputation adapter (agentkarma.io). */
|
|
108
|
-
export { AgentKarmaService } from "./services/agentkarma.service.js";
|
|
114
|
+
export type { AgentKarmaService } from "./services/agentkarma.service.js";
|
|
109
115
|
export type {
|
|
110
116
|
/** Config for the AgentKarma adapter (baseUrl, timeout, fetch, headers). */
|
|
111
117
|
AgentKarmaServiceConfig,
|
package/build/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import { CeloClientFactory } from "./clients/celo-client.js";
|
|
|
8
8
|
import { EnsClientFactory } from "./clients/ens-client.js";
|
|
9
9
|
import { resolveSdkConfig } from "./config/sdk-config.js";
|
|
10
10
|
import { AccountService } from "./services/account.service.js";
|
|
11
|
-
import {
|
|
11
|
+
import { createAgentKarmaService } from "./services/agentkarma-lazy.js";
|
|
12
12
|
import { AaveService } from "./services/aave.service.js";
|
|
13
13
|
import { BlockchainService } from "./services/blockchain.service.js";
|
|
14
14
|
import { ContractService } from "./services/contract.service.js";
|
|
@@ -26,6 +26,12 @@ import { wrapServiceForAnalytics } from "./analytics/wrap-service.js";
|
|
|
26
26
|
/**
|
|
27
27
|
* Create a Celina client for Celo mainnet reads and unsigned tx preparation.
|
|
28
28
|
* No private keys — pass prepared `steps` to wagmi/viem for wallet signing.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* **Server-side only.** Celina SDK includes server-native dependencies
|
|
32
|
+
* (`@agentkarma/sdk`, `@celo/attribution-tags`) that cannot be bundled for
|
|
33
|
+
* the browser. Import only from Node.js environments — API routes, background
|
|
34
|
+
* workers, or CLI scripts.
|
|
29
35
|
*/
|
|
30
36
|
export function createCelinaClient(opts) {
|
|
31
37
|
const config = resolveSdkConfig(opts);
|
|
@@ -50,14 +56,14 @@ export function createCelinaClient(opts) {
|
|
|
50
56
|
self: wrap("self", new SelfService(clientFactory, config)),
|
|
51
57
|
// Optional ecosystem adapter. Not analytics-wrapped: AgentKarma is an
|
|
52
58
|
// external reputation service, not a Celo on-chain read Celina tracks.
|
|
53
|
-
agentKarma:
|
|
59
|
+
agentKarma: createAgentKarmaService(opts?.agentKarma),
|
|
54
60
|
};
|
|
55
61
|
}
|
|
56
62
|
export { serializePreparedFlow } from "./types/prepared.js";
|
|
57
63
|
/** Aave V3 Celo pool address and supported asset symbols. */
|
|
58
64
|
export { AAVE_POOL, AAVE_SUPPORTED_SYMBOLS, resolveAaveAsset, } from "./config/aave.js";
|
|
59
65
|
export { CHAIN, DEFAULT_RPC_URL } from "./config/chains.js";
|
|
60
|
-
export { appendCelinaCalldataTag, attributionDecodeWindow,
|
|
66
|
+
export { appendCelinaCalldataTag, attributionDecodeWindow, buildErc8021AttributionSuffix, checkAttributionInCalldata, collectAttributionTags, ERC_8021_MARKER, normalizeAttributionTags, stripErc8021SuffixIfPresent, toErc8021AttributionCodes, verifyAttributionInCalldata, } from "./config/celina-tag.js";
|
|
61
67
|
export { createAAClient, deriveSmartAccountAddress, GasSponsorshipService, preparedStepsToUserOpCalls, } from "./aa/index.js";
|
|
62
68
|
export { GOODDOLLAR_CUSD_EXCHANGE_ID, GOODDOLLAR_IDENTITY_ADDRESS, GOODDOLLAR_MENTO_BROKER, GOODDOLLAR_MENTO_EXCHANGE_PROVIDER, GOODDOLLAR_RESERVE_COLLATERAL, GOODDOLLAR_TOKEN_ADDRESS, GOODDOLLAR_UBI_SCHEME_ADDRESS, isGoodDollarUsdReservePair, } from "./config/gooddollar.js";
|
|
63
69
|
export { SelfService, } from "./services/self.service.js";
|
|
@@ -67,6 +73,4 @@ export { resolveSelfSessionLinks, formatSelfSessionLinksDisplay, } from "./utils
|
|
|
67
73
|
export { clearSelfSessionsForTests } from "./services/self-session-store.js";
|
|
68
74
|
export { flushCelinaAnalytics } from "./analytics/amplitude.js";
|
|
69
75
|
export { runWithAnalyticsWallet } from "./analytics/wallet-context.js";
|
|
70
|
-
/** Optional read-only AgentKarma reputation adapter (agentkarma.io). */
|
|
71
|
-
export { AgentKarmaService } from "./services/agentkarma.service.js";
|
|
72
76
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAkB,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAkB,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAKxE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MA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BAAwB,CAAC;AAEhC,OAAO,EACL,WAAW,GAIZ,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,YAAY,EACZ,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,YAAY,GACb,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,uBAAuB,EACvB,6BAA6B,GAE9B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Proxy-based lazy loader for AgentKarmaService.
|
|
3
|
+
*
|
|
4
|
+
* Defers the `@agentkarma/sdk` import until the first actual use of
|
|
5
|
+
* `client.agentKarma`. This avoids the `ERR_PACKAGE_PATH_NOT_EXPORTED`
|
|
6
|
+
* error on Node.js v24.10.0+ where `@agentkarma/sdk` lacks an `"exports"`
|
|
7
|
+
* field in its package.json.
|
|
8
|
+
*
|
|
9
|
+
* The Proxy exposes a synchronous `chain` property ("celo") and delegates
|
|
10
|
+
* all other property/method access to a lazily-initialized AgentKarmaService
|
|
11
|
+
* instance via dynamic `import()`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createAgentKarmaService(config?: unknown): any;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Proxy-based lazy loader for AgentKarmaService.
|
|
3
|
+
*
|
|
4
|
+
* Defers the `@agentkarma/sdk` import until the first actual use of
|
|
5
|
+
* `client.agentKarma`. This avoids the `ERR_PACKAGE_PATH_NOT_EXPORTED`
|
|
6
|
+
* error on Node.js v24.10.0+ where `@agentkarma/sdk` lacks an `"exports"`
|
|
7
|
+
* field in its package.json.
|
|
8
|
+
*
|
|
9
|
+
* The Proxy exposes a synchronous `chain` property ("celo") and delegates
|
|
10
|
+
* all other property/method access to a lazily-initialized AgentKarmaService
|
|
11
|
+
* instance via dynamic `import()`.
|
|
12
|
+
*/
|
|
13
|
+
export function createAgentKarmaService(config) {
|
|
14
|
+
let instance = null;
|
|
15
|
+
const getInstance = async () => {
|
|
16
|
+
if (!instance) {
|
|
17
|
+
const mod = await import("./agentkarma.service.js");
|
|
18
|
+
instance = new mod.AgentKarmaService(config);
|
|
19
|
+
}
|
|
20
|
+
return instance;
|
|
21
|
+
};
|
|
22
|
+
// Fire-and-forget pre-init to warm the module cache
|
|
23
|
+
getInstance().catch(() => { });
|
|
24
|
+
return new Proxy({}, {
|
|
25
|
+
get(_, prop) {
|
|
26
|
+
// chain is always "celo" — no import needed
|
|
27
|
+
if (prop === "chain")
|
|
28
|
+
return "celo";
|
|
29
|
+
if (prop === "then")
|
|
30
|
+
return undefined;
|
|
31
|
+
return async (...args) => {
|
|
32
|
+
const svc = await getInstance();
|
|
33
|
+
const val = svc[prop];
|
|
34
|
+
return typeof val === "function" ? val.apply(svc, args) : val;
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=agentkarma-lazy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentkarma-lazy.js","sourceRoot":"","sources":["../../src/services/agentkarma-lazy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAgB;IACtD,IAAI,QAAQ,GAAQ,IAAI,CAAC;IACzB,MAAM,WAAW,GAAG,KAAK,IAAI,EAAE;QAC7B,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,yBAAyB,CAAC,CAAC;YACpD,QAAQ,GAAG,IAAI,GAAG,CAAC,iBAAiB,CAAC,MAAa,CAAC,CAAC;QACtD,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC;IAEF,oDAAoD;IACpD,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAE9B,OAAO,IAAI,KAAK,CAAC,EAAS,EAAE;QAC1B,GAAG,CAAC,CAAC,EAAE,IAAY;YACjB,4CAA4C;YAC5C,IAAI,IAAI,KAAK,OAAO;gBAAE,OAAO,MAAe,CAAC;YAC7C,IAAI,IAAI,KAAK,MAAM;gBAAE,OAAO,SAAS,CAAC;YACtC,OAAO,KAAK,EAAE,GAAG,IAAe,EAAE,EAAE;gBAClC,MAAM,GAAG,GAAG,MAAM,WAAW,EAAE,CAAC;gBAChC,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;gBACtB,OAAO,OAAO,GAAG,KAAK,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;YAChE,CAAC,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -106,7 +106,7 @@ export declare class BlockchainService {
|
|
|
106
106
|
type: string | undefined;
|
|
107
107
|
}>;
|
|
108
108
|
/**
|
|
109
|
-
* Decode
|
|
109
|
+
* Decode ERC-8021 attribution tags from a mined transaction's calldata.
|
|
110
110
|
* @param hash - Transaction hash
|
|
111
111
|
* @param tag - Optional tag to check (e.g. `celo_862c21dd97a7`)
|
|
112
112
|
*/
|
|
@@ -149,7 +149,7 @@ export class BlockchainService {
|
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
151
|
/**
|
|
152
|
-
* Decode
|
|
152
|
+
* Decode ERC-8021 attribution tags from a mined transaction's calldata.
|
|
153
153
|
* @param hash - Transaction hash
|
|
154
154
|
* @param tag - Optional tag to check (e.g. `celo_862c21dd97a7`)
|
|
155
155
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Token sends: estimateSend simulates gas; prepareSend builds unsigned tx steps.
|
|
3
|
-
* Calldata is tagged with
|
|
3
|
+
* Calldata is tagged with the ERC-8021 attribution suffix (see appendCelinaCalldataTag).
|
|
4
4
|
*/
|
|
5
5
|
import { type Hex } from "viem";
|
|
6
6
|
import type { CeloClientFactory } from "../clients/celo-client.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Token sends: estimateSend simulates gas; prepareSend builds unsigned tx steps.
|
|
3
|
-
* Calldata is tagged with
|
|
3
|
+
* Calldata is tagged with the ERC-8021 attribution suffix (see appendCelinaCalldataTag).
|
|
4
4
|
*/
|
|
5
5
|
import { encodeFunctionData, erc20Abi, parseEther, parseGwei, } from "viem";
|
|
6
6
|
import { CHAIN, MENTO_CELO_ADDRESS } from "../config/chains.js";
|
|
@@ -26,7 +26,7 @@ export type AAClient = {
|
|
|
26
26
|
attributionTags: string[] | undefined;
|
|
27
27
|
/**
|
|
28
28
|
* Submit `prepare*` output (ordered `steps` / prepared transactions) as sponsored UserOp(s).
|
|
29
|
-
* When `attributionTags` were set on this client, each step’s `data` is
|
|
29
|
+
* When `attributionTags` were set on this client, each step’s `data` is ERC-8021-tagged
|
|
30
30
|
* before submit; otherwise `data` is used as-is (including tags from `prepare*`).
|
|
31
31
|
*/
|
|
32
32
|
sendPreparedFlow: (flow: PreparedFlow | SerializedPreparedFlow, options?: SendPreparedFlowOptions) => Promise<SendPreparedFlowResult>;
|
|
@@ -38,7 +38,7 @@ export type AAClient = {
|
|
|
38
38
|
* and never stored by Celina. v1 supports `provider: "pimlico"`.
|
|
39
39
|
*
|
|
40
40
|
* Optional `attributionTags` are applied in `sendPreparedFlow` via
|
|
41
|
-
* `appendCelinaCalldataTag` (same
|
|
41
|
+
* `appendCelinaCalldataTag` (same ERC-8021 format as `prepare*`). Omit them to
|
|
42
42
|
* pass step calldata through unchanged.
|
|
43
43
|
*/
|
|
44
44
|
export declare function createAAClient(options: CreateAAClientOptions): Promise<AAClient>;
|
|
@@ -45,7 +45,7 @@ export async function deriveSmartAccountAddress(owner, publicClient) {
|
|
|
45
45
|
* and never stored by Celina. v1 supports `provider: "pimlico"`.
|
|
46
46
|
*
|
|
47
47
|
* Optional `attributionTags` are applied in `sendPreparedFlow` via
|
|
48
|
-
* `appendCelinaCalldataTag` (same
|
|
48
|
+
* `appendCelinaCalldataTag` (same ERC-8021 format as `prepare*`). Omit them to
|
|
49
49
|
* pass step calldata through unchanged.
|
|
50
50
|
*/
|
|
51
51
|
export async function createAAClient(options) {
|