Skip to content

Commit dccfcbb

Browse files
committed
improve readme
1 parent 887f0c4 commit dccfcbb

File tree

4 files changed

+106
-64
lines changed

4 files changed

+106
-64
lines changed

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,42 @@
22

33
An implementation of Infrastructure for intent based transactions with Account abstraction
44

5+
# Contracts
6+
7+
```
8+
case Chains.celoTestnet:
9+
return {
10+
Elliptic: "0xEA4d16E741E76E7a93b8f46650537855149efc48",
11+
TouchIdSafeWalletContractProxyFactoryAddress:
12+
"0x8e5ffc77D0906618A8Ed73dB34f92Ea0251B327b",
13+
TouchIdSafeWalletContractSingletonAddress:
14+
"0xeDba372c904298b79D421a70d9D448E822Bc697E",
15+
fallBackHandlerAddress: "0xac1c08a5a59cEA20518f7201bB0dda29d9454eb0",
16+
};
17+
18+
case Chains.mantleTestnet:
19+
return {
20+
Elliptic: "0x652D29F01fdF8d0c20F78f51bAc9B173B3a76a9B",
21+
TouchIdSafeWalletContractProxyFactoryAddress:
22+
"0x9C0A83154846725446EF3907DaAb41951d2635A1",
23+
TouchIdSafeWalletContractSingletonAddress:
24+
"0x824Eae34D5bB73FE97969dc80f01c5baf0D3f8D6",
25+
fallBackHandlerAddress: "0x4314e106c276413814a01A1618B06c39161fc290",
26+
}
27+
case Chains.gnosis:
28+
return {
29+
Elliptic: "0xC29fDf5544312E23d9cDa9fB67388d040Fdbf434",
30+
TouchIdSafeWalletContractProxyFactoryAddress:
31+
"0x8e5ffc77D0906618A8Ed73dB34f92Ea0251B327b",
32+
TouchIdSafeWalletContractSingletonAddress:
33+
// "0x6f4D71B05140a1DD6D328e0C58216edD1590654e",
34+
"0xDcA01E080a8984830f1f2292d5c723d38223563C",
35+
fallBackHandlerAddress: "0xac1c08a5a59cEA20518f7201bB0dda29d9454eb0",
36+
};
37+
```
38+
39+
40+
541
## Getting Started
642

743
Instructions for how to download and get the project running on your local machine.

client/src/components/Prompt/Prompt.jsx

Lines changed: 67 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { FaRegCopy } from "react-icons/fa";
1919
import { CopyToClipboard } from "react-copy-to-clipboard";
2020
import OnrampComponent from "../Onramp/Onramp";
2121
import { saveToLocalStorage } from "../../utils/saveToLocalstorage";
22-
import { ReactSearchAutocomplete } from 'react-search-autocomplete'
22+
import { ReactSearchAutocomplete } from "react-search-autocomplete";
2323
// import { AutoComplete } from "react-autocomplete";
2424

