Skip to content

Commit c365f7d

Browse files
authored
Merge pull request #21 from terra-money/feat/token/factory/models
feat: token factory models
2 parents 1b5358e + a7f2cb9 commit c365f7d

24 files changed

+970
-158
lines changed

.github/workflows/main.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ jobs:
99
uses: actions/checkout@v2
1010

1111
- name: Setup Node
12-
uses: actions/setup-node@v1
12+
uses: actions/setup-node@v3
1313
with:
14-
node-version: 16
14+
node-version: 18
1515

1616
- name: Use cached node_modules
1717
uses: actions/cache@v1
@@ -34,7 +34,12 @@ jobs:
3434
CI: true
3535

3636
- name: Test
37-
run: npm run test --ci --coverage --maxWorkers=2
37+
run: npm run test
38+
env:
39+
CI: true
40+
41+
- name: Upload coverage to Codecov
42+
uses: codecov/codecov-action@v3
3843
env:
3944
CI: true
4045

.github/workflows/npm-publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- uses: actions/checkout@v1
11-
- uses: actions/setup-node@v1
11+
- uses: actions/setup-node@v3
1212
with:
13-
node-version: 16
13+
node-version: 18
1414
- run: npm install
1515
- run: npm test
1616
- uses: JS-DevTools/npm-publish@v1

jest.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
module.exports = {
22
testEnvironment: 'node',
33
preset: 'ts-jest',
4+
collectCoverage: true,
5+
coverageReporters: ['text', 'cobertura'],
46
roots: ['<rootDir>/src'],
57
};

