Skip to content

Commit

Permalink
Apply changes from gov proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
joon9823 committed Jan 11, 2024
1 parent 2c4bf66 commit 3503062
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 22 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@initia/initia.js",
"version": "0.1.25",
"version": "0.1.26",
"description": "The JavaScript SDK for Initia",
"license": "MIT",
"author": "InitiaLabs",
Expand Down Expand Up @@ -85,7 +85,7 @@
"webpack-cli": "^4.10.0"
},
"dependencies": {
"@initia/initia.proto": "^0.1.21",
"@initia/initia.proto": "^0.1.22",
"@initia/opinit.proto": "^0.0.2",
"@ledgerhq/hw-transport": "^6.27.12",
"@ledgerhq/hw-transport-webhid": "^6.27.12",
Expand Down
15 changes: 2 additions & 13 deletions src/client/lcd/api/GovAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class GovAPI extends BaseAPI {
.get<{
proposals: Proposal.Data[];
pagination: Pagination;
}>(`/cosmos/gov/v1/proposals`, params)
}>(`/initia/gov/v1/proposals`, params)
.then(d => [d.proposals.map(Proposal.fromData), d.pagination]);
}

Expand All @@ -27,7 +27,7 @@ export class GovAPI extends BaseAPI {
): Promise<Proposal> {
return this.c
.get<{ proposal: Proposal.Data }>(
`/cosmos/gov/v1/proposals/${proposalId}`,
`/initia/gov/v1/proposals/${proposalId}`,
params
)
.then(d => Proposal.fromData(d.proposal));
Expand Down Expand Up @@ -104,15 +104,4 @@ export class GovAPI extends BaseAPI {
d.pagination,
]);
}

public async lastEmergencyProposalTallyTimestamp(
params: APIParams = {}
): Promise<Date> {
return this.c
.get<{ tally_timestamp: string }>(
`/initia/gov/v1/last_emergency_proposal_tally_timestamp`,
params
)
.then(d => new Date(d.tally_timestamp));
}
}
47 changes: 46 additions & 1 deletion src/core/gov/proposals/Proposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { num } from '../../num';
import { AccAddress } from '../../bech32';
import { Msg } from '../../Msg';
import {
Proposal as Proposal_pb,
ProposalStatus,
TallyResult,
proposalStatusFromJSON,
proposalStatusToJSON,
} from '@initia/initia.proto/cosmos/gov/v1/gov';
import { Proposal as Proposal_pb } from '@initia/initia.proto/initia/gov/v1/gov';
import Long from 'long';

/**
Expand All @@ -33,11 +33,14 @@ export class Proposal extends JSONSerializable<
* @param total_deposit the total deposit on the proposal
* @param voting_start_time the starting time to vote on a proposal
* @param voting_end_time the end time of voting on a proposal
* @param emergency_start_time
* @param emergency_next_tally_time
* @param metadata any arbitrary metadata attached to the proposal
* @param title title of the proposal
* @param summary short summary of the proposal
* @param proposer the address of the proposal sumbitter
* @param expedited if the proposal is expedited
* @param emergency
* @param failed_reason the reason why the proposal failed
*/
constructor(
Expand All @@ -50,11 +53,14 @@ export class Proposal extends JSONSerializable<
total_deposit: Coins.Input,
public voting_start_time: Date,
public voting_end_time: Date,
public emergency_start_time: Date,
public emergency_next_tally_time: Date,
public metadata: string,
public title: string,
public summary: string,
public proposer: AccAddress,
public expedited: boolean,
public emergency: boolean,
public failed_reason: string
) {
super();
Expand All @@ -72,11 +78,14 @@ export class Proposal extends JSONSerializable<
total_deposit,
voting_start_time,
voting_end_time,
emergency_start_time,
emergency_next_tally_time,
metadata,
title,
summary,
proposer,
expedited,
emergency,
failed_reason,
} = data;

