Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support Terra Classic v1.1.0 #348

Merged
merged 1 commit into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ jobs:

steps:
- name: Begin CI...
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18

- name: Use cached node_modules
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: node_modules
key: nodeModules-${{ hashFiles('**/package-lock.json') }}
Expand Down
6,725 changes: 538 additions & 6,187 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@terra-money/terra.js",
"version": "3.1.7",
"version": "3.1.8",
"description": "The JavaScript SDK for Terra",
"license": "MIT",
"author": "Terraform Labs, PTE.",
Expand Down Expand Up @@ -83,7 +83,7 @@
"webpack-cli": "^4.3.0"
},
"dependencies": {
"@terra-money/legacy.proto": "npm:@terra-money/terra.proto@^0.1.7",
"@classic-terra/terra.proto": "^1.1.0",
"@terra-money/terra.proto": "^2.1.0",
"axios": "^0.27.2",
"bech32": "^2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/client/lcd/APIRequester.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Axios, { AxiosInstance } from 'axios';
import { OrderBy as OrderBy_pb } from '@terra-money/legacy.proto/cosmos/tx/v1beta1/service';
import { OrderBy as OrderBy_pb } from '@terra-money/terra.proto/cosmos/tx/v1beta1/service';

export type APIParams = Record<string, string | number | null | undefined>;

Expand Down
11 changes: 3 additions & 8 deletions src/client/lcd/Wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { LCDClient } from './LCDClient';
import { Key } from '../../key';
import { CreateTxOptions } from '../lcd/api/TxAPI';
import { Tx } from '../../core/Tx';
import { SignMode as SignModeV1 } from '@terra-money/legacy.proto/cosmos/tx/signing/v1beta1/signing';
import { SignMode as SignModeV2 } from '@terra-money/terra.proto/cosmos/tx/signing/v1beta1/signing';
import { SignMode } from '@terra-money/terra.proto/cosmos/tx/signing/v1beta1/signing';

export class Wallet {
constructor(public lcd: LCDClient, public key: Key) {}
Expand Down Expand Up @@ -53,7 +52,7 @@ export class Wallet {
options: CreateTxOptions & {
sequence?: number;
accountNumber?: number;
signMode?: SignModeV1 | SignModeV2;
signMode?: SignMode;
}
): Promise<Tx> {
let accountNumber = options.accountNumber;
Expand All @@ -80,11 +79,7 @@ export class Wallet {
accountNumber,
sequence,
chainID: this.lcd.config.chainID,
signMode:
options.signMode ||
(this.lcd.config.isClassic
? SignModeV1.SIGN_MODE_DIRECT
: SignModeV2.SIGN_MODE_DIRECT),
signMode: options.signMode || SignMode.SIGN_MODE_DIRECT,
},
this.lcd.config.isClassic
);
Expand Down
2 changes: 1 addition & 1 deletion src/client/lcd/api/GovAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {

import { APIParams, Pagination, PaginationOptions } from '../APIRequester';
import { TxSearchResult } from './TxAPI';
import { ProposalStatus } from '@terra-money/legacy.proto/cosmos/gov/v1beta1/gov';
import { ProposalStatus } from '@terra-money/terra.proto/cosmos/gov/v1beta1/gov';
import { LCDClient } from '../LCDClient';

export interface GovParams {
Expand Down
6 changes: 3 additions & 3 deletions src/client/lcd/api/IbcAPI.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ describe('IbcClientAPI', () => {
*/

it('channels', async () => {
const [res, _] = await ibc.channels();
const [res] = await ibc.channels();
expect(res).not.toBeNull();
expect(res).not.toBeUndefined();
expect(res.length).toBeGreaterThan(0);
});

it('channels for a connection', async () => {
const [res, height, _] = await ibc.connectionChannels('connection-3');
const [res, height] = await ibc.connectionChannels('connection-3');
expect(res).not.toBeNull();
expect(res).not.toBeUndefined();
expect(height).not.toBeNull();
Expand All @@ -79,7 +79,7 @@ describe('IbcClientAPI', () => {
});

it('connections', async () => {
const [res, _] = await ibc.connections();
const [res] = await ibc.connections();
expect(res).not.toBeNull();
expect(res).not.toBeUndefined();
expect(res.length).toBeGreaterThan(0);
Expand Down
1 change: 0 additions & 1 deletion src/client/lcd/api/IbcTransferAPI.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { BaseAPI } from './BaseAPI';
import { APIParams, Pagination, PaginationOptions } from '../APIRequester';
//import { DenomTrace } from '@terra-money/legacy.proto/ibc/applications/transfer/v1/query'
import { DenomTrace } from '../../../core/ibc/applications/transfer/v1/DenomTrace';
import { LCDClient } from '../LCDClient';

Expand Down
2 changes: 1 addition & 1 deletion src/client/lcd/api/StakingAPI.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const checkDelegations = (delegations: Delegation[]) => {
// };

const delegator = test1.accAddress;
const validator = 'terravaloper1gtw2uxdkdt3tvq790ckjz8jm8qgwkdw3uptstn';
const validator = 'terravaloper1q8w4u2wyhx574m70gwe8km5za2ptanny9mnqy3';

describe('StakingAPI', () => {
it('parameters', async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/client/lcd/api/TendermintAPI.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TendermintAPI } from './TendermintAPI';
import { Tx } from '../../../core/Tx';
import { Tx as Tx_pb } from '@terra-money/legacy.proto/cosmos/tx/v1beta1/tx';
import { Tx as Tx_pb } from '@terra-money/terra.proto/cosmos/tx/v1beta1/tx';
import { LCDClient } from '../LCDClient';

const terra = new LCDClient({
Expand Down
1 change: 1 addition & 0 deletions src/client/lcd/api/TreasuryAPI.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ describe('TreasuryAPI', () => {
window_short: expect.any(Number),
window_long: expect.any(Number),
window_probation: expect.any(Number),
burn_tax_split: expect.any(Dec),
});
}
});
Expand Down
7 changes: 7 additions & 0 deletions src/client/lcd/api/TreasuryAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ export interface TreasuryParams {
* Number of epochs defining the probationary period after genesis, during which monetary policy levers Tax Rate and Reward Weight do not change.
*/
window_probation: number;

/**
* Factor that determines how much tax will be allocated to the community pool
*/
burn_tax_split: Dec;
}

export namespace TreasuryParams {
Expand All @@ -49,6 +54,7 @@ export namespace TreasuryParams {
window_short: string;
window_long: string;
window_probation: string;
burn_tax_split: string;
}
}
export class TreasuryAPI extends BaseAPI {
Expand Down Expand Up @@ -178,6 +184,7 @@ export class TreasuryAPI extends BaseAPI {
window_long: Number.parseInt(d.window_long),
window_short: Number.parseInt(d.window_short),
window_probation: Number.parseInt(d.window_probation),
burn_tax_split: new Dec(d.burn_tax_split),
}));
}
}
5 changes: 2 additions & 3 deletions src/client/lcd/api/TxAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import { hashToHex } from '../../../util/hash';
import { LCDClient } from '../LCDClient';
import { TxLog } from '../../../core';
import { APIParams, Pagination, PaginationOptions } from '../APIRequester';
import { BroadcastMode as BroadcastModeV1 } from '@terra-money/legacy.proto/cosmos/tx/v1beta1/service';
import { BroadcastMode as BroadcastModeV2 } from '@terra-money/terra.proto/cosmos/tx/v1beta1/service';
import { BroadcastMode } from '@terra-money/terra.proto/cosmos/tx/v1beta1/service';

interface Wait {
height: number;
Expand Down Expand Up @@ -400,7 +399,7 @@ export class TxAPI extends BaseAPI {

private async _broadcast<T>(
tx: Tx,
mode: keyof typeof BroadcastModeV1 | BroadcastModeV2
mode: keyof typeof BroadcastMode
): Promise<T> {
return await this.c.post<any>(`/cosmos/tx/v1beta1/txs`, {
tx_bytes: this.encode(tx),
Expand Down
5 changes: 2 additions & 3 deletions src/client/lcd/api/UpgradeAPI.ts.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { BaseAPI } from './BaseAPI';
import { Coins, Plan } from '../../../core';
import { APIParams, Pagination, PaginationOptions } from '../APIRequester';
import { Plan } from '../../../core';
import { APIParams, PaginationOptions } from '../APIRequester';
import { LCDClient } from '../LCDClient';
import { publicEncrypt } from 'crypto';

export interface ModuleVersion {
name: string;
Expand Down
2 changes: 1 addition & 1 deletion src/client/lcd/api/WasmAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export class WasmAPI extends BaseAPI {
}

// new endpoint doesn't return init_msg so have to retrieve it from history
const [historyEntry, _] = await this.contractHistory(contractAddress);
const [historyEntry] = await this.contractHistory(contractAddress);

const endpoint = `/cosmwasm/wasm/v1/contract/${contractAddress}`;
return this.c
Expand Down
2 changes: 1 addition & 1 deletion src/core/auth/Account.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Any } from '@terra-money/legacy.proto/google/protobuf/any';
import { Any } from '@terra-money/terra.proto/google/protobuf/any';
import { BaseAccount } from './BaseAccount';
import { LazyGradedVestingAccount } from './LazyGradedVestingAccount';
import { ContinuousVestingAccount } from './ContinuousVestingAccount';
Expand Down
2 changes: 0 additions & 2 deletions src/core/auth/BaseAccount.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { PublicKey } from '../PublicKey';
import { JSONSerializable } from '../../util/json';
import { AccAddress } from '../bech32';
// import { BaseAccount as BaseAccount_pb } from '@terra-money/legacy.proto/cosmos/auth/v1beta1/auth';
// import { Any } from '@terra-money/legacy.proto/google/protobuf/any';
import { BaseAccount as BaseAccount_pb } from '@terra-money/terra.proto/cosmos/auth/v1beta1/auth';
import { Any } from '@terra-money/terra.proto/google/protobuf/any';
import * as Long from 'long';
Expand Down
6 changes: 3 additions & 3 deletions src/core/auth/LazyGradedVestingAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { Denom } from '../Denom';
import { JSONSerializable } from '../../util/json';
import { BaseVestingAccount } from './BaseVestingAccount';
import { Dec } from '../numeric';
import { BaseVestingAccount as BaseVestingAccount_pb } from '@terra-money/legacy.proto/cosmos/vesting/v1beta1/vesting';
import { BaseVestingAccount as BaseVestingAccount_pb } from '@classic-terra/terra.proto/cosmos/vesting/v1beta1/vesting';
import {
LazyGradedVestingAccount as LazyGradedVestingAccount_pb,
Schedule as Schedule_pb,
VestingSchedule as VestingSchedule_pb,
} from '@terra-money/legacy.proto/terra/vesting/v1beta1/vesting';
import { Any } from '@terra-money/legacy.proto/google/protobuf/any';
} from '@classic-terra/terra.proto/terra/vesting/v1beta1/vesting';
import { Any } from '@terra-money/terra.proto/google/protobuf/any';
import * as Long from 'long';
import { PublicKey } from '../PublicKey';

Expand Down
4 changes: 1 addition & 3 deletions src/core/bank/msgs/MsgMultiSend.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { JSONSerializable } from '../../../util/json';
import { Coins } from '../../Coins';
import { AccAddress } from '../../bech32';
import { Any } from '@terra-money/legacy.proto/google/protobuf/any';
// there's no difference between two protos
//import { MsgMultiSend as MsgMultiSend_legacy_pb } from '@terra-money/legacy.proto/cosmos/bank/v1beta1/tx';
import { Any } from '@terra-money/terra.proto/google/protobuf/any';
import { MsgMultiSend as MsgMultiSend_pb } from '@terra-money/terra.proto/cosmos/bank/v1beta1/tx';
import {
Input as Input_pb,
Expand Down
4 changes: 1 addition & 3 deletions src/core/bank/msgs/MsgSend.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { Coins } from '../../Coins';
import { JSONSerializable } from '../../../util/json';
import { AccAddress } from '../../bech32';
import { Any } from '@terra-money/legacy.proto/google/protobuf/any';
// there's no difference between two protos
//import { MsgSend as MsgSend_legacy_pb } from '@terra-money/legacy.proto/cosmos/bank/v1beta1/tx';
import { Any } from '@terra-money/terra.proto/google/protobuf/any';
import { MsgSend as MsgSend_pb } from '@terra-money/terra.proto/cosmos/bank/v1beta1/tx';

/**
Expand Down
3 changes: 1 addition & 2 deletions src/core/crisis/MsgVerifyInvariant.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { JSONSerializable } from '../../util/json';
import { Any } from '@terra-money/legacy.proto/google/protobuf/any';
//import { MsgVerifyInvariant as MsgVerifyInvariant_pb } from '@terra-money/legacy.proto/cosmos/crisis/v1beta1/tx';
import { Any } from '@terra-money/terra.proto/google/protobuf/any';
import { MsgVerifyInvariant as MsgVerifyInvariant_pb } from '@terra-money/terra.proto/cosmos/crisis/v1beta1/tx';
import { AccAddress } from '../bech32';

Expand Down
2 changes: 0 additions & 2 deletions src/core/distribution/msgs/MsgFundCommunityPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { JSONSerializable } from '../../../util/json';
import { AccAddress } from '../../bech32';
import { Coins } from '../../Coins';
import { Any } from '@terra-money/terra.proto/google/protobuf/any';
// there's no difference between two protos
// import { MsgFundCommunityPool as MsgFundCommunityPool_legacy_pb } from '@terra-money/legacy.proto/cosmos/distribution/v1beta1/tx';
import { MsgFundCommunityPool as MsgFundCommunityPool_pb } from '@terra-money/terra.proto/cosmos/distribution/v1beta1/tx';

export class MsgFundCommunityPool extends JSONSerializable<
Expand Down
2 changes: 0 additions & 2 deletions src/core/distribution/msgs/MsgSetWithdrawAddress.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { JSONSerializable } from '../../../util/json';
import { AccAddress } from '../../bech32';
import { Any } from '@terra-money/terra.proto/google/protobuf/any';
// there's no difference between two protos
// import { MsgSetWithdrawAddress as MsgSetWithdrawAddress_legacy_pb } from '@terra-money/legacy.proto/cosmos/distribution/v1beta1/tx';
import { MsgSetWithdrawAddress as MsgSetWithdrawAddress_pb } from '@terra-money/terra.proto/cosmos/distribution/v1beta1/tx';

/**
Expand Down
2 changes: 0 additions & 2 deletions src/core/distribution/msgs/MsgWithdrawDelegatorReward.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { JSONSerializable } from '../../../util/json';
import { AccAddress, ValAddress } from '../../bech32';
import { Any } from '@terra-money/terra.proto/google/protobuf/any';
// there's no difference between two protos
// import { MsgWithdrawDelegatorReward as MsgWithdrawDelegatorReward_legacy_pb } from '@terra-money/legacy.proto/cosmos/distribution/v1beta1/tx';
import { MsgWithdrawDelegatorReward as MsgWithdrawDelegatorReward_pb } from '@terra-money/terra.proto/cosmos/distribution/v1beta1/tx';

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { JSONSerializable } from '../../../util/json';
import { ValAddress } from '../../bech32';
import { Any } from '@terra-money/terra.proto/google/protobuf/any';
import { MsgWithdrawValidatorCommission as MsgWithdrawValidatorCommission_pb } from '@terra-money/legacy.proto/cosmos/distribution/v1beta1/tx';
import { MsgWithdrawValidatorCommission as MsgWithdrawValidatorCommission_pb } from '@terra-money/terra.proto/cosmos/distribution/v1beta1/tx';

/**
* A validator can withdraw their outstanding commission rewards accrued from all
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { JSONSerializable } from '../../../util/json';
import { Coins } from '../../Coins';
import { AccAddress } from '../../bech32';
import { Any } from '@terra-money/legacy.proto/google/protobuf/any';
// there's no difference between two protos
// import { CommunityPoolSpendProposal as CommunityPoolSpendProposal_legacy_pb } from '@terra-money/legacy.proto/cosmos/distribution/v1beta1/distribution';
import { Any } from '@terra-money/terra.proto/google/protobuf/any';
import { CommunityPoolSpendProposal as CommunityPoolSpendProposal_pb } from '@terra-money/terra.proto/cosmos/distribution/v1beta1/distribution';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/core/feegrant/allowances/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { AllowedMsgAllowance } from './AllowedMsgAllowance';
export * from './BasicAllowance';
export * from './PeriodicAllowance';
export * from './AllowedMsgAllowance';
import { Any } from '@terra-money/legacy.proto/google/protobuf/any';
import { Any } from '@terra-money/terra.proto/google/protobuf/any';

export type Allowance =
| BasicAllowance
Expand Down
Loading