2525
const PromptComponent = () => {
@@ -71,26 +71,27 @@ const PromptComponent = () => {
7171

7272
const [fetch, { data: data, loading, pagination }] =
7373
useLazyQueryWithPagination(ERC20TokensQueryPolygon);
74-
75-
const gateway = (hash) => `https://beige-yeasty-scorpion-513.mypinata.cloud/ipfs/${hash}`;
74+
75+
const gateway = (hash) =>
76+
`https://beige-yeasty-scorpion-513.mypinata.cloud/ipfs/${hash}`;
7677
const fetchIntents = async () => {
7778
let hashes = localStorage.getItem(walletAddress);
78-
if(hashes) {
79+
if (hashes) {
7980
hashes = JSON.parse(hashes);
80-
console.log(hashes, hashes[0])
81-
for(let i=0; i < hashes.length; i++) {
82-
const res = await Axios.get(gateway(hashes[i]))
83-
console.log(res);
84-
let pIntents = previosIntents;
85-
pIntents.push({
86-
id: i,
87-
name: res.data.intent
88-
})
89-
setPreviousIntents(pIntents)
90-
console.log("all intens ", previosIntents)
81+
console.log(hashes, hashes[0]);
82+
for (let i = 0; i < hashes.length; i++) {
83+
const res = await Axios.get(gateway(hashes[i]));
84+
console.log(res);
85+
let pIntents = previosIntents;
86+
pIntents.push({
87+
id: i,
88+
name: res.data.intent,
89+
});
90+
setPreviousIntents(pIntents);
91+
console.log("all intens ", previosIntents);
9192
}
9293
}
93-
}
94+
};
9495

9596
useEffect(() => {
9697
// for now hardcoded the tokens
@@ -104,7 +105,7 @@ const PromptComponent = () => {
104105
});
105106
}
106107

107-
fetchIntents()
108+
fetchIntents();
108109
// initStripe()
109110
}, [fetch, walletAddress]);
110111

@@ -211,42 +212,39 @@ const PromptComponent = () => {
211212
setIsLoading(false);
212213
};
213214

214-
const getPinataMetaData = (intent) => (
215+
const getPinataMetaData = (intent) =>
215216
JSON.stringify({
216-
"pinataOptions": {
217-
"cidVersion": 1
217+
pinataOptions: {
218+
cidVersion: 1,
218219
},
219-
"pinataMetadata": {
220-
"name": "testing",
221-
"keyvalues": {
222-
"intent": intent,
223-
}
220+
pinataMetadata: {
221+
name: "testing",
222+
keyvalues: {
223+
intent: intent,
224+
},
224225
},
225-
"pinataContent": {
226-
"intent": intent
227-
}
228-
})
229-
);
230-
231-
const getPinataConfig = (intent) => (
232-
{
233-
method: 'post',
234-
url: 'https://api.pinata.cloud/pinning/pinJSONToIPFS',
235-
headers: {
236-
'Content-Type': 'application/json',
237-
'Authorization': `Bearer ${process.env.REACT_APP_PINATA_JWT}`
226+
pinataContent: {
227+
intent: intent,
238228
},
239-
data: getPinataMetaData(intent)
240-
}
241-
)
229+
});
230+
231+
const getPinataConfig = (intent) => ({
232+
method: "post",
233+
url: "https://api.pinata.cloud/pinning/pinJSONToIPFS",
234+
headers: {
235+
"Content-Type": "application/json",
236+
Authorization: `Bearer ${process.env.REACT_APP_PINATA_JWT}`,
237+
},
238+
data: getPinataMetaData(intent),
239+
});
242240

243241
const generateTransactions = async () => {
244242
setIsLoading(true);
245243
const pinataAxiosConfig = getPinataConfig(intent);
246-
console.log('this is pijnata axios config ', pinataAxiosConfig)
244+
console.log("this is pijnata axios config ", pinataAxiosConfig);
247245
// saving intents on ipfs for faster autocomplete
248-
const savingRes = await Axios(pinataAxiosConfig)
249-
console.log('resp', savingRes);
246+
const savingRes = await Axios(pinataAxiosConfig);
247+
console.log("resp", savingRes);
250248
// resp.data.IpfsHash
251249
saveToLocalStorage(walletAddress, savingRes.data.IpfsHash);
252250

@@ -260,7 +258,12 @@ const PromptComponent = () => {
260258
const transactions = JSON.parse(res.data.transactions);
261259
setTransactions(transactions.transaction);
262260
setTxnContext(transactions.context);
263-
setTxnType(transactions.type);
261+
262+
if (transactions.type) {
263+
setTxnType(transactions.type);
264+
} else {
265+
setTxnType("none");
266+
}
264267
setConfirmModal(true);
265268
};
266269
// goerli = 5,
@@ -287,50 +290,52 @@ const PromptComponent = () => {
287290
const itemss = [
288291
{
289292
id: 0,
290-
name: 'Cobol'
293+
name: "Cobol",
291294
},
292295
{
293296
id: 1,
294-
name: 'JavaScript'
297+
name: "JavaScript",
295298
},
296299
{
297300
id: 2,
298-
name: 'Basic'
301+
name: "Basic",
299302
},
300303
{
301304
id: 3,
302-
name: 'PHP'
305+
name: "PHP",
303306
},
304307
{
305308
id: 4,
306-
name: 'Java'
307-
}
308-
]
309+
name: "Java",
310+
},
311+
];
309312

310313
const handleOnSearch = (string, results) => {
311314
// onSearch will have as the first callback parameter
312315
// the string searched and for the second the results.
313-
console.log(string, results)
316+
console.log(string, results);
314317
setIntent(string);
315-
}
318+
};
316319

317320
const handleOnSelect = (item) => {
318321
// the item selected
319-
console.log(item)
320-
}
322+
console.log(item);
323+
};
321324

322325
const handleOnFocus = () => {
323-
console.log('Focused')
324-
}
326+
console.log("Focused");
327+
};
325328

326329
const formatResult = (item) => {
327330
return (
328331
<>
329332
{/* <span style={{ display: 'block', textAlign: 'left' }}>id: {item.id}</span> */}
330-
<span style={{ display: 'block', textAlign: 'left' }}>name: {item.name}</span>
333+
<span style={{ display: "block", textAlign: "left" }}>
334+
name: {item.name}
335+
</span>
331336
</>
332-
)
333-
}
337+
);
338+
};
334339

335340
return (
336341
<div>
@@ -375,7 +380,7 @@ const PromptComponent = () => {
375380
</div>
376381
<div className="prompt">
377382
<div className="content">
378-
{/* <ReactSearchAutocomplete
383+
{/* <ReactSearchAutocomplete
379384
items={previosIntents}
380385
onSearch={handleOnSearch}
381386
// onHover={handleOnHover}

parser/contants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ const nftInfoExtracter = [
143143
},
144144
{
145145
id: 2,
146-
question: `About which operation does the given statement talks about buying or selling if it is buying return answer as buy or if it is about selling return answer as sell ${ONE_WORD_ANS} also ${INFO_NOT_AVALAIBLE}`,
146+
question: `About which operation does the given statement talks about buy or sell if it is buying return answer as "buy" or if it is about selling return answer as "sell" ${ONE_WORD_ANS} also ${INFO_NOT_AVALAIBLE}`,
147147
},
148148
{
149149
id: 3,

parser/transactions/nftTransactions.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const constructNFTMintTransaction = (nftData) => {
4646

4747
return {
4848
success: true,
49-
context: 'This transaction will mint BAYC token of tokenid 124 to your address. The minting cost is currently 2.43 eth.',
49+
context: 'This transaction will mint BAYC NFT token to your address. The minting cost is currently 2.43 matic.',
5050
transaction: [
5151
{
5252
to: address,
@@ -149,6 +149,7 @@ const constructNFTSellTransaction = (nftData) => {
149149

150150
return {
151151
success: true,
152+
context: `This transaction would grant approval to your NFT of tokenid ${nftData.tokenId} to this ethereum address ${nftData.toAddress}`,
152153
transaction: [
153154
{
154155
to: address,

0 commit comments

Comments
 (0)