diff --git a/docs/api-docs/classes/bncclient.md b/docs/api-docs/classes/bncclient.md index 2379a5c4..4c7336e7 100644 --- a/docs/api-docs/classes/bncclient.md +++ b/docs/api-docs/classes/bncclient.md @@ -332,7 +332,7 @@ get open orders for an address Name | Type | Default | Description | ------ | ------ | ------ | ------ | -`address` | string | this.address! | binance address | +`address` | string | this.address! | bnb address | **Returns:** *Promise‹object | never[]›* @@ -465,7 +465,7 @@ Name | Type | Default | Description | **Returns:** *Promise‹object | never[]›* -resolves with http response ([more details](https://docs.bnbchain.org/docs/beaconchain/develop/api-reference/dex-api/block-service/#apiv1txs)) +resolves with http response ([more details](https://docs.binance.org/api-reference/dex-api/block-service.html#apiv1txs)) ```js // Example: const client = new BncClient('https://testnet-api.binance.org') diff --git a/package.json b/package.json index cff2169a..d8f2f1c0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bnb-chain/javascript-sdk", - "version": "0.0.0-development", + "version": "1.0.2", "license": "Apache-2.0", "main": "lib/index.js", "typings": "lib/index.d.ts", diff --git a/src/types/msg/stake/index.ts b/src/types/msg/stake/index.ts index 09963b77..a0b7572e 100644 --- a/src/types/msg/stake/index.ts +++ b/src/types/msg/stake/index.ts @@ -1,3 +1,4 @@ export * from "./bscDelegateMsg" export * from "./bscUndelegateMsg" export * from "./bscRedelegateMsg" +export * from "./stakeMigrationMsg" diff --git a/src/types/msg/stake/stakeMigrationMsg.ts b/src/types/msg/stake/stakeMigrationMsg.ts new file mode 100644 index 00000000..cdfbc5ed --- /dev/null +++ b/src/types/msg/stake/stakeMigrationMsg.ts @@ -0,0 +1,89 @@ +import { BaseMsg, Msg, SignMsg, Coin } from ".." +import * as crypto from "../../../crypto" +import { AminoPrefix } from "../../tx" + +export interface SignedStakeMigrationMsg extends SignMsg { + delegator_addr: string + validator_src_addr: string + validator_dst_addr: string + refund_addr: string + amount: Coin +} + +export interface StakeMigrationData extends Msg { + validator_src_addr: Buffer + validator_dst_addr: Buffer + delegator_addr: Buffer + refund_addr: Buffer + amount: Coin + aminoPrefix: AminoPrefix +} + +export class StakeMigrationMsg extends BaseMsg { + private delegator_addr: string + private validator_src_addr: string + private validator_dst_addr: string + private refund_addr: string + private amount: Coin + + constructor({ + delegator_addr, + validator_src_addr, + validator_dst_addr, + amount, + refund_addr, + }: { + delegator_addr: string + validator_src_addr: string + validator_dst_addr: string + amount: Coin + refund_addr: string + }) { + super() + this.delegator_addr = delegator_addr + this.validator_src_addr = validator_src_addr + this.validator_dst_addr = validator_dst_addr + this.amount = amount + this.refund_addr = refund_addr + } + + getSignMsg() { + const { denom, amount } = this.amount + const signMsg: SignedStakeMigrationMsg = { + validator_src_addr: this.validator_src_addr, + validator_dst_addr: this.validator_dst_addr, + delegator_addr: this.delegator_addr, + refund_addr: this.refund_addr, + amount: { denom, amount: String(amount) }, + } + + return { + type: "cosmos-sdk/MsgSideChainStakeMigration", + value: signMsg, + } + } + + getMsg() { + const data: StakeMigrationData = { + validator_src_addr: crypto.decodeAddress(this.validator_src_addr), + validator_dst_addr: Buffer.from(this.validator_dst_addr.slice(2), "hex"), + delegator_addr: Buffer.from(this.delegator_addr.slice(2), "hex"), + refund_addr: crypto.decodeAddress(this.refund_addr), + amount: this.amount, + aminoPrefix: AminoPrefix.MsgSideChainStakeMigration, + } + + return data + } + + static defaultMsg() { + return { + validator_src_addr: Buffer.from(""), + validator_dst_addr: Buffer.from(""), + delegator_addr: Buffer.from(""), + refund_addr: Buffer.from(""), + amount: [{ denom: "", amount: 0 }], + aminoPrefix: AminoPrefix.MsgSideChainStakeMigration, + } + } +} diff --git a/src/types/tx/stdTx.ts b/src/types/tx/stdTx.ts index 0ee89441..45fe9ad8 100644 --- a/src/types/tx/stdTx.ts +++ b/src/types/tx/stdTx.ts @@ -65,6 +65,7 @@ export enum AminoPrefix { MsgSideChainDelegate = "E3A07FD2", MsgSideChainRedelegate = "E3CED364", MsgSideChainUndelegate = "514F7E0E", + MsgSideChainStakeMigration = "38589196", Claim = "4E781C11", ClaimMsg = "175A0521", BindMsg = "B9AE640C",