-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: In MsgSend, use Coin. Add expo API function makeSendTx (#191)
The gnoclient API uses `MsgSend` where the amount is an [array of `Coin`](https://github.com/gnolang/gno/blob/287c22ec830a1408f1d3de6319602640d841c7cc/tm2/pkg/sdk/bank/msgs.go#L17). A `Coin` is a struct with [separate fields for Denom and Amount.](https://github.com/gnolang/gno/blob/287c22ec830a1408f1d3de6319602640d841c7cc/tm2/pkg/std/coin.go#L19) However, the Gno Native Kit API uses a string such as "1000ugnot" (from the original version of gnoclient). We want to track the current gnoclient API. This PR has four commits: 1. Change the Protobuf `MsgSend` to use an array of `Coin` for the Amount. (The Protobuf `Coin` type was already defined.) Run `make regenerate` to make the native interfaces. Update `gnoNativeService.Send` to use the `Coin` struct. Run `npm install @gnolang/gnonative` to install the new API on buf.build. 2. In expo, update package.json to use the updated bufbuild_es types. Update `send` to take an array of `Coin`. 3. In expo, for making individual transactions we already have `makeCallTx`. Add `makeSendTx`. 4. In expo, in `makeCallTx` and `makeSendTx`, the callerAddress should not be optional. (This should have been fixed for `makeCallTx` in PR #184 .) This was tested by making a local expo NPM package and installing locally in Gnokey Mobile. The following test code sends 100 ugnot to an address. ``` const test_addr = await gnonative.addressFromBech32("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5"); const tx = await gnonative.makeSendTx(test_addr, [new Coin({denom: "ugnot", amount: BigInt(100)})], "1ugnot", BigInt(10000000), keyInfo.address); const signedTx = await gnonative.signTx(tx.txJson, keyInfo.address); await gnonative.broadcastTxCommit(signedTx.signedTxJson); ``` --------- Signed-off-by: Jeff Thompson <[email protected]>
- Loading branch information
Showing
12 changed files
with
239 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.