@@ -31,8 +31,15 @@ const sdk = createBabylonSDK({ rpcUrl: "https://babylon-rpc.example.com" });
31
31
// Connect the client
32
32
await sdk .connect ();
33
33
34
- // Query rewards for an address
35
- const rewards = await sdk .client .getRewards (" bbn1..." );
34
+ // Query BTC staking rewards for an address
35
+ const btcRewards = await sdk .client .getRewardsForBTCStaking (" bbn1..." );
36
+
37
+ // Query BABY staking delegations and rewards
38
+ const delegations = await sdk .client .getBabyStakingDelegations (" bbn1..." );
39
+ const babyRewards = await sdk .client .getRewardsForBABYStaking (" bbn1..." );
40
+
41
+ // Get all validators
42
+ const validators = await sdk .client .getValidators ();
36
43
37
44
// Query balance
38
45
const balance = await sdk .client .getBalance (" bbn1..." , " ubbn" );
@@ -61,11 +68,22 @@ const client = await SigningStargateClient.connectWithSigner(
61
68
},
62
69
);
63
70
64
- // Create messages using the SDK
65
- const withdrawMsg = sdk .messages .createWithdrawRewardMsg (" bbn1..." );
71
+ // BTC Staking: Withdraw BTC staking rewards message
72
+ const btcWithdrawMsg =
73
+ sdk .messages .createWithdrawRewardForBTCStakingMsg (" bbn1..." );
74
+
75
+ // BABY Staking: Stake BABY tokens message
76
+ const stakeMsg = sdk .messages .createStakeBABYMsg (
77
+ " bbn1..." , // delegator address
78
+ " bbnvalidator..." , // validator address
79
+ { denom: " ubbn" , amount: " 1000000" }, // 1 BBN
80
+ );
66
81
67
- // Sign and broadcast
68
- const result = await client .signAndBroadcast (" bbn1..." , [withdrawMsg ], " auto" );
82
+ // BABY Staking: Withdraw BABY staking rewards message
83
+ const withdrawMsg = sdk .messages .createWithdrawRewardForBABYStakingMsg (
84
+ " bbn1..." ,
85
+ " bbnvalidator..." ,
86
+ );
69
87
```
70
88
71
89
### Direct Protobuf Access
@@ -100,21 +118,21 @@ Initializes the client connection to the Babylon network.
100
118
101
119
### Client Methods (via sdk.client)
102
120
103
- #### ` sdk.client.getRewards (address: string): Promise<number> `
121
+ #### ` sdk.client.getRewardsForBTCStaking (address: string): Promise<number> `
104
122
105
- Retrieves the total rewards for a given address.
123
+ Retrieves the total BTC staking rewards for a given address.
106
124
107
125
- ** Parameters:**
108
126
- ` address ` : The Babylon address to query
109
- - ** Returns:** Total rewards amount (number)
127
+ - ** Returns:** Total BTC staking rewards amount (number)
110
128
111
129
#### ` sdk.client.getBalance(address: string, denom?: string): Promise<number> `
112
130
113
131
Gets the balance of a specific token for an address.
114
132
115
133
- ** Parameters:**
116
134
- ` address ` : The Babylon address to query
117
- - ` denom ` : Token denomination (defaults to "ubbn")
135
+ - ` denom ` : Token denomination (defaults to ` "ubbn" ` )
118
136
- ** Returns:** Balance amount (number)
119
137
120
138
#### ` sdk.client.getBTCTipHeight(): Promise<number> `
@@ -123,16 +141,67 @@ Retrieves the current Bitcoin blockchain tip height.
123
141
124
142
- ** Returns:** Bitcoin tip height (number)
125
143
144
+ #### ` sdk.client.getBabyStakingDelegations(address: string): Promise<DelegationResponse[]> `
145
+
146
+ Gets all BABY token delegations for a given address.
147
+
148
+ - ** Parameters:**
149
+ - ` address ` : The Babylon address to query
150
+ - ** Returns:** Array of delegation responses
151
+
152
+ #### ` sdk.client.getRewardsForBABYStaking(address: string): Promise<DelegationDelegatorReward[]> `
153
+
154
+ Retrieves all BABY staking delegation rewards for a given address.
155
+
156
+ - ** Parameters:**
157
+ - ` address ` : The Babylon address to query
158
+ - ** Returns:** Array of delegation rewards
159
+
160
+ #### ` sdk.client.getValidators(): Promise<Validator[]> `
161
+
162
+ Gets all validators in the network.
163
+
164
+ - ** Returns:** Array of all validators
165
+
126
166
### SDK Messages
127
167
128
- #### ` sdk.messages.createWithdrawRewardMsg (address: string) `
168
+ #### ` sdk.messages.createWithdrawRewardForBTCStakingMsg (address: string) `
129
169
130
170
Creates a message for withdrawing rewards from Bitcoin staking.
131
171
132
172
- ** Parameters:**
133
173
- ` address ` : The Babylon address to withdraw rewards for
134
174
- ** Returns:** Message object with proper typeUrl and value, ready for signing and broadcasting
135
175
176
+ #### ` sdk.messages.createStakeBABYMsg(delegatorAddress: string, validatorAddress: string, amount: Coin) `
177
+
178
+ Creates a message for staking BABY tokens.
179
+
180
+ - ** Parameters:**
181
+ - ` delegatorAddress ` : The delegator's Babylon address
182
+ - ` validatorAddress ` : The validator's Babylon address
183
+ - ` amount ` : The amount to stake (Coin object with amount and denom)
184
+ - ** Returns:** Message object with proper typeUrl and value, ready for signing and broadcasting
185
+
186
+ #### ` sdk.messages.createUnstakeBABYMsg(delegatorAddress: string, validatorAddress: string, amount: Coin) `
187
+
188
+ Creates a message for unstaking BABY tokens.
189
+
190
+ - ** Parameters:**
191
+ - ` delegatorAddress ` : The delegator's Babylon address
192
+ - ` validatorAddress ` : The validator's Babylon address
193
+ - ` amount ` : The amount to unstake (Coin object with amount and denom)
194
+ - ** Returns:** Message object with proper typeUrl and value, ready for signing and broadcasting
195
+
196
+ #### ` sdk.messages.createWithdrawRewardForBABYStakingMsg(delegatorAddress: string, validatorAddress: string) `
197
+
198
+ Creates a message for withdrawing BABY staking rewards.
199
+
200
+ - ** Parameters:**
201
+ - ` delegatorAddress ` : The delegator's Babylon address
202
+ - ` validatorAddress ` : The validator's Babylon address
203
+ - ** Returns:** Message object with proper typeUrl and value, ready for signing and broadcasting
204
+
136
205
### SDK Utilities
137
206
138
207
#### ` sdk.utils.createRegistry(): Registry `
@@ -143,6 +212,22 @@ Creates a CosmJS registry with all Babylon message types registered.
143
212
144
213
Creates amino types for Babylon messages, required for hardware wallet compatibility.
145
214
215
+ #### ` sdk.utils.normalizeCosmjsAmount(amount: string): string `
216
+
217
+ Normalizes CosmJS amount from 18-decimal precision to standard ` ubbn ` format.
218
+
219
+ - ** Parameters:**
220
+ - ` amount ` : The amount string from CosmJS (with 18 decimal precision)
221
+ - ** Returns:** The normalized amount as a string in standard ` ubbn ` format
222
+
223
+ #### ` sdk.utils.normalizeRewardResponse(response: QueryDelegationTotalRewardsResponse) `
224
+
225
+ Normalizes reward response from CosmJS to standard ` ubbn ` format.
226
+
227
+ - ** Parameters:**
228
+ - ` response ` : The QueryDelegationTotalRewardsResponse from CosmJS
229
+ - ** Returns:** The normalized reward array with amounts in standard ` ubbn ` format
230
+
146
231
### Protobuf Exports
147
232
148
233
The library exports all generated protobuf types directly, allowing for advanced use cases
0 commit comments