-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 31-add-a-nextjs-example-project-with-wallet-…
…and-staking-integration
- Loading branch information
Showing
36 changed files
with
3,550 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Publish Packages | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18' | ||
cache: 'yarn' | ||
|
||
- name: Install dependencies | ||
run: yarn install | ||
|
||
- name: Configure npm | ||
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc | ||
|
||
- name: Build packages | ||
run: yarn build | ||
|
||
- name: Version bump and tag | ||
run: yarn publish | ||
|
||
- name: Publish packages | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
run: | | ||
packages=("packages/@autonomys/auto-utils") | ||
for package in "${packages[@]}"; do | ||
echo "Publishing $package" | ||
cd $package | ||
npm publish --access public | ||
cd ../.. | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"$schema": "node_modules/lerna/schemas/lerna-schema.json", | ||
"version": "0.1.3-alpha.1", | ||
"npmClient": "yarn" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,10 +8,11 @@ | |
"examples/*" | ||
], | ||
"scripts": { | ||
"build": "yarn workspaces foreach --all run build", | ||
"clean": "yarn workspaces foreach --all run clean", | ||
"format": "yarn workspaces foreach --all run format", | ||
"test": "yarn workspaces foreach --all run test" | ||
"build": "lerna run build", | ||
"clean": "lerna run clean", | ||
"format": "lerna run format", | ||
"test": "lerna run test", | ||
"publish": "lerna publish --no-private" | ||
}, | ||
"packageManager": "[email protected]", | ||
"engines": { | ||
|
@@ -29,6 +30,7 @@ | |
"@types/jest": "^29.5.12", | ||
"eslint": "^8.57.0", | ||
"jest": "^29.7.0", | ||
"lerna": "^8.1.5", | ||
"prettier": "^3.2.5", | ||
"ts-jest": "^29.1.4", | ||
"typescript": "^5.4.5" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,31 @@ | ||
# @autonomys/auto-consensus | ||
# Autonomys Auto Consensus SDK | ||
|
||
## Overview | ||
|
||
The Autonomys Auto Consensus SDK provides functionalities for blockchain consensus interactions, including address management, balance retrieval, staking, and transfers. | ||
|
||
## Address Management | ||
|
||
- `generateAddress(input: MnemonicOrURI): string`: Generates a new address. | ||
|
||
## Balances | ||
|
||
- `getBalance(address: string): Promise<Balance>`: Retrieves the balance of an address. | ||
|
||
## Staking | ||
|
||
- `stake(address: string, amount: number): Promise<void>`: Stakes an amount from an address. | ||
|
||
## Transfers | ||
|
||
- `transfer(from: string, to: string, amount: number): Promise<void>`: Transfers an amount from one address to another. | ||
|
||
## Info | ||
|
||
- `getInfo(): Promise<Info>`: Retrieves blockchain information. | ||
|
||
## Import Example | ||
|
||
```typescript | ||
import { generateAddress, getBalance, stake, transfer, getInfo } from '@autonomys/auto-consensus' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// file: src/address.ts | ||
|
||
import { encodeAddress } from '@polkadot/keyring' | ||
|
||
export const address = (address: string | Uint8Array): string => encodeAddress(address, 2254) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// file: src/index.ts | ||
|
||
export * from './address' | ||
export * from './balances' | ||
export * from './info' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
// file: src/types/index.ts | ||
|
||
export * from './events' | ||
export * from './transaction' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// file: src/types/transaction.ts | ||
|
||
import type { Events } from '../types/events' | ||
|
||
export type EventsValidated = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,56 @@ | ||
# @autonomys/auto-utils | ||
# Autonomys Auto SDK Utility | ||
|
||
## Overview | ||
|
||
The Autonomys Auto SDK Utility provides functionalities for wallet setup, network management, data storage, cryptographic operations, and API activation. | ||
|
||
## Wallet Management | ||
|
||
- `setupWallet(input: MnemonicOrURI): Promise<KeyringPair>`: Initializes a wallet using a mnemonic or URI. | ||
- `activateWallet(input: ActivateWalletInput): Promise<WalletActivated>`: Activates a wallet and returns API and accounts. | ||
- `mockWallets(network: NetworkInput | DomainInput): Promise<WalletActivated[]>`: Creates mock wallets for testing. | ||
- `getMockWallet(name: string, wallets: WalletActivated[]): WalletActivated`: Retrieves a mock wallet by name. | ||
|
||
## Network Management | ||
|
||
- `getNetworkDetails(input?: NetworkInput): Network`: Gets network details. | ||
- `getNetworkRpcUrls(input?: NetworkInput): string[]`: Gets network RPC URLs. | ||
- `getNetworkDomainDetails(input: DomainInput): Domain`: Gets domain details. | ||
- `getNetworkDomainRpcUrls(input: DomainInput): string[]`: Gets domain RPC URLs. | ||
|
||
## Data Storage | ||
|
||
- `save(key: string, value: any)`: Saves data to local storage or file system. | ||
- `read(key: string): any`: Reads data from local storage or file system. | ||
|
||
## Cryptographic Functions | ||
|
||
- `blake2b_256(data: Uint8Array): string`: Hashes data with BLAKE2b-256. | ||
- `stringToUint8Array(text: string): Uint8Array`: Converts a string to a Uint8Array. | ||
- `concatenateUint8Arrays(array1: Uint8Array, array2: Uint8Array): Uint8Array`: Concatenates two Uint8Arrays. | ||
|
||
## API Activation | ||
|
||
- `activate(input?: NetworkInput): Promise<ApiPromise>`: Activates the API for a network. | ||
- `activateDomain(input: DomainInput): Promise<ApiPromise>`: Activates the API for a domain. | ||
- `disconnect()`: Disconnects the API. | ||
- `disconnectDomain()`: Disconnects the domain API. | ||
|
||
## Constants | ||
|
||
- `networks`: Array of network configurations. | ||
- `defaultNetwork`: Default network configuration. | ||
- `mockURIs`: Array of mock URIs. | ||
|
||
## Types | ||
|
||
- `Network`, `Domain`, `Explorer`, `NetworkInput`, `DomainInput` | ||
- `Mnemonic`, `URI`, `AppName`, `MnemonicOrURI` | ||
|
||
For more details, refer to the source files in the `src` directory. | ||
|
||
## Import Example | ||
|
||
```typescript | ||
import { activateWallet } from '@autonomys/auto-utils' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// file: src/constants/index.ts | ||
|
||
export * from './network' | ||
export * from './token' | ||
export * from './wallet' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// file: src/constants/wallet.ts | ||
|
||
export const mockURIs = [ | ||
'//Alice', | ||
'//Bob', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// file: src/crypto.ts | ||
|
||
import { blake2AsHex } from '@polkadot/util-crypto' | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// file: src/index.ts | ||
|
||
export * from './api' | ||
export * from './crypto' | ||
export * from './network' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// file: src/types/network.ts | ||
|
||
export type Explorer = { | ||
name: string | ||
url: string | ||
|
Oops, something went wrong.