Skip to content

Commit

Permalink
Flow validation issue (#279)
Browse files Browse the repository at this point in the history
* FLow validation issue

* Upgrading the version

* Fixing build issue

* Build issue

* Updating version
  • Loading branch information
aanandmishra1804 authored Dec 20, 2021
1 parent 280083b commit 046d6d1
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tatumio/tatum",
"version": "1.30.2",
"version": "1.30.3",
"description": "Tatum API client allows browsers and Node.js clients to interact with Tatum API.",
"main": "dist/src/index.js",
"repository": "https://github.com/tatumio/tatum-js",
Expand Down
6 changes: 3 additions & 3 deletions src/model/request/FlowMnemonicOrPrivateKeyOrSignatureId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ export class FlowMnemonicOrPrivateKeyOrSignatureId {
public account: string;

@Length(1, 500)
@ValidateIf(o => (o.mnemonic && o.index >= 0 && o.privateKey) || (o.index >= 0 && o.privateKey))
@ValidateIf(o => (!o.signatureId && !o.privateKey) || o.mnemonic)
@IsNotEmpty()
public mnemonic?: string;

@ValidateIf(o => (o.mnemonic && o.index >= 0 && o.privateKey) || o.mnemonic)
@ValidateIf(o => ( o.mnemonic))
@Min(0)
@IsNotEmpty()
@IsInt()
@Max(2147483647)
public index?: number;

@ValidateIf(o => (o.mnemonic && o.index >= 0 && o.privateKey) || (!o.mnemonic && !o.signatureId && !o.index))
@ValidateIf(o => (!o.mnemonic &&!o.index && !o.privateKey))
@Length(64, 64)
@IsNotEmpty()
public privateKey?: string;
Expand Down
27 changes: 27 additions & 0 deletions src/transaction/flow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
sendFlowNftMintMultipleToken,
sendFlowNftMintToken
} from './flow';
import {validateBody} from '../connector/tatum'

describe('Flow tests', () => {

Expand Down Expand Up @@ -43,6 +44,32 @@ describe('Flow tests', () => {
() => getFlowSigner('44179e42e147b391d3deb8a7a160b9490941cd7292936e6cc7277166a99ef058', '0x4f09d8d43e4967b7').signer);
expect(result.txId).toBeDefined();
console.log(result);
});

it(' FLOW transaction validation mnomonic and index', async () => {
const body = new TransferFlow();
body.to = '0xbf4cacdb6ef17fa7';
body.amount = '0.114';
body.account = '0x2db1c763e6466c0c';
body.mnemonic= 'marriage favorite inject forward major beef upset victory tissue coil where grant else mean tag pipe naive leg material have blue execute spend chaos'
body.index = 1;
body.currency = Currency.FLOW;
const result = await validateBody(body, TransferFlow);
expect(true)

});

it(' FLOW transaction validation privatekey and index', async () => {
const body = new TransferFlow();
body.to = '0xbf4cacdb6ef17fa7';
body.amount = '0.114';
body.account = '0x2db1c763e6466c0c';
body.privateKey= 'deacb2978067c28a097549d37613a16b64c20ad04f300319cb601dbef0457824'
body.index = 1;
body.currency = Currency.FLOW;
await validateBody(body, TransferFlow);
expect(true);

});

it('should send FLOW API signer transaction', async () => {
Expand Down

0 comments on commit 046d6d1

Please sign in to comment.