Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,5 @@ out

# The root directory used for retrieving and building the Supra Aptos TypeScript SDK. See GitHub issue 4.
.supra_aptos_sdk/
dist
dist
temp
9 changes: 9 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.tsbuildinfo
*.test.ts
**/*.test.ts
*.log
node_modules
dist
test/
node_modules
temp
189 changes: 166 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,182 @@
# Typescript SDK for Supra
# Supra TypeScript SDK

The `supra-l1-sdk` provides a convenient way to interact with the supra chain and perform operations on supra chain. It offers a set of utility functions, classes, and types to simplify the integration process and enhance developer productivity.
Welcome to the **Supra TypeScript SDK**! This SDK offers a streamlined and efficient way to interact with the Supra blockchain, enabling developers to perform a wide range of operations seamlessly. Designed with a clean interface and comprehensive functionalities, the Supra SDK enhances developer productivity and simplifies the integration process.

**Note:** This project is an **overhaul and cleanup by the team NLJinchuriki**, ensuring improved structure, clarity, maintainability and ease of use for developers.

## Table of Contents

- [Installation](#installation)
- [Getting Started](#getting-started)
- [Features](#features)
- [Documentation](#documentation)
- [Contributing](#contributing)
- [Credits](#credits)
- [License](#license)

## Installation

Install supra-l1-sdk with npm
Install the Supra TypeScript SDK via npm:

```bash
npm install supra-l1-sdk
```

or

```bash
npm install supra-l1-sdk
yarn add supra-l1-sdk
```

## Reference Docs
or

```bash
pnpm install supra-l1-sdk
```

## Getting Started

Here's a quick example to help you get started with the Supra SDK:

```typescript
import { SupraClient } from 'supra-l1-sdk'

For SDK documentation, check out the [TypeScript SDK documentation](https://sdk-docs.supra.com/index.html)
// Initialize the client
const client = await SupraClient.init({
url: 'https://rpc.supra.com',
chainId: 1 // Optional: defaults to the RPC node's chain ID
})

// To Create Instance Of Supra Client.
// Note: Here We Need To Pass ChainId, Default ChainId Value Is 3
let supraClient = new SupraClient({
url: 'https://rpc-wallet.supra.com/',
chainId: 3
})

// To Create Instance Of Supra Client, But In This Method We Don't Need To Pass ChainId.
// ChainId Will Be Identified At Instance Creation Time By Making RPC Call.
let supraClient = await SupraClient.init({
url: 'https://rpc-testnet.supra.com/'
})

// Check if an account exists
const accountExists = await client.accountExists('0xYourAccountAddress')
console.log(`Account exists: ${accountExists}`)

// Transfer SupraCoin
const transactionResponse = await client.transferSupraCoin(
senderAccount,
'0xReceiverAddress',
BigInt(1000)
)
console.log(`Transaction Hash: ${transactionResponse.txHash}`)
```

### Using the Built-in Logger

The Supra SDK includes a built-in **Logger** to help you manage and monitor SDK activities with different log levels. Here's how you can set it up:

```typescript
import { Logger } from 'supra-l1-sdk'

// LogTransport for extensive logging
const logTransport = (log) => {
console.log(
`[${new Date(log.timestamp).toISOString()}] ${log.level}: ${log.message}`
)
if (log.data) {
console.log('Data:', JSON.stringify(log.data, null, 2))
}
}

// Creating logger with logTransport
// Set to 'DEBUG' for verbose logging output from the SDK
const logger = new Logger('INFO', logTransport)

// Initialize Supra Client with Logger
let supraClient = await SupraClient.init({
url: 'https://rpc-testnet.supra.com/',
logger
})
```

## Usage
The **Logger** supports various log levels (`DEBUG`, `INFO`, `WARN`, `ERROR`) and allows you to define custom transport functions to handle log messages as needed.

Check [./src/example.ts](https://github.com/Entropy-Foundation/supra-l1-sdk/blob/master/src/example.ts) for understating about the usage.
## Features

## Functionalities
The Supra TypeScript SDK provides a robust set of features to interact with the Supra blockchain:

- [x] Significant `rpc_node` endpoint integration
- [x] Transaction insights
- [x] Transfer coin
- [x] Publish Package
- [X] `entry_function_payload` type tx
- [X] Transaction payload generation
- [X] Transaction simulation
- [X] Transaction signing
- [X] Transaction hash generation
- [ ] `script_payload` type tx
- [X] Sponsor transaction
- [X] Multi-agent transaction
- [X] Starkey wallet integration support
### RPC Node Integration

- **Seamless Connection**: Easily connect to Supra's RPC nodes with significant `rpc_node` endpoint integration.
- **Chain ID Retrieval**: Automatically fetch the chain ID from the RPC node or specify it manually.

### Account Management

- **Account Existence Check**: Verify whether a specific account exists on-chain.
- **Retrieve Account Information**: Access detailed account information and resources.
- **Account Resources Management**: Manage and retrieve all resources held by an account.
- **Starkey Wallet Integration**: Support for integrating with Starkey wallets for enhanced security.

### Transaction Handling

- **Transaction Creation**: Generate various types of transactions, including `entry_function_payload` and `script_payload` types.
- **Transaction Signing**: Sign transactions using Ed25519 or multi-agent authenticators.
- **Transaction Simulation**: Simulate transactions to ensure successful execution before broadcasting.
- **Transaction Payload Generation**: Easily create and manage transaction payloads.
- **Transaction Hash Generation**: Derive transaction hashes locally for verification.
- **Transaction Status Monitoring**: Monitor the status of transactions in real-time.
- **Sponsor Transactions**: Support for sponsor transactions to cover gas fees.
- **Multi-Agent Transactions**: Handle transactions involving multiple agents seamlessly.

### Coin Management

- **Transfer SupraCoin**: Easily transfer SupraCoin between accounts.
- **Transfer Custom Coins**: Handle transfers of custom coin types with ease.
- **Coin Balance Retrieval**: Retrieve SupraCoin and custom coin balances for any account.
- **Coin Change Insights**: Gain insights into coin transfer events and changes.

### Smart Contract Interaction

- **Invoke View Methods**: Interact with smart contracts by invoking view methods.
- **Publish Packages**: Publish packages or modules on the Supra network.
- **Table Item Access**: Access and manage items from smart contract tables using keys.

### Logging and Error Handling

- **Integrated Logging**: Built-in logging with customizable levels (`DEBUG`, `INFO`, `WARN`, `ERROR`) and transports.
- **Comprehensive Error Handling**: Robust error handling with custom `ServiceError` classes for better debugging and reliability.

### Faucet Integration

- **Fund Accounts**: Easily fund accounts with test Supra tokens using the built-in faucet service.

## Documentation

For detailed API documentation, please visit the [TypeScript SDK Documentation](https://sdk-docs.supra.com/index.html). The documentation provides an in-depth look at all available classes, methods, interfaces, and types, ensuring you have all the information needed to leverage the full potential of the Supra SDK.

## Contributing

If you found a bug or would like to request a feature, please file an issue. If, based on the discussion on an issue you would like to offer a code change, please make a pull request.
We welcome contributions to improve the Supra TypeScript SDK! If you encounter a bug or have a feature request, please [file an issue](https://github.com/Entropy-Foundation/supra-l1-sdk/issues). For code changes, please submit a [pull request](https://github.com/Entropy-Foundation/supra-l1-sdk/pulls) after discussing your proposed changes in an issue.

## Credits

A special thanks to the **Supra Team**, our valued contributors, and to us :P **team NLJinchuriki** for their dedication and hard work in overhauling and cleaning up this SDK

Original developers:

- [vpanchal-supra](https://github.com/vpanchal-supra)
- [supra-bharoojangid](https://github.com/supra-bharoojangid)
- [Isaac Doidge](https://github.com/isaacdoidge) - **Isaac Doidge**
- [sjadiya-supra](https://github.com/sjadiya-supra) - **Soham Jadiya**

Your work is greatly appreciated!

## License

This project is licensed under the [MIT License](LICENSE).

---

Feel free to reach out to the [Supra Community](https://community.supra.com) for support or to discuss your ideas!
37 changes: 37 additions & 0 deletions api-extractor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"mainEntryPointFilePath": "<projectFolder>/dist/node/index.d.ts",
"bundledPackages": [],
"compiler": {
"tsconfigFilePath": "<projectFolder>/tsconfig.json"
},
"apiReport": {
"enabled": true
},
"docModel": {
"enabled": true
},
"dtsRollup": {
"enabled": true
},
"tsdocMetadata": {
"enabled": true
},
"messages": {
"compilerMessageReporting": {
"default": {
"logLevel": "warning"
}
},
"extractorMessageReporting": {
"default": {
"logLevel": "warning"
}
},
"tsdocMessageReporting": {
"default": {
"logLevel": "warning"
}
}
}
}
70 changes: 0 additions & 70 deletions docs/assets/highlight.css
Original file line number Diff line number Diff line change
@@ -1,92 +1,22 @@
:root {
--light-hl-0: #000000;
--dark-hl-0: #D4D4D4;
--light-hl-1: #795E26;
--dark-hl-1: #DCDCAA;
--light-hl-2: #A31515;
--dark-hl-2: #CE9178;
--light-hl-3: #0000FF;
--dark-hl-3: #569CD6;
--light-hl-4: #0070C1;
--dark-hl-4: #4FC1FF;
--light-hl-5: #001080;
--dark-hl-5: #9CDCFE;
--light-hl-6: #008000;
--dark-hl-6: #6A9955;
--light-hl-7: #000000;
--dark-hl-7: #C8C8C8;
--light-hl-8: #AF00DB;
--dark-hl-8: #C586C0;
--light-hl-9: #098658;
--dark-hl-9: #B5CEA8;
--light-code-background: #FFFFFF;
--dark-code-background: #1E1E1E;
}

@media (prefers-color-scheme: light) { :root {
--hl-0: var(--light-hl-0);
--hl-1: var(--light-hl-1);
--hl-2: var(--light-hl-2);
--hl-3: var(--light-hl-3);
--hl-4: var(--light-hl-4);
--hl-5: var(--light-hl-5);
--hl-6: var(--light-hl-6);
--hl-7: var(--light-hl-7);
--hl-8: var(--light-hl-8);
--hl-9: var(--light-hl-9);
--code-background: var(--light-code-background);
} }

@media (prefers-color-scheme: dark) { :root {
--hl-0: var(--dark-hl-0);
--hl-1: var(--dark-hl-1);
--hl-2: var(--dark-hl-2);
--hl-3: var(--dark-hl-3);
--hl-4: var(--dark-hl-4);
--hl-5: var(--dark-hl-5);
--hl-6: var(--dark-hl-6);
--hl-7: var(--dark-hl-7);
--hl-8: var(--dark-hl-8);
--hl-9: var(--dark-hl-9);
--code-background: var(--dark-code-background);
} }

:root[data-theme='light'] {
--hl-0: var(--light-hl-0);
--hl-1: var(--light-hl-1);
--hl-2: var(--light-hl-2);
--hl-3: var(--light-hl-3);
--hl-4: var(--light-hl-4);
--hl-5: var(--light-hl-5);
--hl-6: var(--light-hl-6);
--hl-7: var(--light-hl-7);
--hl-8: var(--light-hl-8);
--hl-9: var(--light-hl-9);
--code-background: var(--light-code-background);
}

:root[data-theme='dark'] {
--hl-0: var(--dark-hl-0);
--hl-1: var(--dark-hl-1);
--hl-2: var(--dark-hl-2);
--hl-3: var(--dark-hl-3);
--hl-4: var(--dark-hl-4);
--hl-5: var(--dark-hl-5);
--hl-6: var(--dark-hl-6);
--hl-7: var(--dark-hl-7);
--hl-8: var(--dark-hl-8);
--hl-9: var(--dark-hl-9);
--code-background: var(--dark-code-background);
}

.hl-0 { color: var(--hl-0); }
.hl-1 { color: var(--hl-1); }
.hl-2 { color: var(--hl-2); }
.hl-3 { color: var(--hl-3); }
.hl-4 { color: var(--hl-4); }
.hl-5 { color: var(--hl-5); }
.hl-6 { color: var(--hl-6); }
.hl-7 { color: var(--hl-7); }
.hl-8 { color: var(--hl-8); }
.hl-9 { color: var(--hl-9); }
pre, code { background: var(--code-background); }
2 changes: 1 addition & 1 deletion docs/assets/navigation.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading