@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 CHANGED
@@ -5,23 +5,33 @@
5
5
  [![license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/firmachain/firma-js/blob/master/LICENSE)
6
6
  [![](https://tokei.rs/b1/github/XAMPPRocky/tokei)](https://github.com/FirmaChain/firma-js)
7
7
 
8
- The Javascript & TypeScript SDK for FirmaChain
8
+ **The Official JavaScript & TypeScript SDK for FirmaChain**
9
9
 
10
- Firma-js is a SDK for writing applications based on javascript & typescript. You can use it client web app or Node.js. This SDK is created inspired by cosmjs and several sdk. All functions of the FirmaChain can be accessed at the service level.
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
- ⚠️ We wanted to let you know that the governance module is not accessible at the moment. It requires a patch to become fully operational, which we're actively preparing. We plan to release this patch soon as part of version 0.3.1, at which point the governance module will be enabled.
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
- You can see everything usage of firma-js on the test folder.
145
- </br>
146
- https://github.com/FirmaChain/firma-js/tree/main/test
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, ParamChangeOption, VotingOption, ProposalInfo, ProposalStatus, ProposalParam, CurrentVoteInfo } from "./firmachain/gov";
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 { DeliverTxResponse } from "./firmachain/common/stargateclient";
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
- getGasEstimationSubmitCancelSoftwareUpgradeProposal(wallet: FirmaWalletService, title: string, description: string, initialDepositFCT: number, txMisc?: TxMisc): Promise<number>;
11
- getGasEstimationSubmitSoftwareUpgradeProposalByHeight(wallet: FirmaWalletService, title: string, description: string, initialDepositFCT: number, upgradeName: string, height: number, txMisc?: TxMisc): Promise<number>;
12
- getGasEstimationSubmitParameterChangeProposal(wallet: FirmaWalletService, title: string, description: string, initialDepositFCT: number, paramList: ParamChangeOption[], txMisc?: TxMisc): Promise<number>;
13
- getGasEstimationSubmitCommunityPoolSpendProposal(wallet: FirmaWalletService, title: string, description: string, initialDepositFCT: number, amount: number, recipient: string, txMisc?: TxMisc): Promise<number>;
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 getSignedTxSubmitParameterChangeProposal;
23
+ private getSignedTxSubmitStakingParamsUpdateProposal;
24
+ private getSignedTxSubmitGovParamsUpdateProposal;
20
25
  private getSignedTxSubmitCommunityPoolSpendProposal;
21
26
  private getSignedTxCancelProposal;
22
- submitCancelSoftwareUpgradeProposal(wallet: FirmaWalletService, title: string, description: string, initialDeposit: number, txMisc?: TxMisc): Promise<DeliverTxResponse>;
23
- submitSoftwareUpgradeProposalByHeight(wallet: FirmaWalletService, title: string, description: string, initialDeposit: number, upgradeName: string, height: number, txMisc?: TxMisc): Promise<DeliverTxResponse>;
24
- submitSoftwareUpgradeProposalByTime(wallet: FirmaWalletService, title: string, description: string, initialDeposit: number, upgradeName: string, upgradeTime: Date, txMisc?: TxMisc): Promise<DeliverTxResponse>;
25
- submitParameterChangeProposal(wallet: FirmaWalletService, title: string, description: string, initialDeposit: number, paramList: ParamChangeOption[], txMisc?: TxMisc): Promise<DeliverTxResponse>;
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<ProposalParam>;
35
- getProposal(id: string): Promise<ProposalInfo>;
36
- getProposalListByStatus(status: ProposalStatus): Promise<ProposalInfo[]>;
37
- getProposalList(): Promise<ProposalInfo[]>;
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
  }