@carrot-protocol/http-client 0.2.18 → 0.2.19-dummy-provider-dev-2484a98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare class Client {
|
|
|
4
4
|
readonly baseUrl: string;
|
|
5
5
|
readonly provider: anchor.AnchorProvider;
|
|
6
6
|
private headers;
|
|
7
|
-
constructor(baseUrl: string, provider
|
|
7
|
+
constructor(baseUrl: string, provider?: anchor.AnchorProvider);
|
|
8
8
|
index(): Promise<void>;
|
|
9
9
|
getVault(vault: anchor.web3.PublicKey, useCache: boolean): Promise<Vault>;
|
|
10
10
|
getVaultPerformance(vault: anchor.web3.PublicKey, useCache: boolean): Promise<VaultPerformance>;
|
package/dist/index.js
CHANGED
|
@@ -36,7 +36,13 @@ class Client {
|
|
|
36
36
|
constructor(baseUrl, provider) {
|
|
37
37
|
this.headers = { "Content-Type": "application/json" };
|
|
38
38
|
this.baseUrl = baseUrl;
|
|
39
|
-
|
|
39
|
+
if (provider) {
|
|
40
|
+
this.provider = provider;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
// if no provider is passed in, create a dummy provider, aka read only mode
|
|
44
|
+
this.provider = new anchor.AnchorProvider(new anchor.web3.Connection("http://localhost:8899", "processed"), new anchor.Wallet(anchor.web3.Keypair.generate()), {});
|
|
45
|
+
}
|
|
40
46
|
}
|
|
41
47
|
async index() {
|
|
42
48
|
const response = await (0, cross_fetch_1.default)(this.baseUrl);
|
|
@@ -56,7 +62,7 @@ class Client {
|
|
|
56
62
|
body.address = vault;
|
|
57
63
|
body.authority = new anchor.web3.PublicKey(body.authority);
|
|
58
64
|
body.shares = new anchor.web3.PublicKey(body.shares);
|
|
59
|
-
body.sharesSupply = new anchor.BN(body.sharesSupply.toString(10)
|
|
65
|
+
body.sharesSupply = new anchor.BN(body.sharesSupply.toString(10));
|
|
60
66
|
body.assets = body.assets.map((asset) => ({
|
|
61
67
|
...asset,
|
|
62
68
|
assetId: Number(asset.assetId),
|