Skip to content

Commit

Permalink
* Replace legacy.proto to terra.proto where terra.proto should be used.
Browse files Browse the repository at this point in the history
* Update protobuf package for Terra Classic, @terra-money/terra.proto@0.1.7, to @classic-terra/terra.proto@1.1.0
* Add burn_tax_split to treasury params
* Add AddBurnTaxExemptionAddressProposal and RemoveBurnTaxExemptionAddressProposal
* Update version of GitHub workflow in the deprecate state
  • Loading branch information
inon-man committed Feb 24, 2023
1 parent 168afed commit 637bf5d
Show file tree
Hide file tree
Showing 58 changed files with 1,173 additions and 6,354 deletions.
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,719 changes: 535 additions & 6,184 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
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
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
44 changes: 40 additions & 4 deletions src/core/gov/Proposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ import {
UpdateAdminProposal,
UpdateInstantiateConfigProposal,
} from '../wasm/proposals';
import {
AddBurnTaxExemptionAddressProposal,
RemoveBurnTaxExemptionAddressProposal,
} from '../treasury/proposals';
import {
Proposal as Proposal_pb,
ProposalStatus,
Expand Down Expand Up @@ -253,7 +257,9 @@ export namespace Proposal {
| SudoContractProposal
| UnpinCodesProposal
| UpdateAdminProposal
| UpdateInstantiateConfigProposal;
| UpdateInstantiateConfigProposal
| AddBurnTaxExemptionAddressProposal
| RemoveBurnTaxExemptionAddressProposal;

export namespace Content {
export type Amino =
Expand All @@ -272,7 +278,9 @@ export namespace Proposal {
| SudoContractProposal.Amino
| UnpinCodesProposal.Amino
| UpdateAdminProposal.Amino
| UpdateInstantiateConfigProposal.Amino;
| UpdateInstantiateConfigProposal.Amino
| AddBurnTaxExemptionAddressProposal.Amino
| RemoveBurnTaxExemptionAddressProposal.Amino;

export type Data =
| TextProposal.Data
Expand All @@ -290,7 +298,9 @@ export namespace Proposal {
| SudoContractProposal.Data
| UnpinCodesProposal.Data
| UpdateAdminProposal.Data
| UpdateInstantiateConfigProposal.Data;
| UpdateInstantiateConfigProposal.Data
| AddBurnTaxExemptionAddressProposal.Data
| RemoveBurnTaxExemptionAddressProposal.Data;

export type Proto =
| TextProposal.Proto
Expand All @@ -308,7 +318,9 @@ export namespace Proposal {
| SudoContractProposal.Proto
| UnpinCodesProposal.Proto
| UpdateAdminProposal.Proto
| UpdateInstantiateConfigProposal.Proto;
| UpdateInstantiateConfigProposal.Proto
| AddBurnTaxExemptionAddressProposal.Proto
| RemoveBurnTaxExemptionAddressProposal.Proto;

export function fromAmino(
amino: Proposal.Content.Amino,
Expand Down Expand Up @@ -352,6 +364,13 @@ export namespace Proposal {
return UpdateAdminProposal.fromAmino(amino, isClassic);
case 'wasm/UpdateInstantiateConfigProposal':
return UpdateInstantiateConfigProposal.fromAmino(amino, isClassic);
case 'treasury/AddBurnTaxExemptionAddressProposal':
return AddBurnTaxExemptionAddressProposal.fromAmino(amino, isClassic);
case 'treasury/RemoveBurnTaxExemptionAddressProposal':
return RemoveBurnTaxExemptionAddressProposal.fromAmino(
amino,
isClassic
);
}
}

Expand Down Expand Up @@ -392,6 +411,13 @@ export namespace Proposal {
return UpdateAdminProposal.fromData(data, isClassic);
case '/cosmwasm.wasm.v1.UpdateInstantiateConfigProposal':
return UpdateInstantiateConfigProposal.fromData(data, isClassic);
case '/terra.treasury.v1beta1.AddBurnTaxExemptionAddressProposal':
return AddBurnTaxExemptionAddressProposal.fromData(data, isClassic);
case '/terra.treasury.v1beta1.RemoveBurnTaxExemptionAddressProposal':
return RemoveBurnTaxExemptionAddressProposal.fromData(
data,
isClassic
);
}
}

Expand Down Expand Up @@ -433,6 +459,16 @@ export namespace Proposal {
return UpdateAdminProposal.unpackAny(anyProto, isClassic);
case '/cosmwasm.wasm.v1.UpdateInstantiateConfigProposal':
return UpdateInstantiateConfigProposal.unpackAny(anyProto, isClassic);
case '/terra.treasury.v1beta1.AddBurnTaxExemptionAddressProposal':
return AddBurnTaxExemptionAddressProposal.unpackAny(
anyProto,
isClassic
);
case '/terra.treasury.v1beta1.RemoveBurnTaxExemptionAddressProposal':
return RemoveBurnTaxExemptionAddressProposal.unpackAny(
anyProto,
isClassic
);
}

throw `Proposal content ${typeUrl} not recognized`;
Expand Down
2 changes: 1 addition & 1 deletion src/core/ibc/applications/transfer/v1/DenomTrace.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DenomTrace as DenomTrace_pb } from '@terra-money/legacy.proto/ibc/applications/transfer/v1/transfer';
import { DenomTrace as DenomTrace_pb } from '@terra-money/terra.proto/ibc/applications/transfer/v1/transfer';
import { JSONSerializable } from '../../../../../util/json';

/**
Expand Down
4 changes: 2 additions & 2 deletions src/core/market/msgs/MsgSwap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { JSONSerializable } from '../../../util/json';
import { Coin } from '../../Coin';
import { Denom } from '../../Denom';
import { AccAddress } from '../../bech32';
import { MsgSwap as MsgSwap_pb } from '@terra-money/legacy.proto/terra/market/v1beta1/tx';
import { Any } from '@terra-money/legacy.proto/google/protobuf/any';
import { MsgSwap as MsgSwap_pb } from '@classic-terra/terra.proto/terra/market/v1beta1/tx';
import { Any } from '@terra-money/terra.proto/google/protobuf/any';

/**
* Executes a market swap between 2 denominations at the exchange rate registered by the
Expand Down
Loading

0 comments on commit 637bf5d

Please sign in to comment.