@andrewkimjoseph/celina-sdk 0.15.2 → 0.15.4
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 +5 -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 +12 -6
- package/build/config/celina-tag.js +16 -21
- 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 +2 -2
- package/build/services/contract.service.d.ts +13 -3
- package/build/services/contract.service.js +48 -2
- package/build/services/contract.service.js.map +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 +12 -6
- package/build/src/config/celina-tag.js +16 -21
- 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 +2 -2
- package/build/src/services/contract.service.d.ts +13 -3
- package/build/src/services/contract.service.js +48 -2
- package/build/src/services/contract.service.js.map +1 -1
- package/build/src/tools/domains/blockchain.js +2 -2
- package/build/src/tools/domains/blockchain.js.map +1 -1
- package/build/src/tools/domains/contract.js +53 -1
- package/build/src/tools/domains/contract.js.map +1 -1
- package/build/src/tools/types.d.ts +10 -0
- package/build/src/tools/website-sync.js +2 -0
- package/build/src/tools/website-sync.js.map +1 -1
- package/build/src/types/prepared.d.ts +1 -1
- package/build/tests/catalog/domains/chain-ext.js +31 -0
- package/build/tests/catalog/domains/chain-ext.js.map +1 -1
- package/build/tools/domains/blockchain.js +2 -2
- package/build/tools/domains/blockchain.js.map +1 -1
- package/build/tools/domains/contract.js +53 -1
- package/build/tools/domains/contract.js.map +1 -1
- package/build/tools/types.d.ts +10 -0
- package/build/tools/website-sync.js +2 -0
- package/build/tools/website-sync.js.map +1 -1
- package/build/types/prepared.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Celina is layered from chain logic through agent tooling:
|
|
|
14
14
|
|
|
15
15
|
| Layer | Package | Role |
|
|
16
16
|
|-------|---------|------|
|
|
17
|
-
| **SDK** | `@andrewkimjoseph/celina-sdk` | Reads, gas estimates, `prepare*` flows (`chainId: 42220`),
|
|
17
|
+
| **SDK** | `@andrewkimjoseph/celina-sdk` | Reads, gas estimates, `prepare*` flows (`chainId: 42220`), ERC-8021 attribution, `createAAClient` |
|
|
18
18
|
| **MCP** | `@andrewkimjoseph/celina-mcp` | MCP tools for Cursor / Claude / LM Studio — stdio writes or hosted reads |
|
|
19
19
|
| **MCP host** | `celina-mcp-host` | Vercel Streamable HTTP — hosted reads (36 tools); no server-key writes; no sponsorship keys |
|
|
20
20
|
|
|
@@ -43,7 +43,7 @@ Before broadcasting prepared steps, call `simulatePreparedStep` from `@andrewkim
|
|
|
43
43
|
- [Quick start](https://andrewkimjoseph.gitbook.io/celina-sdk/getting-started/quick-start)
|
|
44
44
|
- [LLM tool catalog](docs/guides/tool-catalog.md) — `@andrewkimjoseph/celina-sdk/tools` for MCP and AI SDK hosts
|
|
45
45
|
- [Architecture](docs/concepts/architecture.md) — client composition and stack
|
|
46
|
-
- [Prepared flows](docs/concepts/prepared-flows.md) — `SerializedPreparedFlow` (`chainId: 42220`),
|
|
46
|
+
- [Prepared flows](docs/concepts/prepared-flows.md) — `SerializedPreparedFlow` (`chainId: 42220`), ERC-8021 Celina attribution
|
|
47
47
|
- [On-chain attribution](docs/guides/on-chain-attribution.md) — wire format, check vs verify, Celina vs AA tags
|
|
48
48
|
- [Account Abstraction](docs/guides/account-abstraction.md) — `createAAClient`, app-owned sponsorship, AA `attributionTags`
|
|
49
49
|
- [Prepared-step simulation](docs/guides/prepared-step-simulation.md) — `simulatePreparedStep` before wallet send
|
|
@@ -63,7 +63,7 @@ import { createCelinaClient } from "@andrewkimjoseph/celina-sdk";
|
|
|
63
63
|
|
|
64
64
|
const celina = createCelinaClient({
|
|
65
65
|
attributionTags: ["celo_862c21dd97a7", "my_app"],
|
|
66
|
-
//
|
|
66
|
+
// ERC-8021 → codes celina, celo_862c21dd97a7, my_app
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
await celina.token.getStablecoinBalances("0xYourAddress");
|
|
@@ -90,12 +90,9 @@ const reserveFlow = await celina.gooddollar.prepareReserveSwap(
|
|
|
90
90
|
|
|
91
91
|
All `prepare*` methods return a **`SerializedPreparedFlow`**: ordered unsigned steps for the user's wallet.
|
|
92
92
|
|
|
93
|
-
Every step with calldata gets **
|
|
93
|
+
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.
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
2. **ERC-8021 Schema 0** — `toDataSuffix(["celina", ...])` via `@celo/attribution-tags` for Celo leaderboards and `verifyTx`
|
|
97
|
-
|
|
98
|
-
Optional `attributionTags` in `createCelinaClient({ attributionTags: [...] })` apply to both layers (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 legacy + ERC-8021 layers.
|
|
95
|
+
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
96
|
|
|
100
97
|
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
98
|
|
|
@@ -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,10 +1,16 @@
|
|
|
1
1
|
import { ERC_8021_MARKER } from "@celo/attribution-tags";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Legacy UTF-8 marker hex(`"CELINA"`) for reading historical dual / legacy-only txs.
|
|
4
|
+
* New writes use ERC-8021 only — see {@link appendCelinaCalldataTag}.
|
|
5
|
+
*/
|
|
3
6
|
export declare const CELINA_DATA_SUFFIX: `0x${string}`;
|
|
4
7
|
export { ERC_8021_MARKER };
|
|
5
8
|
/** Normalize custom attribution tags while preserving first-seen order. */
|
|
6
9
|
export declare function normalizeAttributionTags(tags?: string[]): string[];
|
|
7
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Build deterministic legacy UTF-8 tag string (`CELINA` / `CELINA|TAG…`).
|
|
12
|
+
* @deprecated Prefer ERC-8021 via {@link appendCelinaCalldataTag} / {@link toErc8021AttributionCodes}. Kept for historical decode helpers and tests.
|
|
13
|
+
*/
|
|
8
14
|
export declare function buildCelinaAttributionTag(tags?: string[]): string;
|
|
9
15
|
/** Map client attribution tags to ERC-8021 Schema 0 codes (lowercase `[a-z0-9_]` only). */
|
|
10
16
|
export declare function toErc8021AttributionCodes(attributionTags?: string[]): string[];
|
|
@@ -41,15 +47,15 @@ export declare function verifyAttributionInCalldata(data: `0x${string}`, tag?: s
|
|
|
41
47
|
*/
|
|
42
48
|
export declare function checkAttributionInCalldata(data: `0x${string}`, tag?: string): AttributionCheckResult;
|
|
43
49
|
/**
|
|
44
|
-
* Append
|
|
50
|
+
* Append Celina ERC-8021 Schema 0 attribution to calldata (no legacy UTF-8 `CELINA|…`).
|
|
45
51
|
*
|
|
46
52
|
* Used by `prepare*` when `createCelinaClient({ attributionTags })` is set, and by
|
|
47
53
|
* `createAAClient({ attributionTags }).sendPreparedFlow` when AA tags are set.
|
|
48
54
|
*
|
|
49
55
|
* @param data - Original transaction calldata.
|
|
50
56
|
* @param attributionTags - Optional custom tags (same list semantics on Celina or AA client).
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
57
|
+
* ERC-8021: `toDataSuffix(["celina", ...])` with lowercase codes.
|
|
58
|
+
* Example: `["goclaim"]` → codes `celina`, `goclaim`.
|
|
59
|
+
* Existing legacy UTF-8 on `data` is left in place; a matching ERC-8021 suffix is ensured.
|
|
54
60
|
*/
|
|
55
61
|
export declare function appendCelinaCalldataTag(data: `0x${string}`, attributionTags?: string[]): `0x${string}`;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { ERC_8021_MARKER, fromDataSuffix, toDataSuffix, } from "@celo/attribution-tags";
|
|
2
2
|
import { concat, hexToString, stringToHex } from "viem";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Legacy UTF-8 marker hex(`"CELINA"`) for reading historical dual / legacy-only txs.
|
|
5
|
+
* New writes use ERC-8021 only — see {@link appendCelinaCalldataTag}.
|
|
6
|
+
*/
|
|
4
7
|
export const CELINA_DATA_SUFFIX = stringToHex("CELINA");
|
|
5
8
|
export { ERC_8021_MARKER };
|
|
6
9
|
/** Celo Builders on-chain attribution tag: `celo_` + 12 hex chars (lowercase). */
|
|
@@ -26,7 +29,10 @@ export function normalizeAttributionTags(tags) {
|
|
|
26
29
|
}
|
|
27
30
|
return [...deduped];
|
|
28
31
|
}
|
|
29
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* Build deterministic legacy UTF-8 tag string (`CELINA` / `CELINA|TAG…`).
|
|
34
|
+
* @deprecated Prefer ERC-8021 via {@link appendCelinaCalldataTag} / {@link toErc8021AttributionCodes}. Kept for historical decode helpers and tests.
|
|
35
|
+
*/
|
|
30
36
|
export function buildCelinaAttributionTag(tags) {
|
|
31
37
|
const normalized = normalizeAttributionTags(tags);
|
|
32
38
|
return normalized.length ? `CELINA|${normalized.join("|")}` : "CELINA";
|
|
@@ -46,9 +52,6 @@ export function buildErc8021AttributionSuffix(attributionTags) {
|
|
|
46
52
|
? toDataSuffix(codes[0])
|
|
47
53
|
: toDataSuffix(codes);
|
|
48
54
|
}
|
|
49
|
-
function buildLegacyAttributionSuffixHex(attributionTags) {
|
|
50
|
-
return stringToHex(buildCelinaAttributionTag(attributionTags));
|
|
51
|
-
}
|
|
52
55
|
function sameCodeSets(a, b) {
|
|
53
56
|
if (a.length !== b.length)
|
|
54
57
|
return false;
|
|
@@ -200,35 +203,27 @@ export function checkAttributionInCalldata(data, tag) {
|
|
|
200
203
|
};
|
|
201
204
|
}
|
|
202
205
|
/**
|
|
203
|
-
* Append
|
|
206
|
+
* Append Celina ERC-8021 Schema 0 attribution to calldata (no legacy UTF-8 `CELINA|…`).
|
|
204
207
|
*
|
|
205
208
|
* Used by `prepare*` when `createCelinaClient({ attributionTags })` is set, and by
|
|
206
209
|
* `createAAClient({ attributionTags }).sendPreparedFlow` when AA tags are set.
|
|
207
210
|
*
|
|
208
211
|
* @param data - Original transaction calldata.
|
|
209
212
|
* @param attributionTags - Optional custom tags (same list semantics on Celina or AA client).
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
+
* ERC-8021: `toDataSuffix(["celina", ...])` with lowercase codes.
|
|
214
|
+
* Example: `["goclaim"]` → codes `celina`, `goclaim`.
|
|
215
|
+
* Existing legacy UTF-8 on `data` is left in place; a matching ERC-8021 suffix is ensured.
|
|
213
216
|
*/
|
|
214
217
|
export function appendCelinaCalldataTag(data, attributionTags) {
|
|
215
218
|
if (!data || data === "0x")
|
|
216
219
|
return data;
|
|
217
|
-
const legacyHex = buildLegacyAttributionSuffixHex(attributionTags);
|
|
218
|
-
const legacySuffix = legacyHex.slice(2);
|
|
219
220
|
const erc8021Hex = buildErc8021AttributionSuffix(attributionTags);
|
|
220
221
|
const expectedCodes = toErc8021AttributionCodes(attributionTags);
|
|
221
|
-
const
|
|
222
|
-
if (
|
|
222
|
+
const tip = fromDataSuffix(data);
|
|
223
|
+
if (tip && sameCodeSets(tip.codes, expectedCodes)) {
|
|
223
224
|
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
225
|
}
|
|
232
|
-
|
|
226
|
+
const without8021 = stripErc8021SuffixIfPresent(data);
|
|
227
|
+
return concat([without8021, erc8021Hex]);
|
|
233
228
|
}
|
|
234
229
|
//# 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,WAAW,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAExD
|
|
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,WAAW,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAExD;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;AAExD,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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CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CACxC,IAAmB,EACnB,GAAY;IAEZ,MAAM,QAAQ,GAAG,2BAA2B,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACxD,OAAO;QACL,GAAG,QAAQ;QACX,IAAI,EAAE,sBAAsB,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,OAAO,EAAE,KAAK,IAAI,IAAI,CAAC;KACnF,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,uBAAuB,CACrC,IAAmB,EACnB,eAA0B;IAE1B,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAExC,MAAM,UAAU,GAAG,6BAA6B,CAAC,eAAe,CAAC,CAAC;IAClE,MAAM,aAAa,GAAG,yBAAyB,CAAC,eAAe,CAAC,CAAC;IAEjE,MAAM,GAAG,GAAG,cAAc,CAAC,IAAI,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
|
@@ -48,7 +48,7 @@ export interface CelinaClient {
|
|
|
48
48
|
staking: StakingService;
|
|
49
49
|
/** ERC-721 / ERC-1155 NFT reads. */
|
|
50
50
|
nft: NftService;
|
|
51
|
-
/** Generic
|
|
51
|
+
/** Generic contract reads, gas estimates, and write prepares. */
|
|
52
52
|
contract: ContractService;
|
|
53
53
|
/** Self Agent ID on Celo mainnet (ai.self.xyz + on-chain registry). */
|
|
54
54
|
self: SelfService;
|
|
@@ -84,7 +84,7 @@ export type { MentoFxParams } from "./services/mento-fx.service.js";
|
|
|
84
84
|
export type { UniswapSwapParams } from "./services/uniswap.service.js";
|
|
85
85
|
/** Pagination and metadata options for governance proposal lists. */
|
|
86
86
|
export type { GovernanceProposalsOptions } from "./services/governance.service.js";
|
|
87
|
-
/** Parameters for generic
|
|
87
|
+
/** Parameters for generic contract reads, estimates, and write prepares. */
|
|
88
88
|
export type { ContractCallParams } from "./services/contract.service.js";
|
|
89
89
|
/** Aave V3 Celo pool address and supported asset symbols. */
|
|
90
90
|
export { AAVE_POOL, AAVE_SUPPORTED_SYMBOLS, resolveAaveAsset, } from "./config/aave.js";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Generic contract reads
|
|
2
|
+
* Generic contract reads, gas estimates, and write prepares — caller supplies the ABI.
|
|
3
3
|
*/
|
|
4
4
|
import { type Abi } from "viem";
|
|
5
5
|
import type { CeloClientFactory } from "../clients/celo-client.js";
|
|
6
|
-
|
|
6
|
+
import { type SerializedPreparedFlow } from "../types/prepared.js";
|
|
7
|
+
/** Parameters for a contract call on Celo mainnet (read, estimate, or prepare write). */
|
|
7
8
|
export interface ContractCallParams {
|
|
8
9
|
/** Target contract address. */
|
|
9
10
|
contractAddress: `0x${string}`;
|
|
@@ -18,9 +19,10 @@ export interface ContractCallParams {
|
|
|
18
19
|
/** Wei value as decimal string for payable calls (default `"0"`). */
|
|
19
20
|
value?: string;
|
|
20
21
|
}
|
|
21
|
-
/** Read-
|
|
22
|
+
/** Read, gas-estimate, and prepare helpers for arbitrary contracts. */
|
|
22
23
|
export declare class ContractService {
|
|
23
24
|
private readonly clientFactory;
|
|
25
|
+
private readonly attributionTags?;
|
|
24
26
|
constructor(clientFactory: CeloClientFactory);
|
|
25
27
|
/**
|
|
26
28
|
* Simulate a read-only contract call (`eth_call`).
|
|
@@ -68,6 +70,14 @@ export declare class ContractService {
|
|
|
68
70
|
success: boolean;
|
|
69
71
|
error: string;
|
|
70
72
|
}>;
|
|
73
|
+
/**
|
|
74
|
+
* Build an unsigned single-step flow for a contract write (caller ABI).
|
|
75
|
+
* Calldata includes the CELINA attribution suffix. Rejects `view`/`pure` ABI entries.
|
|
76
|
+
* @param from - Sender wallet address (must match connected wallet when signing)
|
|
77
|
+
* @param params - Contract address, ABI, function name, optional args and wei `value`
|
|
78
|
+
* @returns Single-step `SerializedPreparedFlow` for wagmi or MCP `executePreparedFlow`
|
|
79
|
+
*/
|
|
80
|
+
prepareFunction(from: `0x${string}`, params: ContractCallParams): Promise<SerializedPreparedFlow>;
|
|
71
81
|
}
|
|
72
82
|
/**
|
|
73
83
|
* Decode raw calldata result bytes using a single ABI function entry.
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Generic contract reads
|
|
2
|
+
* Generic contract reads, gas estimates, and write prepares — caller supplies the ABI.
|
|
3
3
|
*/
|
|
4
4
|
import { decodeFunctionResult, encodeFunctionData, } from "viem";
|
|
5
|
+
import { CHAIN } from "../config/chains.js";
|
|
6
|
+
import { appendCelinaCalldataTag } from "../config/celina-tag.js";
|
|
5
7
|
import { normalizeAddress } from "../utils/normalize-address.js";
|
|
8
|
+
import { serializePreparedFlow, } from "../types/prepared.js";
|
|
6
9
|
function findAbiFunction(abi, functionName) {
|
|
7
10
|
const fn = abi.find((item) => item.type === "function" && item.name === functionName);
|
|
8
11
|
if (!fn) {
|
|
@@ -10,11 +13,19 @@ function findAbiFunction(abi, functionName) {
|
|
|
10
13
|
}
|
|
11
14
|
return fn;
|
|
12
15
|
}
|
|
13
|
-
|
|
16
|
+
function assertWritableFunction(fn, functionName) {
|
|
17
|
+
const mutability = fn.stateMutability;
|
|
18
|
+
if (mutability === "view" || mutability === "pure") {
|
|
19
|
+
throw new Error(`Function "${functionName}" is ${mutability}; use call_contract_function for reads`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/** Read, gas-estimate, and prepare helpers for arbitrary contracts. */
|
|
14
23
|
export class ContractService {
|
|
15
24
|
clientFactory;
|
|
25
|
+
attributionTags;
|
|
16
26
|
constructor(clientFactory) {
|
|
17
27
|
this.clientFactory = clientFactory;
|
|
28
|
+
this.attributionTags = clientFactory.getConfig().attributionTags;
|
|
18
29
|
}
|
|
19
30
|
/**
|
|
20
31
|
* Simulate a read-only contract call (`eth_call`).
|
|
@@ -103,6 +114,41 @@ export class ContractService {
|
|
|
103
114
|
};
|
|
104
115
|
}
|
|
105
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Build an unsigned single-step flow for a contract write (caller ABI).
|
|
119
|
+
* Calldata includes the CELINA attribution suffix. Rejects `view`/`pure` ABI entries.
|
|
120
|
+
* @param from - Sender wallet address (must match connected wallet when signing)
|
|
121
|
+
* @param params - Contract address, ABI, function name, optional args and wei `value`
|
|
122
|
+
* @returns Single-step `SerializedPreparedFlow` for wagmi or MCP `executePreparedFlow`
|
|
123
|
+
*/
|
|
124
|
+
async prepareFunction(from, params) {
|
|
125
|
+
const contractAddress = normalizeAddress(params.contractAddress, "contract address");
|
|
126
|
+
const sender = normalizeAddress(from, "from address");
|
|
127
|
+
const fn = findAbiFunction(params.abi, params.functionName);
|
|
128
|
+
assertWritableFunction(fn, params.functionName);
|
|
129
|
+
const args = params.functionArgs ?? [];
|
|
130
|
+
const value = params.value ?? "0";
|
|
131
|
+
const data = appendCelinaCalldataTag(encodeFunctionData({
|
|
132
|
+
abi: params.abi,
|
|
133
|
+
functionName: params.functionName,
|
|
134
|
+
args: args,
|
|
135
|
+
}), this.attributionTags);
|
|
136
|
+
const flow = {
|
|
137
|
+
chainId: CHAIN.id,
|
|
138
|
+
from: sender,
|
|
139
|
+
summary: `Call ${params.functionName} on ${contractAddress}`,
|
|
140
|
+
steps: [
|
|
141
|
+
{
|
|
142
|
+
kind: "contract",
|
|
143
|
+
to: contractAddress,
|
|
144
|
+
data,
|
|
145
|
+
value,
|
|
146
|
+
description: `Call ${params.functionName}`,
|
|
147
|
+
},
|
|
148
|
+
],
|
|
149
|
+
};
|
|
150
|
+
return serializePreparedFlow(flow);
|
|
151
|
+
}
|
|
106
152
|
}
|
|
107
153
|
/**
|
|
108
154
|
* Decode raw calldata result bytes using a single ABI function entry.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.service.js","sourceRoot":"","sources":["../../src/services/contract.service.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAGL,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,MAAM,CAAC;AAEd,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"contract.service.js","sourceRoot":"","sources":["../../src/services/contract.service.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAGL,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,MAAM,CAAC;AAEd,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAEL,qBAAqB,GAEtB,MAAM,sBAAsB,CAAC;AAkB9B,SAAS,eAAe,CAAC,GAAQ,EAAE,YAAoB;IACrD,MAAM,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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/src/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,10 +1,16 @@
|
|
|
1
1
|
import { ERC_8021_MARKER } from "@celo/attribution-tags";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Legacy UTF-8 marker hex(`"CELINA"`) for reading historical dual / legacy-only txs.
|
|
4
|
+
* New writes use ERC-8021 only — see {@link appendCelinaCalldataTag}.
|
|
5
|
+
*/
|
|
3
6
|
export declare const CELINA_DATA_SUFFIX: `0x${string}`;
|
|
4
7
|
export { ERC_8021_MARKER };
|
|
5
8
|
/** Normalize custom attribution tags while preserving first-seen order. */
|
|
6
9
|
export declare function normalizeAttributionTags(tags?: string[]): string[];
|
|
7
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Build deterministic legacy UTF-8 tag string (`CELINA` / `CELINA|TAG…`).
|
|
12
|
+
* @deprecated Prefer ERC-8021 via {@link appendCelinaCalldataTag} / {@link toErc8021AttributionCodes}. Kept for historical decode helpers and tests.
|
|
13
|
+
*/
|
|
8
14
|
export declare function buildCelinaAttributionTag(tags?: string[]): string;
|
|
9
15
|
/** Map client attribution tags to ERC-8021 Schema 0 codes (lowercase `[a-z0-9_]` only). */
|
|
10
16
|
export declare function toErc8021AttributionCodes(attributionTags?: string[]): string[];
|
|
@@ -41,15 +47,15 @@ export declare function verifyAttributionInCalldata(data: `0x${string}`, tag?: s
|
|
|
41
47
|
*/
|
|
42
48
|
export declare function checkAttributionInCalldata(data: `0x${string}`, tag?: string): AttributionCheckResult;
|
|
43
49
|
/**
|
|
44
|
-
* Append
|
|
50
|
+
* Append Celina ERC-8021 Schema 0 attribution to calldata (no legacy UTF-8 `CELINA|…`).
|
|
45
51
|
*
|
|
46
52
|
* Used by `prepare*` when `createCelinaClient({ attributionTags })` is set, and by
|
|
47
53
|
* `createAAClient({ attributionTags }).sendPreparedFlow` when AA tags are set.
|
|
48
54
|
*
|
|
49
55
|
* @param data - Original transaction calldata.
|
|
50
56
|
* @param attributionTags - Optional custom tags (same list semantics on Celina or AA client).
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
57
|
+
* ERC-8021: `toDataSuffix(["celina", ...])` with lowercase codes.
|
|
58
|
+
* Example: `["goclaim"]` → codes `celina`, `goclaim`.
|
|
59
|
+
* Existing legacy UTF-8 on `data` is left in place; a matching ERC-8021 suffix is ensured.
|
|
54
60
|
*/
|
|
55
61
|
export declare function appendCelinaCalldataTag(data: `0x${string}`, attributionTags?: string[]): `0x${string}`;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { ERC_8021_MARKER, fromDataSuffix, toDataSuffix, } from "@celo/attribution-tags";
|
|
2
2
|
import { concat, hexToString, stringToHex } from "viem";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Legacy UTF-8 marker hex(`"CELINA"`) for reading historical dual / legacy-only txs.
|
|
5
|
+
* New writes use ERC-8021 only — see {@link appendCelinaCalldataTag}.
|
|
6
|
+
*/
|
|
4
7
|
export const CELINA_DATA_SUFFIX = stringToHex("CELINA");
|
|
5
8
|
export { ERC_8021_MARKER };
|
|
6
9
|
/** Celo Builders on-chain attribution tag: `celo_` + 12 hex chars (lowercase). */
|
|
@@ -26,7 +29,10 @@ export function normalizeAttributionTags(tags) {
|
|
|
26
29
|
}
|
|
27
30
|
return [...deduped];
|
|
28
31
|
}
|
|
29
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* Build deterministic legacy UTF-8 tag string (`CELINA` / `CELINA|TAG…`).
|
|
34
|
+
* @deprecated Prefer ERC-8021 via {@link appendCelinaCalldataTag} / {@link toErc8021AttributionCodes}. Kept for historical decode helpers and tests.
|
|
35
|
+
*/
|
|
30
36
|
export function buildCelinaAttributionTag(tags) {
|
|
31
37
|
const normalized = normalizeAttributionTags(tags);
|
|
32
38
|
return normalized.length ? `CELINA|${normalized.join("|")}` : "CELINA";
|
|
@@ -46,9 +52,6 @@ export function buildErc8021AttributionSuffix(attributionTags) {
|
|
|
46
52
|
? toDataSuffix(codes[0])
|
|
47
53
|
: toDataSuffix(codes);
|
|
48
54
|
}
|
|
49
|
-
function buildLegacyAttributionSuffixHex(attributionTags) {
|
|
50
|
-
return stringToHex(buildCelinaAttributionTag(attributionTags));
|
|
51
|
-
}
|
|
52
55
|
function sameCodeSets(a, b) {
|
|
53
56
|
if (a.length !== b.length)
|
|
54
57
|
return false;
|
|
@@ -200,35 +203,27 @@ export function checkAttributionInCalldata(data, tag) {
|
|
|
200
203
|
};
|
|
201
204
|
}
|
|
202
205
|
/**
|
|
203
|
-
* Append
|
|
206
|
+
* Append Celina ERC-8021 Schema 0 attribution to calldata (no legacy UTF-8 `CELINA|…`).
|
|
204
207
|
*
|
|
205
208
|
* Used by `prepare*` when `createCelinaClient({ attributionTags })` is set, and by
|
|
206
209
|
* `createAAClient({ attributionTags }).sendPreparedFlow` when AA tags are set.
|
|
207
210
|
*
|
|
208
211
|
* @param data - Original transaction calldata.
|
|
209
212
|
* @param attributionTags - Optional custom tags (same list semantics on Celina or AA client).
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
+
* ERC-8021: `toDataSuffix(["celina", ...])` with lowercase codes.
|
|
214
|
+
* Example: `["goclaim"]` → codes `celina`, `goclaim`.
|
|
215
|
+
* Existing legacy UTF-8 on `data` is left in place; a matching ERC-8021 suffix is ensured.
|
|
213
216
|
*/
|
|
214
217
|
export function appendCelinaCalldataTag(data, attributionTags) {
|
|
215
218
|
if (!data || data === "0x")
|
|
216
219
|
return data;
|
|
217
|
-
const legacyHex = buildLegacyAttributionSuffixHex(attributionTags);
|
|
218
|
-
const legacySuffix = legacyHex.slice(2);
|
|
219
220
|
const erc8021Hex = buildErc8021AttributionSuffix(attributionTags);
|
|
220
221
|
const expectedCodes = toErc8021AttributionCodes(attributionTags);
|
|
221
|
-
const
|
|
222
|
-
if (
|
|
222
|
+
const tip = fromDataSuffix(data);
|
|
223
|
+
if (tip && sameCodeSets(tip.codes, expectedCodes)) {
|
|
223
224
|
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
225
|
}
|
|
232
|
-
|
|
226
|
+
const without8021 = stripErc8021SuffixIfPresent(data);
|
|
227
|
+
return concat([without8021, erc8021Hex]);
|
|
233
228
|
}
|
|
234
229
|
//# sourceMappingURL=celina-tag.js.map
|