Skip to content

Commit 1d9e8d6

Browse files
authored
[LUM-369-3] Register new Dfract message to amino registry (#46)
* Add Dfract message * Fix define-proto.sh and generate protobuf * Bump version * Update proto * Add createdAt into MsgDepositDfract * Update version * Add dfract extension * Add Dfract extension in client * Update codec according to chain update * Register new Dfract message to amino registry * Bump version to 0.7.8 * Update doc
1 parent 3d9770d commit 1d9e8d6

File tree

6 files changed

+159
-150
lines changed

6 files changed

+159
-150
lines changed

docs/lib/modules/lummessages.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -705,15 +705,14 @@ ___
705705

706706
### BuildMsgDepositDfract
707707

708-
`Const` **BuildMsgDepositDfract**(`depositorAddress`, `amount`, `createdAt`): [`Message`](../interfaces/LumMessages.Message.md)
708+
`Const` **BuildMsgDepositDfract**(`depositorAddress`, `amount`): [`Message`](../interfaces/LumMessages.Message.md)
709709

710710
#### Parameters
711711

712712
| Name | Type |
713713
| :------ | :------ |
714714
| `depositorAddress` | `string` |
715715
| `amount` | [`Coin`](../interfaces/LumTypes.Coin.md) |
716-
| `createdAt` | `Date` |
717716

718717
#### Returns
719718

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lum-network/sdk-javascript",
3-
"version": "0.7.7",
3+
"version": "0.7.8",
44
"license": "Apache-2.0",
55
"description": "Javascript SDK library for NodeJS and Web browsers to interact with the Lum Network.",
66
"homepage": "https://github.com/lum-network/sdk-javascript#readme",
@@ -40,14 +40,14 @@
4040
"postdefine-proto": "prettier --write \"src/codec/**/*.ts\""
4141
},
4242
"dependencies": {
43-
"@cosmjs/amino": "^0.26.5",
44-
"@cosmjs/crypto": "^0.26.5",
45-
"@cosmjs/encoding": "^0.26.5",
46-
"@cosmjs/math": "^0.26.5",
47-
"@cosmjs/proto-signing": "^0.26.5",
48-
"@cosmjs/stargate": "^0.26.5",
49-
"@cosmjs/tendermint-rpc": "^0.26.5",
50-
"@cosmjs/utils": "^0.26.5",
43+
"@cosmjs/amino": "^0.26.8",
44+
"@cosmjs/crypto": "^0.26.8",
45+
"@cosmjs/encoding": "^0.26.8",
46+
"@cosmjs/math": "^0.26.8",
47+
"@cosmjs/proto-signing": "^0.26.8",
48+
"@cosmjs/stargate": "^0.26.8",
49+
"@cosmjs/tendermint-rpc": "^0.26.8",
50+
"@cosmjs/utils": "^0.26.8",
5151
"@ledgerhq/hw-app-cosmos": "^6.11.2",
5252
"@ledgerhq/hw-transport": "^6.11.2",
5353
"@types/crypto-js": "^4.0.2",

src/messages/dfract/MsgDepositDfract.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ import { Coin } from '../../types';
44

55
export const MsgDepositDfractUrl = '/lum.network.dfract.MsgDepositDfract';
66

7-
export const BuildMsgDepositDfract = (depositorAddress: string, amount: Coin, createdAt: Date): Message => {
7+
export const BuildMsgDepositDfract = (depositorAddress: string, amount: Coin): Message => {
88
return {
99
typeUrl: MsgDepositDfractUrl,
1010
value: {
1111
depositorAddress,
1212
amount,
13-
createdAt,
1413
} as MsgDepositDfract,
1514
};
1615
};

src/registry/aminoTypes.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { AminoConverter } from '@cosmjs/stargate';
2+
import { MsgDeposit as MsgDepositDfract } from '../codec/dfract/tx';
3+
import { AminoMsg, Coin } from '@cosmjs/amino';
4+
5+
export interface AminoMsgDepositDfract extends AminoMsg {
6+
readonly type: 'lum-network/MsgDepositDfract';
7+
readonly value: {
8+
readonly depositor_address: string;
9+
readonly amount?: Coin;
10+
};
11+
}
12+
13+
export function isAminoMsgSend(msg: AminoMsg): msg is AminoMsgDepositDfract {
14+
return msg.type === 'lum-network/MsgDepositDfract';
15+
}
16+
17+
export const createAdditionalAminoTypes = (): Record<string, AminoConverter> => {
18+
return {
19+
// DFract
20+
21+
'/lum.network.dfract.MsgDepositDfract': {
22+
aminoType: 'lum-network/MsgDepositDfract',
23+
toAmino: ({ depositorAddress, amount }: MsgDepositDfract): AminoMsgDepositDfract['value'] => ({
24+
depositor_address: depositorAddress,
25+
amount,
26+
}),
27+
fromAmino: ({ depositor_address, amount }: AminoMsgDepositDfract['value']): MsgDepositDfract => ({
28+
depositorAddress: depositor_address,
29+
amount,
30+
}),
31+
},
32+
};
33+
};

src/registry/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Registry, GeneratedType } from '@cosmjs/proto-signing';
22
import { AminoTypes } from '@cosmjs/stargate';
3+
import { createAdditionalAminoTypes } from './aminoTypes';
34

45
import { Tx } from '../codec/cosmos/tx/v1beta1/tx';
56
import { PubKey } from '../codec/cosmos/crypto/secp256k1/keys';
@@ -111,5 +112,5 @@ class ExtendedRegistry extends Registry {
111112
};
112113
}
113114

114-
export const LumAminoRegistry = new AminoTypes();
115+
export const LumAminoRegistry = new AminoTypes(createAdditionalAminoTypes());
115116
export const LumRegistry = new ExtendedRegistry(registryTypes);

0 commit comments

Comments
 (0)