@firmachain/firma-js 0.3.0-beta1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -15
- package/dist/sdk/FirmaGovService.d.ts +26 -17
- package/dist/sdk/FirmaGovService.js +282 -150
- package/dist/sdk/FirmaStakingService.d.ts +4 -2
- package/dist/sdk/FirmaStakingService.js +37 -9
- package/dist/sdk/FirmaUtil.d.ts +36 -0
- package/dist/sdk/FirmaUtil.js +139 -0
- package/dist/sdk/firmachain/common/CommonTxClient.js +1 -0
- package/dist/sdk/firmachain/common/modules/gov/messages.js +1 -0
- package/dist/sdk/firmachain/gov/GovQueryClient.d.ts +25 -40
- package/dist/sdk/firmachain/gov/GovQueryClient.js +20 -21
- package/dist/sdk/firmachain/gov/GovTxClient.d.ts +6 -0
- package/dist/sdk/firmachain/gov/GovTxClient.js +8 -2
- package/dist/sdk/firmachain/staking/StakingQueryClient.d.ts +3 -2
- package/dist/test/08.gas_estimate.test.js +41 -28
- package/dist/test/13.staking_query.test.js +12 -0
- package/dist/test/16.gov_tx.test.js +139 -58
- package/dist/test/17.gov_query.test.js +18 -18
- package/dist/test/18.util.test.js +74 -0
- package/dist/test/20.slashing_query.test.js +0 -1
- package/dist/test/config_test.js +10 -4
- package/dist/test/config_test.sample.d.ts +6 -0
- package/dist/test/config_test.sample.js +7 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,23 +5,33 @@
|
|
|
5
5
|
[](https://github.com/firmachain/firma-js/blob/master/LICENSE)
|
|
6
6
|
[](https://github.com/FirmaChain/firma-js)
|
|
7
7
|
|
|
8
|
-
The
|
|
8
|
+
**The Official JavaScript & TypeScript SDK for FirmaChain**
|
|
9
9
|
|
|
10
|
-
Firma-js is a SDK for
|
|
10
|
+
Firma-js is a comprehensive SDK for building applications on the FirmaChain blockchain using JavaScript and TypeScript. Whether you're developing client-side web applications or server-side Node.js applications, this SDK provides seamless integration with FirmaChain's full suite of blockchain capabilities.
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
A patch is planned soon to enable the governance module in version 0.3.1.
|
|
12
|
+
Built with inspiration from CosmJS and other leading Cosmos SDK implementations, firma-js offers a service-oriented architecture that provides direct access to all FirmaChain functionality while maintaining type safety and developer experience.
|
|
14
13
|
|
|
15
14
|
## Features
|
|
16
|
-
Most cosmos sdk features are supported
|
|
17
|
-
- Wallet / Bank
|
|
18
|
-
- Nft / Contract
|
|
19
|
-
- Ipfs / Gov
|
|
20
|
-
- Staking / Distribution
|
|
21
|
-
- Feegrant ...and so one
|
|
22
|
-
|
|
23
|
-
</br>
|
|
24
15
|
|
|
16
|
+
**Core FirmaChain Integration**
|
|
17
|
+
- **Wallet Management**: Create, import, and manage wallets with mnemonic and private key support
|
|
18
|
+
- **Banking Operations**: Send, receive, and query FCT with full transaction control
|
|
19
|
+
- **Staking & Delegation**: Stake tokens, delegate to validators, and manage rewards
|
|
20
|
+
- **Authorization**: Grant and revoke permissions for account delegation
|
|
21
|
+
- **Fee Grant**: Grant and revoke fee allowances for gasless transactions
|
|
22
|
+
- **Governance**: Create proposals, vote, and query governance parameters
|
|
23
|
+
|
|
24
|
+
**FirmaChain Ecosystem**
|
|
25
|
+
- **Smart Contracts**: Deploy, execute, and query CosmWasm smart contracts with full parameter control
|
|
26
|
+
- **IBC Operations**: Cross-chain transfers and communication protocols
|
|
27
|
+
- **IPFS Integration**: Upload, pin, and retrieve files from IPFS with built-in gateway support
|
|
28
|
+
- **NFT Operations**: Mint, transfer, burn, and query built-in NFTs with comprehensive metadata support
|
|
29
|
+
|
|
30
|
+
**Developer Experience**
|
|
31
|
+
- **TypeScript Support**: Full type definitions for enhanced IDE support and compile-time safety
|
|
32
|
+
- **Modular Architecture**: Use only the modules you need for optimal bundle size
|
|
33
|
+
- **Comprehensive Documentation**: Extensive examples and API documentation
|
|
34
|
+
- **CosmJS Compatible**: Familiar patterns for developers experienced with Cosmos SDK
|
|
25
35
|
|
|
26
36
|
## Install
|
|
27
37
|
You can install `firma-js` using [NPM](https://www.npmjs.com/package/@firmachain/firma-js)
|
|
@@ -33,6 +43,23 @@ or
|
|
|
33
43
|
npm i @firmachain/firma-js
|
|
34
44
|
```
|
|
35
45
|
|
|
46
|
+
## Conventions
|
|
47
|
+
|
|
48
|
+
### Implementation Guidelines
|
|
49
|
+
- **Data Structure Consistency**: We recommend preserving the original data structure from FirmaChain RPCs throughout your application and only processing/transforming the data immediately before transaction generation. This convention is also applied to `firma-js` itself.
|
|
50
|
+
- **Chain Data Integrity**: This approach ensures consistency in chain data retrieval logic and maintains compatibility with upstream changes
|
|
51
|
+
- **Transaction Processing**: All data transformations should occur at the transaction boundary to minimize potential inconsistencies
|
|
52
|
+
|
|
53
|
+
### Governance Parameters
|
|
54
|
+
- **Parameter Validation**: For governance proposals requiring multiple parameters, we perform dual validation by comparing submitted parameters against `fromPartial`-processed parameters to ensure identical values
|
|
55
|
+
- **Validation Failure Handling**: If any discrepancy is detected between the original and processed parameters, the transaction will automatically revert to prevent malformed proposals
|
|
56
|
+
- **Best Practice**: To ensure successful governance proposal submissions, use the provided helper functions:
|
|
57
|
+
- `getParamAsGovParams()` - Retrieve current governance parameters
|
|
58
|
+
- `getParamsAsStakingParams()` - Retrieve current staking parameters
|
|
59
|
+
|
|
60
|
+
Modify only the specific fields you need to change while preserving all other existing parameter values
|
|
61
|
+
|
|
62
|
+
|
|
36
63
|
## Usage
|
|
37
64
|
### Initializing SDK
|
|
38
65
|
```js
|
|
@@ -141,6 +168,10 @@ const tokenId = 1;
|
|
|
141
168
|
let result = await firma.Nft.burn(wallet, tokenId);
|
|
142
169
|
```
|
|
143
170
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
171
|
+
## Complete Examples
|
|
172
|
+
|
|
173
|
+
For comprehensive usage examples and test cases, please refer to the test suite:
|
|
174
|
+
|
|
175
|
+
🔗 **[View Complete Examples](https://github.com/FirmaChain/firma-js/tree/main/test)**
|
|
176
|
+
|
|
177
|
+
The test folder contains detailed examples for all SDK features including wallet management, token operations, NFT handling, smart contracts, governance, staking, and more.
|
|
@@ -1,38 +1,47 @@
|
|
|
1
|
-
import { TxMisc,
|
|
1
|
+
import { TxMisc, VotingOption, ProposalStatus, CurrentVoteInfo, GovParamType } from "./firmachain/gov";
|
|
2
|
+
import { DeliverTxResponse } from "./firmachain/common/stargateclient";
|
|
2
3
|
import { FirmaWalletService } from "./FirmaWalletService";
|
|
3
4
|
import { FirmaConfig } from "./FirmaConfig";
|
|
4
|
-
import {
|
|
5
|
+
import { Plan } from "cosmjs-types/cosmos/upgrade/v1beta1/upgrade";
|
|
6
|
+
import { Coin } from "cosmjs-types/cosmos/base/v1beta1/coin";
|
|
7
|
+
import { Proposal, Params as GovParams } from "@kintsugi-tech/cosmjs-types/cosmos/gov/v1/gov";
|
|
8
|
+
import { Params as StakingParams } from "@kintsugi-tech/cosmjs-types/cosmos/staking/v1beta1/staking";
|
|
5
9
|
export declare class FirmaGovService {
|
|
6
10
|
private readonly config;
|
|
11
|
+
static readonly GOV_AUTHORITY = "firma10d07y265gmmuvt4z0w9aw880jnsr700j53mj8f";
|
|
7
12
|
constructor(config: FirmaConfig);
|
|
8
13
|
getGasEstimationVote(wallet: FirmaWalletService, proposalId: number, option: VotingOption, txMisc?: TxMisc): Promise<number>;
|
|
9
14
|
getGasEstimationDeposit(wallet: FirmaWalletService, proposalId: number, amount: number, txMisc?: TxMisc): Promise<number>;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
getGasEstimationSubmitCommunityPoolSpendProposal(wallet: FirmaWalletService, title: string,
|
|
15
|
+
getGasEstimationSubmitSoftwareUpgradeProposal(wallet: FirmaWalletService, title: string, summary: string, initialDepositFCT: number, plan: Plan, metadata?: string, txMisc?: TxMisc): Promise<number>;
|
|
16
|
+
getGasEstimationSubmitStakingParamsUpdateProposal(wallet: FirmaWalletService, title: string, summary: string, initialDepositFCT: number, params: StakingParams, metadata?: string, txMisc?: TxMisc): Promise<number>;
|
|
17
|
+
getGasEstimationSubmitGovParamsUpdateProposal(wallet: FirmaWalletService, title: string, summary: string, initialDepositFCT: number, params: GovParams, metadata?: string, txMisc?: TxMisc): Promise<number>;
|
|
18
|
+
getGasEstimationSubmitCommunityPoolSpendProposal(wallet: FirmaWalletService, title: string, summary: string, initialDepositFCT: number, amountFCT: number, recipient: string, txMisc?: TxMisc): Promise<number>;
|
|
14
19
|
getGasEstimationSubmitTextProposal(wallet: FirmaWalletService, title: string, description: string, initialDepositFCT: number, txMisc?: TxMisc): Promise<number>;
|
|
15
20
|
getGasEstimationCancelProposal(wallet: FirmaWalletService, proposalId: number, txMisc?: TxMisc): Promise<number>;
|
|
16
21
|
private getSignedTxSubmitTextProposal;
|
|
17
|
-
private getSignedTxSubmitCancelSoftwareUpgradeProposal;
|
|
18
22
|
private getSignedTxSubmitSoftwareUpgradeProposal;
|
|
19
|
-
private
|
|
23
|
+
private getSignedTxSubmitStakingParamsUpdateProposal;
|
|
24
|
+
private getSignedTxSubmitGovParamsUpdateProposal;
|
|
20
25
|
private getSignedTxSubmitCommunityPoolSpendProposal;
|
|
21
26
|
private getSignedTxCancelProposal;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
submitCommunityPoolSpendProposal(wallet: FirmaWalletService, title: string, description: string, initialDeposit: number, amount: number, recipient: string, txMisc?: TxMisc): Promise<DeliverTxResponse>;
|
|
27
|
+
submitSoftwareUpgradeProposal(wallet: FirmaWalletService, title: string, summary: string, initialDepositFCT: number, plan: Plan, metadata?: string, txMisc?: TxMisc): Promise<DeliverTxResponse>;
|
|
28
|
+
submitStakingParamsUpdateProposal(wallet: FirmaWalletService, title: string, summary: string, initialDepositFCT: number, params: StakingParams, metadata?: string, txMisc?: TxMisc): Promise<DeliverTxResponse>;
|
|
29
|
+
submitGovParamsUpdateProposal(wallet: FirmaWalletService, title: string, summary: string, initialDepositFCT: number, params: GovParams, metadata?: string, txmisc?: TxMisc): Promise<DeliverTxResponse>;
|
|
30
|
+
submitCommunityPoolSpendProposal(wallet: FirmaWalletService, title: string, summary: string, initialDepositFCT: number, amountFCT: number, recipient: string, metadata?: string, txMisc?: TxMisc): Promise<DeliverTxResponse>;
|
|
27
31
|
submitTextProposal(wallet: FirmaWalletService, title: string, description: string, initialDeposit: number, txMisc?: TxMisc): Promise<DeliverTxResponse>;
|
|
32
|
+
submitGenericProposal(wallet: FirmaWalletService, title: string, summary: string, initialDeposit: Coin[], metadata: string, msgs: {
|
|
33
|
+
typeUrl?: string | undefined;
|
|
34
|
+
value?: Uint8Array | undefined;
|
|
35
|
+
}[] | undefined, txMisc?: TxMisc): Promise<DeliverTxResponse>;
|
|
28
36
|
cancelProposal(wallet: FirmaWalletService, proposalId: number, txMisc?: TxMisc): Promise<DeliverTxResponse>;
|
|
29
37
|
private getSignedTxVote;
|
|
30
38
|
vote(wallet: FirmaWalletService, proposalId: number, option: VotingOption, txMisc?: TxMisc): Promise<DeliverTxResponse>;
|
|
31
39
|
private getSignedTxDeposit;
|
|
32
40
|
deposit(wallet: FirmaWalletService, proposalId: number, amount: number, txMisc?: TxMisc): Promise<DeliverTxResponse>;
|
|
33
41
|
getCurrentVoteInfo(id: string): Promise<CurrentVoteInfo>;
|
|
34
|
-
getParam(): Promise<
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
42
|
+
getParam(): Promise<GovParamType>;
|
|
43
|
+
getParamAsGovParams(): Promise<GovParams>;
|
|
44
|
+
getProposal(id: string): Promise<Proposal>;
|
|
45
|
+
getProposalListByStatus(status: ProposalStatus): Promise<Proposal[]>;
|
|
46
|
+
getProposalList(): Promise<Proposal[]>;
|
|
38
47
|
}
|