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(sdk-coin-osmo): allow amount in execute contract transaction #3726

Merged
merged 1 commit into from
Jul 19, 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
9 changes: 5 additions & 4 deletions modules/abstract-cosmos/src/lib/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,14 @@ export class CosmosTransaction extends BaseTransaction {
case TransactionType.ContractCall:
explanationResult.type = TransactionType.ContractCall;
message = json.sendMessages[0].value as ExecuteContractMessage;
outputAmount = message.funds?.[0]?.amount ?? '0';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what changed suddenly and could you add some description as well ? ticket doesn't indicate why this was needed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM. But yes +1 on the above comment.

outputs = [
{
address: message.contract,
amount: UNAVAILABLE_TEXT,
amount: outputAmount,
},
];
outputAmount = UNAVAILABLE_TEXT;
outputAmount = outputAmount;
break;
default:
throw new InvalidTransactionError('Transaction type not supported');
Expand Down Expand Up @@ -304,12 +305,12 @@ export class CosmosTransaction extends BaseTransaction {
const executeContractMessage = this.cosmosLikeTransaction.sendMessages[0].value as ExecuteContractMessage;
inputs.push({
address: executeContractMessage.sender,
value: UNAVAILABLE_TEXT,
value: executeContractMessage.funds?.[0]?.amount ?? '0',
coin: this._coinConfig.name,
});
outputs.push({
address: executeContractMessage.contract,
value: UNAVAILABLE_TEXT,
value: executeContractMessage.funds?.[0]?.amount ?? '0',
coin: this._coinConfig.name,
});
break;
Expand Down
6 changes: 3 additions & 3 deletions modules/sdk-coin-osmo/test/unit/osmo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ describe('OSMO', function () {
recipients: [
{
address: TEST_EXECUTE_CONTRACT_TRANSACTION.to,
amount: 'UNAVAILABLE',
amount: '0',
},
],
};
Expand Down Expand Up @@ -315,10 +315,10 @@ describe('OSMO', function () {
outputs: [
{
address: TEST_EXECUTE_CONTRACT_TRANSACTION.to,
amount: 'UNAVAILABLE',
amount: '0',
},
],
outputAmount: 'UNAVAILABLE',
outputAmount: '0',
changeOutputs: [],
changeAmount: '0',
fee: { fee: TEST_EXECUTE_CONTRACT_TRANSACTION.gasBudget.amount[0].amount },
Expand Down
9 changes: 4 additions & 5 deletions modules/sdk-coin-osmo/test/unit/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
ExecuteContractMessage,
SendMessage,
WithdrawDelegatorRewardsMessage,
CosmosConstants,
} from '@bitgo/abstract-cosmos';
import utils from '../../src/lib/utils';
import * as testData from '../resources/osmo';
Expand Down Expand Up @@ -217,14 +216,14 @@ describe('Osmo Transaction', () => {
should.deepEqual(tx.inputs, [
{
address: testData.TEST_EXECUTE_CONTRACT_TRANSACTION.from,
value: 'UNAVAILABLE',
value: '0',
coin: 'tosmo',
},
]);
should.deepEqual(tx.outputs, [
{
address: testData.TEST_EXECUTE_CONTRACT_TRANSACTION.to,
value: 'UNAVAILABLE',
value: '0',
coin: 'tosmo',
},
]);
Expand Down Expand Up @@ -272,10 +271,10 @@ describe('Osmo Transaction', () => {
outputs: [
{
address: testData.TEST_EXECUTE_CONTRACT_TRANSACTION.to,
amount: CosmosConstants.UNAVAILABLE_TEXT,
amount: '0',
},
],
outputAmount: CosmosConstants.UNAVAILABLE_TEXT,
outputAmount: '0',
changeOutputs: [],
changeAmount: '0',
fee: { fee: testData.TEST_EXECUTE_CONTRACT_TRANSACTION.feeAmount },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ describe('Osmo contract call txn Builder', () => {
should.deepEqual(tx.inputs, [
{
address: testTx.from,
value: 'UNAVAILABLE',
value: '0',
coin: basecoin.getChain(),
},
]);
should.deepEqual(tx.outputs, [
{
address: testTx.to,
value: 'UNAVAILABLE',
value: '0',
coin: basecoin.getChain(),
},
]);
Expand All @@ -72,14 +72,14 @@ describe('Osmo contract call txn Builder', () => {
should.deepEqual(tx.inputs, [
{
address: testTx.from,
value: 'UNAVAILABLE',
value: '0',
coin: basecoin.getChain(),
},
]);
should.deepEqual(tx.outputs, [
{
address: testTx.to,
value: 'UNAVAILABLE',
value: '0',
coin: basecoin.getChain(),
},
]);
Expand All @@ -106,14 +106,14 @@ describe('Osmo contract call txn Builder', () => {
should.deepEqual(tx.inputs, [
{
address: testTx.from,
value: 'UNAVAILABLE',
value: '0',
coin: basecoin.getChain(),
},
]);
should.deepEqual(tx.outputs, [
{
address: testTx.to,
value: 'UNAVAILABLE',
value: '0',
coin: basecoin.getChain(),
},
]);
Expand Down
Loading