Skip to content

Commit

Permalink
fix: docs, introduce tsup
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotBraem committed Oct 20, 2024
1 parent ad373ac commit 709d004
Show file tree
Hide file tree
Showing 13 changed files with 2,741 additions and 1,305 deletions.
10 changes: 6 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,12 @@ dist
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
.pnp.*

### JetBrains template
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
<div align="center">

<h1 style="font-size: 2.5rem; font-weight: bold;">near-social-js</h1>
<p align="center">
<a href="https://npmjs.com/package/@builddao/near-social-js" target="_blank">
<img src="https://img.shields.io/npm/v/%40builddao%2Fnear-social-js?logo=npm" alt="npm" />
</a>
<a href="https://npmjs.com/package/@builddao/near-social-js" target="_blank">
<img src="https://img.shields.io/npm/dw/%40builddao%2Fnear-social-js?logo=npm&label=weekly%20downloads" alt="weekly npm downloads" />
</a>
</p>

<p>
<strong>Typescript SDK for interacting with the social contract (social.near)</strong>
Expand Down
63 changes: 11 additions & 52 deletions docs/advanced/fetching-indexed-data.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,58 +46,17 @@ A promise that resolves to an array of matched indexed values, ordered by blockH

### Basic Usage

<Tabs
defaultValue="javascript-via-package-manager"
values={[
{ label: 'JavaScript (via package manager)', value: 'javascript-via-package-manager' },
{ label: 'JavaScript (via CDN)', value: 'javascript-via-cdn' },
{ label: 'TypeScript', value: 'typescript' },
]}>
<TabItem value="javascript-via-package-manager">

```js
const { Social } = require('@builddao/near-social-js');

const social = new Social();
const result = await social.index({
action: 'like',
key: 'post-123',
});

console.log(result);
```

</TabItem>
<TabItem value="javascript-via-cdn">

```js
var social = new NEARSocialSDK();

social.index({
action: 'like',
key: 'post-123',
}).then((result) => {
console.log(result);
});
```

</TabItem>
<TabItem value="typescript">

```typescript
import { Social } from '@builddao/near-social-js';

const social = new Social();
const result = await social.index({
action: 'like',
key: 'post-123',
});

console.log(result);
```

</TabItem>
</Tabs>
```typescript
import { Social } from '@builddao/near-social-js';

const social = new Social();
const result = await social.index({
action: 'like',
key: 'post-123',
});

console.log(result);
```

### Advanced Usage

Expand Down
95 changes: 19 additions & 76 deletions docs/advanced/granting-write-permission.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,82 +20,25 @@ Accounts can grant write permission to other accounts for a set of keys.

## Granting an account write permission

<Tabs
defaultValue="javascript-via-package-manager"
values={[
{ label: 'JavaScript (via package manager)', value: 'javascript-via-package-manager' },
{ label: 'JavaScript (via CDN)', value: 'javascript-via-cdn' },
{ label: 'TypeScript', value: 'typescript' },
]}>
<TabItem value="javascript-via-package-manager">

```js
const { Social } = require('@builddao/near-social-js');

const social = new Social();
const transaction = await social.grantWritePermission({
account: {
accountID: 'bob.near',
publicKey: 'ed25519:H9k5eiU4xXS3M4z8HzKJSLaZdqGdGwBG49o7orNC4eZW',
},
granteeAccountId: 'alice.near',
keys: [
'alice.near/profile/name',
'alice.near/profile/image/url',
],
});

// ...sign the returned transaction and post to the network
*/
```

</TabItem>
<TabItem value="javascript-via-cdn">

```js
var social = new NEARSocialSDK();

social.grantWritePermission({
account: {
accountID: 'bob.near',
publicKey: 'ed25519:H9k5eiU4xXS3M4z8HzKJSLaZdqGdGwBG49o7orNC4eZW',
},
granteeAccountId: 'alice.near',
keys: [
'alice.near/profile/name',
'alice.near/profile/image/url'
]
})
.then((transaction) => {
// ...sign the returned transaction and post to the network
});
```

</TabItem>
<TabItem value="typescript">

```typescript
import { Social } from '@builddao/near-social-js';

const social = new Social();
const transaction = await social.grantWritePermission({
account: {
accountID: 'bob.near',
publicKey: 'ed25519:H9k5eiU4xXS3M4z8HzKJSLaZdqGdGwBG49o7orNC4eZW',
},
granteeAccountId: 'alice.near',
keys: [
'alice.near/profile/name',
'alice.near/profile/image/url',
],
});

// ...sign the returned transaction and post to the network
*/
```

</TabItem>
</Tabs>
```typescript
import { Social } from '@builddao/near-social-js';

const social = new Social();
const transaction = await social.grantWritePermission({
account: {
accountID: 'bob.near',
publicKey: 'ed25519:H9k5eiU4xXS3M4z8HzKJSLaZdqGdGwBG49o7orNC4eZW',
},
granteeAccountId: 'alice.near',
keys: [
'alice.near/profile/name',
'alice.near/profile/image/url',
],
});

// ...sign the returned transaction and post to the network
*/
```

:::caution

Expand Down
Loading

0 comments on commit 709d004

Please sign in to comment.