package-lock.json

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@terra-money/feather.js",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "The JavaScript SDK for Terra and Feather chains",
55
"license": "MIT",
66
"author": "Terraform Labs, PTE.",
@@ -26,7 +26,7 @@
2626
"dist"
2727
],
2828
"engines": {
29-
"node": ">=14"
29+
"node": ">=18"
3030
},
3131
"scripts": {
3232
"build": "tsc --module commonjs && webpack --mode production",
@@ -85,7 +85,7 @@
8585
},
8686
"dependencies": {
8787
"@terra-money/legacy.proto": "npm:@terra-money/terra.proto@^0.1.7",
88-
"@terra-money/terra.proto": "^2.2.0-beta.4",
88+
"@terra-money/terra.proto": "3.0.5",
8989
"axios": "^0.27.2",
9090
"bech32": "^2.0.0",
9191
"bip32": "^2.0.6",

src/client/lcd/api/AllianceAPI.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export interface AllianceParams {
1111

1212
/**
1313
* Last application of `take_rate` on assets
14-
* @format date-time
14+
* @format date-time from golang
1515
*/
1616
last_take_rate_claim_time?: string;
1717
}

src/core/Msg.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ import {
8888
import { MsgVerifyInvariant, CrisisMsg } from './crisis';
8989
import { Any } from '@terra-money/terra.proto/google/protobuf/any';
9090
import { MsgLiquidStake, MsgRedeemStake } from './stride/msgs';
91+
import { MsgCreateDenom } from './wasm/msgs/tokenfactory/MsgCreateDenom';
92+
import { MsgBurn } from './wasm/msgs/tokenfactory/MsgBurn';
93+
import { MsgChangeAdmin } from './wasm/msgs/tokenfactory/MsgChangeAdmin';
94+
import { MsgMint } from './wasm/msgs/tokenfactory/MsgMint';
9195

9296
export type Msg =
9397
| BankMsg
@@ -341,6 +345,14 @@ export namespace Msg {
341345
data as MsgClearContractAdmin.Amino,
342346
isClassic
343347
);
348+
case 'osmosis/tokenfactory/create-denom':
349+
return MsgCreateDenom.fromAmino(data as MsgCreateDenom.Amino);
350+
case 'osmosis/tokenfactory/burn':
351+
return MsgBurn.fromAmino(data as MsgBurn.Amino);
352+
case 'osmosis/tokenfactory/change-admin':
353+
return MsgChangeAdmin.fromAmino(data as MsgChangeAdmin.Amino);
354+
case 'osmosis/tokenfactory/mint':
355+
return MsgMint.fromAmino(data as MsgMint.Amino);
344356
// ibc-transfer
345357
case 'cosmos-sdk/MsgTransfer':
346358
return MsgTransfer.fromAmino(data as MsgTransfer.Amino, isClassic);
@@ -458,6 +470,14 @@ export namespace Msg {
458470
case '/terra.wasm.v1beta1.MsgClearContractAdmin':
459471
case '/cosmwasm.wasm.v1.MsgClearAdmin':
460472
return MsgClearContractAdmin.fromData(data, isClassic);
473+
case '/cosmwasm.tokenfactory.v1beta1.MsgCreateDenom':
474+
return MsgCreateDenom.fromData(data);
475+
case '/cosmwasm.tokenfactory.v1beta1.MsgBurn':
476+
return MsgBurn.fromData(data);
477+
case '/cosmwasm.tokenfactory.v1beta1.MsgChangeAdmin':
478+
return MsgChangeAdmin.fromData(data);
479+
case '/cosmwasm.tokenfactory.v1beta1.MsgMint':
480+
return MsgMint.fromData(data);
461481

462482
// ibc-transfer
463483
case '/ibc.applications.transfer.v1.MsgTransfer':
@@ -614,6 +634,14 @@ export namespace Msg {
614634
case '/terra.wasm.v1beta1.MsgClearContractAdmin':
615635
case '/cosmwasm.wasm.v1.MsgClearAdmin':
616636
return MsgClearContractAdmin.unpackAny(proto, isClassic);
637+
case '/cosmwasm.tokenfactory.v1beta1.MsgCreateDenom':
638+
return MsgCreateDenom.unpackAny(proto, isClassic);
639+
case '/cosmwasm.tokenfactory.v1beta1.MsgBurn':
640+
return MsgBurn.unpackAny(proto, isClassic);
641+
case '/cosmwasm.tokenfactory.v1beta1.MsgChangeAdmin':
642+
return MsgChangeAdmin.unpackAny(proto, isClassic);
643+
case '/cosmwasm.tokenfactory.v1beta1.MsgMint':
644+
return MsgMint.unpackAny(proto, isClassic);
617645

618646
// ibc-transfer
619647
case '/ibc.applications.transfer.v1.MsgTransfer':
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { MsgClaimDelegationRewards } from './MsgClaimDelegationRewards';
2+
3+
describe('MsgClaimDelegationRewards', () => {
4+
it('legacy deserializes MsgClaimDelegationRewards correctly', () => {
5+
const data: MsgClaimDelegationRewards.Amino = {
6+
type: 'alliance/MsgClaimDelegationRewards',
7+
value: {
8+
delegator_address: 'DelAddr',
9+
validator_address: 'ValAddr',
10+
denom: 'Denom',
11+
},
12+
};
13+
const acct = MsgClaimDelegationRewards.fromAmino(data);
14+
expect(acct).toMatchObject({
15+
delegator_address: 'DelAddr',
16+
validator_address: 'ValAddr',
17+
denom: 'Denom',
18+
});
19+
expect(acct.toAmino(true)).toMatchObject(data);
20+
});
21+
22+
it('match data interface with model MsgClaimDelegationRewards correctly', () => {
23+
const data: MsgClaimDelegationRewards.Data = {
24+
'@type': '/alliance.alliance.MsgClaimDelegationRewards',
25+
delegator_address: 'DelAddr',
26+
validator_address: 'ValAddr',
27+
denom: 'Denom',
28+
};
29+
const acct = MsgClaimDelegationRewards.fromData(data);
30+
expect(acct).toMatchObject(
31+
new MsgClaimDelegationRewards('DelAddr', 'ValAddr', 'Denom')
32+
);
33+
expect(acct.toData(true)).toMatchObject(data);
34+
});
35+
});
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { Coin } from '../../Coin';
2+
import { MsgDelegate } from './MsgDelegate';
3+
4+
describe('MsgDelegate', () => {
5+
it('legacy deserializes MsgDelegate correctly', () => {
6+
const data: MsgDelegate.Amino = {
7+
type: 'alliance/MsgDelegate',
8+
value: {
9+
delegator_address: 'DelAddr',
10+
validator_address: 'ValAddr',
11+
amount: new Coin('uluna', '10').toAmino(),
12+
},
13+
};
14+
const acct = MsgDelegate.fromAmino(data);
15+
expect(acct).toMatchObject({
16+
delegator_address: 'DelAddr',
17+
validator_address: 'ValAddr',
18+
amount: new Coin('uluna', '10'),
19+
});
20+
expect(acct.toAmino(true)).toMatchObject(data);
21+
});
22+
23+
it('match data interface with model MsgDelegate correctly', () => {
24+
const data: MsgDelegate.Data = {
25+
'@type': '/alliance.alliance.MsgDelegate',
26+
delegator_address: 'DelAddr',
27+
validator_address: 'ValAddr',
28+
amount: new Coin('uluna', '10').toData(),
29+
};
30+
const acct = MsgDelegate.fromData(data);
31+
expect(acct).toMatchObject(
32+
new MsgDelegate('DelAddr', 'ValAddr', new Coin('uluna', '10'))
33+
);
34+
expect(acct.toData(true)).toMatchObject(data);
35+
});
36+
});
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { Coin } from '../../Coin';
2+
import { MsgRedelegate } from './MsgRedelegate';
3+
4+
describe('MsgRedelegate', () => {
5+
it('legacy deserializes MsgRedelegate correctly', () => {
6+
const data: MsgRedelegate.Amino = {
7+
type: 'alliance/MsgRedelegate',
8+
value: {
9+
delegator_address: 'DelAddr',
10+
validator_src_address: 'ValAddr',
11+
validator_dst_address: 'Val1Addr',
12+
amount: new Coin('uluna', '10').toAmino(),
13+
},
14+
};
15+
const acct = MsgRedelegate.fromAmino(data);
16+
expect(acct).toMatchObject({
17+
delegator_address: 'DelAddr',
18+
validator_src_address: 'ValAddr',
19+
validator_dst_address: 'Val1Addr',
20+
amount: new Coin('uluna', '10'),
21+
});
22+
expect(acct.toAmino(true)).toMatchObject(data);
23+
});
24+
25+
it('match data interface with model MsgRedelegate correctly', () => {
26+
const data: MsgRedelegate.Data = {
27+
'@type': '/alliance.alliance.MsgRedelegate',
28+
delegator_address: 'DelAddr',
29+
validator_src_address: 'ValAddr',
30+
validator_dst_address: 'Val1Addr',
31+
amount: new Coin('uluna', '10').toData(),
32+
};
33+
const acct = MsgRedelegate.fromData(data);
34+
expect(acct).toMatchObject(
35+
new MsgRedelegate(
36+
'DelAddr',
37+
'ValAddr',
38+
'Val1Addr',
39+
new Coin('uluna', '10')
40+
)
41+
);
42+
expect(acct.toData(true)).toMatchObject(data);
43+
});
44+
});

0 commit comments

Comments
 (0)