Skip to content

Commit a36e61c

Browse files
baktun14stalniy
andcommitted
feat: chain sdk next api (#2023)
* refactor: migrate provider-proxy to next chain sdk (#1980) * feat(analytics): chain sdk next indexer (#1983) * feat(network): testnet deposit implementation * feat(analytics): implement new handlers for indexing * feat(analytics): add protobuf types from chain sdk for indexer * fix(analytics): remove test throw * feat: update chain-sdk indexer * feat: update net package * fix: net package testnet (#2016) fix: net config data * feat: implement new chain sdk types in api * fix: replace DepositAuthorization * fix: update http sdk + functional test envs * fix: undo frontend code changes * fix: balance calculation * fix: pr fixes * fix: gpu prices test * fix: tests * fix: fallback deployment tests * fix: stripe webhook tests * fix: balances test * fix: api structure for leases + tests * fix: lease fallback tests * fix: tests * fix: build fix * fix: faucet json * refactor: gets rid of akashjs and akash-api * fix: pr fixes for tests * fix: build * fix: sdl --------- Co-authored-by: Serhii Stotskyi <[email protected]>
1 parent 54dbbc5 commit a36e61c

File tree

79 files changed

+2505
-1659
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+2505
-1659
lines changed

apps/api/env/.env.functional.test

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
POSTGRES_URI=postgres://postgres:password@localhost:5432
22
UAKT_TOP_UP_MASTER_WALLET_MNEMONIC="since bread kind field rookie stairs elephant tent horror rice gain tongue collect goose rural garment cover client biology toe ability boat afford mind"
33
USDC_TOP_UP_MASTER_WALLET_MNEMONIC="leaf brush weapon puppy depart hockey walnut hospital orphan require unfair hunt ribbon toe cereal eagle hour door awesome dress mouse when phone return"
4-
NETWORK=sandbox
5-
RPC_NODE_ENDPOINT=https://rpc.sandbox-2.aksh.pw:443
4+
NETWORK=testnet
5+
RPC_NODE_ENDPOINT=https://testnetrpc.akashnet.net
66
TRIAL_DEPLOYMENT_ALLOWANCE_AMOUNT=20000000
77
DEPLOYMENT_ALLOWANCE_REFILL_AMOUNT=20000000
88
DEPLOYMENT_ALLOWANCE_REFILL_THRESHOLD=2000000
@@ -19,8 +19,8 @@ STRIPE_WEBHOOK_SECRET=STRIPE_WEBHOOK_SECRET
1919
ALLOWED_CHECKOUT_REFERRERS=["http://localhost:3000"]
2020
STRIPE_CHECKOUT_REDIRECT_URL=http://localhost:3000
2121
DEPLOYMENT_ENV=test
22-
FAUCET_URL=https://faucet.sandbox-2.aksh.pw/faucet
23-
API_NODE_ENDPOINT=https://api.sandbox-2.aksh.pw:443
22+
FAUCET_URL=https://faucet.dev.akash.pub/faucet
23+
API_NODE_ENDPOINT=https://testnetapi.akashnet.net
2424
PROVIDER_PROXY_URL=http://localhost:3040
2525

2626
AUTH0_ISSUER_HOST_WITH_DEFAULT=${AUTH0_ISSUER_HOST:-localhost}

apps/api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"dependencies": {
4040
"@akashnetwork/akash-api": "^1.3.0",
4141
"@akashnetwork/akashjs": "^0.11.1",
42-
"@akashnetwork/chain-sdk": "1.0.0-alpha.9",
42+
"@akashnetwork/chain-sdk": "^1.0.0-alpha.8",
4343
"@akashnetwork/database": "*",
4444
"@akashnetwork/env-loader": "*",
4545
"@akashnetwork/http-sdk": "*",

apps/api/src/address/services/address/address.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import type { Coin } from "@akashnetwork/chain-sdk/private-types/cosmos.v1beta1";
12
import { CosmosHttpService } from "@akashnetwork/http-sdk/src/cosmos/cosmos-http.service";
23
import { LoggerService } from "@akashnetwork/logging";
34
import { asset_lists } from "@chain-registry/assets";
4-
import type { Coin } from "cosmjs-types/cosmos/base/v1beta1/coin";
55
import { singleton } from "tsyringe";
66

77
import type { GetAddressResponse } from "@src/address/http-schemas/address.schema";

apps/api/src/bid/http-schemas/bid.schema.ts

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,13 @@ const DeploymentResource_V3 = z.object({
5858

5959
export const BidResponseSchema = z.object({
6060
bid: z.object({
61-
bid_id: z.object({
61+
id: z.object({
6262
owner: z.string(),
6363
dseq: z.string(),
6464
gseq: z.number(),
6565
oseq: z.number(),
66-
provider: z.string()
66+
provider: z.string(),
67+
bseq: z.number()
6768
}),
6869
state: z.string(),
6970
price: z.object({
@@ -83,21 +84,33 @@ export const BidResponseSchema = z.object({
8384
scope: z.string(),
8485
xid: z.string()
8586
}),
86-
owner: z.string(),
87-
state: z.string(),
88-
balance: z.object({
89-
denom: z.string(),
90-
amount: z.string()
91-
}),
92-
transferred: z.object({
93-
denom: z.string(),
94-
amount: z.string()
95-
}),
96-
settled_at: z.string(),
97-
depositor: z.string(),
98-
funds: z.object({
99-
denom: z.string(),
100-
amount: z.string()
87+
state: z.object({
88+
owner: z.string(),
89+
state: z.string(),
90+
transferred: z.array(
91+
z.object({
92+
denom: z.string(),
93+
amount: z.string()
94+
})
95+
),
96+
settled_at: z.string(),
97+
funds: z.array(
98+
z.object({
99+
denom: z.string(),
100+
amount: z.string()
101+
})
102+
),
103+
deposits: z.array(
104+
z.object({
105+
owner: z.string(),
106+
height: z.string(),
107+
source: z.string(),
108+
balance: z.object({
109+
denom: z.string(),
110+
amount: z.string()
111+
})
112+
})
113+
)
101114
})
102115
}),
103116
isCertificateRequired: z.boolean()

apps/api/src/bid/services/bid/bid.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class BidService {
3030
}
3131

3232
private async decorateWithCertRequirement<T extends Bid>(bid: T): Promise<T & { isCertificateRequired: boolean }> {
33-
const provider = await this.providerService.getProvider(bid.bid.bid_id.provider);
33+
const provider = await this.providerService.getProvider(bid.bid.id.provider);
3434
return {
3535
...bid,
3636
isCertificateRequired: !provider || !semver.valid(provider.akashVersion) || semver.lt(provider.akashVersion, BidService.JWT_AUTH_SUPPORT_VERSION)

apps/api/src/billing/config/env.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const envSchema = z.object({
1111
TRIAL_FEES_ALLOWANCE_AMOUNT: z.number({ coerce: true }),
1212
TRIAL_DEPLOYMENT_CLEANUP_HOURS: z.number({ coerce: true }).default(24),
1313
DEPLOYMENT_GRANT_DENOM: z.string(),
14-
GAS_SAFETY_MULTIPLIER: z.number({ coerce: true }).default(1.6),
14+
GAS_SAFETY_MULTIPLIER: z.number({ coerce: true }).default(1.8),
1515
AVERAGE_GAS_PRICE: z.number({ coerce: true }).default(0.0025),
1616
FEE_ALLOWANCE_REFILL_THRESHOLD: z.number({ coerce: true }),
1717
FEE_ALLOWANCE_REFILL_AMOUNT: z.number({ coerce: true }),

apps/api/src/billing/http-schemas/tx.schema.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ export const SignTxRequestInputSchema = z.object({
77
.array(
88
z.object({
99
typeUrl: z.enum([
10-
"/akash.deployment.v1beta3.MsgCreateDeployment",
11-
"/akash.cert.v1beta3.MsgCreateCertificate",
12-
"/akash.market.v1beta4.MsgCreateLease",
13-
"/akash.deployment.v1beta3.MsgUpdateDeployment",
14-
"/akash.deployment.v1beta3.MsgCloseDeployment",
15-
"/akash.deployment.v1beta3.MsgDepositDeployment"
10+
"/akash.deployment.v1beta4.MsgCreateDeployment",
11+
"/akash.cert.v1.MsgCreateCertificate",
12+
"/akash.market.v1beta5.MsgCreateLease",
13+
"/akash.deployment.v1beta4.MsgUpdateDeployment",
14+
"/akash.deployment.v1beta4.MsgCloseDeployment",
15+
"/akash.deployment.v1beta4.MsgDepositDeployment"
1616
]),
1717
value: z.string()
1818
})

apps/api/src/billing/lib/batch-signing-client/batch-signing-client.service.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import { TxRaw } from "@akashnetwork/chain-sdk/private-types/cosmos.v1beta1";
12
import { sha256 } from "@cosmjs/crypto";
23
import { toHex } from "@cosmjs/encoding";
34
import { Registry } from "@cosmjs/proto-signing";
45
import type { Account } from "@cosmjs/stargate";
5-
import { TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
66
import { mock } from "jest-mock-extended";
77

88
import type { ChainErrorService } from "@src/billing/services/chain-error/chain-error.service";

apps/api/src/billing/lib/batch-signing-client/batch-signing-client.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import { TxRaw } from "@akashnetwork/chain-sdk/private-types/cosmos.v1beta1";
12
import { LoggerService } from "@akashnetwork/logging";
23
import { sha256 } from "@cosmjs/crypto";
34
import { toHex } from "@cosmjs/encoding";
45
import type { EncodeObject, Registry } from "@cosmjs/proto-signing";
56
import { calculateFee, GasPrice } from "@cosmjs/stargate";
67
import type { IndexedTx } from "@cosmjs/stargate/build/stargateclient";
78
import { Sema } from "async-sema";
8-
import { TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
99
import DataLoader from "dataloader";
1010
import { backOff } from "exponential-backoff";
1111
import assert from "http-assert";
@@ -285,7 +285,7 @@ export class BatchSigningClientService {
285285
}
286286

287287
const gasEstimation = await this.simulate(messages, "");
288-
const estimatedGas = Math.round(gasEstimation * this.config.get("GAS_SAFETY_MULTIPLIER"));
288+
const estimatedGas = Math.ceil(gasEstimation * this.config.get("GAS_SAFETY_MULTIPLIER"));
289289

290290
const fee = calculateFee(estimatedGas, GasPrice.fromString(`${this.config.get("AVERAGE_GAS_PRICE")}${denom}`));
291291

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,32 @@
11
import "@src/utils/protobuf";
22

3-
import { getAkashTypeRegistry } from "@akashnetwork/akashjs/build/stargate";
3+
import * as v1 from "@akashnetwork/chain-sdk/private-types/akash.v1";
4+
import * as v1beta4 from "@akashnetwork/chain-sdk/private-types/akash.v1beta4";
5+
import * as v1beta5 from "@akashnetwork/chain-sdk/private-types/akash.v1beta5";
6+
import * as cosmosv1 from "@akashnetwork/chain-sdk/private-types/cosmos.v1";
7+
import * as cosmosv1alpha1 from "@akashnetwork/chain-sdk/private-types/cosmos.v1alpha1";
8+
import * as cosmosv1beta1 from "@akashnetwork/chain-sdk/private-types/cosmos.v1beta1";
9+
import * as cosmosv2alpha1 from "@akashnetwork/chain-sdk/private-types/cosmos.v2alpha1";
10+
import type { GeneratedType } from "@cosmjs/proto-signing";
411
import { Registry } from "@cosmjs/proto-signing";
5-
import { defaultRegistryTypes } from "@cosmjs/stargate";
12+
import type { InjectionToken } from "tsyringe";
613
import { container, inject } from "tsyringe";
714

8-
const registry = new Registry([...defaultRegistryTypes, ...getAkashTypeRegistry()]);
15+
const newAkashTypes: ReadonlyArray<[string, GeneratedType]> = [
16+
...Object.values(v1),
17+
...Object.values(v1beta4),
18+
...Object.values(v1beta5),
19+
...Object.values(cosmosv1),
20+
...Object.values(cosmosv1beta1),
21+
...Object.values(cosmosv1alpha1),
22+
...Object.values(cosmosv2alpha1)
23+
]
24+
.filter(x => "$type" in x)
25+
.map(x => ["/" + x.$type, x as unknown as GeneratedType]);
926

10-
export const TYPE_REGISTRY = "TYPE_REGISTRY";
27+
const registry = new Registry(newAkashTypes);
28+
29+
export const TYPE_REGISTRY: InjectionToken<Registry> = "TYPE_REGISTRY";
1130

1231
container.register(TYPE_REGISTRY, { useValue: registry });
1332
export const InjectTypeRegistry = () => inject(TYPE_REGISTRY);

0 commit comments

Comments
 (0)