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

Revert ledger bug fix #56

Merged
merged 5 commits into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,5 @@
"ts-jest": "^26.4.4",
"typescript": "^4.0.5"
},
"resolutions": {
"@cosmjs/amino@0.28.13": "npm:@regen-network/cosmjs-amino@0.28.13-regen-4"
},
"packageManager": "yarn@3.2.3"
}
3 changes: 0 additions & 3 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,5 @@
"jest": "26.6.0",
"rimraf": "^3.0.2",
"ts-jest": "^26.4.4"
},
"resolutions": {
"@cosmjs/amino@0.28.13": "npm:@regen-network/cosmjs-amino@0.28.13-regen-4"
}
}
30 changes: 19 additions & 11 deletions packages/api/src/tx/modules/ecocredit/basket/v1/create_amino.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const msgCreateAminoType = 'regen.basket/MsgCreate';
export const createTypeUrl = '/' + MsgCreate.$type;

export interface AminoDateCriteria {
$type: DateCriteria['$type'];
min_start_date?: Date;
start_date_window?: Duration;
years_in_the_past?: number;
Expand Down Expand Up @@ -55,11 +56,15 @@ export function createBasketConverter(): AminoConverter {
disable_auto_retire: disableAutoRetire || undefined,
credit_type_abbrev: creditTypeAbbrev,
allowed_classes: allowedClasses,
date_criteria: {
min_start_date: dateCriteria?.minStartDate || undefined,
start_date_window: dateCriteria?.startDateWindow || undefined,
years_in_the_past: dateCriteria?.yearsInThePast || undefined,
},
date_criteria:
dateCriteria === undefined
? undefined
: {
$type: dateCriteria.$type,
min_start_date: dateCriteria?.minStartDate || undefined,
start_date_window: dateCriteria?.startDateWindow || undefined,
years_in_the_past: dateCriteria?.yearsInThePast || undefined,
},
fee:
fee &&
fee.map(f => {
Expand Down Expand Up @@ -89,12 +94,15 @@ export function createBasketConverter(): AminoConverter {
disableAutoRetire: disable_auto_retire,
creditTypeAbbrev: credit_type_abbrev,
allowedClasses: allowed_classes,
dateCriteria: {
$type: DateCriteria.$type,
minStartDate: date_criteria?.min_start_date,
startDateWindow: date_criteria?.start_date_window,
yearsInThePast: date_criteria?.years_in_the_past || 0,
},
dateCriteria:
date_criteria === undefined
? undefined
: {
$type: date_criteria.$type,
minStartDate: date_criteria?.min_start_date,
startDateWindow: date_criteria?.start_date_window,
yearsInThePast: date_criteria?.years_in_the_past || 0,
},
fee: fee.map(f => {
return {
$type: 'cosmos.base.v1beta1.Coin',
Expand Down
4 changes: 3 additions & 1 deletion packages/api/src/tx/modules/ecocredit/basket/v1/put_amino.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const msgPutAminoType = 'regen.basket/MsgPut';
export const putTypeUrl = '/' + MsgPut.$type;

export interface AminoBasketCredit {
$type: BasketCredit['$type'];
batch_denom: string;
amount: string;
}
Expand Down Expand Up @@ -38,6 +39,7 @@ export function putConverter(): AminoConverter {
basket_denom: basketDenom,
credits: credits.map(c => {
return {
$type: c.$type,
batch_denom: c.batchDenom,
amount: c.amount,
};
Expand All @@ -54,7 +56,7 @@ export function putConverter(): AminoConverter {
basketDenom: basket_denom,
credits: credits.map(credit => {
return {
$type: BasketCredit.$type,
$type: credit.$type,
batchDenom: credit.batch_denom,
amount: credit.amount,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const msgBuyDirectAmnioType = 'regen.marketplace/MsgBuyDirect';
export const buyDirectTypeUrl = '/' + MsgBuyDirect.$type;

interface AminoBuyDirect_Order {
$type: MsgBuyDirect_Order['$type'];
sell_order_id?: string;
quantity?: string;
bid_price?: AminoCoin;
Expand Down Expand Up @@ -40,6 +41,7 @@ export function buyDirectConverter(): AminoConverter {
buyer,
orders: orders.map(b => {
return {
$type: b.$type,
sell_order_id: omitDefault(b.sellOrderId)?.toString(),
quantity: omitDefault(b.quantity),
bid_price: {
Expand All @@ -60,7 +62,7 @@ export function buyDirectConverter(): AminoConverter {
buyer,
orders: orders.map(b => {
return {
$type: MsgBuyDirect_Order.$type,
$type: b.$type,
sellOrderId: longify(b.sell_order_id || 0),
quantity: b.quantity || '0',
bidPrice: b.bid_price && {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const msgSellAminoType = 'regen.marketplace/MsgSell';
export const sellTypeUrl = '/' + MsgSell.$type;

interface AminoSell_Order {
$type: MsgSell_Order['$type'];
batch_denom: string;
quantity: string;
ask_price?: AminoCoin;
Expand Down Expand Up @@ -43,6 +44,7 @@ export function sellConverter(): AminoConverter {
seller,
orders: orders.map(o => {
return {
$type: o.$type,
batch_denom: o.batchDenom,
quantity: o.quantity,
ask_price: {
Expand All @@ -63,7 +65,7 @@ export function sellConverter(): AminoConverter {
seller,
orders: orders.map(o => {
return {
$type: MsgSell_Order.$type,
$type: o.$type,
batchDenom: o.batch_denom,
quantity: o.quantity,
askPrice: o.ask_price && {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const msgUpdateSellOrdersAminoType = 'regen.marketplace/MsgUpdateSellOrders';
export const updateSellOrdersTypeUrl = '/' + MsgUpdateSellOrders.$type;

interface AminoMsgUpdateSellOrders_Update {
$type: MsgUpdateSellOrders_Update['$type'];
sell_order_id: Long;
new_quantity: string;
new_ask_price?: AminoCoin;
Expand Down Expand Up @@ -42,6 +43,7 @@ export function updateSellOrderConverter(): AminoConverter {
seller,
updates: updates.map(u => {
return {
$type: u.$type,
sell_order_id: u.sellOrderId,
new_quantity: u.newQuantity,
new_ask_price: u.newAskPrice,
Expand All @@ -59,7 +61,7 @@ export function updateSellOrderConverter(): AminoConverter {
seller,
updates: updates.map(u => {
return {
$type: MsgUpdateSellOrders_Update.$type,
$type: u.$type,
sellOrderId: u.sell_order_id,
newQuantity: u.new_quantity,
newAskPrice: u.new_ask_price && {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ const msgCreateBatchAminoType = 'regen.core/MsgCreateBatch';
export const createBatchTypeUrl = '/' + MsgCreateBatch.$type;

export interface AminoBatchIssuance {
$type: BatchIssuance['$type'];
recipient?: string;
tradable_amount?: string;
retired_amount?: string;
retirement_jurisdiction?: string;
}

export interface AminoOriginTx {
$type: OriginTx['$type'];
id?: string;
source?: string;
contract?: string;
Expand Down Expand Up @@ -63,6 +65,7 @@ export function createBatchConverter(): AminoConverter {
project_id: projectId,
issuance: issuance.map(i => {
return {
$type: i.$type,
recipient: i.recipient || undefined,
tradable_amount: i.tradableAmount || undefined,
retired_amount: i.retiredAmount || undefined,
Expand All @@ -77,6 +80,8 @@ export function createBatchConverter(): AminoConverter {
originTx === undefined
? undefined
: {
// we should double check this edge case
$type: originTx.$type,
id: originTx?.id || undefined,
source: originTx?.source || undefined,
contract: originTx?.contract || undefined,
Expand All @@ -103,7 +108,7 @@ export function createBatchConverter(): AminoConverter {
projectId: project_id,
issuance: issuance.map(i => {
return {
$type: BatchIssuance.$type,
$type: i.$type,
recipient: i.recipient || '',
tradableAmount: i.tradable_amount || '',
retiredAmount: i.retired_amount || '',
Expand All @@ -118,7 +123,7 @@ export function createBatchConverter(): AminoConverter {
origin_tx === undefined
? undefined
: {
$type: OriginTx.$type,
$type: origin_tx.$type,
id: origin_tx.id || '',
source: origin_tx.source || '',
contract: origin_tx.contract || '',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { AminoMsg } from '@cosmjs/amino';
import { AminoConverter } from '@cosmjs/stargate';
import { MsgMintBatchCredits } from '../../../../generated/regen/ecocredit/v1/tx';
import {
BatchIssuance,
OriginTx,
} from '../../../../generated/regen/ecocredit/v1/types';
import { AminoBatchIssuance, AminoOriginTx } from './create_batch_amino';

const msgMintBatchCreditsAminoType = 'regen.core/MsgMintBatchCredits';
Expand Down Expand Up @@ -41,13 +37,15 @@ export function mintBatchCreditsConverter(): AminoConverter {
batch_denom: batchDenom,
issuance: issuance.map(i => {
return {
$type: i.$type,
recipient: i.recipient,
tradable_amount: i.tradableAmount,
retired_amount: i.retiredAmount,
retirement_jurisdiction: i.retirementJurisdiction,
};
}),
origin_tx: originTx && {
$type: originTx?.$type,
id: originTx?.id,
source: originTx?.source,
},
Expand All @@ -64,15 +62,15 @@ export function mintBatchCreditsConverter(): AminoConverter {
batchDenom: batch_denom,
issuance: issuance.map(i => {
return {
$type: BatchIssuance.$type,
$type: i.$type,
recipient: i.recipient || '',
tradableAmount: i.tradable_amount || '',
retiredAmount: i.retired_amount || '',
retirementJurisdiction: i.retirement_jurisdiction || '',
};
}),
originTx: origin_tx && {
$type: OriginTx.$type,
$type: origin_tx.$type,
id: origin_tx.id || '',
source: origin_tx.source || '',
contract: origin_tx.contract || '',
Expand Down
4 changes: 3 additions & 1 deletion packages/api/src/tx/modules/ecocredit/v1/msg_cancel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const msgCancelAminoType = 'regen.core/MsgCancel';
export const cancelTypeUrl = '/' + MsgCancel.$type;

export interface AminoCredits {
$type: Credits['$type'];
batch_denom: string;
amount: string;
}
Expand Down Expand Up @@ -37,6 +38,7 @@ export function cancelConverter(): AminoConverter {
owner,
credits: credits.map(credit => {
return {
$type: credit.$type,
batch_denom: credit.batchDenom,
amount: credit.amount,
};
Expand All @@ -53,7 +55,7 @@ export function cancelConverter(): AminoConverter {
owner,
credits: credits.map(credit => {
return {
$type: Credits.$type,
$type: credit.$type,
batchDenom: credit.batch_denom,
amount: credit.amount,
};
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/tx/modules/ecocredit/v1/retire_amino.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export function retireAminoConverter(): AminoConverter {
owner,
credits: credits.map(credit => {
return {
$type: credit.$type,
batch_denom: credit.batchDenom,
amount: credit.amount,
};
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/tx/modules/ecocredit/v1/send_amino.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface AminoMsgSend_SendCredits {
export interface AminoMsgSend extends AminoMsg {
readonly type: typeof msgSendAminoType;
readonly value: {
// readonly $type: string; TODO: we will leave these off until nested types can be supported
// readonly $type: string; TODO: we will leave these off until nested types cna be supported
readonly sender: string;
readonly recipient: string;
readonly credits: AminoMsgSend_SendCredits[];
Expand Down Expand Up @@ -62,7 +62,7 @@ export function ecocreditSendConverter(): AminoConverter {
recipient,
credits: credits?.map(credit => {
return {
$type: MsgSend_SendCredits.$type,
$type: MsgSend_SendCredits['$type'],
batchDenom: credit.batch_denom,
tradableAmount: credit.tradable_amount || '',
retiredAmount: credit.retired_amount || '',
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1834,15 +1834,15 @@ __metadata:
languageName: node
linkType: hard

"@cosmjs/amino@npm:@regen-network/cosmjs-amino@0.28.13-regen-4":
version: 0.28.13-regen-4
resolution: "@regen-network/cosmjs-amino@npm:0.28.13-regen-4"
"@cosmjs/amino@npm:0.28.13":
version: 0.28.13
resolution: "@cosmjs/amino@npm:0.28.13"
dependencies:
"@cosmjs/crypto": 0.28.13
"@cosmjs/encoding": 0.28.13
"@cosmjs/math": 0.28.13
"@cosmjs/utils": 0.28.13
checksum: e7dc958024d5206229285314632eae50bda30a451858cf264b8e686a2510a0f4841fb2ca4d6ce57f60b3d18a957a2192e9fd5cd24308bba18d0e9c4988e44174
checksum: 74430f975725beed9928913fb8834b6798515702bf2bf14c4ef9ec68ac1326a32959fb023c4398a48f9e0715cb03b10e7782bab38389f73aa9feb9a48f26dd67
languageName: node
linkType: hard

Expand Down Expand Up @@ -3971,7 +3971,7 @@ __metadata:
languageName: node
linkType: hard

"@regen-network/api@^0.4.0-alpha1.3, @regen-network/api@workspace:packages/api":
"@regen-network/api@^0.4.0-alpha1.4, @regen-network/api@workspace:packages/api":
version: 0.0.0-use.local
resolution: "@regen-network/api@workspace:packages/api"
dependencies:
Expand All @@ -3990,7 +3990,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@regen-network/demo-app@workspace:packages/demo-app"
dependencies:
"@regen-network/api": ^0.4.0-alpha1.3
"@regen-network/api": ^0.4.0-alpha1.4
"@testing-library/jest-dom": ^5.11.8
"@testing-library/react": ^11.2.2
"@testing-library/user-event": ^12.6.0
Expand Down