UNPKG

stellar-plus

Version:

beta version of stellar-plus, an all-in-one sdk for the Stellar blockchain

81 lines (80 loc) 3.19 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.mockTransactionBuilder = exports.mockSecretAccount = exports.mockAccount = exports.MockSubmitTransaction = void 0; exports.mockHeader = mockHeader; exports.mockSignatureSchema = mockSignatureSchema; exports.mockAccountHandler = mockAccountHandler; exports.mockFeeBumpHeader = mockFeeBumpHeader; exports.mockTransactionInvocation = mockTransactionInvocation; const stellar_sdk_1 = require("@stellar/stellar-sdk"); exports.MockSubmitTransaction = { hash: 'hash', ledger: '1234', successful: true, envelope_xdr: 'envelope_xdr', result_xdr: 'result_xdr', result_meta_xdr: 'result_meta_xdr', paging_token: 'paging_token', }; exports.mockAccount = 'GBDMM7FQBVQPZFQPXVS3ZKK4UMELIWPBLG2BZQSWERD2KZR44WI6PTBQ'; exports.mockSecretAccount = 'SCA6IAHZA53NVVOYVUQQI3YCNVUUBNJ4WMNQHFLKI4AKPXFGCU5NCXOV'; function mockHeader(sourceKey = exports.mockAccount) { return { fee: '50', source: sourceKey, timeout: 500, }; } function mockSignatureSchema(threasholds, signers) { return { threasholds: threasholds || { low: 1, medium: 2, high: 3, }, signers: signers || [ { weight: 1, publicKey: exports.mockAccount, }, ], }; } function mockAccountHandler({ accountKey = 'mockAccount', outputSignedTransaction, outputSignedAuthEntry, signatureSchema, }) { return { sign: jest.fn().mockReturnValue(outputSignedTransaction !== null && outputSignedTransaction !== void 0 ? outputSignedTransaction : 'success'), signSorobanAuthEntry: jest.fn().mockReturnValue(outputSignedAuthEntry !== null && outputSignedAuthEntry !== void 0 ? outputSignedAuthEntry : stellar_sdk_1.xdr.SorobanAuthorizationEntry), getPublicKey: jest.fn().mockReturnValue(accountKey), signatureSchema, getBalances: jest.fn().mockReturnValue([]), initializeWithFriendbot: jest.fn(), }; } function mockFeeBumpHeader(signerKey = exports.mockAccount) { return { signers: [mockAccountHandler({ accountKey: signerKey })], header: mockHeader(signerKey), }; } function mockTransactionInvocation(signerKey = exports.mockAccount) { return { signers: [mockAccountHandler({ accountKey: signerKey })], header: mockHeader(signerKey), feeBump: mockFeeBumpHeader(signerKey), }; } exports.mockTransactionBuilder = { build: jest.fn().mockReturnValue('success'), addOperation: jest.fn().mockReturnValue({ addOperation: jest.fn().mockReturnValue({ addOperation: jest.fn().mockReturnValue(true), setTimeout: jest.fn().mockReturnValue({ build: jest.fn().mockReturnValue(true) }), build: jest.fn().mockReturnValue(true), payment: jest.fn().mockReturnValue(true), }), setTimeout: jest.fn().mockReturnValue({ build: jest.fn().mockReturnValue(true) }), build: jest.fn().mockReturnValue(true), payment: jest.fn().mockReturnValue(true), }), toXDR: jest.fn().mockReturnValue('success'), };