Skip to content

Commit

Permalink
feat(sdk-coin-osmo): allow amount in execute contract transaction
Browse files Browse the repository at this point in the history
Ticket: WIN-23
  • Loading branch information
dpkjnr committed Jul 19, 2023
1 parent 3782ce8 commit 44be383
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
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';
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

0 comments on commit 44be383

Please sign in to comment.