@medialane/ui 0.231.0 → 0.232.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/account/input-otp.d.cts +2 -2
- package/dist/components/account/input-otp.d.ts +2 -2
- package/dist/components/badge.d.cts +1 -1
- package/dist/components/badge.d.ts +1 -1
- package/dist/components/button.d.cts +2 -2
- package/dist/components/button.d.ts +2 -2
- package/dist/components/fast-mint/fast-mint.d.cts +2 -2
- package/dist/components/fast-mint/fast-mint.d.ts +2 -2
- package/dist/components/medialane-app.cjs.map +1 -1
- package/dist/components/medialane-app.d.cts +1 -0
- package/dist/components/medialane-app.d.ts +1 -0
- package/dist/components/medialane-app.js.map +1 -1
- package/dist/components/sheet.d.cts +1 -1
- package/dist/components/sheet.d.ts +1 -1
- package/dist/components/transaction-dialog.cjs +90 -0
- package/dist/components/transaction-dialog.cjs.map +1 -0
- package/dist/components/transaction-dialog.d.cts +18 -0
- package/dist/components/transaction-dialog.d.ts +18 -0
- package/dist/components/transaction-dialog.js +66 -0
- package/dist/components/transaction-dialog.js.map +1 -0
- package/dist/index.cjs +6 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/use-transaction.cjs +84 -0
- package/dist/utils/use-transaction.cjs.map +1 -0
- package/dist/utils/use-transaction.d.cts +17 -0
- package/dist/utils/use-transaction.d.ts +17 -0
- package/dist/utils/use-transaction.js +60 -0
- package/dist/utils/use-transaction.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/use-transaction.ts"],"sourcesContent":["\"use client\";\n\nimport { useCallback, useState } from \"react\";\nimport { assertTransactionSucceeded, syncTransactionBestEffort, type ReceiptLike } from \"@medialane/sdk/starknet\";\nimport { useMedialaneApp } from \"../components/medialane-app.js\";\nimport type { FastMintSigner } from \"../components/fast-mint/types.js\";\nimport { describeError } from \"./describe-error.js\";\n\nexport type TransactionPhase = \"idle\" | \"preparing\" | \"submitting\" | \"confirming\" | \"success\" | \"error\";\n\nexport function useTransaction() {\n const app = useMedialaneApp();\n const [phase, setPhase] = useState<TransactionPhase>(\"idle\");\n const [txHash, setTxHash] = useState<string | null>(null);\n const [receipt, setReceipt] = useState<ReceiptLike | null>(null);\n const [error, setError] = useState<string | null>(null);\n\n const run = useCallback(\n async (work: (signer: FastMintSigner) => Promise<void>) => {\n setPhase(\"preparing\");\n setTxHash(null);\n setReceipt(null);\n setError(null);\n try {\n const signer = await app.getSigner();\n let hash: string | null = null;\n const tracked: FastMintSigner = {\n address: signer.address,\n signTypedData: (data) => signer.signTypedData(data),\n execute: async (calls, opts) => {\n setPhase(\"submitting\");\n const result = await signer.execute(calls, opts);\n hash = result.txHash;\n setTxHash(result.txHash);\n setPhase(\"confirming\");\n return result;\n },\n };\n await work(tracked);\n if (hash) {\n const client = app.getClient();\n setReceipt(await assertTransactionSucceeded(client.provider, hash));\n await syncTransactionBestEffort(client, hash);\n }\n setPhase(\"success\");\n } catch (err) {\n setError(describeError(err, \"We couldn't complete that. Please try again.\").message);\n setPhase(\"error\");\n } finally {\n app.releaseSigner?.();\n }\n },\n [app],\n );\n\n const reset = useCallback(() => {\n setPhase(\"idle\");\n setTxHash(null);\n setReceipt(null);\n setError(null);\n }, []);\n\n return { phase, txHash, receipt, error, run, reset };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAsC;AACtC,sBAAwF;AACxF,2BAAgC;AAEhC,4BAA8B;AAIvB,SAAS,iBAAiB;AAC/B,QAAM,UAAM,sCAAgB;AAC5B,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAA2B,MAAM;AAC3D,QAAM,CAAC,QAAQ,SAAS,QAAI,uBAAwB,IAAI;AACxD,QAAM,CAAC,SAAS,UAAU,QAAI,uBAA6B,IAAI;AAC/D,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAwB,IAAI;AAEtD,QAAM,UAAM;AAAA,IACV,OAAO,SAAoD;AACzD,eAAS,WAAW;AACpB,gBAAU,IAAI;AACd,iBAAW,IAAI;AACf,eAAS,IAAI;AACb,UAAI;AACF,cAAM,SAAS,MAAM,IAAI,UAAU;AACnC,YAAI,OAAsB;AAC1B,cAAM,UAA0B;AAAA,UAC9B,SAAS,OAAO;AAAA,UAChB,eAAe,CAAC,SAAS,OAAO,cAAc,IAAI;AAAA,UAClD,SAAS,OAAO,OAAO,SAAS;AAC9B,qBAAS,YAAY;AACrB,kBAAM,SAAS,MAAM,OAAO,QAAQ,OAAO,IAAI;AAC/C,mBAAO,OAAO;AACd,sBAAU,OAAO,MAAM;AACvB,qBAAS,YAAY;AACrB,mBAAO;AAAA,UACT;AAAA,QACF;AACA,cAAM,KAAK,OAAO;AAClB,YAAI,MAAM;AACR,gBAAM,SAAS,IAAI,UAAU;AAC7B,qBAAW,UAAM,4CAA2B,OAAO,UAAU,IAAI,CAAC;AAClE,oBAAM,2CAA0B,QAAQ,IAAI;AAAA,QAC9C;AACA,iBAAS,SAAS;AAAA,MACpB,SAAS,KAAK;AACZ,qBAAS,qCAAc,KAAK,8CAA8C,EAAE,OAAO;AACnF,iBAAS,OAAO;AAAA,MAClB,UAAE;AACA,YAAI,gBAAgB;AAAA,MACtB;AAAA,IACF;AAAA,IACA,CAAC,GAAG;AAAA,EACN;AAEA,QAAM,YAAQ,0BAAY,MAAM;AAC9B,aAAS,MAAM;AACf,cAAU,IAAI;AACd,eAAW,IAAI;AACf,aAAS,IAAI;AAAA,EACf,GAAG,CAAC,CAAC;AAEL,SAAO,EAAE,OAAO,QAAQ,SAAS,OAAO,KAAK,MAAM;AACrD;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ReceiptLike } from '@medialane/sdk/starknet';
|
|
2
|
+
import { FastMintSigner } from '../components/fast-mint/types.cjs';
|
|
3
|
+
import 'react';
|
|
4
|
+
import 'starknet';
|
|
5
|
+
import '@medialane/sdk';
|
|
6
|
+
|
|
7
|
+
type TransactionPhase = "idle" | "preparing" | "submitting" | "confirming" | "success" | "error";
|
|
8
|
+
declare function useTransaction(): {
|
|
9
|
+
phase: TransactionPhase;
|
|
10
|
+
txHash: string | null;
|
|
11
|
+
receipt: ReceiptLike | null;
|
|
12
|
+
error: string | null;
|
|
13
|
+
run: (work: (signer: FastMintSigner) => Promise<void>) => Promise<void>;
|
|
14
|
+
reset: () => void;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { type TransactionPhase, useTransaction };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ReceiptLike } from '@medialane/sdk/starknet';
|
|
2
|
+
import { FastMintSigner } from '../components/fast-mint/types.js';
|
|
3
|
+
import 'react';
|
|
4
|
+
import 'starknet';
|
|
5
|
+
import '@medialane/sdk';
|
|
6
|
+
|
|
7
|
+
type TransactionPhase = "idle" | "preparing" | "submitting" | "confirming" | "success" | "error";
|
|
8
|
+
declare function useTransaction(): {
|
|
9
|
+
phase: TransactionPhase;
|
|
10
|
+
txHash: string | null;
|
|
11
|
+
receipt: ReceiptLike | null;
|
|
12
|
+
error: string | null;
|
|
13
|
+
run: (work: (signer: FastMintSigner) => Promise<void>) => Promise<void>;
|
|
14
|
+
reset: () => void;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { type TransactionPhase, useTransaction };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback, useState } from "react";
|
|
3
|
+
import { assertTransactionSucceeded, syncTransactionBestEffort } from "@medialane/sdk/starknet";
|
|
4
|
+
import { useMedialaneApp } from "../components/medialane-app.js";
|
|
5
|
+
import { describeError } from "./describe-error.js";
|
|
6
|
+
function useTransaction() {
|
|
7
|
+
const app = useMedialaneApp();
|
|
8
|
+
const [phase, setPhase] = useState("idle");
|
|
9
|
+
const [txHash, setTxHash] = useState(null);
|
|
10
|
+
const [receipt, setReceipt] = useState(null);
|
|
11
|
+
const [error, setError] = useState(null);
|
|
12
|
+
const run = useCallback(
|
|
13
|
+
async (work) => {
|
|
14
|
+
setPhase("preparing");
|
|
15
|
+
setTxHash(null);
|
|
16
|
+
setReceipt(null);
|
|
17
|
+
setError(null);
|
|
18
|
+
try {
|
|
19
|
+
const signer = await app.getSigner();
|
|
20
|
+
let hash = null;
|
|
21
|
+
const tracked = {
|
|
22
|
+
address: signer.address,
|
|
23
|
+
signTypedData: (data) => signer.signTypedData(data),
|
|
24
|
+
execute: async (calls, opts) => {
|
|
25
|
+
setPhase("submitting");
|
|
26
|
+
const result = await signer.execute(calls, opts);
|
|
27
|
+
hash = result.txHash;
|
|
28
|
+
setTxHash(result.txHash);
|
|
29
|
+
setPhase("confirming");
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
await work(tracked);
|
|
34
|
+
if (hash) {
|
|
35
|
+
const client = app.getClient();
|
|
36
|
+
setReceipt(await assertTransactionSucceeded(client.provider, hash));
|
|
37
|
+
await syncTransactionBestEffort(client, hash);
|
|
38
|
+
}
|
|
39
|
+
setPhase("success");
|
|
40
|
+
} catch (err) {
|
|
41
|
+
setError(describeError(err, "We couldn't complete that. Please try again.").message);
|
|
42
|
+
setPhase("error");
|
|
43
|
+
} finally {
|
|
44
|
+
app.releaseSigner?.();
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
[app]
|
|
48
|
+
);
|
|
49
|
+
const reset = useCallback(() => {
|
|
50
|
+
setPhase("idle");
|
|
51
|
+
setTxHash(null);
|
|
52
|
+
setReceipt(null);
|
|
53
|
+
setError(null);
|
|
54
|
+
}, []);
|
|
55
|
+
return { phase, txHash, receipt, error, run, reset };
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
useTransaction
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=use-transaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/use-transaction.ts"],"sourcesContent":["\"use client\";\n\nimport { useCallback, useState } from \"react\";\nimport { assertTransactionSucceeded, syncTransactionBestEffort, type ReceiptLike } from \"@medialane/sdk/starknet\";\nimport { useMedialaneApp } from \"../components/medialane-app.js\";\nimport type { FastMintSigner } from \"../components/fast-mint/types.js\";\nimport { describeError } from \"./describe-error.js\";\n\nexport type TransactionPhase = \"idle\" | \"preparing\" | \"submitting\" | \"confirming\" | \"success\" | \"error\";\n\nexport function useTransaction() {\n const app = useMedialaneApp();\n const [phase, setPhase] = useState<TransactionPhase>(\"idle\");\n const [txHash, setTxHash] = useState<string | null>(null);\n const [receipt, setReceipt] = useState<ReceiptLike | null>(null);\n const [error, setError] = useState<string | null>(null);\n\n const run = useCallback(\n async (work: (signer: FastMintSigner) => Promise<void>) => {\n setPhase(\"preparing\");\n setTxHash(null);\n setReceipt(null);\n setError(null);\n try {\n const signer = await app.getSigner();\n let hash: string | null = null;\n const tracked: FastMintSigner = {\n address: signer.address,\n signTypedData: (data) => signer.signTypedData(data),\n execute: async (calls, opts) => {\n setPhase(\"submitting\");\n const result = await signer.execute(calls, opts);\n hash = result.txHash;\n setTxHash(result.txHash);\n setPhase(\"confirming\");\n return result;\n },\n };\n await work(tracked);\n if (hash) {\n const client = app.getClient();\n setReceipt(await assertTransactionSucceeded(client.provider, hash));\n await syncTransactionBestEffort(client, hash);\n }\n setPhase(\"success\");\n } catch (err) {\n setError(describeError(err, \"We couldn't complete that. Please try again.\").message);\n setPhase(\"error\");\n } finally {\n app.releaseSigner?.();\n }\n },\n [app],\n );\n\n const reset = useCallback(() => {\n setPhase(\"idle\");\n setTxHash(null);\n setReceipt(null);\n setError(null);\n }, []);\n\n return { phase, txHash, receipt, error, run, reset };\n}\n"],"mappings":";AAEA,SAAS,aAAa,gBAAgB;AACtC,SAAS,4BAA4B,iCAAmD;AACxF,SAAS,uBAAuB;AAEhC,SAAS,qBAAqB;AAIvB,SAAS,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AO,EAAE,OAAO,QAAQ,SAAS,OAAO,KAAK,MAAM;AACrD;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medialane/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.232.0",
|
|
4
4
|
"description": "Shared UI components for Medialane apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"preview": "vite --config preview/vite.config.ts"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@medialane/sdk": ">=0.
|
|
54
|
+
"@medialane/sdk": ">=0.202.0 <0.203.0",
|
|
55
55
|
"@radix-ui/react-checkbox": ">=1.1.0",
|
|
56
56
|
"@radix-ui/react-collapsible": ">=1.1.0",
|
|
57
57
|
"@radix-ui/react-dialog": ">=1.1.0",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@happy-dom/global-registrator": "^20.14.5",
|
|
86
|
-
"@medialane/sdk": "0.
|
|
86
|
+
"@medialane/sdk": "0.202.0",
|
|
87
87
|
"@radix-ui/react-checkbox": "^1.3.8",
|
|
88
88
|
"@radix-ui/react-collapsible": "^1.1.17",
|
|
89
89
|
"@radix-ui/react-dialog": "^1.1.20",
|