Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CU-86dt0ndwq - Improvements on NeonDappkit docs #34

Merged
merged 2 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 26 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ React-Native Apps to the Neo3 Blockchain.

> [WalletConnectSDK](https://github.com/CityOfZion/wallet-connect-sdk) uses Neon-DappKit Types, so you can easily swap
between Neon-DappKit implementation and WalletConnectSDK on the fly and reuse code, check the
[guide](/packages/neon-dappkit/WALLET-CONNECT.md).
[guide](https://github.com/CityOfZion/neon-dappkit/blob/main/packages/neon-dappkit/WALLET-CONNECT.md).

## Installation
```sh
Expand All @@ -41,31 +41,44 @@ export default defineConfig({
## Getting Started

Neon-Dappkit has 4 main components:
- [NeonInvoker](/packages/neon-dappkit/NEON-INVOKER.md): SmartContract Invocation Tool.
- [NeonParser](/packages/neon-dappkit/NEON-PARSER.md): Powerful Parser for Neo3 Types.
- [NeonSigner](/packages/neon-dappkit/NEON-SIGNER.md): Signs, Verifies, Encrypts and Decrypts data.
- [NeonEventListener](/packages/neon-dappkit/NEON-EVENT-LISTENER.md): Listen to events from the Neo3 Blockchain.
- [NeonInvoker](https://github.com/CityOfZion/neon-dappkit/blob/main/packages/neon-dappkit/NEON-INVOKER.md): SmartContract Invocation Tool.
- [NeonParser](https://github.com/CityOfZion/neon-dappkit/blob/main/packages/neon-dappkit/NEON-PARSER.md): Powerful Parser for Neo3 Types.
- [NeonSigner](https://github.com/CityOfZion/neon-dappkit/blob/main/packages/neon-dappkit/NEON-SIGNER.md): Signs, Verifies, Encrypts and Decrypts data.
- [NeonEventListener](https://github.com/CityOfZion/neon-dappkit/blob/main/packages/neon-dappkit/NEON-EVENT-LISTENER.md): Listen to events from the Neo3 Blockchain.

Check out some examples in [examples folder](https://github.com/CityOfZion/neon-dappkit/blob/main/packages/neon-dappkit/)
melanke marked this conversation as resolved.
Show resolved Hide resolved


## Quick Example

```ts
import { NeonInvoker, NeonParser } from "@CityOfZion/neon-dappkit";
import { NeonInvoker, NeonParser, TypeChecker } from '@CityOfZion/neon-dappkit'
import {ContractInvocationMulti} from '@cityofzion/neon-dappkit-types'

const invoker = await NeonInvoker.init({
rpcAddress: NeonInvoker.TESTNET,
})

const rawResp = await invoker.testInvoke({
const invocation: ContractInvocationMulti = {
invocations: [
{
scriptHash: '0x123456',
operation: 'myMethod',
args: [123, 'Test'].map(NeonParser.formatRpcArgument)
},
scriptHash: '0x309b6b2e0538fe4095ecc48e81bb4735388432b5',
operation: 'getMetaData',
args: [
{
type: 'Hash160',
value: '0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5'
}
]
}
],
})
}

const testInvokeResult = await invoker.testInvoke(invocation)

const resp = NeonParser.parseRpcResponse(rawResp.stack[0])
console.log(`Invocation state returned: ${testInvokeResult.state}`)
console.log(`Estimated GAS consumed on involke: ${testInvokeResult.gasconsumed} GAS`) // Using testInvoke ensures zero GAS consumption, unlike invokeFunction.
console.log(`Contract method returned a map: ${TypeChecker.isStackTypeMap(testInvokeResult.stack[0])}`)
console.log(`Contract method data returned: ${JSON.stringify(NeonParser.parseRpcResponse(testInvokeResult.stack[0]), null, 2)}`)
```

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Improvements on NeonDappkit docs",
"type": "none",
"packageName": "@cityofzion/neon-dappkit-types"
}
],
"packageName": "@cityofzion/neon-dappkit-types",
"email": "[email protected]"
}
11 changes: 11 additions & 0 deletions common/changes/@cityofzion/neon-dappkit/main_2024-04-16-16-14.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Improvements on NeonDappkit docs",
"type": "none",
"packageName": "@cityofzion/neon-dappkit"
}
],
"packageName": "@cityofzion/neon-dappkit",
"email": "[email protected]"
}
41 changes: 27 additions & 14 deletions packages/neon-dappkit-types/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# Neon-DappKit

Neon-DappKit is the easiest way to build a dApp on Neo3. Suitable to connect Web Applications, Off-chain JS Servers and
Neon-DappKit is the easiest way to build a dApp on Neo3. Suitable to connect Web Applications, Off-chain JS Servers and
React-Native Apps to the Neo3 Blockchain.

> [WalletConnectSDK](https://github.com/CityOfZion/wallet-connect-sdk) uses Neon-DappKit Types, so you can easily swap
Expand All @@ -20,7 +20,7 @@ between Neon-DappKit implementation and WalletConnectSDK on the fly and reuse co

## Installation
```sh
npm i @CityOfZion/neon-dappkit
npm i @cityofzion/neon-dappkit-types
```

<details>
Expand All @@ -41,31 +41,44 @@ export default defineConfig({
## Getting Started

Neon-Dappkit has 4 main components:
- [NeonInvoker](/packages/neon-dappkit/NEON-INVOKER.md): SmartContract Invocation Tool.
- [NeonParser](/packages/neon-dappkit/NEON-PARSER.md): Powerful Parser for Neo3 Types.
- [NeonSigner](/packages/neon-dappkit/NEON-SIGNER.md): Signs, Verifies, Encrypts and Decrypts data.
- [NeonEventListener](/packages/neon-dappkit/NEON-EVENT-LISTENER.md): Listen to events from the Neo3 Blockchain.
- [NeonInvoker](https://github.com/CityOfZion/neon-dappkit/blob/main/packages/neon-dappkit/NEON-INVOKER.md): SmartContract Invocation Tool.
- [NeonParser](https://github.com/CityOfZion/neon-dappkit/blob/main/packages/neon-dappkit/NEON-PARSER.md): Powerful Parser for Neo3 Types.
- [NeonSigner](https://github.com/CityOfZion/neon-dappkit/blob/main/packages/neon-dappkit/NEON-SIGNER.md): Signs, Verifies, Encrypts and Decrypts data.
- [NeonEventListener](https://github.com/CityOfZion/neon-dappkit/blob/main/packages/neon-dappkit/NEON-EVENT-LISTENER.md): Listen to events from the Neo3 Blockchain.

Check out some examples in [examples folder](https://github.com/CityOfZion/neon-dappkit/blob/main/packages/neon-dappkit/)
melanke marked this conversation as resolved.
Show resolved Hide resolved


## Quick Example

```ts
import { NeonInvoker, NeonParser } from "@CityOfZion/neon-dappkit";
import { NeonInvoker, NeonParser, TypeChecker } from '@CityOfZion/neon-dappkit'
import {ContractInvocationMulti} from '@cityofzion/neon-dappkit-types'

const invoker = await NeonInvoker.init({
rpcAddress: NeonInvoker.TESTNET,
})

const rawResp = await invoker.testInvoke({
const invocation: ContractInvocationMulti = {
invocations: [
{
scriptHash: '0x123456',
operation: 'myMethod',
args: [123, 'Test'].map(NeonParser.formatRpcArgument)
},
scriptHash: '0x309b6b2e0538fe4095ecc48e81bb4735388432b5',
operation: 'getMetaData',
args: [
{
type: 'Hash160',
value: '0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5'
}
]
}
],
})
}

