forked from MergeFi/backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstellar-sdk.mock.js
More file actions
73 lines (69 loc) · 1.72 KB
/
Copy pathstellar-sdk.mock.js
File metadata and controls
73 lines (69 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Lightweight Jest manual mock for @stellar/stellar-sdk.
//
// The real package ships nested ESM-only dependencies (@noble/hashes,
// uint8array-extras, etc.) that Jest's CommonJS transform can't parse
// without a much heavier babel/ESM setup. None of our unit tests exercise
// the real Stellar network — SorobanClientService itself is always mocked
// at the DI boundary in tests — so we stub just enough of the surface for
// soroban-client.service.ts to import without throwing at module-load time.
class Contract {
call() {
return {};
}
}
class Address {
constructor(value) {
this.value = value;
}
toScVal() {
return this.value;
}
}
class Keypair {
static fromSecret() {
return { publicKey: () => 'MOCK_PUBLIC_KEY', sign: () => undefined };
}
}
class TransactionBuilder {
constructor() {}
addOperation() {
return this;
}
setTimeout() {
return this;
}
build() {
return { sign: () => undefined };
}
}
module.exports = {
Contract,
Address,
Keypair,
TransactionBuilder,
BASE_FEE: '100',
Networks: { TESTNET: 'Test SDF Network ; September 2015', PUBLIC: 'Public Global Stellar Network ; September 2015' },
nativeToScVal: (v) => v,
scValToNative: (v) => v,
rpc: {
Server: class Server {
async getAccount() {
return {};
}
async simulateTransaction() {
return {};
}
async sendTransaction() {
return { status: 'PENDING', hash: 'mock-hash' };
}
async getTransaction() {
return { status: 'SUCCESS', ledger: 1 };
}
},
Api: {
isSimulationError: () => false,
GetTransactionStatus: { NOT_FOUND: 'NOT_FOUND' },
},
assembleTransaction: (tx) => ({ build: () => tx }),
},
};