Skip to content

Commit

Permalink
Updated the doc and enabled the simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
vpanchal-supra committed Oct 2, 2024
1 parent 91eee8b commit 288c7a9
Show file tree
Hide file tree
Showing 32 changed files with 473 additions and 208 deletions.
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
# supra-l1-sdk
# Typescript SDK for Supra

The supra-l1-sdk provides a convenient way to interact with the supra chain and perform operations on supra chain.
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.

**NOTE:** This `sdk` utilizes [aptos-sdk](https://aptos-labs.github.io/ts-sdk-doc/) and expects few things such as `keyPair` of `aptos-sdk` type, so due to this you also have to add `aptos-sdk` in your project.
## Installation

Install supra-l1-sdk with npm

```bash
npm install git+https://github.com/Entropy-Foundation/supra-l1-sdk.git
```

**NOTE:** This `sdk` utilizes [aptos-sdk](https://github.com/aptos-labs/aptos-core/tree/main/ecosystem/typescript/sdk) and expects few things such as `keyPair` of `aptos-sdk` type, so due to this you also have to add `aptos-sdk` in your project.

This `sdk` is under development and in future we will try to completely remove dependency from `aptos-sdk`

## Usage

This `sdk` is well documented and you can check [./src/example.ts](https://github.com/Entropy-Foundation/supra-l1-sdk/blob/master/src/example.ts) for understating about the usage.
Check [./src/example.ts](https://github.com/Entropy-Foundation/supra-l1-sdk/blob/master/src/example.ts) for understating about the usage.
54 changes: 41 additions & 13 deletions dist/browser/index.d.mts
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,20 @@ declare class SupraClient {
*/
getChainId(): Promise<TxnBuilderTypes.ChainId>;
/**
* Get current mean_gas_price
* @returns Current mean_gas_price
* Get current `mean_gas_price`
* @returns Current `mean_gas_price`
*/
getGasPrice(): Promise<bigint>;
/**
* Airdrop test Supra token on given account
* @param account Hex-encoded 32 byte Supra account address
* @returns Transaction hash of faucet transaction
* @returns `FaucetRequestResponse`
*/
fundAccountWithFaucet(account: HexString): Promise<FaucetRequestResponse>;
/**
* Check whether given account exists onchain or not
* @param account Hex-encoded 32 byte Supra account address
* @returns true if account exists otherwise false
* @returns `true` if account exists otherwise `false`
*/
isAccountExists(account: HexString): Promise<boolean>;
/**
Expand All @@ -165,7 +165,7 @@ declare class SupraClient {
/**
* Get status of given supra transaction
* @param transactionHash Hex-encoded 32 byte transaction hash for getting transaction status
* @returns TransactionStatus
* @returns `TransactionStatus`
*/
getTransactionStatus(transactionHash: string): Promise<TransactionStatus | null>;
private getCoinChangeAmount;
Expand All @@ -178,21 +178,28 @@ declare class SupraClient {
*/
getTransactionDetail(account: HexString, transactionHash: string): Promise<TransactionDetail | null>;
/**
* Get transaction associated with an account
* Get transactions sent by the account
* @param account Supra account address
* @param count Number of transactions details
* @param start Cursor for pagination based response
* @returns Transaction Details
* @returns List of `TransactionDetail`
*/
getAccountTransactionsDetail(account: HexString, count?: number, start?: number | null): Promise<TransactionDetail[]>;
/**
* Get Coin Transfer related transactions details
* Get Coin Transfer related transactions associated with the account
* @param account Supra account address
* @param count Number of transactions details
* @param start Sequence number from which N number of transactions returned
* @returns Transaction Details
* @param start Cursor for pagination based response
* @returns List of `TransactionDetail`
*/
getCoinTransactionsDetail(account: HexString, count?: number, start?: number | null): Promise<TransactionDetail[]>;
/**
* Get transactions sent by the account and Coin transfer related transactions
* @param account Supra account address
* @param count Number of coin transfer transactions and account sent transaction to be considered,
* For instance if the value is `N` so total `N*2` transactions will be returned.
* @returns List of `TransactionDetail`
*/
getAccountCompleteTransactionsDetail(account: HexString, count?: number): Promise<TransactionDetail[]>;
/**
* Get Supra balance of given account
Expand All @@ -217,15 +224,36 @@ declare class SupraClient {
private sendTx;
private signSupraTransaction;
private getSendTxPayload;
/**
* Send `entry_function_payload` type tx using serialized raw transaction datas
* @param senderAccount Sender KeyPair
* @param serializedRawTransaction Serialized raw transaction data
* @returns `TransactionResponse`
*/
sendTxUsingSerializedRawTransaction(senderAccount: AptosAccount, serializedRawTransaction: Uint8Array): Promise<TransactionResponse>;
static createRawTxObject(senderAddr: HexString, senderSequenceNumber: bigint, moduleAddr: string, moduleName: string, functionName: string, functionTypeArgs: TxnBuilderTypes.TypeTag[], functionArgs: Uint8Array[], chainId: TxnBuilderTypes.ChainId, maxGas?: bigint, gasUnitPrice?: bigint, txExpiryTime?: bigint): Promise<TxnBuilderTypes.RawTransaction>;
/**
* Create serialized raw transaction object for `entry_function_payload` type tx
* @param senderAddr Sender account address
* @param senderSequenceNumber Sender account sequence number
* @param moduleAddr Target module address
* @param moduleName Target module name
* @param functionName Target function name
* @param functionTypeArgs Target function type args
* @param functionArgs Target function args
* @param chainId Supra network chain id
* @param maxGas Maximum gas for transaction
* @param gasUnitPrice Maximum gas unit price for transaction
* @param txExpiryTime Expiry time for transaction
* @returns Serialized raw transaction object
*/
static createSerializedRawTxObject(senderAddr: HexString, senderSequenceNumber: bigint, moduleAddr: string, moduleName: string, functionName: string, functionTypeArgs: TxnBuilderTypes.TypeTag[], functionArgs: Uint8Array[], chainId: TxnBuilderTypes.ChainId, maxGas?: bigint, gasUnitPrice?: bigint, txExpiryTime?: bigint): Promise<Uint8Array>;
/**
* Transfer supra coin
* @param senderAccount Sender KeyPair
* @param receiverAccountAddr Receiver Supra Account address
* @param amount Amount to transfer
* @returns Transaction Response
* @returns `TransactionResponse`
*/
transferSupraCoin(senderAccount: AptosAccount, receiverAccountAddr: HexString, amount: bigint, waitForTransactionCompletion?: boolean): Promise<TransactionResponse>;
/**
Expand All @@ -234,15 +262,15 @@ declare class SupraClient {
* @param receiverAccountAddr Receiver Supra Account address
* @param amount Amount to transfer
* @param coinType Type of coin
* @returns Transaction Response
* @returns `TransactionResponse`
*/
transferCoin(senderAccount: AptosAccount, receiverAccountAddr: HexString, amount: bigint, coinType: string, waitForTransactionCompletion?: boolean): Promise<TransactionResponse>;
/**
* Publish package or module on supra network
* @param senderAccount Module Publisher KeyPair
* @param packageMetadata Package Metadata
* @param modulesCode module code
* @returns Transaction Response
* @returns `TransactionResponse`
*/
publishPackage(senderAccount: AptosAccount, packageMetadata: Uint8Array, modulesCode: Uint8Array[]): Promise<TransactionResponse>;
/**
Expand Down
54 changes: 41 additions & 13 deletions dist/browser/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,20 @@ declare class SupraClient {
*/
getChainId(): Promise<TxnBuilderTypes.ChainId>;
/**
* Get current mean_gas_price
* @returns Current mean_gas_price
* Get current `mean_gas_price`
* @returns Current `mean_gas_price`
*/
getGasPrice(): Promise<bigint>;
/**
* Airdrop test Supra token on given account
* @param account Hex-encoded 32 byte Supra account address
* @returns Transaction hash of faucet transaction
* @returns `FaucetRequestResponse`
*/
fundAccountWithFaucet(account: HexString): Promise<FaucetRequestResponse>;
/**
* Check whether given account exists onchain or not
* @param account Hex-encoded 32 byte Supra account address
* @returns true if account exists otherwise false
* @returns `true` if account exists otherwise `false`
*/
isAccountExists(account: HexString): Promise<boolean>;
/**
Expand All @@ -165,7 +165,7 @@ declare class SupraClient {
/**
* Get status of given supra transaction
* @param transactionHash Hex-encoded 32 byte transaction hash for getting transaction status
* @returns TransactionStatus
* @returns `TransactionStatus`
*/
getTransactionStatus(transactionHash: string): Promise<TransactionStatus | null>;
private getCoinChangeAmount;
Expand All @@ -178,21 +178,28 @@ declare class SupraClient {
*/
getTransactionDetail(account: HexString, transactionHash: string): Promise<TransactionDetail | null>;
/**
* Get transaction associated with an account
* Get transactions sent by the account
* @param account Supra account address
* @param count Number of transactions details
* @param start Cursor for pagination based response
* @returns Transaction Details
* @returns List of `TransactionDetail`
*/
getAccountTransactionsDetail(account: HexString, count?: number, start?: number | null): Promise<TransactionDetail[]>;
/**
* Get Coin Transfer related transactions details
* Get Coin Transfer related transactions associated with the account
* @param account Supra account address
* @param count Number of transactions details
* @param start Sequence number from which N number of transactions returned
* @returns Transaction Details
* @param start Cursor for pagination based response
* @returns List of `TransactionDetail`
*/
getCoinTransactionsDetail(account: HexString, count?: number, start?: number | null): Promise<TransactionDetail[]>;
/**
* Get transactions sent by the account and Coin transfer related transactions
* @param account Supra account address
* @param count Number of coin transfer transactions and account sent transaction to be considered,
* For instance if the value is `N` so total `N*2` transactions will be returned.
* @returns List of `TransactionDetail`
*/
getAccountCompleteTransactionsDetail(account: HexString, count?: number): Promise<TransactionDetail[]>;
/**
* Get Supra balance of given account
Expand All @@ -217,15 +224,36 @@ declare class SupraClient {
private sendTx;
private signSupraTransaction;
private getSendTxPayload;
/**
* Send `entry_function_payload` type tx using serialized raw transaction datas
* @param senderAccount Sender KeyPair
* @param serializedRawTransaction Serialized raw transaction data
* @returns `TransactionResponse`
*/
sendTxUsingSerializedRawTransaction(senderAccount: AptosAccount, serializedRawTransaction: Uint8Array): Promise<TransactionResponse>;
static createRawTxObject(senderAddr: HexString, senderSequenceNumber: bigint, moduleAddr: string, moduleName: string, functionName: string, functionTypeArgs: TxnBuilderTypes.TypeTag[], functionArgs: Uint8Array[], chainId: TxnBuilderTypes.ChainId, maxGas?: bigint, gasUnitPrice?: bigint, txExpiryTime?: bigint): Promise<TxnBuilderTypes.RawTransaction>;
/**
* Create serialized raw transaction object for `entry_function_payload` type tx
* @param senderAddr Sender account address
* @param senderSequenceNumber Sender account sequence number
* @param moduleAddr Target module address
* @param moduleName Target module name
* @param functionName Target function name
* @param functionTypeArgs Target function type args
* @param functionArgs Target function args
* @param chainId Supra network chain id
* @param maxGas Maximum gas for transaction
* @param gasUnitPrice Maximum gas unit price for transaction
* @param txExpiryTime Expiry time for transaction
* @returns Serialized raw transaction object
*/
static createSerializedRawTxObject(senderAddr: HexString, senderSequenceNumber: bigint, moduleAddr: string, moduleName: string, functionName: string, functionTypeArgs: TxnBuilderTypes.TypeTag[], functionArgs: Uint8Array[], chainId: TxnBuilderTypes.ChainId, maxGas?: bigint, gasUnitPrice?: bigint, txExpiryTime?: bigint): Promise<Uint8Array>;
/**
* Transfer supra coin
* @param senderAccount Sender KeyPair
* @param receiverAccountAddr Receiver Supra Account address
* @param amount Amount to transfer
* @returns Transaction Response
* @returns `TransactionResponse`
*/
transferSupraCoin(senderAccount: AptosAccount, receiverAccountAddr: HexString, amount: bigint, waitForTransactionCompletion?: boolean): Promise<TransactionResponse>;
/**
Expand All @@ -234,15 +262,15 @@ declare class SupraClient {
* @param receiverAccountAddr Receiver Supra Account address
* @param amount Amount to transfer
* @param coinType Type of coin
* @returns Transaction Response
* @returns `TransactionResponse`
*/
transferCoin(senderAccount: AptosAccount, receiverAccountAddr: HexString, amount: bigint, coinType: string, waitForTransactionCompletion?: boolean): Promise<TransactionResponse>;
/**
* Publish package or module on supra network
* @param senderAccount Module Publisher KeyPair
* @param packageMetadata Package Metadata
* @param modulesCode module code
* @returns Transaction Response
* @returns `TransactionResponse`
*/
publishPackage(senderAccount: AptosAccount, packageMetadata: Uint8Array, modulesCode: Uint8Array[]): Promise<TransactionResponse>;
/**
Expand Down
Loading

0 comments on commit 288c7a9

Please sign in to comment.