const testInvokeResult = await invoker.testInvoke(invocation)

const resp = NeonParser.parseRpcResponse(rawResp.stack[0])
console.log(`Invocation state returned: ${testInvokeResult.state}`)
console.log(`Estimated GAS consumed on involke: ${testInvokeResult.gasconsumed} GAS`) // Using testInvoke ensures zero GAS consumption, unlike invokeFunction.
console.log(`Dapp method returned a map: ${TypeChecker.isStackTypeMap(testInvokeResult.stack[0])}`)
console.log(`Dapp method data returned: ${JSON.stringify(NeonParser.parseRpcResponse(testInvokeResult.stack[0]), null, 2)}`)
```

2 changes: 1 addition & 1 deletion packages/neon-dappkit/NEON-EVENT-LISTENER.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ eventListener.confirmTransaction(

For more details on the methods signature, check the auto-generated
[Docs](https://htmlpreview.github.io/?https://raw.githubusercontent.com/CityOfZion/neon-dappkit/master/packages/neon-dappkit-types/docs/interfaces/Neo3EventListener.html)
and the [Source Code](./src/NeonEventListener.ts).
and the [Source Code](https://github.com/CityOfZion/neon-dappkit/blob/main/packages/neon-dappkit/src/NeonEventListener.ts).
6 changes: 3 additions & 3 deletions packages/neon-dappkit/NEON-INVOKER.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ To persist changes to the blockchain or sign the transactions you should pass an
`Account` from `@cityofzion/neon-js`. Check the example:
```ts
import { NeonInvoker } from '@cityofzion/neon-dappkit'
import { default as Neon } from '@cityofzion/neon-js'
import * as Neon from '@cityofzion/neon-js'

const account = new Neon.wallet.account('3bd06d95e9189385851aa581d182f25de34af759cf7f883af57030303ded52b8')
const account = new Neon.wallet.Account('3bd06d95e9189385851aa581d182f25de34af759cf7f883af57030303ded52b8')

