Skip to content

Commit

Permalink
Merge pull request #325 from terra-money/fix/decode
Browse files Browse the repository at this point in the history
fix decode()
  • Loading branch information
Vritra4 authored Aug 3, 2022
2 parents 44a836e + 150c18e commit 6291df9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/client/lcd/api/TxAPI.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,28 @@ const terra = new LCDClient({
URL: 'https://pisco-lcd.terra.dev',
});

const terraClassic = new LCDClient({
chainID: 'columbus-5',
URL: 'https://lcd.terra.dev',
});

const txAPI = new TxAPI(terra);
const wallet = terra.wallet(mk);

describe('TxAPI', () => {
describe('decode', () => {
it('classic', async () => {
terraClassic.tx.decode(
'CpUHCsgFCjIvdGVycmEub3JhY2xlLnYxYmV0YTEuTXNnQWdncmVnYXRlRXhjaGFuZ2VSYXRlVm90ZRKRBQoEYTBiMRKlBDAuMDAwMDAwMDAwMDAwMDAwMDAwdXVzZCwwLjAwMDAwMDAwMDAwMDAwMDAwMHVrcncsMC4wMDAwMDAwMDAwMDAwMDAwMDB1c2RyLDAuMDAwMDAwMDAwMDAwMDAwMDAwdW1udCwwLjAwMDAwMDAwMDAwMDAwMDAwMHVldXIsMC4wMDAwMDAwMDAwMDAwMDAwMDB1Z2JwLDAuMDAwMDAwMDAwMDAwMDAwMDAwdWNueSwwLjAwMDAwMDAwMDAwMDAwMDAwMHVqcHksMC4wMDAwMDAwMDAwMDAwMDAwMDB1aW5yLDAuMDAwMDAwMDAwMDAwMDAwMDAwdWNhZCwwLjAwMDAwMDAwMDAwMDAwMDAwMHVjaGYsMC4wMDAwMDAwMDAwMDAwMDAwMDB1aGtkLDAuMDAwMDAwMDAwMDAwMDAwMDAwdWF1ZCwwLjAwMDAwMDAwMDAwMDAwMDAwMHVzZ2QsMC4wMDAwMDAwMDAwMDAwMDAwMDB1dGhiLDAuMDAwMDAwMDAwMDAwMDAwMDAwdXNlaywwLjAwMDAwMDAwMDA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gkxMDQ3ODQwMDYSH2J5LiBodHRwczovL2dpdGh1Yi5jb20vZW1pZGV2OTgSagpSCkYKHy9jb3Ntb3MuY3J5cHRvLnNlY3AyNTZrMS5QdWJLZXkSIwohA+Q1ZNHkGfabYf1wRUdLcaJHlqDC62Llxam8fKgoH6mZEgQKAggBGJPWChIUCg4KBXVsdW5hEgUzNTk4MxCJ0g4aQOQgfKscECIN6Z6NtfWwEiZ2nxnnjdfZEVq4f2ypIm1QLY8Oo60Rfbe6Y10leA4bL5fPRHp8GC7d9hmrhtDVlXc='
);
});
});

describe('broadcast', () => {
beforeEach(() => {
// Need to respond to requests made by createAndSignTx.
Expand Down
5 changes: 4 additions & 1 deletion src/client/lcd/api/TxAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,10 @@ export class TxAPI extends BaseAPI {
* @param tx transaction string to decode
*/
public decode(encodedTx: string): Tx {
return Tx.fromBuffer(Buffer.from(encodedTx, 'base64'));
return Tx.fromBuffer(
Buffer.from(encodedTx, 'base64'),
this.lcd.config.isClassic
);
}

/**
Expand Down

0 comments on commit 6291df9

Please sign in to comment.