Skip to content

Commit 56857a9

Browse files
feat: contractAddress shown in universal-provider-tezos
1 parent 6c1bf27 commit 56857a9

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

dapps/universal-provider-tezos/.codesandbox/tasks.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"command": "yarn dev",
1515
"runAtStart": true,
1616
"preview": {
17-
"port": 5173
17+
"port": 5175
1818
}
1919
},
2020
"build": {

dapps/universal-provider-tezos/src/App.tsx

+14-8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
TezosGetAccountResponse
1616
} from './utils/helpers'
1717
import { SAMPLE_KINDS, SAMPLES } from './utils/samples'
18+
import { ErrorObject } from '@walletconnect/utils'
1819

1920
const projectId = import.meta.env.VITE_PROJECT_ID
2021

@@ -31,7 +32,7 @@ const App = () => {
3132
const [isConnected, setIsConnected] = useState(false)
3233
const [lastKind, setLastKind] = useState<SAMPLE_KINDS | undefined>(undefined)
3334
const [result, setResult] = useState<
34-
TezosSendResponse | TezosSignResponse | TezosGetAccountResponse | string | null
35+
TezosSendResponse | TezosSignResponse | TezosGetAccountResponse | ErrorObject | string | null
3536
>(null)
3637
const [description, setDescription] = useState<Record<string, unknown> | string | undefined>(
3738
undefined
@@ -132,7 +133,9 @@ const App = () => {
132133
if (provider) {
133134
await provider.disconnect()
134135
setIsConnected(false)
135-
setResult(null) // Clear result on disconnect
136+
setResult(null)
137+
setContractAddress('[click Origination to get contract address]')
138+
setBalance('')
136139
}
137140
}, [provider])
138141

@@ -170,7 +173,7 @@ const App = () => {
170173
SAMPLES[kind]
171174
)
172175
console.log('TezosRpc origination result: ', res)
173-
for (let attempt = 0; attempt < 5; attempt++) {
176+
for (let attempt = 0; attempt < 10; attempt++) {
174177
const contractAddressList = await apiGetContractAddress(
175178
TezosChainData['testnet'].id,
176179
res.hash
@@ -212,7 +215,7 @@ const App = () => {
212215
await getBalance()
213216
} catch (error) {
214217
console.error(`Error sending ${kind}:`, error)
215-
setResult(JSON.stringify(error, null, 2))
218+
setResult(error as ErrorObject)
216219
}
217220
},
218221
[provider, address]
@@ -225,7 +228,7 @@ const App = () => {
225228
}
226229
}, [address])
227230

228-
const describe = useCallback((kind: SAMPLE_KINDS) => {
231+
const describe = (kind: SAMPLE_KINDS) => {
229232
switch (kind) {
230233
case SAMPLE_KINDS.SEND_TRANSACTION:
231234
case SAMPLE_KINDS.SEND_DELEGATION:
@@ -247,11 +250,11 @@ const App = () => {
247250
default:
248251
setDescription('No description available')
249252
}
250-
}, [])
253+
}
251254

252-
const describeClear = useCallback(() => {
255+
const describeClear = () => {
253256
setDescription(undefined)
254-
}, [])
257+
}
255258

256259
return (
257260
<div className="App">
@@ -274,6 +277,9 @@ const App = () => {
274277
<p>
275278
<b>Balance:</b> {balance}
276279
</p>
280+
<p>
281+
<b>Contract Address:</b> {contractAddress}
282+
</p>
277283
<div className="layout-container">
278284
<div className="btn-container">
279285
<button onClick={disconnect} onMouseEnter={describeClear}>

0 commit comments

Comments
 (0)