const invoker = await NeonInvoker.init({
rpcAddress: NeonInvoker.MAINNET,
Expand Down Expand Up @@ -254,4 +254,4 @@ const txId = await invokerOwner.invokeFunction(builtTransaction)

For more details on the methods signature, check the auto-generated
[Docs](https://htmlpreview.github.io/?https://raw.githubusercontent.com/CityOfZion/neon-dappkit/master/packages/neon-dappkit-types/docs/interfaces/Neo3Invoker.html),
the [Unit Tests](./src/NeonInvoker.spec.ts) and the [Source Code](./src/NeonInvoker.ts).
the [Unit Tests](https://github.com/CityOfZion/neon-dappkit/blob/main/packages/neon-dappkit/src/NeonInvoker.spec.ts) and the [Source Code](https://github.com/CityOfZion/neon-dappkit/blob/main/packages/neon-dappkit/src/NeonInvoker.ts).
2 changes: 1 addition & 1 deletion packages/neon-dappkit/NEON-SIGNER.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ is the correct one.

For more details on the methods signature, check the auto-generated
[Docs](https://htmlpreview.github.io/?https://raw.githubusercontent.com/CityOfZion/neon-dappkit/master/packages/neon-dappkit-types/docs/interfaces/Neo3Signer.html),
the [Unit Tests](./src/NeonSigner.spec.ts) and the [Source Code](./src/NeonSigner.ts).
the [Unit Tests](https://github.com/CityOfZion/neon-dappkit/blob/main/packages/neon-dappkit/src/NeonSigner.spec.ts) and the [Source Code](https://github.com/CityOfZion/neon-dappkit/blob/main/packages/neon-dappkit/src/NeonSigner.ts).
41 changes: 25 additions & 16 deletions packages/neon-dappkit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@

# Neon-DappKit

Neon-DappKit is the easiest way to build a dApp on Neo3. Suitable to connect Web Applications, Off-chain JS Servers and
Neon-DappKit is the easiest way to build a dApp on Neo3. Suitable to connect Web Applications, Off-chain JS Servers and
React-Native Apps to the Neo3 Blockchain.

> [WalletConnectSDK](https://github.com/CityOfZion/wallet-connect-sdk) uses Neon-DappKit Types, so you can easily swap
between Neon-DappKit implementation and WalletConnectSDK on the fly and reuse code, check the
[guide](/packages/neon-dappkit/WALLET-CONNECT.md).
[guide](https://github.com/CityOfZion/neon-dappkit/blob/main/packages/neon-dappkit/WALLET-CONNECT.md).

## Installation
```sh
npm i @CityOfZion/neon-dappkit
npm i @cityofzion/neon-dappkit
```

<details>
Expand All @@ -41,31 +41,40 @@ export default defineConfig({
## Getting Started

Neon-Dappkit has 4 main components:
- [NeonInvoker](/packages/neon-dappkit/NEON-INVOKER.md): SmartContract Invocation Tool.
- [NeonParser](/packages/neon-dappkit/NEON-PARSER.md): Powerful Parser for Neo3 Types.
- [NeonSigner](/packages/neon-dappkit/NEON-SIGNER.md): Signs, Verifies, Encrypts and Decrypts data.
- [NeonEventListener](/packages/neon-dappkit/NEON-EVENT-LISTENER.md): Listen to events from the Neo3 Blockchain.
- [NeonInvoker](https://github.com/CityOfZion/neon-dappkit/blob/main/packages/neon-dappkit/NEON-INVOKER.md): SmartContract Invocation Tool.
- [NeonParser](https://github.com/CityOfZion/neon-dappkit/blob/main/packages/neon-dappkit/NEON-PARSER.md): Powerful Parser for Neo3 Types.
- [NeonSigner](https://github.com/CityOfZion/neon-dappkit/blob/main/packages/neon-dappkit/NEON-SIGNER.md): Signs, Verifies, Encrypts and Decrypts data.
- [NeonEventListener](https://github.com/CityOfZion/neon-dappkit/blob/main/packages/neon-dappkit/NEON-EVENT-LISTENER.md): Listen to events from the Neo3 Blockchain.

Check out some examples in [examples folder](https://github.com/CityOfZion/neon-dappkit/packages/neon-dappkit/)
melanke marked this conversation as resolved.
Show resolved Hide resolved


## Quick Example

```ts
import { NeonInvoker, NeonParser } from "@CityOfZion/neon-dappkit";
import { NeonInvoker, NeonParser, TypeChecker } from '@CityOfZion/neon-dappkit'

const invoker = await NeonInvoker.init({
rpcAddress: NeonInvoker.TESTNET,
})

const rawResp = await invoker.testInvoke({
const testInvokeResult = await invoker.testInvoke({
invocations: [
{
scriptHash: '0x123456',
operation: 'myMethod',
args: [123, 'Test'].map(NeonParser.formatRpcArgument)
},
scriptHash: '0x309b6b2e0538fe4095ecc48e81bb4735388432b5',
operation: 'getMetaData',
args: [
{
type: 'Hash160',
value: '0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5'
}
]
}
],
})

const resp = NeonParser.parseRpcResponse(rawResp.stack[0])
```

console.log(`Invocation state returned: ${testInvokeResult.state}`)
console.log(`Estimated GAS consumed on involke: ${testInvokeResult.gasconsumed} GAS`) // Using testInvoke ensures zero GAS consumption, unlike invokeFunction.
console.log(`Dapp method returned a map: ${TypeChecker.isStackTypeMap(testInvokeResult.stack[0])}`)
console.log(`Dapp method data returned: ${JSON.stringify(NeonParser.parseRpcResponse(testInvokeResult.stack[0]), null, 2)}`)
```
Loading