atlas-react-widget 0.0.1
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 +141 -0
- package/dist/assets/Icon.d.ts +2 -0
- package/dist/assets/tokens/0glogo.jpg +0 -0
- package/dist/assets/tokens/OG.png +0 -0
- package/dist/assets/tokens/Tether.png +0 -0
- package/dist/assets/tokens/bitcoin.png +0 -0
- package/dist/assets/tokens/ethereum.png +0 -0
- package/dist/assets/tokens/gimo.png +0 -0
- package/dist/assets/tokens/stOG.png +0 -0
- package/dist/ccip-BGicimZg.mjs +150 -0
- package/dist/ccip-BGicimZg.mjs.map +1 -0
- package/dist/components/AtlasPaymentButton.d.ts +16 -0
- package/dist/components/AtlasPaymentForm.d.ts +16 -0
- package/dist/components/AtlasPaymentStatus.d.ts +12 -0
- package/dist/hooks/useAtlasPayment.d.ts +30 -0
- package/dist/index-CuYsyW6b.mjs +50556 -0
- package/dist/index-CuYsyW6b.mjs.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.es.js +7 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.js +97 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/clients.d.ts +15750 -0
- package/dist/style.css +1 -0
- package/dist/types/index.d.ts +51 -0
- package/dist/vite.svg +1 -0
- package/package.json +40 -0
package/README.md
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# Deserialize Swap Widget
|
|
2
|
+
|
|
3
|
+
A plug-and-play React/Next.js widget for swapping tokens using the [`deserialize-evm-client-sdk`](https://www.npmjs.com/package/deserialize-evm-client-sdk).
|
|
4
|
+
Built with Radix UI, Framer Motion, Tailwind utilities, and TypeScript.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## ✨ Features
|
|
9
|
+
|
|
10
|
+
- Plug & Play React/Next.js component
|
|
11
|
+
- Fetches and displays wallet token balances on 0g Chain
|
|
12
|
+
- Token swap flow with live quotes
|
|
13
|
+
- Fully styled with Radix + Tailwind Merge
|
|
14
|
+
- Written in TypeScript with full type definitions
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## 📦 Installation
|
|
19
|
+
|
|
20
|
+
Install via npm (or yarn / pnpm):
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install deserialize-0g-swap-widget
|
|
24
|
+
# or
|
|
25
|
+
yarn add deserialize-0g-swap-widget
|
|
26
|
+
# or
|
|
27
|
+
pnpm add deserialize-0g-swap-widget
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
You also need **peer dependencies** (if your project doesn’t already include them):
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install react react-dom ethers framer-motion lucide-react clsx tailwind-merge
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 🚀 Usage
|
|
39
|
+
|
|
40
|
+
### Basic Example (Next.js / React)
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
"use client";
|
|
44
|
+
|
|
45
|
+
import { SwapForm } from "deserialize-0g-swap-widget";
|
|
46
|
+
import "deserialize-0g-swap-widget/styles.css";
|
|
47
|
+
|
|
48
|
+
export default function SwapPage() {
|
|
49
|
+
return (
|
|
50
|
+
<div className="max-w-md mx-auto mt-10">
|
|
51
|
+
<SwapForm walletAddress="0xYourWalletAddress" connected={true} />
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
### With Default Parameters
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
<SwapForm
|
|
65
|
+
walletAddress="0xYourWallet"
|
|
66
|
+
connected={true}
|
|
67
|
+
defaultParams={{
|
|
68
|
+
tokenIn: "0xTokenInAddress",
|
|
69
|
+
tokenOut: "0xTokenOutAddress",
|
|
70
|
+
amount: "1.5",
|
|
71
|
+
dexId: "ZERO_G",
|
|
72
|
+
}}
|
|
73
|
+
/>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
### Listening to Param Changes
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
<SwapForm
|
|
82
|
+
walletAddress="0xYourWallet"
|
|
83
|
+
connected={true}
|
|
84
|
+
onParamsChange={(params) => {
|
|
85
|
+
console.log("Swap form params updated:", params);
|
|
86
|
+
}}
|
|
87
|
+
/>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## 🧩 Hooks
|
|
93
|
+
|
|
94
|
+
### `useWalletAssets`
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
import { useWalletAssets } from "deserialize-0g-swap-widget";
|
|
98
|
+
|
|
99
|
+
function Balances({ walletAddress }: { walletAddress: string }) {
|
|
100
|
+
const { assets, loading, error } = useWalletAssets(walletAddress);
|
|
101
|
+
|
|
102
|
+
if (loading) return <p>Loading balances...</p>;
|
|
103
|
+
if (error) return <p>Error: {error}</p>;
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<ul>
|
|
107
|
+
{assets.map((a) => (
|
|
108
|
+
<li key={a.address}>
|
|
109
|
+
{a.symbol}: {a.balance}
|
|
110
|
+
</li>
|
|
111
|
+
))}
|
|
112
|
+
</ul>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### `fetchAssets`
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
import { fetchAssets } from "deserialize-0g-swap-widget";
|
|
121
|
+
import { useDeserializeEVM } from "deserialize-evm-client-sdk";
|
|
122
|
+
|
|
123
|
+
const { getBalance } = useDeserializeEVM("0xYourWallet");
|
|
124
|
+
|
|
125
|
+
const assets = await fetchAssets("0xYourWallet", getBalance);
|
|
126
|
+
console.log(assets);
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## 🛠 Types
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
import type {
|
|
135
|
+
SwapFormProps,
|
|
136
|
+
TokenAsset,
|
|
137
|
+
FormState,
|
|
138
|
+
DexIdTypes,
|
|
139
|
+
InputActionButtonType,
|
|
140
|
+
} from "deserialize-0g-swap-widget";
|
|
141
|
+
```
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { B as p, g as m, s as w, d as k, i as b, l as L, a as O, c as E, b as x, e as R, H as y, f as M } from "./index-CuYsyW6b.mjs";
|
|
2
|
+
class S extends p {
|
|
3
|
+
constructor({ callbackSelector: r, cause: a, data: n, extraData: i, sender: f, urls: t }) {
|
|
4
|
+
var o;
|
|
5
|
+
super(a.shortMessage || "An error occurred while fetching for an offchain result.", {
|
|
6
|
+
cause: a,
|
|
7
|
+
metaMessages: [
|
|
8
|
+
...a.metaMessages || [],
|
|
9
|
+
(o = a.metaMessages) != null && o.length ? "" : [],
|
|
10
|
+
"Offchain Gateway Call:",
|
|
11
|
+
t && [
|
|
12
|
+
" Gateway URL(s):",
|
|
13
|
+
...t.map((d) => ` ${m(d)}`)
|
|
14
|
+
],
|
|
15
|
+
` Sender: ${f}`,
|
|
16
|
+
` Data: ${n}`,
|
|
17
|
+
` Callback selector: ${r}`,
|
|
18
|
+
` Extra data: ${i}`
|
|
19
|
+
].flat(),
|
|
20
|
+
name: "OffchainLookupError"
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
class $ extends p {
|
|
25
|
+
constructor({ result: r, url: a }) {
|
|
26
|
+
super("Offchain gateway response is malformed. Response data must be a hex value.", {
|
|
27
|
+
metaMessages: [
|
|
28
|
+
`Gateway URL: ${m(a)}`,
|
|
29
|
+
`Response: ${w(r)}`
|
|
30
|
+
],
|
|
31
|
+
name: "OffchainLookupResponseMalformedError"
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
class q extends p {
|
|
36
|
+
constructor({ sender: r, to: a }) {
|
|
37
|
+
super("Reverted sender address does not match target contract address (`to`).", {
|
|
38
|
+
metaMessages: [
|
|
39
|
+
`Contract address: ${a}`,
|
|
40
|
+
`OffchainLookup sender address: ${r}`
|
|
41
|
+
],
|
|
42
|
+
name: "OffchainLookupSenderMismatchError"
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const A = "0x556f1830", T = {
|
|
47
|
+
name: "OffchainLookup",
|
|
48
|
+
type: "error",
|
|
49
|
+
inputs: [
|
|
50
|
+
{
|
|
51
|
+
name: "sender",
|
|
52
|
+
type: "address"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "urls",
|
|
56
|
+
type: "string[]"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "callData",
|
|
60
|
+
type: "bytes"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: "callbackFunction",
|
|
64
|
+
type: "bytes4"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: "extraData",
|
|
68
|
+
type: "bytes"
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
};
|
|
72
|
+
async function D(c, { blockNumber: r, blockTag: a, data: n, to: i }) {
|
|
73
|
+
const { args: f } = k({
|
|
74
|
+
data: n,
|
|
75
|
+
abi: [T]
|
|
76
|
+
}), [t, o, d, l, s] = f, { ccipRead: e } = c, h = e && typeof (e == null ? void 0 : e.request) == "function" ? e.request : C;
|
|
77
|
+
try {
|
|
78
|
+
if (!b(i, t))
|
|
79
|
+
throw new q({ sender: t, to: i });
|
|
80
|
+
const u = o.includes(L) ? await O({
|
|
81
|
+
data: d,
|
|
82
|
+
ccipRequest: h
|
|
83
|
+
}) : await h({ data: d, sender: t, urls: o }), { data: g } = await E(c, {
|
|
84
|
+
blockNumber: r,
|
|
85
|
+
blockTag: a,
|
|
86
|
+
data: x([
|
|
87
|
+
l,
|
|
88
|
+
R([{ type: "bytes" }, { type: "bytes" }], [u, s])
|
|
89
|
+
]),
|
|
90
|
+
to: i
|
|
91
|
+
});
|
|
92
|
+
return g;
|
|
93
|
+
} catch (u) {
|
|
94
|
+
throw new S({
|
|
95
|
+
callbackSelector: l,
|
|
96
|
+
cause: u,
|
|
97
|
+
data: n,
|
|
98
|
+
extraData: s,
|
|
99
|
+
sender: t,
|
|
100
|
+
urls: o
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async function C({ data: c, sender: r, urls: a }) {
|
|
105
|
+
var i;
|
|
106
|
+
let n = new Error("An unknown error occurred.");
|
|
107
|
+
for (let f = 0; f < a.length; f++) {
|
|
108
|
+
const t = a[f], o = t.includes("{data}") ? "GET" : "POST", d = o === "POST" ? { data: c, sender: r } : void 0, l = o === "POST" ? { "Content-Type": "application/json" } : {};
|
|
109
|
+
try {
|
|
110
|
+
const s = await fetch(t.replace("{sender}", r.toLowerCase()).replace("{data}", c), {
|
|
111
|
+
body: JSON.stringify(d),
|
|
112
|
+
headers: l,
|
|
113
|
+
method: o
|
|
114
|
+
});
|
|
115
|
+
let e;
|
|
116
|
+
if ((i = s.headers.get("Content-Type")) != null && i.startsWith("application/json") ? e = (await s.json()).data : e = await s.text(), !s.ok) {
|
|
117
|
+
n = new y({
|
|
118
|
+
body: d,
|
|
119
|
+
details: e != null && e.error ? w(e.error) : s.statusText,
|
|
120
|
+
headers: s.headers,
|
|
121
|
+
status: s.status,
|
|
122
|
+
url: t
|
|
123
|
+
});
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
if (!M(e)) {
|
|
127
|
+
n = new $({
|
|
128
|
+
result: e,
|
|
129
|
+
url: t
|
|
130
|
+
});
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
return e;
|
|
134
|
+
} catch (s) {
|
|
135
|
+
n = new y({
|
|
136
|
+
body: d,
|
|
137
|
+
details: s.message,
|
|
138
|
+
url: t
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
throw n;
|
|
143
|
+
}
|
|
144
|
+
export {
|
|
145
|
+
C as ccipRequest,
|
|
146
|
+
D as offchainLookup,
|
|
147
|
+
T as offchainLookupAbiItem,
|
|
148
|
+
A as offchainLookupSignature
|
|
149
|
+
};
|
|
150
|
+
//# sourceMappingURL=ccip-BGicimZg.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ccip-BGicimZg.mjs","sources":["../node_modules/viem/_esm/errors/ccip.js","../node_modules/viem/_esm/utils/ccip.js"],"sourcesContent":["import { stringify } from '../utils/stringify.js';\nimport { BaseError } from './base.js';\nimport { getUrl } from './utils.js';\nexport class OffchainLookupError extends BaseError {\n constructor({ callbackSelector, cause, data, extraData, sender, urls, }) {\n super(cause.shortMessage ||\n 'An error occurred while fetching for an offchain result.', {\n cause,\n metaMessages: [\n ...(cause.metaMessages || []),\n cause.metaMessages?.length ? '' : [],\n 'Offchain Gateway Call:',\n urls && [\n ' Gateway URL(s):',\n ...urls.map((url) => ` ${getUrl(url)}`),\n ],\n ` Sender: ${sender}`,\n ` Data: ${data}`,\n ` Callback selector: ${callbackSelector}`,\n ` Extra data: ${extraData}`,\n ].flat(),\n name: 'OffchainLookupError',\n });\n }\n}\nexport class OffchainLookupResponseMalformedError extends BaseError {\n constructor({ result, url }) {\n super('Offchain gateway response is malformed. Response data must be a hex value.', {\n metaMessages: [\n `Gateway URL: ${getUrl(url)}`,\n `Response: ${stringify(result)}`,\n ],\n name: 'OffchainLookupResponseMalformedError',\n });\n }\n}\nexport class OffchainLookupSenderMismatchError extends BaseError {\n constructor({ sender, to }) {\n super('Reverted sender address does not match target contract address (`to`).', {\n metaMessages: [\n `Contract address: ${to}`,\n `OffchainLookup sender address: ${sender}`,\n ],\n name: 'OffchainLookupSenderMismatchError',\n });\n }\n}\n//# sourceMappingURL=ccip.js.map","import { call } from '../actions/public/call.js';\nimport { OffchainLookupError, OffchainLookupResponseMalformedError, OffchainLookupSenderMismatchError, } from '../errors/ccip.js';\nimport { HttpRequestError, } from '../errors/request.js';\nimport { decodeErrorResult } from './abi/decodeErrorResult.js';\nimport { encodeAbiParameters } from './abi/encodeAbiParameters.js';\nimport { isAddressEqual } from './address/isAddressEqual.js';\nimport { concat } from './data/concat.js';\nimport { isHex } from './data/isHex.js';\nimport { localBatchGatewayRequest, localBatchGatewayUrl, } from './ens/localBatchGatewayRequest.js';\nimport { stringify } from './stringify.js';\nexport const offchainLookupSignature = '0x556f1830';\nexport const offchainLookupAbiItem = {\n name: 'OffchainLookup',\n type: 'error',\n inputs: [\n {\n name: 'sender',\n type: 'address',\n },\n {\n name: 'urls',\n type: 'string[]',\n },\n {\n name: 'callData',\n type: 'bytes',\n },\n {\n name: 'callbackFunction',\n type: 'bytes4',\n },\n {\n name: 'extraData',\n type: 'bytes',\n },\n ],\n};\nexport async function offchainLookup(client, { blockNumber, blockTag, data, to, }) {\n const { args } = decodeErrorResult({\n data,\n abi: [offchainLookupAbiItem],\n });\n const [sender, urls, callData, callbackSelector, extraData] = args;\n const { ccipRead } = client;\n const ccipRequest_ = ccipRead && typeof ccipRead?.request === 'function'\n ? ccipRead.request\n : ccipRequest;\n try {\n if (!isAddressEqual(to, sender))\n throw new OffchainLookupSenderMismatchError({ sender, to });\n const result = urls.includes(localBatchGatewayUrl)\n ? await localBatchGatewayRequest({\n data: callData,\n ccipRequest: ccipRequest_,\n })\n : await ccipRequest_({ data: callData, sender, urls });\n const { data: data_ } = await call(client, {\n blockNumber,\n blockTag,\n data: concat([\n callbackSelector,\n encodeAbiParameters([{ type: 'bytes' }, { type: 'bytes' }], [result, extraData]),\n ]),\n to,\n });\n return data_;\n }\n catch (err) {\n throw new OffchainLookupError({\n callbackSelector,\n cause: err,\n data,\n extraData,\n sender,\n urls,\n });\n }\n}\nexport async function ccipRequest({ data, sender, urls, }) {\n let error = new Error('An unknown error occurred.');\n for (let i = 0; i < urls.length; i++) {\n const url = urls[i];\n const method = url.includes('{data}') ? 'GET' : 'POST';\n const body = method === 'POST' ? { data, sender } : undefined;\n const headers = method === 'POST' ? { 'Content-Type': 'application/json' } : {};\n try {\n const response = await fetch(url.replace('{sender}', sender.toLowerCase()).replace('{data}', data), {\n body: JSON.stringify(body),\n headers,\n method,\n });\n let result;\n if (response.headers.get('Content-Type')?.startsWith('application/json')) {\n result = (await response.json()).data;\n }\n else {\n result = (await response.text());\n }\n if (!response.ok) {\n error = new HttpRequestError({\n body,\n details: result?.error\n ? stringify(result.error)\n : response.statusText,\n headers: response.headers,\n status: response.status,\n url,\n });\n continue;\n }\n if (!isHex(result)) {\n error = new OffchainLookupResponseMalformedError({\n result,\n url,\n });\n continue;\n }\n return result;\n }\n catch (err) {\n error = new HttpRequestError({\n body,\n details: err.message,\n url,\n });\n }\n }\n throw error;\n}\n//# sourceMappingURL=ccip.js.map"],"names":["OffchainLookupError","BaseError","callbackSelector","cause","data","extraData","sender","urls","_a","url","getUrl","OffchainLookupResponseMalformedError","result","stringify","OffchainLookupSenderMismatchError","to","offchainLookupSignature","offchainLookupAbiItem","offchainLookup","client","blockNumber","blockTag","args","decodeErrorResult","callData","ccipRead","ccipRequest_","ccipRequest","isAddressEqual","localBatchGatewayUrl","localBatchGatewayRequest","data_","call","concat","encodeAbiParameters","err","error","i","method","body","headers","response","HttpRequestError","isHex"],"mappings":";AAGO,MAAMA,UAA4BC,EAAU;AAAA,EAC/C,YAAY,EAAE,kBAAAC,GAAkB,OAAAC,GAAO,MAAAC,GAAM,WAAAC,GAAW,QAAAC,GAAQ,MAAAC,KAAS;;AACrE,UAAMJ,EAAM,gBACR,4DAA4D;AAAA,MAC5D,OAAAA;AAAA,MACA,cAAc;AAAA,QACV,GAAIA,EAAM,gBAAgB;SAC1BK,IAAAL,EAAM,iBAAN,QAAAK,EAAoB,SAAS,KAAK,CAAA;AAAA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IACL;AAAA,EACJ;AACA,QAAM2B;AACV;","x_google_ignoreList":[0,1]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { PaymentType } from "../types";
|
|
3
|
+
interface AtlasPaymentButtonProps {
|
|
4
|
+
authKey: string;
|
|
5
|
+
merchantPaymentAddress: string;
|
|
6
|
+
onSuccess?: (receipt: any) => void;
|
|
7
|
+
onError?: (error: Error) => void;
|
|
8
|
+
className?: string;
|
|
9
|
+
buttonText?: string;
|
|
10
|
+
amount?: string;
|
|
11
|
+
paymentType?: PaymentType;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
chainId?: number;
|
|
14
|
+
}
|
|
15
|
+
export declare const AtlasPaymentButton: React.FC<AtlasPaymentButtonProps>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { PaymentType } from "../types";
|
|
3
|
+
interface AtlasPaymentFormProps {
|
|
4
|
+
authKey: string;
|
|
5
|
+
merchantPaymentAddress: string;
|
|
6
|
+
amount?: string;
|
|
7
|
+
paymentType?: PaymentType;
|
|
8
|
+
onSuccess?: (receipt: any) => void;
|
|
9
|
+
onError?: (error: Error) => void;
|
|
10
|
+
className?: string;
|
|
11
|
+
buttonText?: string;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
chainId?: number;
|
|
14
|
+
}
|
|
15
|
+
export declare const AtlasPaymentForm: React.FC<AtlasPaymentFormProps>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface PaymentStatus {
|
|
3
|
+
status: "idle" | "loading" | "validating" | "ready" | "processing" | "success" | "error";
|
|
4
|
+
message: string;
|
|
5
|
+
transactionHash?: string;
|
|
6
|
+
error?: string;
|
|
7
|
+
}
|
|
8
|
+
interface AtlasPaymentStatusProps {
|
|
9
|
+
status: PaymentStatus;
|
|
10
|
+
}
|
|
11
|
+
export declare const AtlasPaymentStatus: React.FC<AtlasPaymentStatusProps>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { PaymentType, DecryptedCredentials } from "../types";
|
|
2
|
+
interface PaymentStatus {
|
|
3
|
+
status: "idle" | "loading" | "validating" | "ready" | "processing" | "success" | "error";
|
|
4
|
+
message: string;
|
|
5
|
+
transactionHash?: string;
|
|
6
|
+
error?: string;
|
|
7
|
+
}
|
|
8
|
+
interface PaymentData {
|
|
9
|
+
cardId?: string;
|
|
10
|
+
businessAddress?: string;
|
|
11
|
+
userAddress?: string;
|
|
12
|
+
identifier?: string;
|
|
13
|
+
credentials?: DecryptedCredentials;
|
|
14
|
+
isValid: boolean;
|
|
15
|
+
isLoading: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare const useAtlasPayment: (authKey: string, paymentType: PaymentType) => {
|
|
18
|
+
processPayment: (merchantAddress: string, amount: string) => Promise<{
|
|
19
|
+
success: boolean;
|
|
20
|
+
transactionHash: any;
|
|
21
|
+
amount: string;
|
|
22
|
+
merchant: string;
|
|
23
|
+
type: PaymentType;
|
|
24
|
+
paymentData: PaymentData;
|
|
25
|
+
}>;
|
|
26
|
+
status: PaymentStatus;
|
|
27
|
+
paymentData: PaymentData;
|
|
28
|
+
reset: () => void;
|
|
29
|
+
};
|
|
30
|
+
export {};
|