-
Notifications
You must be signed in to change notification settings - Fork 0
/
index-normal.html
159 lines (143 loc) · 7.52 KB
/
index-normal.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0" />
<title>Crescent SDK</title>
<script src="./dist/umd/index.bundle.js"></script>
<!-- <script src="./index.bundle.js?v=2"></script>-->
<style>
body {
margin: 0px;
padding: 0px;
background-color: transparent;
overflow: hidden;
}
.base {
display: flex;
position: relative;
flex-direction: column;
}
.btn {
width: 150px;
height: 40px;
margin-top: 50px;
}
.btn-wrap {
display: flex;
position: relative;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
}
.pop-parent {
display: none;
position: fixed;
justify-content: center;
align-items: center;
height: 100%;
width: 100%;
background: rgba(0, 0, 0, 0.4)
}
</style>
</head>
<body>
<div class="base">
<span id="user_id"></span>
<div class="btn-wrap">
<button class="btn" onclick="connect()">Connect</button>
<button class="btn" onclick="connect2()">Connect2</button>
<button class="btn" onclick="sendTransaction()">SendTransaction</button>
<button class="btn" onclick="fiatOnRamp()">fiatOnRamp</button>
<button class="btn" onclick="logout()">Logout</button>
</div>
<div class="pop-parent" id="parent_div" onclick="closePop()"></div>
</div>
<script>
function connect() {
const element = document.getElementById('parent_div');
element.style.display = "flex";
const params = {
container: element,
paymasterUrl: "https://wallet.crescentbase.com/api/v2/signOp",
onConnectSuccess: (info) => {
const email = info.email;
const address = info.address;
console.log('email:', email);
console.log('address:', address);
// const spanElement = document.getElementById('user_id');
// spanElement.innerText = `Email: ${email} \n Address: ${address}`;
},
emailAccount: '[email protected]',
walletJson: '{"address":"691ec6bcfa1990bb1b739c6671e8770bae50d2eb","id":"c9ab0ca6-aece-40c5-911a-add69a833528","version":3,"crypto":{"cipher":"aes-128-ctr","cipherparams":{"iv":"96ca7147d6a72ff8e706aa086da0b2a0"},"ciphertext":"ad31afe2d998ae0749810818999975f6f069512b5e87931646f1f94f083d30ae","kdf":"scrypt","kdfparams":{"salt":"474236e545a4c28af4e0b39724e46947e18db01c5f8f8cbee360e8eca7579e5f","n":256,"dklen":32,"p":1,"r":8},"mac":"f719c44ceee797ace82cefd5b8e4eeec271732ca48d1dc75bb56acc36d8a90f6"}}'
// emailAccount: '[email protected]',
// walletJson: '{"address":"e55df1714bdd343e5b1fd85ceb4197d8a16bbdcd","id":"e765dca0-8bbd-4623-a333-fe4c9e7bad54","version":3,"crypto":{"cipher":"aes-128-ctr","cipherparams":{"iv":"ab48bf64c4d6ffa63c66e0234d967e66"},"ciphertext":"9cdc7c936ba6341ec4f55fda02293a751d00ac899a517777bed4eb545d688e03","kdf":"scrypt","kdfparams":{"salt":"11eb1a988ae0fa56dcdcd709eacd0dddc412c4b461c6118202155a9c2ae77638","n":256,"dklen":32,"p":1,"r":8},"mac":"90b5a203e73d0ed1156abd5228d38ac535540af1a04e772616eda3df4fdb4b15"}}'
// tx: {to: '0x0648ceA573a37aD78738c9ED861dD8Ad9Ca53beC', chainId: 137, value: '0x2386f26fc10000'}
}
CrescentSDK.connect(params);
}
function connect2() {
const element = document.getElementById('parent_div');
element.style.display = "flex";
const params = {
container: element,
paymasterUrl: "https://wallet.crescentbase.com/api/v2/signOp",
onConnectSuccess: (info) => {
const email = info.email;
const address = info.address;
console.log('email:', email);
console.log('address:', address);
// const spanElement = document.getElementById('user_id');
// spanElement.innerText = `Email: ${email} \n Address: ${address}`;
},
emailAccount: '[email protected]',
walletJson: '{"address":"691ec6bcfa1990bb1b739c6671e8770bae50d2eb","id":"c9ab0ca6-aece-40c5-911a-add69a833528","version":3,"crypto":{"cipher":"aes-128-ctr","cipherparams":{"iv":"96ca7147d6a72ff8e706aa086da0b2a0"},"ciphertext":"ad31afe2d998ae0749810818999975f6f069512b5e87931646f1f94f083d30ae","kdf":"scrypt","kdfparams":{"salt":"474236e545a4c28af4e0b39724e46947e18db01c5f8f8cbee360e8eca7579e5f","n":256,"dklen":32,"p":1,"r":8},"mac":"f719c44ceee797ace82cefd5b8e4eeec271732ca48d1dc75bb56acc36d8a90f6"}}',
// emailAccount: '[email protected]',
// walletJson: '{"address":"e55df1714bdd343e5b1fd85ceb4197d8a16bbdcd","id":"e765dca0-8bbd-4623-a333-fe4c9e7bad54","version":3,"crypto":{"cipher":"aes-128-ctr","cipherparams":{"iv":"ab48bf64c4d6ffa63c66e0234d967e66"},"ciphertext":"9cdc7c936ba6341ec4f55fda02293a751d00ac899a517777bed4eb545d688e03","kdf":"scrypt","kdfparams":{"salt":"11eb1a988ae0fa56dcdcd709eacd0dddc412c4b461c6118202155a9c2ae77638","n":256,"dklen":32,"p":1,"r":8},"mac":"90b5a203e73d0ed1156abd5228d38ac535540af1a04e772616eda3df4fdb4b15"}}'
// tx: {to: '0x0648ceA573a37aD78738c9ED861dD8Ad9Ca53beC', chainId: 137, value: '0x2386f26fc10000'}
onClose: () => {
closePop();
}
}
CrescentSDK.connect2(params);
}
function sendTransaction() {
const element = document.getElementById('parent_div');
element.style.display = "flex";
const params = {
container: element,
paymasterUrl: "https://wallet.crescentbase.com/api/v2/signOp",
onSendSuccess: (txHash) => {
console.log('txHash: ', txHash)
const spanElement = document.getElementById('user_id');
spanElement.innerText = txHash;
},
// emailAccount: '[email protected]',
// walletJson: '{"address":"e55df1714bdd343e5b1fd85ceb4197d8a16bbdcd","id":"e765dca0-8bbd-4623-a333-fe4c9e7bad54","version":3,"crypto":{"cipher":"aes-128-ctr","cipherparams":{"iv":"ab48bf64c4d6ffa63c66e0234d967e66"},"ciphertext":"9cdc7c936ba6341ec4f55fda02293a751d00ac899a517777bed4eb545d688e03","kdf":"scrypt","kdfparams":{"salt":"11eb1a988ae0fa56dcdcd709eacd0dddc412c4b461c6118202155a9c2ae77638","n":256,"dklen":32,"p":1,"r":8},"mac":"90b5a203e73d0ed1156abd5228d38ac535540af1a04e772616eda3df4fdb4b15"}}'
// emailAccount: '[email protected]',
// walletJson:'{"address":"8a73520b8052d7023d327cf6786533cd22fbcdd5","id":"c2e3af00-e9ee-4a15-8da4-4ead185e1212","version":3,"crypto":{"cipher":"aes-128-ctr","cipherparams":{"iv":"cd9dcc4506caeb1f0a974eaf4f0bd68c"},"ciphertext":"ba2a2b05936b44eb1ab4c655926a1d65c6c912d762fa39215b3aa9104f5d7ba6","kdf":"scrypt","kdfparams":{"salt":"1f2cc358cce3139f0b8c2ab4289e996f08b3524354f48dd8161390b9161e8c45","n":256,"dklen":32,"p":1,"r":8},"mac":"b947b5662ac7001dc452d86b817534527b396fb880f98909abc5eee6ecc749d6"}}'
tx: {to: '0x0648ceA573a37aD78738c9ED861dD8Ad9Ca53beC', chainId: 137, value: '0x2386f26fc10000'}
}
CrescentSDK.connect(params);
}
function logout() {
CrescentSDK.logout();
}
function closePop() {
const element = document.getElementById('parent_div');
element.style.display = "none";
while (element.firstChild) {
element.removeChild(element.firstChild);
}
}
function fiatOnRamp() {
const params = {
walletAddress: '0x0648ceA573a37aD78738c9ED861dD8Ad9Ca53beC'
}
// CrescentSDK.fiatOnRamp(params);
CrescentSDK.fiatOnRamp(); //If using the wallet address of crescent sdk, no parameters are required
}
</script>
</body>
</html>