Skip to content

Commit 741193b

Browse files
authored
feat: converts to ESM package (#52)
* fix: revamp readme * fix: commitlint .mjs * fix: docs, introduce tsup * fix: remove buffer dependency * chore: increment version * fix: bundle dependencies
1 parent 3e64f59 commit 741193b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+6255
-5720
lines changed

.gitignore

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,12 @@ dist
189189
.vscode-test
190190

191191
# yarn v2
192-
.yarn/cache
193-
.yarn/unplugged
194-
.yarn/build-state.yml
195-
.yarn/install-state.gz
192+
.yarn/*
193+
!.yarn/patches
194+
!.yarn/plugins
195+
!.yarn/releases
196+
!.yarn/sdks
197+
!.yarn/versions
196198
.pnp.*
197199

198200
### JetBrains template
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
module.exports = {
1+
export default {
22
'**/*.{js,json,ts}': (filenames) => `prettier --write ${filenames.join(' ')}`,
33
};

README.md

Lines changed: 61 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,11 @@
1-
<h1 align="center">
2-
NEAR Social SDK
3-
</h1>
1+
<!-- markdownlint-disable MD014 -->
2+
<!-- markdownlint-disable MD033 -->
3+
<!-- markdownlint-disable MD041 -->
4+
<!-- markdownlint-disable MD029 -->
45

5-
<p align="center">
6-
<a href="https://github.com/NEARBuilders/near-social-js/releases/latest">
7-
<img alt="GitHub Release" src="https://img.shields.io/github/v/release/NEARBuilders/near-social-js?&logo=github">
8-
</a>
9-
<a href="https://github.com/NEARBuilders/near-social-js/releases/latest">
10-
<img alt="GitHub Release Date - Published At" src="https://img.shields.io/github/release-date/NEARBuilders/near-social-js?logo=github">
11-
</a>
12-
</p>
13-
14-
<p align="center">
15-
<a href="https://github.com/NEARBuilders/near-social-js/releases">
16-
<img alt="GitHub Pre-release" src="https://img.shields.io/github/v/release/NEARBuilders/near-social-js?include_prereleases&label=pre-release&logo=github">
17-
</a>
18-
<a href="https://github.com/NEARBuilders/near-social-js/releases">
19-
<img alt="GitHub Pre-release Date - Published At" src="https://img.shields.io/github/release-date-pre/NEARBuilders/near-social-js?label=pre-release%20date&logo=github">
20-
</a>
21-
</p>
22-
23-
<p align="center">
24-
<a href="https://github.com/NEARBuilders/near-social-js/blob/main/LICENSE">
25-
<img alt="GitHub License" src="https://img.shields.io/github/license/NEARBuilders/near-social-js">
26-
</a>
27-
</p>
6+
<div align="center">
287

8+
<h1 style="font-size: 2.5rem; font-weight: bold;">near-social-js</h1>
299
<p align="center">
3010
<a href="https://npmjs.com/package/@builddao/near-social-js" target="_blank">
3111
<img src="https://img.shields.io/npm/v/%40builddao%2Fnear-social-js?logo=npm" alt="npm" />
@@ -35,68 +15,65 @@
3515
</a>
3616
</p>
3717