Expand All @@ -97,11 +106,14 @@ export class Proposal extends JSONSerializable<
Coins.fromAmino(total_deposit),
new Date(voting_start_time),
new Date(voting_end_time),
new Date(emergency_start_time),
new Date(emergency_next_tally_time),
metadata,
title,
summary,
proposer,
expedited,
emergency,
failed_reason
);
}
Expand All @@ -117,11 +129,14 @@ export class Proposal extends JSONSerializable<
total_deposit,
voting_start_time,
voting_end_time,
emergency_start_time,
emergency_next_tally_time,
metadata,
title,
summary,
proposer,
expedited,
emergency,
failed_reason,
} = this;

Expand All @@ -142,11 +157,14 @@ export class Proposal extends JSONSerializable<
total_deposit: total_deposit.toAmino(),
voting_start_time: voting_start_time.toISOString(),
voting_end_time: voting_end_time.toISOString(),
emergency_start_time: emergency_start_time.toISOString(),
emergency_next_tally_time: emergency_next_tally_time.toISOString(),
metadata,
title,
summary,
proposer,
expedited,
emergency,
failed_reason,
};
}
Expand All @@ -162,11 +180,14 @@ export class Proposal extends JSONSerializable<
total_deposit,
voting_start_time,
voting_end_time,
emergency_start_time,
emergency_next_tally_time,
metadata,
title,
summary,
proposer,
expedited,
emergency,
failed_reason,
} = data;

Expand All @@ -187,11 +208,14 @@ export class Proposal extends JSONSerializable<
Coins.fromData(total_deposit),
new Date(voting_start_time),
new Date(voting_end_time),
new Date(emergency_start_time),
new Date(emergency_next_tally_time),
metadata,
title,
summary,
proposer,
expedited,
emergency,
failed_reason
);
}
Expand All @@ -207,11 +231,14 @@ export class Proposal extends JSONSerializable<
total_deposit,
voting_start_time,
voting_end_time,
emergency_start_time,
emergency_next_tally_time,
metadata,
title,
summary,
proposer,
expedited,
emergency,
failed_reason,
} = this;

Expand All @@ -232,11 +259,14 @@ export class Proposal extends JSONSerializable<
total_deposit: total_deposit.toData(),
voting_start_time: voting_start_time.toISOString(),
voting_end_time: voting_end_time.toISOString(),
emergency_start_time: emergency_start_time.toISOString(),
emergency_next_tally_time: emergency_next_tally_time.toISOString(),
metadata,
title,
summary,
proposer,
expedited,
emergency,
failed_reason,
};
}
Expand All @@ -259,11 +289,14 @@ export class Proposal extends JSONSerializable<
Coins.fromProto(data.totalDeposit),
data.votingStartTime as Date,
data.votingEndTime as Date,
data.emergencyStartTime as Date,
data.emergencyNextTallyTime as Date,
data.metadata,
data.title,
data.summary,
data.proposer,
data.expedited,
data.emergency,
data.failedReason
);
}
Expand All @@ -279,11 +312,14 @@ export class Proposal extends JSONSerializable<
total_deposit,
voting_start_time,
voting_end_time,
emergency_start_time,
emergency_next_tally_time,
metadata,
title,
summary,
proposer,
expedited,
emergency,
failed_reason,
} = this;

Expand All @@ -307,11 +343,14 @@ export class Proposal extends JSONSerializable<
totalDeposit: total_deposit.toProto(),
votingStartTime: voting_start_time,
votingEndTime: voting_end_time,
emergencyStartTime: emergency_start_time,
emergencyNextTallyTime: emergency_next_tally_time,
metadata,
title,
summary,
proposer,
expedited,
emergency,
failedReason: failed_reason,
});
}
Expand Down Expand Up @@ -343,11 +382,14 @@ export namespace Proposal {
total_deposit: Coins.Amino;
voting_start_time: string;
voting_end_time: string;
emergency_start_time: string;
emergency_next_tally_time: string;
metadata: string;
title: string;
summary: string;
proposer: AccAddress;
expedited: boolean;
emergency: boolean;
failed_reason: string;
}

Expand All @@ -366,11 +408,14 @@ export namespace Proposal {
total_deposit: Coins.Data;
voting_start_time: string;
voting_end_time: string;
emergency_start_time: string;
emergency_next_tally_time: string;
metadata: string;
title: string;
summary: string;
proposer: AccAddress;
expedited: boolean;
emergency: boolean;
failed_reason: string;
}

Expand Down

0 comments on commit 3503062

Please sign in to comment.