Skip to content

Commit b5afa1b

Browse files
committed
cleanup READEME
1 parent ccf9a57 commit b5afa1b

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
## Beta Testing
44

5-
### Release v0.1.4
5+
### Release v0.2.0
6+
+ ******** Breaking changes ********
67
+ Rename ConvexAccount to Account
78
+ Rename ConvexAPI to API
89
+ Split ConvexAccount to KeyPair
10+
+ API class has to use the `create` method to create a new object
911

1012
### Relase 0.1.3
1113
+ Add address '#' identifier before each address number.

README.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ API toolkit to access convex network.
1010
First import the library and setup the convex API connection
1111

1212
```js
13-
import { ConvexAPI, ConvexAccount } from '@convex-dev/convex-api-js'
14-
15-
const convex = new ConvexAPI('https://convex.world')
13+
import { API, Account, KeyPair } from '@convex-dev/convex-api-js'
1614

15+
const convex = API.create('https://convex.world')
1716
```
1817

19-
Create a new account with random keys.
20-
```js
18+
Create a new account with some a random key pair.
2119

22-
const account = convex.createAccount()
20+
```js
21+
const keyPair = KeyPair.create()
22+
const account = convex.createAccount(keyPair)
2323
```
2424

2525
Topup account to have sufficient funds.
@@ -30,13 +30,15 @@ Topup account to have sufficient funds.
3030
```
3131

3232
Check the balance on the new account.
33+
3334
```js
3435
const balance = await convex.getBalance(account)
3536
console.log(`The account ${account.address} has a balance of ${balance}`)
3637

3738
```
3839

3940
Do a send, this will cost the account a small fee so we need the account object to sign the transaction.
41+
4042
```js
4143
const resultSend = await convex.send('(map inc [1 2 3 4 5])', account)
4244
consol.log(`Result from calculation ${resultSend}`)
@@ -51,38 +53,40 @@ This can be usefull if you whish to query an actors state by using the actors ad
5153
consol.log(`Result from a query ${resultQuery}`)
5254
```
5355

54-
## Example using an account with a name
56+
## Example using an key pairs with an account name
5557

5658
We have already saved an existing account keys in a .pem file
5759
So first we need to import the account details public/private keys using it's encrypted data on file
5860

5961
```js
60-
importAccount = ConvexAccount.importFromFile('my-account.pem', 'secret')
61-
62+
importKeyPair = keyPair.importFromFile('my-account.pem', 'secret')
6263
```
6364

6465
Create a new account address for the first time, or if the account name has already been regisetered
6566
then load in the account address.
6667

6768
The returned account object will have the account address assigned to the account name `my-account`.
69+
6870
```js
69-
const account = await convex.setupAccount('my-account', importAccount)
71+
const account = await convex.setupAccount('my-account', importKeyPair)
7072
```
7173

7274
Later on you may need to re-load the same account address using only the registered name.
75+
7376
```js
74-
const sameAccount = await convex.loadAccount('my-account', importAccount)
77+
const sameAccount = await convex.loadAccount('my-account', importKeyPair)
7578
```
7679

7780
You can still use `setupAccount` this will just call `loadAccount` if the account name is registered with the registry.
81+
7882
```js
7983
// or the same as
80-
const sameAccount = await convex.setupAccount('my-account', importAccount)
84+
const sameAccount = await convex.setupAccount('my-account', importKeyPair)
8185
```
8286

8387

8488
If you just want to find out a name from the registry you can just do this:
89+
8590
```js
8691
const accountAddress = await convex.resolveAccountName('my-account')
87-
8892
```

0 commit comments

Comments
 (0)