38-
<p align="center">
39-
A JavaScript SDK for interacting with the social contract (social.near) with helper functions for typical social features.
40-
</p>
41-
42-
### Table of contents
43-
44-
* [1. Overview](#-1-overview)
45-
* [2. Documentation](#-2-documentation)
46-
* [3. Development](#-3-development)
47-
* [3.1. Requirements](#31-requirements)
48-
* [3.2. Setup](#32-setup)
49-
* [3.3. Build](#33-build)
50-
* [4. Appendix](#-4-appendix)
51-
* [4.1. Useful Commands](#41-useful-commands)
52-
* [4.2. Social Contract](#42-social-contract)
53-
* [5. How To Contribute](#-5-how-to-contribute)
54-
* [6. License](#-6-license)
18+
<p>
19+
<strong>Typescript SDK for interacting with the social contract (social.near)</strong>
20+
</p>
5521

56-
## 🔭 1. Overview
22+
</div>
5723

58-
TBC...
24+
<details>
25+
<summary>Table of Contents</summary>
5926

60-
<sup>[Back to top ^][table-of-contents]</sup>
27+
- [Getting Started](#getting-started)
28+
- [Installing dependencies](#installing-dependencies)
29+
- [Running the app](#running-the-app)
30+
- [Building for production](#building-for-production)
31+
- [Running tests](#running-tests)
32+
- [Contributing](#contributing)
6133

62-
## 📚 2. Documentation
34+
</details>
6335

64-
For full documentation, please see [here][documentation].
36+
## Getting Started
6537

66-
<sup>[Back to top ^][table-of-contents]</sup>
38+
### Installing dependencies
6739

68-
## 🛠 3. Development
40+
```bash
41+
yarn install
42+
```
6943

70-
### 3.1. Requirements
44+
### Running the app
7145

72-
* Install [Node v18.20.2+][node]
73-
* Install [Yarn v1.22.5+][yarn]
46+
First, run the development server:
7447

75-
<sup>[Back to top ^][table-of-contents]</sup>
48+
```bash
49+
yarn run dev
50+
```
7651

77-
### 3.2. Setup
52+
### Building for production
7853

79-
1. Install the dependencies:
8054
```bash
81-
$ yarn install
55+
yarn run build
8256
```
8357

84-
<sup>[Back to top ^][table-of-contents]</sup>
58+
### Running tests
8559

86-
### 3.3. Build
87-
88-
* To build simply run:
8960
```bash
90-
$ yarn build
61+
yarn run test
9162
```
9263

93-
The above command will compile the Typescript source code into a `dist/` directory.
64+
See the full [testing guide](./playwright-tests/README.md).
9465

95-
<sup>[Back to top ^][table-of-contents]</sup>
66+
## Appendix
9667

97-
## 📑 4. Appendix
68+
### Social Contract
69+
70+
| Network | Account ID | Link |
71+
|---------|-----------------------|------------------------------------------------------------------------------------------------------------------------|
72+
| Mainnet | `social.near` | [https://nearblocks.io/address/social.near](https://nearblocks.io/address/social.near) |
73+
| Testnet | `v1.social08.testnet` | [https://testnet.nearblocks.io/address/v1.social08.testnet](https://testnet.nearblocks.io/address/v1.social08.testnet) |
9874

99-
### 4.1. Useful Commands
75+
76+
### Useful Commands
10077

10178
| Command | Description |
10279
|-------------------|------------------------------------------------------------------------------------|
@@ -107,36 +84,30 @@ The above command will compile the Typescript source code into a `dist/` directo
10784
| `yarn lint` | Runs the linter on `.js` and `.ts` files. |
10885
| `yarn node:start` | Starts up a NEAR development node in a background process. |
10986
| `yarn node:start` | Stops the NEAR development node that was started in `yarn node:start`. |
110-
| `yarn prettier` | Runs the prettier on `.js` and `.ts` files. |
87+
| `yarn fmt` | Runs prettier on `.js` and `.ts` files. |
11188
| `yarn test` | Starts a NEAR development node and runs the tests. |
11289

113-
<sup>[Back to top ^][table-of-contents]</sup>
114-
115-
### 4.2. Social Contract
116-
117-
| Network | Account ID | Link |
118-
|---------|-----------------------|------------------------------------------------------------------------------------------------------------------------|
119-
| Mainnet | `social.near` | [https://nearblocks.io/address/social.near](https://nearblocks.io/address/social.near) |
120-
| Testnet | `v1.social08.testnet` | [https://testnet.nearblocks.io/address/v1.social08.testnet](https://testnet.nearblocks.io/address/v1.social08.testnet) |
121-
122-
<sup>[Back to top ^][table-of-contents]</sup>
123-
124-
## 👏 5. How To Contribute
125-
126-
Please read the [**Contributing Guide**][contribute] to learn about the development process.
127-
128-
<sup>[Back to top ^][table-of-contents]</sup>
129-
130-
## 📄 6. License
131-
132-
Please refer to the [LICENSE][license] file.
133-
134-
<sup>[Back to top ^][table-of-contents]</sup>
135-
13690
<!-- Links -->
13791
[contribute]: ./CONTRIBUTING.md
13892
[documentation]: https://nearbuilders.github.io/near-social-js
13993
[license]: ./LICENSE
14094
[node]: https://nodejs.org/en/
14195
[table-of-contents]: #table-of-contents
14296
[yarn]: https://yarnpkg.com/
97+
98+
99+
## Contributing
100+
101+
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
102+
103+
If you're interested in contributing to this project, please read the [contribution guide](./CONTRIBUTING).
104+
105+
<div align="right">
106+
<a href="https://nearbuilders.org" target="_blank">
107+
<img
108+
src="https://builders.mypinata.cloud/ipfs/QmWt1Nm47rypXFEamgeuadkvZendaUvAkcgJ3vtYf1rBFj"
109+
alt="Near Builders"
110+
height="40"
111+
/>
112+
</a>
113+
</div>

commitlint.config.js renamed to commitlint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
export default {
22
extends: ['@commitlint/config-conventional'],
33
rules: {
44
'type-enum': [

docs/advanced/fetching-indexed-data.mdx

Lines changed: 11 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -46,58 +46,17 @@ A promise that resolves to an array of matched indexed values, ordered by blockH
4646

4747
### Basic Usage
4848

49-
<Tabs
50-
defaultValue="javascript-via-package-manager"
51-
values={[
52-
{ label: 'JavaScript (via package manager)', value: 'javascript-via-package-manager' },
53-
{ label: 'JavaScript (via CDN)', value: 'javascript-via-cdn' },
54-
{ label: 'TypeScript', value: 'typescript' },
55-
]}>
56-
<TabItem value="javascript-via-package-manager">
57-
58-
```js
59-
const { Social } = require('@builddao/near-social-js');
60-
61-
const social = new Social();
62-
const result = await social.index({
63-
action: 'like',
64-
key: 'post-123',
65-
});
66-
67-
console.log(result);
68-
```
69-
70-
</TabItem>
71-
<TabItem value="javascript-via-cdn">
72-
73-
```js
74-
var social = new NEARSocialSDK();
75-
76-
social.index({
77-
action: 'like',
78-
key: 'post-123',
79-
}).then((result) => {
80-
console.log(result);
81-
});
82-
```
83-
84-
</TabItem>
85-
<TabItem value="typescript">
86-
87-
```typescript
88-
import { Social } from '@builddao/near-social-js';
89-
90-
const social = new Social();
91-
const result = await social.index({
92-
action: 'like',
93-
key: 'post-123',
94-
});
95-
96-
console.log(result);
97-
```
98-
99-
</TabItem>
100-
</Tabs>
49+
```typescript
50+
import { Social } from '@builddao/near-social-js';
51+
52+
const social = new Social();
53+
const result = await social.index({
54+
action: 'like',
55+
key: 'post-123',
56+
});
57+
58+
console.log(result);
59+
```
10160

10261
### Advanced Usage
10362

docs/advanced/granting-write-permission.mdx

Lines changed: 19 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -20,82 +20,25 @@ Accounts can grant write permission to other accounts for a set of keys.
2020

2121
## Granting an account write permission
2222

23-
<Tabs
24-
defaultValue="javascript-via-package-manager"
25-
values={[
26-
{ label: 'JavaScript (via package manager)', value: 'javascript-via-package-manager' },
27-
{ label: 'JavaScript (via CDN)', value: 'javascript-via-cdn' },
28-
{ label: 'TypeScript', value: 'typescript' },
29-
]}>
30-
<TabItem value="javascript-via-package-manager">
31-
32-
```js
33-
const { Social } = require('@builddao/near-social-js');
34-
35-
const social = new Social();
36-
const transaction = await social.grantWritePermission({
37-
account: {
38-
accountID: 'bob.near',
39-
publicKey: 'ed25519:H9k5eiU4xXS3M4z8HzKJSLaZdqGdGwBG49o7orNC4eZW',
40-
},
41-
granteeAccountId: 'alice.near',
42-
keys: [
43-
'alice.near/profile/name',
44-
'alice.near/profile/image/url',
45-
],
46-
});
47-
48-
// ...sign the returned transaction and post to the network
49-
*/
50-
```
51-
52-
</TabItem>
53-
<TabItem value="javascript-via-cdn">
54-
55-
```js
56-
var social = new NEARSocialSDK();
57-
58-
social.grantWritePermission({
59-
account: {
60-
accountID: 'bob.near',
61-
publicKey: 'ed25519:H9k5eiU4xXS3M4z8HzKJSLaZdqGdGwBG49o7orNC4eZW',
62-
},
63-
granteeAccountId: 'alice.near',
64-
keys: [
65-
'alice.near/profile/name',
66-
'alice.near/profile/image/url'
67-
]
68-
})
69-
.then((transaction) => {
70-
// ...sign the returned transaction and post to the network
71-
});
72-
```
73-
74-
</TabItem>
75-
<TabItem value="typescript">
76-
77-
```typescript
78-
import { Social } from '@builddao/near-social-js';
79-
80-
const social = new Social();
81-
const transaction = await social.grantWritePermission({
82-
account: {
83-
accountID: 'bob.near',
84-
publicKey: 'ed25519:H9k5eiU4xXS3M4z8HzKJSLaZdqGdGwBG49o7orNC4eZW',
85-
},
86-
granteeAccountId: 'alice.near',
87-
keys: [
88-
'alice.near/profile/name',
89-
'alice.near/profile/image/url',
90-
],
91-
});
92-
93-
// ...sign the returned transaction and post to the network
94-
*/
95-
```
96-
97-
</TabItem>
98-
</Tabs>
23+
```typescript
24+
import { Social } from '@builddao/near-social-js';
25+
26+
const social = new Social();
27+
const transaction = await social.grantWritePermission({
28+
account: {
29+
accountID: 'bob.near',
30+
publicKey: 'ed25519:H9k5eiU4xXS3M4z8HzKJSLaZdqGdGwBG49o7orNC4eZW',
31+
},
32+
granteeAccountId: 'alice.near',
33+
keys: [
34+
'alice.near/profile/name',
35+
'alice.near/profile/image/url',
36+
],
37+
});
38+
39+
// ...sign the returned transaction and post to the network
40+
*/
41+
```
9942

10043
:::caution
10144

0 commit comments

Comments
 (0)