Skip to content

Commit

Permalink
Version Packages
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored and iosh committed Sep 23, 2024
1 parent 69fba58 commit 4e47e01
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 45 deletions.
5 changes: 0 additions & 5 deletions .changeset/hot-cougars-cheer.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/hungry-queens-hunt.md

This file was deleted.

68 changes: 34 additions & 34 deletions examples/client_wallet_fluent/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,78 +6,78 @@ import {
custom,
parseCFX,
SignMessageErrorType,
} from "cive";
import { mainnet, testnet } from "cive/chains";
import React, { useCallback, useEffect, useMemo, useState } from "react";
import "cive/window";
import type { SendTransactionErrorType } from "../../../src/_types/actions/wallet/sendTransaction";
} from 'cive'
import { mainnet, testnet } from 'cive/chains'
import React, { useCallback, useEffect, useMemo, useState } from 'react'
import 'cive/window'
import type { SendTransactionErrorType } from '../../../src/_types/actions/wallet/sendTransaction'

export default function App() {
const [account, setAccount] = useState<Address>();
const [transaction, setTransaction] = useState<string>();
const [signMessage, setSignMessage] = useState<string>();
const [account, setAccount] = useState<Address>()
const [transaction, setTransaction] = useState<string>()
const [signMessage, setSignMessage] = useState<string>()

const walletClient = useMemo(
() =>
createWalletClient({
chain: testnet,
transport: custom(window.fluent!),
}),
[]
);
[],
)

const connect = useCallback(async () => {
const [address] = await walletClient.requestAddresses();
setAccount(address);
}, [walletClient]);
const [address] = await walletClient.requestAddresses()
setAccount(address)
}, [walletClient])

const handleSendTransaction = useCallback(async () => {
if (account) {
try {
const hash = await walletClient.sendTransaction({
account,
to: account,
value: parseCFX("0.01"),
});
setTransaction(`successful: ${hash}`);
value: parseCFX('0.01'),
})
setTransaction(`successful: ${hash}`)
} catch (error: unknown) {
const err = error as SendTransactionErrorType;
setTransaction(err.name);
const err = error as SendTransactionErrorType
setTransaction(err.name)
}
}
}, [walletClient, account]);
}, [walletClient, account])

const handleSignMessage = useCallback(async () => {
if (account) {
try {
const signature = await walletClient.signMessage({
account,
message: "hello world",
});
setSignMessage(`successful: ${signature}`);
message: 'hello world',
})
setSignMessage(`successful: ${signature}`)
} catch (error: unknown) {
const err = error as SignMessageErrorType;
const err = error as SignMessageErrorType

setSignMessage(err.name);
setSignMessage(err.name)
}
}
}, [walletClient, account]);
}, [walletClient, account])

const handleSwitchChain = useCallback(async () => {
if (account) {
await walletClient.switchChain({ id: testnet.id });
await walletClient.switchChain({ id: testnet.id })
}
}, [walletClient, account]);
}, [walletClient, account])
useEffect(() => {
window?.fluent?.on("accountsChanged", (accounts: Address[]) => {
window?.fluent?.on('accountsChanged', (accounts: Address[]) => {
if (accounts.length > 0) {
setAccount(accounts[0]);
setAccount(accounts[0])
} else {
setAccount(undefined);
setAccount(undefined)
}
});
window?.fluent?.on("disconnect", () => setAccount(undefined));
}, []);
})
window?.fluent?.on('disconnect', () => setAccount(undefined))
}, [])

return (
<div className="box">
Expand Down Expand Up @@ -120,5 +120,5 @@ export default function App() {
</div>
</div>
</div>
);
)
}
7 changes: 7 additions & 0 deletions src/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# cive

## 0.4.1

### Patch Changes

- f484fe1: Added wallet action to export
- 68dd2a6: Fixed EIP1193EventMap Address type

## 0.4.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cive",
"version": "0.4.0",
"version": "0.4.1",
"description": "",
"type": "module",
"main": "./_cjs/index.js",
Expand Down

0 comments on commit 4e47e01

Please sign in to comment.